Mathcad'S Program Function and Application in Teaching of Math
Mathcad'S Program Function and Application in Teaching of Math
Mathcad'S Program Function and Application in Teaching of Math
and
APPLICATION IN TEACHING OF MATH
DE TING WU
Depart of Math
Morehouse College
Atlanta, GA.30314, USA
dtwu@morehouse.edu
1. Introduction
1.1 About Mathcad
Mathcad is one of popular computer algebra system (math software) in the world. Like
other CAS's, it has the capabilities to perform algebraic operations, calculus operations
and draw graph of 2 or 3 dimensions. We can use it to get numerical, symbolic and
graphic solution of math problem. Besides above common capabilities, it has some
feature: its words processor function is better than other CAS. This feature makes it look
like a scientifical words processor and it easy to create a woksheet.
Following current trend to add program function to math software, it added program
function to itself , started in Mathcad V7. This improvement makes its function more
complete and more powerful.
1.2 Role of program function in teaching of Math.
Without doubt, math softwares and technology are helpful aide in teaching of Math. They
are effecting the teaching of Math profoundly and it can be expected the emerging newer
technologies will penetrate and reconfigure the teaching of Math.
The program function is a new function of math software. It is natural we want to know
whether or not it is useful in teaching of Math? I think: although for most problems we
meet in teaching of Math it is enough to use computation ability, in certain cases the
program function becomes necessary and very helpful. For example, for Numerical
Analysis the program function is very useful but for Abstract Algebra it is less necessary.
Another example is Differential Equations, when teaching approximate method for a
solution of a differential equation the program function is necassary and teaching
existence and uniquess of the solution of a differential equation it is not necessary.
Moreover, as the power of program function is increasing the more applications will be
found.
1.3 About this presentation
This presentation is to introduce the program function of Mathcad and illustrate some of
application in teaching of Math which is based on my teaching experience in past years.
4."
if
": conditional operator which can be used whenever you want a program
statement to be executed only upon the occurrence of some condition.
otherwise ":
conditional operator which can be used together with "if" operator when
you want a program to execute a statement when the condition of "if"
operator is false.
" : looping operator which can be used when you know how many times you
5." for
10."
": Control operator which can be used anywhere in a program when you
want to interrupt a program and to return a value different from the value
of last expression of a program.
on error
": Operator for error control which can be used to return an alternative
value when an error happened in an expression.
f( x, y ) :=
x +y
v sin ( u ) + e
w 1+ u
v
w
The form and structure of Mathcad program make it easy to recognize and separate
from other part of worksheet. The program operators are simple so that writing a
program is simple. This is very suitable for teaching purpose. This form and structure
is good for revising of program too. Also, its form and structure make it convenient to
interact with other parts of a worksheet.
Although Mathcad program is comprised of its program operators, a lot of its built-in
functions can be used in the program too. For example, augment, sign, random variable
and so on. This makes its program more concise and powerful. The output of Mathcad
program maybe is a number, a vector, a matrix and a function, this makes its application
wide and flexible.
However, the program function of Mathcad is as limited as other technologies. For
example, Not all its built-in functions can be used in Mathcad program and some of
them can not be used completely and symbolic operations don't work within a
program.
Anyway, Program function of Mathcad is a useful tool in teaching of Math.
y
Given: y'=1+ y +
interval by Euler method and Improved Euler method with step size h=0.1 and errors.
To make programs of Euler and Improved Euler method
Program of Euler method
Eu( f , a , b , c , h ) :=
x a
0
i+ 1
x +h
y + h f x , y
y1
( i i)
P augment ( x, y)
P
for i 0.. n 1
for i 0 .. n 1
i+ 1
ca
ca
i+ 1
y b
y b
n
x a
x +h
i
i+ 1
i+ 1
( i i)
y + h f x , y
i
y +
i
h
2
( ( i i) ( i+ 1 , y1i+ 1))
f x ,y + f x
P augment ( x, y )
P
Note: in above programs Left side is the output of the program which is a matrix of xvalue and approximate solution values. Right side is the program which uses the
input: 'f' function of ODE, 'a' initial x value; 'b' initial y value; 'c' end point of the interval;
'h' step size and perform approximate method to produce approximate solution.
Now, let's us these programs to get approximate solutions of above example.
In above example,
Let
f( x, y) := 1 +
A := Eu( f , a , b , c , h )
y
x
a := 1
b := 0
c := 2
h := 0.1
B := IEu( f , a , b , c , h )
A = 0
1.1
1.2
1.3
1.4
1.5
1.6
1.7
1.8
1.9
B = 0
1.1
1.2
1.3
1.4
1.5
1.6
1.7
1.8
1.9
i := 0 .. 10
x := 1 + i 0.1
i
y' ( x)
1+
y ( x)
x
y ( x)
x
y( 1)
y := Odesolve ( x, 2)
( i)
y x =
0.1052
0.1052
0.2212
0.2212
0.3491
0.3491
0.4897
0.4897
0.6439
0.6439
0.8128
0.8128
0.9975
0.9975
1.1994
1.1994
1.4201
1.4201
10 1.6613
( i)
g x =
10 1.6613
(A 1 )i
1.5
(B 1 )i
g( xi)
y ( xi)
0.5
1.2
1.4
1.6
1.8
xi
Next, let's analyze their error. we define error of Euler method and Improved Euler Method as
ErEu and ErIEu.
( i) (
ErEu := g x A
i
ErEu =
ErIEu =
1
0 5.159810 -3
0 2.011410
ErEui
-4
)i
0.0113
0.0187
0.0273
0.0376
4.71410
-4
8.117610
-4
1.228610
0.1
ErIEui
0.05
1.2
( i) ( 1 )i
ErIEu := g x B
1.4
1.6
xi
1.8
-3
1.732210 -3
t a
0
u1 b
0
u2 c
0
u3 d
0
la
h
for i 0.. n 1
t
i+ 1
t +h
i
( i i i i)
u21
u2 + h f2( t , u1 , u2 , u3 )
i+ 1
i
i
i
i
i
u31
u3 + h f3( t , u1 , u2 , u3 )
i+ 1
i
i
i
i
i
u11
i+ 1
u1 + h f1 t , u1 , u2 , u3
i
u1
u1 +
u2
u2 +
u3
u3 +
i+ 1
i+ 1
i+ 1
i
i
h
2
h
2
h
2
( (i
( (i
( (i
f1 t , u1 , u2 , u3 + f1 t
i
f2 t , u1 , u2 , u3 + f2 t
i
f3 t , u1 , u2 , u3 + f3 t
i
P augment ( t , u1)
P augment ( P , u2)
P augment ( P , u3)
P
f1( t , u1 , u2 , u3) := u2
a := 0
b := 1
f2( t , u1 , u2 , u3) := u1 2 e + 1
c := 0
d := 1
l := 1
h := 0.1
f3( t , u1 , u2 , u3) := u1 e + 1
Let
A=
2
1
0.1
0.99 -0.2105
0.8947
0.2
0.9579 -0.4411
0.7805
0.3
0.9018 -0.6918
0.6583
0.4
0.8196 -0.9627
0.5295
0.5
0.7093 -1.2539
0.3953
0.6
0.5689 -1.5657
0.2571
0.7
0.3963 -1.8983
0.1163
0.8
10
( i)
t := 0.1 i
i
g1 t =
0.9897
-0.21
0.8952
0.9573
-0.44
0.7814
0.901
-0.69
0.6598
0.8187
-0.9602
0.5316
0.7083
-1.2506
0.3982
0.5679
-1.5614
0.2607
0.3953
-1.8931
0.1206
0.1885
-2.2462
-0.0206
-0.0547
-2.6213
-0.1617
10 -0.3365
( i)
g2 t =
10 -3.0195
( i)
g3 t =
10 -0.3012
Next, we make 4 graphes. Ist one is graph of 3 approximate solutions; 2nd one is the
graph of u1 and g1; 3rd one is the graph of u2 and g2; 4th is graph of u3 and g3.
2
1
(A 1 )i
0
(A 2 )i
(A 3 )i
0.5
(A 1 )i
0.5
g1( t i)
0.5
0.5
(A 0 )i
(A 2 )i
g2( t i)
ti
0.5
(A 3 )i
0.5
g3( t i)
0
0.5
0.5
ti
ti
Now, let's analyze the error. We define error in u1, u2, u3 as Eru1, Eru2, Eru3.
Eru1 :=
i
(A 1 )i g1(ti)
0
Eru1 =
Eru2 =
Eru2 :=
i
(A 2 )i g2(ti)
Eru3 :=
i
1
2
3
4
0 3.333410 -4 6.134310 -4 8.327510 -4 9.845510 -4
1
0 5.169210
Eru3 =
2
-4
1
0 4.292910
1.116410
3
-3
2
-4
9.318910
1.794610
4
-3
3
-4
1.503110
2.547310
2.137510
5
1.06310 -3
5
-3
4
-3
(A 3 )i g3(ti)
3.369910 -3
5
-3
2.829410 -3
0.008
Eru1i 0.006
Eru2i
Eru3i
0.004
0.002
0.2
0.4
0.6
ti
0.8
p0 a
Note:
Input: f(x)=0- given equation
a,b-endpoints of [a,b]
that bracket the solution
r-desired accuracy
Output: Approximate solution
satifying accuracy
p1 b
while p1 p0 r
p
p0 f( p1) p1 f( p0)
f( p1) f( p0)
p0 p1
p1 p
p
Now, let's see an example: Find approximate solution of cos(x)-x=0 with accuracy 10 5.
f( x) := cos ( x) x
f( 0) = 1
f( 1) = 0.45969769
f( x)
b := 1
x := ApS ( f , a , b , r)
x = 0.73908513
r := 10
a := 0
r = 0.73908513
er := x r
13
er = 1.59317004 10
a := 1.3
a := 1.6
b := 0.7651977
a := 1.9
b := 0.620086
b := 0.4554022
a := 2.2
b := 0.2818186
b := 0.1103623
f :=
for i 0 .. 4
x a
i
i, 0
0.7651977
0.620086 0.48370567
for j 1 .. i
i, j
0
f = 0.4554022 0.548946 0.10873389
0.2818186 0.578612 0.04944333 0.0658784
for i 1 .. 4
0.1103623 0.571521
i , j 1
0
0
i1 , j 1
x x
i j
p4( t) := f
0, 0
p4( t)
f
i =1
i, i
(t ak)
k =0
simplify
-2
2
-2 3
-3 4
.977735 + 7.3391310
t .343047t
+ 5.5292810
t + 1.8251010
t
float , 6
p4( 2) = 0.22387536
Finally, Plot the data points and Newton's interpolation polynomial in a graph below:
i := 0.. 4
t := 1 , 1.01.. 2.2
Graph of data points and Newton's poly.
bi
p4 ( t ) 0.5
0.5
1.5
2.5
ai , t
5. Reference
[1] R.L.Burden & J.D.Faires:"Numerical Analysis" 7th edition, Brooks/Cole ,2001.
[2] L.Fausett: "Numerical Methods Using Mathcad", Prentice Hall, 2002.
[3] R.K.Nagle, E.B.Staff & A.D.Snide: "Fundamentals of Differential Equations" 6th
edition , Addition Wesley, 2004
[4} D.T.Wu: "Using Mathcad in Teaching Differential Equations" , Electronic Proceedings
of ICTMT4, 1999.
Web site: www.tech.plym.ac.uk/maths/CTMHOME/ictmt4.html
[5] D.T.Wu: "Teaching Numerical Analysis with Mathcad", "International Journal of
Computer Algebra in Mathematics Education" Vol 10 No.1, 2003.