Skip to main content
11-Garnet
September 5, 2019
Question

Isolate a block area from the rest of the Mathcad sheet

  • September 5, 2019
  • 8 replies
  • 7754 views

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?

 

Thank you.

8 replies

23-Emerald IV
September 5, 2019

Hi Anthony,

 

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...

 

Success!
Luc

21-Topaz II
September 5, 2019

Just reset the symbolic variables and give new values to the constants.

21-Topaz II
September 5, 2019

Hi,

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.

 

Cheers

Terry

11-Garnet
September 5, 2019

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.

 

A.

23-Emerald IV
September 5, 2019

Anthony,

 

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.

 

Success!
Luc

25-Diamond I
September 5, 2019

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.

B.png

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:

B2.png

 

23-Emerald IV
September 5, 2019

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.

 

Success!
Luc

11-Garnet
September 5, 2019

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:=.

 

23-Emerald IV
September 5, 2019

Hmm, nice find, but it's not quite the same I fear.

LM_20190905_Undefine.png

(I wonder if Mathcad 15 is the same.)

 

Luc

25-Diamond I
September 5, 2019

Here is a pdf-print of your sheet from Mathcad 15.

As you can see MC15 acts differently than your MC11 in some cases.

 

11-Garnet
September 6, 2019

Thanks again to all, Luc and Werner_E in particular.

 

Still naive here:

Let say I have x :=3, by using:

x:=x.   (the final dot comes hidden, since it is captured in MC11 as a way to put a text subscript, if I am correct)  gives

 

x =     (in red, i.e. empty), and symbolically it gives correctly

x --> x     and  solves dx^2/dx --> 2x

 The hidden dot is still there in the symbolic calculations, but can be put completely invisible just by typing a space after it x:=x.[space]. It works also in  case there is already  a text subscript, like xy - just add "." after y.

 

PS: @Werner_E  in MC 11 after using x :=.  I don't have x=0 as you are showing in MC15,  but x= (in red, i.e. undefined).

 

25-Diamond I
September 6, 2019

It does not matter if you assign x:=x. or if you use x:=x.new or any other variable name which was not used in the sheet.

As already written above this clear effectively the variable for numeric use, but when it comes to symbolics it does not the very same as x:=x is doing. Nevertheless it might suffice for some needs.

 


symbolically it gives correctly

x --> x     and  solves dx^2/dx --> 2x

Thats not correct! You get x --> x. and dx^2/dx --> 2x.

Note the dot after x. It looks like x, but it isn't. I can image that this is OK in a lot of occasions, but maybe not in all.

B.PNG

11-Garnet
September 6, 2019

Thats not correct! You get x --> x. and dx^2/dx --> 2x.

Note the dot after x. It looks like x, but it isn't. I can image that this is OK in a lot of occasions, but maybe not in all.

 



I noticed that, thanks, and I was editing my last post, while you were posting yours.

You are correct: not exactly a pure "x"! But for most practical purposes it could work.

11-Garnet
September 7, 2019

Another possible single solution that in MC11 seems to work for both numeric and symbolic calculations is to use a global definition like that.

previous definition:  x :=3

now: x ≡ x

result: x = (undefined) and with symbolics  x --> x  and  dx^2/dx --> 2x

25-Diamond I
September 7, 2019

So it looks like MC11 and MC15 behave differently here.

In MC15 this global assignment makes the variable unusable for symbolic calculations:

B.png

11-Garnet
September 7, 2019

Unfortunately, it seems so. Probably this is due to the fact that from v.11 to v.15 the math engine has changed.