Class FieldUnivariateDerivative2<T extends CalculusFieldElement<T>>
- Type Parameters:
T
- the type of the function parameters and value
- All Implemented Interfaces:
DifferentialAlgebra
,FieldDerivative<T,
,FieldUnivariateDerivative2<T>> CalculusFieldElement<FieldUnivariateDerivative2<T>>
,FieldElement<FieldUnivariateDerivative2<T>>
This class is a stripped-down version of FieldDerivativeStructure
with only one free parameter
and derivation order
limited to two.
It should have less overhead than FieldDerivativeStructure
in its domain.
This class is an implementation of Rall's numbers. 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.
FieldUnivariateDerivative2
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.
Instances of this class are guaranteed to be immutable.
-
Constructor Summary
ConstructorDescriptionBuild an instance from aDerivativeStructure
.FieldUnivariateDerivative2
(T f0, T f1, T f2) Build an instance with values and derivative. -
Method Summary
Modifier and TypeMethodDescriptionabs()
absolute value.acos()
Arc cosine operation.acosh()
Inverse hyperbolic cosine operation.add
(double a) '+' operator.Compute this + a.asin()
Arc sine operation.asinh()
Inverse hyperbolic sine operation.atan()
Arc tangent operation.Two arguments arc tangent operation.atanh()
Inverse hyperbolic tangent operation.cbrt()
Cubic root.Compute composition of the instance by a function.copySign
(double sign) Returns the instance with the sign of the argument.copySign
(FieldUnivariateDerivative2<T> sign) Returns the instance with the sign of the argument.Returns the instance with the sign of the argument.cos()
Cosine operation.cosh()
Hyperbolic cosine operation.divide
(double a) '÷' operator.Compute this ÷ a.'÷' operator.boolean
Test for the equality of two univariate derivatives.exp()
Exponential.expm1()
Exponential minus 1.getDerivative
(int n) Get a derivative from the univariate derivative.getField()
Get theField
to which the instance belongs.Get the first derivative.int
getOrder()
Get the derivation order.getPi()
Get the Archimedes constant π.Get the second derivative.getValue()
Get the value part of the univariate derivative.Get theField
the value and parameters of the function belongs to.int
hashCode()
Get a hashCode for the univariate derivative.Returns the hypotenuse of a triangle with sidesthis
andy
- sqrt(this2 +y2) avoiding intermediate overflow or underflow.linearCombination
(double[] a, FieldUnivariateDerivative2<T>[] b) Compute a linear combination.linearCombination
(double a1, FieldUnivariateDerivative2<T> b1, double a2, FieldUnivariateDerivative2<T> b2) Compute a linear combination.linearCombination
(double a1, FieldUnivariateDerivative2<T> b1, double a2, FieldUnivariateDerivative2<T> b2, double a3, FieldUnivariateDerivative2<T> b3) Compute a linear combination.linearCombination
(double a1, FieldUnivariateDerivative2<T> b1, double a2, FieldUnivariateDerivative2<T> b2, double a3, FieldUnivariateDerivative2<T> b3, double a4, FieldUnivariateDerivative2<T> b4) Compute a linear combination.Compute a linear combination.linearCombination
(FieldUnivariateDerivative2<T> a1, FieldUnivariateDerivative2<T> b1, FieldUnivariateDerivative2<T> a2, FieldUnivariateDerivative2<T> b2) Compute a linear combination.linearCombination
(FieldUnivariateDerivative2<T> a1, FieldUnivariateDerivative2<T> b1, FieldUnivariateDerivative2<T> a2, FieldUnivariateDerivative2<T> b2, FieldUnivariateDerivative2<T> a3, FieldUnivariateDerivative2<T> b3) Compute a linear combination.linearCombination
(FieldUnivariateDerivative2<T> a1, FieldUnivariateDerivative2<T> b1, FieldUnivariateDerivative2<T> a2, FieldUnivariateDerivative2<T> b2, FieldUnivariateDerivative2<T> a3, FieldUnivariateDerivative2<T> b3, FieldUnivariateDerivative2<T> a4, FieldUnivariateDerivative2<T> b4) Compute a linear combination.linearCombination
(T[] a, FieldUnivariateDerivative2<T>[] b) Compute a linear combination.linearCombination
(T a1, FieldUnivariateDerivative2<T> b1, T a2, FieldUnivariateDerivative2<T> b2, T a3, FieldUnivariateDerivative2<T> b3) Compute a linear combination.log()
Natural logarithm.log10()
Base 10 logarithm.log1p()
Shifted natural logarithm.multiply
(double a) '×' operator.multiply
(int n) Compute n × this.Compute this × a.'×' operator.negate()
Returns the additive inverse ofthis
element.newInstance
(double value) Create an instance corresponding to a constant real value.newInstance
(T value) Create an instance corresponding to a constant Field value.pow
(double p) Power operation.static <T extends CalculusFieldElement<T>>
FieldUnivariateDerivative2<T>pow
(double a, FieldUnivariateDerivative2<T> x) Compute ax where a is a double and x aFieldUnivariateDerivative2
pow
(int n) Integer power operation.Returns the multiplicative inverse ofthis
element.remainder
(double a) IEEE remainder operator.IEEE remainder operator.IEEE remainder operator.rootN
(int n) Nth root.scalb
(int n) Multiply the instance by a power of 2.sin()
Sine operation.sinCos()
Combined Sine and Cosine operation.sinh()
Hyperbolic sine operation.sinhCosh()
Combined hyperbolic sine and cosine operation.sqrt()
Square root.square()
Compute this × this.subtract
(double a) '-' operator.Compute this - a.tan()
Tangent operation.tanh()
Hyperbolic tangent operation.taylor
(double delta) Evaluate Taylor expansion a univariate derivative.Evaluate Taylor expansion a univariate derivative.Convert radians to degrees, with error of less than 0.5 ULPConvert the instance to aFieldDerivativeStructure
.Convert degrees to radians, with error of less than 0.5 ULPCreate a new object with new value (zeroth-order derivative, as passed as input) and same derivatives of order one and above.Methods inherited from class org.hipparchus.analysis.differentiation.FieldUnivariateDerivative
getFreeParameters, getPartialDerivative
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.analysis.differentiation.FieldDerivative
add, ceil, floor, getExponent, getReal, pow, rint, sign, subtract, ulp
Methods inherited from interface org.hipparchus.FieldElement
isZero
-
Constructor Details
-
FieldUnivariateDerivative2
Build an instance with values and derivative.- Parameters:
f0
- value of the functionf1
- first derivative of the functionf2
- second derivative of the function
-
FieldUnivariateDerivative2
public FieldUnivariateDerivative2(FieldDerivativeStructure<T> ds) throws MathIllegalArgumentException Build an instance from aDerivativeStructure
.- Parameters:
ds
- derivative structure- Throws:
MathIllegalArgumentException
- if eitherds
parameters is not 1 ords
order is not 2
-
-
Method Details
-
newInstance
Create an instance corresponding to a constant real value.- Parameters:
value
- constant real value- Returns:
- instance corresponding to a constant real value
-
newInstance
Create an instance corresponding to a constant Field value.This default implementation is there so that no API gets broken by the next release, which is not a major one. Custom inheritors should probably overwrite it.
- Parameters:
value
- constant value- Returns:
- instance corresponding to a constant Field value
-
withValue
Create a new object with new value (zeroth-order derivative, as passed as input) and same derivatives of order one and above.This default implementation is there so that no API gets broken by the next release, which is not a major one. Custom inheritors should probably overwrite it.
- Parameters:
value
- zeroth-order derivative of new represented function- Returns:
- new object with changed value
-
getValue
Get the value part of the univariate derivative.- Returns:
- value part of the univariate derivative
-
getDerivative
Get a derivative from the univariate derivative.- Specified by:
getDerivative
in classFieldUnivariateDerivative<T extends CalculusFieldElement<T>,
FieldUnivariateDerivative2<T extends CalculusFieldElement<T>>> - Parameters:
n
- derivation order (must be between 0 andgetOrder()
, both inclusive)- Returns:
- nth derivative, or
NaN
if n is either negative or strictly larger thangetOrder()
-
getOrder
public int getOrder()Get the derivation order.- Returns:
- derivation order
-
getFirstDerivative
Get the first derivative.- Returns:
- first derivative
- See Also:
-
getSecondDerivative
Get the second derivative.- Returns:
- second derivative
- See Also:
-
getValueField
Get theField
the value and parameters of the function belongs to.- Returns:
Field
the value and parameters of the function belongs to
-
toDerivativeStructure
Convert the instance to aFieldDerivativeStructure
.- Specified by:
toDerivativeStructure
in classFieldUnivariateDerivative<T extends CalculusFieldElement<T>,
FieldUnivariateDerivative2<T extends CalculusFieldElement<T>>> - Returns:
- derivative structure with same value and derivative as the instance
-
add
'+' operator.- Parameters:
a
- right hand side parameter of the operator- Returns:
- this+a
-
add
Compute this + a.- Parameters:
a
- element to add- Returns:
- a new element representing this + a
-
subtract
'-' operator.- Parameters:
a
- right hand side parameter of the operator- Returns:
- this-a
-
subtract
Compute this - a.- Parameters:
a
- element to subtract- Returns:
- a new element representing this - a
-
multiply
'×' operator.- Parameters:
a
- right hand side parameter of the operator- Returns:
- this×a
-
multiply
Compute n × this. Multiplication by an integer number is defined as the following sum \[ n \times \mathrm{this} = \sum_{i=1}^n \mathrm{this} \]- Parameters:
n
- Number of timesthis
must be added to itself.- Returns:
- A new element representing n × this.
-
multiply
'×' operator.- Parameters:
a
- right hand side parameter of the operator- Returns:
- this×a
-
multiply
Compute this × a.- Parameters:
a
- element to multiply- Returns:
- a new element representing this × a
-
square
Compute this × this.- Returns:
- a new element representing this × this
-
divide
'÷' operator.- Parameters:
a
- right hand side parameter of the operator- Returns:
- this÷a
-
divide
'÷' operator.- Parameters:
a
- right hand side parameter of the operator- Returns:
- this÷a
-
divide
Compute this ÷ a.- Parameters:
a
- element to divide by- Returns:
- a new element representing this ÷ a
-
remainder
IEEE remainder operator.- Parameters:
a
- right hand side parameter of the operator- Returns:
- this - n × a where n is the closest integer to this/a (the even integer is chosen for n if this/a is halfway between two integers)
-
remainder
IEEE remainder operator.- Parameters:
a
- right hand side parameter of the operator- Returns:
- this - n × a where n is the closest integer to this/a
-
remainder
IEEE remainder operator.- Parameters:
a
- right hand side parameter of the operator- Returns:
- this - n × a where n is the closest integer to this/a
-
negate
Returns the additive inverse ofthis
element.- Returns:
- the opposite of
this
.
-
abs
absolute value.- Returns:
- abs(this)
-
copySign
Returns the instance with the sign of the argument. A NaNsign
argument is treated as positive.- Parameters:
sign
- the sign for the returned value- Returns:
- the instance with the same sign as the
sign
argument
-
copySign
Returns the instance with the sign of the argument. A NaNsign
argument is treated as positive.- Parameters:
sign
- the sign for the returned value- Returns:
- the instance with the same sign as the
sign
argument
-
copySign
Returns the instance with the sign of the argument. A NaNsign
argument is treated as positive.- Parameters:
sign
- the sign for the returned value- Returns:
- the instance with the same sign as the
sign
argument
-
scalb
Multiply the instance by a power of 2.- Parameters:
n
- power of 2- Returns:
- this × 2n
-
hypot
Returns the hypotenuse of a triangle with sidesthis
andy
- 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.
- Parameters:
y
- a value- Returns:
- sqrt(this2 +y2)
-
reciprocal
Returns the multiplicative inverse ofthis
element.- Returns:
- the inverse of
this
.
-
compose
Compute composition of the instance by a function.- Parameters:
g0
- value of the function at the current point (i.e. atg(getValue())
)g1
- first derivative of the function at the current point (i.e. atg'(getValue())
)g2
- second derivative of the function at the current point (i.e. atg''(getValue())
)- Returns:
- g(this)
-
sqrt
Square root.- Returns:
- square root of the instance
-
cbrt
Cubic root.- Returns:
- cubic root of the instance
-
rootN
Nth root.- Parameters:
n
- order of the root- Returns:
- nth root of the instance
-
getField
Get theField
to which the instance belongs.- Returns:
Field
to which the instance belongs
-
pow
public static <T extends CalculusFieldElement<T>> FieldUnivariateDerivative2<T> pow(double a, FieldUnivariateDerivative2<T> x) Compute ax where a is a double and x aFieldUnivariateDerivative2
- Type Parameters:
T
- the type of the function parameters and value- Parameters:
a
- number to exponentiatex
- power to apply- Returns:
- ax
-
pow
Power operation.- Parameters:
p
- power to apply- Returns:
- thisp
-
pow
Integer power operation.- Parameters:
n
- power to apply- Returns:
- thisn
-
exp
Exponential.- Returns:
- exponential of the instance
-
expm1
Exponential minus 1.- Returns:
- exponential minus one of the instance
-
log
Natural logarithm.- Returns:
- logarithm of the instance
-
log1p
Shifted natural logarithm.- Returns:
- logarithm of one plus the instance
-
log10
Base 10 logarithm.- Returns:
- base 10 logarithm of the instance
-
cos
Cosine operation.- Returns:
- cos(this)
-
sin
Sine operation.- Returns:
- sin(this)
-
sinCos
Combined Sine and Cosine operation.- Returns:
- [sin(this), cos(this)]
-
tan
Tangent operation.- Returns:
- tan(this)
-
acos
Arc cosine operation.- Returns:
- acos(this)
-
asin
Arc sine operation.- Returns:
- asin(this)
-
atan
Arc tangent operation.- Returns:
- atan(this)
-
atan2
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 computesatan2(this, x)
, i.e. the instance represents they
argument and thex
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 languagesatan2
two-arguments arc tangent and putsx
as its first argument.- Parameters:
x
- second argument of the arc tangent- Returns:
- atan2(this, x)
-
cosh
Hyperbolic cosine operation.- Returns:
- cosh(this)
-
sinh
Hyperbolic sine operation.- Returns:
- sinh(this)
-
sinhCosh
Combined hyperbolic sine and cosine operation.- Returns:
- [sinh(this), cosh(this)]
-
tanh
Hyperbolic tangent operation.- Returns:
- tanh(this)
-
acosh
Inverse hyperbolic cosine operation.- Returns:
- acosh(this)
-
asinh
Inverse hyperbolic sine operation.- Returns:
- asin(this)
-
atanh
Inverse hyperbolic tangent operation.- Returns:
- atanh(this)
-
toDegrees
Convert radians to degrees, with error of less than 0.5 ULP- Returns:
- instance converted into degrees
-
toRadians
Convert degrees to radians, with error of less than 0.5 ULP- Returns:
- instance converted into radians
-
taylor
Evaluate Taylor expansion a univariate derivative.- Parameters:
delta
- parameter offset Δx- Returns:
- value of the Taylor expansion at x + Δx
-
taylor
Evaluate Taylor expansion a univariate derivative.- Parameters:
delta
- parameter offset Δx- Returns:
- value of the Taylor expansion at x + Δx
-
linearCombination
Compute a linear combination.- Parameters:
a
- Factors.b
- Factors.- Returns:
Σi ai bi
.- Throws:
MathIllegalArgumentException
- if arrays dimensions don't match
-
linearCombination
public FieldUnivariateDerivative2<T> linearCombination(FieldUnivariateDerivative2<T>[] a, FieldUnivariateDerivative2<T>[] b) Compute a linear combination.- Parameters:
a
- Factors.b
- Factors.- Returns:
Σi ai bi
.
-
linearCombination
public FieldUnivariateDerivative2<T> linearCombination(double[] a, FieldUnivariateDerivative2<T>[] b) Compute a linear combination.- Parameters:
a
- Factors.b
- Factors.- Returns:
Σi ai bi
.
-
linearCombination
public FieldUnivariateDerivative2<T> linearCombination(FieldUnivariateDerivative2<T> a1, FieldUnivariateDerivative2<T> b1, FieldUnivariateDerivative2<T> a2, FieldUnivariateDerivative2<T> b2) Compute a linear combination.- Parameters:
a1
- first factor of the first termb1
- second factor of the first terma2
- first factor of the second termb2
- second factor of the second term- Returns:
- a1×b1 + a2×b2
- See Also:
-
linearCombination
public FieldUnivariateDerivative2<T> linearCombination(double a1, FieldUnivariateDerivative2<T> b1, double a2, FieldUnivariateDerivative2<T> b2) Compute a linear combination.- Parameters:
a1
- first factor of the first termb1
- second factor of the first terma2
- first factor of the second termb2
- second factor of the second term- Returns:
- a1×b1 + a2×b2
- See Also:
-
linearCombination
public FieldUnivariateDerivative2<T> linearCombination(FieldUnivariateDerivative2<T> a1, FieldUnivariateDerivative2<T> b1, FieldUnivariateDerivative2<T> a2, FieldUnivariateDerivative2<T> b2, FieldUnivariateDerivative2<T> a3, FieldUnivariateDerivative2<T> b3) Compute a linear combination.- Parameters:
a1
- first factor of the first termb1
- second factor of the first terma2
- first factor of the second termb2
- second factor of the second terma3
- first factor of the third termb3
- second factor of the third term- Returns:
- a1×b1 + a2×b2 + a3×b3
- See Also:
-
linearCombination
public FieldUnivariateDerivative2<T> linearCombination(T a1, FieldUnivariateDerivative2<T> b1, T a2, FieldUnivariateDerivative2<T> b2, T a3, FieldUnivariateDerivative2<T> b3) Compute a linear combination.- Parameters:
a1
- first factor of the first termb1
- second factor of the first terma2
- first factor of the second termb2
- second factor of the second terma3
- first factor of the third termb3
- second factor of the third term- Returns:
- a1×b1 + a2×b2 + a3×b3
- Throws:
MathIllegalArgumentException
- if number of free parameters or orders are inconsistent- See Also:
-
linearCombination
public FieldUnivariateDerivative2<T> linearCombination(double a1, FieldUnivariateDerivative2<T> b1, double a2, FieldUnivariateDerivative2<T> b2, double a3, FieldUnivariateDerivative2<T> b3) Compute a linear combination.- Parameters:
a1
- first factor of the first termb1
- second factor of the first terma2
- first factor of the second termb2
- second factor of the second terma3
- first factor of the third termb3
- second factor of the third term- Returns:
- a1×b1 + a2×b2 + a3×b3
- See Also:
-
linearCombination
public FieldUnivariateDerivative2<T> linearCombination(FieldUnivariateDerivative2<T> a1, FieldUnivariateDerivative2<T> b1, FieldUnivariateDerivative2<T> a2, FieldUnivariateDerivative2<T> b2, FieldUnivariateDerivative2<T> a3, FieldUnivariateDerivative2<T> b3, FieldUnivariateDerivative2<T> a4, FieldUnivariateDerivative2<T> b4) Compute a linear combination.- Parameters:
a1
- first factor of the first termb1
- second factor of the first terma2
- first factor of the second termb2
- second factor of the second terma3
- first factor of the third termb3
- second factor of the third terma4
- first factor of the fourth termb4
- second factor of the fourth term- Returns:
- a1×b1 + a2×b2 + a3×b3 + a4×b4
- See Also:
-
linearCombination
public FieldUnivariateDerivative2<T> linearCombination(double a1, FieldUnivariateDerivative2<T> b1, double a2, FieldUnivariateDerivative2<T> b2, double a3, FieldUnivariateDerivative2<T> b3, double a4, FieldUnivariateDerivative2<T> b4) Compute a linear combination.- Parameters:
a1
- first factor of the first termb1
- second factor of the first terma2
- first factor of the second termb2
- second factor of the second terma3
- first factor of the third termb3
- second factor of the third terma4
- first factor of the fourth termb4
- second factor of the fourth term- Returns:
- a1×b1 + a2×b2 + a3×b3 + a4×b4
- See Also:
-
getPi
Get the Archimedes constant π.Archimedes constant is the ratio of a circle's circumference to its diameter.
- Returns:
- Archimedes constant π
-
equals
Test for the equality of two univariate derivatives.univariate derivatives are considered equal if they have the same derivatives.
-
hashCode
public int hashCode()Get a hashCode for the univariate derivative.
-