The purpose of these definitions is to let the import of sicmutils.env bring all the functions in the book into scope without qualification, so you can just start working with examples.
The purpose of these definitions is to let the import of sicmutils.env bring all the functions in the book into scope without qualification, so you can just start working with examples.
Converts an S-expression to printable infix form. Numeric exponents are written as superscripts. Partial derivatives get subscripts.
Converts an S-expression to printable infix form. Numeric exponents are written as superscripts. Partial derivatives get subscripts.
(arg-scale f & factors)
Takes a function f
and a sequence of factors
, and returns a new function
that multiplies each factor by the corresponding argument of f
. Too many or
two few factors are ignored.
((arg-scale square 3) 4) ==> 144 ((arg-scale square 3 2 1) 4) ==> 144
Takes a function `f` and a sequence of `factors`, and returns a new function that multiplies each factor by the corresponding argument of `f`. Too many or two few factors are ignored. ((arg-scale square 3) 4) ==> 144 ((arg-scale square 3 2 1) 4) ==> 144
(arg-shift f & shifts)
Takes a function f
and a sequence of shifts
, and returns a new function
that adds each shift to the corresponding argument of f
. Too many or two few
shifts are ignored.
((arg-shift square 3) 4) ==> 49 ((arg-shift square 3 2 1) 4) ==> 49
Takes a function `f` and a sequence of `shifts`, and returns a new function that adds each shift to the corresponding argument of `f`. Too many or two few shifts are ignored. ((arg-shift square 3) 4) ==> 49 ((arg-shift square 3 2 1) 4) ==> 49
(arity f)
Return the cached or obvious arity of the object if we know it. Otherwise delegate to the heavy duty reflection, if we have to.
Return the cached or obvious arity of the object if we know it. Otherwise delegate to the heavy duty reflection, if we have to.
(basis->basis-over-map mu:N->M basis-on-M)
(basis->oneform-basis b)
Extract the dual basis from the given basis object.
Extract the dual basis from the given basis object.
(basis->vector-basis b)
Extract the vector basis from the given basis object.
Extract the vector basis from the given basis object.
(binomial-series alpha)
Returns a PowerSeries
instance representing a
Binomial series, ie, the
taylor series of the function $f$ given by
$$f(x) = (1 + x)^\alpha$$
Returns a `PowerSeries` instance representing a [Binomial series](https://en.wikipedia.org/wiki/Binomial_series), ie, the taylor series of the function $f$ given by $$f(x) = (1 + x)^\alpha$$
(bootstrap-repl!)
Bootstraps a repl or Clojure namespace by requiring all public vars from sicmutils.env. From (This will only work at a repl in Clojurescript.)
TODO add support for refer-macros
in Clojurescript
TODO add rename, exclude support.
Bootstraps a repl or Clojure namespace by requiring all public vars from sicmutils.env. From (This will only work at a repl in Clojurescript.) TODO add support for `refer-macros` in Clojurescript TODO add rename, exclude support.
(brent-max f a b opts)
For convenience, we also provide the sister-procedure for finding the maximum of a unimodal function using Brent's method.
Negate the function, minimize, negate the result.
For convenience, we also provide the sister-procedure for finding the maximum of a unimodal function using Brent's method. Negate the function, minimize, negate the result.
(brent-min f a b)
(brent-min f
a
b
{:keys [relative-threshold absolute-threshold maxiter maxfun
callback]
:or {relative-threshold (g/sqrt v/machine-epsilon)
absolute-threshold 1.0E-11
maxiter 1000
callback (constantly nil)}})
Find the minimum of the function f: R -> R in the interval [a,b] using Brent's Method, described by Richard Brent in Algorithms for Minimization without Derivatives.
Brent's method is a combination of a golden section search with a parabolic interpolation step. Parabolic interpolation can go wild if the candidate point is close to colinear with the search bounds, or of the points are too close together.
Brent's method prevents this by applying an internal test that forces a golden
section step every so often. (If you want the details, see parabola-valid?
above.)
Supports the following optional keyword arguments:
:callback
if supplied, the supplied fn will be invoked at each intermediate
point with the iteration count and the values of x and f(x) at each search
step.
:relative-threshold
defaults to around 1.49e8, the sqrt of the machine
tolerance. You won't gain any benefit attempting to set the value less than
the default.
:absolute-threshold
a smaller absolute threshold that applies when the
candidate minimum point is close to 0.
: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)
.
Find the minimum of the function f: R -> R in the interval [a,b] using Brent's Method, described by Richard Brent in [Algorithms for Minimization without Derivatives](https://books.google.com/books?id=AITCAgAAQBAJ&q=Brent%E2%80%99s#v=onepage&q=Parabolic&f=false). Brent's method is a combination of a golden section search with a parabolic interpolation step. Parabolic interpolation can go wild if the candidate point is close to colinear with the search bounds, or of the points are too close together. Brent's method prevents this by applying an internal test that forces a golden section step every so often. (If you want the details, see `parabola-valid?` above.) Supports the following optional keyword arguments: `:callback` if supplied, the supplied fn will be invoked at each intermediate point with the iteration count and the values of x and f(x) at each search step. `:relative-threshold` defaults to around 1.49e8, the sqrt of the machine tolerance. You won't gain any benefit attempting to set the value less than the default. `:absolute-threshold` a smaller absolute threshold that applies when the candidate minimum point is close to 0. `: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)`.
(column-matrix->up m)
Returns the single column from the supplied column matrix as an up
. Errors if
some other type is supplied.
Returns the single column from the supplied column matrix as an `up`. Errors if some other type is supplied.
(column-matrix->vector m)
Returns the single column from the supplied column matrix as a vector. Errors if some other type is supplied.
Returns the single column from the supplied column matrix as a vector. Errors if some other type is supplied.
(compatible-shape s)
Returns a structure compatible for multiplication with s
down to a scalar,
with the slots filled with gensyms.
Returns a structure compatible for multiplication with `s` down to a scalar, with the slots filled with gensyms.
(complex re)
(complex re im)
Construct a complex number from real, or real and imaginary, components.
Construct a complex number from real, or real and imaginary, components.
(component & indices)
Given an access chain (a sequence of indices), return a function that accepts a structure and returns the element at the specified access chain.
Given an access chain (a sequence of indices), return a function that accepts a structure and returns the element at the specified access chain.
(components->oneform-field components coordinate-system & [name])
(components->vector-field components coordinate-system & [name])
(compose & fns)
Compose is like Clojure's standard comp, but for this system we like to know the arity of our functions, so that we can calculate their derivatives with structure, etc. The arity of a composition is simply the arity of its rightmost (that is, first to be applied) function term.
Compose is like Clojure's standard comp, but for this system we like to know the arity of our functions, so that we can calculate their derivatives with structure, etc. The arity of a composition is simply the arity of its rightmost (that is, first to be applied) function term.
(compositional-canonical? C H)
p.324
p.324
generic conjugate
generic conjugate
(coordinate local)
A convenience function on local tuples. A local tuple describes the state of a system at a particular time: [t, q, D q, D^2 q] representing time, position, velocity (and optionally acceleration etc.) Returns the q element, which is expected to be a mapping from time to a structure of coordinates
A convenience function on local tuples. A local tuple describes the state of a system at a particular time: [t, q, D q, D^2 q] representing time, position, velocity (and optionally acceleration etc.) Returns the q element, which is expected to be a mapping from time to a structure of coordinates
(coordinate-system->basis coordinate-system)
Return the standard basis object for the coordinate system.
Return the standard basis object for the coordinate system.
(coordinate-system->oneform-basis coordinate-system)
(coordinate-system->vector-basis coordinate-system)
(covariant-derivative Cartan)
(covariant-derivative Cartan map)
generic cross-product
generic cross-product
Derivative operator. Produces a function whose value at some point can multiply an increment in the arguments, to produce the best linear estimate of the increment in the function value.
Derivative operator. Produces a function whose value at some point can multiply an increment in the arguments, to produce the best linear estimate of the increment in the function value.
(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.
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?
)
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.
(definite-integral f a b)
(definite-integral f
a
b
{:keys [method compile? info?]
:or {method :open compile? false info? false}
:as opts})
Evaluates the definite integral of integrand f
across the interval $a, b$.
Optionally accepts a dictionary opts
of customizing options; All opts
will
be passed through to the supplied integrate
functions.
If you'd like more control, or to retrieve the integration function directly
without looking it up via :method
each time, see get-integrator
.
All supplied options are passed through to the underlying integrator; see the specific integrator for information on what options are available.
:method
: Specifies the integration method used. Must be
available-methods
:method
keyDefaults to :open
, which specifies an adaptive bulirsch-stoer quadrature method.
:compile?
If true, the generic function will be simplified and compiled
before execution.
:info?
If true, definite-integral
will return a map of integration
information returned by the underlying integrator. Else, returns an estimate
of the definite integral.
Evaluates the definite integral of integrand `f` across the interval $a, b$. Optionally accepts a dictionary `opts` of customizing options; All `opts` will be passed through to the supplied `integrate` functions. If you'd like more control, or to retrieve the integration function directly without looking it up via `:method` each time, see `get-integrator`. All supplied options are passed through to the underlying integrator; see the specific integrator for information on what options are available. ## Keyword arguments: `:method`: Specifies the integration method used. Must be - a keyword naming one of the available methods in `available-methods` - a function with the proper integrator signature - a dictionary of integrator options with a `:method` key Defaults to `:open`, which specifies an adaptive bulirsch-stoer quadrature method. `:compile?` If true, the generic function will be simplified and compiled before execution. `:info?` If true, `definite-integral` will return a map of integration information returned by the underlying integrator. Else, returns an estimate of the definite integral.
generic determinant
generic determinant
(differential mu:N->M)
FDG p.72
FDG p.72
generic dimension
generic dimension
generic dot-product
generic dot-product
(down & xs)
Construct a down (covariant) tuple from the arguments. Variadic version of [[down*]].
Construct a down (covariant) tuple from the arguments. Variadic version of [[down*]].
(down->row-matrix v)
Returns a row matrix with the contents of the supplied down
structure.
Errors if any other type is provided.
Returns a row matrix with the contents of the supplied `down` structure. Errors if any other type is provided.
(evolution order)
We can use the coordinatized vector field to build an evolution along an integral curve.
We can use the coordinatized vector field to build an evolution along an integral curve.
(evolve state-derivative & state-derivative-args)
evolve takes a state derivative function constructor and its arguments, and returns an integrator via make-integrator.
In particular, the returned function accepts a callback function which will be invoked at intermediate grid points of the integration.
evolve takes a state derivative function constructor and its arguments, and returns an integrator via make-integrator. In particular, the returned function accepts a callback function which will be invoked at intermediate grid points of the integration.
generic exp.
Returns the base-e exponential of x
. Equivalent to (expt e x)
, given
some properly-defined e
symbol.
generic exp. Returns the base-e exponential of `x`. Equivalent to `(expt e x)`, given some properly-defined `e` symbol.
generic exp10.
Returns the base-10 exponential of x
. Equivalent to (expt 10 x)
.
generic exp10. Returns the base-10 exponential of `x`. Equivalent to `(expt 10 x)`.
generic exp2.
Returns the base-2 exponential of x
. Equivalent to (expt 2 x)
.
generic exp2. Returns the base-2 exponential of `x`. Equivalent to `(expt 2 x)`.
(F->CT F)
A transformation of configuration coordinates F to a procedure implementing a transformation of phase-space coordinates (p. 320)
A transformation of configuration coordinates F to a procedure implementing a transformation of phase-space coordinates (p. 320)
(factorial n)
Returns
the factorial of n
, ie, the product of 1 to n inclusive.
Returns the factorial of `n`, ie, the product of 1 to n inclusive.
(find-path Lagrangian t0 q0 t1 q1 n & {:keys [observe]})
SICM p. 23. The optional parameter values is a callback which will report intermediate points of the minimization.
SICM p. 23. The optional parameter values is a callback which will report intermediate points of the minimization.
(form-field->form-field-over-map mu:N->M)
(freeze this)
Freezing an expression means removing wrappers and other metadata from subexpressions, so that the result is basically a pure S-expression with the same structure as the input. Doing this will rob an expression of useful information for further computation; so this is intended to be done just before simplification and printing, to simplify those processes.
Freezing an expression means removing wrappers and other metadata from subexpressions, so that the result is basically a pure S-expression with the same structure as the input. Doing this will rob an expression of useful information for further computation; so this is intended to be done just before simplification and printing, to simplify those processes.
(Gamma q)
(Gamma q n)
Gamma takes a path function (from time to coordinates) to a state function (from time to local tuple).
Gamma takes a path function (from time to coordinates) to a state function (from time to local tuple).
(golden-section-max f xa xb)
(golden-section-max f xa xb opts)
For convenience, we also provide the sister-procedure for finding the maximum of a unimodal function using the golden section method.
Negate the function, minimize, negate the result.
For convenience, we also provide the sister-procedure for finding the maximum of a unimodal function using the golden section method. Negate the function, minimize, negate the result.
(golden-section-min f xa xb)
(golden-section-min f
xa
xb
{:keys [choose callback]
:or {choose best-of callback (constantly nil)}
:as opts})
Golden Section search attempts to locate the minimum of the supplied function
f
by evaluating points located at golden-ratioed intervals between the two
starting endpoints a
and b
. This method is slow, steady and reliable.
Supports the following optional keyword arguments:
:converged?
is an optional predicate accepting five arguments:
[a fa]
[l fl]
[r fr]
[b fb]
current-iteration
If the supplied fn
returns true, it will signal convergence and the
optimizer will return. Returning false will continue.
:choose
is called at the final step of optimization with all 4 points and
their fn values (see the first four arguments to :converged?
), and returns
the final choice.
:callback
receives all 5 arguments on every iteration.
: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 1000.
:fn-tolerance
check that the minimal value of any of the checked points is
within the maximum of f(a) or f(b).
:arg-tolerance
check that a
and b
are within this supplied absolute
distance.
Golden Section search attempts to locate the minimum of the supplied function `f` by evaluating points located at golden-ratioed intervals between the two starting endpoints `a` and `b`. This method is slow, steady and reliable. Supports the following optional keyword arguments: `:converged?` is an optional predicate accepting five arguments: `[a fa]` `[l fl]` `[r fr]` `[b fb]` `current-iteration` If the supplied `fn` returns true, it will signal convergence and the optimizer will return. Returning false will continue. `:choose` is called at the final step of optimization with all 4 points and their fn values (see the first four arguments to `:converged?`), and returns the final choice. `:callback` receives all 5 arguments on every iteration. `: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 1000. `:fn-tolerance` check that the minimal value of any of the checked points is within the maximum of f(a) or f(b). `:arg-tolerance` check that `a` and `b` are within this supplied absolute distance.
(Hamiltonian & n)
Return SICM-style function signature for a Hamiltonian with n degrees of freedom (or 1 if n is not given). Useful for constructing Hamiltonian literal functions.
Return SICM-style function signature for a Hamiltonian with n degrees of freedom (or 1 if n is not given). Useful for constructing Hamiltonian literal functions.
(Hamiltonian->state-derivative Hamiltonian)
generic imag-part
generic imag-part
generic inner-product
generic inner-product
(integrate-state-derivative state-derivative
state-derivative-args
initial-state
t1
dt)
A wrapper for evolve, which is more convenient when you just want a vector of (time, state) pairs over the integration interval instead of having to deal with a callback. Integrates the supplied state derivative (and its argument package) from [0 to t1] in steps of size dt
A wrapper for evolve, which is more convenient when you just want a vector of (time, state) pairs over the integration interval instead of having to deal with a callback. Integrates the supplied state derivative (and its argument package) from [0 to t1] in steps of size dt
(iterated-map f n)
f is a function of (x y continue fail), which calls continue with the values of x' y' that follow x y in the mapping. Returns a map of the same shape that iterates the iterated map n times before invoking the continuation, or invokes the fail continuation if the inner map fails.
f is a function of (x y continue fail), which calls continue with the values of x' y' that follow x y in the mapping. Returns a map of the same shape that iterates the iterated map n times before invoking the continuation, or invokes the fail continuation if the inner map fails.
(Jacobian to-basis from-basis)
Compute the Jacobian of transition from from-basis to to-basis.
Compute the Jacobian of transition from from-basis to to-basis.
(kind-predicate x)
Returns a predicate that returns true if its argument matches the supplied
kind-keyword k
, false otherwise.
Returns a predicate that returns true if its argument matches the supplied kind-keyword `k`, false otherwise.
(Lagrange-equations-first-order L)
(Lagrange-interpolation-function ys xs)
(Lagrangian->state-derivative L)
The state derivative of a Lagrangian is a function carrying a state tuple to its time derivative.
The state derivative of a Lagrangian is a function carrying a state tuple to its time derivative.
(let-coordinates bindings & body)
Example: (let-coordinates [[x y] R2-rect [r theta] R2-polar] body...)
Example: (let-coordinates [[x y] R2-rect [r theta] R2-polar] body...)
generic Lie-derivative
generic Lie-derivative
(literal-down sym size)
Generates a down
structure of dimension size
populated by symbolic entries,
each prefixed by the supplied symbol sym
.
For example:
(= (literal-down 'x 3) (down 'x_0 'x_1 'x_2))
Generates a `down` structure of dimension `size` populated by symbolic entries, each prefixed by the supplied symbol `sym`. For example: (= (literal-down 'x 3) (down 'x_0 'x_1 'x_2))
(literal-function f)
(literal-function f sicm-signature)
(literal-function f domain range)
(literal-manifold-function name coordinate-system)
(literal-matrix sym nrows ncols)
Generates a nrows
x ncols
matrix of symbolic entries, each prefixed by
the supplied symbol sym
.
NOTE: The symbols in the returned matrix record their Einstein-notation path
into the structure that this matrix represents; a down
of up
columns. This
means that the returned indices embedded in the symbols look flipped, ji
vs
ij
.
For example:
(= (literal-matrix 'x 2 2) (by-rows ['x_0↑0 'x_1↑0] ['x_0↑1 'x_1↑1]))
Generates a `nrows` x `ncols` matrix of symbolic entries, each prefixed by the supplied symbol `sym`. NOTE: The symbols in the returned matrix record their Einstein-notation path into the structure that this matrix represents; a `down` of `up` columns. This means that the returned indices embedded in the symbols look flipped, `ji` vs `ij`. For example: (= (literal-matrix 'x 2 2) (by-rows ['x_0↑0 'x_1↑0] ['x_0↑1 'x_1↑1]))
(literal-number x)
Returns its argument, wrapped in a marker type that responds to the generic
operations registered in sicmutils.numsymb
.
Symbols are automatically treated as literal-number
instances, so
(* 10 (literal-number 'x))
is equivalent to
(* 10 'x).
If you pass an actual number, sicmutils will attempt to preserve exact values through various operations:
(g/+ 1 (g/cos (g/* 2 (literal-number 4)))) ;;=> (+ 1 (cos 8))
Notice that the (g/* 2 ...)
is evaluated, but cos
evaluation is deferred,
since the result is inexact. On the other hand, if the number is inexact to
begin with:
(g/+ 1 (g/cos (g/* 2 (literal-number 2.2)))) ;;=> 0.6926671300215806
the system will go ahead and evaluate it.
Returns its argument, wrapped in a marker type that responds to the generic operations registered in `sicmutils.numsymb`. Symbols are automatically treated as `literal-number` instances, so (* 10 (literal-number 'x)) is equivalent to (* 10 'x). If you pass an actual number, sicmutils will attempt to preserve exact values through various operations: (g/+ 1 (g/cos (g/* 2 (literal-number 4)))) ;;=> (+ 1 (cos 8)) Notice that the `(g/* 2 ...)` is evaluated, but `cos` evaluation is deferred, since the result is inexact. On the other hand, if the number is inexact to begin with: (g/+ 1 (g/cos (g/* 2 (literal-number 2.2)))) ;;=> 0.6926671300215806 the system will go ahead and evaluate it.
(literal-oneform-field name coordinate-system)
(literal-up sym size)
Generates an up
structure of dimension size
populated by symbolic entries,
each prefixed by the supplied symbol sym
.
For example:
(= (literal-up 'x 3) (up 'x↑0 'x↑1 'x↑2))
Generates an `up` structure of dimension `size` populated by symbolic entries, each prefixed by the supplied symbol `sym`. For example: (= (literal-up 'x 3) (up 'x↑0 'x↑1 'x↑2))
(literal-vector-field name coordinate-system)
generic log.
Returns the natural logarithm of x
.
generic log. Returns the natural logarithm of `x`.
generic log10.
Returns the base-10 logarithm of x
, ie, $log_10(x)$.
generic log10. Returns the base-10 logarithm of `x`, ie, $log_10(x)$.
generic log2.
Returns the base-2 logarithm of x
, ie, $log_2(x)$.
generic log2. Returns the base-2 logarithm of `x`, ie, $log_2(x)$.
(m->s ls m rs)
Convert the matrix m into a structure S, guided by the requirement that (* ls S rs) should be a scalar
Convert the matrix m into a structure S, guided by the requirement that (* ls S rs) should be a scalar
generic magnitude
generic magnitude
generic make-polar
generic make-polar
generic make-rectangular
generic make-rectangular
(mapr f & structures)
Return a structure with the same shape as s but with f applied to each primitive (that is, not structural) component.
Return a structure with the same shape as s but with f applied to each primitive (that is, not structural) component.
(minimize f a b)
(minimize f a b observe)
Find the minimum of the function f: R -> R in the interval [a,b]. If observe is supplied, will be invoked with the iteration count and the values of x and f(x) at each search step.
Find the minimum of the function f: R -> R in the interval [a,b]. If observe is supplied, will be invoked with the iteration count and the values of x and f(x) at each search step.
(momentum H-state)
See coordinate: this returns the momentum element of a Hammilton state tuple (by convention, the element at index 2).
See coordinate: this returns the momentum element of a Hammilton state tuple (by convention, the element at index 2).
(multidimensional-minimize func x0 & {:keys [info?] :as opts})
Entrypoint for multidimensional minimization routines.
See sicmutils.numerical.multimin.nelder-mead/nelder-mead
for the only
supported option.
Entrypoint for multidimensional minimization routines. See `sicmutils.numerical.multimin.nelder-mead/nelder-mead` for the only supported option.
(nelder-mead func x0 {:keys [callback] :as opts})
Find the minimum of the function f: R^n -> R, given an initial point q ∈ R^n. Supports the following optional keyword arguments:
:callback
if supplied, the supplied fn will be invoked with iteration count,
the values of X and the value of f(X) at each intermediate point of
evaluation.
:info?
if true, wraps the result with evaluation information.
:adaptive?
if true, the Nelder-Mead parameters for contraction, expansion,
reflection and shrinking will be set adaptively, as functions of the number of
dimensions. If false they stay constant.
:alpha
sets the reflection coefficient used for each step of Nelder-Mead.
:beta
sets the expansion coefficient used for each step of Nelder-Mead.
:gamma
sets the contraction coefficient used for each step of Nelder-Mead.
:sigma
sets the shrink coefficient used for each step of Nelder-Mead.
:maxiter
Maximum number of iterations allowed for the minimizer. Defaults to
200*dimension.
:maxfun
Maximum number of times the function can be evaluated before exiting.
Defaults to 200*dimension.
:simplex-tolerance
When the absolute value of the max difference between the
best point and any point in the simplex falls below this tolerance, the
minimizer stops. Defaults to 1e-4.
:fn-tolerance
When the absolute value of the max difference between the best
point's function value and the fn value of any point in the simplex falls
below this tolerance, the minimizer stops. Defaults to 1e-4.
:zero-delta
controls the value to which 0 entries in the initial vector are
set during initial simplex generation. Defaults to 0.00025.
:nonzero-delta
factor by which entries in the initial vector are perturbed to
generate the initial simplex. Defaults to 0.05.
See Gao, F. and Han, L. Implementing the Nelder-Mead simplex algorithm with adaptive parameters. 2012. Computational Optimization and Applications. 51:1, pp. 259-277 I gratefully acknowledge the Python implementation in SciPy which I have imitated here.
Find the minimum of the function f: R^n -> R, given an initial point q ∈ R^n. Supports the following optional keyword arguments: `:callback` if supplied, the supplied fn will be invoked with iteration count, the values of X and the value of f(X) at each intermediate point of evaluation. `:info?` if true, wraps the result with evaluation information. `:adaptive?` if true, the Nelder-Mead parameters for contraction, expansion, reflection and shrinking will be set adaptively, as functions of the number of dimensions. If false they stay constant. `:alpha` sets the reflection coefficient used for each step of Nelder-Mead. `:beta` sets the expansion coefficient used for each step of Nelder-Mead. `:gamma` sets the contraction coefficient used for each step of Nelder-Mead. `:sigma` sets the shrink coefficient used for each step of Nelder-Mead. `:maxiter` Maximum number of iterations allowed for the minimizer. Defaults to 200*dimension. `:maxfun` Maximum number of times the function can be evaluated before exiting. Defaults to 200*dimension. `:simplex-tolerance` When the absolute value of the max difference between the best point and any point in the simplex falls below this tolerance, the minimizer stops. Defaults to 1e-4. `:fn-tolerance` When the absolute value of the max difference between the best point's function value and the fn value of any point in the simplex falls below this tolerance, the minimizer stops. Defaults to 1e-4. `:zero-delta` controls the value to which 0 entries in the initial vector are set during initial simplex generation. Defaults to 0.00025. `:nonzero-delta` factor by which entries in the initial vector are perturbed to generate the initial simplex. Defaults to 0.05. See Gao, F. and Han, L. Implementing the Nelder-Mead simplex algorithm with adaptive parameters. 2012. Computational Optimization and Applications. 51:1, pp. 259-277 I gratefully acknowledge the [Python implementation in SciPy](https://github.com/scipy/scipy/blob/589c9afe41774ee96ec121f1867361146add8276/scipy/optimize/optimize.py#L556:5) which I have imitated here.
(orientation s)
Returns the orientation of s, either ::up
or ::down
. Defaults to ::up
,
even for non-structures.
Returns the orientation of s, either `::up` or `::down`. Defaults to `::up`, even for non-structures.
(osculating-path state0)
Given a state tuple (of finite length), reconstitutes the initial segment of the Taylor series corresponding to the state tuple data as a function of t. Time is measured beginning at the point of time specified in the input state tuple.
Given a state tuple (of finite length), reconstitutes the initial segment of the Taylor series corresponding to the state tuple data as a function of t. Time is measured beginning at the point of time specified in the input state tuple.
generic outer-product
generic outer-product
(p->r [_ [r φ]])
SICM p. 47. Polar to rectangular coordinates of state.
SICM p. 47. Polar to rectangular coordinates of state.
(partial & selectors)
A shim. Dispatches to partial differentiation when all the arguments are integers; falls back to the core meaning (partial function application) otherwise.
A shim. Dispatches to partial differentiation when all the arguments are integers; falls back to the core meaning (partial function application) otherwise.
(partial-sums s)
Returns a series (of the same type as the input) of partial sums of the terms
in the supplied series s
.
Returns a series (of the same type as the input) of partial sums of the terms in the supplied series `s`.
(polar-canonical alpha)
p.327
p.327
(pushforward-vector mu:N->M mu-inverse:M->N)
generic real-part
generic real-part
(ref a)
(ref a & ks)
A shim so that ref can act like nth in SICM contexts, as clojure core ref elsewhere.
A shim so that ref can act like nth in SICM contexts, as clojure core ref elsewhere.
(row-matrix->down m)
Returns the single row from the supplied row matrix as a down
. Errors if some
other type is supplied.
Returns the single row from the supplied row matrix as a `down`. Errors if some other type is supplied.
(row-matrix->vector m)
Returns the single row from the supplied row matrix as a vector. Errors if some other type is supplied.
Returns the single row from the supplied row matrix as a vector. Errors if some other type is supplied.
(Rx α)
Returns a function which rotates a vector α radians about the x axis.
Returns a function which rotates a vector α radians about the x axis.
(Ry α)
Returns a function which rotates a vector α radians about the y axis.
Returns a function which rotates a vector α radians about the y axis.
(Rz α)
Returns a function which rotates a vector α radians about the z axis.
Returns a function which rotates a vector α radians about the z axis.
(s->m ls ms rs)
Convert the structure ms, which would be a scalar if the (compatible) multiplication (* ls ms rs) were performed, to a matrix.
Convert the structure ms, which would be a scalar if the (compatible) multiplication (* ls ms rs) were performed, to a matrix.
(state->t s)
Extract the time slot from a state tuple
Extract the time slot from a state tuple
(state-advancer state-derivative & state-derivative-args)
state-advancer takes a state derivative function constructor followed by the arguments to construct it with. The state derivative function is constructed and an integrator is produced which takes:
as arguments. Optionally, supply an options map with these optional fields:
:compile?
: If true, the ODE solver will compile your state function.
:epsilon
: The maximum error tolerance allowed by the ODE solver, both
relative and absolute.
Returns the final state.
The state derivative is expected to map a structure to a structure of the same shape, and is required to have the time parameter as the first element.
state-advancer takes a state derivative function constructor followed by the arguments to construct it with. The state derivative function is constructed and an integrator is produced which takes: - initial state - target time as arguments. Optionally, supply an options map with these optional fields: `:compile?`: If true, the ODE solver will compile your state function. `:epsilon`: The maximum error tolerance allowed by the ODE solver, both relative and absolute. Returns the final state. The state derivative is expected to map a structure to a structure of the same shape, and is required to have the time parameter as the first element.
(structure->vector s)
Return the structure in unoriented vector form.
Return the structure in unoriented vector form.
(structure? s)
Returns true
if s
is a structure, false otherwise. (Vectors are treated as
up structures.)
Returns `true` if `s` is a structure, false otherwise. (Vectors are treated as up structures.)
(submatrix m lowrow hirow lowcol hicol)
Returns the submatrix of m
generated by taking
lowrow
-> hirow
,lowcol
-> hicol
Returns the submatrix of `m` generated by taking - rows from `lowrow` -> `hirow`, - columns from `lowcol` -> `hicol`
(sum xs)
(sum f low high)
Sums either:
xs
of numbers, orf
to (range low high)
Using Kahan's summation trick behind the scenes to keep floating point errors under control.
Sums either: - a series `xs` of numbers, or - the result of mapping function `f` to `(range low high)` Using Kahan's summation trick behind the scenes to keep floating point errors under control.
(symplectic-transform? C)
p. 334
p. 334
(symplectic-unit n)
p. 334 (used, but not defined there)
p. 334 (used, but not defined there)
(tex$ expr)
Render expression in a form convenient for rendering with clojupyter. In this case, we want the TeX material wrapped with dollar signs.
Render expression in a form convenient for rendering with clojupyter. In this case, we want the TeX material wrapped with dollar signs.
(tex$$ expr)
Render expression in a form convenient for rendering with clojupyter. In this case, we want the TeX material wrapped with dollar signs.
Render expression in a form convenient for rendering with clojupyter. In this case, we want the TeX material wrapped with dollar signs.
(time-independent-canonical? C)
p.326
p.326
generic transpose
generic transpose
(up & xs)
Construct an up (contravariant) tuple from the arguments.
Variadic version of [[up*]].
Construct an up (contravariant) tuple from the arguments. Variadic version of [[up*]].
(up->column-matrix v)
Returns a column matrix with the contents of the supplied up
structure.
Errors if any other type is provided.
Returns a column matrix with the contents of the supplied `up` structure. Errors if any other type is provided.
(up? s)
Returns true
if s
is an up structure, false otherwise.
Returns `true` if `s` is an up structure, false otherwise.
(using-coordinates coordinate-prototype coordinate-system & body)
Example: (using-coordinates (up x y) R2-rect body...)
Note: this is just a macro wrapping let-coordinates, the use of which is preferred.
Example: (using-coordinates (up x y) R2-rect body...) Note: this is just a macro wrapping let-coordinates, the use of which is preferred.
(vector->down v)
Form a down-tuple from a vector.
NOTE that this is an alias of [[down*]] that is more restrictive, in that it only accepts a vector. Use [[down*]] if you'd like to pass an arbitrary sequence. (If you pass a vector to [[down*]]) it will be just as efficient.
Form a down-tuple from a vector. NOTE that this is an alias of [[down*]] that is more restrictive, in that it only accepts a vector. Use [[down*]] if you'd like to pass an arbitrary sequence. (If you pass a vector to [[down*]]) it will be just as efficient.
(vector->up v)
Form an up-tuple from a vector.
NOTE that this is an alias of [[up*]] that is more restrictive, in that it only accepts a vector. Use [[up*]] if you'd like to pass an arbitrary sequence. (If you pass a vector to [[up*]]) it will be just as efficient.
Form an up-tuple from a vector. NOTE that this is an alias of [[up*]] that is more restrictive, in that it only accepts a vector. Use [[up*]] if you'd like to pass an arbitrary sequence. (If you pass a vector to [[up*]]) it will be just as efficient.
(vector-basis->dual vector-basis coordinate-system)
(vector-field->components vf coordinate-system)
(vector-field->vector-field-over-map mu:N->M)
FDG p.72
FDG p.72
(vector:generate n f)
Generates a new vector of length n
by applying the function f
to integers
in the range $[0,n)$.
Generates a new vector of length `n` by applying the function `f` to integers in the range $[0,n)$.
(velocity local)
See coordinate: this returns the velocity element of a local tuple (by convention, the 2nd element).
See coordinate: this returns the velocity element of a local tuple (by convention, the 2nd element).
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close