[back] [home] [content] [continue]
It's really simple to convert an expression. The
ExpressionConfiguration
class provides an appropriate method for
any kind of conversion. Such a method returns a new Expression
object presenting the converted expression. There are two
possibilities of converting as yet:
To simplify an expression you have to call the method
on an ExpressionConfiguration
object. For Example:
ExpressionConfiguration config=new ExpressionConfiguration(RealType.TYPE); config.setExpression("0+9"); config.setExpression(config.simplify());
After this, the Expression
of config
will be "9"
.
The following table shows source operations and it's simplifications. a and b are arbitrary expressions. Note that often there is no simplification (e.g. 1 + a).
source operation # | + | - | * | / | ^ |
---|---|---|---|---|---|
#a | a | -a | |||
#(#a) | a | a | |||
0 # a | a | -a | 0 | 0 | 0 |
a # 0 | a | a | 0 | a / 0 | 1 |
1 # a | 1 + a | 1 - a | a | 1 / a | 1 |
a # 1 | a + 1 | a - 1 | a | a | a |
a # a | a + a | 0 | a * a | 1 | a ^ a |
a # b | a + b | a - b | a * b | a / b | a ^ b |
-a # b | b - a | -(a + b) | -(a * b) | -(a / b) | -a ^ b |
a # -b | a - b | a + b | -(a * b) | -(a / b) | a ^ -b |
-a # -b | -(a + b) | b - a | a * b | a / b | -(a ^ -b) |
Note: An Expressions
wont be simplified in the following cases:
To get the derivative of an Expression
with respect to any Symbol you have to call one of the
following methods on an ExpressionConfiguration
object:
The easiest way is to give the respection by a String
.
Example:
ExpressionConfiguration config=new ExpressionConfiguration(RealType.TYPE); config.setExpression("a^2"); config.setExpression(config.differentiate("a"));
After this, the Expression
of config
will be "a^2 * (2/a)"
.
It's not simplified to "2*a"
because cancel down simplification is not implemented yet.