Mathcad Prime is engineering computational software designed to resemble the layout and appearance of manual computations. Equations, graphics, and text can be placed at will in the worksheet, with the only restriction that constants and functions must be defined above where they are used, because the worksheet is computed from top to bottom, left to right. Mathcad strives to use conventional mathematical notation, making the worksheet significantly easier to read than computer code. Plotting a function in Mathcad requires little more than defining the function to be plotted using an assignment statement.

Plotting in Mathcad Let us say you wish to plot the result of example Sect. 2.8.1 , \(v( t ) = 2.66( {1 - {{\rm{e}}^{ - 0.5t}}} )\) . You must first define v (t ) in the Mathcad worksheet above, or to the left of where you plan to place the plot. When you click on an empty area of a Mathcad worksheet and begin to type, the program presumes that you are entering an equation. If, in fact, you are typing text, Mathcad will recognize you are entering text by the space entered between letters. There are no spaces in equations. When entering an equation, the space bar is used in lieu of the mouse to move the \(\left. {\underline {\,{} \,}}\! \right|\) shaped cursor out of exponents and denominators. Alternatively, if you wish to enter text, type “ as the first character to create a “text region.”

Click in an empty area of a Mathcad worksheet and type

$$\text{v}(\text{t}):2.66*(1-\text{e}\hat{\ }-0.5*{{\text{t}}_{\,\,Space\,\,Bar}}_{\,\,Space\,\,Bar})$$

Then either type tab, or click outside of the equation object. You will see the following:

$$\text{v}(\text{t}):=2.66\cdot \left( 1-{{\text{e}}^{-0.5\cdot t}} \right)$$

Mathcad is case and font sensitive. T, t, t, τ , and t are all different variables. Greek characters can be entered using the Greek alphabet “pallet” (produced by clicking on the αβ button), or by typing the combination of the Ctrl key and g simultaneously, when the cursor is immediately to the right of the Roman character one wishes to change to Greek.

The duration of a response plot should be six or seven times the largest time constant in the system, Sect. 2.9.4 . We are plotting a first-order response, where the time constant is the inverse of the magnitude of coefficient in the exponent, \(\sigma=- 0.5\) . Type

$$\text{t}\underbrace{\text{Ctrl+g}}_{\text{Simultaneously}}:\,\,|\,\,1/-0.5$$

Press the Ctrl and g keys simultaneously. Type tab or click outside the equation object and you will see

$$\tau :=\left| \frac{1}{-0.5} \right|$$

To insert an x-y plot into a Mathcad worksheet, first place the cursor outside an existing Mathcad text or math region. One can then either use icons or the menus. The first time you click on a plot icon, Mathcad displays the plotting pallet or button bar. Clicking on the icon for an x-y plot in the button bar inserts an empty x-y plot into the worksheet. To use the menu, click on the Insert menu, and follow the drop down menu to the item X-Y Plot.

Insert

Graph

X-Y Plot.

An empty x-y plot will display with solid black rectangles termed “place holders” for the independent and dependent variables and the axes limits, Fig. A2.1 .

Fig. A2.1 A Mathcad x-y plot object showing the black rectangular place holders. The variables can be scalars, vectors, expressions, or functions. The limits can be numerical values or expressions

To plot v(t) vs. t , enter t in the independent variable place holder on the x-axis, 0 in the lower limit x-axis place holder, 7*t Ctrl + g (to see \(7 \cdot \tau\) ) in the upper limit x-axis place holder, and either the function, v(t), or the expression, \(2.66 \cdot ( {1 - {{\rm{e}}^{ - 0.5 \cdot {\rm{t}}}}} )\) , in the dependent place holder on the y-axis. Clicking outside the region causes Mathcad to display the plot, Fig. A2.2 .

Fig. A2.2 A Mathcad plot of the function, \(v( t ) = 2.66( {1 - {{\rm{e}}^{ - 0.5t}}} )\)

