0% found this document useful (0 votes)
74 views12 pages

Using Mathcad To Plot Graph1 PDF

1. There are four types of equal signs in Mathcad used for different purposes such as defining functions or evaluating expressions. 2. To graph functions, they must first be defined using := and then selected using the 2-D plot icon. Functions can be graphed individually or together on the same axes. 3. Range variables can be used to define specific ranges for independent variables, for example when graphing parametric equations or solving differential equations numerically over a range of values.

Uploaded by

FickriJokyalit
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
0% found this document useful (0 votes)
74 views12 pages

Using Mathcad To Plot Graph1 PDF

1. There are four types of equal signs in Mathcad used for different purposes such as defining functions or evaluating expressions. 2. To graph functions, they must first be defined using := and then selected using the 2-D plot icon. Functions can be graphed individually or together on the same axes. 3. Range variables can be used to define specific ranges for independent variables, for example when graphing parametric equations or solving differential equations numerically over a range of values.

Uploaded by

FickriJokyalit
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 12

Introduction and Basics

1 Text Regions

By Clicking on the Worksheet you are in an active Math Region

In order to insert a text region either go to INSERT -TEXT REGION or simply

start typing --the first time you hit the space bar you will be thrown into a text region .

You can copy from a Math region into a text region and the math operator stays active.

1 1
 2  2
For example  x d x has been added. To evaluate highlight and hit equal.  x d x  0.333
 
0 0

2. Equal signs There are 4 types of equal signs used in Mathcad, they can be found on the
calculator and evaluation menus:

a.  used for defining functions, range variables, vectors etc.

b. = used for evaluating expressions

c. Boolean Equal which appears as Used in solving equations

d.  used for symbolic results

3. Mathcad reads left to right and up to down

To define a function type f (x)  in a math region .

For Example

2
f ( x)  x

To evaluate this expression say f(2) simply type f(2) and hit the =

f (2)  4

If we redefine f(x) it does not affect anything above it

3
f ( x)  x

f (2)  8
Note if we try to evaluate a function above or to the left of it's definition we will get an error message in read
g(2) 
2
g(2)  g( x)  x

2
Correctly g( x)  x g(2)  4

2
or: g( x)  x

g(2)  4

4. Basic Graphs in Mathcad

a To create a graph first define the function to be graphed

b.Choose the 2-D plot Icon in the graphing menu:

For functions of one variable you do not need to define range variables,however there are occasions when you will
want to define a range variable and we will discuss this later.
Also there is no syntax to learn, functions are typed in just the way you'd write them.

Example 1

3 2
As always start by defining the function to be graphed y( x)  x  3 x  2 x Note the := in the evaluation
menu is always used for defining functions.

On the graph window are place holders for the independent variable and the function to be graphed.
Graph before formatting. Note the ranges on the x and y axes is set by the computer. With the default
domain being [-10,-10] and the range adjusted by Mathcad automatically

3
110

0
y ( x)
3
 110

3
 210
 10 5 0 5 10
x
The graphing window has been reset to -5 to 5 on the x axis and -10 to 10 on the y axis.

In general we list the window [a,b]x{c,d] where [a.b] is the interval in the x direction and [c,d] is the
interval in the y direction. This by the way is known as a Cartesian Product.

10

y ( x) 0

5

 10
4 2 0 2 4
x

To format the graph right click in the graphing window and choose FORMAT.

For example below on the x-y Axes Tab I changed the axes style from boxed to crossed.

10

y ( x)
4 2 0 2 4
5

 10

If you click on the traces tab you can choose line type ,color etc. You may want to experiment with the various
possibilities.

Excercise 1 Graph x4 - 4x3 formatted as follows:

1. graphing window set -5 to 5 on the x axis,-30 to 30 on the y axis.


2. axes style changed from boxed to crossed
Graphing more than one function

If we want to graph more than one function on the same graph, as always start by defining the 2 functions to be graphed

2
f ( x)  x g(x)  x

Type in the first function on the vertical,highlight it and hit the comma. A box will appear to enter a second
function. If you want a third function repeat the process.
Mathcad can graph up to 15 functions on a single graph. Suppose we want to graph g(x) =|x| on the same
graph as f(x) = x2 on the grid [-2,2] x [-2,2].

2
f ( x)  x g(x)  x

f ( x)

2
2 x 2

1
f ( x)

g( x) 2 1 0 1 2
1

2

