Algorithm 748 (TOMS748) of Alefeld, Potra and Shi for a root of a function on an interval with a sign change.
The method encloses the root in a shrinking bracket and uses inverse cubic interpolation (a quadratic step when the values are too close), a double length secant step and, when the bracket does not shrink fast enough, a bisection step. It needs the fewest evaluations of the bracketing methods in this library on smooth functions (convergence order about 1.65 per evaluation) and keeps the guarantees of the bisection.
Algorithm 748 (TOMS748) of Alefeld, Potra and Shi for a root of a function on an interval with a sign change. The method encloses the root in a shrinking bracket and uses inverse cubic interpolation (a quadratic step when the values are too close), a double length secant step and, when the bracket does not shrink fast enough, a bisection step. It needs the fewest evaluations of the bracketing methods in this library on smooth functions (convergence order about 1.65 per evaluation) and keeps the guarantees of the bisection.
(toms748 f lower upper)(toms748 f lower upper options)Finds a root of f on [lower, upper] with Algorithm 748 (TOMS748).
Parameters:
f (function): a function of one number returning a number; it has to change the sign on the interval.lower, upper (finite numbers): ends of the interval; reversed ends are swapped.options (map, optional):
:absolute-accuracy - absolute tolerance of the root, default 1.0e-300.:relative-accuracy - tolerance relative to the root, default four times the machine epsilon. The root is found within absolute + relative * |root|.:max-iters - limit of function evaluations (an integer), default 1200. Exceeding it throws.:initial-value - ignored by this method.:info? - when truthy, returns the map {:root :evaluations :status} instead of the root, and returns the failure status instead of throwing. Default false.Returns the root as a double, the end of the final bracket with the smaller absolute value of the function. A root at an end of the interval is returned after at most two evaluations.
Throws ex-info for an invalid argument, and for a failed solve: no sign change on the interval (:status :no-bracket), NaN function values (:nan), a non number result (:invalid-result) or the evaluation limit (:max-evals). The data of the exception holds the :status and a few scalars.
See also fastmath.solver/find-root, fastmath.solver.brent/brent, fastmath.solver.bisection/bisection.
Finds a root of `f` on `[lower, upper]` with Algorithm 748 (TOMS748).
Parameters:
- `f` (function): a function of one number returning a number; it has to change the sign on the interval.
- `lower`, `upper` (finite numbers): ends of the interval; reversed ends are swapped.
- `options` (map, optional):
- `:absolute-accuracy` - absolute tolerance of the root, default `1.0e-300`.
- `:relative-accuracy` - tolerance relative to the root, default four times the machine epsilon. The root is found within `absolute + relative * |root|`.
- `:max-iters` - limit of function evaluations (an integer), default `1200`. Exceeding it throws.
- `:initial-value` - ignored by this method.
- `:info?` - when truthy, returns the map `{:root :evaluations :status}` instead of the root, and returns the failure status instead of throwing. Default `false`.
Returns the root as a double, the end of the final bracket with the smaller absolute value of the function. A root at an end of the interval is returned after at most two evaluations.
Throws `ex-info` for an invalid argument, and for a failed solve: no sign change on the interval (`:status :no-bracket`), `NaN` function values (`:nan`), a non number result (`:invalid-result`) or the evaluation limit (`:max-evals`). The data of the exception holds the `:status` and a few scalars.
See also [[fastmath.solver/find-root]], [[fastmath.solver.brent/brent]], [[fastmath.solver.bisection/bisection]].cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |