Class NumericalDerivative

java.lang.Object
math.numericalmethods.NumericalDerivative

public class NumericalDerivative extends Object
  • Field Details

    • function

      private Function function
      The function to differentiate.
    • xPoint

      private double xPoint
      The x coordinate of the point on the function where we need to find the derivative.
  • Constructor Details

    • NumericalDerivative

      public NumericalDerivative()
    • NumericalDerivative

      public NumericalDerivative(String expression)
      Parameters:
      expression - An expression containing information about the function whose derivative is to be evaluated and the point at which the derivative is to be evaluated. For example: function,4....means find the derivative of the function at the point where x=4 on the curve. Direct examples would be: diff(@(x)sin(x+1),4) diff(F,5.32) and so on.
    • NumericalDerivative

      public NumericalDerivative(Function function, double xPoint)
  • Method Details

    • setFunction

      public void setFunction(Function function)
    • getFunction

      public Function getFunction()
    • setxPoint

      public void setxPoint(double xPoint)
    • getxPoint

      public double getxPoint()
    • findDerivativeByPolynomialExpander

      public String findDerivativeByPolynomialExpander()
      Returns:
      the numerical value of the derivative very near the given point.
    • findDerivativeByLimit

      public String findDerivativeByLimit(double dx)
      Parameters:
      dx - The infinitesimal used to compute the numerical derivative at the given xPoint on the function.
      Returns:
      the numerical value of the derivative very near the given point.
    • extractFunctionStringFromExpression

      public static Object[] extractFunctionStringFromExpression(String expression)
      Analyzes the expression and extracts the Function string from it.
      Parameters:
      expression - The expression to be analyzed. Direct examples would be: diff(@sin(x+1),4) diff(F,5.32) where F is a function that has been defined before in the workspace.. and so on.
      Returns:
      an Object array containing at index 0, the function string,which may or may not be anonymous, and in index 1, the horizontal coordinate of type double where the derivative is needed.
    • main

      public static void main(String[] args)
    • getVariable

      public String getVariable()
      Returns:
      the independent variable in a 2D function e.g. f(x)=sin(x). If the function is more than 2D then it returns the first independent variable alone.