Liking cljdoc? Tell your friends :D
Clojure only.

fastmath.solver.fixed-point

Fixed point iteration for a solution of g(x) = x.

The iteration x -> g(x) converges to a fixed point when g is a contraction near it, with a linear rate |g'|. The optional Steffensen acceleration (Aitken's delta squared process applied to every second step) converges quadratically when the plain iteration converges. Unlike the root finders, the method needs a start and no bracket: it fails with the status :diverged when the iterates stop being finite or do not converge within the limit.

Fixed point iteration for a solution of `g(x) = x`.

The iteration `x -> g(x)` converges to a fixed point when `g` is a contraction near it, with a linear rate `|g'|`. The optional Steffensen acceleration (Aitken's delta squared process applied to every second step) converges quadratically when the plain iteration converges. Unlike the root finders, the method needs a start and no bracket: it fails with the status `:diverged` when the iterates stop being finite or do not converge within the limit.
raw docstring

fixed-pointclj

(fixed-point g x0)
(fixed-point g x0 options)

Finds a fixed point of g, a solution of g(x) = x, by iteration from x0.

Parameters:

  • g (function): a function of one number returning a number.
  • x0 (finite number): the start.
  • options (map, optional):
    • :steffensen? - when truthy, uses the Steffensen acceleration; each step costs two evaluations. Default false.
    • :absolute-accuracy - absolute tolerance, default 1.0e-300.
    • :relative-accuracy - tolerance relative to the result, default four times the machine epsilon. The iteration stops when the step is within absolute + relative * |x|.
    • :max-iters - limit of evaluations of g (an integer), default 1200. Exceeding it throws.
    • :info? - when truthy, returns the map {:root :evaluations :status} instead of the fixed point, and returns the failure status instead of throwing. Default false.

Returns the fixed point as a double. The step size is the only stopping rule: a small step of a slowly converging iteration (a rate close to 1) does not mean a small error. The error is about step * rate / (1 - rate).

Throws ex-info for an invalid argument, and for a failed iteration: iterates which are not finite (:status :diverged), NaN values of g (:nan), a non number result (:invalid-result) or the evaluation limit (:max-evals, which is also the result of a diverging or oscillating iteration). The data of the exception holds the :status and a few scalars.

See also fastmath.solver/find-root, fastmath.solver.newton/newton.

Finds a fixed point of `g`, a solution of `g(x) = x`, by iteration from `x0`.

Parameters:

- `g` (function): a function of one number returning a number.
- `x0` (finite number): the start.
- `options` (map, optional):
    - `:steffensen?` - when truthy, uses the Steffensen acceleration; each step costs two evaluations. Default `false`.
    - `:absolute-accuracy` - absolute tolerance, default `1.0e-300`.
    - `:relative-accuracy` - tolerance relative to the result, default four times the machine epsilon. The iteration stops when the step is within `absolute + relative * |x|`.
    - `:max-iters` - limit of evaluations of `g` (an integer), default `1200`. Exceeding it throws.
    - `:info?` - when truthy, returns the map `{:root :evaluations :status}` instead of the fixed point, and returns the failure status instead of throwing. Default `false`.

Returns the fixed point as a double. The step size is the only stopping rule: a small step of a slowly converging iteration (a rate close to 1) does not mean a small error. The error is about `step * rate / (1 - rate)`.

Throws `ex-info` for an invalid argument, and for a failed iteration: iterates which are not finite (`:status :diverged`), `NaN` values of `g` (`:nan`), a non number result (`:invalid-result`) or the evaluation limit (`:max-evals`, which is also the result of a diverging or oscillating iteration). The data of the exception holds the `:status` and a few scalars.

See also [[fastmath.solver/find-root]], [[fastmath.solver.newton/newton]].
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