Mathcad Lecture: Tarlac State University Civil Engineering Department Engr. Orlando Sico JR, CE
Mathcad Lecture: Tarlac State University Civil Engineering Department Engr. Orlando Sico JR, CE
Graph: Various two- and three-dimensional plot types and graph tools.
The Standard toolbar is the strip of buttons shown just below the main menus in
Figure 2-1. Many menu commands can be accessed quickly by using these buttons.
The Formatting toolbar is shown immediately below the Standard toolbar in Figure
2-1. This contains scrolling lists and buttons used to specify font characteristics in
equations and text.
Tip To learn what a button on any toolbar does, let the mouse pointer rest on the button momentarily.
You’ll see a tooltip beside the pointer giving a brief description.
You can choose to show or hide each toolbar from the View menu. To detach and drag
a toolbar around your window, place the mouse pointer anywhere other than on a button
or a text box. Then press and hold down the mouse button and drag.
Tip You can customize the Standard, Formatting, and Math toolbars. To add and remove buttons,
right click on the toolbar and choose Customize from the popup menu.
Regions / 13
• Choose Zoom from the View menu or click on the Standard toolbar and
choose a number smaller than 100%.
Tip Mathcad supports the Microsoft IntelliMouse and compatible pointing devices. Turning the
wheel scrolls the window one line vertically for each click of the wheel. When you press
[Shift] and turn the wheel, the window scrolls horizontally.
See “Appendix I: Arrow and Movement Keys” on page 445 in the Appendices for
keystrokes for moving the cursor. If you are working with a longer worksheet, use Go
to Page from the Edit menu to move quickly through the worksheet.
Tip Mathcad supports standard Windows keystrokes for operations such as file opening, [Ctrl]O,
saving, [Ctrl]S, printing, [Ctrl]P, copying, [Ctrl]C, and pasting, [Ctrl]V. Choose
Preferences from the Tools menu and uncheck “Standard Windows shortcut keys” in the
General tab to use shortcut keys supported in early versions of Mathcad.
Regions
Mathcad lets you enter equations, text, and plots anywhere in the worksheet. Each
equation, piece of text, or other element is a region. Mathcad creates an invisible
rectangle to hold each region. A Mathcad worksheet is a collection of such regions. To
start a new region in Mathcad:
1. Click anywhere in a blank area of the worksheet. You see a small crosshair.
Anything you type appears at the crosshair.
2. If the region you want to create is a math region, just start typing anywhere you put
the crosshair. By default Mathcad understands what you type as mathematics. See
“A Simple Calculation” on page 16 for an example.
3. To create a text region, first choose Text Region from the Insert menu and then
start typing. See “Entering Text” on page 18 for an example.
In addition to equations and text, Mathcad supports a variety of plot regions. See
“Graphs” on page 21.
Tip Mathcad displays a box around any region you are currently working in. When you click outside
the region, the surrounding box disappears. To put a permanent box around a region or regions,
select them, then right click and choose Properties from the popup menu. Click on the Display
tab and check the box next to “Show Border.”
Selecting Regions
To select a single region, simply click it. Mathcad shows a rectangle around the region.
To select multiple regions:
1. Press and hold down the left mouse button to anchor one corner of the selection
rectangle.
2. Without letting go of the mouse button, move the mouse to enclose everything you
want inside the selection rectangle.
3. Release the mouse button. Mathcad shows dashed rectangles around the regions
you have selected.
Tip You can also select a single region or disconnected regions anywhere in the worksheet by
holding down the [Ctrl] key while clicking on each region. If you click one region and
[Shift]-click another, you select both regions and all regions in between.
Region Properties
The Region Properties dialog box allows you to perform the following actions,
depending on the type of region you’ve selected:
• Highlight the region.
• Display a border around the region.
• Assign a tag to the region.
• Restore the region to original size.
• Widen a region to the entire page width.
• Automatically move everything down in the worksheet below the region when the
region wraps at the right margin.
• Disable/enable evaluation of the region.
• Optimize an equation.
• Turn protection on/off for the region.
You can change the properties of a region or regions by right clicking and choosing
Properties from the menu.
Tip You can change the properties for multiple regions by selecting the regions you want to change,
and either selecting Properties from the Format menu or by right clicking on one of the regions
and choosing Properties from the menu.
Note When you select multiple regions, you may only change the properties common to the regions
selected. If you select both math and text regions, you will not be able to change text-only or
math-only options, such as “Occupy Page Width” or “Disable/Enable Evaluation”.
Moving and Copying Regions
Once the regions are selected, you can move or copy them.
Moving regions
You can move regions by dragging with the mouse, nudging with the arrow keys, or
by using Cut and Paste.
To drag regions with the mouse:
1. Select the regions.
2. Place the pointer on the border of any selected region. The pointer turns into a small
hand.
3. Press and hold down the mouse button.
4. Without letting go of the button, move the mouse. The rectangular outlines of the
selected regions follow the mouse pointer.
Dragging regions. To move the selected regions into another worksheet, press and
hold down the mouse button, drag the rectangular outlines into the destination
worksheet, and release the mouse button.
Nudging Regions.To nudge the regions, first select them to get a dotted line around
them. If you want to select a single region, press [Ctrl] and then click on the region.
Then you can use the arrows keys to nudge them in different directions.
To move the selected regions by using Cut and Paste:
1. Select the regions.
2. Choose Cut from the Edit menu, [Ctrl] X, or click on the Standard toolbar.
This deletes the selected regions and puts them on the Clipboard.
3. Click the mouse wherever you want the regions moved. Make sure you’ve clicked
in an empty space.
4. Choose Paste from the Edit menu, [Ctrl] V, or click on the Standard toolbar.
Note You can move one region on top of another. To move a particular region to the top or bottom,
right click on it and choose Bring to Front or Send to Back from the popup menu.
Copying Regions
To copy regions by using the Copy and Paste commands:
1. Select the regions.
2. Choose Copy from the Edit menu, [Ctrl] C, or click on the Standard toolbar
to copy the selected regions to the Clipboard.
3. Click the mouse wherever you want to place a copy of the regions. Make sure you’ve
clicked in an empty space and that you see the crosshair.
4. Choose Paste from the Edit menu, [Ctrl] V.
Tip If the regions you want to copy are coming from a locked area (see “Safeguarding an Area of the
Worksheet” on page 85) or an E-book, you can copy them simply by dragging them with the
mouse into your worksheet.
Deleting Regions
To delete one or more regions:
1. Select the regions.
2. Choose Cut from the Edit menu, [Ctrl] X.
Choosing Cut removes the selected regions from your worksheet and puts them on the
Clipboard. If you don’t want to disturb the contents of your Clipboard, or if you don’t
want to save the selected regions, choose Delete from the Edit menu or press
[Ctrl] D instead.
A Simple Calculation
Although Mathcad can perform sophisticated mathematics, you can easily use it as a
simple calculator. To try your first calculation, follow these steps:
1. Click anywhere in the worksheet. You see a small
crosshair. Anything you type appears at the crosshair.
2. Type 15-8/104.5=. When you type the equal sign or
click on the Evaluation toolbar, Mathcad computes
the result.
This calculation demonstrates the way Mathcad works:
• Mathcad sizes fraction bars, brackets, and other symbols to display equations the
same way you might see them in a book or on a blackboard.
• Mathcad understands which operation to perform first. In this example, Mathcad
knew to perform the division before the subtraction and displayed the equation
accordingly.
• As soon as you type the equal sign or click on the Evaluation toolbar, Mathcad
returns the result. Unless you specify otherwise, Mathcad processes each equation
as you enter it. See the section “Controlling Calculation” in Chapter 8 to learn how
to change this.
• As you type each operator (in this case, − and /), Mathcad shows a small rectangle
called a placeholder. Placeholders hold spaces open for numbers or expressions not
yet typed. As soon as you type a number, it replaces the placeholder in the
expression. The placeholder that appears at the end of the expression is used for
unit conversions. Its use is discussed in “Displaying Units of Results” on page 115.
Once an equation is on the screen, you can edit it by clicking in the appropriate spot
and typing new letters, numbers, or operators. You can type many operators and Greek
letters by clicking in the math toolbars introduced in “The Mathcad Workspace” on
page 11. Chapter 4, “Working with Math,” details how to edit Mathcad equations.
Definitions and Variables
Mathcad’s power and versatility quickly become apparent once you begin using
variables and functions. By defining variables and functions, you can link equations
together and use intermediate results in further calculations.
Defining Variables
To define a variable t, follow these steps:
2. Type the colon key : or click on the Calculator toolbar to insert the definition
symbol.
3. Type the value to be assigned to the variable. The value can be a single number or
a more complicated combination of numbers and previously defined variables.
Mathcad worksheets read from top to bottom and left to right. Once you have defined
a variable like t, you can compute with it anywhere below and to the right of the equation
that defines it.
Now enter another definition:
1. Press [↵]. This moves the crosshair below the first
equation.
2. To define acc as –9.8, type: acc:–9.8. Then press [↵]
again. Mathcad shows the crosshair cursor below the last
equation you entered.
Calculating Results
Now that the variables acc and t are defined, you can use them in other expressions:
1. Click the mouse a few lines below the two definitions.
2. Type acc/2[Space]*t^2. The caret symbol (^)
represents raising to a power, the asterisk (*) is
multiplication, and the slash (/) represents division.
3. Press the equal sign [=].
This equation calculates the distance traveled by a falling body in time t with
acceleration acc. When you enter the equation and press the equal sign [=], or click
on the Evaluation toolbar, Mathcad returns the result.
Mathcad updates results as soon as you make changes. For example, if you click on the
10 on your screen and change it to some other number, Mathcad changes the result as
soon as you press [Enter] or click outside of the equation.
Entering Text
Mathcad handles text as easily as it does equations, so you can make notes while
calculating.
Here’s how to enter text:
1. Click in the blank space to the right of the equations you
entered. You’ll see a small crosshair.
2. Choose Text Region from the Insert menu, or press " (the
double-quote key), to tell Mathcad that you’re about to enter
some text. Mathcad changes the crosshair into a vertical line called the insertion
point. Characters you type appear behind this line. A box surrounds the insertion
point, indicating you are now in a text region. This box is called a text box. It grows
as you enter text.
3. Type Equations of motion. The text appears in the
worksheet.
Note If Ruler under the View menu is checked when the cursor is inside a text region, the ruler resizes
to indicate the size of your text region. To use the ruler to set tab stops and indents in a text
region, see “Changing Paragraph Properties” on page 69.
Tip If you click in blank space in the worksheet and start typing, which creates a math region,
Mathcad automatically converts the math region to a text region when you press [Space].
Note Use [Ctrl][Shift][↵] to move out of the text region to a blank space in your worksheet. If
you press [↵], Mathcad inserts a line break in the current text region instead.
You can set the width of a text region and change the font, size, and style of the text in
it. (See Chapter 6, “Working with Text.”)
Iterative Calculations
Mathcad can do repeated or iterative calculations as easily as individual calculations
by using a special variable called a range variable.
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.
Creating a Range Variable
To compute equations for a range of values, first create a range variable. In the problem
shown in “Calculating Results” on page 17, 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:
1. First, change t into a range variable by editing its definition.
Click on the 10 in the equation t:=10. The insertion point
should be next to the 10 as shown.
2. Type ,11. This tells Mathcad that the next number in the range
will be 11.
3. Type ; for the range variable operator, or click on the
Matrix toolbar, and then type the last number, 20. This tells
Mathcad that the last number in the range will be 20. Mathcad
shows the range variable operator as a pair of dots.
Defining a Function
Here’s how to add a function definition to your worksheet:
1. First delete the table if you are in the same worksheet.
Now define the function d(t) by typing d(t):
2. Complete the definition by typing this expression:
1600+acc/2[Space]*t^2[↵]
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:
1. To evaluate the function at a particular value, such as 3.5,
type d(3.5)=. Mathcad returns the correct value as shown
at right.
2. To evaluate the function once for each value of the range variable
t you defined earlier, click below the other equations and type
d(t)=. Mathcad shows a table of values, as shown at right.
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, in the example above, the first two values, 1.11 ⋅ 10 3 and 1.007 ⋅ 10 3 ,
are in exponential (powers of 10) notation. Here’s how to change the table produced
above so that none of the numbers in it are displayed in exponential notation:
1. Click anywhere on the table with the
mouse.
2. Choose Result from the Format
menu. You see the Result Format
dialog box. This box contains
settings that affect how results are
displayed, including the number of
decimal places, the use of
exponential notation, the radix, and
so on.
3. The default format scheme is General which has Exponential Threshold
set to 3. This means that only numbers greater than or equal to 10 3 are
displayed in exponential notation. Click the arrows to the right of the 3
to increase the Exponential Threshold to 6.
4. Click “OK.” The table changes to reflect the new result format.
(See“Formatting Results” on page 112.)
Note When you format a result, only the display of the result is affected. Mathcad maintains full
precision internally (up to 15 digits).
Graphs
Mathcad provides two-dimensional Cartesian and polar graphs, contour plots, surface
plots, and a variety of other three-dimensional graphs. This section describes how to
create a simple two-dimensional graph showing the points calculated in the previous
section.
Creating a Basic Graph
To create an X-Y plot:
1. Click in your worksheet.
2. Choose Graph⇒X-Y Plot from the Insert menu
To print, choose Print from the File menu or click on the Standard toolbar. To
preview the printed page, choose Print Preview from the File menu or click on
the Standard toolbar.(See Chapter 7, “Worksheet Management.”)
Exiting Mathcad
To quit Mathcad choose Exit from the File menu. If you have moved any toolbars,
Mathcad remembers their locations for the next time you open the application.
Note To close an individual worksheet while keeping Mathcad open, choose Close from the
File menu.
Working with Math
! Inserting Math
! Building Expressions
! Editing Expressions
! Math Styles
Inserting Math
You can place math expressions anywhere you want in a Mathcad worksheet.
1. Click anywhere in the worksheet. Anything you type
appears at the crosshair.
2. Type numbers, letters, and math operators, or insert them
by clicking buttons on Mathcad’s math toolbars, to create
a math region.
You’ll notice that unlike a word processor, Mathcad by default understands anything
you type at the crosshair cursor as math. If you want to create a text region instead, see
Chapter 6, “Working with Text.”
You can also type math expressions in any math placeholder that appears. See Chapter
17, “Operators” for more on Mathcad’s operators.
Numbers and Complex Numbers
A single number in Mathcad is called a scalar. To enter groups of numbers in arrays,
see “Inserting an Operator” on page 38.
Types of numbers
In math regions, Mathcad interprets anything beginning with one of the digits 0–9 as
a number. A digit can be followed by:
• other digits
• a decimal point
• digits after the decimal point
• or appended as a suffix, one of the letters b, h, or o, for binary, hexadecimal, and
octal numbers, or i or j for imaginary numbers. These are discussed in more detail
below. See “Appendix G: Suffixes for Numbers” on page 443 for additional
suffixes.
Note Mathcad uses the period (.) to signify the decimal point. The comma (,) is used to separate
values in a range variable definition, as described in “Range Variables” on page 103. So when
you enter numbers greater than 999, do not use either a comma or a period to separate digits into
groups of three. Simply type the digits one after another. For example, to enter ten thousand, type
“10000”.
Imaginary and complex numbers
To enter an imaginary number, follow it with i or j, as in 1i or 2.5j.
Note You cannot use i or j alone to represent the imaginary unit. You must always type 1i or 1j. If
you don’t, Mathcad thinks you are referring to a variable named either i or j. When the cursor is
outside an equation that contains 1i or 1j, however, Mathcad hides the (superfluous) 1.
Although you can enter imaginary numbers followed by either i or j, Mathcad normally
displays them followed by i. To have Mathcad display imaginary numbers with j,
choose Result from the Format menu, click on the Display Options tab, and set
“Imaginary value” to “j(J).” See “Formatting Results” on page 112 for a full
description.
Mathcad accepts complex numbers of the form a + bi (or a + bj ), where a and b are
ordinary numbers.
Binary numbers
To enter a number in binary, follow it with the lowercase letter b. For example,
11110000b represents 240 in decimal. Binary numbers must be less than 2 31 .
Octal numbers
To enter a number in octal, follow it with the lowercase letter o. For example, 25636o
represents 11166 in decimal. Octal numbers must be less than 2 31 .
Hexadecimal numbers
To enter a number in hexadecimal, follow it with the lowercase letter h. For example,
2b9eh represents 11166 in decimal. To represent digits above 9, use the upper or
lowercase letters A through F. To enter a hexadecimal number that begins with a letter,
you must begin it with a leading zero. If you don’t, Mathcad will think it’s a variable
name. For example, use 0a3h (delete the implied multiplication symbol between 0
and a) rather than a3h to represent the decimal number 163 in hexadecimal.
Hexadecimal numbers must be less than 2 31 .
Exponential notation
To enter very large or very small numbers in exponential notation, just multiply a
number by a power of 10. For example, to represent the number 3 ⋅ 10 8 , type 3*10^8.
Tip You may wish to distinguish between the names of matrices, vectors, and scalars by font. Names
of vectors could be set in bold while setting scalars in italic. See “Math Styles” on page 50.
Strings
Although in most cases the math expressions or variables you work with in Mathcad
are numbers or arrays, you can also work with strings (also called string literals or
string variables). Strings can include any character you can type at the keyboard,
including letters, numbers, punctuation, and spacing, as well as a variety of special
symbols as listed in “Appendix K: ASCII codes” on page 447. Strings differ from
variable names or numbers because Mathcad always displays them between double
quotes. You can assign a string to a variable name, use a string as an element of a vector
or matrix, or use a string as the argument to a function.
To create a string:
1. Click on an empty math placeholder usually on the
right-hand side of a variable definition.
2. Type the double-quote (") key to get a pair of quotes
with an insertion line between them.
3. Type any combination of letters, numbers,
punctuation, or spaces. Click outside the expression
or press the right arrow key (→) twice when you are
finished.
To enter a special character corresponding to one of the ASCII codes:
1. Click to position the insertion point in the string.
2. Hold down the [Alt] key, and type the number “0” followed immediately by the
number of the ASCII code using the numeric keypad in number-entry mode.
3. Release the [Alt] key to see the symbol in the string.
For example, to enter the degree symbol (°) in a string, press [Alt] and type “0176”
using the numeric keypad.
Note The double-quote key (") has a variety of meanings in Mathcad, depending on the exact location
of the cursor in your worksheet. When you want to enter a string, you must always have a blank
placeholder selected.
Valid strings include expressions such as “Invalid input: try a number less than -5,”
and “Meets stress requirements.” A string in Mathcad, while not limited in size, always
appears as a single line of text. Note that a string such as “123” is understood by Mathcad
to be a string of characters rather than the number 123.
Tip Strings are especially useful for generating custom error messages in programs, as described in
Chapter 15, “Extending and Automating Mathcad.” Other string handling functions are listed in
“String Functions” on page 256. You can use strings to specify system paths for arguments to
some Mathcad built-in functions. (See “File Access Functions” on page 250.)
Names
A name in Mathcad is simply a sequence of characters you type referring to a variable
or function used in computations. Mathcad distinguishes between two kinds of names:
• Built-in names.
• User-defined names.
Built-in names
Mathcad’s built-in names include built-in variables and built-in functions.
• Some predefined or built-in variables either have a conventional value, like π
(3.14159...) or e (2.71828...), or are used as system variables to control how
Mathcad performs calculations. (See “Built-in Variables” on page 100.)
• In addition to these predefined variables, Mathcad treats the names of all built-in
units as predefined variables. For example, Mathcad recognizes the name “A” as
the ampere, “m” as the meter, “s” as the second, and so on. Choose Unit from the
• Choose Function from the Insert menu or click on the Standard toolbar to
insert one of Mathcad’s built-in functions. (See “Built-in Functions” on page 249.)
User-defined variable and function names
Names in Mathcad can contain any of the following characters:
• Uppercase and lowercase letters.
• The digits 0 through 9.
• The underscore (_).
• The prime symbol ('). Note that this is not the same as an apostrophe. The prime
symbol is on the same key as the tilde (~) or press [Ctrl][F7] to insert it.
• The percent symbol (%).
• Greek letters. To insert a Greek letter, click a button on the Greek toolbar or type
the equivalent roman letter and press [Ctrl]G. (See “Greek letters” on page 37.)
Note Mathcad distinguishes between uppercase and lowercase letters. For example, diam is a different
variable from DIAM. Mathcad also distinguishes between names in different fonts, as discussed
in “Math Styles” on page 50. Thus, Diam is also a different variable from Diam.
Tip To type symbols such as $ in a name, press [Ctrl][Shift]K, type the symbol(s), and type
[Ctrl][Shift]K again.
Greek letters
There are two ways to enter a Greek variable name:
• Click the letter on the Greek toolbar. To see this toolbar, click on the Math
toolbar or choose Toolbars⇒Greek from the View menu.
• Type the Roman equivalent of the Greek symbol and then press [Ctrl]G. For
example, to enter φ, press f[Ctrl]G. See “Appendix H: Greek Letters” on page
444 in the Appendices for a table of Greek letters and their Roman equivalents.
Note Although many uppercase Greek letters look like ordinary capital letters, they are not the same.
Mathcad distinguishes between Greek and Roman letters, even if they appear the same.
Literal subscripts
If you include a period in a variable name, Mathcad displays whatever follows the
period as a subscript. You can use these literal subscripts to create variables with names
like vel init and u air .
key ([) or by clicking on the Calculator toolbar. Although they appear similar—a literal
subscript appears below the line, like an array subscript, but with a slight space before the
subscript—they behave quite differently in computations. A literal subscript is simply a
cosmetic part of a variable name. An array subscript represents a reference to an array element.
See Chapter 5, “Vectors, Matrices, and Data Arrays”.
Operators
Operators are symbols like “+” and “−” that link variables and numbers together to
form expressions. The variables and numbers linked together by operators are called
operands. For example, in an expression like:
ax + y
the operands for the “+” are x and y. The operands for the exponent operator are a and
the expression x + y .
Inserting an Operator
Insert arithmetic operators in Mathcad using standard keystrokes, like * and +, that you
use in other applications. Alternatively, all of Mathcad’s operators can be inserted from
the math toolbars. For example, insert a derivative operator by clicking on the
Calculus toolbar, or by typing ?. Choose Toolbars from the View menu to see the math
toolbars. See Chapter 17, “Operators” for a complete list of operators, their keystrokes,
and descriptions.
Note To use operators in text, first click in the text and choose Math Region from the Insert menu.
Tip You can find the keyboard shortcut for an operator by hovering the mouse pointer over a button
in a math toolbar and reading the tooltip.
When you insert a Mathcad operator into a blank space in your worksheet, a
mathematical symbol with empty placeholders appears. You must enter a valid math
expression in each placeholder of an operator in order to calculate a result.
Here is a very simple example involving Mathcad’s addition operator:
4. Type +.
Note that you can type the expression the same way you’d say it out loud. However,
even this simple example already contains an ambiguity. When you say “a to the x plus
y” there’s no way to tell if you mean a x + y or a x + y . For more complicated
expressions, the number of ambiguities increases dramatically.
Although you can always resolve ambiguities by using parentheses, doing so can
quickly become cumbersome. A better way is to use the editing lines to specify the
operands of whatever operator you type. The following example illustrates this by
describing how to create the expression a x + y instead of a x + y .
1. Enter a^x as you did in the previous example. Note how the editing
lines hold the x between them. If you were to type + at this point, the
x would become the first operand of the plus.
2. Press [Space]. The editing lines now hold the entire expression a x .
3. Now type +. Whatever was held between the editing lines now
becomes the first operand of the plus.
4. In the remaining placeholder, type y.
Multiplication
When writing, expressions like ax or a ( x + y ) are easily understood to mean “a times
x” and “a times the quantity x plus y,” respectively.
This cannot be done with Mathcad variables for the simple reason that when you type
ax, Mathcad has no way of knowing whether you mean “a times x” or “the variable
named ax.” Similarly, when you type a(x+y), Mathcad cannot tell if you mean
“a times the quantity x plus y” or whether you mean “the function a applied to the
argument x + y .”
To avoid ambiguity in math expressions, we recommend that you always press *
explicitly to indicate multiplication, as shown in the following example:
1. Type a followed by *. Mathcad inserts a small dot after the “a” to
indicate multiplication.
2. In the placeholder, type the second factor, x.
Note In the special case when you type a numerical constant followed immediately by a variable
name, such as 4x, Mathcad interprets the expression to mean the constant multiplied by the
variable: 4 ⋅ x . Mathcad displays a space between the constant and the variable to indicate that
the multiplication is implied. This enables you to produce math notation that closely
approximates the notation in textbooks. However, Mathcad reserves certain letters, such as “i”
for the imaginary unit and “o” for octal, as suffixes for numbers, and in these cases does not
attempt to multiply the number by a variable name but rather treats the expression as a single
number with a suffix.
Tip You can change the display of the multiplication operator to an X, a thin space, or a large dot.
To do so, click on the multiplication operator with the right mouse button and choose View
Multiplication As... Or to change all the multiplication operators in a worksheet, choose
Worksheet Options from the Tools menu, click on the Display tab, and choose from the
selections next to “Multiplication.” See “Changing the Display of an Operator” on page 391.
An Annotated Example
An equation is really two-dimensional, with a structure more like a tree with branches
than like a line of text. As a result, Mathcad has to use a two-dimensional editing cursor.
That’s why there are two editing lines: a vertical line and a horizontal line.
Suppose, for example, that you want to type the slightly more complicated expression
x – 3 ⋅ a2
---------------------------------------
–4+ y+1+π
Watch what happens to the editing lines in the following steps:
1. Type x-3*a^2. Since the editing lines contain just the “2,”
only the “2” becomes the numerator when you press the /. To
make the whole expression, x – 3 ⋅ a 2 , be the numerator, you
need the editing lines to hold the entire expression.
2. Press [Space]. Each time you press [Space], the editing lines
hold more of the expression. You need to press [Space] three
times to enclose the entire expression.
3. Now press / to create a division bar. Note that the numerator
is whatever was enclosed between the editing lines when you
pressed /.
Editing Expressions
Changing a Name or Number
To edit a name or number:
1. Click on it with the mouse. The vertical editing line appears.
2. Move the vertical editing line by pressing the [→] and [←] keys.
3. If you type a character, it appears just to the left of the vertical editing line. Pressing
[Bksp] removes the character to the left. Pressing [Delete] removes the character
to the right.
Choose Replace from the Edit menu to change several occurrences of the same name
or number. To search for a sequence of characters, choose Find from the Edit menu.
See “Text Tools” on page 73.
Inserting an Operator
The easiest place to insert an operator is between two characters in a name or two
numbers in a constant. For example, here’s how to insert a plus sign between two
characters:
1. Place the editing lines where you want the plus sign to be.
Note Mathcad inserts spaces automatically around operators wherever doing so is appropriate. If you
do try to insert a space, Mathcad assumes you meant to type text rather than math and converts
your math region into a text region.
When you insert a division sign, Mathcad moves everything that comes after the
division sign into the denominator. Here’s how you insert a division sign:
1. Place the editing lines where you want the division sign.
• The editing lines hold the entire fraction. Any operator you type
will apply to the entire fraction.
• The editing lines hold the entire fraction. However, this time
the vertical editing line is on the left side instead of on the right
side.
• Typing *c results in this expression. The c is before the fraction.
because the vertical editing line was on the left side rather than
the right side.
Controlling the editing lines
Use the following techniques to control what’s between the editing lines:
• Click on an operator. To move the vertical editing line from one side to the other
of the expression, press [Insert].
• Use the left and right arrow keys to move the vertical editing line one character at
a time. The horizontal editing line selects an operand of the nearest operator. If your
expression contains built-up fractions, you can also use the up and down arrow keys
to move the editing lines.
• Press [Space] to select larger parts of the expression. Each time you press
[Space], the editing lines enclose more and more of the expression, until they
enclose the entire expression. Pressing [Space] one more time brings the editing
lines back to where they started.
Tip You can drag-select parts of an expression to hold it between the editing lines. The selected
expression is highlighted in reverse video. Whatever you type next overwrites the highlighted
expression.
The following example walks you through a short cycle of using [Space]:
1. This is the starting position. The two editing lines hold just the
single variable “d.”
2. Pressing [Space] makes the editing lines grow so that they now
hold the entire denominator.
4. At this point, the editing lines can’t become any longer. Pressing
[Space] brings the editing lines back to the starting point of the
cycle.
You’ll notice there was never an intermediate step in which the editing lines held just
the numerator. Nor was there ever a step in which the editing lines held just the a or
just the b in the numerator. The sequence of steps the editing lines go through as you
press [Space] depends on the starting point of the cycle.
The arrow keys walk the editing lines through the expression in the indicated direction.
Keep in mind that the idea of “up” and “down” or “left” and “right” may not always
be obvious, particularly when the expression becomes very complicated or if it involves
summations, integrals, and other advanced operators.
Note Editing of strings differs from editing of other math expressions because you must use the arrow
keys or click outside the string to move out of a string. Pressing [Space], which can be used
in other expressions to change the position of the editing lines, is interpreted as just another
character in a string.
Deleting an Operator
To delete an operator connecting two variable names or constants:
1. Place the vertical editing line after the operator.
2. Press [BkSp].
Now you can insert a new operator to replace the one you deleted just
by typing it in.
Tip You can place the editing lines before an operator and press [Delete].
In these examples, it is easy to see what “before” and “after” mean because the
expressions involved naturally flow from left to right, the same way we read. Fractions
behave the same way. Since we naturally say “a over b,” putting the editing lines “after”
the division bar means putting them just before the b. Similarly, putting the editing lines
“before” the division bar means putting them immediately after the a. The following
example illustrates this:
1. Place the vertical editing lines after the division bar.
2. Press [BkSp].
To delete an operator having only one operand
(for example, x , x or x! ):
1. Position the editing lines just after the operator.
2. Press [BkSp].
For certain operators, it may not be clear where to put the editing lines.
For example, it is not clear when looking at x or x what “before” and “after” mean.
When this happens, Mathcad resolves the ambiguity by referring to the spoken form
of the expression. For example, since you read x as “x conjugate,” the bar is treated as
being after the x.
Replacing an Operator
To replace an operator after deleting it, simply type the new operator after pressing
[BkSp].
To replace an operator between two expressions:
1. Position the editing lines just after the operator.
2. Press [BkSp]. An operator placeholder appears.
Inserting Parentheses
Mathcad places parentheses automatically to maintain the precedence of operations.
You may want to place parentheses to clarify an expression or to change the overall
structure of the expression. You can either insert a matched pair of parentheses all at
once or insert the parentheses one at a time. We recommend you insert a matched pair
since this avoids the possibility of unmatched parentheses.
To enclose an expression with a matched pair of parentheses:
1. Select the expression by placing it between the editing lines. Do
this by clicking on the expression and pressing [Space] one or
more times.
2. Press [BkSp]. Note that you could also begin with the editing
lines to the left of the “)”and press [Delete] instead.
Insert Function
To see an alphabetical or category listing of available built-in functions or to insert a
function together with placeholders for its arguments, choose Function from the Insert
menu. The dialog box lists all functions.
1. Click in a blank area of your worksheet or on a placeholder.
2. Choose Function from the
Insert menu or click on the
Standard toolbar. Mathcad opens
the Insert Function dialog box.
3. Choose a Function Category or
click “All” to see all functions
sorted alphabetically.
Tip Although built-in function names are not font sensitive, they are case sensitive. If you do not use
the Insert Function dialog box to insert a function name, you must enter the name of a built-in
function in a math region exactly as it appears in the tables in Chapter 16, “Functions: :
uppercase, lowercase, or mixed, as indicated.
• Online Help or clicking on the Standard toolbar provides both overview and
detailed help on functions and function categories.
• QuickSheets under the Help menu include working examples of most functions.
Applying a Function to an Expression
To turn an expression into the argument of a function, follow these steps:
1. Click in the expression and press [Space] until the entire
expression, w ⋅ t – k ⋅ z , is held between the editing lines.
Tip You can drag and drop expressions, or even entire math regions, into placeholders in other
expressions or into any blank space. Don’t let go of the mouse button before you’ve dragged the
expression to wherever you want to drop it. If you’re trying to drop the expression into a
placeholder, be sure to position the pointer carefully over the placeholder.
Note If you select an expression with the editing lines instead of drag-selecting as shown above, you
must press [Bksp] or [Delete] twice to remove it. In this case, [Bksp] removes the expression
to the left of the editing lines, and [Delete] removes to the right.
Math Styles
By making changes to text styles rather than to individual text elements, you can make
uniform changes across your files. (See Chapter 6, “Working with Text”.) You can get
this same kind of leverage by using math styles to assign particular fonts, font sizes,
font styles and affects, and colors to your math expressions.
Mathcad has predefined math styles that govern the default appearance of all the math
in your worksheet, but you can define and apply additional styles.
Mathcad’s predefined math styles are:
• Variables: all variables, letters, and operators in math regions.
• Constants: all numbers in math regions.
Whenever you type a variable name, Mathcad:
• Assigns to it a math style named “Variables.”
• Displays the variable name using the characteristics associated with the style named
“Variables.”
Similarly, when you type a number or when a result is calculated, Mathcad:
• Assigns to it a math style named “Constants.”
• Displays the number using the characteristics associated with the style named
“Constants.”
Editing Math Styles
To change Mathcad’s default style for all variables and plots:
1. Click on a variable name in your worksheet.
2. Choose Equation from the Format menu.
The style name “Variables” is selected.
3. Click “Modify” to change the font associated
with the “Variables” style. You’ll see a dialog
box for changing fonts.
4. Make any changes using the dialog box.
Mathcad changes the font of all variables in
the worksheet.
If you change the Variables style, you may also
want to change the style used for numbers so that the two go together.
1. Click on a number.
2. Choose Equation from the Format menu to see the Equation Format dialog box.
The style name “Constants” is now selected.
3. Follow the procedure given above for modifying the Variables style.
You can also use the Formatting toolbar to change the font, font size, or font style
associated with a math style. For example, click on a variable, then click on the
appropriate Formatting toolbar button to make variables bold, italic, or underlined or
to specify the font or point size in the drop-down lists.
Note Mathcad’s line-and-character grid does not respond automatically to changes in the font sizes
used in text and math. Changing font characteristics, particularly font sizes, may cause regions
to overlap. You can separate these regions by choosing Separate Regions from the Format
menu.
You may wish to have your equations display in a different color than your default text
regions to avoid confusing the two. To change the default color of all equations in your
worksheet:
1. Choose Equation from the Format menu.
2. Select a color in the “Default Equation Color” drop-down list.
Applying Math Styles
The “Variables” and “Constants” styles govern the default appearance of all math in
your worksheet. These two style names cannot be changed. You may, however, create
and apply additional math styles.
To see what math style is currently assigned to a name or number, simply click on the
name or number, and look at the style window on the Formatting toolbar.
Alternatively, click the name or number and
choose Equation from the Format menu. The
math style associated with whatever you clicked
on appears in the drop-down list in the Equation
Format dialog box.
If you click on the button to the right of
“Variables” in either the Formatting toolbar or the
Equation Format dialog box, you’ll see a drop-
down list of available math styles. If you now
choose “User 1” and click “OK,” a new math style is applied to the selected element
and its appearance changes accordingly.
You can apply a variety of math styles to:
• individual variable names in an expression, or
• individual numbers in a math expression (but not in computed results, which always
display in the “Constants” style).
For example, you may want to show vectors in a bold, underlined font:
1. Choose Equation from the Format menu.
2. Click the down arrow beside the name of the current math styles to see a drop-down
list of available math styles.
3. Click on an unused math style name like “User 1” to select it. The name “User 1”
should now appear in the “New Style Name” text box. Click in this text box and
change the name to “Vectors.”
4. Click “Modify” to change this style to a bold, underlined font.
This creates a math style called “Vectors” with the desired appearance.
Now rather than individually changing the font, font size, and font style for names of
vectors, you can simply change the math style for all vectors.
Note All names, whether function names or variable names, are font sensitive. This means that x and
x refer to different variables, and f(x) and f(x) refer to different functions. In deciding whether
two variable names are the same, Mathcad actually checks math styles rather than fonts. To
avoid having distinct variables that look identical, don’t create a math style with exactly the
same font, size, and other characteristics as another math style.