# Euler Method Calculator Program

The Euler method for solving differential equations can often be tedious. Especially in calculus classes, students are often required to produce tables to demonstrate their knowledge of the subject. This calculator program lets users input an initial function solution, a step size, a differential equation, and the number of steps, and the calculator automatically generates a table for you. In order to create this program, follow the detailed steps below, or you can jump to the end for the complete code.

### Creating a Program

To create a program, press the prgm button and scroll over to NEW. You can name the program whatever you like, but its recommended that the name relate to the program’s function. That way you can easily recognize it and understand what it does from the title. I’ll name it “EULER” here because it performs the Euler method. ### Coding the Program

We’ll begin by clearing any existing lists and the home screen, and then prompting for the desired inputs. ClrHome and Input can be found by pressing prgm in the program editor. To find ClrAllLists, navigate to it in the catalog found with 2nd0. The term “Y1” is actually a function name and is found under vars>1.

```: ClrHome : ClrAllLists : Input "START X: ",X : Input "START Y: ",Y : Input "DELTA X: ",Z : Input "DY/DX= ",Y1 : Input "STEPS: ",W```

We then need to fill a list with all the desired x-values. The seq( command is found under 2ndstat>5 and takes as an input the function, variable, start value, end value, and step size. A very important thing to note is that, because of the way you write functions, the 4th input will need to be written in quotation marks when running the program. After that we’ll create a variable for a loop. To store a value in a variable you use the sto→ button.

```: seq(X,X,X,((W+1)*Z)+X,Z)→L1 : 1→I```

The loop will then iterate through the x-values and calculate the corresponding y-values, y-prime-values, and change in y-value, and store them in lists 2, 3, and 4 respectively. Make sure you are selecting the actual list names found by pressing 2nd and then a number 1 through 6, and not just typing “L” and “1” for example.

```: While W≥0 : Y→L2(I) : Y1→L3(I) : Y1*Z→L4(I) : I+1→I : L1(I)→X : Y+L4(I-1)→Y : W-1→W : End``` ### Testing the Program

The program is now finished! Exit out of the program editor by pressing 2ndmode and run your program found at prgm. Try solving Y(2) given Y(1) = 2 and Y’ = X + Y using a step size of 0.2. We know that the starting x and y values will be 1 and 2 respectively, and the step size 0.2. Very important: when writing the function you need to type it in quotation marks. Otherwise, the program will interpret it as a numeric value rather than an equation. Lastly, since we want to reach X=2 with a step size of 0.2, we will require 5 steps. Press enter to run the program then navigate to the lists under state and select EDIT. The second column containing the y-values shows that Y(2) equals 6.953. ### Complete Code

```: ClrHome : ClrAllLists : Input "START X: ",X : Input "START Y: ",Y : Input "DELTA X: ",Z : Input "DY/DX= ",Y1 : Input "STEPS: ",W : seq(X,X,X,((W+1)*Z)+X,Z)→L1 : 1→I : While W≥0 : Y→L2(I) : Y1→L3(I) : Y1*Z→L4(I) : I+1→I : L1(I)→X : Y+L4(I-1)→Y : W-1→W : End```