Confirming Pages
CA P P E N D I X C
Mathcad has a unique way to handle equations, numbers, text, and graphs. It works like ascratch pad and pencil. The screen interface is a blank worksheet on which you can enterequations, graph data or functions, and annotate operations with text. It uses standardmathematical symbols to represent operators when possible. Therefore, you may find thatthe Mathcad interface is quite natural and familiar.
Mathcad can solve a wide range of mathematical problems either numerically or sym-bolically. The symbolic capabilities of Mathcad have relatively little application in thistext, although they may be used to check our numerical results. Therefore, they will not becovered in detail in this overview. Mathcad has a comprehensive set of operators and func-tions that allow you to perform many of the numerical methods covered in this text. It alsohas a programming language that allows you to write your own multiline procedures andsubprograms. The following discussion provides a brief description of the features ofMathcad you will find most useful for this text.
THE BASICS OF MATHCAD
Applications in this text will require that you be able to create your own worksheets. Tofacilitate your efforts, let’s go over the main features of the Mathcad application window.
The Main Menu
This is your gateway to Mathcad. It also provides commands that handle the details of edit-ing and managing your worksheets. For example, click on the File and Tools menus to seesome of the functionality available to you.
The Standard Tool Bar
Several toolbars should be automatically displayed just below the Main menu. As thename implies, the Standard toolbar provides shortcuts for many common tasks, fromworksheet opening and file saving to bringing up lists of built-in functions and units.
941
Getting Started with Mathcad
cha01064_app_C.qxd 3/17/09 6:04 PM Page 941
Confirming Pages
Depending on what you are doing in your worksheet, one or more of these buttons mayappear grayed out. If you let your mouse hover over each of the buttons on the palette, youwill see a description of the button’s function.
The Math Palette
The Math Palette may automatically be displayed at the top of the screen. If not, just selectView, Toolbars, Math and it will appear. The buttons and their functions are describedbelow:
Calculator Boolean
Graph Programming
Vector and Matrix Greek Symbol
Evaluation Symbolic Keyword
Calculus
Click on one of these buttons to bring up the full palette. You can use the palettes to insertmath symbols and operations directly into your Mathcad worksheet.
ENTERING TEXT AND MATHEMATICAL OPERATIONS
Entering Text
To create a text region, click in a blank area of the screen to position the red crosshair cur-sor and type a double quote ["]. Now you can type whatever you like, just as in a wordprocessor. As the region grows, a black box appears around the text. The box has resizing“handles” on the right and bottom edges of the rectangle. Once you are done, click outsidethe text region to go back to inputting math operations. The black selection box disappearswhen you are no longer working in the text region.
Mathematical Operations
Type See on Screen
1+
Click somewhere in the upper-left-hand corner of the worksheet, and the red crosshairshould move to where you click. After you type the number 1 and the + sign you will seea little black box delimited by blue editing lines. In Mathcad this black box is called a
942 APPENDIX C GETTING STARTED WITH MATHCAD
cha01064_app_C.qxd 3/17/09 6:04 PM Page 942
Confirming Pages
placeholder. If you continue typing, whatever you type next will appear in the placeholder.For example, type 2 in the placeholder, then press the equals key ( = ) to see the result.
1 + 2 = 3
The basic arithmetic operators are listed below, along with their keystrokes and CalculatorPalette button equivalents.
Operation Keystroke Palette Example
Addition + + 2 + 2 = 4Subtraction – – 2 – 2 = 0Multiplication * × 2 · 2 = 4Division / ÷ = 1
Exponentiation ^ xY 22 = 4
Notice that operations in a Mathcad worksheet appear in familiar notation—multiplication as a dot, division with a fraction bar, exponents in a raised position, and soon. Calculations are computed internally to 15 places, but you can show fewer places in theanswer. To change the default display of numerical and symbolic results in a worksheet,click in a blank area of the worksheet. Then select Result from the Format menu to displaythe Result Format dialog box, and choose your default settings. Make sure that the buttonlabeled “Set as default” is checked, and click OK. If you just want to change the display ofa particular result, click on the equation, and follow the same steps.
Here are a few more examples that demonstrate Mathcad features.√1.837 · 103
100 + 35= 2.3142353232
Most standard engineering and mathematical functions are built in.
log(1347.2) · sin
(3
5· π
)= 2.976
Mathcad’s functions and operators easily handle complex numbers.
(2.3 + 4.7i)3 + e3−2i = −148.613 − 47.498i
MATHEMATICAL FUNCTIONS AND VARIABLES
The definition symbol := is used to define a function or variable in Mathcad. For example,click an empty worksheet to position the red crosshair in a blank area and type:
Type See on Screen
f(x):x^2
22
APPENDIX C GETTING STARTED WITH MATHCAD 943
cha01064_app_C.qxd 3/17/09 6:04 PM Page 943
Confirming Pages
The definition symbol is also located on the Evaluation selection of the Math Palette.When you change a definition function or variable, Mathcad immediately recalculates anynew values that depend on it. Once you’ve defined a function like f(x), you can use it in anumber of ways, for example:
f(x) := x2
Now you can insert a numerical value as the argument of f(x)
f(10) = 100
or define a variable and insert it in as the argument of f(x).
x := 3
f(x) = 9
You can even define another function in terms of f(x).
g(y) := f(y) + 6
g(x) = 15
Note that you can define a function using expressions you build up from the keyboard orfrom the palettes of math operators. You can also include any of Mathcad’s hundreds ofbuilt-in functions. To see a list of built-in functions along with brief descriptions, selectFunction from the Insert menu, or click on the f(x) button. You can also type the name ofany built-in function directly from the keyboard. The following are just a few examplesthat use some of Mathcad’s built-in functions.
Trig and Logs
ln(26) = 3.258 csc(45 ·.deg) = 1.414
Matrix Functions
identity(3) =[ 1 0 0
0 1 00 0 1
]
Probability Distributions
pnorm(2,0,1) = 0.977
Range Variables
In Mathcad you will find yourself wanting to work with a range of values for manyapplications—for example, to define a series of values to plot. Mathcad therefore providesthe range operator ( .. ), which can be entered by typing a semicolon ( ; ) at the keyboard.
944 APPENDIX C GETTING STARTED WITH MATHCAD
cha01064_app_C.qxd 3/17/09 6:04 PM Page 944
Confirming Pages
The first and last numbers establish the endpoints of the range variable, and the secondnumber sets the increment. For example,
Type See on Screen
z:0,0.5;2 z:=0,0.5..2
z =
Matrix Computations and Operations
To enter a matrix, click on the 3 × 3 matrix icon in the Matrix Palette (or choose Matrixfrom the Insert menu), choose the number of rows and columns, then fill in the placeholders.For example,
A :=[ 4 5 1
5 0 −12−7 2 8
]
To compute the inverse,
Type See on Screen
A^–1= A−1 =[ 0.074 −0.117 −0.184
0.135 0.12 0.1630.031 −0.132 −0.077
]
Mathcad has a comprehensive set of commands to perform various matrix operations. Forexample, to find the determinant, type a vertical bar ( | ) or use the button on the MatrixPalette.
|A| = 326
Units
Mathcad can also handle units. To see the built-in units, choose Unit from the Insert menu,or click on the appropriate toolbar button. Let’s start with a simple example. Open a newworksheet in Mathcad and type Mass:75kg[Enter]. You should see
Mass := 75 kg
APPENDIX C GETTING STARTED WITH MATHCAD 945
cha01064_app_C.qxd 3/17/09 6:04 PM Page 945
Confirming Pages
You could also have typed Mass:75*kg[Enter], multiplying the quantity times the unit.Now, enter g:9.8m/s^2 and you should have
g := 9.8m
s2
To see how Mathcad manages the units with calculations, enter Mass*g= and the resultshould be displayed with combined units as
Mass · g = 735 N
Mathcad uses the SI unit system by default, but you can change that from Tools,Worksheet Options, Unit System. Alternate systems include CGS, MKS, and US. Insteadof typing in the unit, you can also insert it from a list. Try the following. TypeTemp:273.16* then click on Insert, Unit. Select Temperature from the upper box andKelvin(K) from the lower box and click OK.
NUMERICAL METHODS FUNCTION
Mathcad has a number of special built-in functions that perform a variety of numericaloperations of particular interest to readers of this book. Examples of the development andapplication of these functions are described in detail in the text. Here we will provide abrief list of some of the more important functions just to give you an overview of thecapabilities. We illustrate their use in the relevant sections of this book.
Function Name Use
root Solves f(x) = 0polyroots Finds all roots of a polynomialfind Solves a system of nonlinear algebraic equationsminerr Returns a minimum error solution of a system of equationslsolve Solves a system of linear algebraic equationslinterp Linear interpolationcspline Cubic spline interpolationregress Polynomial regressiongenfit General nonlinear regressionfft Fourier transformifft Inverse Fourier transformrkfixed Solves a system of differential equations using a fixed step-size fourth-
order Runge-Kutta methodrkadapt Solves a system of differential equations using a variable step-size fourth-
order Runge-Kutta methodsbval Solves a two-point boundary value problemeigenvals Finds eigenvalueseigenvecs Finds eigenvectorsrelax Solves Poisson’s equation for a square domain
946 APPENDIX C GETTING STARTED WITH MATHCAD
cha01064_app_C.qxd 3/17/09 6:04 PM Page 946
Confirming Pages
MULTILINE PROCEDURES AND SUBPROGRAMS
The Programming Palette in Mathcad provides the capability for multiline procedures orsubprograms with standard control structures such as FOR and WHILE loops, branching,recursion, and more. Subprograms can be integrated with Mathcad’s worksheets and canoperate on scalars, vectors, arrays, and even arrays of arrays.
CREATING GRAPHS
Mathcad’s graphics capabilities are particularly important to engineering work. The firsttype of graph to know about is the QuickPlot. Start with a new worksheet and enter the fol-lowing formula. Leave the formula selected.
From the menu, select Insert, Graph, X-Y Plot. Click away from the graph and youshould see an automatic QuickPlot.
This plot can now be adjusted as desired. For example, click in the plot to select it andchange the x limits to 0 to 1. This should appear as
Then, click away from the plot, and the y axis will rescale automatically. Double-click onthe plot, and the Formatting Currently Selected X-Y Plot dialog box should appear.Check the boxes for X and Y gridlines and click OK. Click away from the plot, and youshould now have
e−x4 · (2 − x) − 1|
APPENDIX C GETTING STARTED WITH MATHCAD 947
cha01064_app_C.qxd 3/17/09 6:04 PM Page 947
Confirming Pages
Mathcad graphs one point for each value of the range variable x. This variable was cre-ated automatically in this case. The x-y points are joined by short straight-line segments.You can create your own range variables for the x axis.
Instead of using a formula for the y axis, you can use a function. To illustrate this, enterthe following function definition above your chart:
and change the y axis from the formula to f(x). You should have the same plot, but now itis in terms of the function f(x) instead of the direct formula.
A function can also be used for the x axis. Try another example below your currentgraph. Make the following definitions:
N := 100 � := 0, 2 · x
N.. 2 · x
x(�) := cos(�) y(�) := sin(�)
Insert a blank plot by pressing the @ key (Shift-2). Enter y(�) in the y-axis placeholderand x(�) in the x-axis placeholder and click away from the graph. This should yield theplot of a circle:
948 APPENDIX C GETTING STARTED WITH MATHCAD
cha01064_app_C.qxd 3/17/09 6:05 PM Page 948
Confirming Pages
It is also possible to plot the elements of a vector. Create the following vector of binomialprobabilities:
i :=0.. 10pi :=0.4i.0.6(10 � i)
and insert a graph with i on the x axis and pi on the y axis (you can use the [ key for the sub-script). Your graph should look like
Of course, you can plot one vector against another too, as long as they have the same num-ber of elements. The vectors could contain data instead a mathematical formula.
There are many axis settings that can be adjusted by double-clicking on the graph.These are self-explanatory to a great extent, and you can become familiar with themthrough practice.
There are many other styles of plots that can be generated by Mathcad. These includepolar, surface, contour, 3D bar, scatter, vector-field plots, and graphical animations.
SYMBOLIC MATHEMATICS
An intriguing and valuable feature of Mathcad is its capability to carry out symbolic mathmanipulations. The symbolic capabilities include
• Algebraic manipulations.• Calculus: differentiation and integration.• Solving algebraic equations and systems of such equations.
and, more advanced features
• Symbolic Fourier, Laplace, and z transforms.• Symbolic optimization.
We will review the first group here.Let’s start with a simple example of symbolic algebra. Enter the expression
(x + 2) · (x − 1) · (x + 4)
Expand the horizontal editing line to encompass the entire expression and then selectExpand from the Symbolics menu. You should see below:
x3 + 5 · x2 + 2 · x − 8
APPENDIX C GETTING STARTED WITH MATHCAD 949
cha01064_app_C.qxd 3/17/09 6:05 PM Page 949
Confirming Pages
Now, enter the polynomial x3 + 3x2 + 3x + 1 and follow the same procedure, except pickFactor from the Symbolics menu. You should have
x3 + 3 · x2 +3 · x + 1
(x + 1)3
Another way to carry out symbolic commands is with keystrokes. Enter the followingexpression:
Then press the Ctrl-Shift-. key combination and type simplify into the placeholder thatappears. You should get
x2 − 3 · x − 4
x − 4+ 2 · x − 5 simplify → 3 · x − 4
This is a different style of symbolic evaluation with the keyword retained and the resultappearing out to the right. You’ve seen the use of three important symbolic operators:
• expand Expand all powers and products of sums.• factor Factor into a product of simpler functions.• simplify Simplify by performing arithmetic, canceling common factors, using
identities, and simplifying powers.
Additional algebraic features include expansion to a series, partial fraction expansion, andextracting coefficients of a polynomial into a vector.
Now, let’s experiment with simple differentiation. Enter the expression
and leave the T selected (or click on it to select it). Then select Variable and Differentiatefrom the Symbolics menu. You should have the result
Another way to do this is to use the differentiation operator from the Calculus toolbar.Enter the following expression:
x2 − 3 · x − 4
x − 4+ 2 · x − 5|
950 APPENDIX C GETTING STARTED WITH MATHCAD
cha01064_app_C.qxd 3/17/09 6:05 PM Page 950
Confirming Pages
and then click on the button on the Evaluation toolbar (you can also press Ctrl-.).The result should be
Symbolic integrals can be determined either in indefinite or definite form. For an
indefinite integral, start by typing Ctrl-i or click on the button on the Calculus
toolbar. Then enter the desired function and differential followed by the button toproduce the following result:
Mathcad can also compute limits symbolically. The appropriate buttons are on theCalculus toolbar.
LEARNING MORE ABOUT MATHCAD
In this brief introduction we have covered only the Mathcad basics. Further help is avail-able right in the Mathcad software package in a variety of forms.
ToolTips
Let your mouse pointer hover over a palette or toolbar button for a few seconds. You willsee an explanatory tooltip displayed near the button: Look also on the message line at thebottom of the Mathcad application window for helpful tips and shortcuts.
Resource Center and QuickSheets
To help you get going fast and keep you learning, Mathcad comes complete with Quick-Sheets. These provide mathematical shortcuts for frequently used analyses—from graph-ing a function to solving simultaneous equations to the analysis of variance. There arenumerous QuickSheets. To open the QuickSheets section, choose QuickSheets from theHelp option on the Main menu.
Online Help
Online Help provides detailed, step-by-step instructions for using all of Mathcad’s fea-tures. Help is available at any time by simply going to the Help button on the Main menu.There you will find several links including the Mathcad website and Mathcad training.
APPENDIX C GETTING STARTED WITH MATHCAD 951
cha01064_app_C.qxd 3/17/09 6:05 PM Page 951
Top Related