Publication date: 07/08/2024

Algebraic Manipulations

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)

where

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

For example,

Invert Expr( Sqrt( log( x ) ), x, y );

is wound around the name x (which should appear in the expression only once), and results in

Exp( y ^ 2 )

It is performed exactly as you would when doing the algebra by hand.

y = Sqrt( log( x ) );

y2 = Log( x );

Exp( y2 ) = 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));

or

result = Simplify Expr(nameExpr(global));

For example,

Simplify Expr( Expr( 2 * 3 * a + b * (a + 3 - c) - a * b ) );

results in

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 ) ) ) ) );

results in

If(cond1, result1, cond2, result2, cond3, result3, resultElse);

Want more information? Have questions? Get answers in the JMP User Community (community.jmp.com).