Liking cljdoc? Tell your friends :D

sicmutils.numerical.derivative

Different numerical derivative implementations.

Different numerical derivative implementations.
raw docstring

backward-differenceclj/s

(backward-difference f x)
(backward-difference f x fx)

Returns a single-variable function of a step size h that calculates the backward-difference estimate of the first derivative of f at point x:

f'(x) = [f(x) - f(x - h)] / h

Optionally accepts a third argument fx == (f x), in case you've already calculated it elsewhere and would like to save a function evaluation.

Returns a single-variable function of a step size `h` that calculates the
backward-difference estimate of the first derivative of `f` at point `x`:

f'(x) = [f(x) - f(x - h)] / h

Optionally accepts a third argument `fx == (f x)`, in case you've already
calculated it elsewhere and would like to save a function evaluation.
sourceraw docstring

central-differenceclj/s

(central-difference f x)

Returns a single-variable function of a step size h that calculates the central-difference estimate of the first derivative of f at point x:

f'(x) = [f(x + h) - f(x - h)] / 2h

Returns a single-variable function of a step size `h` that calculates the
central-difference estimate of the first derivative of `f` at point `x`:

f'(x) = [f(x + h) - f(x - h)] / 2h
sourceraw docstring

central-difference-d2clj/s

(central-difference-d2 f x)
(central-difference-d2 f x fx)

Returns a single-variable function of a step size h that calculates the central-difference estimate of the second derivative of f at point x:

f''(x) = [f(x + h) - 2f(x) + f(x - h)] / h^2

Optionally accepts a third argument fx == (f x), in case you've already calculated it elsewhere and would like to save a function evaluation.

Returns a single-variable function of a step size `h` that calculates the
central-difference estimate of the second derivative of `f` at point `x`:

f''(x) = [f(x + h) - 2f(x) + f(x - h)] / h^2

Optionally accepts a third argument `fx == (f x)`, in case you've already
calculated it elsewhere and would like to save a function evaluation.
sourceraw docstring

D-numericclj/s

(D-numeric f)
(D-numeric f opts)

Takes a function f: R => R (function of a single real variable), and returns a new function of x that approximates the derivative $Df(x)$ (or $D^2f(x)$ if you pass :method :central-d2).

Returns the estimated value of the derivative at x. If you pass :info? true, the fn returns a dictionary of the results of us/seq-limit:

{:converged? <boolean> :terms-checked <int> :result <derivative estimate>}

Make sure to visit sicmutils.calculus.derivative/D if you want symbolic or automatic differentiation.

Roundoff Estimate

The returned function will attempt to estimate how many times it can halve the step size used to estimate the derivative before roundoff error swamps the calculation, and force the function to return (with :converged? false, if you pass :info?)

Optional Arguments

D-numeric takes optional args as its second param. Any of these can be overridden by passing a second argument to the function returned by D-numeric; helpful for setting defaults and then overriding them later.

The returned function passes through these and any other options to us/seq-limit, where they control the sequence of richardson extrapolation-accelerated estimates.

Options:

  • :method: one of :central, :central-d2, :forward or :backward. :central-d2 forces a second derivative estimate; the other methods configure a first derivative estimator.

  • :info? if false (default), returns the estimated value of x. If true, returns a dictionary with more information (see D-numeric's docstring for more info.)

  • :initial-h: the initial h to use for derivative estimates before $h o 0$. Defaults to 0.1 * abs(x).

  • :tolerance: see us/stream-limit for a discussion of how this value handles relative vs absolute tolerance. $\sqrt(\epsilon)$ by default, where $\epsilon$ = machine tolerance.

  • :maxterms: the maximum number of terms to consider when hunting for a derivative estimate. This defaults to an estimate generated internally, designed to prevent roundoff error from swamping the result. If you want to disable this feature, set :maxterms to something moderately large, like :maxterms 100. But do so carefully! See the surrounding namespace for a larger discussion.

Takes a function `f: R => R` (function of a single real variable), and returns
a new function of `x` that approximates the derivative $Df(x)$ (or $D^2f(x)$
if you pass `:method :central-d2`).

Returns the estimated value of the derivative at `x`. If you pass `:info?
true`, the fn returns a dictionary of the results of `us/seq-limit`:

{:converged? <boolean>
 :terms-checked <int>
 :result <derivative estimate>}

Make sure to visit `sicmutils.calculus.derivative/D` if you want symbolic or
automatic differentiation.

## Roundoff Estimate

The returned function will attempt to estimate how many times it can halve the
step size used to estimate the derivative before roundoff error swamps the
calculation, and force the function to return (with `:converged? false`, if
you pass `:info?`)

## Optional Arguments

`D-numeric` takes optional args as its second param. Any of these can be
overridden by passing a second argument to the function returned by
`D-numeric`; helpful for setting defaults and then overriding them later.

The returned function passes through these and any other options to
`us/seq-limit`, where they control the sequence of richardson
extrapolation-accelerated estimates.

Options:

- `:method`: one of `:central`, `:central-d2`, `:forward` or `:backward`.
`:central-d2` forces a second derivative estimate; the other methods configure
a first derivative estimator.

- `:info?` if false (default), returns the estimated value of `x`. If true,
returns a dictionary with more information (see `D-numeric`'s docstring for
more info.)

- `:initial-h`: the initial `h` to use for derivative estimates before $h 	o
0$. Defaults to 0.1 * abs(x).

- `:tolerance`: see `us/stream-limit` for a discussion of how this value
handles relative vs absolute tolerance. $\sqrt(\epsilon)$ by default, where
$\epsilon$ = machine tolerance.

- `:maxterms`: the maximum number of terms to consider when hunting for a
derivative estimate. This defaults to an estimate generated internally,
designed to prevent roundoff error from swamping the result. If you want to
disable this feature, set `:maxterms` to something moderately large, like
`:maxterms 100`. But do so carefully! See the surrounding namespace for a
larger discussion.
sourceraw docstring

forward-differenceclj/s

(forward-difference f x)
(forward-difference f x fx)

Returns a single-variable function of a step size h that calculates the forward-difference estimate of the the first derivative of f at point x:

f'(x) = [f(x + h) - f(x)] / h

Optionally accepts a third argument fx == (f x), in case you've already calculated it elsewhere and would like to save a function evaluation.

Returns a single-variable function of a step size `h` that calculates the
forward-difference estimate of the the first derivative of `f` at point `x`:

f'(x) = [f(x + h) - f(x)] / h

Optionally accepts a third argument `fx == (f x)`, in case you've already
calculated it elsewhere and would like to save a function evaluation.
sourceraw docstring

valid-methodsclj/s

source

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close