qnm.contfrac¶
Infinite continued fractions via Lentz’s method.
TODO Documentation.
Functions
lentz (a, b[, tol, N_min, N_max, tiny]) |
Compute a continued fraction via modified Lentz’s method. |
lentz_gen (a, b[, tol, N_min, N_max, tiny]) |
Compute a continued fraction via modified Lentz’s method, using generators rather than functions. |
-
qnm.contfrac.
lentz
(a, b, tol=1e-10, N_min=0, N_max=inf, tiny=1e-30)[source]¶ Compute a continued fraction via modified Lentz’s method.
This implementation is by the book [1].
Parameters: - a: callable returning numeric.
- b: callable returning numeric.
- tol: float [default: 1.e-10]
Tolerance for termination of evaluation.
- N_min: int [default: 0]
Minimum number of iterations to evaluate.
- N_max: int or comparable [default: np.Inf]
Maximum number of iterations to evaluate.
- tiny: float [default: 1.e-30]
Very small number to control convergence of Lentz’s method when there is cancellation in a denominator.
Returns: - (float, float, int)
The first element of the tuple is the value of the continued fraction. The second element is the estimated error. The third element is the number of iterations.
References
[1] WH Press, SA Teukolsky, WT Vetterling, BP Flannery, “Numerical Recipes,” 3rd Ed., Cambridge University Press 2007, ISBN 0521880688, 9780521880688 .
-
qnm.contfrac.
lentz_gen
(a, b, tol=1e-10, N_min=0, N_max=inf, tiny=1e-30)[source]¶ Compute a continued fraction via modified Lentz’s method, using generators rather than functions.
This implementation is by the book [1].
Parameters: - a: generator yielding numeric.
- b: generator yielding numeric.
- tol: float [default: 1.e-10]
Tolerance for termination of evaluation.
- N_min: int [default: 0]
Minimum number of iterations to evaluate.
- N_max: int or comparable [default: np.Inf]
Maximum number of iterations to evaluate.
- tiny: float [default: 1.e-30]
Very small number to control convergence of Lentz’s method when there is cancellation in a denominator.
Returns: - (float, float, int)
The first element of the tuple is the value of the continued fraction. The second element is the estimated error. The third element is the number of iterations.
References
[1] WH Press, SA Teukolsky, WT Vetterling, BP Flannery, “Numerical Recipes,” 3rd Ed., Cambridge University Press 2007, ISBN 0521880688, 9780521880688 .