## 1.

## INTRODUCTION

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:

## 2.

## NUMERICAL DIFFERENTIATION RECIPE

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 *ρ*, *c _{nm}* - coefficient (shows contribution of each aberration type), - 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

*ρ*and

_{x}*ρ*in the interval

_{y}*ρ*∈ [−1;1] by forward and central difference methods in case only 3-order spherical aberration is presented:

, where , coefficient *c*_{40}=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:**

## 3.

## NUMERICAL INTEGRATION RECIPE

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 - point spread function, - canonical coordinates on image.

**Example of exercise:**

1. Calculate integral 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 1

^{st}order Newton-Cotes method. Draw plots of encircled energy and point spread function.

## 4.

## APPROXIMATION RECIPE

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 , . 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 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 *n _{i}* = 1.662241,

*n*= 1.628440,

_{F}*n*= 1.620541,

_{e}*n*= 1.611600,

_{C}*n*= 1.608862,

_{r}*n*= 1.599483. Develop index of refraction calculation procedure for wavelength from 0.3 to 2 um. Calculate indexes of refraction for

_{t}*λ*= 0.40466 um,

_{h}*λ*= 0.58756 um,

_{d}*λ*= 0.64380 um. Check calculation in http://glassbank.ifmo.ru.

_{spec}**Solution of exercise:**

Calculated index of refraction values: *n _{λh}* = 1.6467860,

*n*= 1.6165512,

_{λd}*n*= 1.6123803. Reference index of refraction values [2]:

_{λspec}*n*= 1.6468077,

_{λh}*n*= 1.6165511,

_{λd}*n*= 1.6123800. Those, calculation accuracy is less than 10

_{λspec}^{−5}.

## 5.

## FAST FOURIER TRANSFORM RECIPE

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 *τ*(*ρ _{x},ρ_{y}*) - transmission,

*W*(

*ρ*) - wave aberration, Ω

_{x},ρ_{y}_{0}- pupil area in canonical coordinates. Normalization factor is:

**Example of exercise:**

**Solution of exercise:**

## CONCLUSIONS

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.

## REFERENCES

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