jtem home

downloads

credits

tools:
· jterm

libraries:
· numericalMethods
· mfc
· ellipticFunctions
· blas
· moebiusViewer
· riemann
· mathExpr
· jgimmick
· java2d

Java Tools
for
Experimental Mathematics

mathExpr

[back] [home] [content] [continue]


1.6. Expression Conversions

  • 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:


  • Simplify an expression

    To simplify an expression you have to call the method

    • simplify()

    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 #+-*/^
    #aa-a
    #(#a)aa
    0 # aa-a000
    a # 0aa0a / 01
    1 # a1 + a1 - aa1 / a1
    a # 1a + 1a - 1aaa
    a # aa + a0a * a1a ^ a
    a # ba + ba - ba * ba / ba ^ b
    -a # bb - a-(a + b)-(a * b)-(a / b)-a ^ b
    a # -ba - ba + b-(a * b)-(a / b)a ^ -b
    -a # -b-(a + b)b - aa * ba / b-(a ^ -b)

    Note: An Expressions wont be simplified in the following cases:

    • constant expressions, e.g.: "9+1" wont be simplified to "10"
    • cancel down divisions, e.g.: "a^2/a" wont be simplified to "a"
    • commutative law wont be detected, e.g.: "(a+b)/(b+a)" wont be simplified to "1"

  • Differentiate an expression

    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:

    • differentiate(String s)
    • differentiate(Symbol s)

    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.


[back] [home] [content] [continue]

WML Valid HTML 4.0!