Let’s talk about Auto Calculation

Many of you know PTC Mathcad Prime is an interpreted math engine, you make a change to a variable and PTC Mathcad Prime computes. In most cases this is perfect; PTC Mathcad Prime creates and tracks dependencies trees, keeping all variables and results current. What else could a geek ask for? Well, sometimes I’d like for it to not do all that.

Imagine you have an equation that takes some time to compute and you have 20 input variables to that calculation. Each time you entered a new input value, PTC Mathcad Prime would be off to the races. One flattering feature of PTC Mathcad Prime is that while the worksheet is calculating you are no longer locked out of the User Interface, including the equation editor. However you have unleashed nonsensical computing, since the result will be wrong until all 20 new variables are entered.

This is the perfect time to disable Auto Calculation by clicking Stop All Calculations, enter 20 new values, and then turn Auto Calculation back on.

So for most uses, Auto Calculation is what we want, but on occasion we want to “batch mode” enter values, there it makes sense to suspend calculations.

OK so then what about Disabling Regions, when does that make sense? Well Disabling Region is much like Stop All Calculation, but on a finer granularity. Instead of shutting off the entire worksheet you can simply stop the calculation of a specified region or regions.

You’ll notice when a region is disabled visually it looks different, greyed out.

The image above shows a perfect reason to use Disabled Region instead of Stop All Calculations. While developing algorithms, we might have several revisions of the same calculation. We would never deliver a worksheet to a colleague or client this way, but while developing the worksheet I may have several revisions of an algorithm that I want to compare. Maybe it’s 3 or 4 versions of an inline program or 3 or 4 versions of an input vector to an inline program. The point is we want everything to recalculate except certain regions.

Simply select one or more with multi select techniques and click Disable Regions. You can use this technique to turn on and off different algorithms like the image above…only one is being graphed.

Auto Calculation is on by default. You can shut it off completely or keep it turned on and use Disable Region, a rifle approach rather then shot gun.

Tips And Tricks

How do you stop a renegade calculation?

This inline function completes nicely with the variable “I” being decremented by 1 each iteration.

But what if I made a typo and instead defined myfunc as

Notice myfunc(3) is disabled. OK when I enable this region I have an infinite loop

As I am typing this, PTC Mathcad Prime is computing and computing. I mentioned earlier the UI including the equation editor is alive even when PTC Mathcad Prime is computing. So click on the rogue region and backspace your way back to safety, meaning erase the myfunc (3) region by backspacing it away.

Now I’ll go fix my code.

Download the free for life version, PTC Mathcad Express.

Learn about our latest version PTC Mathcad Prime 3.1

Chat with a PTC Mathcad sales expert today. >>