net.sourceforge.webcompmath.functions
Class DerivParser

java.lang.Object
  extended by net.sourceforge.webcompmath.functions.DerivParser
All Implemented Interfaces:
java.io.Serializable, MathObject, ParserExtension

public class DerivParser
extends java.lang.Object
implements ParserExtension

The DerivParser class makes it possible to use symbolic derivatives such as Deriv(x,0,x^2) in a Parser. The derivative psedu-function has four parameters: (1) The with-respect-to variable, which must be an identifier; (2) The value of the variable at which to evaluate the derivative, given as an expression; (3) the expression that is to have its derivative taken; and (4) an optional expression indicating whether to take the first, second, etc. derivative. The expression in the third parameter can (and presumably will) use the variable (as well as other identifiers known to the parser). The default for the fourth parameter is 1 (i.e., the first derivative). Only derivatives up to the 100th are supported; if you try to take a larger derivative, Double.Nan is returned.

To use derivatives with a Parser p, just say p.add(new DerivParser()). It's unlikely that you will ever need to do anything else with DerivParsers. If you want to use a name other than "Deriv", you can change the name after creating the DerivParser object but before adding it to a parser.

See Also:
Serialized Form

Constructor Summary
DerivParser()
           
 
Method Summary
 void doParse(Parser parser, ParserContext context)
          When the name of this ParserExtension is encountered by a parser with which the extension is registered, the parser calls this routine to parse the subexpression.
 java.lang.String getName()
          Get the name, which will be used in place of "Deriv" in expressions.
 void setName(java.lang.String name)
          Set the name, which will be used in place of "Deriv" in expressions.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DerivParser

public DerivParser()
Method Detail

setName

public void setName(java.lang.String name)
Set the name, which will be used in place of "Deriv" in expressions. This should not be done after the DerivParser has been added to a Parser. The default name is "Deriv".

Specified by:
setName in interface MathObject
Parameters:
name - name of derivative

getName

public java.lang.String getName()
Get the name, which will be used in place of "Deriv" in expressions.

Specified by:
getName in interface MathObject
Returns:
name of derivative

doParse

public void doParse(Parser parser,
                    ParserContext context)
When the name of this ParserExtension is encountered by a parser with which the extension is registered, the parser calls this routine to parse the subexpression. The subexpression has the form ( , ,, ). This method is not meant to be called directly

Specified by:
doParse in interface ParserExtension
Parameters:
parser - parser to use
context - context to use