org.hipparchus.analysis.differentiation

## Class DerivativeStructure

• All Implemented Interfaces:
Serializable, Derivative<DerivativeStructure>, CalculusFieldElement<DerivativeStructure>, FieldElement<DerivativeStructure>

public class DerivativeStructure
extends Object
implements Derivative<DerivativeStructure>, Serializable
Class representing both the value and the differentials of a function.

This class is the workhorse of the differentiation package.

This class is an implementation of the extension to Rall's numbers described in Dan Kalman's paper Doubly Recursive Multivariate Automatic Differentiation, Mathematics Magazine, vol. 75, no. 3, June 2002. Rall's numbers are an extension to the real numbers used throughout mathematical expressions; they hold the derivative together with the value of a function. Dan Kalman's derivative structures hold all partial derivatives up to any specified order, with respect to any number of free parameters. Rall's numbers therefore can be seen as derivative structures for order one derivative and one free parameter, and real numbers can be seen as derivative structures with zero order derivative and no free parameters.

DerivativeStructure instances can be used directly thanks to the arithmetic operators to the mathematical functions provided as methods by this class (+, -, *, /, %, sin, cos ...).

Implementing complex expressions by hand using these classes is a tedious and error-prone task but has the advantage of having no limitation on the derivation order despite not requiring users to compute the derivatives by themselves. Implementing complex expression can also be done by developing computation code using standard primitive double values and to use differentiators to create the DerivativeStructure-based instances. This method is simpler but may be limited in the accuracy and derivation orders and may be computationally intensive (this is typically the case for finite differences differentiator.

Instances of this class are guaranteed to be immutable.

DSCompiler, FieldDerivativeStructure, Serialized Form
• ### Method Summary

All Methods
Modifier and Type Method and Description
DerivativeStructure abs()
absolute value.
DerivativeStructure acos()
Arc cosine operation.
DerivativeStructure acosh()
Inverse hyperbolic cosine operation.
DerivativeStructure add(DerivativeStructure a)
Compute this + a.
DerivativeStructure add(double a)
'+' operator.
DerivativeStructure asin()
Arc sine operation.
DerivativeStructure asinh()
Inverse hyperbolic sine operation.
DerivativeStructure atan()
Arc tangent operation.
DerivativeStructure atan2(DerivativeStructure x)
Two arguments arc tangent operation.
static DerivativeStructure atan2(DerivativeStructure y, DerivativeStructure x)
Two arguments arc tangent operation.
DerivativeStructure atanh()
Inverse hyperbolic tangent operation.
DerivativeStructure cbrt()
Cubic root.
DerivativeStructure ceil()
Get the smallest whole number larger than instance.
DerivativeStructure compose(double... f)
Compute composition of the instance by a univariate function.
DerivativeStructure copySign(DerivativeStructure sign)
Returns the instance with the sign of the argument.
DerivativeStructure copySign(double sign)
Returns the instance with the sign of the argument.
DerivativeStructure cos()
Cosine operation.
DerivativeStructure cosh()
Hyperbolic cosine operation.
DerivativeStructure differentiate(int varIndex, int differentiationOrder)
Differentiate w.r.t.
DerivativeStructure divide(DerivativeStructure a)
Compute this ÷ a.
DerivativeStructure divide(double a)
'÷' operator.
boolean equals(Object other)
Test for the equality of two derivative structures.
DerivativeStructure exp()
Exponential.
DerivativeStructure expm1()
Exponential minus 1.
DerivativeStructure floor()
Get the largest whole number smaller than instance.
double[] getAllDerivatives()
Get all partial derivatives.
int getExponent()
Return the exponent of the instance value, removing the bias.
DSFactory getFactory()
Get the factory that built the instance.
Field<DerivativeStructure> getField()
Get the Field to which the instance belongs.
int getFreeParameters()
Get the number of free parameters.
int getOrder()
Get the derivation order.
double getPartialDerivative(int... orders)
Get a partial derivative.
DerivativeStructure getPi()
Get the Archimedes constant π.
double getReal()
Get the real value of the number.
double getValue()
Get the value part of the derivative structure.
int hashCode()
Get a hashCode for the derivative structure.
DerivativeStructure hypot(DerivativeStructure y)
Returns the hypotenuse of a triangle with sides this and y - sqrt(this2 +y2) avoiding intermediate overflow or underflow.
static DerivativeStructure hypot(DerivativeStructure x, DerivativeStructure y)
Returns the hypotenuse of a triangle with sides x and y - sqrt(x2 +y2) avoiding intermediate overflow or underflow.
DerivativeStructure integrate(int varIndex, int integrationOrder)
Integrate w.r.t.
DerivativeStructure linearCombination(DerivativeStructure[] a, DerivativeStructure[] b)
Compute a linear combination.
DerivativeStructure linearCombination(DerivativeStructure a1, DerivativeStructure b1, DerivativeStructure a2, DerivativeStructure b2)
Compute a linear combination.
DerivativeStructure linearCombination(DerivativeStructure a1, DerivativeStructure b1, DerivativeStructure a2, DerivativeStructure b2, DerivativeStructure a3, DerivativeStructure b3)
Compute a linear combination.
DerivativeStructure linearCombination(DerivativeStructure a1, DerivativeStructure b1, DerivativeStructure a2, DerivativeStructure b2, DerivativeStructure a3, DerivativeStructure b3, DerivativeStructure a4, DerivativeStructure b4)
Compute a linear combination.
DerivativeStructure linearCombination(double[] a, DerivativeStructure[] b)
Compute a linear combination.
DerivativeStructure linearCombination(double a1, DerivativeStructure b1, double a2, DerivativeStructure b2)
Compute a linear combination.
DerivativeStructure linearCombination(double a1, DerivativeStructure b1, double a2, DerivativeStructure b2, double a3, DerivativeStructure b3)
Compute a linear combination.
DerivativeStructure linearCombination(double a1, DerivativeStructure b1, double a2, DerivativeStructure b2, double a3, DerivativeStructure b3, double a4, DerivativeStructure b4)
Compute a linear combination.
DerivativeStructure log()
Natural logarithm.
DerivativeStructure log10()
Base 10 logarithm.
DerivativeStructure log1p()
Shifted natural logarithm.
DerivativeStructure multiply(DerivativeStructure a)
Compute this × a.
DerivativeStructure multiply(double a)
'×' operator.
DerivativeStructure multiply(int n)
Compute n × this.
DerivativeStructure negate()
Returns the additive inverse of this element.
DerivativeStructure newInstance(double value)
Create an instance corresponding to a constant real value.
DerivativeStructure pow(DerivativeStructure e)
Power operation.
DerivativeStructure pow(double p)
Power operation.
static DerivativeStructure pow(double a, DerivativeStructure x)
Compute ax where a is a double and x a DerivativeStructure
DerivativeStructure pow(int n)
Integer power operation.
DerivativeStructure rebase(DerivativeStructure... p)
Rebase instance with respect to low level parameter functions.
DerivativeStructure reciprocal()
Returns the multiplicative inverse of this element.
DerivativeStructure remainder(DerivativeStructure a)
IEEE remainder operator.
DerivativeStructure remainder(double a)
IEEE remainder operator.
DerivativeStructure rint()
Get the whole number that is the nearest to the instance, or the even one if x is exactly half way between two integers.
DerivativeStructure rootN(int n)
Nth root.
DerivativeStructure scalb(int n)
Multiply the instance by a power of 2.
DerivativeStructure sign()
Compute the sign of the instance.
DerivativeStructure sin()
Sine operation.
FieldSinCos<DerivativeStructure> sinCos()
Combined Sine and Cosine operation.
DerivativeStructure sinh()
Hyperbolic sine operation.
FieldSinhCosh<DerivativeStructure> sinhCosh()
Combined hyperbolic sine and sosine operation.
DerivativeStructure sqrt()
Square root.
DerivativeStructure subtract(DerivativeStructure a)
Compute this - a.
DerivativeStructure subtract(double a)
'-' operator.
DerivativeStructure tan()
Tangent operation.
DerivativeStructure tanh()
Hyperbolic tangent operation.
double taylor(double... delta)
Evaluate Taylor expansion a derivative structure.
DerivativeStructure toDegrees()
Convert radians to degrees, with error of less than 0.5 ULP
DerivativeStructure toRadians()
Convert degrees to radians, with error of less than 0.5 ULP
DerivativeStructure ulp()
Compute least significant bit (Unit in Last Position) for a number.
• ### Methods inherited from class java.lang.Object

clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
• ### Methods inherited from interface org.hipparchus.CalculusFieldElement

isFinite, isInfinite, isNaN, norm, round
• ### Methods inherited from interface org.hipparchus.FieldElement

isZero
• ### Method Detail

• #### newInstance

public DerivativeStructure newInstance(double value)
Create an instance corresponding to a constant real value.
Specified by:
newInstance in interface CalculusFieldElement<DerivativeStructure>
Parameters:
value - constant real value
Returns:
instance corresponding to a constant real value
• #### getFactory

public DSFactory getFactory()
Get the factory that built the instance.
Returns:
factory that built the instance
• #### getFreeParameters

public int getFreeParameters()
Description copied from interface: Derivative
Get the number of free parameters.
Specified by:
getFreeParameters in interface Derivative<DerivativeStructure>
Returns:
number of free parameters
• #### getOrder

public int getOrder()
Description copied from interface: Derivative
Get the derivation order.
Specified by:
getOrder in interface Derivative<DerivativeStructure>
Returns:
derivation order
• #### getReal

public double getReal()
Get the real value of the number.
Specified by:
getReal in interface FieldElement<DerivativeStructure>
Returns:
real value
• #### getValue

public double getValue()
Get the value part of the derivative structure.
Specified by:
getValue in interface Derivative<DerivativeStructure>
Returns:
value part of the derivative structure
getPartialDerivative(int...)
• #### getPartialDerivative

public double getPartialDerivative(int... orders)
throws MathIllegalArgumentException
Get a partial derivative.
Specified by:
getPartialDerivative in interface Derivative<DerivativeStructure>
Parameters:
orders - derivation orders with respect to each variable (if all orders are 0, the value is returned)
Returns:
partial derivative
Throws:
MathIllegalArgumentException - if the numbers of variables does not match the instance
Derivative.getValue()

public DerivativeStructure add(double a)
'+' operator.
Specified by:
add in interface CalculusFieldElement<DerivativeStructure>
Parameters:
a - right hand side parameter of the operator
Returns:
this+a

public DerivativeStructure add(DerivativeStructure a)
throws MathIllegalArgumentException
Compute this + a.
Specified by:
add in interface FieldElement<DerivativeStructure>
Parameters:
a - element to add
Returns:
a new element representing this + a
Throws:
MathIllegalArgumentException - if number of free parameters or orders do not match
• #### subtract

public DerivativeStructure subtract(double a)
'-' operator.
Specified by:
subtract in interface CalculusFieldElement<DerivativeStructure>
Parameters:
a - right hand side parameter of the operator
Returns:
this-a
• #### subtract

public DerivativeStructure subtract(DerivativeStructure a)
throws MathIllegalArgumentException
Compute this - a.
Specified by:
subtract in interface FieldElement<DerivativeStructure>
Parameters:
a - element to subtract
Returns:
a new element representing this - a
Throws:
MathIllegalArgumentException - if number of free parameters or orders do not match
• #### multiply

public DerivativeStructure multiply(int n)
Compute n × this. Multiplication by an integer number is defined as the following sum
n × this = ∑i=1n this.
Specified by:
multiply in interface FieldElement<DerivativeStructure>
Parameters:
n - Number of times this must be added to itself.
Returns:
A new element representing n × this.
• #### multiply

public DerivativeStructure multiply(double a)
'×' operator.
Specified by:
multiply in interface CalculusFieldElement<DerivativeStructure>
Parameters:
a - right hand side parameter of the operator
Returns:
this×a
• #### multiply

public DerivativeStructure multiply(DerivativeStructure a)
throws MathIllegalArgumentException
Compute this × a.
Specified by:
multiply in interface FieldElement<DerivativeStructure>
Parameters:
a - element to multiply
Returns:
a new element representing this × a
Throws:
MathIllegalArgumentException - if number of free parameters or orders do not match
• #### divide

public DerivativeStructure divide(double a)
'÷' operator.
Specified by:
divide in interface CalculusFieldElement<DerivativeStructure>
Parameters:
a - right hand side parameter of the operator
Returns:
this÷a
• #### divide

public DerivativeStructure divide(DerivativeStructure a)
throws MathIllegalArgumentException
Compute this ÷ a.
Specified by:
divide in interface FieldElement<DerivativeStructure>
Parameters:
a - element to divide by
Returns:
a new element representing this ÷ a
Throws:
MathIllegalArgumentException - if number of free parameters or orders do not match
• #### remainder

public DerivativeStructure remainder(double a)
IEEE remainder operator.
Specified by:
remainder in interface CalculusFieldElement<DerivativeStructure>
Parameters:
a - right hand side parameter of the operator
Returns:
this - n × a where n is the closest integer to this/a
• #### remainder

public DerivativeStructure remainder(DerivativeStructure a)
throws MathIllegalArgumentException
IEEE remainder operator.
Specified by:
remainder in interface CalculusFieldElement<DerivativeStructure>
Parameters:
a - right hand side parameter of the operator
Returns:
this - n × a where n is the closest integer to this/a
Throws:
MathIllegalArgumentException - if number of free parameters or orders do not match
• #### negate

public DerivativeStructure negate()
Returns the additive inverse of this element.
Specified by:
negate in interface FieldElement<DerivativeStructure>
Returns:
the opposite of this.
• #### abs

public DerivativeStructure abs()
absolute value.

Just another name for CalculusFieldElement.norm()

Specified by:
abs in interface CalculusFieldElement<DerivativeStructure>
Returns:
abs(this)
• #### ceil

public DerivativeStructure ceil()
Get the smallest whole number larger than instance.
Specified by:
ceil in interface CalculusFieldElement<DerivativeStructure>
Returns:
ceil(this)
• #### floor

public DerivativeStructure floor()
Get the largest whole number smaller than instance.
Specified by:
floor in interface CalculusFieldElement<DerivativeStructure>
Returns:
floor(this)
• #### rint

public DerivativeStructure rint()
Get the whole number that is the nearest to the instance, or the even one if x is exactly half way between two integers.
Specified by:
rint in interface CalculusFieldElement<DerivativeStructure>
Returns:
a double number r such that r is an integer r - 0.5 ≤ this ≤ r + 0.5
• #### sign

public DerivativeStructure sign()
Compute the sign of the instance. The sign is -1 for negative numbers, +1 for positive numbers and 0 otherwise, for Complex number, it is extended on the unit circle (equivalent to z/|z|, with special handling for 0 and NaN)
Specified by:
sign in interface CalculusFieldElement<DerivativeStructure>
Returns:
-1.0, -0.0, +0.0, +1.0 or NaN depending on sign of a
• #### copySign

public DerivativeStructure copySign(DerivativeStructure sign)
Returns the instance with the sign of the argument. A NaN sign argument is treated as positive.
Specified by:
copySign in interface CalculusFieldElement<DerivativeStructure>
Parameters:
sign - the sign for the returned value
Returns:
the instance with the same sign as the sign argument
• #### copySign

public DerivativeStructure copySign(double sign)
Returns the instance with the sign of the argument. A NaN sign argument is treated as positive.
Specified by:
copySign in interface CalculusFieldElement<DerivativeStructure>
Parameters:
sign - the sign for the returned value
Returns:
the instance with the same sign as the sign argument
• #### getExponent

public int getExponent()
Return the exponent of the instance value, removing the bias.

For double numbers of the form 2x, the unbiased exponent is exactly x.

Specified by:
getExponent in interface CalculusFieldElement<DerivativeStructure>
Returns:
exponent for instance in IEEE754 representation, without bias
• #### scalb

public DerivativeStructure scalb(int n)
Multiply the instance by a power of 2.
Specified by:
scalb in interface CalculusFieldElement<DerivativeStructure>
Parameters:
n - power of 2
Returns:
this × 2n
• #### ulp

public DerivativeStructure ulp()
Compute least significant bit (Unit in Last Position) for a number.

The ulp function is a step function, hence all its derivatives are 0.

Specified by:
ulp in interface CalculusFieldElement<DerivativeStructure>
Returns:
ulp(this)
Since:
2.0
• #### hypot

public DerivativeStructure hypot(DerivativeStructure y)
throws MathIllegalArgumentException
Returns the hypotenuse of a triangle with sides this and y - sqrt(this2 +y2) avoiding intermediate overflow or underflow.
• If either argument is infinite, then the result is positive infinity.
• else, if either argument is NaN then the result is NaN.
Specified by:
hypot in interface CalculusFieldElement<DerivativeStructure>
Parameters:
y - a value
Returns:
sqrt(this2 +y2)
Throws:
MathIllegalArgumentException - if number of free parameters or orders do not match
• #### hypot

public static DerivativeStructure hypot(DerivativeStructure x,
DerivativeStructure y)
throws MathIllegalArgumentException
Returns the hypotenuse of a triangle with sides x and y - sqrt(x2 +y2) avoiding intermediate overflow or underflow.
• If either argument is infinite, then the result is positive infinity.
• else, if either argument is NaN then the result is NaN.
Parameters:
x - a value
y - a value
Returns:
sqrt(x2 +y2)
Throws:
MathIllegalArgumentException - if number of free parameters or orders do not match
• #### compose

public DerivativeStructure compose(double... f)
throws MathIllegalArgumentException
Compute composition of the instance by a univariate function.
Specified by:
compose in interface Derivative<DerivativeStructure>
Parameters:
f - array of value and derivatives of the function at the current point (i.e. [f(getValue()), f'(getValue()), f''(getValue())...]).
Returns:
f(this)
Throws:
MathIllegalArgumentException - if the number of derivatives in the array is not equal to order + 1
• #### reciprocal

public DerivativeStructure reciprocal()
Returns the multiplicative inverse of this element.
Specified by:
reciprocal in interface CalculusFieldElement<DerivativeStructure>
Specified by:
reciprocal in interface FieldElement<DerivativeStructure>
Returns:
the inverse of this.
• #### sqrt

public DerivativeStructure sqrt()
Square root.
Specified by:
sqrt in interface CalculusFieldElement<DerivativeStructure>
Returns:
square root of the instance
• #### cbrt

public DerivativeStructure cbrt()
Cubic root.
Specified by:
cbrt in interface CalculusFieldElement<DerivativeStructure>
Returns:
cubic root of the instance
• #### rootN

public DerivativeStructure rootN(int n)
Nth root.
Specified by:
rootN in interface CalculusFieldElement<DerivativeStructure>
Parameters:
n - order of the root
Returns:
nth root of the instance
• #### getField

public Field<DerivativeStructure> getField()
Get the Field to which the instance belongs.
Specified by:
getField in interface FieldElement<DerivativeStructure>
Returns:
Field to which the instance belongs
• #### pow

public static DerivativeStructure pow(double a,
DerivativeStructure x)
Compute ax where a is a double and x a DerivativeStructure
Parameters:
a - number to exponentiate
x - power to apply
Returns:
ax
• #### pow

public DerivativeStructure pow(double p)
Power operation.
Specified by:
pow in interface CalculusFieldElement<DerivativeStructure>
Parameters:
p - power to apply
Returns:
thisp
• #### pow

public DerivativeStructure pow(int n)
Integer power operation.
Specified by:
pow in interface CalculusFieldElement<DerivativeStructure>
Parameters:
n - power to apply
Returns:
thisn
• #### pow

public DerivativeStructure pow(DerivativeStructure e)
throws MathIllegalArgumentException
Power operation.
Specified by:
pow in interface CalculusFieldElement<DerivativeStructure>
Parameters:
e - exponent
Returns:
thise
Throws:
MathIllegalArgumentException - if number of free parameters or orders do not match
• #### exp

public DerivativeStructure exp()
Exponential.
Specified by:
exp in interface CalculusFieldElement<DerivativeStructure>
Returns:
exponential of the instance
• #### expm1

public DerivativeStructure expm1()
Exponential minus 1.
Specified by:
expm1 in interface CalculusFieldElement<DerivativeStructure>
Returns:
exponential minus one of the instance
• #### log

public DerivativeStructure log()
Natural logarithm.
Specified by:
log in interface CalculusFieldElement<DerivativeStructure>
Returns:
logarithm of the instance
• #### log1p

public DerivativeStructure log1p()
Shifted natural logarithm.
Specified by:
log1p in interface CalculusFieldElement<DerivativeStructure>
Returns:
logarithm of one plus the instance
• #### log10

public DerivativeStructure log10()
Base 10 logarithm.
Specified by:
log10 in interface CalculusFieldElement<DerivativeStructure>
Returns:
base 10 logarithm of the instance
• #### cos

public DerivativeStructure cos()
Cosine operation.
Specified by:
cos in interface CalculusFieldElement<DerivativeStructure>
Returns:
cos(this)
• #### sin

public DerivativeStructure sin()
Sine operation.
Specified by:
sin in interface CalculusFieldElement<DerivativeStructure>
Returns:
sin(this)
• #### sinCos

public FieldSinCos<DerivativeStructure> sinCos()
Combined Sine and Cosine operation.
Specified by:
sinCos in interface CalculusFieldElement<DerivativeStructure>
Returns:
[sin(this), cos(this)]
• #### tan

public DerivativeStructure tan()
Tangent operation.
Specified by:
tan in interface CalculusFieldElement<DerivativeStructure>
Returns:
tan(this)
• #### acos

public DerivativeStructure acos()
Arc cosine operation.
Specified by:
acos in interface CalculusFieldElement<DerivativeStructure>
Returns:
acos(this)
• #### asin

public DerivativeStructure asin()
Arc sine operation.
Specified by:
asin in interface CalculusFieldElement<DerivativeStructure>
Returns:
asin(this)
• #### atan

public DerivativeStructure atan()
Arc tangent operation.
Specified by:
atan in interface CalculusFieldElement<DerivativeStructure>
Returns:
atan(this)
• #### atan2

public DerivativeStructure atan2(DerivativeStructure x)
throws MathIllegalArgumentException
Two arguments arc tangent operation.

Beware of the order or arguments! As this is based on a two-arguments functions, in order to be consistent with arguments order, the instance is the first argument and the single provided argument is the second argument. In order to be consistent with programming languages atan2, this method computes atan2(this, x), i.e. the instance represents the y argument and the x argument is the one passed as a single argument. This may seem confusing especially for users of Wolfram alpha, as this site is not consistent with programming languages atan2 two-arguments arc tangent and puts x as its first argument.

Specified by:
atan2 in interface CalculusFieldElement<DerivativeStructure>
Parameters:
x - second argument of the arc tangent
Returns:
atan2(this, x)
Throws:
MathIllegalArgumentException - if number of free parameters or orders are inconsistent
• #### atan2

public static DerivativeStructure atan2(DerivativeStructure y,
DerivativeStructure x)
throws MathIllegalArgumentException
Two arguments arc tangent operation.
Parameters:
y - first argument of the arc tangent
x - second argument of the arc tangent
Returns:
atan2(y, x)
Throws:
MathIllegalArgumentException - if number of free parameters or orders do not match
• #### cosh

public DerivativeStructure cosh()
Hyperbolic cosine operation.
Specified by:
cosh in interface CalculusFieldElement<DerivativeStructure>
Returns:
cosh(this)
• #### sinh

public DerivativeStructure sinh()
Hyperbolic sine operation.
Specified by:
sinh in interface CalculusFieldElement<DerivativeStructure>
Returns:
sinh(this)
• #### sinhCosh

public FieldSinhCosh<DerivativeStructure> sinhCosh()
Combined hyperbolic sine and sosine operation.
Specified by:
sinhCosh in interface CalculusFieldElement<DerivativeStructure>
Returns:
[sinh(this), cosh(this)]
• #### tanh

public DerivativeStructure tanh()
Hyperbolic tangent operation.
Specified by:
tanh in interface CalculusFieldElement<DerivativeStructure>
Returns:
tanh(this)
• #### acosh

public DerivativeStructure acosh()
Inverse hyperbolic cosine operation.
Specified by:
acosh in interface CalculusFieldElement<DerivativeStructure>
Returns:
acosh(this)
• #### asinh

public DerivativeStructure asinh()
Inverse hyperbolic sine operation.
Specified by:
asinh in interface CalculusFieldElement<DerivativeStructure>
Returns:
asin(this)
• #### atanh

public DerivativeStructure atanh()
Inverse hyperbolic tangent operation.
Specified by:
atanh in interface CalculusFieldElement<DerivativeStructure>
Returns:
atanh(this)
• #### toDegrees

public DerivativeStructure toDegrees()
Convert radians to degrees, with error of less than 0.5 ULP
Specified by:
toDegrees in interface CalculusFieldElement<DerivativeStructure>
Returns:
instance converted into degrees

public DerivativeStructure toRadians()
Convert degrees to radians, with error of less than 0.5 ULP
Specified by:
toRadians in interface CalculusFieldElement<DerivativeStructure>
Returns:
• #### integrate

public DerivativeStructure integrate(int varIndex,
int integrationOrder)
Integrate w.r.t. one independent variable.

Rigorously, if the derivatives of a function are known up to order N, the ones of its M-th integral w.r.t. a given variable (seen as a function itself) are actually known up to order N+M. However, this method still casts the output as a DerivativeStructure of order N. The integration constants are systematically set to zero.

Parameters:
varIndex - Index of independent variable w.r.t. which integration is done.
integrationOrder - Number of times the integration operator must be applied. If non-positive, call the differentiation operator.
Returns:
DerivativeStructure on which integration operator has been applied a certain number of times.
Since:
2.2
• #### differentiate

public DerivativeStructure differentiate(int varIndex,
int differentiationOrder)
Differentiate w.r.t. one independent variable.

Rigorously, if the derivatives of a function are known up to order N, the ones of its M-th derivative w.r.t. a given variable (seen as a function itself) are only known up to order N-M. However, this method still casts the output as a DerivativeStructure of order N with zeroes for the higher order terms.

Parameters:
varIndex - Index of independent variable w.r.t. which differentiation is done.
differentiationOrder - Number of times the differentiation operator must be applied. If non-positive, call the integration operator instead.
Returns:
DerivativeStructure on which differentiation operator has been applied a certain number of times
Since:
2.2
• #### taylor

public double taylor(double... delta)
throws MathRuntimeException
Evaluate Taylor expansion a derivative structure.
Parameters:
delta - parameters offsets (Δx, Δy, ...)
Returns:
value of the Taylor expansion at x + Δx, y + Δy, ...
Throws:
MathRuntimeException - if factorials becomes too large
• #### rebase

public DerivativeStructure rebase(DerivativeStructure... p)
Rebase instance with respect to low level parameter functions.

The instance is considered to be a function of n free parameters up to order o $$f(p_0, p_1, \ldots p_{n-1})$$. Its partial derivatives are therefore $$f, \frac{\partial f}{\partial p_0}, \frac{\partial f}{\partial p_1}, \ldots \frac{\partial^2 f}{\partial p_0^2}, \frac{\partial^2 f}{\partial p_0 p_1}, \ldots \frac{\partial^o f}{\partial p_{n-1}^o}$$. The free parameters $$p_0, p_1, \ldots p_{n-1}$$ are considered to be functions of $$m$$ lower level other parameters $$q_0, q_1, \ldots q_{m-1}$$.

\begin{align} p_0 & = p_0(q_0, q_1, \ldots q_{m-1})\\ p_1 & = p_1(q_0, q_1, \ldots q_{m-1})\\ p_{n-1} & = p_{n-1}(q_0, q_1, \ldots q_{m-1}) \end{align}

This method compute the composition of the partial derivatives of $$f$$ and the partial derivatives of $$p_0, p_1, \ldots p_{n-1}$$, i.e. the partial derivatives of the value returned will be $$f, \frac{\partial f}{\partial q_0}, \frac{\partial f}{\partial q_1}, \ldots \frac{\partial^2 f}{\partial q_0^2}, \frac{\partial^2 f}{\partial q_0 q_1}, \ldots \frac{\partial^o f}{\partial q_{m-1}^o}$$.

The number of parameters must match getFreeParameters() and the derivation orders of the instance and parameters must also match.

Parameters:
p - base parameters with respect to which partial derivatives were computed in the instance
Returns:
derivative structure with partial derivatives computed with respect to the lower level parameters used in the $$p_i$$
Since:
2.2
• #### linearCombination

public DerivativeStructure linearCombination(DerivativeStructure[] a,
DerivativeStructure[] b)
throws MathIllegalArgumentException
Compute a linear combination.
Specified by:
linearCombination in interface CalculusFieldElement<DerivativeStructure>
Parameters:
a - Factors.
b - Factors.
Returns:
Σi ai bi.
Throws:
MathIllegalArgumentException - if number of free parameters or orders do not match
• #### linearCombination

public DerivativeStructure linearCombination(double[] a,
DerivativeStructure[] b)
throws MathIllegalArgumentException
Compute a linear combination.
Specified by:
linearCombination in interface CalculusFieldElement<DerivativeStructure>
Parameters:
a - Factors.
b - Factors.
Returns:
Σi ai bi.
Throws:
MathIllegalArgumentException - if number of free parameters or orders do not match
• #### linearCombination

public DerivativeStructure linearCombination(DerivativeStructure a1,
DerivativeStructure b1,
DerivativeStructure a2,
DerivativeStructure b2,
DerivativeStructure a3,
DerivativeStructure b3,
DerivativeStructure a4,
DerivativeStructure b4)
throws MathIllegalArgumentException
Compute a linear combination.
Specified by:
linearCombination in interface CalculusFieldElement<DerivativeStructure>
Parameters:
a1 - first factor of the first term
b1 - second factor of the first term
a2 - first factor of the second term
b2 - second factor of the second term
a3 - first factor of the third term
b3 - second factor of the third term
a4 - first factor of the fourth term
b4 - second factor of the fourth term
Returns:
a1×b1 + a2×b2 + a3×b3 + a4×b4
Throws:
MathIllegalArgumentException - if number of free parameters or orders do not match
CalculusFieldElement.linearCombination(FieldElement, FieldElement, FieldElement, FieldElement), CalculusFieldElement.linearCombination(FieldElement, FieldElement, FieldElement, FieldElement, FieldElement, FieldElement)
• #### linearCombination

public DerivativeStructure linearCombination(double a1,
DerivativeStructure b1,
double a2,
DerivativeStructure b2,
double a3,
DerivativeStructure b3,
double a4,
DerivativeStructure b4)
throws MathIllegalArgumentException
Compute a linear combination.
Specified by:
linearCombination in interface CalculusFieldElement<DerivativeStructure>
Parameters:
a1 - first factor of the first term
b1 - second factor of the first term
a2 - first factor of the second term
b2 - second factor of the second term
a3 - first factor of the third term
b3 - second factor of the third term
a4 - first factor of the fourth term
b4 - second factor of the fourth term
Returns:
a1×b1 + a2×b2 + a3×b3 + a4×b4
Throws:
MathIllegalArgumentException - if number of free parameters or orders do not match
CalculusFieldElement.linearCombination(double, FieldElement, double, FieldElement), CalculusFieldElement.linearCombination(double, FieldElement, double, FieldElement, double, FieldElement)
• #### getPi

public DerivativeStructure getPi()
Get the Archimedes constant π.

Archimedes constant is the ratio of a circle's circumference to its diameter.

Specified by:
getPi in interface CalculusFieldElement<DerivativeStructure>
Returns:
Archimedes constant π
• #### equals

public boolean equals(Object other)
Test for the equality of two derivative structures.

Derivative structures are considered equal if they have the same number of free parameters, the same derivation order, and the same derivatives.

Overrides:
equals in class Object
Parameters:
other - Object to test for equality to this
Returns:
true if two derivative structures are equal
• #### hashCode

public int hashCode()
Get a hashCode for the derivative structure.
Overrides:
hashCode in class Object
Returns:
a hash code value for this object