I am still using MC 11.2
Sometimes I solve a set of math exercises, let say three of them, in the same MC document since they belong to the same exam.
I was looking for a way to separate completely one exercise from the others, not only in terms of layout (using "Insert Area"), but also in terms of variable definitions. In this way a variable defined in the first exercise would not be seen (and used) in the second and third exercise. This to avoid overlappings of data.
Is there a way to do this, like a command "clear variables", or isolation blocks, that are in use in other math software? If not, is there a workaround to achieve the same result?
Mathcad does not have a 'clear variables' command. (Prime has, but there are other things it doesn't have...).
Separate sheets gives the best isolation.
The second best is to undefine your variables at/after the end of every exrcise, using
var := var
to undefine the variable 'var', that is, it removes any definition (
numeric or only the symbolic ones) attached to var.
The third best is to use unique variable names in each of your exercises. Attach the exercise number to each of your variables e.g...
Luc has the answer but has not gone far enough. He said
"The second best is to undefine your variables at/after the end of every exercise, using
var := var
to undefine the variable 'var', that is, it removes any definition (numeric or symbolic) attached to var."
What he didn't add was you could put all these var:=var statements into a region which could be collapsed and leave just a line between each exercise.
Thanks Luc, MFranc and Terry,
I knew the "trick" of redefining the variable. But when there are many of them, there is the risk of leaving something behind.
Luc and Terry: the trick of clearing the variable with var := var seems not working in MC 11.2 (at least, with numeric values).
I agree, that apart of putting a single exercise in a single sheet, the other workaround is to add numbering to variables, according to the exercise that is referring to.
you are right.
var := var only clears the symbolic definition of var. It leaves the numeric definition intact. For that you need to use MFranc's suggestion: Redefine var numerically. But then it's defined symbolically as well, but with a numeric value; that will impact subsequent symbolic manipulations using var.
Seems the third-best option might be the best option when you want all exercises in one sheet.
Or you solve all exercises the way I advise to do generally:
1. First solve your problem (as much as possible) purely symbolically; using undefined or cleared symbols.
2. Then fill in the numbers (if needed), which involves defining numerical values to variables as applicable.
Either way, you have to keep track of any variables you use.
To reset a variable symbolically AND numerically you may use the two step procedure shown in the picture.
But it sure is cumbersome and failure-prone to do so with all variables one by one.
The variable name "_-y-_" simply was chosen to ensure(?) its a name still undefined and unused.
Numerical clearing could be done using a vector, but symbolical clearing must be done singly one by one:
And the order in which you 'undefine' does matter.
First do the numeric, then the symbolic.
If you reverse that, your variable will be symbolically defined to whatever you chose as undefined symbol.
Thanks Werner_E you too.
I don't know if the following is too naive. But I notice that it is enough to use (at least for numeric definitions) the following to clear variables' content.
var :=. (i.e. dot).
or also var :="" (enough to type once the double inverted comma).
The first works also by putting in a vector all variables, and then equalizing the vector to this:=.
Hmm, nice find, but it's not quite the same I fear.
(I wonder if Mathcad 15 is the same.)