:\text{Slope}_{\text{left}} = f(x_i, y_i) :\text{Slope}_{\text{right}} = f(x_i + h, y_i + h f(x_i, y_i)) :\text{Slope}_{\text{ideal}} = \frac{1}{2} (\text{Slope}_{\text{left}} + \text{Slope}_{\text{right}}) Using the principle that the slope of a line equates to the rise/run, the coordinates at the end of the interval can be found using the following formula: :\text{Slope}_{\text{ideal}} = \frac{\Delta y}{h} :\Delta y = h (\text{Slope}_{\text{ideal}}) :x_{i+1} = x_i + h, \textstyle y_{i+1} = y_i + \Delta y :y_{i+1} = y_i + h \text{Slope}_{\text{ideal}} :y_{i+1} = y_{i} + \frac{1}{2} h (\text{Slope}_{\text{left}} + \text{Slope}_{\text{right}}) :y_{i+1} = y_{i} + \frac{h}{2}(f(x_i, y_i) + f(x_i + h, y_i + hf(x_i, y_i))) The accuracy of the Euler method improves only linearly with the step size is decreased, whereas the Heun Method improves accuracy quadratically. The scheme can be compared with the
implicit trapezoidal method, but with f(t_{i+1},y_{i+1}) replaced by f(t_{i+1},\tilde{y}_{i+1}) in order to make it explicit. \tilde{y}_{i+1} is the result of one step of
Euler's method on the same initial value problem. So, Heun's method is a
predictor-corrector method with forward
Euler's method as predictor and
trapezoidal method as corrector. ==Runge–Kutta method==