Beruflich Dokumente
Kultur Dokumente
This worksheet takes the form of a number of examples which illustrate and introduce
these principles. Work through them all.
MathCAD will create a blank plot and insert it in the worksheet. When the graph is first
inserted, it shows 2 placeholders, one for the x-axis and one for the y-, as shown below:
Y-axis placeholder
X-axis placeholder
Sizing grab-handle
© dpl 2001,5,6 1
• Select the –x-axis placeholder and type the name of the independent variable, in
this case ‘x’.
• Then select the y-axis placeholder and type the expression we wish to plot, in this
case ‘sin(x). MathCAD will now create a plot of sin(x) vs x, it has selected a
range of –10 to +10 for x, we will see how to change this later.
• The default plot in mathCAD is rather small, so position the cursor over the sizing
grab-handle at the bottom right hand corner of the plot (the cursor will change to a
double ended arrow) and drag the grab-handle to make the plot fill most of the
screen.
Plot of sin(x) vs x
0.5
sin ( x) 0
0.5
1
10 5 0 5 10
x
We will use this graph as the basis for the next few exercises.
© dpl 2001,5,6 2
PH15720 MathCAD Example Sheet 4
MathCAD allows us to change the appearance of our basic plot. We can add grid lines to
the axes, change the style of plotting and change the range of both axes. We can also plot
more than one curve on the same graph.
• On the X-Y Axes page, select the checkboxes for gridlines on both axes.
• Select the tab for ‘Traces’
• In the list box, against the entry for ‘trace 1’, change the line colour to black.
• You can set other properties the traces on the plot if you wish, you may need to
scroll the box of trace options to see all of them.
• Press the OK button to apply the changes to the graph.
1
1
0.5
sin ( x) 0
0.5
1 1
10 5 0 5 10
10 x 10
© dpl 2001,5,6 3
PH15720 MathCAD Example Sheet 4
For this exercise, we will add curves for the cos(x) and tan(x) functions to our plot and
then adjust the plot ranges to scale our plot.
y-axis scale
placeholders
30
22.754
20
10
sin ( x)
cos( x) 0
tan ( x)
10
20
22.754 30
10 5 0 5 10
10 x 10
x-axis scale
placeholders
The y-axis will have automatically scaled to quite large values as it tries to accommodate
the tan curve as it shoots towards infinity. Up until now we have let mathCAD scale the
axes automatically. We will now give mathCAD values to use for the maximum and
minimum points on each axis.
© dpl 2001,5,6 4
PH15720 MathCAD Example Sheet 4
• Select the scale maximum placeholder on the y-axis and type ‘2’
• Select the scale minimum placeholder on the y-axis and type ‘-2’
• Select the scale maximum placeholder on the x-axis and type ‘4’
• Select the scale maximum placeholder on the x-axis and type ‘-4’
When you click the mouse outside the graph area, the plot should update to show the 3
curves plotted with the new axes.
It is often useful to plot horizontal or vertical lines called markers on the graph to show
important features. We will add markers on the x-axis at –π and π .
2
2
π π
sin ( x)
cos ( x) 0
tan ( x)
2 2
4 3 2 1 0 1 2 3 4
4 x 4
© dpl 2001,5,6 5
PH15720 MathCAD Example Sheet 4
You have now completed the part of this worksheet dealing with creating and formatting
graphs. If you have free time and are feeling confident, try the remaining two exercises
on this worksheet, otherwise move onto worksheet 5.
Providing x is in radians, a good approximation for sin(x) is x itself. This is valid for
small values of x.
x3 x5
sin( x ) ≈ x − +
3! 5!
This exercise will plot values for the first 3 approximations of sin(x) with the aid of some
user defined functions.
© dpl 2001,5,6 6
PH15720 MathCAD Example Sheet 4
sinApp1( x) x
3
x
sinApp2( x) x
3!
3 5
x x
sinApp3( x) x
3! 5!
sin ( x)
sinApp1 ( x)
0
sinApp2 ( x)
Exercise
sinApp3 ( x) 5 – The Cosine Approximation
x2 x4 x6
cos( x ) ≈ x 0 − + −
2! 4! 6!
2
4 3 2 1 0 1 2 3 4
0 x
which can be re-written, using the identity x =1, as
x2 x4 x6
cos( x ) ≈1 − + −
2! 4! 6!
© dpl 2001,5,6 7
PH15720 MathCAD Example Sheet 4
• Produce a graph showing cos(x) and the three approximations over the range of x-
values ± 4.
It is frequently important to know how much error is introduced into a problem by using
an approximation to sin(x) or cos(x) by using a simple approximation. Create a new
graph showing the error in the approximation. In this case we will define the error in the
approximations as the difference between our approximations and the built-in sin() and
cos() functions.
• Define 3 new functions, sinErr1(x), sinErr2(x) and sinErr3(x) which calculate the
error in using the approximate functions sinApp1(x), sinApp2(x) and sinApp3(x)
respectively.
• Plot the 3 error functions on a new graph over the range ± 4, limiting the y-axis
scaling to ± 2.
N 2 ⋅i+1
∑
i x
TaylorSine ( x , N) := ( −1) ⋅
( 2 ⋅i + 1)!
i=0
Plot a graph of your new function compared with the built in sin() function.
© dpl 2001,5,6 8