This program applies Euler's method to the solution of the differential equation Y'' + c

The program treats Y'' + c_{1}Y' + c_{0}Y = 0 as
a set of two coupled first-order equations:

Y' = V

V' = -c_{1}V - c_{0}Y

The function
-c_{1}V - c_{0}Y is
stored in the Y= register as Y_{3}.

For a readable display, you must first set the window size
with X_{min} = A, X_{max} = B, and Y_{min}
and Y_{max} appropriate for your problem.

To key in the program, start from the main screen (hit QUIT if you are somewhere else), hit PGRM and select NEW from the menu. The calculator goes into Alpha-lock mode and prompts you for the Name of the new program. Type in EULER2, for example, and hit ENTER. Calculator will move to a new line and display a colon : which means the beginning of an instrction. Hit ENTER after each instruction has been keyed in. Calculator will move to a new line and display the colon.

To finish keying the program hit QUIT (2nd MODE). To run it, enter the expression for -cProgram Explanation and Keying instructions:ClrDraw Clears the screen. DRAW (2nd PRGM), 1. :FnOff Turns off the function graphing. Y-VARS (2nd VARS),5,2. :Prompt A,B,Y,V,N Asks you to input A,B,Y,V,N. The Prompt command is 2 on the PRGM --> I/O menu. The comma key is just below SIN. :(B-A)/N -> H Calculate the step-size H. -> is one character, obtained by pressing STO. :A -> X :1 -> I Initialize X and the counter I :Lbl P Label this spot in the program as P. Lbl is 9 on the CTL menu: PRGM --> CTL,9 :Y + V*H -> Y :V + Y_{3}*H -> V The new Y value is computed from the :X+H->X current V value. The new V value is computed from the equation. Then X is updated. The symbol Y3 is selected from the Y-VARS Function... menu. :X->K:Y->L Pt-On(X,Y) draws a point at coordinates :Pt-On(X,Y) (X,Y). The other two instructions work :K->X:L->Y around the Pt-On's tendency to erase X and Y. Pt-On is DRAW -> POINTS, 1. :IS>(I,N) IS>( is on the PRGM --> CTL menu. This command adds 1 to the counter I and then tests if the new value is greater then N. If it is, the following instruction is skipped (so the program displays the current value Y and terminates). Otherwise it executes the following instruction. :Goto P Cycle back to location P. Goto is 0 on the CTL menu. :DispGraph Displays the graph. PRGM --> I/O,4.

*Check:* Enter -4Y in Y3, so the differential equation in question
is Y''+ 4Y = 0, with general solution Y = A cos(2X) + B sin(2X).
Prepare the window with X_{min} = 0, X_{max} = 10, and
Y_{min} = -1.5, Y_{max} = 1.5 Run the program with A=0, B=10,
Y=1, V=0, N=100. The window should display a good likeness of
Y = cos(2X). Run it with A=0, B=10, Y=0, V=1, N=100. The window
should display a good likeness of Y = (1/2)sin(2X).

*Note:* This program can also be used for more general
second-order equations.

Math Dept SUNY Stony Brook

tony@math.sunysb.edu

March 26 2003