Previous Up Next

5.13.21  Substitute a variable by a value: ()

Given an expression with variables, you can substitute a variable by a value with the | operator or the subst command.
Input:

Expr := x + 2*y + 3*z

then:

subst(Expr,[x=1,y=2])

or:

Expr | x=1, y=2

Output:

5+3*z

One other way to do this is with something akin to functional notation; following the expression with equalities of the form variable = value.
Input:

Expr(x=1,y=2)

Output:

5+3*z

Input:

(h*k*t^2+h^3*t^3)(t=2)

Output:

h*k*4+8*h^3

Previous Up Next