# Scattering of Gaussian beams by a spherical particle

## Overflow problems

Previous pages have examined the choice of parameters for Gaussian beam calculations using Mie theory and the Debye series. However, in practice, other difficulties often arise with calculations for large spheres (e.g. r >= 1000 μm) or for very narrow Gaussian beams.

One problem is that the numerical values of intermediate results can exceed the program's permitted range: for example, as MiePlot uses double precision for most of its variables, the absolute value of any variable must be less than about 10308. If this limit is exceeded, the program will crash due to an "overflow" problem.

Various steps can be taken to avoid overflow problems: for example, consider evaluation of a simple equation such as d = (a * b) / c. If all 3 of the variables a,b and c have a value of 10200, the result should be d = 10200. However, the intermediate result of (a * b) = 10400 exceeds the double precision limit of 10308, thus causing the program to crash.   In this case, it is simple to rearrange the order of the equation to d = (a / c) * b and avoid this particular type of overflow.

Other types of overflow are much more difficult to avoid in, for example, evaluation of the following equation: Equation 12 from Lock's 1995 paper
Reproduced by kind permission of J. A. Lock ©

Note that this equation involves:
• Exponents of j, (j - p) and p
• Factorials of (j - p) and p
The above equation (which is used to calculate the beam shape coefficients) must be evaluated for integer values of j from j = 1 to jmax. As p is also a positive integer, j - p < j, resulting in overflow problems when j is very large and p = 0.    In Lock's 1993 paper, jmax = 21 was used - but much higher values of jmax can be required for other conditions, such as very narrow beams.

Note that j! exceeds the double precision limit of 10308 when j = 171. For this reason, it is convenient to set jmax = 170 as in Fig. 1 below. Fig. 1   Comparison of Mie theory and Young mod. calculations (for p = 0 through p = 12) for scattering of light from a sphere of radius 1000 μm and refractive index n = 1.336, refractive index of medium = 1, λ = 0.5145 μm, Gaussian beam: x0 = 0, y0 = -950 μm, z0 = 0, ω0 = 200 μm.
N.B. The Mie calculations used a fixed value of jmax = 170.

Fig. 1 compares Mie calculations with jmax = 170 with the modified version of Young's method. Note that there are significant differences between the red and blue curves - even where ray tracing should be reasonably accurate (e.g. in the range 30° < θ < 80° where p = 1 scattering is dominant). Fig. 2   Comparison of Mie theory calculations for scattering of light from a sphere of radius 1000 μm and refractive index n = 1.336, refractive index of medium = 1, λ = 0.5145 μm, Gaussian beam: x0 = 0, y0 = -950 μm, z0 = 0, ω0 = 200 μm.
N.B. In one case, the value of Jmax = 170 whilst in the other case Jmax was adjusted dynamically - its maximum value was 573.

Special measures in MiePlot have been taken to handle variables that exceed the double precision limit of 10308. Consequently, MiePlot can handle values of jmax > 170. In practice, MiePlot sets the value of jmax dynamically for each value of l and m. The blue curves in Fig. 2 show the results obtained with jmax = 170, whilst the red curves show the results when jmax is unconstrained by overflow issues - in this particular case, the maximum value of jmax = 573. Note that the red curves in Fig. 2 are very close to the red curves shown in Fig. 1, thus again emphasising the value of ray tracing as an independent check on the accuracy of the algorithms for Mie and Debye series calculations. Users of MiePlot can easily perform such checks by selecting Young (mod.) as the calculation method and setting p = -12 (to plot the vector sum of calculations from p = 0 through p = 12).

Page updated on 9 April 2008