Class NumericalIntegral
java.lang.Object
com.github.gbenroscience.math.numericalmethods.NumericalIntegral
Objects of this class are able to perform numerical integration of a curve
within a given range given that the function is continuous throughout that
range.
- Author:
- JIBOYE Oluwagbemiro Olaoluwa
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intUse this to integrate without using the integral symbol.static final intUse this to integrate using the integral symbol. -
Constructor Summary
ConstructorsConstructorDescriptionNumericalIntegral(double xLower, double xUpper, int iterations, String function) NumericalIntegral(Function f, double lower, double upper, int iterations, MethodHandle targetHandle, String[] vars, int[] slots) NumericalIntegral(Function f, MethodHandle methodHandle, String[] vars, int[] slots) NumericalIntegral(String expression, int chooseExpressionType) -
Method Summary
Modifier and TypeMethodDescriptionstatic voidAnalyzes the list and extracts the Function string from it.doubledoubleDetermines the integral in a given range by splitting the range into sub-ranges of width that are at most 0.1 units along x, and finding the polynomial curve for each sub-range.doubleDetermines the integral in a given range by splitting the range into sub-ranges of width that are at most 0.1 units along x, and finding the polynomial curve for each sub-range.doublefindSimpsonIntegral(double h) doubledoublefindTrapezoidalIntegral(double h) intdoubledoubledoublestatic voidvoidsetFunction(Function function) final voidsetIterations(int iterations) Set the number of iterations and ensure that it is even.voidsetxLower(double xLower) voidsetxUpper(double xUpper)
-
Field Details
-
SYMBOLIC_INTEGRATION
public static final int SYMBOLIC_INTEGRATIONUse this to integrate using the integral symbol.- See Also:
-
FUNCTIONAL_INTEGRATION
public static final int FUNCTIONAL_INTEGRATIONUse this to integrate without using the integral symbol. Here, the intg() command containing the function and the bounds are specified.- See Also:
-
-
Constructor Details
-
NumericalIntegral
public NumericalIntegral() -
NumericalIntegral
-
NumericalIntegral
public NumericalIntegral(Function f, double lower, double upper, int iterations, MethodHandle targetHandle, String[] vars, int[] slots) -
NumericalIntegral
- Parameters:
xLower- The lower limit of xxUpper- The upper limit of xiterations- The number of iterationsfunction- The name of a Function that has been defined before in the WorkSpace or an anonymous Function just specified.
-
NumericalIntegral
- Parameters:
expression- An expression containing information about the function whose integral is to be evaluated and the limits of integration. For example: function,2,4....means integrate function between horizontal coordinates 2 and 3. Direct examples would be: sin(x+1),3,4 cos(sinh(x-2/tan9x)),4,4.32 and so on.chooseExpressionType- Determines if the expression to integrate containsAlgebraicFunction the integral symbol or not. F(x) = sin(x)/2x; intg(F(x),0,2,iterations)
-
-
Method Details
-
setIterations
public final void setIterations(int iterations) Set the number of iterations and ensure that it is even.- Parameters:
iterations-
-
getIterations
public int getIterations()- Returns:
- the number of iterations.
-
getFunction
-
setFunction
-
getxLower
public double getxLower() -
setxLower
public void setxLower(double xLower) -
getxUpper
public double getxUpper() -
setxUpper
public void setxUpper(double xUpper) -
findSimpsonIntegral
- Returns:
- the Simpson integral of the function Simpson's rule requires an even number of rectangular strips and so an odd number of ordinates(y-coordinates) The x distances must also be equal. h= (xUpper-xLower)/(2*m)
-
findSimpsonIntegral
public double findSimpsonIntegral(double h) - Parameters:
h-- Returns:
- the Simpson integral of the function Simpson's rule requires an even number of rectangular strips and so an odd number of ordinates(y-coordinates) The x distances must also be equal. h= (xUpper-xLower)/(2*m)
-
findTrapezoidalIntegral
public double findTrapezoidalIntegral()- Returns:
- the integral of the function using the trapezoidal rule.
-
findTrapezoidalIntegral
public double findTrapezoidalIntegral(double h) - Returns:
- the integral of the function using the trapezoidal rule.
-
findHighRangeIntegral
public double findHighRangeIntegral()Determines the integral in a given range by splitting the range into sub-ranges of width that are at most 0.1 units along x, and finding the polynomial curve for each sub-range.- Returns:
- the integral of the function using the trapezoidal rule.
-
findHighRangeIntegralTurbo
public double findHighRangeIntegralTurbo()Determines the integral in a given range by splitting the range into sub-ranges of width that are at most 0.1 units along x, and finding the polynomial curve for each sub-range.- Returns:
- the integral of the function using the trapezoidal rule.
-
findGaussianQuadrature
public double findGaussianQuadrature()- Returns:
- The Gaussian Quadrature Version.
-
extractFunctionStringFromExpression
Analyzes the list and extracts the Function string from it.- Parameters:
list- The list to be analyzed. Direct examples would be: intg(@sin(x+1),4,7) intg(F,4,7) where F is a function that has been defined before in the workspace.. and so on. Simplifies the list to the form intg(funcName,x1,x2) or intg(funcName,x1,x2,iterations)
-
getVariable
-
integrate
-
main
-