getting started primers - pudn.comread.pudn.com/downloads173/ebook/804572/mathcad.pdf · getting...

47
GETTING STARTED PRIMERS Mathcad Toolbars Features of the Mathcad Window Before you move on to learning more about Mathcad’s features and especially about building math and text in your own Mathcad worksheets, take a moment to look at the Mathcad application window in front of you. The Main Menu This gateway to math, graphics, and symbolic functions provides the commands that handle the details of editing and managing your worksheets. Click on each of the menus to see the array of computational and formatting functionality available to you.

Upload: others

Post on 22-Mar-2020

5 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: GETTING STARTED PRIMERS - pudn.comread.pudn.com/downloads173/ebook/804572/MathCAD.pdf · GETTING STARTED PRIMERS Mathcad Toolbars Features of the Mathcad Window Before you move on

GETTING STARTED PRIMERS

Mathcad Toolbars

Features of the Mathcad Window

Before you move on to learning more about Mathcad’s features and especially about building math and text in your own Mathcad worksheets, take a moment to look at the Mathcad application window in front of you.

The Main Menu

This gateway to math, graphics, and symbolic functions provides the commands that handle the details of editing and managing your worksheets. Click on each of the menus to see the array of computational and formatting functionality available to you.

Page 2: GETTING STARTED PRIMERS - pudn.comread.pudn.com/downloads173/ebook/804572/MathCAD.pdf · GETTING STARTED PRIMERS Mathcad Toolbars Features of the Mathcad Window Before you move on

Click on one of these buttons in the bar to bring up the associated operator toolbar. You can then use the operator toolbar to insert math symbols right into your Mathcad worksheet. Hover over any button for a tooltip giving a brief description and keystrokes.

Calculus toolbar

Symbolic toolbarEvaluation toolbar

Greek toolbarMatrix toolbar

Programming toolbarGraph toolbar

Boolean toolbarCalculator toolbar

Choose Toolbars ⇒ Math from the View menu to see a tear-away bar whose buttons bring up toolbars of math operators. You can dock the bar under the main menu. If you let your mouse hover over each of the buttons on the bar in turn, you will see a tool tip telling you what menu each button brings up.

The Math Toolbar

Page 3: GETTING STARTED PRIMERS - pudn.comread.pudn.com/downloads173/ebook/804572/MathCAD.pdf · GETTING STARTED PRIMERS Mathcad Toolbars Features of the Mathcad Window Before you move on

The Standard Toolbar

is another tear-away button bar that provides shortcuts for many common tasks, from worksheet opening and file saving to spell checking to bringing up lists of built-in functions and units. Depending on what you’re doing in your worksheet, one or more of these buttons may appear grayed out. Hover over each button to see a tooltips with a brief description. You can customize the Standard toolbar, by right clicking on it and choosing customize, then pick additional buttons to add.

The Formatting Toolbar

The Formatting toolbar helps you easily format your text and math at the click of a button. If the Formatting Bar is not showing, select Toolbars⇒ Formatting from the View menu.

The Resources Toolbar

The Resources toolbar opens up Tutorials, QuickSheets, Reference Tables, and any Extension Packs or E-books you've installed.

Page 4: GETTING STARTED PRIMERS - pudn.comread.pudn.com/downloads173/ebook/804572/MathCAD.pdf · GETTING STARTED PRIMERS Mathcad Toolbars Features of the Mathcad Window Before you move on

The Controls Toolbar

The Controls toolbar can be used to insert Mathsoft custom controls, such as check boxes, radio buttons, sliders, and text boxes into your worksheets. See sample files under Using Mathcad with Other Applications in QuickSheets. Details about using the controls are in the Developer's Reference under the Help menu.

Finally, the status line

at the bottom of the Mathcad window gives you status alerts, tips, keyboard shortcuts, and other helpful information. It also lists the calculation status of your worksheet — “AUTO” means that the worksheet is in automatic mode, which means Mathcad will automatically recalculate math expressions if you make edits to your worksheet. You can turn off Automatic Calculation from Calculate in the Tools menu.

Other information that appears on the status line is whether you have the Caps Lock or Num Lock key depressed on your keyboard as well as the page number of the current screen you have selected by clicking in it.

The Resources Window Navigational Controls

These buttons let you browse among the sections of the Resources windows or Mathcad E-books. This Tutorial you are reading is in fact a Mathcad E-book! Just let your mouse hover over each of the navigational buttons at the top of this window to see a tooltip explaining what each one does.

Page 5: GETTING STARTED PRIMERS - pudn.comread.pudn.com/downloads173/ebook/804572/MathCAD.pdf · GETTING STARTED PRIMERS Mathcad Toolbars Features of the Mathcad Window Before you move on

Try it!

To resize a toolbar, you can drag on its borders to reshape it.

Try it!

Or de-select that toolbar under Toolbars in the View menu:

To close a toolbar, click the “X” in the upper right corner of the toolbar:

Try it!

To move the Calculator toolbar, move your cursor to the title bar at the top of the toolbar. Then, click on it and drag:

Try it!

To open the Calculator toolbar, select Toolbars ⇒ Calculator from the View menu:

All of toolbars in the main Worksheet window can be opened, closed, and moved around your workspace.

Opening, Closing, and Moving “Floating” Toolbars

The Address toolbar in the Resources window can be opened through this button. You can browse to files on the web or your computer, bookmark files, and reload files.

The Address Toolbar

Page 6: GETTING STARTED PRIMERS - pudn.comread.pudn.com/downloads173/ebook/804572/MathCAD.pdf · GETTING STARTED PRIMERS Mathcad Toolbars Features of the Mathcad Window Before you move on

Try it! ⇒

34

