# Improved Euler's Method

The improved Euler's method (or Heun's method) approximates the solution of an initial value problem of the form y' = f(x,y), y(x_0) = y_0. It is an example of a predictor-corrector method.

In the applet below, enter f(x,y), x_0, y_0, and b, where [x_0, b] is the interval over which you want to approximate. Also enter n, the number of subintervals of [x_0, b] you want to use. (Then h = (b - x_0)/n is the step size.) When entering f(x,y), you can use +, -, *, /, ^, (), sin(), cos(), tan(), ln(), log(), asin(), acos(), atan(), pi, e. Take care to remember the * in all multiplications and avoid discontinuities. Then press the "Enter" button. If n > 10, press the "Run" button to get the trajectory traced out by the improved Euler's method. If n < = 10, press the "Predict/Correct" button repeatedly to get the trajectory traced out by Euler's method one step at a time. At each step, pressing "Predict" draws a gray line segment with slope determined by the derivative y' at the beginning of the segment, as in Euler's method. A short black line segment is also drawn that shows y' at the end of the gray segment. Pressing "Correct" then replaces the prediction segment with a corrected segment whose slope is the average of y' at the two ends of the prediction segment.

This applet uses a slightly modified version of the expression parser expr written by Darius Bacon.

source code