Class Parser

java.lang.Object
math.differentialcalculus.Parser

public class Parser
extends java.lang.Object
Author:
JIBOYE, OLUWAGBEMIRO OLAOLUWA Parses derivative commands of the format: diff(@(x)sin(x),5)... diff(@(x)sin(x),5,2)... diff(y,5)... diff(y,5,2)... The first command means the function, sin(x) is to be differentiated wrt x, and evaluated at x = 5. The second command means the function, sin(x) is to be differentiated wrt x, twice and then evaluated at x = 5. The third command means that a function called y has been pre-defined. The parser will load the function and differentiate it wrt x, and then evaluate it at x = 5. The fourth command means that a function called y has been pre-defined. The parser will load the function and differentiate it wrt x, twice, and then evaluate it at x = 5. Here sin(x) is to be differentiated and evaluated at x=5.
  • Field Details

  • Constructor Details

    • Parser

      public Parser​(java.lang.String expression)
      Parameters:
      expression - The expression to parse. e.g. diff(@(x)cos(x)+5*x,6,1) or diff(F,6,1) where F is a function that has been previously defined in the workspace and so is in the FunctionManager It may also take the form diff(@(x)cos(x)+5*x,6) or diff(F,6) where it assumes that the function is to be differentiated only once. In the future, we have diff(F) or (diff(@(x)cos(x)+5*x) which will return the gradient function itself.
  • Method Details

    • getEvalPoint

      public double getEvalPoint()
    • getFunction

      public Function getFunction()
    • getOrderOfDifferentiation

      public int getOrderOfDifferentiation()
    • setOrderOfDifferentiation

      public void setOrderOfDifferentiation​(int orderOfDifferentiation)
    • getDiffType

      public int getDiffType()
    • setDiffType

      public void setDiffType​(int diffType)
    • isGradFunc

      public boolean isGradFunc()
    • isGradEval

      public boolean isGradEval()
    • parseDerivativeCommand

      public static void parseDerivativeCommand​(java.util.List<java.lang.String> list)
      Parameters:
      list - A list containing the scanned form of an expression containing information about the function whose derivative is to be evaluated and the point at which the derivative is to be evaluated. Common forms for the expression are: diff(@(x)sin(x),5)... diff(@(x)sin(x),5,2)... diff(y,5)... diff(y,5,2)... The first command means the function, sin(x) is to be differentiated wrt x, and evaluated at x = 5. The second command means the function, sin(x) is to be differentiated wrt x, twice and then evaluated at x = 5. The third command means that a function called y has been pre-defined. The parser will load the function and differentiate it wrt x, and then evaluate it at x = 5. The fourth command means that a function called y has been pre-defined. The parser will load the function and differentiate it wrt x, twice, and then evaluate it at x = 5. Direct examples would be: diff(@(x)sin(x+1),4) diff(F,5.32) where F is a function that has been defined before in the workspace.. and so on.
    • main

      public static void main​(java.lang.String[] args)