Liking cljdoc? Tell your friends :D

emmy.numerical.roots.bisect

This namespace contains implementations of a number of methods for root-finding on real-valued functions of one argument.

NOTE: This namespace is not yet stable: Expect these functions to change as new root-finding methods are added.

This namespace contains implementations of a number of methods for root-finding
on real-valued functions of one argument.

NOTE: This namespace is not yet stable: Expect these functions to change as
new root-finding methods are added. 
raw docstring

*bisect-break*clj/s

Controls the default behavior of bisect's search. See bisect's docstring for more info.

Controls the default behavior of [[bisect]]'s search.
See [[bisect]]'s docstring for more info.
sourceraw docstring

all-methodsclj/s

Set of all methods allowed as :method options to bisect.

Set of all methods allowed as `:method` options to [[bisect]].
sourceraw docstring

bisectclj/s

(bisect f a b)
(bisect f
        a
        b
        {:keys [eps maxiter maxfun callback]
         :or {eps v/machine-epsilon maxiter 1000 callback (constantly nil)}
         :as opts})

Given some function f and (inclusive) lower and upper bounds a and b on the domain, attempts to find a root of f in that range, i.e., a value x for which (f x) is equal to 0.

Supports the following optional keyword arguments:

:method: can be :bisection, :secant or :mixed. See the Methods section below for a description of each. Defaults to :mixed

:eps: defaults to emmy.value/machine-epsilon.

:callback: if supplied, the supplied f will be invoked at each intermediate point with the iteration count and the values of x and f(x) at each search step.

:maxiter: maximum number of iterations allowed for the minimizer. Defaults to 1000.

:maxfun maximum number of times the function can be evaluated before exiting. Defaults to (inc maxiter).

:n-break defaults to the dynamically bindable *bisect-break* (which defaults to 60). Bind *bisect-break* to modify the behavior of the :mixed method (see below) when it's used inside a nested routine. Ignored if method is not :mixed.

Methods

  • :bisection causes bisect to use the Bisection method; at each iteration, the midpoint between the bounds is chosen as the next point.

  • :secant uses the Secant method; each candidate point is chosen by taking the root of a line drawn between the two endpoints [a (f a)] and [b (f b)]. This method is most useful when the bounds are close to the root.

  • :mixed uses :bisection up until :n-break iterations and :secant beyond. This can be useful for narrowing down a very wide range close to the root, and then switching in to a faster search method.

Given some function `f` and (inclusive) lower and upper bounds `a` and `b` on
the domain, attempts to find a root of `f` in that range, i.e., a value `x` for
which `(f x)` is equal to 0.

Supports the following optional keyword arguments:

`:method`: can be `:bisection`, `:secant` or `:mixed`. See the Methods section
below for a description of each. Defaults to `:mixed`

`:eps`: defaults to [[emmy.value/machine-epsilon]].

`:callback`: if supplied, the supplied `f` will be invoked at each
intermediate point with the iteration count and the values of x and f(x) at
each search step.

`:maxiter`: maximum number of iterations allowed for the minimizer. Defaults to
1000.

`:maxfun` maximum number of times the function can be evaluated before
exiting. Defaults to `(inc maxiter)`.

`:n-break` defaults to the dynamically bindable `*bisect-break*` (which
defaults to 60). Bind `*bisect-break*` to modify the behavior of the `:mixed`
method (see below) when it's used inside a nested routine. Ignored if method
is not `:mixed`.

## Methods

- `:bisection` causes [[bisect]] to use the [Bisection
  method](https://en.wikipedia.org/wiki/Bisection_method); at each iteration,
  the midpoint between the bounds is chosen as the next point.

- `:secant` uses the [Secant
  method](https://en.wikipedia.org/wiki/Secant_method); each candidate point is
  chosen by taking the root of a line drawn between the two endpoints `[a (f
  a)]` and `[b (f b)]`. This method is most useful when the bounds are close to
  the root.

- `:mixed` uses `:bisection` up until `:n-break` iterations and `:secant`
  beyond. This can be useful for narrowing down a very wide range close to the
  root, and then switching in to a faster search method.
sourceraw docstring

search-for-rootsclj/s

(search-for-roots f a b dx)
(search-for-roots f a b dx opts)

Given a smooth function f and (inclusive) lower and upper bounds a and b on the domain, attempts to find all roots of f, i.e., a vector of values x_n such that each (f x_n) is equal to 0.

search-for-roots first attempts to cut the (inclusive) range [a, b] into pieces at most dx wide; then bisect is used to search each segment for a root.

All opts supplied are passed on to bisect.

Given a smooth function `f` and (inclusive) lower and upper bounds `a` and
`b` on the domain, attempts to find all roots of `f`, i.e., a vector of values
`x_n` such that each `(f x_n)` is equal to 0.

[[search-for-roots]] first attempts to cut the (inclusive) range `[a, b]`
into pieces at most `dx` wide; then [[bisect]] is used to search each segment
for a root.

All `opts` supplied are passed on to [[bisect]].
sourceraw docstring

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

× close