Mathcad can do repeated or iterative calculations as easily as individual calculations. Mathcad uses a special variable called a range variable to perform iteration. Range variables take on a range of values, such as all the integers from 0 to 10. Whenever a range variable appears in a Mathcad equation, Mathcad calculates the equation not just once, but once for each value of the range variable. This section describes how to use range variables to do iterative calculations.

Creating a range variable

To compute equations for a range of values, first create a range variable. In the problem shown in Figure 1-5, for example, you can compute results for a range of values of t from 10 to 20 in steps of 1. To do so, follow these steps:
• First, change t into a range variable by II I editing its definition. Click on the 10 in -=t =:==l.Q]= _ the equation t := 10. The insertion point should be next to the 10 as shown on the right.
• Type, 11. This tells Mathcad that the next number in the range will be 11. ” Type; 20. This tells Mathcad that the last number in the range will be 20. Mathcad shows the semicolon as a pair of dots.
• Now click outside the equation for t. Mathcad begins to compute with t defined as a range variable. Since t now takes on eleven different values, there must also be eleven different answers. These are displayed in the table shown in Figure 1-6. You may have to resize your window or scroll down to see the whole table.

7

Defining a function

{ou can gain additional flexibility by defining functions. Here’s how to add a function definition to your worksheet:
• First delete the table. To do so, click anywhere
in the table press [Space] until you’ve enclosed everything between the two editing lines.
• Now define the function d(t) by typing d(t) :
• Complete the definition by typing this expression: 1600+acc/ 2[Space)*tA2[.J] -490 The definition you just typed defines a function. The function name is d, and the argument of the function is t.You can use this function to evaluate the above expression for different values of t. To do so, simply replace t with an appropriate number. For example:

• To evaluate the function at the value 3.5, I type d (3.5) =. Mathcad returns the cor- d (3.5) = 939.975 rect value as shown on the right.
• To evaluate the function once for each value of t you defined earlier, click below the other equations and type d (t) Mathcad shows a table of values (Figure 1-7). The first two values, 1.11 . 103 and 1.007 . 103 , are in exponential (powers of 10) notation.

8

Formatting a result

You can set the display format for any number Mathcad calculates and displays. This means changing the number of decimal places shown, changing exponential notation to ordinary decimal notation, and so on.

• For example, here’s how to change the table in Figure 1-7 so that none of the numbers in it are displayed in exponential notation:
• Click on the table with the mouse.

•Choose Number from the Format menu. You see the Format Number dialog box. This box contains settings that affect how results are displayed, including the number of decimal places, the use of exponential notation, and whether the number is shown in decimal, octal, or hexadecimal. The option button beside “Set for current region only” should be filled in. This indicates that whatever you do in this dialog box affects only the result you’ve selected.
• The default setting for Exponential Threshold is 3. This means that only numbers greater than or equal to 103 are displayed in exponential notation. Click to the right of the 3, press [BkSp] and type 6.
• Click the “OK” button. The equation changes to reflect the new result format- 1110 is no longer shown in exponential notation.  When you format a result, only the display of the result is affected. Mathcad maintains full precision intemall y.

Posted on November 20, 2015 in The Basics