8 October 2015 Numerical recipes understanding through optical applications
Author Affiliations +
Proceedings Volume 9793, Education and Training in Optics and Photonics: ETOP 2015; 97931Z (2015) https://doi.org/10.1117/12.2223189
Event: Education and Training in Optics and Photonics: ETOP 2015, 2015, Bordeaux, France
Usually mathematical abstractions are used as examples in teaching of general courses as well as in special courses such as numerical recipes. Using of examples from physics (or optics in particular) makes the course more interesting and understandable for students in optical engineering. In Applied and Computer Optics Department of ITMO University the course “Numerical Recipes in Optics” is studied via practical usage of optical image modeling and quality analysis. It helps to make studying of numerical recipes (such as numerical integration, approximation, fast Fourier transform etc.) more useful. Moreover it gives deeper understanding in mathematical models of physical processes. The most interesting exercises corresponding to different numerical recipes are presented in the paper.
Ivanova: Numerical recipes understanding through optical applications



Numerical recipes course is often in optical engineering curricula. It is necessary to be able to making numerical simulation for various physical processes, in particular in optics. Simple mathematical functions are usually using in exercises in such courses [1]. It gives to student good understanding of numerical recipes, their accuracy and others properties. However, we can see that it does not guarantee ability to use these recipes for practical calculations and connection between theory and its practical usage. In Applied and Computer Optics Department of ITMO University we use examples from optical image modeling and quality analysis as exercises. It makes studying of numerical recipes more useful from practical point of view, gives deeper understanding of optical processes and applications. Moreover we use interest to computer science for studying optics.

There are several studying numerical recipes:

  • numerical differentiation;

  • numerical integration;

  • interpolation;

  • approximation;

  • Fourier transform.



Numerical differentiation is the simplest numerical recipe, but it has useful application in aberration theory. It is well known that the first derivation of wave aberration by pupil coordinate is a lateral aberration, and the second derivation is a longitudinal aberration [2]. Usually wave aberration is described with Zernike polynomials:


where ρ, φ polar pupil coordinates, m - power of φ, n - power of ρ, cnm - coefficient (shows contribution of each aberration type), 00053_psisdg9793_97931Z_page_1_2.jpg - radial polynomial.

As exercise each student gets his own set of Zernike polynomials for differentiation, and calculates the first and the second derivative (in fact lateral and longitudinal aberrations) by forward and central difference methods. Also student evaluates accuracy of computation as difference between values calculated by numerical recipe and by analytical derivation.

Thus in additions to methods of numerical differentiation students also study practical usage of Zernike polynomials and mathematical connection between wave, lateral, and longitudinal aberrations.

Example of exercise:

Calculate first and second derivation of wave aberration function W(ρx, ρy) by ρx and ρy in the interval ρ ∈ [−1;1] by forward and central difference methods in case only 3-order spherical aberration is presented:

00053_psisdg9793_97931Z_page_2_5.jpg, where 00053_psisdg9793_97931Z_page_2_4.jpg, coefficient c40=1.

Draw plots of wave, lateral and longitudinal aberrations, calculated by numerical recipes and analytically. Draw plot of final accuracy form differentiation step.

Solution of exercise:

Figure 1.

Example of result plots of wave, lateral, and longitudinal aberrations.




In numerical integration part we study Gaussian method and Newton-Cotes method. For studying accuracy of these methods we use simple mathematical function (cos for example). Good example of using numerical integration in optics is calculation of encircled energy by point spread function:


where 00053_psisdg9793_97931Z_page_2_6.jpg - point spread function, 00053_psisdg9793_97931Z_page_2_7.jpg - canonical coordinates on image.

Example of exercise:

  • 1. Calculate integral 00053_psisdg9793_97931Z_page_2_3.jpg by Newton-Cotes method (1-5 order) and Gaussian method (1-6 order). Draw plot of accuracy from number of points for various degrees of Newton-Cotes method and Gaussian method.

  • 2. Calculate encircled energy by given point spread function by 1st order Newton-Cotes method. Draw plots of encircled energy and point spread function.


