Undefining a Variable
by Mathcad Staff
|
Defining a variable by a numerical value can sometimes cause problems elsewhere in a worksheet. For example, suppose you define a variable x by |
|
If you then try to solve the equation x2 = 30, using the symbolic keyword "solve," |
|
Mathcad returns an error. The reason for this is that Mathcad first substitutes the value 3 for x in the equation x2 = 30 to get |
|
which has no solution. In other words, x is not a free variable in the equation. |
|
There are a couple of ways to deal with this problem. The simplest method is to "undefine" x, by typing |
|
This redefines the symbolic value of x to be itself, as you can see by evaluating it with the symbolic equal sign [Ctrl] [.]. |
|
2. Click "solve" on the Symbolic toolbar, which you can open by selecting Symbolic on the View > Toolbars menu. |
|
3. Type x in the placeholder to the right of "solve" and press [Enter]. |
|
Mathcad returns the solutions in a vector. |
|
Note that x still has the numeric value 3. Only its symbolic value is undefined. |
|
Using "explicit" to Undefine a Variable |
|
The other method for solving an equation for a variable with a defined numerical value is to use the symbolic keyword "explicit" after "solve." For example, suppose you try to solve the equation 5y – 34 = 0 after defining y. |
|
As before, Mathcad returns an error. Now, insert the keyword "explicit" as follows: |
|
1. Place the cursor to the right of "solve, y" and press [Ctrl] [Shift] [.]. |
|
2. Type "explicit" in the placeholder below "solve." Doing so tells Mathcad to ignore the assigned values of any variables in the expression. Then press [Enter]. |
|
Note that y retains both its numeric and symbolic values after you perform the above operation. |
|