|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
public interface Expression
Interface for creating symbolic expressions, which may be evaluated.
Expressions may be differentiable in which case we can obtain their
derivatives in symbolic for such as in: Expression derivative =
expression.diff( new Variable( "x", 0 ) ); It is possible to
generate Java source code for computing an expression. In addition
expressions may be expandable meaning that one can generate a Taylor
expansion of the solution of an ordinary differential equation like
x'=f where f is an expandable function. The
latter feature can, of course, only be used if the functions used have
Taylor expansions.
Example of use:
Constant c = new Constant( 1 ); // constant with value 1 Variable x = new Variable( "x", 3 ); // variable with name x and value 3 Variable y = new Variable( "y", 7 ); // variable with name y and value 7 Expression e1 = new Multiplication( x, new Addition( y, c ) ); // e1 = (x*(y+1)) double value = e1.eval(); // value = 24 Expression e2 = e1.diff( x ); // e2 = ((1.0*(y+1.0))+(x*(0.0+0.0))) Expression e3 = e2.optimize(); // e3 = (y+1.0) Expression e4 = new Addition( e3, new Multiplication( x, new Sin( y ) ) ); // e4 = ((y+1.0)+(x*sin(y))) String javacode = e4.toJava(); // javacode = "((y+1.0)+(x*Math.sin(y)))" String tmapcode = e4.toTaylorMap(); // tmapcode = "new TaylorAdd(new TaylorAdd(y, new TaylorConstant( 1.0 )),new TaylorMultiply(x,new TaylorSin(y)))"
Constant,
Variable,
Addition,
Multiplication,
Sin| Method Summary | |
|---|---|
boolean |
contains(Expression e)
The method contains should return true if the Expression e is found in the expression (this), else false should be returned. |
Expression |
diff(NamedDataExpression x)
Returns the differential quotient for the Expression object. |
double |
eval()
Returns the value of the Expression object. |
Expression |
factor(Expression e)
The method should attempt to return the factor of the Expression e in the Expression this. |
java.util.List |
getElements()
The getElements method must return a java.util.List whose elements are all the subexpressions of the Expression. |
boolean |
isDifferentiable()
Returns whether the object in question is differentiable. |
boolean |
isExpandable()
Returns whether the object in question is expandable as a Taylor expansion. |
Expression |
isolate(Expression e)
The method should attempt to isolate the Expression e in the equation this=0, and return the resulting Expression. |
Expression |
isolate(Expression f,
Expression e)
The method should attempt to isolate the expression e in the equation this=f, and return the resulting Expression. |
Expression |
optimize()
Returns a new Expression object that represents the optimized expression. |
Expression |
replace(Expression a,
Expression b)
Replace all occurences of the Expression a in the current expression with the Expression b. |
java.lang.String |
toJava()
Returns String object representing Expression in Java source code. |
java.lang.String |
toTaylorMap()
Returns String object representing TaylorMap |
java.lang.String |
toXML()
Returns String XML representation |
| Method Detail |
|---|
double eval()
boolean isDifferentiable()
diff(NamedDataExpression)boolean isExpandable()
Expression diff(NamedDataExpression x)
x - The NamedDataExpression object representing the
variable/parameter we wish to differentiate with respect to.
Expression optimize()
Expression replace(Expression a,
Expression b)
a - DOCUMENT ME!b - DOCUMENT ME!
java.lang.String toJava()
toJava in interface JavaExpressiblejava.lang.String toTaylorMap()
TaylorMap
TaylorMap.java.lang.String toXML()
toXML in interface XMLExpressiblejava.util.List getElements()
boolean contains(Expression e)
e - DOCUMENT ME!
Expression isolate(Expression e)
e - DOCUMENT ME!
Expression isolate(Expression f,
Expression e)
f - DOCUMENT ME!e - DOCUMENT ME!
Expression factor(Expression e)
e - DOCUMENT ME!
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||