89

+3/4 [Spacebar] +8/9

Get this:Type this:

Entering an Expression

Practice

x2 2x+ 1+x^2 [Spacebar] +2x+1

Get this:Type this:

When you are in an exponent and you want to continue entering more of the expression, you use the Spacebar to move down from the exponent.

12

2+1/2 [Spacebar] +2

Get this:Type this:

Click to position the red crosshair to the right and type the following examples. Pay particular attention to what happens when you press the spacebar. The spacebar moves you out of the denominator of a fraction.

Building Math Expressions

GETTING STARTED PRIMERS

Page 7: GETTING STARTED PRIMERS - pudn.comread.pudn.com/downloads173/ebook/804572/MathCAD.pdf · GETTING STARTED PRIMERS Mathcad Toolbars Features of the Mathcad Window Before you move on

The exponent operator in Mathcad is called a sticky operator because your keystrokes will stick to the exponent position until you specifically move back to the baseline by pressing [Spacebar]. Other sticky operators include square roots, subscripts, and division.

x+6[Spacebar]*(x^3[Spacebar]-1) x 6+( ) x3 1−( )Get this:Type this:

Try it! ⇒

34

12

+

6

\3/4 [Spacebar] +1/2 [Spacebar][Spacebar][Spacebar] /6

Get this:Type this:

Try it! ⇒

a 1− a+\a–1 [Spacebar] [Spacebar] + a

Tip: You might need to press [Spacebar] two or more times to get to the right position in the expression before you can continue typing.

Get this:Type this:

Try it! ⇒

2x3 3x2− x+ 1−2x^3 [Spacebar] –3x^2 [Spacebar] +x–1

Get this:Type this:

Page 8: GETTING STARTED PRIMERS - pudn.comread.pudn.com/downloads173/ebook/804572/MathCAD.pdf · GETTING STARTED PRIMERS Mathcad Toolbars Features of the Mathcad Window Before you move on

Try it! ⇒

/x+4

x+2 [Spacebar] [Spacebar] [Spacebar]

x 1−( ) x 2+( )x 4+

x–1 [Spacebar] [Spacebar] *

Get this:Click and type this:

Try it! ⇒ Tip: If you select an operator, such as the mixed number operator, by clicking a button on the Calculator toolbar, you can use the Tab key to move from one placeholder to another.

123

58

+1 [Tab] 2 [Tab] 3 [Spacebar] +5/8

Get this:Click and type this:

Try it! ⇒

2πr2 4πr−rr^2 [Spacebar] – 42

Get this:Click and type this:

With your Calculator toolbar in view next to the Resources window and your Resources window active:

Remember that to use the Calculator toolbar in conjunction with the Resources window, you must move it over to the far left in your Worksheet window. Then bring your Resources window back up, which will make it the “active” window.

Using the Calculator Toolbar

Page 9: GETTING STARTED PRIMERS - pudn.comread.pudn.com/downloads173/ebook/804572/MathCAD.pdf · GETTING STARTED PRIMERS Mathcad Toolbars Features of the Mathcad Window Before you move on

Try it! ⇒

log 1000( ) log 10000( )− 1−=10000 =1000 [Spacebar] —

Get this:Click and type this:

Try it! ⇒

3 8 2=8 [Tab] 3 =

Tip: To get a result, you can press equal [=] no matter where the blue editing lines are in a numeric expression.

Get this:Click and type this:

Getting a Result

Page 10: GETTING STARTED PRIMERS - pudn.comread.pudn.com/downloads173/ebook/804572/MathCAD.pdf · GETTING STARTED PRIMERS Mathcad Toolbars Features of the Mathcad Window Before you move on

Tip: If you don’t know the abbreviation for a unit you are trying to use, select Unit from the Insert menu and browse for the units you want.

Try it! ⇒

dist 25m:=dist:25m

Get this:Type this:

Try it! ⇒

x 2:=x:2

Get this:Type this:

Defining a Single-Value Variable

Practice

Often you will want to define a value as a variable you can use in subsequent calculations. In this worksheet, you will practice defining and viewing single-value and range variables.

Defining Variables

GETTING STARTED PRIMERS

Page 11: GETTING STARTED PRIMERS - pudn.comread.pudn.com/downloads173/ebook/804572/MathCAD.pdf · GETTING STARTED PRIMERS Mathcad Toolbars Features of the Mathcad Window Before you move on

Try it! ⇒

g 1 10..:=1 [Tab] 10g:

Tip: This definition will give you a range of numbers between 1 and 10 at whole number increments.

Get this:Click or type this:

With your Matrix toolbar in view next to the Resources window and your Resources window active:

Remember that to use a toolbar in conjunction with the Resources window, you must move it over to the far left in your Worksheet window. Then bring your Resources window back up, which will make it the “active” window.

Before starting these exercises, display the Matrix toolbar on your desktop by selecting Toolbars ⇒ Matrix from the View menu.

Defining a Range Variable

on the Calculator toolbar, Mathcad displays :=. The assignment operator (colon equals) in Mathcad is used for definitions.

Notice that when you type the colon [:] key or press the assignment operator key

Tip: This definition uses a literal subscript, a common notation in science. You get a literal subscript by pressing the period (.) key after the variable name.

Try it! ⇒

v1 20mihr

:=v.1:20mi/hr

Get this:Type this:

Page 12: GETTING STARTED PRIMERS - pudn.comread.pudn.com/downloads173/ebook/804572/MathCAD.pdf · GETTING STARTED PRIMERS Mathcad Toolbars Features of the Mathcad Window Before you move on

Tip: This definition will give you a

range of numbers between 14

and 74

in increments of 14

.

Try it! ⇒

h14

12

