Jump to content

Euler method: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
Geometrical description: fixed formatting, made writing more clear
Tags: Mobile edit Mobile app edit Android app edit
m Reverted edit by 14.139.208.85 (talk) to last version by Jarfuls of Tweed
 
(40 intermediate revisions by 20 users not shown)
Line 1: Line 1:
{{Short description|Approach to finding numerical solutions of ordinary differential equations}}
{{Short description|Approach to finding numerical solutions of ordinary differential equations}}
{{for multi|integrating with respect to the Euler characteristic|Euler calculus|Euler's method for factorizing an integer|Euler's factorization method}}
{{for multi|integrating with respect to the Euler characteristic|Euler calculus|Euler's method for factorizing an integer|Euler's factorization method}}
{{Differential equations}}
[[Image:Euler method.svg|thumb|(Figure 1) Illustration of the Euler method. The unknown curve is in blue, and its polygonal approximation is in red.]]
[[Image:Euler method.svg|thumb|(Figure 1) Illustration of the Euler method. The unknown curve is in blue, and its polygonal approximation is in red.]]
{{Differential equations}}


In [[mathematics]] and [[computational science]], the '''Euler method''' (also called the '''forward Euler method''' or '''Euler's Method''') is a first-order [[numerical analysis|numerical]] procedure for solving [[ordinary differential equation]]s (ODEs) with a given [[Initial value problem|initial value]]. It is the most basic [[explicit and implicit methods|explicit method]] for [[numerical ordinary differential equations|numerical integration of ordinary differential equations]] and is the simplest [[Runge–Kutta method]]. The Euler method is named after [[Leonhard Euler]], who first proposed it in his book ''[[Institutionum calculi integralis]]'' (published 1768–1870).<ref>{{harvnb|Butcher|2003|p=45}}; {{harvnb|Hairer|Nørsett|Wanner|1993|p=35}}</ref>
In [[mathematics]] and [[computational science]], the '''Euler method''' (also called the '''forward Euler method''') is a first-order [[numerical analysis|numerical]] procedure for solving [[ordinary differential equation]]s (ODEs) with a given [[Initial value problem|initial value]]. It is the most basic [[explicit and implicit methods|explicit method]] for [[numerical ordinary differential equations|numerical integration of ordinary differential equations]] and is the simplest [[Runge–Kutta method]]. The Euler method is named after [[Leonhard Euler]], who first proposed it in his book ''[[Institutionum calculi integralis]]'' (published 1768–1770).<ref>{{harvnb|Butcher|2003|p=45}}; {{harvnb|Hairer|Nørsett|Wanner|1993|p=35}}</ref>


The Euler method is a first-order method, which means that the local error (error per step) is proportional to the square of the step size, and the global error (error at a given time) is proportional to the step size.
The Euler method is a first-order method, which means that the local error (error per step) is proportional to the square of the step size, and the global error (error at a given time) is proportional to the step size.
Line 19: Line 19:


=== First-order process ===
=== First-order process ===
When given the values for <math>t_0 </math> and <math>y(t_0) </math>, and the derivative of <math>y </math> is a given function of <math>t </math> and <math>y </math> denoted as <math>y'(t) = f\bigl(t,y(t)\bigr) </math>, begin the process by setting <math>y_0=y(t_0) </math>. Next, choose a value <math>h</math> for the size of every step and set <math>t_n = t_0 + nh</math> (or equivalently <math>t_{n+1} = t_n + h</math>). Now, one step of the Euler method from <math>t_n</math> to <math>t_{n+1}</math> is:<ref>{{harvnb|Butcher|2003|p=45}}; {{harvnb|Hairer|Nørsett|Wanner|1993|p=36}}</ref>
When given the values for <math>t_0 </math> and <math>y(t_0) </math>, and the derivative of <math>y </math> is a given function of <math>t </math> and <math>y </math> denoted as <math>y'(t) = f\bigl(t,y(t)\bigr) </math>. Begin the process by setting <math>y_0=y(t_0) </math>. Next, choose a value <math>h</math> for the size of every step along t-axis, and set <math>t_n = t_0 + nh</math> (or equivalently <math>t_{n+1} = t_n + h</math>). Now, the Euler method is used to find <math>y_{n+1}</math> from <math>y_n</math> and <math>t_n</math>:<ref>{{harvnb|Butcher|2003|p=45}}; {{harvnb|Hairer|Nørsett|Wanner|1993|p=36}}</ref>


:<math> y_{n+1} = y_n + hf(t_n,y_n).</math>
:<math> y_{n+1} = y_n + hf(t_n,y_n).</math>


