Divided differences of a function at given nodes, with repeated nodes (Hermite, confluent divided differences).
The divided difference f[x0, x1, ..., xn] is the leading coefficient of the Newton interpolation polynomial through the nodes. When nodes are repeated, the polynomial interpolates also the derivatives and the divided difference of k + 1 equal nodes is f^(k)(x) / k!. The derivatives are given by the user or approximated with finite differences.
Functions: divided (the highest divided difference only) and divided-all (all levels of the table).
Divided differences of a function at given nodes, with repeated nodes (Hermite, confluent divided differences). The divided difference `f[x0, x1, ..., xn]` is the leading coefficient of the Newton interpolation polynomial through the nodes. When nodes are repeated, the polynomial interpolates also the derivatives and the divided difference of `k + 1` equal nodes is `f^(k)(x) / k!`. The derivatives are given by the user or approximated with finite differences. Functions: [[divided]] (the highest divided difference only) and [[divided-all]] (all levels of the table).
(divided f xs)(divided f xs {:keys [derivatives]})Divided difference f[x0, x1, ..., xn] of f at the nodes xs, the highest level of the table.
It is the leading coefficient of the Newton interpolation polynomial through the nodes. Repeated nodes are allowed and give the Hermite (confluent) divided differences: for k + 1 equal nodes the value is f^(k)(x) / k!.
Parameters:
f (function): the function of a node. A vector or a map (lookup by the node) is also accepted as f, but then the nodes have to be distinct or :derivatives has to be given.xs (sequence of numbers): the nodes, at least one. Equal nodes must be adjacent.options (map, optional):
:derivatives - sequence of functions [f' f'' ...] giving the derivatives of f; the element k - 1 is the k-th derivative. It has to contain the derivatives up to the order of the longest run of equal nodes minus one. When it is not given, the derivatives are approximated with fastmath.calculus.finite/derivative with Richardson extrapolation (:extrapolate? true) started with the step 0.5 (divided by 10, up to 8 times, when f is not finite so far from the node). It is accurate to about 1e-6 or better for the first and the second derivative of smooth functions, and gets worse for higher orders. f has to be a smooth function of a double.Returns the divided difference as a double. For a single node it is f(x0).
Throws ex-info with {:option :value :expected} when xs is empty, equal nodes are not adjacent, f is not callable, f is not a function while nodes are repeated and :derivatives is not given, or :derivatives is too short.
See also divided-all.
Divided difference `f[x0, x1, ..., xn]` of `f` at the nodes `xs`, the highest level of the table.
It is the leading coefficient of the Newton interpolation polynomial through the nodes. Repeated nodes are allowed and give the Hermite (confluent) divided differences: for `k + 1` equal nodes the value is `f^(k)(x) / k!`.
Parameters:
- `f` (function): the function of a node. A vector or a map (lookup by the node) is also accepted as `f`, but then the nodes have to be distinct or `:derivatives` has to be given.
- `xs` (sequence of numbers): the nodes, at least one. Equal nodes must be adjacent.
- `options` (map, optional):
- `:derivatives` - sequence of functions `[f' f'' ...]` giving the derivatives of `f`; the element `k - 1` is the `k`-th derivative. It has to contain the derivatives up to the order of the longest run of equal nodes minus one. When it is not given, the derivatives are approximated with [[fastmath.calculus.finite/derivative]] with Richardson extrapolation (`:extrapolate? true`) started with the step `0.5` (divided by 10, up to 8 times, when `f` is not finite so far from the node). It is accurate to about 1e-6 or better for the first and the second derivative of smooth functions, and gets worse for higher orders. `f` has to be a smooth function of a double.
Returns the divided difference as a double. For a single node it is `f(x0)`.
Throws `ex-info` with `{:option :value :expected}` when `xs` is empty, equal nodes are not adjacent, `f` is not callable, `f` is not a function while nodes are repeated and `:derivatives` is not given, or `:derivatives` is too short.
See also [[divided-all]].(divided-all f xs)(divided-all f xs {:keys [derivatives]})Divided differences of f at the nodes xs: all levels of the divided differences table.
The level k consists of the divided differences f[x_i, ..., x_(i+k)] of k + 1 consecutive nodes. Repeated nodes are allowed and give the Hermite (confluent) divided differences: for k + 1 equal nodes the value is f^(k)(x) / k!.
Parameters:
f (function): the function of a node. A vector or a map (lookup by the node) is also accepted as f, but then the nodes have to be distinct or :derivatives has to be given.xs (sequence of numbers): the nodes, at least one. Equal nodes must be adjacent.options (map, optional):
:derivatives - sequence of functions [f' f'' ...] giving the derivatives of f; the element k - 1 is the k-th derivative. It has to contain the derivatives up to the order of the longest run of equal nodes minus one. When it is not given, the derivatives are approximated with fastmath.calculus.finite/derivative with Richardson extrapolation (:extrapolate? true) started with the step 0.5 (divided by 10, up to 8 times, when f is not finite so far from the node). It is accurate to about 1e-6 or better for the first and the second derivative of smooth functions, and gets worse for higher orders. f has to be a smooth function of a double.Returns a list of levels in the order from the highest to the lowest: the first element is a list with the single divided difference of all nodes, the last element is the list of the values of f at the nodes. Every level is a list of doubles. For a single node the result is ((f(x0))). The first (highest) element is the value returned by divided.
Throws ex-info with {:option :value :expected} when xs is empty, equal nodes are not adjacent, f is not callable, f is not a function while nodes are repeated and :derivatives is not given, or :derivatives is too short.
See also divided.
Divided differences of `f` at the nodes `xs`: all levels of the divided differences table.
The level `k` consists of the divided differences `f[x_i, ..., x_(i+k)]` of `k + 1` consecutive nodes. Repeated nodes are allowed and give the Hermite (confluent) divided differences: for `k + 1` equal nodes the value is `f^(k)(x) / k!`.
Parameters:
- `f` (function): the function of a node. A vector or a map (lookup by the node) is also accepted as `f`, but then the nodes have to be distinct or `:derivatives` has to be given.
- `xs` (sequence of numbers): the nodes, at least one. Equal nodes must be adjacent.
- `options` (map, optional):
- `:derivatives` - sequence of functions `[f' f'' ...]` giving the derivatives of `f`; the element `k - 1` is the `k`-th derivative. It has to contain the derivatives up to the order of the longest run of equal nodes minus one. When it is not given, the derivatives are approximated with [[fastmath.calculus.finite/derivative]] with Richardson extrapolation (`:extrapolate? true`) started with the step `0.5` (divided by 10, up to 8 times, when `f` is not finite so far from the node). It is accurate to about 1e-6 or better for the first and the second derivative of smooth functions, and gets worse for higher orders. `f` has to be a smooth function of a double.
Returns a list of levels in the order from the highest to the lowest: the first element is a list with the single divided difference of all nodes, the last element is the list of the values of `f` at the nodes. Every level is a list of doubles. For a single node the result is `((f(x0)))`. The first (highest) element is the value returned by [[divided]].
Throws `ex-info` with `{:option :value :expected}` when `xs` is empty, equal nodes are not adjacent, `f` is not callable, `f` is not a function while nodes are repeated and `:derivatives` is not given, or `:derivatives` is too short.
See also [[divided]].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 |