,74

..:=h:1/4 [Spacebar] ,1/2 [Spacebar] ;7/4

Get this:Type this:

Try it! ⇒Tip: This definition will give you a range of numbers between 3.5 and 12.5 in increments of 0.5.

n 3.5 4.0, 12.5..:=n:3.5,4.0;12.5

Get this:Type this:

Try it! ⇒

Notice that when you type the semicolon character [;], it displays on the screen as two dots ( .. ) surrounded by placeholders. This is Mathcad’s range variable operator.

Tip: This definition will give you a range of numbers between 3.5 and 12.5 at whole number increments.

n 3.5 12.5..:=n:3.5;12.5

Get this:Type this:

Page 13: GETTING STARTED PRIMERS - pudn.comread.pudn.com/downloads173/ebook/804572/MathCAD.pdf · GETTING STARTED PRIMERS Mathcad Toolbars Features of the Mathcad Window Before you move on

Try it! ⇒ Tip: Units are always displayed in the base units of the worksheet. In this case, the result is given in SI, which is the default unit system in Mathcad. You can change the default units in Worksheet Options under the Tools menu.

xstart 13.716m=x.start=

Get this:Then, type this:

Try it! ⇒

xstart 45ft:=x.start:45ft

Get this:Type this:

Viewing a Definition

Try it! ⇒Tip: This definition will give you a range of numbers between –6 and 6 in increments of 0.1.

n 6− 5.9−, 6..:=n:–6,-5.9;6

Get this:Type this:

Page 14: GETTING STARTED PRIMERS - pudn.comread.pudn.com/downloads173/ebook/804572/MathCAD.pdf · GETTING STARTED PRIMERS Mathcad Toolbars Features of the Mathcad Window Before you move on

Try it! ⇒

time 1s 2.5s, 7s..:=time:1s,2.5s;7s

Get this:Type this:

Try it! ⇒

t2

2.5

3

3.5

4

4.5

5

5.5

6

6.5

7

7.5

8

=t=

Tip: Range variables are always displayed in a table.

Get this:Then, type this:

Try it! ⇒

t 2 2.5, 8..:=t:2,2.5;8

Get this:Type this:

If you want your range to be in increments other than 1 (the default), enter the next value in the range after the first one. For example, to create a range variable x that goes from 2 to 8 in increments of 0.5, type:

Page 15: GETTING STARTED PRIMERS - pudn.comread.pudn.com/downloads173/ebook/804572/MathCAD.pdf · GETTING STARTED PRIMERS Mathcad Toolbars Features of the Mathcad Window Before you move on

Then, type this: Get this: Tip: In a range variable, the difference between the starting point and the ending point should be evenly divisble by the increment you have chosen.

time= time1

2.5

4

5.5

7

s=

Try it! ⇒

To practice calculating results based on variables you have defined in the worksheet, continue to the second part of this primer, Calculating with Variables.

Page 16: GETTING STARTED PRIMERS - pudn.comread.pudn.com/downloads173/ebook/804572/MathCAD.pdf · GETTING STARTED PRIMERS Mathcad Toolbars Features of the Mathcad Window Before you move on

GETTING STARTED PRIMERS

Graphing — 2D Plots

Note: This worksheet is formatted in the landscape view. Either maximize your viewing window or use the horizontal scrollbar to view the entire page.

Graphs are easy to create and modify to your liking. You can create 2D graphs from functions or data sets. A 2D graph can contain up to sixteen plots all formatted differently. In this worksheet, you will learn how to plot functions and data in 2D Cartesian graphs. More information about parametric and polar plots is given in the In-Depth Tutorial on 2D Plots.

Definitions

plot – a single line, or trace, in a graph region.

graph – a set of axis with a scale into which plots may be placed.

argument – variable or expression used in a function or graph to define the region.

Page 17: GETTING STARTED PRIMERS - pudn.comread.pudn.com/downloads173/ebook/804572/MathCAD.pdf · GETTING STARTED PRIMERS Mathcad Toolbars Features of the Mathcad Window Before you move on

Example

log 1000( ) 3= The number 1000 is the argument to the log function.

10 0 10

50

100

x2

x

In this graph, x is the x-axis argument,

and x2 is the y-axis argument.

A placeholder is a small black rectangle in which you insert arguments for functions or graphs, in this case .

Page 18: GETTING STARTED PRIMERS - pudn.comread.pudn.com/downloads173/ebook/804572/MathCAD.pdf · GETTING STARTED PRIMERS Mathcad Toolbars Features of the Mathcad Window Before you move on

Practice

Creating a 2D QuickPlot from an Expression or a Function

1. Type: Get this:

10 5 0 5 10

40

20

20

40

60

4− x 3+

x

–4x+3

Without removing your cursor from this math region, select Graph ⇒ X–Y Plot from the Insert menu. Then, in the placeholder on the x-axis, where your cursor is, type:

x

Try it! ⇒

Tip: This is a plot of the equation more typically expressed as y 4− x 3+= . Notice that only the right-hand side of the equation is entered in the plot as an argument.

Page 19: GETTING STARTED PRIMERS - pudn.comread.pudn.com/downloads173/ebook/804572/MathCAD.pdf · GETTING STARTED PRIMERS Mathcad Toolbars Features of the Mathcad Window Before you move on

Get this:

10 5 0 5 10

30

20

10

9 2n−−

n

–|9–2n

Without removing your cursor from this math region, type:

[Shift]2

Then, in the placeholder on the x-axis, where your cursor is, type:

n

Try it! ⇒

Tip: When you are in a math region and you press the key for a single vertical bar, as above, you actually get two absolute value bars and a blank placeholder to fill in.

