Using the author's considerable experience of applying Mathcad to engineering problems, Essential Mathcad introduces the most powerful functions and features of the software and teaches how to apply these to create comprehensive calculations for any quantitative subject. The simple, step-by-step approach makes this book an ideal Mathcad text for professional engineers as well as engineering , science, and math students. Examples from a variety of fields demonstrate the power and utility of Mathcad's tools, while also demonstrating how other software, such as Excel spreadsheets, can be incorporated effectively. A full version of Mathcad v15 is available by using the registration code included in the front of the book (North America only). The included software is for educational purposes only.
*Many more applied examples and exercises from a wide variety of engineering, science, and math fields
* New: more thorough discussions of differential equations, 3D plotting, and curve fitting, reading from files and writing to files.
* Full non-expiring version of Mathcad 15 software available, by using the registration code included in the front of the book). The included software is for educational purposes only.
*New: A new chapter 1 introduces many basics of Mathcad, allowing the reader to begin using the program in less time.
* A step-by-step approach enables easy learning for professionals and students alike
Brent Maxfield is a Professional Structural Engineer in Utah and a Professional Civil Engineering in California. He graduated Magna Cum Laude from Brigham Young University with a degree in Civil Engineering and earned a Master of Engineering Management degree. He is active in professional associations, having served on the Board of Directors of the Structural Engineers Association of Utah and in the Structural Advisory Committee to the Utah Uniform Building Codes Commission. He has used Mathcad extensively for nearly 20 years. In Essential Mathcad, Maxfield shares his vast Mathcad experience and knowledge.
This chapter is intended to quickly teach you some fundamental Mathcad concepts. We will only touch the surface of many Mathcad concepts. In later chapters, we will get into more depth, and build on the concepts covered in this chapter. This chapter also teaches techniques to create and edit Mathcad expressions.
Chapter 1 will:
* Show how to do simple math in Mathcad.
* Teach how to assign and display variables.
* Explain how to create and edit math expressions.
* Demonstrate the editing cursor and the different forms it takes.
* Discuss the use of operators.
* Demonstrate how to wrap a math region.
* Briefly discuss the Mathcad toolbars.
* Introduce and define math and text regions.
* Introduce built-in and user-defined functions.
* Introduce units.
* Introduce arrays and subscripts.
* Discuss the variable ORIGIN.
* Describe the difference between literal and array subscripts.
* Introduce range variables.
* Introduce X-Y plots.
* Encourage completing several Mathcad tutorials.
BEFORE YOU BEGIN
If you don't already have Mathcad installed on your computer, take a few minutes and install the included version of Mathcad 14. This is the full unexpiring version of Mathcad. This will allow you to follow along and practice the concepts discussed in this book. It will also give you access to Mathcad Help and Mathcad Tutorials.
Essential Mathcad is based on the US version of Mathcad. It is also based on the US keyboard. There may be slight differences in Mathcad versions sold outside of the United States.
We suggest that you read and do the exercises in the Mathcad tutorial before or just after reading this chapter. You can open the Mathcad tutorial by clicking Tutorials from the Help menu. This opens a new window called the Mathcad Resources window. In this window you will see a list of Mathcad tutorials. Click the Getting Started Primers. Each of these primers is excellent. You may choose to do them all, but for the purpose of this chapter, focus on the following topics: Entering Math Expressions, Building Math Expressions, Editing Math Expressions, First Things First, and Adding Text and Images. This chapter cannot replace the experience gained by completing the Mathcad tutorials.
Whenever you open Mathcad, a blank worksheet appears. You can liken this worksheet to a clean sheet of calculation paper waiting for you to put information on it.
Let's begin with some simple math. Type 5+3=. You should get the following:
5 + 3 = 8.
Now type (2+3)*2=. You should get the following:
(2 + 3)* = 10.
You can also assign variable names to these equations. To assign a value to a variable, type the variable name and then type the colon : key. For example, type a1:5+3.
Now type a1=. This evaluates and displays the value of variable a1.
al = 8.
Let's assign another variable. Type b1:(2+3)*2.
Now type b1=. This displays the value of variable b1.
Now that values are assigned to variable a1 and variable b1, you can use these variables in equations. Type c1:a1+b1.
c1 = 18.
Now type c1=. You should get the following result:
As you begin using variables, it is important to understand the following Mathcad protocol. In order to use a previously defined variable, the variable must be defined above or to the left of where it is being used. In other words, Mathcad calculates from left to right, top to bottom.
As you can see, Mathcad does not require any programming language to perform simple operations. Simply type the equations as you would write them on paper.
CREATING SIMPLE MATH EXPRESSIONS
There are two ways to create a simple expression. The first way is to just type as you would say the expression. For example, you say 2 plus 5, so you would type the following 2+5. You say 2 to the 4th power, so you would type 2^4. You say the square root of 100, so you type \100.
The second way to create a simple expression is to type an operator such as +, —, *, or /. This will create empty placeholders (black boxes) that you can then click to fill in the numbers or operands. For example, if you press the + key anywhere in your worksheet, you will get the following:
* + * Click in the first placeholder and type 2, then press TAB or click in the second placeholder and type 5. Your expression should now look like this:
2 + 5
In this example, 2 and 5 are operands of the + operator.
You can use this procedure with any operator. Let's try the exponent operator. Press ^ to create the exponent operator. You can also click [X.sup.Y] on the calculator toolbar. You should have the following:
Click in the lower placeholder and type 2, then press TAB or click in the upper placeholder and type 4. Your expression should now look like this:
These methods of creating expressions work very well for creating simple expressions. As your expressions become more complex, there are a few things we must learn.
Creating more complex math expressions is very easy once you learn the concept of the editing lines. These are similar to a two-dimensional cursor with a vertical and a horizontal component. There is a vertical editing line and a horizontal editing line. As an expression gets larger, the editing lines can grow larger to contain the expanding expression. Notice how in the previous examples the editing lines just contained a single operand. Pressing the spacebar will cause the editing lines to grow to hold more of the expression. For example, if you type 2+5 spacebar, you get the following:
2 + 5
Whatever is held between the editing lines becomes the operand for the next operator. So, if you type 2+5 spacebar^3, you get the following:
(2 + 5)3
In this case (2+5) is the x operand for the operator x to the power of y. Notice how the editing lines now contain only the number 3. This means that if you type any operator, the number 3 is the operand for the operator. Thus, if you type + 4, you get the following:
(2 + 5)3+4
But, if you press the spacebar first, the editing lines expand to enclose the whole expression. This expression becomes the operand for the next operator. Thus, if you now type + 4, you get the following:
(2 + 5)3 + 4
The whole expression became the operand for the addition operator.
It is very important to understand this concept of using the editing lines to determine what the operand is of your next operator. You can also use parentheses to set the operand for operators. Pressing the single quote (') adds a pair of opposing parentheses.
The following example will help reinforce these concepts. Let's create the following expression:
[MATHEMATICAL EXPRESSION NOT REPRODUCIBLE IN ASCII]
To create this expression, use the following steps:
1. Type 1/2 spacebar. The editing lines now hold the fraction 1/2. This becomes the operand for the subtraction operator.
2. Type - 1 / 3 spacebar spacebar. The editing lines should now hold both fractions. This becomes the operand for the power operator.
1/2 - 1/3
3. Type ^2 spacebar. The editing lines should now hold the entire numerator. This becomes the operand for the division operator.
(1/2 - 1/3)2
4. Type /\(or use the square root icon on the math toolbar) 4/5 spacebar spacebar. This makes everything under the radical the operand for the addition operator.
[MATHEMATICAL EXPRESSION NOT REPRODUCIBLE IN ASCII]
5. Type + 2 / 7. This completes the example.
[MATHEMATICAL EXPRESSION NOT REPRODUCIBLE IN ASCII]
Notice how during each step, the spacebar was used to enlarge the editing lines to include the operand for the following operator.
The Mathcad tutorial has additional examples that provide worthwhile practice.
Another important concept to know is how to edit existing expressions. In order to understand this concept, it is important to understand how to move the vertical editing line. This vertical editing line can be moved left and right using the left and right arrow keys. You can also toggle the vertical editing line from the right side to the left side and back by pressing the INSERT key. For expressions that are more complex you can also use the up and down arrows to move both editing lines.
If you click anywhere in an expression and then press the spacebar, the editing lines expand to include more and more of the expression. How the editing lines expand depend on where you begin and on what side the vertical editing line is on. The editing lines work differently in different versions of Mathcad. The best way to understand how they work is to experiment and to follow the examples in the Mathcad tutorial.
I have found that if you begin with the vertical editing line on the right side of the horizontal editing line, the expansion of the editing lines makes more sense. The general rule is that as the editing lines expand and cross an operator, the operand for that operator is then included within the lines.
You can delete characters in your expressions by moving the vertical editing line adjacent to the character. If the vertical editing line is to the left of the character, press the DELETE key. If the vertical editing line is to the right of the character, press the BACKSPACE key.
To delete multiple characters, drag-select the portion of the expression you want to delete. If the vertical editing line is to the left of the highlighted area, press the DELETE key. If the vertical editing line is to the right of the highlighted area, press the BACKSPACE key.
Deleting and Replacing Operators
To replace an operator, place the editing lines so that the vertical editing line is just to the left of the operator. Next, press the DELETE key. This will delete the operator, usually leaving a hollow box symbol where the operator used to be. Now, type a new operator, and it will replace the box symbol. See Figure 1.1.
You may also have the vertical editing line to the right of the operator and use the BACKSPACE key to delete and replace the operator.
The best way to understand this concept is to experiment with it.
There are times when a very long expression might extend beyond the right margin. If this is the case, the entire expression will not print on the same sheet of paper.
There is a way to wrap your equations so that they are contained on two or more lines; however, you are only able to wrap equations at an addition operator.
To wrap an equation, press CTRL+ENTER just prior to an addition operator. Mathcad inserts three dots indicating that the expression is to be continued on a following line. On the following line, Mathcad inserts the addition operator with a placeholder box. Because Mathcad automatically inserts the addition operator, you are not able to wrap an equation at other operators.
You may wrap an equation at a subtraction operator by making the following operand a negative number (in essence adding a negative number).
Now that you understand how to create and edit Mathcad expressions, let's start exploring some of Mathcad's features.
One of the easiest ways to access many of Mathcad's features is by the use of toolbars. You access Mathcad toolbars by clicking Toolbars from the View menu. For our discussion it is important to have the following toolbars turned on: Standard, Formatting, and Math. See Figure 1.3 to see these toolbars.
The Math toolbar allows you to quickly access many of the other toolbars. From this toolbar you will be able to open the following toolbars: Calculator, Graph, Vector and Matrix, Evaluation, Calculus, Boolean, Programming, Greek Symbol, and Symbolic Keyword. Hover your mouse above each icon on the Math toolbar to see a tooltip reminding you which toolbar each icon opens.
The Calculator toolbar allows you to quickly access some basic math operators and trigonometric functions. See Figure 1.4. The Calculator toolbar behaves just like a calculator. It inserts the numbers and operators into Mathcad as you click the buttons on the toolbar. If you click an operator prior to entering numbers, Mathcad inserts blank placeholders into the worksheet. Press the TAB key to move between placeholders.
In-line division is a way to save space when you have several divisions in your expression. It displays division similar to a textbook. To add an in-line division operator to your expression, type CTRL+/ rather than just the /. You can also use the division (÷) icon on the Calculator toolbar. See Figure 1.5.
Mixed numbers allow you to input and show values as integers and fractions. To enter a mixed number press CTRL+SHIFT+PLUS or use the [??] icon on the Calculator toolbar. See Figure 1.6.
To display results as mixed fractions, double-click the displayed result. This opens the Result Format dialog box. Select Fraction from the Format list, and check the "Use mixed numbers" check box.
The Greek toolbar allows you to quickly enter Greek letters. See Figure 1.7. Chapter 2 will discuss Greek letters in more detail.
Summary of Equal Signs
There are four equal signs used in Mathcad. It is important to understand the difference between them.
* The assignment operator (:=) COLON is used to define variables, functions, or expressions.
* The evaluation operator (=) EQUAL SIGN is used to evaluate a variable, function, or expression numerically.
* The Boolean equality operator (=) CTRL+EQUAL SIGN is used to evaluate the equality condition in a Boolean statement. It is also used for programming, solving, and in symbolic equations. It will be discussed in more detail in future chapters.
* The global assignment operator ([equivalent to]) TILDA $ or SHIFT+ACCENT is used to assign a global variable. All global assignment definitions in the worksheet are scanned by Mathcad prior to scanning for normal assignment definitions. This means that global assignments can be defined anywhere in the worksheet and still be recognized. Global assignments should be used with caution.
The use of global definitions is discouraged because they do not participate in redefinition warnings, and they can create confusing redefinition chains if used in the middle of a document.
The assignment operator, evaluation operator, and global assignment operator are found on the Evaluation toolbar. The Boolean equality operator is found on the Boolean toolbar.
A region is a location where information is stored on the worksheet. Your entire Mathcad worksheet will be comprised of individual regions. You can view the regions in your worksheet by clicking Regions from the View menu. There are two types of regions—math regions and text regions.
Math regions contain variables, constants, expressions, functions, plots, among others. These regions are basically anything except text regions. These regions are created automatically whenever you create any expression or definition.
Text regions allow you to add notes, comments, titles, headings, and other items of interest to your calculation worksheet. There are several ways to create a text region. The simplest way to create a text region is to start typing text. As soon as you use the spacebar, Mathcad converts the math region into a text region. This is a handy feature, unless you press the spacebar by accident when you are entering a variable name. Once a math region is converted to a text region, it cannot be changed back to a math region. (You can use the undo command, if you immediately catch the mistake.) Other ways to create text regions are to use the double quote (") key, or choose Text Region from the Insert menu.
When you are finished typing the text, if you press the ENTER key, Mathcad inserts a new paragraph in the same text region. In order to exit a text region, click outside the region. You can also press CTRL+SHIFT+ENTER, or you can use the arrow keys to move the cursor outside the text region.
In Chapter 2, we will discuss text regions in much more depth.
Creating and Editing Mathcad Expressions
Simple User-Defined Functions
Arrays, Vectors, and Matrices
Selected Mathcad Functions
Simple Logic Programming
Introduction to Symbolic Calculations
Solving Engineering Equations
Putting It All Together
Assembling Calculations from Standard Calculation Worksheets
Importing Files from Other Programs into Mathcad
Communicating with Other Programs Using Components
Microsoft Excel Component
Inputs and Outputs
Hyperlinks and Tables of Contents