Heun's method: Difference between revisions

Content deleted Content added
Runge–Kutta method: make the coefficients consistent (\sum_j a_i_j = c_i), see http://en.wikipedia.org/wiki/Runge%E2%80%93Kutta_methods#Usage f.ex.
Derivation: An extended description, expanding on the relationship between Euler's Method and Heun's
Line 8:
:<math>\tilde{y}_{i+1} = y_i + h f(t_i,y_i)</math>
:<math>y_{i+1} = y_i + \frac{h}{2}(f(t_i, y_i) + f(t_{i+1},\tilde{y}_{i+1})).</math>
 
==Description==
Euler’s method is used as the foundation for Heun’s method. Where Euler’s method uses the tangent line to the actual solution curve as an estimate of the curve itself, provided the step size remains small enough, contends that the two will not drift too far apart. In reality, even when extremely small step sizes are used, over a large number of steps the error starts to accumulate and both solutions diverge.
 
Where the solution curve is concave up, its tangent line will underestimate the vertical coordinate of the next point and vice versa for a concave down solution. The ideal prediction line would hit the curve at its next predicted point. 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 over estimate or under estimate its vertical value. The concavity of the curve cannot be guaranteed to remain consistent either and the prediction may over estimate and under estimate 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
<ref>{{cite web
|title=Numerical Methods for Solving Differential Equations
|publisher=San Joaquin Delta College
|url=http://calculuslab.deltacollege.edu/ODE/7-C-2/7-C-2-h.html
|archiveurl=http://web.archive.org/web/20090212005921/http://calculuslab.deltacollege.edu/ODE/7-C-2/7-C-2-h.html
|archivedate=2009-02-12}}</ref>
The points along the tangent line of the left end point have vertical coordinates which all underestimate those that lie on the solution curve, including the right end point of the interval under consideration. The solution is to make the slope greater by some amount. 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 half way between the erroneous over estimation and under estimation, the average of the two slopes [[File:Heun's Method Diagram.jpg|thumb|right|alt=Heun's Method.|A diagram depicting the use of Heun's method to a find less erroneous prediction when compared to the lower order Euler's Method]].
Euler’s Method is used to roughly estimate the coordinates of the next point in the solution, and with this knowledge, the original estimate is re-predicted or ''corrected'' <ref>
{{Citation | last1=Chen
| first1=Wenfang.
| last2=Kee
| first2=Daniel D.
| title=Advanced Mathematics for Engineering and Science
| publisher=World Scientific
| ___location=MA, USA
| isbn=9812382925
| year=2003}}.</ref>. Assuming that the quantity <math>\textstyle f(x, y)</math> on the right hand side of the equation can be thought of as the slope of the solution sought at any point <math>\textstyle (x, y) </math>, 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.
 
==Derivation==
:<math>\textstyle Slope_{left} = f(x_i, y_i)</math>
:<math>\textstyle Slope_{right} = f(x_i + h, y_i + h f(x_i, y_i))</math>
:<math>\textstyle Slope_{ideal} = (1/2) (Slope_{left} + Slope_{right})</math>
 
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:
 
:<math>\textstyle Slope_{ideal} = (\Delta y /h) </math>
:<math>\textstyle \Delta y = h (Slope_{ideal})</math>
 
:<math>\textstyle x_{n+1} = x_i + h</math>, <math>\textstyle y_{n+1} = y_i + \Delta y</math>
:<math>\textstyle y_{n+1} = y_i + h Slope_{ideal}</math>
:<math>y_{n+1} = y_{n} + \frac{1}{2} h (Slope_{left} + Slope_{right})</math>
 
:<math>y_{n+1} = y_{n} + \frac{1}{2} h (f(x_i, y_i) f(x_i + h, y_i + hf(x_i, y_i)))</math>
The scheme can be compared with the [[Explicit and implicit methods|implicit]] [[trapezoidal method]], but with <math>f(t_{i+1},y_{i+1})</math> replaced by <math>f(t_{i+1},\tilde{y}_{i+1})</math> in order to make it explicit. <math>\tilde{y}_{i+1}</math> is the result of one step of [[Euler's method]] on the same initial value problem.
or
:<math>y_{n+1} = y_{n} + \frac{h}{2}(f(x_i, y_i) + f(x_i + h, y_i + hf(x_i, y_i)))</math>
 
The accuracy of the Euler method improves only linearly with the step size is decreased, whereas the Heun Method improves accuracy quadratically
So, Heun's method is a [[predictor-corrector method]] with forward [[Euler's method]] as predictor and [[trapezoidal method]] as corrector.
<ref>{{cite web
|title=The Euler-Heun Method
|publisher=LiveToad.org
|url=http://livetoad.org/Courses/Documents/214a/Notes/euler-heun_method.pdf
}}</ref>. The scheme can be compared with the [[Explicit and implicit methods|implicit]] [[trapezoidal method]], but with <math>f(t_{i+1},y_{i+1})</math> replaced by <math>f(t_{i+1},\tilde{y}_{i+1})</math> in order to make it explicit. <math>\tilde{y}_{i+1}</math> 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==