Tip: This type of plot is known as a QuickPlot because the program picks a range over which to plot the function you enter. The range is from –10 to 10 at 0.1 increments.

Page 20: GETTING STARTED PRIMERS - pudn.comread.pudn.com/downloads173/ebook/804572/MathCAD.pdf · GETTING STARTED PRIMERS Mathcad Toolbars Features of the Mathcad Window Before you move on

3. To define a function, type: Get this:

f(x):3x^2 [Spacebar] +1 f x( ) 3x2 1+:=

Then, type:

10 5 0 5 10

400

200

200

400

f x( )

f x( )−

x

f(x),–f(x)

Without removing your cursor from this math region, select Graph ⇒ X–Y Plot from the Insert menu or type [Shift]2. Then, in the placeholder on the x-axis, where your cursor is, type:

x

Try it! ⇒

Tip: You can plot up to 16 plots in a single graph region. This example shows two plots, the function, f(x), and its negative.

Page 21: GETTING STARTED PRIMERS - pudn.comread.pudn.com/downloads173/ebook/804572/MathCAD.pdf · GETTING STARTED PRIMERS Mathcad Toolbars Features of the Mathcad Window Before you move on

Adding a Plot to an Existing Graph

Click the expression in the y-axis of the plot below. Then, click the [Spacebar] until the entire expression is selected:

Get this:

2 1 0 1 2

5

5

10

15

4− x 3+

x

2 1 0 1 2

10

5

5

10

15

4− x 3+

4− x 2+

4− x 1+

x

To enter two more expressions in the plot, type: Tip: To add more plots to an existing graph, simply enter expressions in the y-axis separated by commas. Be sure all the expressions contain the same independent variable. In this case, the independent variable is x. If not, then you must add the additional independent variables on the x-axis separated by commas.

,–4x+2,–4x+1

Page 22: GETTING STARTED PRIMERS - pudn.comread.pudn.com/downloads173/ebook/804572/MathCAD.pdf · GETTING STARTED PRIMERS Mathcad Toolbars Features of the Mathcad Window Before you move on

Changing the Axis Limits of a Graph

Click the graph below and then click the left limit of the x-axis (displayed as –10):

Get this:

10 5 0 5 10

400

300

200

100

100

4− x2 3+

x

2 1 0 1 2

15

10

5

5

4− x2 3+

x

Start typing in this limit placeholder and enter a new lower limit of –2.

Tip: You do not need to delete a default axis limit. You can simply start typing over it to replace it.

Likewise, enter a new upper limit of 2 for the x-axis.

Page 23: GETTING STARTED PRIMERS - pudn.comread.pudn.com/downloads173/ebook/804572/MathCAD.pdf · GETTING STARTED PRIMERS Mathcad Toolbars Features of the Mathcad Window Before you move on

Click the graph below and then click the lower limit of the y-axis (displayed as –397):

Get this:

10 5 0 5 10

400

300

200

100

100

4− x2 3+

x

10 5 0 5 10

20

104− x2 3+

x

Start typing in this limit placeholder and enter a new lower limit of –20.

Tip: Changing the x-axis limits in a QuickPlot automatically rescales the y-axis limits to match, much like zooming in on a plot. However, changing the y-axis limits in a QuickPlot does not change the x-axis limits.

Likewise, enter a new upper limit of 5 for the y-axis.

Page 24: GETTING STARTED PRIMERS - pudn.comread.pudn.com/downloads173/ebook/804572/MathCAD.pdf · GETTING STARTED PRIMERS Mathcad Toolbars Features of the Mathcad Window Before you move on

Formatting Traces in a 2D Graph

Double-click the graph below to bring up the X-Y Plot Formatting dialog box:

Get this:

2 1 0 1 2

20

15

10

5

5

4− x2 3+

4− x2

x

1. Click the Traces Tab and set the trace 1 color to Black and the trace 1 weight to 2. Click Apply to see the changes without dismissing the dialog box.

Tip: The best way to learn about the formatting options available for 2D graphs is to change the various settings in this dialog and see the effect on the graph.2. Set the trace 2 line style to “dash” and the trace 2

weight to 2. Click Apply.

3. On the X-Y Axes tab, deselect “Grid Lines” for both axes. Click OK.

Page 25: GETTING STARTED PRIMERS - pudn.comread.pudn.com/downloads173/ebook/804572/MathCAD.pdf · GETTING STARTED PRIMERS Mathcad Toolbars Features of the Mathcad Window Before you move on

1. Get this: 2 and 3. Get this:

2 1 0 1 2

20

15

10

5

5

4− x2 3+

4− x2

x

2 1 0 1 2

20

15

10

5

5

4− x2 3+

4− x2

x

Page 26: GETTING STARTED PRIMERS - pudn.comread.pudn.com/downloads173/ebook/804572/MathCAD.pdf · GETTING STARTED PRIMERS Mathcad Toolbars Features of the Mathcad Window Before you move on

Creating a 2D Plot Using a Range Variable for the Independent Variable

To define a function and range variable, type: Get this:

g(n):|4–2n and n:–3,–2.5;7 g n( ) 4 2n−:= n 3− 2.5−, 7..:=

Below these two definitions, type:

5 0 5 10

5

10

g n( )

n

[Shift]2 n [Tab][Tab] g(n)

Try it! ⇒

Tip: With a range variable, you can control the range of values at which the function in the graph is evaluated.

Tip: You can use the [Tab] key to jump from placeholder to placeholder in a 2D graph region, or you can use your mouse to click on the placeholders you want to fill in.

Page 27: GETTING STARTED PRIMERS - pudn.comread.pudn.com/downloads173/ebook/804572/MathCAD.pdf · GETTING STARTED PRIMERS Mathcad Toolbars Features of the Mathcad Window Before you move on

