public abstract static class Function.Cts2Cts extends Function.Native
apply_x(.)
and all else follows.
A Cts2Cts has a derivative
and
an integral
.
Also see Function.Cts2Cts2Cts
.Modifier and Type | Class and Description |
---|---|
class |
Function.Cts2Cts.Derivative
This default Derivative of a given function '
f '
uses finite-differences – see apply_x(x) and
apply_xx(δ,x) . |
class |
Function.Cts2Cts.Integral
Integral: Cts→Cts→Cts (±) integrates
f from 'lo' to 'hi'. |
static class |
Function.Cts2Cts.WithInverse
This class exists so that one can create an anonymous
Cts2Cts which (implements)
HasInverse . |
Function.Cts2Cts, Function.Cts2Cts2Cts, Function.CtsD2CtsD, Function.HasInverse, Function.Native, Function.Native2, Function.Native3
Value.Atomic, Value.Bool, Value.Char, Value.Chars, Value.Cts, Value.Defer, Value.Discrete, Value.Enum, Value.Inc_Or, Value.Int, Value.Lambda, Value.List, Value.Maybe, Value.Option, Value.Real, Value.Scannable, Value.Structured, Value.Triv, Value.Tuple
Constructor and Description |
---|
Cts2Cts() |
Modifier and Type | Method and Description |
---|---|
abstract double |
apply_x(double x)
apply_x(x) is used by
apply(c) . |
Value.Cts |
apply(Value c)
Calls
apply_x(c.x()) . |
Function.Cts2Cts |
d_dx()
Return the derivative of 'this' function, d/dx this.
|
Function.Cts2Cts |
d2_dx2()
The second derivative, d2/dx2 this,
that is
d_dx() twice. |
Function.Cts2Cts2Cts |
exactIntegral(Function.Cts2Cts F)
Creates a definite integral from an indefinite one, F, if
such a closed form is known.
|
static Function.Cts2Cts |
fromFunction(Function f)
(Static) fromFunction(f) creates a Cts2Cts from a Function,
'f', where f is not an instance of class Cts2Cts but f does
in fact accept, and return, Cts values.
|
Function.Cts2Cts2Cts |
integral()
Return the integral of 'this' function,
∫ this(x) dx.
|
protected Function.Cts2Cts |
make_d_dx()
Slave worker for
d_dx() . |
protected Function.Cts2Cts2Cts |
make_integral()
Slave worker for
integral() . |
double |
NewtonRaphson(double x0)
Use Newton-Raphson to solve f(x) = 0, where
'f' is 'this' Cts2Cts, given an initial guess, x0.
|
double |
root(double x0)
Solve f(x) = 0, where 'f' is 'this' Cts2Cts, given
an initial guess, x0.
|
double |
turning(double x0)
Find a turning point of 'this' Cts2Cts, 'f', that is find x such
that
f'(x) =0, given an initial guess, x0. |
Function.Cts2Cts |
uOp(int op)
For example, sin.uOp(minus) satisfies
(sin.uOp(minus))(x) = −sin(x).
|
public abstract double apply_x(double x)
apply(c)
.
Define apply_x(.) to make an instance of Cts2Cts.public Value.Cts apply(Value c)
apply_x(c.x())
.
Note, if c.AoM()>zero, apply(.) also calls
the derivative
to get an
AoM()
for the result.apply
in class Function.Native
public static Function.Cts2Cts fromFunction(Function f)
public Function.Cts2Cts uOp(int op)
uOp(int)
.public double turning(double x0)
public double root(double x0)
NewtonRaphson(x0)
.public double NewtonRaphson(double x0)
d_dx
.
(If Newton-Raphson fails, plan B is binary search.)public final Function.Cts2Cts d_dx()
make_d_dx()
.public final Function.Cts2Cts d2_dx2()
d_dx()
twice.protected Function.Cts2Cts make_d_dx()
d_dx()
. This default returns
new Derivative()
which works by finite
differences. Override make_d_dx if there is a closed form.public final Function.Cts2Cts2Cts integral()
make_integral()
. Note that
integral:R→R→R is a
curried
function,
integral(ko)(hi)=lo∫hithis.protected Function.Cts2Cts2Cts make_integral()
integral()
. This default
implementation returns new Integral()
which uses numerical integretaion. Override make_integral if
there is a closed form
(as in Derivative
).
Also see exactIntegral(F)
.public Function.Cts2Cts2Cts exactIntegral(Function.Cts2Cts F)
make_integral()
.