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(String expression, int chooseExpressionType) -
Method Summary
Modifier and TypeMethodDescriptionstatic voidAnalyzes the list and extracts the Function string from it.doubleAlgorithm that combines a variant of the Simpson rule and the polynomial rule to produce higher accuracy integrals.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) findTrapezoidalIntegral(double h) intdoubledoublestatic voidvoidsetFunction(Function function) 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
- 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 contains the integral symbol or not. F(x) = sin(x)/2x; intg(F(x),0,2,iterations)
-
-
Method Details
-
setIterations
public 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
- 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
- Returns:
- the integral of the function using the trapezoidal rule.
-
findTrapezoidalIntegral
- Returns:
- the integral of the function using the trapezoidal rule.
-
findPolynomialIntegral
public double findPolynomialIntegral()- Returns:
- the integral of the function using the polynomial rule.
-
findHighRangeIntegralWithAdvancedPolynomial
public double findHighRangeIntegralWithAdvancedPolynomial()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.
-
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.
-
findGaussianQuadrature
public double findGaussianQuadrature()- Returns:
- The Gaussian Quadrature Version.
-
findAdvancedPolynomialIntegral
public double findAdvancedPolynomialIntegral()Algorithm that combines a variant of the Simpson rule and the polynomial rule to produce higher accuracy integrals. -
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
-
main
-