Using Mathcad To Plot Graph1 PDF
Using Mathcad To Plot Graph1 PDF
1 Text Regions
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:
For Example
2
f ( x) x
To evaluate this expression say f(2) simply type f(2) and hit the =
f (2) 4
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
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
110
0
y ( x)
3
110
3
210
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.
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
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.
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
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;
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
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
x
t2
y ( x) e dt 1
0
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:
x 11 .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