Mathcad autoscales axes, when the limit place holders are blank. Often, as in this example, autoscaling leads to the display of only a portion of the response. The limits can be edited, after the plot is produced to change either the vertical or horizontal range shown. Clicking on the lower limit of the vertical axis 0.689 introduces the \(\left. {\underline {\,{} \,}}\! \right|\) shaped cursor into that region. Editing 0.689 to read 0, and then either typing tab, or clicking outside the plot region causes Mathcad to re-evaluate and display the plot, Fig. A2.3 .

Fig. A2.3 The Mathcad plot of the function, \(v( t ) = 2.66( {1 - {{\rm{e}}^{ - 0.5t}}} )\) , with the lower limit of the vertical axis edited to read zero

Plot regions can be dragged around the worksheet, and the frame of a plot region can be dragged to resize the plot. Plots can also be “formatted” to add grid lines, change the grid spacing, and to change the width, color, and type of line, Fig. A2.4 . Right-clicking within a plot region brings up a context-sensitive menu which includes the three items, Format…, Trace…, and Zoom… The format dialog box has five tabs which are self-explanatory, with the exception of the “secondary Y-axis.” Clicking the check box “Enable second Y-axis” produces a set of place holders on the right side of the plot, the middle place holder is for a second dependent variable, and the other two are the limits of the secondary Y-axis. We will find a secondary Y-axis useful, since the power variables of energetic systems have different units and, importantly, different magnitudes. Plotting the responses of two different power variables on one axis can lead to one response appearing flat, since its vertical range is misscaled.

Fig. A2.4 The Mathcad plot of the function, \(v( t ) = 2.66( {1 - {{\rm{e}}^{ - 0.5t}}} )\) , formatted adding gridlines, axes labels, and a plot title

When we wish to plot two or more “traces” on the same axis, typing a comma after entering a variable or expression in a place holder produces another place holder. For example, we plot \(v( t )\) , \(- 2.66{{\rm{e}}^{ - 0.5t}}\) , and 2.66 on the same axis, by typing a comma after entering \(v( t )\) , and again after entering \(- 2.66{{\rm{e}}^{ - 0.5t}}\) , Fig. A2.5 .

Fig. A2.5 The Mathcad plot of the function, \(v( t ) = 2.66( {1 - {{\rm{e}}^{ - 0.5t}}} )\) , the expression, \(- 2.66{{\rm{e}}^{ - 0.5t}}\) , and the constant, 2.66

We chose to set the limits of the time axis at zero and six or seven time constants. If we create a plot by editing the place holders for the independent and dependent variables, but leave the axes limits blank, Mathcad will autoscale the horizontal axis from − 10 to + 10, and evaluate the dependent variable within those limits. Since the input was applied at time, t = 0, the plot will show a response before the input acted on the system, Fig. A2.6 . Even though we did not intend for the function to be evaluated for negative time, it can be. The polite term for the resulting plot is “non-causal” since it violates cause and effect. The more common terms include nonsense and garbage.

Fig. A2.6 The Mathcad plot of the function, \(v( t ) = 2.66( {1 - {{\rm{e}}^{ - 0.5t}}} )\) , autoscaled from \(t =- 10\) to \(t =+ 10\)

Do not plot negative time, unless (1) the input is applied at the negative time of the lower limit, or (2) the response function is multiplied by the Heaviside unit step function to zero out the response function, until the time the input is applied. Mathcad’s notation for the Heaviside unit step function is capital phi, Φ( ). The f(x) button brings up a dialog with all of Mathcad’s built-in functions. The Heaviside unit step is in the “Piecewise Continuous” submenu, or can be found in the alphabetical list. Multiplying the response function by the Heaviside unit step function zeros out the value of the response function, until the moment when the Heaviside step function transitions from zero to one, Fig. A2.7 .

Fig. A2.7 The Mathcad plot of the product of the response function, v (t ), and the Heaviside step function, u _{ s } (t ). Mathcad’s notation for the Heaviside step function is Φ(t)

As an example of a second-order oscillatory step response, we will plot the result of Sect. 2.7.3

$$v\left( t \right)=2.74{{\text{e}}^{-0.16t}}\cos \left( 0.68t-2.91 \right)+2.66$$

