Symbolics > Working with Symbolics > Working with Variables > To Substitute Variables
  
To Substitute Variables
1. Place the cursor at the end of an expression, insert the symbolic evaluation operator, and type the keyword substitute in the placeholder.
2. After substitute, type a comma and the variable that you want to replace.
3. Insert the Boolean equal sign, and then type the number, variable, or expression that you want to substitute.
4. Press Enter or click outside the region. PTC Mathcad replaces all occurrences of the variable with its value in the result.
Click to copy this expression
Click to copy this expression
Click to copy this expression
5. To substitute values for additional variables, type a comma plus a comma-separated list of additional equations of the form var = expr, again using the Boolean equal sign.
Click to copy this expression
6. To return results that are not fully simplified, add the modifier raw after substitute.
Click to copy this expression
Additional Information
If you predefine a variable that you later set after substitute, you might not get the result that you expect.
Click to copy this expression
Click to copy this expression
The returned value of 6 is not what you expect. This happens because PTC Mathcad first replaces x with its assigned value of 5, and then it evaluates the expression 5 + 1 to get the following result:
Click to copy this expression
Since 5 does not appear in the expression, PTC Mathcad simply returns 6.
To avoid this problem, you can either clear the substitution variable's symbolic value by using the function clear, or by using the keyword explicit to temporarily suppress the assigned value of x:
Click to copy this expression