Lentz's algorithm

In mathematics, Lentz's algorithm is an algorithm to evaluate continued fractions and compute tables of spherical Bessel functions.

The version usually employed now is due to Thompson and Barnett.

History
The idea was introduced in 1973 by William J. Lentz and was simplified by him in 1982. Lentz suggested that calculating ratios of spherical Bessel functions of complex arguments can be difficult. He developed a new continued fraction technique for calculating the ratios of spherical Bessel functions of consecutive order. This method was an improvement compared to other methods because it started from the beginning of the continued fraction rather than the tail, had a built-in check for convergence, and was numerically stable. The original algorithm uses algebra to bypass a zero in either the numerator or denominator. Simpler Improvements to overcome unwanted zero terms include an altered recurrence relation suggested by Jaaskelainen and Ruuskanen in 1981 or a simple shift of the denominator by a very small number as suggested by Thompson and Barnett in 1986.

Initial work
This theory was initially motivated by Lentz's need for accurate calculation of ratios of spherical Bessel function necessary for Mie scattering. He created a new continued fraction algorithm that starts from the beginning of the continued fraction and not at the tail-end. This eliminates guessing how many terms of the continued fraction are needed for convergence. In addition, continued fraction representations for both ratios of Bessel functions and spherical Bessel functions of consecutive order themselves can be computed with Lentz's algorithm. The algorithm suggested that it is possible to terminate the evaluation of continued fractions when $$|f_j-f_{j-1} |$$ is relatively small.

Algorithm
Lentz's algorithm is based on the Wallis-Euler relations. If


 * $${f}_{0} = {b}_{0}$$


 * $${f}_{1} = {b}_{0} + \frac{{a}_{1}}{{b}_{1}}$$


 * $${f}_{2} = {b}_{0} + \frac{{a}_{1}}{{b}_{1} + \frac{{a}_{2}}{{b}_{2}}}$$


 * $${f}_{3} = {b}_{0} + \frac{{a}_{1}}{{b}_{1} + \frac{{a}_{2}}{{b}_{2} + \frac{{a}_{3}}{{b}_{3}}}}$$

etc., or using the big-K notation, if


 * $${f}_{n} = {b}_{0} + \underset{j = 1}\overset{n}\operatorname{K}\frac{{a}_{j}}{{b}_{j} +}$$

is the $$n$$th convergent to $$f$$ then


 * $${f}_{n} = \frac{{A}_{n}}{{B}_{n}}$$

where $${A}_{n}$$ and $${B}_{n}$$ are given by the Wallis-Euler recurrence relations


 * $${A}_{- 1} = 1$$


 * $${B}_{- 1} = 0$$


 * $${A}_{0} = {b}_{0}$$


 * $${B}_{0} = 1$$


 * $${A}_{n} = {b}_{n} {A}_{n - 1} + {a}_{n} {A}_{n - 2}$$


 * $${B}_{n} = {b}_{n} {B}_{n - 1} + {a}_{n} {B}_{n - 2}$$

Lentz's method defines


 * $${C}_{n} = \frac{{A}_{n}}{{A}_{n - 1}}$$


 * $${D}_{n} = \frac{{B}_{n - 1}}{{B}_{n}}$$

so that the $$n$$th convergent is


 * $${f}_{n} = {C}_{n} {D}_{n} {f}_{n - 1}$$

and uses the recurrence relations


 * $${C}_{0} = \frac{{A}_{0}}{{A}_{- 1}} = {b}_{0}$$


 * $${D}_{0} = \frac{{B}_{- 1}}{{B}_{0}} = 0$$


 * $${f}_{0} = {b}_{0}$$


 * $${C}_{n} = {b}_{n} + \frac{{a}_{n}}{{C}_{n - 1}}$$


 * $${D}_{n} = \frac{1}{{b}_{n} + {a}_{n} {D}_{n - 1}}$$

When the product $${C}_{n} {D}_{n}$$ approaches unity with increasing $$n$$, it is hoped that $${f}_{n}$$ has converged to $$f$$.

Applications
Lentz's algorithm was used widely in the late twentieth century. It was suggested that it doesn't have any rigorous analysis of error propagation. However, a few empirical tests suggest that it's at least as good as the other methods. As an example, it was applied to evaluate exponential integral functions. This application was then called modified Lentz algorithm. It's also stated that the Lentz algorithm is not applicable for every calculation, and convergence can be quite rapid for some continued fractions and vice versa for others.