Task solution example

Figure 2.

Example of result plots for point spread function and encircled energy.




In approximation recipe we study least squares method. An optical example is approximation of index of refraction. If we know several indices of refraction for glass, we can calculate coefficients of Herzberger dispersion formula [3]:


where 00053_psisdg9793_97931Z_page_3_5.jpg, 00053_psisdg9793_97931Z_page_3_6.jpg. It is enough to know the six values of refraction index for calculating of coefficients μ1, …, μ6 for one glass, but it could be more.

A system of linear equations in matrix for m ≥ 6 refraction indexes is:


where 00053_psisdg9793_97931Z_page_3_7.jpg are known values of refraction index for wavelengths λi, m is number of known refraction indices, μ1, …, μ6 are coefficients of Herzberger dispersion formula.

Using least squares method for the system of linear equations (4):


Example of exercise:

The known index of refraction values for optical glass F2 are ni = 1.662241, nF = 1.628440, ne = 1.620541, nC = 1.611600, nr = 1.608862, nt = 1.599483. Develop index of refraction calculation procedure for wavelength from 0.3 to 2 um. Calculate indexes of refraction for λh = 0.40466 um, λd = 0.58756 um, λspec = 0.64380 um. Check calculation in http://glassbank.ifmo.ru.

Solution of exercise:

Calculated index of refraction values: nλh = 1.6467860, nλd = 1.6165512, nλspec = 1.6123803. Reference index of refraction values [2]: nλh = 1.6468077, nλd = 1.6165511, nλspec = 1.6123800. Those, calculation accuracy is less than 10−5.



The most interesting optical application of numerical recipe is Fourier transform [4]. For studying Fourier transform and its properties we use typical function (delta-function, rectangle, etc.). As simple optical example we use calculation of point spread function by given pupil function. There are variety of tasks with complicated area of pupil (central obscuration, synthetic aperture), pupil with non-uniform transmission or with given types of aberrations (specified with Zernike polynomials). Additionally we are considering normalization problem for PSF calculation:


where f(ρx, ρy) - pupil function, H′ - normalization factor. Pupil function is:


where τ(ρxy) - transmission, W(ρxy) - wave aberration, Ω0 - pupil area in canonical coordinates. Normalization factor is:


Example of exercise:

  • 1. Calculate spectrum of function 1 + cos(2πx) by 1D Fourier transform.

  • 2. Calculate spectrum of function 00053_psisdg9793_97931Z_page_4_4.jpg by 2D Fourier transform.

  • 3. Calculate PSF of optical system with central obscuration f(ρxy) = circ(ρ) − circ(ρ/ε), ε = 0.6. Compare result with PSF of optical system with round pupil.

Solution of exercise:

Figure 3.

Perfect optical system PSF and PSF of optical system with central obscuration.



As we can see, it is a lot of interesting and useful examples in optics for using them in numerical recipes course. It makes studying of numerical recipes more useful from practical point of view. Also it gives deeper understanding of optical processes and applications. Our experience shows that it really works. After this course student use numerical recipes with confidence in other courses, in bachelor and master thesis, and later in profession.



William H. Press, Saul A. Teukolsky, William T. Vetterling, Brian P. Flannery. Numerical Recipes: The Art of Scientific Computing (3rd Edition). Cambridge University Press, 2007Google Scholar


Born M., Wolf E. Principles of Optics. Cambridge University Press, 1999Google Scholar


Bach H., Neuroth N. The Properties of Optical Glass. Springer Science & Business Media, 2012Google Scholar


Goodman J.W. Introduction to Fourier Optics. McGraw-Hill, 1996Google Scholar

© (2015) COPYRIGHT Society of Photo-Optical Instrumentation Engineers (SPIE). Downloading of the abstract is permitted for personal use only.
Tatiana Ivanova, "Numerical recipes understanding through optical applications", Proc. SPIE 9793, Education and Training in Optics and Photonics: ETOP 2015, 97931Z (8 October 2015); doi: 10.1117/12.2223189; https://doi.org/10.1117/12.2223189

Back to Top