Program DFIELD
Output: A direction field for
dy
dx
= f(x, y) or for the
system
dx
dt
= g(x, y),
dy
dt
= h(x, y). In the later case, we take
f(x, y) = h(x, y)/g(x, y).
Input: f(X, Y ) as the Y
1
variable.
:ClrDraw
:FnOff
:(Xmax−Xmin)/10 → S
:Xmin+S → X
:Ymin+S → Y
:Lbl 1
:X − S/5 → A
:Y − SY
1
/5 → B
:X + S/5 → C
:Y + SY
1
/5 → D
:Line(A,B,C,D)
:Y + S → Y
:If Y <Ymax
:Goto 1
:X + S → X
:Ymin→ Y
:If X ≥ Xmax
:Stop
:Goto 1
Program EULER
Output: An approximate solution using Euler’s method
to
dy
dx
= f(x, y), y
0
= y(x
0
) on the interval [x
0
, b].
Input: f(X, Y ) as the Y
1
variable, X0 as x
0
, Y0 as
y
0
= y(x
0
), H and B as h and b in Euler’s method
:FnOff
:Disp “X0”
:Input X
:Disp “Y0”
:Input Y
:Disp “H”
:Input H
:Disp “B”
:Input B
:Lbl 1
:Disp “X=”
:Disp X
:Disp “Y=”
:Disp Y
:Pause
:Y + HY
1
→ Y
:X + H → X
:If X ≤ B + H
Goto 1
Stop
Program EULERG
Output: The graph of an approximate solution to y
0
=
f(x, y), y(0) = x
0
on the interval [x
0
, B] using Euler’s
method.
Input: f(X, Y ) as the Y
1
variable, X0 as x
0
, Y0 as
y
0
= y(x
0
), H as h in Euler’s method. Set the RANGE
variables so that x
min
= x
0
and x
max
= B.
:ClrDraw
:FnOff
:Disp “X0”
:Input X
:Disp “Y0”
:Input Y
:Disp “B”
:Input B
:Disp “H”
:Input H
:Lbl 1
:X → P
:Y → Q
:Pt-On(X,Y)
:P → X
:Q → Y
:Y + HY
1
→ Y
:X + H → X
:If X < B + H
:Goto 1
:Stop
Program EULERS
Output: A graph of an approximate solution to the sys-
tem of differential equations
dX
dt
= P (x, y, t),
dY
dt
=
P (x, y, t), X(t
0
) = X
0
, Y (t
0
) = Y
0
using Euler’s
method.
Input: P (X, Y, T ) as the Y
1
variable, Q(X, Y, T ) as the
Y
2
variable, H as h in Euler’s method. Set the range
variables as desired.
:FnOff
:ClrDraw
:(Xmax−Xmin)/H → N
:Disp “X0”
:Input X
:Disp “Y0”
:Input Y
:Disp “H”
53