Class UnivariateDerivative1
- java.lang.Object
-
- org.hipparchus.analysis.differentiation.UnivariateDerivative<UnivariateDerivative1>
-
- org.hipparchus.analysis.differentiation.UnivariateDerivative1
-
- All Implemented Interfaces:
Serializable
,Comparable<UnivariateDerivative1>
,Derivative<UnivariateDerivative1>
,Derivative1<UnivariateDerivative1>
,DifferentialAlgebra
,CalculusFieldElement<UnivariateDerivative1>
,FieldElement<UnivariateDerivative1>
public class UnivariateDerivative1 extends UnivariateDerivative<UnivariateDerivative1> implements Derivative1<UnivariateDerivative1>
Class representing both the value and the differentials of a function.This class is a stripped-down version of
DerivativeStructure
with only onefree parameter
andderivation order
also limited to one. It should have less overhead thanDerivativeStructure
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.
UnivariateDerivative1
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 anyCalculusFieldElement
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.
-
-
Field Summary
Fields Modifier and Type Field Description static UnivariateDerivative1
PI
The constant value of π as aUnivariateDerivative1
.
-
Constructor Summary
Constructors Constructor Description UnivariateDerivative1(double f0, double f1)
Build an instance with values and derivative.UnivariateDerivative1(DerivativeStructure ds)
Build an instance from aDerivativeStructure
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description UnivariateDerivative1
abs()
absolute value.UnivariateDerivative1
add(UnivariateDerivative1 a)
Compute this + a.UnivariateDerivative1
atan2(UnivariateDerivative1 x)
Two arguments arc tangent operation.int
compareTo(UnivariateDerivative1 o)
UnivariateDerivative1
compose(double... f)
Compute composition of the instance by a univariate function.UnivariateDerivative1
compose(double ff0, double ff1)
Compute composition of the instance by a univariate function differentiable at order 1.UnivariateDerivative1
copySign(double sign)
Returns the instance with the sign of the argument.UnivariateDerivative1
copySign(UnivariateDerivative1 sign)
Returns the instance with the sign of the argument.UnivariateDerivative1
divide(double a)
'÷' operator.UnivariateDerivative1
divide(UnivariateDerivative1 a)
Compute this ÷ a.boolean
equals(Object other)
Test for the equality of two univariate derivatives.UnivariateDerivative1
getAddendum()
Get the addendum to the real value of the number.double
getDerivative(int n)
Get a derivative from the univariate derivative.UnivariateDerivative1Field
getField()
Get theField
to which the instance belongs.double
getFirstDerivative()
Get the first derivative.UnivariateDerivative1
getPi()
Get the Archimedes constant π.double
getValue()
Get the value part of the function.int
hashCode()
Get a hashCode for the univariate derivative.UnivariateDerivative1
hypot(UnivariateDerivative1 y)
Returns the hypotenuse of a triangle with sidesthis
andy
- sqrt(this2 +y2) avoiding intermediate overflow or underflow.UnivariateDerivative1
linearCombination(double[] a, UnivariateDerivative1[] b)
Compute a linear combination.UnivariateDerivative1
linearCombination(double a1, UnivariateDerivative1 b1, double a2, UnivariateDerivative1 b2)
Compute a linear combination.UnivariateDerivative1
linearCombination(double a1, UnivariateDerivative1 b1, double a2, UnivariateDerivative1 b2, double a3, UnivariateDerivative1 b3)
Compute a linear combination.UnivariateDerivative1
linearCombination(double a1, UnivariateDerivative1 b1, double a2, UnivariateDerivative1 b2, double a3, UnivariateDerivative1 b3, double a4, UnivariateDerivative1 b4)
Compute a linear combination.UnivariateDerivative1
linearCombination(UnivariateDerivative1[] a, UnivariateDerivative1[] b)
Compute a linear combination.UnivariateDerivative1
linearCombination(UnivariateDerivative1 a1, UnivariateDerivative1 b1, UnivariateDerivative1 a2, UnivariateDerivative1 b2)
Compute a linear combination.UnivariateDerivative1
linearCombination(UnivariateDerivative1 a1, UnivariateDerivative1 b1, UnivariateDerivative1 a2, UnivariateDerivative1 b2, UnivariateDerivative1 a3, UnivariateDerivative1 b3)
Compute a linear combination.UnivariateDerivative1
linearCombination(UnivariateDerivative1 a1, UnivariateDerivative1 b1, UnivariateDerivative1 a2, UnivariateDerivative1 b2, UnivariateDerivative1 a3, UnivariateDerivative1 b3, UnivariateDerivative1 a4, UnivariateDerivative1 b4)
Compute a linear combination.UnivariateDerivative1
multiply(double a)
'×' operator.UnivariateDerivative1
multiply(int n)
Compute n × this.UnivariateDerivative1
multiply(UnivariateDerivative1 a)
Compute this × a.UnivariateDerivative1
negate()
Returns the additive inverse ofthis
element.UnivariateDerivative1
newInstance(double value)
Create an instance corresponding to a constant real value.UnivariateDerivative1
pow(double p)
Power operation.static UnivariateDerivative1
pow(double a, UnivariateDerivative1 x)
Compute ax where a is a double and x aUnivariateDerivative1
UnivariateDerivative1
pow(int n)
Integer power operation.UnivariateDerivative1
remainder(UnivariateDerivative1 a)
IEEE remainder operator.UnivariateDerivative1
scalb(int n)
Multiply the instance by a power of 2.UnivariateDerivative1
subtract(UnivariateDerivative1 a)
Compute this - a.double
taylor(double delta)
Evaluate Taylor expansion a univariate derivative.UnivariateDerivative1
toDegrees()
Convert radians to degrees, with error of less than 0.5 ULPDerivativeStructure
toDerivativeStructure()
Convert the instance to aDerivativeStructure
.UnivariateDerivative1
toRadians()
Convert degrees to radians, with error of less than 0.5 ULPUnivariateDerivative1
withValue(double value)
Create 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.UnivariateDerivative
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
ceil, floor, isFinite, isInfinite, isNaN, norm, rint, round, sign, ulp
-
Methods inherited from interface org.hipparchus.analysis.differentiation.Derivative
add, getExponent, getPartialDerivative, getReal, pow, remainder, subtract
-
Methods inherited from interface org.hipparchus.analysis.differentiation.Derivative1
acos, acosh, asin, asinh, atan, atanh, cbrt, cos, cosh, exp, expm1, getOrder, log, log10, log1p, reciprocal, rootN, sin, sinCos, sinh, sinhCosh, sqrt, square, tan, tanh
-
Methods inherited from interface org.hipparchus.analysis.differentiation.DifferentialAlgebra
getFreeParameters
-
Methods inherited from interface org.hipparchus.FieldElement
isZero
-
-
-
-
Field Detail
-
PI
public static final UnivariateDerivative1 PI
The constant value of π as aUnivariateDerivative1
.- Since:
- 2.0
-
-
Constructor Detail
-
UnivariateDerivative1
public UnivariateDerivative1(double f0, double f1)
Build an instance with values and derivative.- Parameters:
f0
- value of the functionf1
- first derivative of the function
-
UnivariateDerivative1
public UnivariateDerivative1(DerivativeStructure ds) throws MathIllegalArgumentException
Build an instance from aDerivativeStructure
.- Parameters:
ds
- derivative structure- Throws:
MathIllegalArgumentException
- if eitherds
parameters is not 1 ords
order is not 1
-
-
Method Detail
-
newInstance
public UnivariateDerivative1 newInstance(double value)
Create an instance corresponding to a constant real value.- Specified by:
newInstance
in interfaceCalculusFieldElement<UnivariateDerivative1>
- Parameters:
value
- constant real value- Returns:
- instance corresponding to a constant real value
-
withValue
public UnivariateDerivative1 withValue(double value)
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:
withValue
in interfaceDerivative<UnivariateDerivative1>
- Parameters:
value
- zeroth-order derivative of new represented function- Returns:
- new object with changed value
-
getAddendum
public UnivariateDerivative1 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 part
recovers the instance. This means that whene.getReal()
is finite (i.e. neither infinite nor NaN), thene.getAddendum().add(e.getReal())
ise
ande.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:
getAddendum
in interfaceCalculusFieldElement<UnivariateDerivative1>
- Returns:
- real value
-
getValue
public double getValue()
Get the value part of the function.- Specified by:
getValue
in interfaceDerivative<UnivariateDerivative1>
- Returns:
- value part of the value of the function
-
getDerivative
public double getDerivative(int n)
Get a derivative from the univariate derivative.- Specified by:
getDerivative
in classUnivariateDerivative<UnivariateDerivative1>
- Parameters:
n
- derivation order (must be between 0 andDifferentialAlgebra.getOrder()
, both inclusive)- Returns:
- nth derivative
-
getFirstDerivative
public double getFirstDerivative()
Get the first derivative.- Returns:
- first derivative
- See Also:
getValue()
-
toDerivativeStructure
public DerivativeStructure toDerivativeStructure()
Convert the instance to aDerivativeStructure
.- Specified by:
toDerivativeStructure
in classUnivariateDerivative<UnivariateDerivative1>
- Returns:
- derivative structure with same value and derivative as the instance
-
add
public UnivariateDerivative1 add(UnivariateDerivative1 a)
Compute this + a.- Specified by:
add
in interfaceFieldElement<UnivariateDerivative1>
- Parameters:
a
- element to add- Returns:
- a new element representing this + a
-
subtract
public UnivariateDerivative1 subtract(UnivariateDerivative1 a)
Compute this - a.- Specified by:
subtract
in interfaceCalculusFieldElement<UnivariateDerivative1>
- Specified by:
subtract
in interfaceFieldElement<UnivariateDerivative1>
- Parameters:
a
- element to subtract- Returns:
- a new element representing this - a
-
multiply
public UnivariateDerivative1 multiply(int n)
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:
multiply
in interfaceCalculusFieldElement<UnivariateDerivative1>
- Specified by:
multiply
in interfaceFieldElement<UnivariateDerivative1>
- Parameters:
n
- Number of timesthis
must be added to itself.- Returns:
- A new element representing n × this.
-
multiply
public UnivariateDerivative1 multiply(double a)
'×' operator.- Specified by:
multiply
in interfaceCalculusFieldElement<UnivariateDerivative1>
- Parameters:
a
- right hand side parameter of the operator- Returns:
- this×a
-
multiply
public UnivariateDerivative1 multiply(UnivariateDerivative1 a)
Compute this × a.- Specified by:
multiply
in interfaceFieldElement<UnivariateDerivative1>
- Parameters:
a
- element to multiply- Returns:
- a new element representing this × a
-
divide
public UnivariateDerivative1 divide(double a)
'÷' operator.- Specified by:
divide
in interfaceCalculusFieldElement<UnivariateDerivative1>
- Parameters:
a
- right hand side parameter of the operator- Returns:
- this÷a
-
divide
public UnivariateDerivative1 divide(UnivariateDerivative1 a)
Compute this ÷ a.- Specified by:
divide
in interfaceCalculusFieldElement<UnivariateDerivative1>
- Specified by:
divide
in interfaceFieldElement<UnivariateDerivative1>
- Parameters:
a
- element to divide by- Returns:
- a new element representing this ÷ a
-
remainder
public UnivariateDerivative1 remainder(UnivariateDerivative1 a)
IEEE remainder operator.- Specified by:
remainder
in interfaceCalculusFieldElement<UnivariateDerivative1>
- Parameters:
a
- right hand side parameter of the operator- Returns:
- this - n × a where n is the closest integer to this/a
-
negate
public UnivariateDerivative1 negate()
Returns the additive inverse ofthis
element.- Specified by:
negate
in interfaceFieldElement<UnivariateDerivative1>
- Returns:
- the opposite of
this
.
-
abs
public UnivariateDerivative1 abs()
absolute value.- Specified by:
abs
in interfaceCalculusFieldElement<UnivariateDerivative1>
- Returns:
- abs(this)
-
copySign
public UnivariateDerivative1 copySign(UnivariateDerivative1 sign)
Returns the instance with the sign of the argument. A NaNsign
argument is treated as positive.- Specified by:
copySign
in interfaceCalculusFieldElement<UnivariateDerivative1>
- Parameters:
sign
- the sign for the returned value- Returns:
- the instance with the same sign as the
sign
argument
-
copySign
public UnivariateDerivative1 copySign(double sign)
Returns the instance with the sign of the argument. A NaNsign
argument is treated as positive.- Specified by:
copySign
in interfaceCalculusFieldElement<UnivariateDerivative1>
- Parameters:
sign
- the sign for the returned value- Returns:
- the instance with the same sign as the
sign
argument
-
scalb
public UnivariateDerivative1 scalb(int n)
Multiply the instance by a power of 2.- Specified by:
scalb
in interfaceCalculusFieldElement<UnivariateDerivative1>
- Parameters:
n
- power of 2- Returns:
- this × 2n
-
hypot
public UnivariateDerivative1 hypot(UnivariateDerivative1 y)
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.
- Specified by:
hypot
in interfaceCalculusFieldElement<UnivariateDerivative1>
- Parameters:
y
- a value- Returns:
- sqrt(this2 +y2)
-
compose
public UnivariateDerivative1 compose(double... f)
Compute composition of the instance by a univariate function.- Specified by:
compose
in interfaceDerivative<UnivariateDerivative1>
- Parameters:
f
- array of value and derivatives of the function at the current point (i.e. [f(Derivative.getValue()
), f'(Derivative.getValue()
), f''(Derivative.getValue()
)...]).- Returns:
- f(this)
-
compose
public UnivariateDerivative1 compose(double ff0, double ff1)
Compute composition of the instance by a univariate function differentiable at order 1.- Specified by:
compose
in interfaceDerivative1<UnivariateDerivative1>
- Parameters:
ff0
- value of functionff1
- first-order derivative- Returns:
- f(this)
-
getField
public UnivariateDerivative1Field getField()
Get theField
to which the instance belongs.- Specified by:
getField
in interfaceFieldElement<UnivariateDerivative1>
- Returns:
Field
to which the instance belongs
-
pow
public static UnivariateDerivative1 pow(double a, UnivariateDerivative1 x)
Compute ax where a is a double and x aUnivariateDerivative1
- Parameters:
a
- number to exponentiatex
- power to apply- Returns:
- ax
-
pow
public UnivariateDerivative1 pow(double p)
Power operation.- Specified by:
pow
in interfaceCalculusFieldElement<UnivariateDerivative1>
- Parameters:
p
- power to apply- Returns:
- thisp
-
pow
public UnivariateDerivative1 pow(int n)
Integer power operation.- Specified by:
pow
in interfaceCalculusFieldElement<UnivariateDerivative1>
- Parameters:
n
- power to apply- Returns:
- thisn
-
atan2
public UnivariateDerivative1 atan2(UnivariateDerivative1 x)
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.- Specified by:
atan2
in interfaceCalculusFieldElement<UnivariateDerivative1>
- Parameters:
x
- second argument of the arc tangent- Returns:
- atan2(this, x)
-
toDegrees
public UnivariateDerivative1 toDegrees()
Convert radians to degrees, with error of less than 0.5 ULP- Specified by:
toDegrees
in interfaceCalculusFieldElement<UnivariateDerivative1>
- Returns:
- instance converted into degrees
-
toRadians
public UnivariateDerivative1 toRadians()
Convert degrees to radians, with error of less than 0.5 ULP- Specified by:
toRadians
in interfaceCalculusFieldElement<UnivariateDerivative1>
- Returns:
- instance converted into radians
-
taylor
public double taylor(double delta)
Evaluate Taylor expansion a univariate derivative.- Parameters:
delta
- parameter offset Δx- Returns:
- value of the Taylor expansion at x + Δx
-
linearCombination
public UnivariateDerivative1 linearCombination(UnivariateDerivative1[] a, UnivariateDerivative1[] b)
Compute a linear combination.- Specified by:
linearCombination
in interfaceCalculusFieldElement<UnivariateDerivative1>
- Parameters:
a
- Factors.b
- Factors.- Returns:
Σi ai bi
.
-
linearCombination
public UnivariateDerivative1 linearCombination(double[] a, UnivariateDerivative1[] b)
Compute a linear combination.- Specified by:
linearCombination
in interfaceCalculusFieldElement<UnivariateDerivative1>
- Parameters:
a
- Factors.b
- Factors.- Returns:
Σi ai bi
.
-
linearCombination
public UnivariateDerivative1 linearCombination(UnivariateDerivative1 a1, UnivariateDerivative1 b1, UnivariateDerivative1 a2, UnivariateDerivative1 b2)
Compute a linear combination.- Specified by:
linearCombination
in interfaceCalculusFieldElement<UnivariateDerivative1>
- 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:
CalculusFieldElement.linearCombination(FieldElement, FieldElement, FieldElement, FieldElement, FieldElement, FieldElement)
,CalculusFieldElement.linearCombination(FieldElement, FieldElement, FieldElement, FieldElement, FieldElement, FieldElement, FieldElement, FieldElement)
-
linearCombination
public UnivariateDerivative1 linearCombination(double a1, UnivariateDerivative1 b1, double a2, UnivariateDerivative1 b2)
Compute a linear combination.- Specified by:
linearCombination
in interfaceCalculusFieldElement<UnivariateDerivative1>
- 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:
CalculusFieldElement.linearCombination(double, FieldElement, double, FieldElement, double, FieldElement)
,CalculusFieldElement.linearCombination(double, FieldElement, double, FieldElement, double, FieldElement, double, FieldElement)
-
linearCombination
public UnivariateDerivative1 linearCombination(UnivariateDerivative1 a1, UnivariateDerivative1 b1, UnivariateDerivative1 a2, UnivariateDerivative1 b2, UnivariateDerivative1 a3, UnivariateDerivative1 b3)
Compute a linear combination.- Specified by:
linearCombination
in interfaceCalculusFieldElement<UnivariateDerivative1>
- 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:
CalculusFieldElement.linearCombination(FieldElement, FieldElement, FieldElement, FieldElement)
,CalculusFieldElement.linearCombination(FieldElement, FieldElement, FieldElement, FieldElement, FieldElement, FieldElement, FieldElement, FieldElement)
-
linearCombination
public UnivariateDerivative1 linearCombination(double a1, UnivariateDerivative1 b1, double a2, UnivariateDerivative1 b2, double a3, UnivariateDerivative1 b3)
Compute a linear combination.- Specified by:
linearCombination
in interfaceCalculusFieldElement<UnivariateDerivative1>
- 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:
CalculusFieldElement.linearCombination(double, FieldElement, double, FieldElement)
,CalculusFieldElement.linearCombination(double, FieldElement, double, FieldElement, double, FieldElement, double, FieldElement)
-
linearCombination
public UnivariateDerivative1 linearCombination(UnivariateDerivative1 a1, UnivariateDerivative1 b1, UnivariateDerivative1 a2, UnivariateDerivative1 b2, UnivariateDerivative1 a3, UnivariateDerivative1 b3, UnivariateDerivative1 a4, UnivariateDerivative1 b4)
Compute a linear combination.- Specified by:
linearCombination
in interfaceCalculusFieldElement<UnivariateDerivative1>
- 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:
CalculusFieldElement.linearCombination(FieldElement, FieldElement, FieldElement, FieldElement)
,CalculusFieldElement.linearCombination(FieldElement, FieldElement, FieldElement, FieldElement, FieldElement, FieldElement)
-
linearCombination
public UnivariateDerivative1 linearCombination(double a1, UnivariateDerivative1 b1, double a2, UnivariateDerivative1 b2, double a3, UnivariateDerivative1 b3, double a4, UnivariateDerivative1 b4)
Compute a linear combination.- Specified by:
linearCombination
in interfaceCalculusFieldElement<UnivariateDerivative1>
- 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:
CalculusFieldElement.linearCombination(double, FieldElement, double, FieldElement)
,CalculusFieldElement.linearCombination(double, FieldElement, double, FieldElement, double, FieldElement)
-
getPi
public UnivariateDerivative1 getPi()
Get the Archimedes constant π.Archimedes constant is the ratio of a circle's circumference to its diameter.
- Specified by:
getPi
in interfaceCalculusFieldElement<UnivariateDerivative1>
- Returns:
- Archimedes constant π
-
equals
public boolean equals(Object other)
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.
-
compareTo
public int compareTo(UnivariateDerivative1 o)
Comparison performed considering that derivatives are intrinsically linked to monomials in the corresponding Taylor expansion and that the higher the degree, the smaller the term.
- Specified by:
compareTo
in interfaceComparable<UnivariateDerivative1>
- Since:
- 3.0
-
-