Class NumericalIntegral

java.lang.Object
math.numericalmethods.NumericalIntegral

public class NumericalIntegral extends Object
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.
  • Field Details

    • SYMBOLIC_INTEGRATION

      public static final int SYMBOLIC_INTEGRATION
      Use this to integrate using the integral symbol.
      See Also:
    • FUNCTIONAL_INTEGRATION

      public static final int FUNCTIONAL_INTEGRATION
      Use this to integrate without using the integral symbol. Here, the intg() command containing the function and the bounds are specified.
      See Also:
    • xUpper

      private double xUpper
      The upper boundary value of x.
    • xLower

      private double xLower
      The lower boundary value of x.
    • function

      private Function function
      The function to integrate.
    • iterations

      private int iterations
      The number of iterations.
  • Constructor Details

    • NumericalIntegral

      public NumericalIntegral(double xLower, double xUpper, int iterations, String function)
      Parameters:
      xLower - The lower limit of x
      xUpper - The upper limit of x
      iterations - The number of iterations
      function - The name of a Function that has been defined before in the WorkSpace or an anonymous Function just specified.
    • NumericalIntegral

      public NumericalIntegral(String expression, int chooseExpressionType)
      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

      public Function getFunction()
    • setFunction

      public void setFunction(Function function)
    • getxLower

      public double getxLower()
    • setxLower

      public void setxLower(double xLower)
    • getxUpper

      public double getxUpper()
    • setxUpper

      public void setxUpper(double xUpper)
    • findSimpsonIntegral

      public String 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 String findSimpsonIntegral(double 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 String findTrapezoidalIntegral()
      Returns:
      the integral of the function using the trapezoidal rule.
    • findTrapezoidalIntegral

      public String findTrapezoidalIntegral(double h)
      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

      public static void extractFunctionStringFromExpression(List<String> list)
      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

      public String getVariable()
    • main

      public static void main(String[] args)