Liking cljdoc? Tell your friends :D
Clojure only.

fastmath.solver.muller2

Muller's method for a root of a function on an interval, without a bracket.

The classic Muller iteration: a parabola through the last three points, starting from the ends and the middle of the interval. The bracket is not kept, so the iteration is faster than the bracketing one but can run away: an iterate which leaves the interval, or a step which converged to a point which is not a root, throws. A parabola without real roots moves to its vertex, a flat parabola to a bisection step of the sign change seen so far.

Muller's method for a root of a function on an interval, without a bracket.

The classic Muller iteration: a parabola through the last three points, starting from the ends and the middle of the interval. The bracket is not kept, so the iteration is faster than the bracketing one but can run away: an iterate which leaves the interval, or a step which converged to a point which is not a root, throws. A parabola without real roots moves to its vertex, a flat parabola to a bisection step of the sign change seen so far.
raw docstring

muller2clj

(muller2 f lower upper)
(muller2 f lower upper options)

Finds a root of f on [lower, upper] with Muller's method, without a bracket.

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. The interval is also the limit of the search.
  • 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. A root at an end of the interval is returned after at most two evaluations. The search stops when the step is within the tolerance and the function changes the sign within two tolerances of the point.

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), the evaluation limit (:max-evals) or a runaway iteration (:diverged): the iterate leaves the interval, or the step converged to a point which is not a root. The data of the exception holds the :status and a few scalars.

See also fastmath.solver/find-root, fastmath.solver.muller/muller, fastmath.solver.secant/secant.

Finds a root of `f` on `[lower, upper]` with Muller's method, without a bracket.

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. The interval is also the limit of the search.
- `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. A root at an end of the interval is returned after at most two evaluations. The search stops when the step is within the tolerance and the function changes the sign within two tolerances of the point.

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`), the evaluation limit (`:max-evals`) or a runaway iteration (`:diverged`): the iterate leaves the interval, or the step converged to a point which is not a root. The data of the exception holds the `:status` and a few scalars.

See also [[fastmath.solver/find-root]], [[fastmath.solver.muller/muller]], [[fastmath.solver.secant/secant]].
raw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
←Move to previous article
→Move to next article
Ctrl+/Jump to the search field
× close