The value of <math>y_n</math> is an approximation of the solution to the ODE at time <math>t_n</math>, i.e., <math>y_n \approx y(t_n)</math>. The Euler method is [[explicit and implicit methods|explicit]], i.e. the solution <math>y_{n+1}</math> is an explicit function of <math>y_i</math> for <math>i \leq n</math>.
The value of <math>y_n</math> is an approximation of the solution at time <math>t_n</math>, i.e., <math>y_n \approx y(t_n)</math>. The Euler method is [[explicit and implicit methods|explicit]], i.e. the solution <math>y_{n+1}</math> is an explicit function of <math>y_i</math> for <math>i \leq n</math>.


=== Higher-order process ===
=== Higher-order process ===
While the Euler method integrates a first-order ODE, any ODE of order <math>N</math> can be represented as a system of first-order ODEs. When given the ODE of order <math>N</math> defined as
While the Euler method integrates a first-order ODE, any ODE of order <math>N</math> can be represented as a system of first-order ODEs. When given the ODE of order <math>N</math> defined as


:<math> y^{(N)}(t) = f\left(t, y(t), y'(t), \ldots, y^{(N-1)}(t)\right) ,</math>
:<math> y^{(N+1)}(t) = f\left(t, y(t), y'(t), \ldots, y^{(N)}(t)\right) ,</math>


we implement the following formula until we reach the approximation of the solution to the ODE at the desired time:
as well as <math>h</math>, <math>t_0</math>, and <math>y_0,y'_0,\dots, y^{(N)}_0</math>, we implement the following formula until we reach the approximation of the solution to the ODE at the desired time:


:<math> \vec{y_{i+1}}
:<math> \vec{y}_{i+1}
= \begin{pmatrix} y_{i+1}\\ \vdots\\ y_{i+1}^{(N-1)}\\ y_{i+1}^{(N)} \end{pmatrix}
= \begin{pmatrix} y_{i+1}\\ y'_{ i+1 } \\ \vdots\\ y_{i+1}^{(N-1)}\\ y_{i+1}^{(N)} \end{pmatrix}
= \begin{pmatrix} y_{i}+h\cdot y'_i\\ \vdots\\ y^{(N-1)}_{i}+h\cdot y^{(N)}_{i}\\ y^{(N)}_{i}+h\cdot f\left(t_i, y_i, y'_i, \ldots, y^{(N)}_i\right) \end{pmatrix} </math>
= \begin{pmatrix} y_{i}+h\cdot y'_i\\ y' _{i}+h\cdot y''_{i}\\ \vdots\\ y^{(N-1)}_{i}+h\cdot y^{(N)}_{i}\\ y^{(N)}_{i}+h\cdot f\left(t_i, y_i, y'_i, \ldots, y^{(N)}_i\right) \end{pmatrix} </math>


These first-order systems can be handled by Euler's method or, in fact, by any other scheme for first-order systems.<ref>{{harvnb|Butcher|2003|p=3}}; {{harvnb|Hairer|Nørsett|Wanner|1993|p=2}}</ref>
These first-order systems can be handled by Euler's method or, in fact, by any other scheme for first-order systems.<ref>{{harvnb|Butcher|2003|p=3}}; {{harvnb|Hairer|Nørsett|Wanner|1993|p=2}}</ref>
==First-order example==

==Example==
Given the initial value problem
Given the initial value problem


Line 117: Line 116:


We can extrapolate from the above table that the step size needed to get an answer that is correct to three decimal places is approximately 0.00001, meaning that we need 400,000 steps. This large number of steps entails a high computational cost. For this reason, higher-order methods are employed such as [[Runge–Kutta method]]s or [[linear multistep method]]s, especially if a high accuracy is desired.<ref>{{harvnb|Hairer|Nørsett|Wanner|1993|p=40}}</ref>
We can extrapolate from the above table that the step size needed to get an answer that is correct to three decimal places is approximately 0.00001, meaning that we need 400,000 steps. This large number of steps entails a high computational cost. For this reason, higher-order methods are employed such as [[Runge–Kutta method]]s or [[linear multistep method]]s, especially if a high accuracy is desired.<ref>{{harvnb|Hairer|Nørsett|Wanner|1993|p=40}}</ref>

== Higher-order example ==
For this third-order example, assume that the following information is given:

<math>\begin{align} &
y''' + 4ty'' - t^2y'- (\cos{t})y=\sin{t}
\\ &
t_0=0
\\ &
y_0=y(t_0)=2
\\ &
y'_0=y'(t_0)=-1
\\ &
y''_0 = y''( t_0 )=3
\\ &
h=0.5
\end{align} </math>

From this we can isolate y<nowiki>'''</nowiki> to get the equation:

<math>f\left(t , y, y' , y'' \right) = y''' = \sin{t} + (\cos{t})y + t^2y' - 4ty'' </math>

Using that we can get the solution for <math> \vec{y}_{1} </math>:<math display="block"> \vec{y}_{1}
= \begin{pmatrix} y_{1} \\ y_{1}'\\ y_{1} '' \end{pmatrix}
= \begin{pmatrix} y_{0}+h\cdot y'_0\\ y'_{0}+h\cdot y''_{0} \\
y''_{0}+h\cdot f\left(t_0 , y_0, y'_0 , y''_0\right) \end{pmatrix}
= \begin{pmatrix} 2+0.5 \cdot -1 \\ -1+0.5\cdot 3 \\ 3 +0.5\cdot \left(\sin{0} + (\cos{0}) \cdot 2 + 0^2 \cdot (-1) - 4 \cdot 0 \cdot 3 \right) \end{pmatrix} =
\begin{pmatrix} 1.5\\ 0.5 \\ 4 \end{pmatrix} </math>And using the solution for <math> \vec{y}_{1} </math>, we can get the solution for <math> \vec{y}_{2} </math>:<math display="block"> \vec{y}_{2}
= \begin{pmatrix} y_{2} \\ y_{2}' \\ y_{2} '' \end{pmatrix}
= \begin{pmatrix} y_{1}+h\cdot y'_1\\ y'_{1}+h\cdot y''_{1} \\
y''_{1}+h\cdot f\left(t_1 , y_1, y'_1 , y''_1 \right) \end{pmatrix}
= \begin{pmatrix} 1.5+ 0.5 \cdot 0.5\\ 0.5+ 0.5 \cdot 4 \\
4+ 0.5 \cdot \left( \sin{0.5} + ( \cos{0.5}) \cdot 1.5 + 0.5^2 \cdot 0.5 - 4 \cdot 0.5 \cdot 4 \right) \end{pmatrix}
= \begin{pmatrix} 1.75 \\ 2.5 \\ 0.9604... \end{pmatrix} </math>We can continue this process using the same formula as long as necessary to find whichever <math> \vec{y}_{i} </math> desired.


==Derivation==
==Derivation==


The Euler method can be derived in a number of ways. Firstly, there is the geometrical description above.
The Euler method can be derived in a number of ways.


'''(1)''' Firstly, there is the geometrical description above.
Another possibility is to consider the [[Taylor expansion]] of the function <math>y</math> around <math>t_0</math>:

'''(2)''' Another possibility is to consider the [[Taylor expansion]] of the function <math>y</math> around <math>t_0</math>:


:<math> y(t_0 + h) = y(t_0) + h y'(t_0) + \tfrac12 h^2 y''(t_0) + O\left(h^3\right). </math>
:<math> y(t_0 + h) = y(t_0) + h y'(t_0) + \tfrac12 h^2 y''(t_0) + O\left(h^3\right). </math>


The differential equation states that <math>y'=f(t,y)</math>. If this is substituted in the Taylor expansion and the quadratic and higher-order terms are ignored, the Euler method arises.<ref>{{harvnb|Atkinson|1989|p=342}}; {{harvnb|Hairer|Nørsett|Wanner|1993|p=36}}</ref> The Taylor expansion is used below to analyze the error committed by the Euler method, and it can be extended to produce [[Runge–Kutta methods]].
The differential equation states that <math>y'=f(t,y)</math>. If this is substituted in the Taylor expansion and the quadratic and higher-order terms are ignored, the Euler method arises.<ref>{{harvnb|Atkinson|1989|p=342}}; {{harvnb|Hairer|Nørsett|Wanner|1993|p=36}}</ref>
The Taylor expansion is used below to analyze the error committed by the Euler method, and it can be extended to produce [[Runge–Kutta methods]].


A closely related derivation is to substitute the forward [[finite difference]] formula for the derivative,
'''(3)''' A closely related derivation is to substitute the forward [[finite difference]] formula for the derivative,


:<math> y'(t_0) \approx \frac{y(t_0+h) - y(t_0)}{h} </math>
:<math> y'(t_0) \approx \frac{y(t_0+h) - y(t_0)}{h} </math>


in the differential equation <math>y' = f(t,y)</math>. Again, this yields the Euler method.<ref>{{harvnb|Atkinson|1989|p=342}}</ref> A similar computation leads to the [[midpoint method]] and the [[backward Euler method]].
in the differential equation <math>y' = f(t,y)</math>. Again, this yields the Euler method.<ref>{{harvnb|Atkinson|1989|p=342}}</ref>


Finally, one can integrate the differential equation from <math>t_0</math> to <math>t_0 + h</math> and apply the [[fundamental theorem of calculus]] to get:
A similar computation leads to the [[midpoint method]] and the [[backward Euler method]].
'''(4)''' Finally, one can integrate the differential equation from <math>t_0</math> to <math>t_0 + h</math> and apply the [[fundamental theorem of calculus]] to get:


:<math> y(t_0+h) - y(t_0) = \int_{t_0}^{t_0+h} f\bigl(t,y(t)\bigr) \,\mathrm{d}t. </math>
:<math> y(t_0+h) - y(t_0) = \int_{t_0}^{t_0+h} f\bigl(t,y(t)\bigr) \,\mathrm{d}t. </math>
Line 142: Line 183:
:<math> \int_{t_0}^{t_0+h} f\bigl(t,y(t)\bigr) \,\mathrm{d}t \approx h f\bigl(t_0, y(t_0)\bigr). </math>
:<math> \int_{t_0}^{t_0+h} f\bigl(t,y(t)\bigr) \,\mathrm{d}t \approx h f\bigl(t_0, y(t_0)\bigr). </math>


Combining both equations, one finds again the Euler method.<ref>{{harvnb|Atkinson|1989|p=343}}</ref> This line of thought can be continued to arrive at various [[linear multistep method]]s.
Combining both equations, one finds again the Euler method.<ref>{{harvnb|Atkinson|1989|p=343}}</ref>
This line of thought can be continued to arrive at various [[linear multistep method]]s.


==Local truncation error==
==Local truncation error==
Line 159: Line 203:
This result is valid if <math>y</math> has a bounded third derivative.<ref>{{harvnb|Butcher|2003|p=60}}</ref>
This result is valid if <math>y</math> has a bounded third derivative.<ref>{{harvnb|Butcher|2003|p=60}}</ref>


This shows that for small <math>h</math>, the local truncation error is approximately proportional to <math>h^2</math>. This makes the Euler method less accurate (for small <math>h</math>) than other higher-order techniques such as [[Runge-Kutta method]]s and [[linear multistep method]]s, for which the local truncation error is proportional to a higher power of the step size.
This shows that for small <math>h</math>, the local truncation error is approximately proportional to <math>h^2</math>. This makes the Euler method less accurate than higher-order techniques such as [[Runge-Kutta method]]s and [[linear multistep method]]s, for which the local truncation error is proportional to a higher power of the step size.


A slightly different formulation for the local truncation error can be obtained by using the Lagrange form for the remainder term in [[Taylor's theorem]]. If <math>y</math> has a continuous second derivative, then there exists a <math>\xi \in [t_0,t_0+h]</math> such that
A slightly different formulation for the local truncation error can be obtained by using the Lagrange form for the remainder term in [[Taylor's theorem]]. If <math>y</math> has a continuous second derivative, then there exists a <math>\xi \in [t_0,t_0+h]</math> such that
Line 170: Line 214:


==Global truncation error==
==Global truncation error==
The [[global truncation error]] is the error at a fixed time <math>t</math>, after however many steps the method needs to take to reach that time from the initial time. The global truncation error is the cumulative effect of the local truncation errors committed in each step.<ref>{{harvnb|Atkinson|1989|p=344}}</ref> The number of steps is easily determined to be <math display="inline">\frac{t-t_0}{h}</math>, which is proportional to <math display="inline">\frac{1}{h}</math>, and the error committed in each step is proportional to <math>h^2</math> (see the previous section). Thus, it is to be expected that the global truncation error will be proportional to <math>h</math>.<ref>{{harvnb|Butcher|2003|p=49}}</ref>
The [[global truncation error]] is the error at a fixed time <math>t_i</math>, after however many steps the method needs to take to reach that time from the initial time. The global truncation error is the cumulative effect of the local truncation errors committed in each step.<ref>{{harvnb|Atkinson|1989|p=344}}</ref> The number of steps is easily determined to be <math display="inline">\frac{t_i-t_0}{h}</math>, which is proportional to <math display="inline">\frac{1}{h}</math>, and the error committed in each step is proportional to <math>h^2</math> (see the previous section). Thus, it is to be expected that the global truncation error will be proportional to <math>h</math>.<ref>{{harvnb|Butcher|2003|p=49}}</ref>


This intuitive reasoning can be made precise. If the solution <math>y</math> has a bounded second derivative and <math>f</math> is [[Lipschitz continuity|Lipschitz continuous]] in its second argument, then the global truncation error (GTE) is bounded by
This intuitive reasoning can be made precise. If the solution <math>y</math> has a bounded second derivative and <math>f</math> is [[Lipschitz continuity|Lipschitz continuous]] in its second argument, then the global truncation error (denoted as <math> |y(t_i)-y_i| </math>) is bounded by


:<math> |\text{GTE}| \le \frac{hM}{2L}\left(e^{L(t-t_0)}-1\right) </math>
:<math> |y(t_i)-y_i| \le \frac{hM}{2L}\left(e^{L(t_i-t_0)}-1\right) </math>


where <math>M</math> is an upper bound on the second derivative of <math>y</math> on the given interval and <math>L</math> is the Lipschitz constant of <math>f</math>.<ref>{{harvnb|Atkinson|1989|p=346}}; {{harvnb|Lakoba|2012|loc=equation (1.16)}}</ref>
where <math>M</math> is an upper bound on the second derivative of <math>y</math> on the given interval and <math>L</math> is the Lipschitz constant of <math>f</math>.<ref>{{harvnb|Atkinson|1989|p=346}}; {{harvnb|Lakoba|2012|loc=equation (1.16)}}</ref> Or more simply, when <math>y'(t) = f(t,y) </math>, the value <math display="inline">L = \text{max}\bigl(|\frac{d}{dy}\bigl[f(t,y)\bigr] | \bigr) </math> (such that <math>t </math> is treated as a constant). In contrast, <math display="inline">M = \text{max}\bigl( | \frac{d^2}{dt^2}\bigl[y(t)\bigr] | \bigr) </math> where function <math>y(t) </math> is the exact solution which only contains the <math>t </math> variable.


The precise form of this bound is of little practical importance, as in most cases the bound vastly overestimates the actual error committed by the Euler method.<ref>{{harvnb|Iserles|1996|p=7}}</ref> What is important is that it shows that the global truncation error is (approximately) proportional to <math>h</math>. For this reason, the Euler method is said to be first order.<ref>{{harvnb|Butcher|2003|p=63}}</ref>
The precise form of this bound is of little practical importance, as in most cases the bound vastly overestimates the actual error committed by the Euler method.<ref>{{harvnb|Iserles|1996|p=7}}</ref> What is important is that it shows that the global truncation error is (approximately) proportional to <math>h</math>. For this reason, the Euler method is said to be first order.<ref>{{harvnb|Butcher|2003|p=63}}</ref>

=== Example ===


If we have the differential equation <math>y'=1+ ( t-y)^2</math>, and the exact solution <math>y=t+ \frac{1}{t-1}</math>, and we want to find <math>M</math> and <math>L</math> for when <math>2 \le t \le 3</math>. <math display="block">L = \text{max}\bigl( | \frac{d}{dy}\bigl[f(t,y)\bigr] | \bigr) = \max_{2 \le t \le 3}\bigl( | \frac{d}{dy}\bigl[1+ ( t-y)^2 \bigr] | \bigr) = \max_{2 \le t \le 3}\bigl( | 2( t-y) | \bigr) = \max_{2 \le t \le 3}\bigl( | 2( t-[t+ \frac{1}{t-1}]) | \bigr) = \max_{2 \le t \le 3}\bigl( | - \frac{2}{t-1} | \bigr) = 2 </math><math display="block">M = \text{max}\bigl(|\frac{d^2}{dt^2}\bigl[y(t)\bigr]|\bigr) = \max_{2 \le t \le 3} \left( | \frac{d^2}{dt^2} \bigl[ t + \frac{1}{1-t} \bigr] |\right) = \max_{2 \le t \le 3}\left( | \frac{2}{(-t+1)^3} | \right) = 2 </math>Thus we can find the error bound at t=2.5 and h=0.5:

<math display="block"> \text{error bound} = \frac{hM}{2L}\left(e^{L(t_i-t_0)}-1\right) = \frac{0.5 \cdot 2}{2 \cdot 2}\left(e^{2(2.5-2)}-1\right) = 0.42957 </math>Notice that t<sub>0</sub> is equal to 2 because it is the lower bound for t in <math>2 \le t \le 3</math>.


==Numerical stability==
==Numerical stability==
Line 191: Line 242:
illustrated on the right. This region is called the (linear) ''stability region''.<ref>{{harvnb|Butcher|2003|p=70}}; {{harvnb|Iserles|1996|p=57}}</ref> In the example, <math>k = -2.3</math>, so if <math>h = 1</math> then <math>hk = -2.3</math> which is outside the stability region, and thus the numerical solution is unstable.
illustrated on the right. This region is called the (linear) ''stability region''.<ref>{{harvnb|Butcher|2003|p=70}}; {{harvnb|Iserles|1996|p=57}}</ref> In the example, <math>k = -2.3</math>, so if <math>h = 1</math> then <math>hk = -2.3</math> which is outside the stability region, and thus the numerical solution is unstable.


This limitation — along with its slow convergence of error with <math>h</math> — means that the Euler method is not often used, except as a simple example of numerical integration{{citation needed|date=May 2021}}.
This limitation — along with its slow convergence of error with <math>h</math> — means that the Euler method is not often used, except as a simple example of numerical integration{{citation needed|date=May 2021}}. Frequently models of physical systems contain terms representing fast-decaying elements (i.e. with large negative exponential arguments). Even when these are not of interest in the overall solution, the instability they can induce means that an exceptionally small timestep would be required if the Euler method is used.


==Rounding errors==
==Rounding errors==
Line 209: Line 260:
The other possibility is to use more past values, as illustrated by the two-step Adams–Bashforth method:
The other possibility is to use more past values, as illustrated by the two-step Adams–Bashforth method:
:<math> y_{n+1} = y_n + \tfrac32 h f(t_{n}, y_{n}) - \tfrac12 h f(t_{n-1}, y_{n-1}). </math>
:<math> y_{n+1} = y_n + \tfrac32 h f(t_{n}, y_{n}) - \tfrac12 h f(t_{n-1}, y_{n-1}). </math>
This leads to the family of [[linear multistep method]]s. There are other modifications which uses techniques from compressive sensing to minimize memory usage<ref>{{cite journal |last1=Unni |first1=M. P. |last2=Chandra|first2=M. G. |last3=Kumar |first3=A. A. |date=March 2017 |title=Memory reduction for numerical solution of differential equations using compressive sensing |journal=2017 IEEE 13th&nbsp;International Colloquium on Signal Processing Its Applications (CSPA) |pages=79–84 |doi=10.1109/CSPA.2017.8064928|isbn=978-1-5090-1184-1 |s2cid=13082456 }}</ref>
This leads to the family of [[linear multistep method]]s. There are other modifications which uses techniques from compressive sensing to minimize memory usage<ref>{{cite book |last1=Unni |first1=M. P. |last2=Chandra|first2=M. G. |last3=Kumar |first3=A. A. |title=2017 IEEE 13th International Colloquium on Signal Processing & its Applications (CSPA) |chapter=Memory reduction for numerical solution of differential equations using compressive sensing |date=March 2017 |pages=79–84 |doi=10.1109/CSPA.2017.8064928|isbn=978-1-5090-1184-1 |s2cid=13082456 }}</ref>


==In popular culture==
==In popular culture==

Latest revision as of 18:01, 15 November 2024

(Figure 1) Illustration of the Euler method. The unknown curve is in blue, and its polygonal approximation is in red.

In mathematics and computational science, the Euler method (also called the forward Euler method) is a first-order numerical procedure for solving ordinary differential equations (ODEs) with a given initial value. It is the most basic explicit method for numerical integration of ordinary differential equations and is the simplest Runge–Kutta method. The Euler method is named after Leonhard Euler, who first proposed it in his book Institutionum calculi integralis (published 1768–1770).[1]

The Euler method is a first-order method, which means that the local error (error per step) is proportional to the square of the step size, and the global error (error at a given time) is proportional to the step size. The Euler method often serves as the basis to construct more complex methods, e.g., predictor–corrector method.

Geometrical description

[edit]

Purpose and why it works

[edit]

Consider the problem of calculating the shape of an unknown curve which starts at a given point and satisfies a given differential equation. Here, a differential equation can be thought of as a formula by which the slope of the tangent line to the curve can be computed at any point on the curve, once the position of that point has been calculated.

The idea is that while the curve is initially unknown, its starting point, which we denote by is known (see Figure 1). Then, from the differential equation, the slope to the curve at can be computed, and so, the tangent line.

Take a small step along that tangent line up to a point Along this small step, the slope does not change too much, so will be close to the curve. If we pretend that is still on the curve, the same reasoning as for the point above can be used. After several steps, a polygonal curve () is computed. In general, this curve does not diverge too far from the original unknown curve, and the error between the two curves can be made small if the step size is small enough and the interval of computation is finite.[2]

First-order process

[edit]

When given the values for and , and the derivative of is a given function of and denoted as . Begin the process by setting . Next, choose a value for the size of every step along t-axis, and set (or equivalently ). Now, the Euler method is used to find from and :[3]

The value of is an approximation of the solution at time , i.e., . The Euler method is explicit, i.e. the solution is an explicit function of for .

Higher-order process

[edit]

While the Euler method integrates a first-order ODE, any ODE of order can be represented as a system of first-order ODEs. When given the ODE of order defined as

as well as , , and , we implement the following formula until we reach the approximation of the solution to the ODE at the desired time:

These first-order systems can be handled by Euler's method or, in fact, by any other scheme for first-order systems.[4]

First-order example

[edit]

Given the initial value problem

we would like to use the Euler method to approximate .[5]

Using step size equal to 1 (h = 1)

[edit]
(Figure 2) Illustration of numerical integration for the equation Blue is the Euler method; green, the midpoint method; red, the exact solution, The step size is

The Euler method is

so first we must compute . In this simple differential equation, the function is defined by . We have

By doing the above step, we have found the slope of the line that is tangent to the solution curve at the point . Recall that the slope is defined as the change in divided by the change in , or .

The next step is to multiply the above value by the step size , which we take equal to one here:

Since the step size is the change in , when we multiply the step size and the slope of the tangent, we get a change in value. This value is then added to the initial value to obtain the next value to be used for computations.

The above steps should be repeated to find , and .

Due to the repetitive nature of this algorithm, it can be helpful to organize computations in a chart form, as seen below, to avoid making errors.

0 1 0 1 1 1 2
1 2 1 2 1 2 4
2 4 2 4 1 4 8
3 8 3 8 1 8 16

The conclusion of this computation is that . The exact solution of the differential equation is , so . Although the approximation of the Euler method was not very precise in this specific case, particularly due to a large value step size , its behaviour is qualitatively correct as the figure shows.

Using other step sizes

[edit]
(Figure 3) The same illustration for

As suggested in the introduction, the Euler method is more accurate if the step size is smaller. The table below shows the result with different step sizes. The top row corresponds to the example in the previous section, and the second row is illustrated in the figure.

step size result of Euler's method error
1 16.00 38.60
0.25 35.53 19.07
0.1 45.26 09.34
0.05 49.56 05.04
0.025 51.98 02.62
0.0125 53.26 01.34

The error recorded in the last column of the table is the difference between the exact solution at and the Euler approximation. In the bottom of the table, the step size is half the step size in the previous row, and the error is also approximately half the error in the previous row. This suggests that the error is roughly proportional to the step size, at least for fairly small values of the step size. This is true in general, also for other equations; see the section Global truncation error for more details.

Other methods, such as the midpoint method also illustrated in the figures, behave more favourably: the global error of the midpoint method is roughly proportional to the square of the step size. For this reason, the Euler method is said to be a first-order method, while the midpoint method is second order.

We can extrapolate from the above table that the step size needed to get an answer that is correct to three decimal places is approximately 0.00001, meaning that we need 400,000 steps. This large number of steps entails a high computational cost. For this reason, higher-order methods are employed such as Runge–Kutta methods or linear multistep methods, especially if a high accuracy is desired.[6]

Higher-order example

[edit]

For this third-order example, assume that the following information is given:

From this we can isolate y''' to get the equation:

Using that we can get the solution for :And using the solution for , we can get the solution for :We can continue this process using the same formula as long as necessary to find whichever desired.

Derivation

[edit]

The Euler method can be derived in a number of ways.

(1) Firstly, there is the geometrical description above.

(2) Another possibility is to consider the Taylor expansion of the function around :

The differential equation states that . If this is substituted in the Taylor expansion and the quadratic and higher-order terms are ignored, the Euler method arises.[7]

The Taylor expansion is used below to analyze the error committed by the Euler method, and it can be extended to produce Runge–Kutta methods.

(3) A closely related derivation is to substitute the forward finite difference formula for the derivative,

in the differential equation . Again, this yields the Euler method.[8]

A similar computation leads to the midpoint method and the backward Euler method.


(4) Finally, one can integrate the differential equation from to and apply the fundamental theorem of calculus to get:

Now approximate the integral by the left-hand rectangle method (with only one rectangle):

Combining both equations, one finds again the Euler method.[9]


This line of thought can be continued to arrive at various linear multistep methods.

Local truncation error

[edit]

The local truncation error of the Euler method is the error made in a single step. It is the difference between the numerical solution after one step, , and the exact solution at time . The numerical solution is given by

For the exact solution, we use the Taylor expansion mentioned in the section Derivation above:

The local truncation error (LTE) introduced by the Euler method is given by the difference between these equations:

This result is valid if has a bounded third derivative.[10]

This shows that for small , the local truncation error is approximately proportional to . This makes the Euler method less accurate than higher-order techniques such as Runge-Kutta methods and linear multistep methods, for which the local truncation error is proportional to a higher power of the step size.

A slightly different formulation for the local truncation error can be obtained by using the Lagrange form for the remainder term in Taylor's theorem. If has a continuous second derivative, then there exists a such that

[11]

In the above expressions for the error, the second derivative of the unknown exact solution can be replaced by an expression involving the right-hand side of the differential equation. Indeed, it follows from the equation that[12]

Global truncation error

[edit]

The global truncation error is the error at a fixed time , after however many steps the method needs to take to reach that time from the initial time. The global truncation error is the cumulative effect of the local truncation errors committed in each step.[13] The number of steps is easily determined to be , which is proportional to , and the error committed in each step is proportional to (see the previous section). Thus, it is to be expected that the global truncation error will be proportional to .[14]

This intuitive reasoning can be made precise. If the solution has a bounded second derivative and is Lipschitz continuous in its second argument, then the global truncation error (denoted as ) is bounded by

where is an upper bound on the second derivative of on the given interval and is the Lipschitz constant of .[15] Or more simply, when , the value (such that is treated as a constant). In contrast, where function is the exact solution which only contains the variable.

The precise form of this bound is of little practical importance, as in most cases the bound vastly overestimates the actual error committed by the Euler method.[16] What is important is that it shows that the global truncation error is (approximately) proportional to . For this reason, the Euler method is said to be first order.[17]

Example

[edit]

If we have the differential equation , and the exact solution , and we want to find and for when . Thus we can find the error bound at t=2.5 and h=0.5:

Notice that t0 is equal to 2 because it is the lower bound for t in .

Numerical stability

[edit]
(Figure 4) Solution of computed with the Euler method with step size (blue squares) and (red circles). The black curve shows the exact solution.

The Euler method can also be numerically unstable, especially for stiff equations, meaning that the numerical solution grows very large for equations where the exact solution does not. This can be illustrated using the linear equation

The exact solution is , which decays to zero as . However, if the Euler method is applied to this equation with step size , then the numerical solution is qualitatively wrong: It oscillates and grows (see the figure). This is what it means to be unstable. If a smaller step size is used, for instance , then the numerical solution does decay to zero.

(Figure 5) The pink disk shows the stability region for the Euler method.

If the Euler method is applied to the linear equation , then the numerical solution is unstable if the product is outside the region

illustrated on the right. This region is called the (linear) stability region.[18] In the example, , so if then which is outside the stability region, and thus the numerical solution is unstable.

This limitation — along with its slow convergence of error with — means that the Euler method is not often used, except as a simple example of numerical integration[citation needed]. Frequently models of physical systems contain terms representing fast-decaying elements (i.e. with large negative exponential arguments). Even when these are not of interest in the overall solution, the instability they can induce means that an exceptionally small timestep would be required if the Euler method is used.

Rounding errors

[edit]

In step of the Euler method, the rounding error is roughly of the magnitude where is the machine epsilon. Assuming that the rounding errors are independent random variables, the expected total rounding error is proportional to .[19] Thus, for extremely small values of the step size the truncation error will be small but the effect of rounding error may be big. Most of the effect of rounding error can be easily avoided if compensated summation is used in the formula for the Euler method.[20]

Modifications and extensions

[edit]

A simple modification of the Euler method which eliminates the stability problems noted above is the backward Euler method:

This differs from the (standard, or forward) Euler method in that the function is evaluated at the end point of the step, instead of the starting point. The backward Euler method is an implicit method, meaning that the formula for the backward Euler method has on both sides, so when applying the backward Euler method we have to solve an equation. This makes the implementation more costly.

Other modifications of the Euler method that help with stability yield the exponential Euler method or the semi-implicit Euler method.

More complicated methods can achieve a higher order (and more accuracy). One possibility is to use more function evaluations. This is illustrated by the midpoint method which is already mentioned in this article:

.

This leads to the family of Runge–Kutta methods.

The other possibility is to use more past values, as illustrated by the two-step Adams–Bashforth method:

This leads to the family of linear multistep methods. There are other modifications which uses techniques from compressive sensing to minimize memory usage[21]

[edit]

In the film Hidden Figures, Katherine Goble resorts to the Euler method in calculating the re-entry of astronaut John Glenn from Earth orbit.[22]

See also

[edit]

Notes

[edit]
  1. ^ Butcher 2003, p. 45; Hairer, Nørsett & Wanner 1993, p. 35
  2. ^ Atkinson 1989, p. 342; Butcher 2003, p. 60
  3. ^ Butcher 2003, p. 45; Hairer, Nørsett & Wanner 1993, p. 36
  4. ^ Butcher 2003, p. 3; Hairer, Nørsett & Wanner 1993, p. 2
  5. ^ See also Atkinson 1989, p. 344
  6. ^ Hairer, Nørsett & Wanner 1993, p. 40
  7. ^ Atkinson 1989, p. 342; Hairer, Nørsett & Wanner 1993, p. 36
  8. ^ Atkinson 1989, p. 342
  9. ^ Atkinson 1989, p. 343
  10. ^ Butcher 2003, p. 60
  11. ^ Atkinson 1989, p. 342
  12. ^ Stoer & Bulirsch 2002, p. 474
  13. ^ Atkinson 1989, p. 344
  14. ^ Butcher 2003, p. 49
  15. ^ Atkinson 1989, p. 346; Lakoba 2012, equation (1.16)
  16. ^ Iserles 1996, p. 7
  17. ^ Butcher 2003, p. 63
  18. ^ Butcher 2003, p. 70; Iserles 1996, p. 57
  19. ^ Butcher 2003, pp. 74–75
  20. ^ Butcher 2003, pp. 75–78
  21. ^ Unni, M. P.; Chandra, M. G.; Kumar, A. A. (March 2017). "Memory reduction for numerical solution of differential equations using compressive sensing". 2017 IEEE 13th International Colloquium on Signal Processing & its Applications (CSPA). pp. 79–84. doi:10.1109/CSPA.2017.8064928. ISBN 978-1-5090-1184-1. S2CID 13082456.
  22. ^ Khan, Amina (9 January 2017). "Meet the 'Hidden Figures' mathematician who helped send Americans into space". Los Angeles Times. Retrieved 12 February 2017.

References

[edit]
[edit]