Creating a 2D Plot from a Data Set

To define two vectors to contain your x and y data points, type:

Get this:

xdata: [Ctrl]m and ydata: [Ctrl]m

For each vector, enter 10 rows and 1 column and click OK. Then enter the following set of data into the vector’s placeholders:

For x: 2, 4, 5, 7, 8, 9, 11, 13, 14, 15xdata

2

4

5

7

8

9

11

13

14

15

:= ydata

3

6

9

13

14

17

22

25

26

28

:=For y: 3, 6, 9, 13, 14, 17, 22, 25, 26, 28

Try it! ⇒

Tip: To quickly enter values in a vector, use the [Tab] key after each entry to get to the next placeholder.

Page 28: GETTING STARTED PRIMERS - pudn.comread.pudn.com/downloads173/ebook/804572/MathCAD.pdf · GETTING STARTED PRIMERS Mathcad Toolbars Features of the Mathcad Window Before you move on

To insert a graph region, type: Get this:

0 5 10 15

10

20

30

ydata

xdata

[Shift]2

In the x-axis placeholder, enter “xdata” and in the y-axis placeholder, enter “ydata”, and press [Enter].

Try it! ⇒

Tip: The default formatting for a graph is a line, but you can format any plot as points, bars, etc.

Page 29: GETTING STARTED PRIMERS - pudn.comread.pudn.com/downloads173/ebook/804572/MathCAD.pdf · GETTING STARTED PRIMERS Mathcad Toolbars Features of the Mathcad Window Before you move on

To format the plot as points, double-click your graph above to bring up the X-Y Plot Formatting dialog box. Then, click the Traces tab and set the trace 1 type to points and the Symbol to box:

Get this:

0 5 10 15

10

20

30

ydata

xdata

To learn about 3D graphing, continue to the second part of this primer, Graphing — 3D Plots.

Page 30: GETTING STARTED PRIMERS - pudn.comread.pudn.com/downloads173/ebook/804572/MathCAD.pdf · GETTING STARTED PRIMERS Mathcad Toolbars Features of the Mathcad Window Before you move on

FEATURES IN-DEPTH

Vectors and Matrices

In two dimensions, there are two types of arrays: vectors and matrices. A vector is an array of just one row or column of numbers. A matrix is an array with two or more rows and columns. In this tutorial, you will learn how to create and work with vectors and matrices.

If you want to learn about using arrays to store data for import and export, see Handling Data.

Creating a Vector or Matrix

Subscripts and Superscripts

Creating a Vector or Matrix Using Range Variables

Calculating with Vectors and Matrices

Transpose, Inverse, Determinant

Array Functions

Creating a Vector or Matrix

To create a vector or matrix of values defined element by element:

1. Press [Ctrl]m or click the Matrix or Vector button on the Matrix toolbar.

2. Enter the dimensions of the vector or matrix you want and click OK or Insert.

3. Fill in each empty placeholder with a value. Use the Tab key to move from placeholder to placeholder.

feat_03.mcd 1 27.10.2004

Page 31: GETTING STARTED PRIMERS - pudn.comread.pudn.com/downloads173/ebook/804572/MathCAD.pdf · GETTING STARTED PRIMERS Mathcad Toolbars Features of the Mathcad Window Before you move on

This last example contains strings, or words, and numeric values. It is helpful to be able to mix data in an array, particularly if you are copying and pasting that data from another application. In fact, data copied and pasted into matrices from tabular applications, such as Excel, or an ASCII worksheet that contains rows and columns, will preserve data characteristics, including text, numerics, complex numbers, or empty cells. For example, if you copy the following cells from Excel:

2 rows, 3 columns"dog"

1

"cat"

3

"mouse"

2

3 rows, 1 column

5i

1 2i+

6

1 row, 3 columns3 5.2 10.1( )

Here are several arrays with various types of data in them:

1 [Tab] 2 [Tab]

You see this:Type this:

After you click OK or Insert:

[Ctrl]m

You see this:Type this:

feat_03.mcd 2 27.10.2004

Page 32: GETTING STARTED PRIMERS - pudn.comread.pudn.com/downloads173/ebook/804572/MathCAD.pdf · GETTING STARTED PRIMERS Mathcad Toolbars Features of the Mathcad Window Before you move on

Placing the cursor in a blank region of the worksheet and choosing Edit ⇒ Paste Special... As “Unformatted Text As Number,” results in:

"temp"

98

98.2

98.6

98.7

"time"

1

3

4

6

"phase"

0.2i

0.2 0.5i+

0.3 0.04i+

0.6

"Amplitude"

700

9 103×

1.1 104×

1.6 104×

Try to create any of these arrays yourself, below. To enter a string, type " in the placeholder and then enter the text. From within the string quotes, you cannot press [Tab] to move to the next placeholder.

Try it!

You can also assign a variable to a vector or matrix in order to use it later in the worksheet for calculations.

If you define x to be a 1 x 3 vector and y to be a 3 x 1 vector, then you can use those definitions to compute the dot product of the two vectors:

x 2 7 10( ):= y

4

1

5

:=

x y 65=

feat_03.mcd 3 27.10.2004

Page 33: GETTING STARTED PRIMERS - pudn.comread.pudn.com/downloads173/ebook/804572/MathCAD.pdf · GETTING STARTED PRIMERS Mathcad Toolbars Features of the Mathcad Window Before you move on

M

7

5

56

6

5

8

5

5

9

:=

Here is a 3 x 3 matrix:

vec1 56=

