Package com.singularsys.extensions.djep
Class DJep
java.lang.Object
com.singularsys.jep.Jep
com.singularsys.extensions.xjep.XJep
com.singularsys.extensions.djep.DJep
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
MDJep
Adds differentiation facilities to Jep.
For example
DJep j = new DJep();
j.addStandardDiffRules();
....
Node node = j.parse("x^3");
Node diff = j.differentiate(node,"x");
Node simp = j.simplify(diff);
j.println(simp);
Node node2 = j.parse("diff(x^4,x)");
Node proc = j.preprocess(node2);
Node simp2 = j.simplify(proc);
j.println(simp2);
- Author:
- Rich Morris Created on 16-Nov-2003
- See Also:
-
Field Summary
FieldsFields inherited from class com.singularsys.extensions.xjep.XJep
cleaner, commandv, copier, extractor, polyv, rewritev, subv, tuFields inherited from class com.singularsys.jep.Jep
additionalComponents, allowAssignment, allowUndeclared, evaluator, funTab, implicitMul, lastRootNode, nodeFac, numFac, opTab, parser, pv, varFac, varTab -
Constructor Summary
ConstructorsConstructorDescriptionDJep()Standard constructor.DJep(ComponentSet dJepComponents) DJep(JepComponent... components) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddDiffRule(DiffRulesI rule) Adds a rule with instruction on how to differentiate a function.booleanAdds the standard set of differentiation rules.differentiate(DVariable var, String... names) Finds the derivative of a differentiable variable.differentiate(Node node, String name) Differentiate an equation with respect to a variable.Returns the visitor used for differentiation.Replace any partial derivatives found in the expression by their expressions.protected voidMethods inherited from class com.singularsys.extensions.xjep.XJep
addRewriteRule, calcVarValue, clean, deepCopy, equals, expand, getCommandVisitor, getCopier, getExpressionCleaner, getExtractor, getPolynomialCreator, getRewriteVisitor, getSubstitutionVisitor, getTreeUtils, getVarsInEquation, getVarsInEquation, preprocess, recursiveGetVarsInEquation, replaceRHSVariablesByEquations, replaceVariablesByExpressions, rewrite, simplify, substitute, substitute, substitute, substitute, substitute, substitute, substituteConstantVariablesMethods inherited from class com.singularsys.jep.Jep
addConstant, addDefaultComponents, addFunction, addStandardConstants, addVariable, addVariable, addVariable, addVariable, continueParsing, evaluate, evaluate, evaluateD, getAdditionalComponent, getAdditionalComponentExact, getAdditionalComponents, getAllowAssignment, getAllowUndeclared, getDefaultValue, getEvaluator, getFunctionTable, getImplicitMul, getLastRootNode, getNodeFactory, getNumberFactory, getOperatorTable, getOperatorTable2, getParser, getPrintVisitor, getVariable, getVariableFactory, getVariableTable, getVariableValue, initMultiParse, initMultiParse, parse, parse, print, print, print, println, println, println, reinitializeComponents, rootNodeToString, setAllowAssignment, setAllowUndeclared, setComponent, setComponentInternal, setComponents, setComponentsInternal, setDefaultValue, setImplicitMul, setVariable, setVariableValue, toString, tryAddConstant
-
Field Details
-
dv
-
-
Constructor Details
-
DJep
public DJep()Standard constructor. Use this instead of Jep or Jep if differentiation facilities are required. -
DJep
-
DJep
-
-
Method Details
-
setXComponentInternal
- Overrides:
setXComponentInternalin classXJep
-
getDifferentiationVisitor
Returns the visitor used for differentiation. Allows more advanced functions. -
addStandardDiffRules
public boolean addStandardDiffRules()Adds the standard set of differentiation rules. Corresponds to all standard functions in the Jep plus a few more.sin,cos,tan,asin,acos,atan,sinh,cosh,tanh,asinh,acosh,atanh sqrt,log,ln,abs,angle sum,im,re are handled separately. rand and mod currently un-handled Also adds rules for functions not in Jep function list: sec,cosec,cot,exp,pow,sgn- Returns:
- false on error
-
addDiffRule
Adds a rule with instruction on how to differentiate a function.- Parameters:
rule-
-
differentiate
Differentiate an equation with respect to a variable.- Parameters:
node- top node of the expression tree to differentiate.name- differentiate with respect to this variable.- Returns:
- the top node of a new parse tree representing the derivative.
- Throws:
ParseExceptionIllegalArgumentException
-
replacePartialDerivativeByExpressions
Replace any partial derivatives found in the expression by their expressions.- Parameters:
node- expression to process, may be modified- Returns:
- the expression after replacement
- Throws:
JepException
-
differentiate
Finds the derivative of a differentiable variable. Will look up existing derivative if it exists or calculate the derivative if needed.- Parameters:
var- variable to differentiatenames- names of the partial derivatives to find, either a single name "x" or an array of names to find higher derivatives- Returns:
- a variable representing the partial derivative
- Throws:
ParseException
-