JSL provides a way of algebraically unwinding an expression (essentially, solving for a variable). It is accomplished through the Invert Expr() function.
Invert Expr(expression, name, y)
•
|
expression is the expression to be inverted, or the name of a global containing the expression
|
•
|
name is the name inside expression to unwind the expression around
|
•
|
y is what the expression was originally equal to
|
Invert Expr( Sqrt( log( x ) ), x, y );
Exp( y ^ 2 )
y = Sqrt( log( x ) );
Invert Expr supports most basic operations that are invertible, and makes assumptions as necessary, such as assuming you are interested only in the positive roots, and that the trigonometric functions are in invertible areas so that the inverse functions are legal.
F, Beta, Chi-square, t, Gamma, and Weibull distributions are supported for the first arguments in their Distribution and Quantile functions. If it encounters an expression that it cannot convert, Invert Expr() returns Empty().
JSL provides a Simplify Expr command that takes a messy, complex formula and tries to simplify it using various algebraic rules. To use it, submit
result = Simplify Expr(expr(expression));
result = Simplify Expr(nameExpr(global));
Simplify Expr( Expr( 2 * 3 * a + b * (a + 3 - c) - a * b ) );
6*a + 3*b + -1*b*c
Simplify Expr() also unwinds nested If expressions. For example:
r = Simplify Expr( Expr( If( cond1, result1, If( cond2, result2, If( cond3, result3, resultElse ) ) ) ) );
If(cond1, result1, cond2, result2, cond3, result3, resultElse);