Computer aid in graphical interpretation of ODE

Computer aid in graphical interpretation of ODE
Magdalena Makowiak,
Wydzia³ Matematyki i Informatyki, UAM, Matejki 48/49, Poznañ, Poland; e-mail: [email protected]
Adam Marlewski,
Instytut Matematyki, Politechnika Poznañska, ul.Piotrowo 3a, 60-965 Poznañ,; [email protected]
Abstract. Modern computer software can effectively improve mathematical education. In particular, it concerns
ordinary differential equations. Here advanced notions and methods are in use, time-consuming calculations are
necessary to get a graphical interpretation and numerical solutions. Both last aspects are specially important
when we can not obtain an exact, analytical formula for the function satisfying given initial problem. In this case
a direction field can help in the justification whether a numerical solution is correct enough. A direction field is
also useful when we investigate the uniqueness of solutions. In paper at hand we present how the systems
DERIVE (from Soft Warehouse Inc.) and WinPlot (by Richard Parris) may be applied to problems mentioned
above in the way which increases independent student activity.
Key words: computers in mathematical education, ordinary differential equations
1. Introduction
No doubt, since Newton and Leibniz there is no higher mathematics and physics without
differential equations. They are basic in the formalized description of the universe [10]-[11].
Thus there is very important to dominate and deeply understand their nature, to feel the idea
behind the concept of differential equation. A crucial point here is the notion of a direction
field. The importance of this concept is justified not only by the fact that almost every book
on differential equations (e.g. [5]-[7], [9], [14], [15], [16]) discusses it. The role of the
direction field is indispensable if an ODE is not solvable analytically and numerical methods
(e.g. the classical Runge-Kutta algorithm) have to be applied. Then, specially in cases of illposed problems, the coincidence between the numerical solution and slopes forming the
direction field is a proof to accept or reject results numerically calculated. Obviously, the hand
sketching of such a field consumes a lot of time, the assistance of computers is here very
effective.
We deal with any function f defined in an area D contained in the real plane R2 equipped with
the rectangular co-ordinate system Oxy. We distinguish a set Dp of points in D. In most cases
they are nodes of regular rectangular net, so the index p is a pair of two numbers, m and n,
saying how many different abscissas xj and different ordinates yk build the set Dp . Then we
write Dp = Dm,n := { (xj, yk ): j=0..m, k=0..n}.
First, in Section 2, we give basic definitions. In Section 3 we report a sample lesson on
direction field for an ODE with one singular point. In the next section we investigate an ODE
with no singularities is investigated, here the aspect of the DF-examination of a numerical
solution is considered. In Section 5 we deal with an ODE of the second degree. Otherwise
than in previous sections, where the computer algebra system DERIVE (from Soft Warehouse
Inc.; see e.g. [4]) is applied, here we use the program WinPlot (by Richard Parris; see e.g.
[13]). At last, we formulate conclusions underlining the advantages of CAI (computer assisted
instruction) in the area of ODE.
2. Basic definitions
A direction field (DF) of a differential equation
(2.1)
y’ = f (x, y)
(generated by the set Dm,n, named often as a canvas) is the set
(2.2)
{ f(xj, yk ) : (xj, yk ) ∈ Dm,n }.
A direction field may be (and usually it is) interpreted geometrically. To each point
(xj, yk ) ∈ Dm,n we may assign the angle α j,k such that
(2.3)
tan(α j,k) = f(xj, yk )
100
and then we can draw a linear segment (called a direction) sloped with this angle. Every such
a segment indicates a direction along which a solution y of the equation y’ = f(x, y) locally
goes. In other words, every solution y to the equation y’ = f(x, y) fits to these directions.
Immediately from the form of considered equation we see that this fitting is of a tangent
nature: a linear segment visualizing the direction lays on the tangent line to the curve y= y(x).
When enough number of linear segments is drawn (i.e. the net Dm,n is dense enough), one can
often see trends in the solution curves. This allows a graphical analysis of solutions.
Moreover, one can plot a numerical solution to see does it fit the slopes forming a DF.
Let’s say that in some realization a DF is called a slope field (no arrows are drawn) or a vector
field (arrows are on).
Fig.1. Direction field of the equation y’ = {y + sin(x)}/x − cos(x)
and graphs of fifteen particular solutions of this equation (Section 3)
3. Sample DERIVE lesson on direction field
Typical student’s exercise runs as follows: a student assumes the general solution
y = y(x,c)
of an ODE, next (s)he gets the derivative y’(x,c) and substitute a constant c eliminated from
the general solution. This work completed, the student may produce graphs of the direction
field and particular solutions.
For instance, assuming
(3.1)
y = c⋅x − sin(x)
we derive
(3.2)
c = {y + sin(x)}/x
and
(3.3)
y’ = c − cos(x) = {y + sin(x)}/x − cos(x).
101
That’s why we deal with the equation
(3.4)
y’ = {y + sin(x)}/x − cos(x).
Now we produce its direction field. At last we plot some particular solutions. It means we plot
graphs of functions obtained by fixing the value of the constant c.
Operations which within DERIVE produce figures as Fig.1 and Fig.2 are described, e.g. [8]
and [3].
All operations described above are easily issued if there are handy highlight (sub)expression
already displayed and we copy them (via hot keys F3 or F4) into the editing line.
It is didactically desired to plot a function which does not solve the considered ODE. Usually,
just after producing the direction field, a teacher says: „Let’s plot a particular solution, for
instance with c = 0”. It means the students edit the expression −SIN(x). „Look”, the teacher
says, „how this function perfectly fits to directions”. And (s)he may continue: „Now let’s
draw the graph with an other value of c, for example with c = 1. Hence we edit the expression
–1*x and we plot it”. This intentionally made mistake reveals that the graph of edited
expression does not coincide with the directions. It makes the students remember and deeper
understand what the direction field and solution to an ODE are.
Notice that the direction field appears that the resulted ODE (3.4) has the singular point at
x = 0. It does not happen, e.g., when we deal with such equations as y’ = y − sin(x) + cos(x)
and y’ = y +3x3 − x3 + cos(x) − sin(x) derived from the general solution y = c⋅exp(x) + sin(x)
and y = c⋅exp(x) + x3 + sin(x), respectively (comp. [2]).
4. Direction field examines a numerical solution
Let’s consider the equation
y’ = (2x − 4)/y2 .
Its direction field produced in the DERIVE by the approximation of the call
DIRECTION_FIELD((2x−4)/y^2,x,0,5,0.5,y,−3,16,0.5)
is reproduced in Fig.2. There are also plotted three lines. They are produced by the
approximation of the calls
RK([(2x−4)/y^2],[x,y],[0,1],h,5/h).
Both procedures, DIRECTION_FIELD and RK, are memorised in the unit ODE_APPR.MTH
distributed jointly to the CAS DERIVE. The procedure RK realises the classical fourth order
Runge-Kutta method and yields the sequence of values which (should) approximate the exact
solution of the initial problem. There are plotted graphs obtained when we run with the step
size h = 0.01, 0.001 and 0.0005. Some results concerning these values of h, as well as that
corresponding to h = 0.1 and 0.0001, are listed in Table 1 (see [3] to compare the discussed
case to solutions provided via Heun method implemented in the program Euler). It reveals
that there is no correspondence between the step size h and the quality of numerical solution.
Against a common feeling, not always the decrease in the step size h improves the output. In
considered case the results produced with h = 0.001 and 0.0005 are completely erroneous (that
with h = 0.001 keeps negative values, that with h = 0.0005 jumps drastically around the point
x = 1), while that produced with bigger values of h (0.1 and 0.01) are fully acceptable. The
time consumed by them is essentially shorter (some seconds against to 2 and 4 minutes used
when the work is with h = 0.001 and 0.005). Moreover, the RK-solution returned with
h = 0.0001 (25 minutes) is not essentially better than that produced in 1 and 10 seconds. We
do not discuss here the reasons to that strange (and rather extraordinary) behaviour. We put
our attention to the fact that the correctness of a numerical solution can be justified by the
examination how far the graph coincides with the direction field.
102
Fig. 2. Direction field to the equation y’ = (2x−4)/y2
and three solutions produced by the RK procedure (Section 4)
Table 1. Report on the work of the RK procedure
step size number
value
approximation
h
of steps
at x=5
time (in seconds)*)
1 0.1
50
2.45782
1
2 0.01
500
2.49435
10
3 0.001
5000
113
−5.04599
4 0.0005
10000
15.5230
246
5 0.0001
50000
2.5192
1518
*)
on the IBM PC 133 MHz
From the didactic point of view it is advised to plot in the graph of the function
u: x → (3x2 –12x + 1)1/3
which solves the considered initial problem: u’ = (2x –4)/u2 , u(0) =1. The coincidence of this
function to the directions (forming the direction field shown in Fig.2) is perfect. Naturally,
this perfection is up to the accuracy of float-point arithmetic and the pixel resolution. There
are just two elements which have to be taken into account when we justify the coincidence
between a numerical solution and the direction field.
103
Fig.3. Slope field for ODE {y’} 2 + y2 = 1 and graphs of some solutions
(Section 5)
5. Investigating an ODE of the first order and second degree
Let us consider the equation [9]
(5.1)
{y’}2 + y2 = 1
Here the derivative of the unknown function y appears in the square, so we have an ODE of
second degree. A direction field is defined for equations of the form
y’ = f(x,y),
so we have to derive such relations. In our case they simply are
(5.2)
y' =
1 − y2 ,
(5.3)
y' = − 1 − y 2 .
That’s why we complete direction field of the equation (5.1) is composed of two fields,
namely that defined by (5.2) and that by (5.3). This interference appears in the crossing of
directions (in Fig.3 it looks like crosses). At points where these directions coincide (i.e. at
points having ordinates y = −1 or y = +1) any solution of the equation (mm.2) may pass
smoothly into the solution of the equation (5.3). Obviously, this interlace takes place in the
opposite direction: from (5.3) to (5.2). Moreover, at every point laying on the line y= −1 or
y = +1 we can follow along any of them. On these two lines the Lipschitz condition does not
hold, the relations y = −1 and y = +1 are singular solutions to (5.1).
Both equations (5.2) and (5.3) are analytically solved (by the separation of variables). Their
solutions are defined on the whole real line and can be described by the one formula:
y = sin(x + c).
Detailed description how to produce figures as Fig.3 can be found in [12] or [2].
104
6. Conclusions
Differential equations are essential (and, in the same time, one of the most difficult) part of
higher mathematics and physics. That’s why students have to get a solid, well-grounded
knowledge on them. The nature of the subject makes that getting instructive examples is timeconsuming. In particular, it concerns the notions of a direction field, the uniqueness and the
acceptability of numerical solutions. We deal with these problems occurring in ODE of the
first order and first or second degree. We treat them with the aid of computer programs (we
take use of DERIVE and WinPlot, but there are other ones which are applied, see e.g. [6]).
This help is effective not only in the aspect of the time, it contributes essentially to the deep
understanding what a direction field is, what a singular point, particular and singular solutions
are, which phenomena may happen when a numerical method is used. An additional
advantage is than a student can individually explore the area, e.g. find singularities, exposure
the unsuitability of applied methods (or a bad choice in the values of their parameters). After
examining many cases (s)he may even undertake trials to formulate general conclusions. It
intensifies a mathematical activity, what is the one of the most important aims in
mathematical training [1].
Bibliography
[1] Z.Krygowska, “Elementy aktywnoœci matematycznej, które powinny odgrywaæ znacz¹c¹
rolê w matematyce dla wszystkich” (“Components of Mathematical Activities which
should Play a Significant Role in Mathematics Education for All”),
Dydaktyka
Matematyki 6(1986), 25-41
[2] M.Makowiak, A.Marlewski, “ Computer facilitation in understanding some notions in
ordinary differential equations”, submitted to “Lucrarile Seminarului de Creativitae
Matematica“, Baia Mare (Romania)
[3] A.Marlewski, “DERIVE 3.0”, NAKOM Poznañ 1995
[4] A.Marlewski, “Metoda Heuna realizowana w programie Euler (Heun method realised in
the program Euler)”, accepted for publication in “Pro Dialog” 12 (2000)
[5] N.M.Matwiejew, “Zadania z równañ ró¿niczkowych zwyczajnych”, PWN Warszawa 1974
[6] A.Palczewski, "Równania ró¿niczkowe zwyczajne", WNT Warszawa 1999
[7] D.L.Powers, "Elementary differential equations with boundary value problems", Prindle,
Weber & Schmidt, Boston 1985
[8] R.S.Freese, D.A.Stegenga, “Calculus Concepts Using Derive For Windows”, R&D
Publishing 1999
[9] W.W.Stiepanow, “Równania ró¿niczkowe”, PWN Warszawa 1964.
[10] I.Steward. "Nature's numbers. The Unreal Reality of Mathematical Imagination", Orion
Publishing Group 1996 (Polish edition: "Liczby natury", CIS Warszawa 1996)
[11] I.Steward. "Does God Play Dice? The New Mathematics of Chaos.", Penguin Books
1990 (Polish edition: "Czy Bóg gra w koœci? Nowa matematyka chaosu", PWN
Warszawa 1994)
[12] ftp://instruction.madison.tec.wi.us/alehnen/winptut/winpltut.htm
[13] http://www.exeter.edu/~rparris/default.html (as on 20.04.2000)
[14] http://barker.sjdccd.cc.ca.us/ODE/ (ODE laboratories: A Sabbatical Project by
Christopher A.Barker)
[15] http://www.humboldt.edu/~mef2/book/IVD.html
[16] http://calculus.sjdccd.cc.ca.us/ODE/7-1/7-1-0-h.html
105