net.sourceforge.webcompmath.functions
Class NumIntParser

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

public class NumIntParser
extends java.lang.Object
implements ParserExtension

The NumIntParser class makes it possible to use numerical definite integrals, such as numInt(xx,0,5,xx^2) in a Parser. The numerical integral psedu-function has four parameters: (1) The integration variable, which must be an identifier and should be different than other variables registered with the parser; (2) The lower limit for the integral, given as an expression (which can involve variables); (3) The upper limit for the integral, given as an expression (which can involve variables); and (4) the expression that is the integrand. The expression in the fourth parameter can (and presumably will) use the integration variable (as well as other identifiers known to the parser). You can also provide an optional 5th parameter to specify the number of intervals used in the computation (the default is 1000).

You can take the derivative of a function defined using numInt() and the lower and upper limits can depend on the variable that the derivative is being taken with respect to. For example you could take the derivative of a function defined by "numInt(z,0,x,z^2)" with respect to x. Note that the integrand cannot depend on the wrt variable, because that would require symbolic integration (which is not supported).

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

See Also:
Serialized Form

Constructor Summary
NumIntParser()
           
 
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 integration subexpression.
 java.lang.String getName()
          Get the name, which will be used in place of "numInt" in expressions.
 void setName(java.lang.String name)
          Set the name, which will be used in place of "numInt" in expressions.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NumIntParser

public NumIntParser()
Method Detail

setName

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

Specified by:
setName in interface MathObject
Parameters:
name - name of numerical integral

getName

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

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

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 integration 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