Class Calculus
- java.lang.Object
-
- org.mariuszgromada.math.mxparser.mathcollection.Calculus
-
public final class Calculus extends Object
Calculus - numerical integration, differentiation, etc...
-
-
Field Summary
Fields Modifier and Type Field Description static intGENERAL_DERIVATIVEstatic intLEFT_DERIVATIVEDerivative type specificationstatic intRIGHT_DERIVATIVE
-
Constructor Summary
Constructors Constructor Description Calculus()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static doublebackwardDifference(Expression f, double h, Argument x)Backward difference(h) operator (at the current value of the argument x)static doublebackwardDifference(Expression f, double h, Argument x, double x0)Backward difference(h) operator (at x = x0)static doublebackwardDifference(Expression f, Argument x)Backward difference(1) operator (at current value of argument x)static doublebackwardDifference(Expression f, Argument x, double x0)Backward difference(1) operator (at x = x0).static doublederivative(Expression f, Argument x, double x0, int derType, double eps, int maxSteps)Numerical derivative at x = x0static doublederivativeNth(Expression f, double n, Argument x, double x0, int derType, double eps, int maxSteps)Numerical n-th derivative at x = x0 (you should avoid calculation of derivatives with order higher than 2).static doubleforwardDifference(Expression f, double h, Argument x)Forward difference(h) operator (at the current value of the argument x)static doubleforwardDifference(Expression f, double h, Argument x, double x0)Forward difference(h) operator (at x = x0)static doubleforwardDifference(Expression f, Argument x)Forward difference(1) operator (at current value of argument x)static doubleforwardDifference(Expression f, Argument x, double x0)Forward difference(1) operator (at x = x0)static doubleintegralTrapezoid(Expression f, Argument x, double a, double b, double eps, int maxSteps)Trapezoid numerical integrationstatic doublesolveBrent(Expression f, Argument x, double a, double b, double eps, double maxSteps)Brent solver (Brent root finder)
-
-
-
Field Detail
-
LEFT_DERIVATIVE
public static final int LEFT_DERIVATIVE
Derivative type specification- See Also:
- Constant Field Values
-
RIGHT_DERIVATIVE
public static final int RIGHT_DERIVATIVE
- See Also:
- Constant Field Values
-
GENERAL_DERIVATIVE
public static final int GENERAL_DERIVATIVE
- See Also:
- Constant Field Values
-
-
Method Detail
-
integralTrapezoid
public static double integralTrapezoid(Expression f, Argument x, double a, double b, double eps, int maxSteps)
Trapezoid numerical integration- Parameters:
f- the expressionx- the argumenta- form a ...b- ... to beps- the epsilon (error)maxSteps- the maximum number of steps- Returns:
- Integral value as double.
- See Also:
Expression
-
derivative
public static double derivative(Expression f, Argument x, double x0, int derType, double eps, int maxSteps)
Numerical derivative at x = x0- Parameters:
f- the expressionx- the argumentx0- at point x = x0derType- derivative type (LEFT_DERIVATIVE, RIGHT_DERIVATIVE, GENERAL_DERIVATIVEeps- the epsilon (error)maxSteps- the maximum number of steps- Returns:
- Derivative value as double.
- See Also:
Expression
-
derivativeNth
public static double derivativeNth(Expression f, double n, Argument x, double x0, int derType, double eps, int maxSteps)
Numerical n-th derivative at x = x0 (you should avoid calculation of derivatives with order higher than 2).- Parameters:
f- the expressionn- the deriviative orderx- the argumentx0- at point x = x0derType- derivative type (LEFT_DERIVATIVE, RIGHT_DERIVATIVE, GENERAL_DERIVATIVEeps- the epsilon (error)maxSteps- the maximum number of steps- Returns:
- Derivative value as double.
- See Also:
Expression
-
forwardDifference
public static double forwardDifference(Expression f, Argument x, double x0)
Forward difference(1) operator (at x = x0)- Parameters:
f- the expressionx- the argument namex0- x = x0- Returns:
- Forward difference(1) value calculated at x0.
- See Also:
Expression,Argument
-
forwardDifference
public static double forwardDifference(Expression f, Argument x)
Forward difference(1) operator (at current value of argument x)- Parameters:
f- the expressionx- the argument name- Returns:
- Forward difference(1) value calculated at the current value of argument x.
- See Also:
Expression,Argument
-
backwardDifference
public static double backwardDifference(Expression f, Argument x, double x0)
Backward difference(1) operator (at x = x0).- Parameters:
f- the expressionx- the argument namex0- x = x0- Returns:
- Backward difference value calculated at x0.
- See Also:
Expression,Argument
-
backwardDifference
public static double backwardDifference(Expression f, Argument x)
Backward difference(1) operator (at current value of argument x)- Parameters:
f- the expressionx- the argument name- Returns:
- Backward difference(1) value calculated at the current value of argument x.
- See Also:
Expression,Argument
-
forwardDifference
public static double forwardDifference(Expression f, double h, Argument x, double x0)
Forward difference(h) operator (at x = x0)- Parameters:
f- the expressionh- the differencex- the argument namex0- x = x0- Returns:
- Forward difference(h) value calculated at x0.
- See Also:
Expression,Argument
-
forwardDifference
public static double forwardDifference(Expression f, double h, Argument x)
Forward difference(h) operator (at the current value of the argument x)- Parameters:
f- the expressionh- the differencex- the argument name- Returns:
- Forward difference(h) value calculated at at the current value of the argument x.
- See Also:
Expression,Argument
-
backwardDifference
public static double backwardDifference(Expression f, double h, Argument x, double x0)
Backward difference(h) operator (at x = x0)- Parameters:
f- the expressionh- the differencex- the argument namex0- x = x0- Returns:
- Backward difference(h) value calculated at x0.
- See Also:
Expression,Argument
-
backwardDifference
public static double backwardDifference(Expression f, double h, Argument x)
Backward difference(h) operator (at the current value of the argument x)- Parameters:
f- the expressionh- the differencex- the argument name- Returns:
- Backward difference(h) value calculated at at the current value of the argument x.
- See Also:
Expression,Argument
-
solveBrent
public static double solveBrent(Expression f, Argument x, double a, double b, double eps, double maxSteps)
Brent solver (Brent root finder)- Parameters:
f- Function given in the Expression formx- Argumenta- Left limitb- Right limiteps- Epsilon value (accuracy)maxSteps- Maximum number of iterations- Returns:
- Function root - if found, otherwise Double.NaN.
-
-