It is named after Karl Heun and is a numerical procedure for solving ordinary differential equations (ODEs) with a given initial value.
Euler's method uses the line tangent to the function at the beginning of the interval as an estimate of the slope of the function over the interval, assuming that if the step size is small, the error will be small.
In reality, there is no way to know whether the solution is concave-up or concave-down, and hence if the next predicted point will overestimate or underestimate its vertical value.
The concavity of the curve cannot be guaranteed to remain consistent either and the prediction may overestimate and underestimate at different points in the domain of the solution.
Heun's Method addresses this problem by considering the interval spanned by the tangent line segment as a whole.
Taking a concave-up example, the left tangent prediction line underestimates the slope of the curve for the entire width of the interval from the current point to the next predicted point.
If the tangent line at the right end point is considered (which can be estimated using Euler's Method), it has the opposite problem.
Heun's Method considers the tangent lines to the solution curve at both ends of the interval, one which overestimates, and one which underestimates the ideal vertical coordinates.
A prediction line must be constructed based on the right end point tangent's slope alone, approximated using Euler's Method.
If this slope is passed through the left end point of the interval, the result is evidently too steep to be used as an ideal prediction line and overestimates the ideal point.
Therefore, the ideal point lies approximately halfway between the erroneous overestimation and underestimation, the average of the two slopes.
on the right hand side of the equation can be thought of as the slope of the solution sought at any point
, this can be combined with the Euler estimate of the next point to give the slope of the tangent line at the right end-point.
Next the average of both slopes is used to find the corrected coordinates of the right end interval.
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: The accuracy of the Euler method improves only linearly with the step size is decreased, whereas the Heun Method improves accuracy quadratically .