Recall the exponent of the real exponential is σ , the real component of the eigenvalues of the system, and the frequency ω is the magnitude of the imaginary component of the eigenvalues.

$${{s}_{1}},\,{{s}_{2}}=\sigma \pm j\omega \,\,\,\,\,\,\to \,\,\,\,\,\,{{s}_{1}},\,{{s}_{2}}=-0.16\pm j0.68$$

Create an assignment statement defining the response variable, v _{2} (t ). Note the subscript 2, which is part of the function’s name. Mathcad refers to a subscript which is part of a variable of function name as a “literal” subscript, to distinguish it from a subscript which represents the index of a vector. A literal subscript is created by typing a period immediately before the literal subscript. A “vector” subscript or index is created by typing a left square bracket [ immediately before the subscript. Type

$$\text{v}.\text{2}(\text{t}):2.74*\text{e}\hat{\ }-0.5*{{\text{t}}_{\,\,Space\,\,Bar}}_{\,\,Space\,\,Bar}*\cos (0.68*\text{t}-2.91)+2.66$$

to see

$${{\text{v}}_{2}}\left( \text{t} \right):=2.74\cdot {{\text{e}}^{-0.16\cdot \text{t}}}\cdot \cos \left( 0.68\cdot \text{t}-2.91 \right)+2.66$$

The time constant, which scales the duration of the plot, is the time constant of the decay envelope. The upper limit of the time axis should be six or seven τ , where

$$\tau =\left| \frac{1}{\sigma } \right|\,\,\,\,\,\,\to \,\,\,\,\,\,\tau =\left| \frac{1}{-0.16} \right|\,\,\,\,\,\,\to \,\,\,\,\,\,\tau =43.75\,\,\sec \approx 44\,\,\sec $$

Mathcad permits assignment statements to be evaluated. Type

$$\text{t}\underbrace{\text{Ctrl+g}}_{\text{Simultaneously}}.2:\,\,|\,\,1/-0.16=$$

to see

$${{\tau }_{2}}:=\left| \frac{1}{-0.16} \right|=6.25$$

Create a plot by clicking the X-Y Plot button, which should be visible in both the button bar below the menus and in the Graph pallet. Get into the habit of entering the independent variable, t, and its limits, before entering the function name or expression as the dependent variable. Reversing the order leads to Mathcad trying to be helpful and autoscaling using its standard range of − 10 to 10, which is rarely the range we will want. Format the plot, adding gridlines, axes labels, and a plot title, Fig. A2.8 .

Fig. A2.8 The Mathcad plot of the response function, v _{2} (t ), formatted with gridlines, axes labels, and a plot title

We can reuse function and variable names. The assignment operator : = is a “local” assignment, meaning that it can be overwritten by a new assignment operator which appears to its left or below it in the worksheet. If we reuse a variable name, Mathcad underlines it with a green squiggle, to alert us, in case we thought the variable name was unique. Mathcad handles units as if they were variables, and has virtually every engineering unit predefined. Click on the measuring cup symbol to bring up the unit dialog box. Many common choices for variable names are predefined units. Consequently, variables may be underlined with a green squiggle, even though they are unique, because they are also the abbreviation of a unit.

Mathcad permits mixed units in calculations. Mathcad converts all units to SI prior to computation, and then presents the results in SI (or sometimes metric) but adds a blank placeholder. If the user enters a unit into the placeholder, Mathcad recomputes and expresses the result those units.

For example, type in the following volume computation, where the three lengths are expressed in inches, feet, and centimeters.

$$5*\text{in}*0.6*\text{ft}*14*\text{cm}=$$

You will see,

$$5\cdot \text{in}\cdot 0.6\cdot \text{ft}\cdot 14\cdot \text{cm}=3.252\,\text{L}\,\blacksquare $$

Edit the place holder. Type in^3. You will see

$$5\cdot \text{in}\cdot 0.6\cdot \text{ft}\cdot 14\cdot \text{cm}=3.252\,\text{L}\,\blacksquare $$