x
Note Mathcad color codes the function. You can change g(x) to a solid curve by going to the FORMAT window
choose TRACES --then TRACE 2 and change line from dot to solid. Notice you cam change color,line type, etc
in this window. Note the number of the trace corresponds to the listing of the functions on the vertical.
for eg in the above f(x) is trace 1, g(x) trace 2 and so on
Exercise 2

Plot f(x) = 3 - x and g(x) = -7 + x2

1. Use the window [-5,5] x [-15,15].


2. axes style changed from boxed to crossed
3. both graphs solid but different colors

Finding Points of Intersection

To find the points of intersection of two graphs:

1. Highlight the graph

2 Right Click on the graph and choose TRACE from the drop down window. (This is not the same as the
trace tab in the format menu)

3. Left Click on the mouse and a crosshair wiil appear. move it to the point of intersection and read off the
coordinates the window.

Note like any graphical technique this is only an approximation

Exercise 3 Find the points of intersection of the graphs in exercise 2.


Of Course to get a better approximation We can Zoom in on the point of intersection.

To do this right click on the graph and choose ZOOM. Left Click on the graph and drag to the right and down
to create the rectangle to be zoomed in on.

Hit OK

f ( x)
1
g( x)

0.5

0.5 1 1.5
x

We'll Trace again:


Range Variables

In many instances it is necessary to define a specific range for the independent variable or a desired step size (
increment between successive points) . For example for parametric equations or numerical analysis.

Example Parametric Equations Suppose we want to graph x(t) = cos(t) and y(t) =sin(t)

0 < t < increments of .1 sec. Define a range by t:=first point,first point + step size..endpoint. Use the m..n
symbol on the matrix menu for the .. Do Not Simply type .. .

t  0.1 2 
x(t)  cos (t) y(t)  sin(t)

0.5

y ( t)
1  0.5 0 0.5 1
 0.5

1

x( t )
We can also graph the derivatives using the derivative operator in the Calculus menu

d 0.5
y ( t)
dt

d 0 2 4 6 8
x( t )
dt  0.5

1

Example 2 Numerical Methods -- Another important case where we want to define the range of the
independent variable

Step 1

2
d x
For Example suppose we want the graphical and numerical solution to y e with y(0) = 1
dx

Define :

x

  t2
y ( x)   e dt  1

0

Step 2 Define the values of x for which you want the solution to the differential equation.

For example suppose we want the solution to the above equation for x = -2.5, -2, -1.5, -1, -.5, 0, .5, 1, 1.5,
2 and 2.5;

Define : x  2.52.5  .5 2.5 or simply x  2.52 2.5

Step 3 Obtaining the numerical solution

Once you've defined y and x to evaluate

Type x = then next to it type y(x) =. For example for the above differential equation:
x y ( x) 
-2.5 0.114
-2 0.118
-1.5 0.144
-1 0.253
-0.5 0.539
0 1
0.5 1.461
1 1.747
1.5 1.856
2 1.882
2.5 1.886

Step 4 The Graphical solution

Graph using x on the horizontal and y(x) on the vertical. Again for the above:

1.5

y ( x) 1

0.5

3 2 1 0 1 2 3
x

To format your graph:


Double click inside the graph and the format window
will appear

1. Change axes style from boxed to crossed


2. Under Traces change symbol from none to x's
3. Under TRACE TYPE change from lines to points
Suppose we want to use a smaller increment --All we have to do is copy and paste our resuls from above and
change the increment in our definiton of the range variable. Suppose we want the solution in increments of .2 units

x

  t2
y ( x)   e dt  1

0

Define : x  2.52.5  .2 2.5

x y ( x) 
-2.5 0.114
-2.3 0.115
-2.1 0.116
-1.9 0.12
-1.7 0.128
-1.5 0.144
-1.3 0.172
-1.1 0.22
-0.9 0.294
-0.7 0.399
-0.5 0.539
-0.3 0.709
-0.1 0.9
0.1 1.1
0.3 1.291
... ...

1.5

y ( x) 1

0.5

4 2 0 2 4
x
Piecewise Functions

Here open the programming window and the evaluation windows whose icons are:

The windows appear as

Using the Add Line and if commands we define:

x  11  .01 4

f ( x)  1  x if x  0
sin( x) if 0  x  
( x   ) if x  

When graphing in the Trace Tab change type from lines to points otherwise at discontinuities
a line segment will connect the graph over the discontinuity. Note I defined a range variable x with a very
small stepsize .01 to give the appearance of a solid curve

2
2

f ( x)

1 0 1 2 3 4

1
1

1 x 4

You might also like