Likewise, if you type “vec[1=” you will get the second element of the vector:

vec0 7=

If you type “vec[0=” you will get the first element of the vector:

vec

7

56

5

:=

Here is a vector with three elements:

By default in Mathcad the first element has the index 0. This means that the first row or column of an array is always referred to with the subscript 0.

To type an array subscript, type“[” or click the Subscript button, shown at the right, on the Matrix toolbar.

Am n,

A subscript on a matrix refers to an element in the mth row and nth column in the matrix.

Read, “V sub n”.Vn

Subscripts are the numbers or variables written below an array variable. A subscript on a vector refers to the nth element of a vector.

Subscripts

feat_03.mcd 4 27.10.2004

Page 34: GETTING STARTED PRIMERS - pudn.comread.pudn.com/downloads173/ebook/804572/MathCAD.pdf · GETTING STARTED PRIMERS Mathcad Toolbars Features of the Mathcad Window Before you move on

If you type “M[0,1=” you will get the element in the first row and second column:

M0 1, 6=

Superscripts

The superscript of an array refers to a column of the array. For example, if you want to reference an entire column of a particular array, type “[Ctrl]6” to insert a superscript or click the Matrix Column button on the Matrix toolbar.

Here is a 3 x 5 array, P:

P

7

1

5

6

7

2

5

89

6

4

50

7

3

67

8

:=

If you type “P[Ctrl]6 0 =”, you will get the first column of the matrix:

P 0⟨ ⟩7

1

5

=

Creating a Vector or Matrix Using Range Variables

Another way to define vectors and matrices is by creating a definition dependent on a range variable or variables, which serves as the indices for the array.

1. Define a range variable from 1 to n, where n is the number of rows you want in the vector. For a matrix, define a second range variable from 1 to m, where m is the number of columns.

2. Now, define your array, A. On the left side of your array definition, type “A[n” for a vector and “A[n,m” for a matrix. Remember that the open bracket is the keystroke for the array subscript.

3. On the right side of your array definition, type an expression in terms of n for a vector and n and m for a matrix.

4. To view the array you have defined, below the definition type “A=”.

feat_03.mcd 5 27.10.2004

Page 35: GETTING STARTED PRIMERS - pudn.comread.pudn.com/downloads173/ebook/804572/MathCAD.pdf · GETTING STARTED PRIMERS Mathcad Toolbars Features of the Mathcad Window Before you move on

First, define a range variable, i, by typing “i:0;2”.

i 0 2..:=

Now, type “B[i:i+4”. This will assign to each element in the vector B the row number plus 4, i.e. the values 4, 5, and 6.

Bi i 4+:= B

4

5

6

=

Note: In Mathcad enter all vectors as column vectors, that is vectors that go down, not across.

Calculating with Vectors and Matrices

Mathematics has some simple rules for how to calculate using arrays. Generally, you can apply the same operations to arrays as you would to simple variables. There are no special instructions for calculating with vectors or matrices in Mathcad. Simply follow the rules of mathematics.

Scalar Multiplication

If you multiply a vector by a scalar (single number), the result is a vector in which each component of the original vector has been multiplied by the scalar.

A

2

4

5

6

:= 2A

4

8

10

12

=

feat_03.mcd 6 27.10.2004

Page 36: GETTING STARTED PRIMERS - pudn.comread.pudn.com/downloads173/ebook/804572/MathCAD.pdf · GETTING STARTED PRIMERS Mathcad Toolbars Features of the Mathcad Window Before you move on

The rule for matrix addition is that when you add two matrices together, the resultant matrix is another matrix, the elements of which are the sums of those same elements of the two original matrices. Just as with vectors, matrix addition is only defined for matrices of the same size.

S T+6

8

10

12

=

Now add them together:

T5

6

7

8

:=S1

2

3

4

:=

Here are two 2 x 2 matrices, S and T:Adding or Subtracting Matrices

A B+ =A B+This doesn’t:

A C+

10

11

11

11

=This works:

C

8

7

6

5

:=B

4

5

6

=A

2

4

5

6

=

You may add or subtract two vectors whenever they are the same length. Adding or Subtracting Vectors

feat_03.mcd 7 27.10.2004

Page 37: GETTING STARTED PRIMERS - pudn.comread.pudn.com/downloads173/ebook/804572/MathCAD.pdf · GETTING STARTED PRIMERS Mathcad Toolbars Features of the Mathcad Window Before you move on

Transpose, Inverse, Determinant

Here is a 3 x 3 matrix, C:

C

5

1

2

4

3

4

86

5

2

:=

Matrix Transpose

To calculate the transpose of the matrix, type “C[Ctrl]1”.

CT

5

4

86

1

3

5

2

4

2

=

To calculate the inverse of the matrix, type “C^-1”.

C 1−

0.067

0.038−

9.524 10 3−×

1.6−

0.771

0.057

1.133

0.29−

0.052−

=

To calculate the determinant of the matrix, type “C^|”.

C 210−=

feat_03.mcd 8 27.10.2004

Page 38: GETTING STARTED PRIMERS - pudn.comread.pudn.com/downloads173/ebook/804572/MathCAD.pdf · GETTING STARTED PRIMERS Mathcad Toolbars Features of the Mathcad Window Before you move on

combines two matrices by stacking A above B

stack A B,( )

augment A B,( ) combines two matrices together by placing them side by side

gives the n x n identity matrixidentity n( )

rearranges the rows of a matrix A so that the nth column is in ascending order

csort A n,( )

sorts a vector in ascending ordersort v( )

cols A( )

the number of rows or columns in Arows A( )

min A( )

the maximum or minimum of the elements in a vector or matrix

max A( )

Mathcad includes a variety of functions for working with vectors and matrices. A few are listed below. For a full list, choose Function from the Insert menu and click on the Vector and Matrix category.

Array Functions

feat_03.mcd 9 27.10.2004

Page 39: GETTING STARTED PRIMERS - pudn.comread.pudn.com/downloads173/ebook/804572/MathCAD.pdf · GETTING STARTED PRIMERS Mathcad Toolbars Features of the Mathcad Window Before you move on

This method also works for right- and left-sided limits; the buttons for those operators are also located on the Calculus toolbar. Also, note that if you want to find a limit to positive or negative infinity, be sure to use the infinity symbol located on the Calculus toolbar or type “[Ctrl][Shift]z”.

1. On the Calculus toolbar, click the two-sided limit button or type “[Ctrl]l” to get the two-sided limit operator. (Choose Calculus from the View ⇒ Toolbars menu.)

2. Fill in the three placeholders of the limit operator.3. On the Symbolics toolbar, click the symbolic equal sign (→) or type

“[Ctrl].” to get a result.

Limits may only be evaluated algebraically in Mathcad. To find a limit:Limits

Higher Order Derivatives

Indefinite Integrals

Integrals

Derivatives

Sums and Iterated Products

Limits

Here are the topics covered in this tutorial:

You can use Mathcad to perform basic calculus functions both numerically and algebraically. In this tutorial, you will learn various methods for finding limits, sums, derivatives, and integrals.

Calculus in Mathcad

FEATURES IN-DEPTH

feat_08.mcd 1 27.10.2004

Page 40: GETTING STARTED PRIMERS - pudn.comread.pudn.com/downloads173/ebook/804572/MathCAD.pdf · GETTING STARTED PRIMERS Mathcad Toolbars Features of the Mathcad Window Before you move on

0x

sin x( )x

lim−→

Try this one yourself. Select the entire expression, below, and choose Simplify from the Symbolics menu:

undefined

simplifies to

1x

x2

x 1−lim→

Here is an example of a limit expression evaluated using the Simplify command on the Symbolics menu:

Note: Though the results of limit operations are often numeric, this operation may only be performed symbolically using the symbolic equal sign in Mathcad. Alternatively, you can use the Simplify command on the Symbolics menu.

left-sided limit2x

xx 2−

lim−→

Try this one yourself. Click anywhere in the expression and type “[Ctrl].”:

right-sided limit2x

xx 2−

lim+→

∞→

two-sided limit∞x

1x

lim→

0→

Here are two examples of limits evaluated algebraically:

feat_08.mcd 2 27.10.2004

Page 41: GETTING STARTED PRIMERS - pudn.comread.pudn.com/downloads173/ebook/804572/MathCAD.pdf · GETTING STARTED PRIMERS Mathcad Toolbars Features of the Mathcad Window Before you move on

Note: As you can see, it is also helpful to use the symbolic equal sign to get exact solutions, where the numeric equal sign gives you a decimal solution. If you are calculating numeric results involving fractions, roots, or π, consider using the symbolic equal sign.

exact

1

4

n

n

2∑=

approximate

1

4

n

n

2∑=

Try these examples yourself. Click anywhere in the first expression and press =; click anywhere in the second expression and type “[Ctrl].”:

symbolic

1

k

n

n2∑=

13

k 1+( )3 12

k 1+( )2−16

k+16

+→

numeric1

3

n

n2∑=

14→

Here are two examples of sums:

1. On the Calculus toolbar, click the summation button or type “[Ctrl][Shift]4” to get the summation operator.

2. Fill in the four placeholders of the summation operator.3. For numeric evaluation, press = to get a result.4. For symbolic evaluation, on the Symbolic toolbar, click the symbolic

equal sign (→) or type “[Ctrl].” to get a result.

Sums and iterated products may be evaluated numerically and symbolically in Mathcad. In general, if you have a sum that contains a variable in either the starting or ending value of its range, then you must evaluate the sum symbolically. To find a sum:

Sums and Iterated Products

feat_08.mcd 3 27.10.2004

Page 42: GETTING STARTED PRIMERS - pudn.comread.pudn.com/downloads173/ebook/804572/MathCAD.pdf · GETTING STARTED PRIMERS Mathcad Toolbars Features of the Mathcad Window Before you move on

Here are two examples of iterated products. To get the iterated product operator, click its button on the Calculus toolbar or type “[Ctrl][Shift]3” :

1

5

n

n2

n 1+∏=

20= numeric, using the = sign

1

3

n

1n∏

=

16

→ exact numeric, using the symbolic equal sign

Derivatives

To find a derivative:1. Define the variable value at which you want to differentiate the

expression.2. Type “?” or click the Derivative button on the Calculus toolbar to get

the derivative operator. (Choose Calculus from the View ⇒ Toolbars menu.)

3. Fill in the two placeholders of the derivative operator.4. For numeric evaluation, press = to get a result.5. For symbolic evaluation, on the Symbolic toolbar, click the symbolic

equal sign (→) or type “[Ctrl].” to get a result.

Note: As with any operation that can be carried out using the symbolic equal sign, you can also use the Simplify command on the Symbolics menu. Also, it is often necessary to use either the symbolic equal sign or the Simplify command to find an exact numeric result, particular if the result contains fractions, roots, or constants such as π or e.

To find the derivative of x2 at x = 4, first define x so you get the derivative at a that particular point.

x 4:=

feat_08.mcd 4 27.10.2004

Page 43: GETTING STARTED PRIMERS - pudn.comread.pudn.com/downloads173/ebook/804572/MathCAD.pdf · GETTING STARTED PRIMERS Mathcad Toolbars Features of the Mathcad Window Before you move on

Numeric: In this case, the numeric result is an estimate to three digits of precision.z

tan z( )z

dd

0.318=3.

zsin z( )d

d1−=

Numeric: In this case, even though the value at which the expression is differentiated is π, the result is an integer.

z π:=2.

Symbolic: The variable x was already defined, above, as having the value 4. So, a different variable of differentiation was used here in order to get an expression in terms of the variable. Alternatively, you can “reset” the variable by defining x equal to x.

zsin z( )d

dcos z( )→1.

Here are other examples of derivatives:

xx2d

d8=

Press = .

xx2d

d

Click on the placeholder to the right of the derivative and type x2. Click on the bottom placeholder and type x.

dd

Then insert the derivative operator by pressing ?. You see the derivative operator with placeholders:

feat_08.mcd 5 27.10.2004

Page 44: GETTING STARTED PRIMERS - pudn.comread.pudn.com/downloads173/ebook/804572/MathCAD.pdf · GETTING STARTED PRIMERS Mathcad Toolbars Features of the Mathcad Window Before you move on

4.z

tan z( )z

dd

1 tan π( )2+

π

tan π( )π

2−→ Exact Numeric: This may look

like a symbolic expression, but it is in fact numeric. If you copy and paste this result into its own region and again evaluate it with the symbolic equal sign, you’ll see a further simplified result.

1 tan π( )2+( )

π

tan π( )π

2−

1

π→

Try this one yourself. Select the entire expression below and choose Simplify from the Symbolics menu:

w

1w

dd

Note: When you evaluate an expression using the Simplify command, you see comments between the expression and the result. To change the style of this result, choose Worksheet Options from the Tools menu and select from among the options on the Calculation tab.

Integrals

To find an integral:1. Type “&” ([Shift]7) or click the Definite Integral button on the

Calculus toolbar to get the integral sign. 2. Fill in the placeholders of the integral operator, the upper limit, the lower

limit, the function, and the variable over which you want to integrate.3. For numeric evaluation, press = to get a result.4. For symbolic evaluation, on the Symbolic toolbar, click the symbolic

equal sign (→) or type “[Ctrl].” to get a result.

Note: To get a symbolic result, you can also use the Simplify command on the Symbolics menu; or, to get an exact numeric result use the symbolic equal sign.

feat_08.mcd 6 27.10.2004

Page 45: GETTING STARTED PRIMERS - pudn.comread.pudn.com/downloads173/ebook/804572/MathCAD.pdf · GETTING STARTED PRIMERS Mathcad Toolbars Features of the Mathcad Window Before you move on

Exact Numeric: Here is the same calculation evaluated using the symbolic equal sign.

1

3

x13

x3⌠⌡

d203

→2.

Numeric: In this case, the numeric result is an estimate to three digits of precision.

1

3

x13

x3⌠⌡

d 6.667=1.

Here are other examples of definite integrals:

0

9

xx2⌠⌡

d 243=

Press = .

0

9

xx2⌠⌡

d

Note: You can also use the [Tab] key to jump from placeholder to placeholder.

Click on the placeholder to the right of the integral symbol and type x2

. Click on the placeholder to the right of the “d” and type x. Fill in the lower and upper placeholders with 0 and 9, respectively.

⌠⌡

d

To find the integral of x2 from 0 to 9, first insert the definite integral operator by typing “&”. You see the integral operator with placeholders:

feat_08.mcd 7 27.10.2004

Page 46: GETTING STARTED PRIMERS - pudn.comread.pudn.com/downloads173/ebook/804572/MathCAD.pdf · GETTING STARTED PRIMERS Mathcad Toolbars Features of the Mathcad Window Before you move on

Try this one yourself. Click on the integral expression below and type “[Ctrl].” to get a result:

1

n

x1x

⌠⌡

d Symbolic: When one of the limits of integration is a variable, or if there is a variable other than the variable of integration in the function, use the symbolic equal sign to evaluate the integral.

Indefinite Integrals

For indefinite integrals, follow the steps outlined earlier for definite integrals, but type “[Ctrl]i” or click the Indefinite Integral button on the Calculus toolbar to get the indefinite integral operator. Indefinite integrals are always evaluated symbolically. So, either use the Simplify command on the Symbolics menu or the symbolic equal sign.

An indefinite integral evaluated using the Simplify command:

xx2 ex⌠⌡

d

simplifies to

x2 ex 2x ex− 2ex+

Try this one yourself. Click on the integral expression below and type “[Ctrl].” to get a result:

xx2 ex⌠⌡

d

Note: Mathcad never puts in the integration constant C. This is because Mathcad gives you a single solution rather than a formula for all the antiderivatives in the solution set. Be sure to remember to add the C if that’s how your solution must appear.

feat_08.mcd 8 27.10.2004

Page 47: GETTING STARTED PRIMERS - pudn.comread.pudn.com/downloads173/ebook/804572/MathCAD.pdf · GETTING STARTED PRIMERS Mathcad Toolbars Features of the Mathcad Window Before you move on

Higher Order Derivatives

For higher order derivatives, follow the steps outlined earlier for first derivatives, but type “[Ctrl][Shift]/” or click the Nth Derivative button on the Calculus toolbar. Fill in the order of the derivative in the superscript placeholder of the denominator; Mathcad copies it automatically to the placeholder in the numerator.

Higher order derivatives may be evaluated numerically or symbolically.

Higher order derivative evaluated numerically:

t 1:=

3t1 t+( )5d

d

3240=

Higher order derivative evaluated symbolically:

x x:= Note: Here we “reset” the variable of differentiation to itself. If we did not do this, the derivative operation would evaluate the expression using the last defined value of x, which is x = 4, near the top of the worksheet.

3x1 x+( )5d

d

360 1 x+( )2→

feat_08.mcd 9 27.10.2004