Class FieldUnivariateDerivative1<T extends CalculusFieldElement<T>>
- Type Parameters:
T- the type of the function parameters and value
- All Implemented Interfaces:
DifferentialAlgebra,FieldDerivative<T,,FieldUnivariateDerivative1<T>> FieldDerivative1<T,,FieldUnivariateDerivative1<T>> CalculusFieldElement<FieldUnivariateDerivative1<T>>,FieldElement<FieldUnivariateDerivative1<T>>
This class is a stripped-down version of FieldDerivativeStructure
with only one free parameter
and derivation order also limited to one.
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.
FieldUnivariateDerivative1 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 Derivative-based
classes (or in fact any CalculusFieldElement class) is
a tedious and error-prone task but has the advantage of not requiring users
to compute the derivatives by themselves and allowing to switch for one
derivative implementation to another as they all share the same filed API.
Instances of this class are guaranteed to be immutable.
- Since:
- 1.7
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionBuild an instance from aFieldDerivativeStructure.FieldUnivariateDerivative1(T f0, T f1) Build an instance with values and derivative. -
Method Summary
Modifier and TypeMethodDescriptionabs()absolute value.add(double a) '+' operator.Compute this + a.Two arguments arc tangent operation.Compute composition of the instance by a function.copySign(double sign) Returns the instance with the sign of the argument.copySign(FieldUnivariateDerivative1<T> sign) Returns the instance with the sign of the argument.Returns the instance with the sign of the argument.divide(double a) '÷' operator.Compute this ÷ a.'÷' operator.booleanTest for the equality of two univariate derivatives.Get the addendum to the real value of the number.getDerivative(int n) Get a derivative from the univariate derivative.getField()Get theFieldto which the instance belongs.Get the first derivative.getPi()Get the Archimedes constant π.getValue()Get the value part of the univariate derivative.Get theFieldthe value and parameters of the function belongs to.inthashCode()Get a hashCode for the univariate derivative.Returns the hypotenuse of a triangle with sidesthisandy- sqrt(this2 +y2) avoiding intermediate overflow or underflow.linearCombination(double[] a, FieldUnivariateDerivative1<T>[] b) Compute a linear combination.linearCombination(double a1, FieldUnivariateDerivative1<T> b1, double a2, FieldUnivariateDerivative1<T> b2) Compute a linear combination.linearCombination(double a1, FieldUnivariateDerivative1<T> b1, double a2, FieldUnivariateDerivative1<T> b2, double a3, FieldUnivariateDerivative1<T> b3) Compute a linear combination.linearCombination(double a1, FieldUnivariateDerivative1<T> b1, double a2, FieldUnivariateDerivative1<T> b2, double a3, FieldUnivariateDerivative1<T> b3, double a4, FieldUnivariateDerivative1<T> b4) Compute a linear combination.Compute a linear combination.linearCombination(FieldUnivariateDerivative1<T> a1, FieldUnivariateDerivative1<T> b1, FieldUnivariateDerivative1<T> a2, FieldUnivariateDerivative1<T> b2) Compute a linear combination.linearCombination(FieldUnivariateDerivative1<T> a1, FieldUnivariateDerivative1<T> b1, FieldUnivariateDerivative1<T> a2, FieldUnivariateDerivative1<T> b2, FieldUnivariateDerivative1<T> a3, FieldUnivariateDerivative1<T> b3) Compute a linear combination.linearCombination(FieldUnivariateDerivative1<T> a1, FieldUnivariateDerivative1<T> b1, FieldUnivariateDerivative1<T> a2, FieldUnivariateDerivative1<T> b2, FieldUnivariateDerivative1<T> a3, FieldUnivariateDerivative1<T> b3, FieldUnivariateDerivative1<T> a4, FieldUnivariateDerivative1<T> b4) Compute a linear combination.linearCombination(T[] a, FieldUnivariateDerivative1<T>[] b) Compute a linear combination.linearCombination(T a1, FieldUnivariateDerivative1<T> b1, T a2, FieldUnivariateDerivative1<T> b2, T a3, FieldUnivariateDerivative1<T> b3) Compute a linear combination.multiply(double a) '×' operator.multiply(int n) Compute n × this.Compute this × a.'×' operator.negate()Returns the additive inverse ofthiselement.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>>
FieldUnivariateDerivative1<T> pow(double a, FieldUnivariateDerivative1<T> x) Compute ax where a is a double and x aFieldUnivariateDerivative1pow(int n) Integer power operation.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.subtract(double a) '-' operator.Compute this - a.taylor(double delta) Evaluate Taylor expansion of a univariate derivative.Evaluate Taylor expansion of 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, getPartialDerivativeMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.hipparchus.CalculusFieldElement
isFinite, isInfinite, isNaN, norm, roundMethods inherited from interface org.hipparchus.analysis.differentiation.DifferentialAlgebra
getFreeParametersMethods inherited from interface org.hipparchus.analysis.differentiation.FieldDerivative
add, ceil, floor, getExponent, getPartialDerivative, getReal, pow, rint, sign, subtract, ulpMethods inherited from interface org.hipparchus.analysis.differentiation.FieldDerivative1
acos, acosh, asin, asinh, atan, atanh, cbrt, cos, cosh, exp, expm1, getOrder, log, log10, log1p, reciprocal, sin, sinCos, sinh, sinhCosh, sqrt, square, tan, tanhMethods inherited from interface org.hipparchus.FieldElement
isZero
-
Constructor Details
-
FieldUnivariateDerivative1
Build an instance with values and derivative.- Parameters:
f0- value of the functionf1- first derivative of the function
-
FieldUnivariateDerivative1
public FieldUnivariateDerivative1(FieldDerivativeStructure<T> ds) throws MathIllegalArgumentException Build an instance from aFieldDerivativeStructure.- Parameters:
ds- derivative structure- Throws:
MathIllegalArgumentException- if eitherdsparameters is not 1 ordsorder is not 1
-
-
Method Details
-
newInstance
Create an instance corresponding to a constant real value.- Specified by:
newInstancein interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>- 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.
- Specified by:
newInstancein interfaceFieldDerivative<T extends CalculusFieldElement<T>,FieldUnivariateDerivative1<T extends CalculusFieldElement<T>>> - 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.
- Specified by:
withValuein interfaceFieldDerivative<T extends CalculusFieldElement<T>,FieldUnivariateDerivative1<T extends CalculusFieldElement<T>>> - Parameters:
value- zeroth-order derivative of new represented function- Returns:
- new object with changed value
-
getAddendum
Get the addendum to the real value of the number.The addendum is considered to be the part that when added back to the
real partrecovers the instance. This means that whene.getReal()is finite (i.e. neither infinite nor NaN), thene.getAddendum().add(e.getReal())iseande.subtract(e.getReal())ise.getAddendum(). Beware that for non-finite numbers, these two equalities may not hold. The first equality (with the addition), always holds even for infinity and NaNs if the real part is independent of the addendum (this is the case for all derivatives types, as well as for complex and Dfp, but it is not the case for Tuple and FieldTuple). The second equality (with the subtraction), generally doesn't hold for non-finite numbers, because the subtraction generates NaNs.- Specified by:
getAddendumin interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>- Returns:
- real value
-
getValue
Get the value part of the univariate derivative.- Specified by:
getValuein interfaceFieldDerivative<T extends CalculusFieldElement<T>,FieldUnivariateDerivative1<T extends CalculusFieldElement<T>>> - Returns:
- value part of the univariate derivative
-
getDerivative
Get a derivative from the univariate derivative.- Specified by:
getDerivativein classFieldUnivariateDerivative<T extends CalculusFieldElement<T>,FieldUnivariateDerivative1<T extends CalculusFieldElement<T>>> - Parameters:
n- derivation order (must be between 0 andDifferentialAlgebra.getOrder(), both inclusive)- Returns:
- nth derivative, or
NaNif n is either negative or strictly larger thanDifferentialAlgebra.getOrder()
-
getFirstDerivative
Get the first derivative.- Returns:
- first derivative
- See Also:
-
getValueField
Get theFieldthe value and parameters of the function belongs to.- Returns:
Fieldthe value and parameters of the function belongs to
-
toDerivativeStructure
Convert the instance to aFieldDerivativeStructure.- Specified by:
toDerivativeStructurein classFieldUnivariateDerivative<T extends CalculusFieldElement<T>,FieldUnivariateDerivative1<T extends CalculusFieldElement<T>>> - Returns:
- derivative structure with same value and derivative as the instance
-
add
'+' operator.- Specified by:
addin interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>- Parameters:
a- right hand side parameter of the operator- Returns:
- this+a
-
add
Compute this + a.- Specified by:
addin interfaceFieldElement<T extends CalculusFieldElement<T>>- Parameters:
a- element to add- Returns:
- a new element representing this + a
-
subtract
'-' operator.- Specified by:
subtractin interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>- Parameters:
a- right hand side parameter of the operator- Returns:
- this-a
-
subtract
Compute this - a.- Specified by:
subtractin interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>- Specified by:
subtractin interfaceFieldElement<T extends CalculusFieldElement<T>>- 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} \]- Specified by:
multiplyin interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>- Specified by:
multiplyin interfaceFieldElement<T extends CalculusFieldElement<T>>- Parameters:
n- Number of timesthismust be added to itself.- Returns:
- A new element representing n × this.
-
multiply
'×' operator.- Specified by:
multiplyin interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>- Parameters:
a- right hand side parameter of the operator- Returns:
- this×a
-
multiply
Compute this × a.- Specified by:
multiplyin interfaceFieldElement<T extends CalculusFieldElement<T>>- Parameters:
a- element to multiply- Returns:
- a new element representing this × a
-
divide
'÷' operator.- Parameters:
a- right hand side parameter of the operator- Returns:
- this÷a
-
divide
'÷' operator.- Specified by:
dividein interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>- Parameters:
a- right hand side parameter of the operator- Returns:
- this÷a
-
divide
Compute this ÷ a.- Specified by:
dividein interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>- Specified by:
dividein interfaceFieldElement<T extends CalculusFieldElement<T>>- 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.- Specified by:
remainderin interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>- 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.- Specified by:
remainderin interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>- 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 ofthiselement.- Specified by:
negatein interfaceFieldElement<T extends CalculusFieldElement<T>>- Returns:
- the opposite of
this.
-
abs
absolute value.- Specified by:
absin interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>- Returns:
- abs(this)
-
copySign
Returns the instance with the sign of the argument. A NaNsignargument is treated as positive.- Parameters:
sign- the sign for the returned value- Returns:
- the instance with the same sign as the
signargument
-
copySign
Returns the instance with the sign of the argument. A NaNsignargument is treated as positive.- Specified by:
copySignin interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>- Parameters:
sign- the sign for the returned value- Returns:
- the instance with the same sign as the
signargument
-
copySign
Returns the instance with the sign of the argument. A NaNsignargument is treated as positive.- Specified by:
copySignin interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>- Parameters:
sign- the sign for the returned value- Returns:
- the instance with the same sign as the
signargument
-
scalb
Multiply the instance by a power of 2.- Specified by:
scalbin interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>- Parameters:
n- power of 2- Returns:
- this × 2n
-
hypot
Returns the hypotenuse of a triangle with sidesthisandy- 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:
hypotin interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>- Parameters:
y- a value- Returns:
- sqrt(this2 +y2)
-
compose
Compute composition of the instance by a function.- Specified by:
composein interfaceFieldDerivative1<T extends CalculusFieldElement<T>,FieldUnivariateDerivative1<T extends CalculusFieldElement<T>>> - 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()))- Returns:
- g(this)
-
rootN
Nth root.- Specified by:
rootNin interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>- Parameters:
n- order of the root- Returns:
- nth root of the instance
-
getField
Get theFieldto which the instance belongs.- Specified by:
getFieldin interfaceFieldElement<T extends CalculusFieldElement<T>>- Returns:
Fieldto which the instance belongs
-
pow
public static <T extends CalculusFieldElement<T>> FieldUnivariateDerivative1<T> pow(double a, FieldUnivariateDerivative1<T> x) Compute ax where a is a double and x aFieldUnivariateDerivative1- Type Parameters:
T- the type of the function parameters and value- Parameters:
a- number to exponentiatex- power to apply- Returns:
- ax
-
pow
Power operation.- Specified by:
powin interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>- Parameters:
p- power to apply- Returns:
- thisp
-
pow
Integer power operation.- Specified by:
powin interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>- Parameters:
n- power to apply- Returns:
- thisn
-
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 theyargument and thexargument 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 languagesatan2two-arguments arc tangent and putsxas its first argument.- Specified by:
atan2in interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>- Parameters:
x- second argument of the arc tangent- Returns:
- atan2(this, x)
-
toDegrees
Convert radians to degrees, with error of less than 0.5 ULP- Specified by:
toDegreesin interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>- Returns:
- instance converted into degrees
-
toRadians
Convert degrees to radians, with error of less than 0.5 ULP- Specified by:
toRadiansin interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>- Returns:
- instance converted into radians
-
taylor
Evaluate Taylor expansion of a univariate derivative.- Parameters:
delta- parameter offset Δx- Returns:
- value of the Taylor expansion at x + Δx
-
taylor
Evaluate Taylor expansion of 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 FieldUnivariateDerivative1<T> linearCombination(FieldUnivariateDerivative1<T>[] a, FieldUnivariateDerivative1<T>[] b) Compute a linear combination.- Specified by:
linearCombinationin interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>- Parameters:
a- Factors.b- Factors.- Returns:
Σi ai bi.
-
linearCombination
public FieldUnivariateDerivative1<T> linearCombination(double[] a, FieldUnivariateDerivative1<T>[] b) Compute a linear combination.- Specified by:
linearCombinationin interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>- Parameters:
a- Factors.b- Factors.- Returns:
Σi ai bi.
-
linearCombination
public FieldUnivariateDerivative1<T> linearCombination(FieldUnivariateDerivative1<T> a1, FieldUnivariateDerivative1<T> b1, FieldUnivariateDerivative1<T> a2, FieldUnivariateDerivative1<T> b2) Compute a linear combination.- Specified by:
linearCombinationin interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>- 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 FieldUnivariateDerivative1<T> linearCombination(double a1, FieldUnivariateDerivative1<T> b1, double a2, FieldUnivariateDerivative1<T> b2) Compute a linear combination.- Specified by:
linearCombinationin interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>- 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 FieldUnivariateDerivative1<T> linearCombination(FieldUnivariateDerivative1<T> a1, FieldUnivariateDerivative1<T> b1, FieldUnivariateDerivative1<T> a2, FieldUnivariateDerivative1<T> b2, FieldUnivariateDerivative1<T> a3, FieldUnivariateDerivative1<T> b3) Compute a linear combination.- Specified by:
linearCombinationin interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>- 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 FieldUnivariateDerivative1<T> linearCombination(T a1, FieldUnivariateDerivative1<T> b1, T a2, FieldUnivariateDerivative1<T> b2, T a3, FieldUnivariateDerivative1<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 FieldUnivariateDerivative1<T> linearCombination(double a1, FieldUnivariateDerivative1<T> b1, double a2, FieldUnivariateDerivative1<T> b2, double a3, FieldUnivariateDerivative1<T> b3) Compute a linear combination.- Specified by:
linearCombinationin interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>- 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 FieldUnivariateDerivative1<T> linearCombination(FieldUnivariateDerivative1<T> a1, FieldUnivariateDerivative1<T> b1, FieldUnivariateDerivative1<T> a2, FieldUnivariateDerivative1<T> b2, FieldUnivariateDerivative1<T> a3, FieldUnivariateDerivative1<T> b3, FieldUnivariateDerivative1<T> a4, FieldUnivariateDerivative1<T> b4) Compute a linear combination.- Specified by:
linearCombinationin interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>- 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 FieldUnivariateDerivative1<T> linearCombination(double a1, FieldUnivariateDerivative1<T> b1, double a2, FieldUnivariateDerivative1<T> b2, double a3, FieldUnivariateDerivative1<T> b3, double a4, FieldUnivariateDerivative1<T> b4) Compute a linear combination.- Specified by:
linearCombinationin interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>- 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.
- Specified by:
getPiin interfaceCalculusFieldElement<T extends CalculusFieldElement<T>>- 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.
-