Ошибка метода эйлера

Работа по теме: ЛР_Численные методы решения дифференциальных ур. Глава: Ошибка метода Эйлера. ВУЗ: УрФУ.

Ошибка метода Эйлера

Представленный
метод аппроксимации решения задачи
Коши называется разностным. Решение
представляет собой совокупность
отдельных точек, называемых узловыми.

При
использовании разностных методов
существует два источника ошибок: ошибка
дискретизации, возникающая в результаты
замены дифференциального уравнения
разностной аппроксимацией (2.5), и ошибка
округления, накопившаяся при выполнении
арифметических операций. Будем считать,
что значения

вычисляются точно, так что погрешности
обусловлены только ошибкой дискретизации.
Введем величину, равную наибольшему
отклонению аппроксимации от точного
решения на отрезке

(3.1)

называемую
глобальной
ошибкой дискретизации

(иногда эту величину называют глобальной
ошибкой усечения
).
Отметим, что

зависит от величины шага

,
поскольку предполагается, что приближения

вычисляют при заданном значении

.
Интуитивно ожидаем, что при уменьшении

ошибка дискретизации будет убывать и,
в частности, при стремлении

к нулю, так же будет стремиться к нулю.

Теорема
(ошибка дискретизации метода Эйлера).

Если функция

имеет ограниченную частную производную
по второй переменной и если решение
задачи Коши имеет ограниченную вторую
производную, то глобальная ошибка
дискретизации метода Эйлера

.

Порядок
метода численного интегрирования
показывает, от какой степени шага зависит
величина ошибки.

Локальная
(или шаговая)
ошибка метода – это ошибка, совершаемая
на одном шаге. Очевидно, что от шага к
шагу, т. е. при многократном применении
формулы метода, возможно наложение
ошибок. За

шагов, т. е. в точке

,
образуется глобальная
ошибка
.

Порядок
глобальной ошибки (относительно шага

)
на единицу ниже, чем порядок локальной
ошибки, а порядком глобальной ошибки и
определяется порядок соответствующего
численного процесса решения задачи
Коши.

Глобальная
ошибка метода Эйлера есть

,
т. е. данный метод имеет первый порядок.
Иными словами, размер шага и ошибка для
метода Эйлера связаны линейно. Практическим
следствием этого факта является ожидание
того, что при уменьшении

приближенное решение будет все более
точным и при стремлении

к нулю будет стремиться к точному решению
с линейной скоростью

;
т.е. ожидаем, что при уменьшении шага

вдвое ошибка уменьшится примерно в два
раза. Такое поведение ошибки демонстрируется
на следующем примере.

Поскольку
в методе Эйлера ошибка достаточно велика
и от шага к шагу накапливается, а точность
пропорциональна количеству вычислений,
то метод Эйлера обычно применяют для
грубых расчетов, для оценки поведения
системы в принципе. Для точных
количественных расчетов применяют
более точные методы.

Метод Хьюна

Следующий
подход представляет новую идею построения
алгоритмов решения задачи Коши. Пусть

на
отрезке

с начальным условием

Для
получения решения в точке

,
можем воспользоваться теоремой о
вычислнии определенного интеграла:

где
первообразная от

является
искомой функцией

.
Если разрешить уравнение последнее
уравнение относительно

,
получим

Теперь
можно применить численные методы
нахождения интеграла. Воспользуемся
методом трапеций с шагом

,
получим:

Правая
часть формулы включает в себя еще не
найденное значение

.
Для его нахождения воспользуемся методом
Эйлера. Получим конечную формулу,
именуемую методом
Хьюна
(синонимы:
метод
Хойна
,
метод
Эйлера-Коши
):

Продолжая
процесс, получим последовательность
точек, аппроксимирующих кривую решения

.
Метод Хьюна относится к классу методов
прогноза-коррекции. На каждом шаге метод
Эйлера используется для предсказания,
а метод трапеций для уточнения конечного
значения. Общие формулы для шага метода
Хьюна:

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]

  • #
  • #
  • #
  • #
  • #
  • #
  • #
  • #
  • #
  • #
  • #

(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–1870).[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 A_{0}, is known (see Figure 1). Then, from the differential equation, the slope to the curve at A_{0} can be computed, and so, the tangent line.

Take a small step along that tangent line up to a point A_{1}. Along this small step, the slope does not change too much, so A_{1} will be close to the curve. If we pretend that A_{1} is still on the curve, the same reasoning as for the point A_{0} above can be used. After several steps, a polygonal curve (A_{0}A_{1}A_{2}A_{3}dots ) 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 t_0 and {displaystyle y(t_{0})}, and the derivative of y is a given function of t and y denoted as {displaystyle y'(t)=f{bigl (}t,y(t){bigr )}}. Begin the process by setting {displaystyle y_{0}=y(t_{0})}. Next, choose a value h for the size of every step and set t_{n}=t_{0}+nh (or equivalently t_{n+1}=t_{n}+h). Now, one step of the Euler method from t_{n} to t_{n+1} is:[3]

y_{n+1}=y_{n}+hf(t_{n},y_{n}).

The value of y_{n} is an approximation of the solution to the ODE at time t_{n}, i.e., y_{n}approx y(t_{n}). The Euler method is explicit, i.e. the solution y_{n+1} is an explicit function of y_{i} for ileq n.

Higher-order process[edit]

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

{displaystyle y^{(N)}(t)=fleft(t,y(t),y'(t),ldots ,y^{(N-1)}(t)right),}

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

{displaystyle {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}+hcdot y'_{i}\vdots \y_{i}^{(N-1)}+hcdot y_{i}^{(N)}\y_{i}^{(N)}+hcdot fleft(t_{i},y_{i},y'_{i},ldots ,y_{i}^{(N)}right)end{pmatrix}}}

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

Example[edit]

Given the initial value problem

y'=y,quad y(0)=1,

we would like to use the Euler method to approximate y(4).[5]

Using step size equal to 1 (h = 1)[edit]

(Figure 2) Illustration of numerical integration for the equation y'=y,y(0)=1. Blue is the Euler method; green, the midpoint method; red, the exact solution, y=e^{t}. The step size is h=1.0.

The Euler method is

{displaystyle y_{n+1}=y_{n}+hf(t_{n},y_{n}).}

so first we must compute f(t_{0},y_{0}). In this simple differential equation, the function f is defined by {displaystyle f(t,y)=y'}. We have

{displaystyle f(t_{0},y_{0})=f(0,1)=1.}

By doing the above step, we have found the slope of the line that is tangent to the solution curve at the point (0,1). Recall that the slope is defined as the change in y divided by the change in t, or {textstyle {frac {Delta y}{Delta t}}}.

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

{displaystyle hcdot f(y_{0})=1cdot 1=1.}

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

{displaystyle y_{0}+hf(y_{0})=y_{1}=1+1cdot 1=2.}

The above steps should be repeated to find y_{2}, y_{3} and y_{4}.

{begin{aligned}y_{2}&=y_{1}+hf(y_{1})=2+1cdot 2=4,\y_{3}&=y_{2}+hf(y_{2})=4+1cdot 4=8,\y_{4}&=y_{3}+hf(y_{3})=8+1cdot 8=16.end{aligned}}

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.

n y_{n} t_{n} f(t_{n},y_{n}) h Delta y y_{n+1}
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 y_{4}=16. The exact solution of the differential equation is y(t)=e^{t}, so y(4)=e^{4}approx 54.598. Although the approximation of the Euler method was not very precise in this specific case, particularly due to a large value step size h, its behaviour is qualitatively correct as the figure shows.

Using other step sizes[edit]

(Figure 3) The same illustration for h=0.25.

As suggested in the introduction, the Euler method is more accurate if the step size h 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 t=4 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]

Derivation[edit]

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

Another possibility is to consider the Taylor expansion of the function y around t_{0}:

{displaystyle y(t_{0}+h)=y(t_{0})+hy'(t_{0})+{tfrac {1}{2}}h^{2}y''(t_{0})+Oleft(h^{3}right).}

The differential equation states that y'=f(t,y). 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.

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

y'(t_{0})approx {frac {y(t_{0}+h)-y(t_{0})}{h}}

in the differential equation y'=f(t,y). Again, this yields the Euler method.[8] A similar computation leads to the midpoint method and the backward Euler method.

Finally, one can integrate the differential equation from t_{0} to t_{0}+h and apply the fundamental theorem of calculus to get:

{displaystyle y(t_{0}+h)-y(t_{0})=int _{t_{0}}^{t_{0}+h}f{bigl (}t,y(t){bigr )},mathrm {d} t.}

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

{displaystyle int _{t_{0}}^{t_{0}+h}f{bigl (}t,y(t){bigr )},mathrm {d} tapprox hf{bigl (}t_{0},y(t_{0}){bigr )}.}

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, y_{1}, and the exact solution at time t_{1}=t_{0}+h. The numerical solution is given by

{displaystyle y_{1}=y_{0}+hf(t_{0},y_{0}).}

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

{displaystyle y(t_{0}+h)=y(t_{0})+hy'(t_{0})+{tfrac {1}{2}}h^{2}y''(t_{0})+Oleft(h^{3}right).}

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

{displaystyle mathrm {LTE} =y(t_{0}+h)-y_{1}={tfrac {1}{2}}h^{2}y''(t_{0})+Oleft(h^{3}right).}

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

This shows that for small h, the local truncation error is approximately proportional to h^{2}. This makes the Euler method less accurate (for small h) than other 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 y has a continuous second derivative, then there exists a xi in [t_{0},t_{0}+h] such that

{displaystyle mathrm {LTE} =y(t_{0}+h)-y_{1}={tfrac {1}{2}}h^{2}y''(xi ).}[11]

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

{displaystyle y''(t_{0})={frac {partial f}{partial t}}{bigl (}t_{0},y(t_{0}){bigr )}+{frac {partial f}{partial y}}{bigl (}t_{0},y(t_{0}){bigr )},f{bigl (}t_{0},y(t_{0}){bigr )}.}

Global truncation error[edit]

The global truncation error is the error at a fixed time t_{i}, 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 {textstyle {frac {t_{i}-t_{0}}{h}}}, which is proportional to {textstyle {frac {1}{h}}}, and the error committed in each step is proportional to h^{2} (see the previous section). Thus, it is to be expected that the global truncation error will be proportional to h.[14]

This intuitive reasoning can be made precise. If the solution y has a bounded second derivative and f is Lipschitz continuous in its second argument, then the global truncation error (denoted as {displaystyle |y(t_{i})-y_{i}|}) is bounded by

{displaystyle |y(t_{i})-y_{i}|leq {frac {hM}{2L}}left(e^{L(t_{i}-t_{0})}-1right)}

where M is an upper bound on the second derivative of y on the given interval and L is the Lipschitz constant of f.[15] Or more simply, when {displaystyle y'(t)=f(t,y)}, the value {textstyle L={text{max}}{bigl (}{frac {d}{dy}}{bigl [}f(t,y){bigr ]}{bigr )}} (such that t is treated as a constant). In contrast, {textstyle M={text{max}}{bigl (}{frac {d^{2}}{dt^{2}}}{bigl [}y(t){bigr ]}{bigr )}} where function {displaystyle y(t)} is the exact solution which only contains the t 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 h. For this reason, the Euler method is said to be first order.[17]

Numerical stability[edit]

(Figure 4) Solution of y'=-2.3y computed with the Euler method with step size h=1 (blue squares) and h=0.7 (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

y'=-2.3y,qquad y(0)=1.

The exact solution is y(t)=e^{-2.3t}, which decays to zero as tto infty . However, if the Euler method is applied to this equation with step size h=1, 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 {displaystyle h=0.7}, 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 y'=ky, then the numerical solution is unstable if the product hk is outside the region

{displaystyle {bigl {}zin mathbf {C} ,{big |},|z+1|leq 1{bigr }},}

illustrated on the right. This region is called the (linear) stability region.[18] In the example, {displaystyle k=-2.3}, so if h=1 then hk=-2.3 which is outside the stability region, and thus the numerical solution is unstable.

This limitation — along with its slow convergence of error with h — means that the Euler method is not often used, except as a simple example of numerical integration[citation needed].

Rounding errors[edit]

In step n of the Euler method, the rounding error is roughly of the magnitude {displaystyle varepsilon y_{n}} where varepsilon is the machine epsilon. Assuming that the rounding errors are independent random variables, the expected total rounding error is proportional to {textstyle {frac {varepsilon }{sqrt {h}}}}.[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:

y_{n+1}=y_{n}+hf(t_{n+1},y_{n+1}).

This differs from the (standard, or forward) Euler method in that the function f 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 y_{n+1} 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:

{displaystyle y_{n+1}=y_{n}+hfleft(t_{n}+{tfrac {1}{2}}h,y_{n}+{tfrac {1}{2}}hf(t_{n},y_{n})right)}.

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:

y_{n+1}=y_{n}+{tfrac {3}{2}}hf(t_{n},y_{n})-{tfrac {1}{2}}hf(t_{n-1},y_{n-1}).

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

In popular culture[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]

  • Crank–Nicolson method
  • Gradient descent similarly uses finite steps, here to find minima of functions
  • List of Runge-Kutta methods
  • Linear multistep method
  • Numerical integration (for calculating definite integrals)
  • Numerical methods for ordinary differential equations

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): 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]

  • Atkinson, Kendall A. (1989). An Introduction to Numerical Analysis (2nd ed.). New York: John Wiley & Sons. ISBN 978-0-471-50023-0.
  • Ascher, Uri M.; Petzold, Linda R. (1998). Computer Methods for Ordinary Differential Equations and Differential-Algebraic Equations. Philadelphia: Society for Industrial and Applied Mathematics. ISBN 978-0-89871-412-8.
  • Butcher, John C. (2003). Numerical Methods for Ordinary Differential Equations. New York: John Wiley & Sons. ISBN 978-0-471-96758-3.
  • Hairer, Ernst; Nørsett, Syvert Paul; Wanner, Gerhard (1993). Solving ordinary differential equations I: Nonstiff problems. Berlin, New York: Springer-Verlag. ISBN 978-3-540-56670-0.
  • Iserles, Arieh (1996). A First Course in the Numerical Analysis of Differential Equations. Cambridge University Press. ISBN 978-0-521-55655-2.
  • Stoer, Josef; Bulirsch, Roland (2002). Introduction to Numerical Analysis (3rd ed.). Berlin, New York: Springer-Verlag. ISBN 978-0-387-95452-3.
  • Lakoba, Taras I. (2012), Simple Euler method and its modifications (PDF) (Lecture notes for MATH334), University of Vermont, retrieved 29 February 2012
  • Unni, M P. (2017). «Memory reduction for numerical solution of differential equations using compressive sensing». 2017 IEEE 13th International Colloquium on Signal Processing & its Applications (CSPA). IEEE CSPA. pp. 79–84. doi:10.1109/CSPA.2017.8064928. ISBN 978-1-5090-1184-1. S2CID 13082456.

External links[edit]

  • Media related to Euler method at Wikimedia Commons
  • Euler method implementations in different languages by Rosetta Code
  • «Euler method», Encyclopedia of Mathematics, EMS Press, 2001 [1994]

(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–1870).[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 A_{0}, is known (see Figure 1). Then, from the differential equation, the slope to the curve at A_{0} can be computed, and so, the tangent line.

Take a small step along that tangent line up to a point A_{1}. Along this small step, the slope does not change too much, so A_{1} will be close to the curve. If we pretend that A_{1} is still on the curve, the same reasoning as for the point A_{0} above can be used. After several steps, a polygonal curve (A_{0}A_{1}A_{2}A_{3}dots ) 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 t_0 and {displaystyle y(t_{0})}, and the derivative of y is a given function of t and y denoted as {displaystyle y'(t)=f{bigl (}t,y(t){bigr )}}. Begin the process by setting {displaystyle y_{0}=y(t_{0})}. Next, choose a value h for the size of every step and set t_{n}=t_{0}+nh (or equivalently t_{n+1}=t_{n}+h). Now, one step of the Euler method from t_{n} to t_{n+1} is:[3]

y_{n+1}=y_{n}+hf(t_{n},y_{n}).

The value of y_{n} is an approximation of the solution to the ODE at time t_{n}, i.e., y_{n}approx y(t_{n}). The Euler method is explicit, i.e. the solution y_{n+1} is an explicit function of y_{i} for ileq n.

Higher-order process[edit]

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

{displaystyle y^{(N)}(t)=fleft(t,y(t),y'(t),ldots ,y^{(N-1)}(t)right),}

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

{displaystyle {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}+hcdot y'_{i}\vdots \y_{i}^{(N-1)}+hcdot y_{i}^{(N)}\y_{i}^{(N)}+hcdot fleft(t_{i},y_{i},y'_{i},ldots ,y_{i}^{(N)}right)end{pmatrix}}}

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

Example[edit]

Given the initial value problem

y'=y,quad y(0)=1,

we would like to use the Euler method to approximate y(4).[5]

Using step size equal to 1 (h = 1)[edit]

(Figure 2) Illustration of numerical integration for the equation y'=y,y(0)=1. Blue is the Euler method; green, the midpoint method; red, the exact solution, y=e^{t}. The step size is h=1.0.

The Euler method is

{displaystyle y_{n+1}=y_{n}+hf(t_{n},y_{n}).}

so first we must compute f(t_{0},y_{0}). In this simple differential equation, the function f is defined by {displaystyle f(t,y)=y'}. We have

{displaystyle f(t_{0},y_{0})=f(0,1)=1.}

By doing the above step, we have found the slope of the line that is tangent to the solution curve at the point (0,1). Recall that the slope is defined as the change in y divided by the change in t, or {textstyle {frac {Delta y}{Delta t}}}.

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

{displaystyle hcdot f(y_{0})=1cdot 1=1.}

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

{displaystyle y_{0}+hf(y_{0})=y_{1}=1+1cdot 1=2.}

The above steps should be repeated to find y_{2}, y_{3} and y_{4}.

{begin{aligned}y_{2}&=y_{1}+hf(y_{1})=2+1cdot 2=4,\y_{3}&=y_{2}+hf(y_{2})=4+1cdot 4=8,\y_{4}&=y_{3}+hf(y_{3})=8+1cdot 8=16.end{aligned}}

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.

n y_{n} t_{n} f(t_{n},y_{n}) h Delta y y_{n+1}
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 y_{4}=16. The exact solution of the differential equation is y(t)=e^{t}, so y(4)=e^{4}approx 54.598. Although the approximation of the Euler method was not very precise in this specific case, particularly due to a large value step size h, its behaviour is qualitatively correct as the figure shows.

Using other step sizes[edit]

(Figure 3) The same illustration for h=0.25.

As suggested in the introduction, the Euler method is more accurate if the step size h 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 t=4 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]

Derivation[edit]

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

Another possibility is to consider the Taylor expansion of the function y around t_{0}:

{displaystyle y(t_{0}+h)=y(t_{0})+hy'(t_{0})+{tfrac {1}{2}}h^{2}y''(t_{0})+Oleft(h^{3}right).}

The differential equation states that y'=f(t,y). 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.

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

y'(t_{0})approx {frac {y(t_{0}+h)-y(t_{0})}{h}}

in the differential equation y'=f(t,y). Again, this yields the Euler method.[8] A similar computation leads to the midpoint method and the backward Euler method.

Finally, one can integrate the differential equation from t_{0} to t_{0}+h and apply the fundamental theorem of calculus to get:

{displaystyle y(t_{0}+h)-y(t_{0})=int _{t_{0}}^{t_{0}+h}f{bigl (}t,y(t){bigr )},mathrm {d} t.}

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

{displaystyle int _{t_{0}}^{t_{0}+h}f{bigl (}t,y(t){bigr )},mathrm {d} tapprox hf{bigl (}t_{0},y(t_{0}){bigr )}.}

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, y_{1}, and the exact solution at time t_{1}=t_{0}+h. The numerical solution is given by

{displaystyle y_{1}=y_{0}+hf(t_{0},y_{0}).}

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

{displaystyle y(t_{0}+h)=y(t_{0})+hy'(t_{0})+{tfrac {1}{2}}h^{2}y''(t_{0})+Oleft(h^{3}right).}

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

{displaystyle mathrm {LTE} =y(t_{0}+h)-y_{1}={tfrac {1}{2}}h^{2}y''(t_{0})+Oleft(h^{3}right).}

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

This shows that for small h, the local truncation error is approximately proportional to h^{2}. This makes the Euler method less accurate (for small h) than other 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 y has a continuous second derivative, then there exists a xi in [t_{0},t_{0}+h] such that

{displaystyle mathrm {LTE} =y(t_{0}+h)-y_{1}={tfrac {1}{2}}h^{2}y''(xi ).}[11]

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

{displaystyle y''(t_{0})={frac {partial f}{partial t}}{bigl (}t_{0},y(t_{0}){bigr )}+{frac {partial f}{partial y}}{bigl (}t_{0},y(t_{0}){bigr )},f{bigl (}t_{0},y(t_{0}){bigr )}.}

Global truncation error[edit]

The global truncation error is the error at a fixed time t_{i}, 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 {textstyle {frac {t_{i}-t_{0}}{h}}}, which is proportional to {textstyle {frac {1}{h}}}, and the error committed in each step is proportional to h^{2} (see the previous section). Thus, it is to be expected that the global truncation error will be proportional to h.[14]

This intuitive reasoning can be made precise. If the solution y has a bounded second derivative and f is Lipschitz continuous in its second argument, then the global truncation error (denoted as {displaystyle |y(t_{i})-y_{i}|}) is bounded by

{displaystyle |y(t_{i})-y_{i}|leq {frac {hM}{2L}}left(e^{L(t_{i}-t_{0})}-1right)}

where M is an upper bound on the second derivative of y on the given interval and L is the Lipschitz constant of f.[15] Or more simply, when {displaystyle y'(t)=f(t,y)}, the value {textstyle L={text{max}}{bigl (}{frac {d}{dy}}{bigl [}f(t,y){bigr ]}{bigr )}} (such that t is treated as a constant). In contrast, {textstyle M={text{max}}{bigl (}{frac {d^{2}}{dt^{2}}}{bigl [}y(t){bigr ]}{bigr )}} where function {displaystyle y(t)} is the exact solution which only contains the t 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 h. For this reason, the Euler method is said to be first order.[17]

Numerical stability[edit]

(Figure 4) Solution of y'=-2.3y computed with the Euler method with step size h=1 (blue squares) and h=0.7 (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

y'=-2.3y,qquad y(0)=1.

The exact solution is y(t)=e^{-2.3t}, which decays to zero as tto infty . However, if the Euler method is applied to this equation with step size h=1, 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 {displaystyle h=0.7}, 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 y'=ky, then the numerical solution is unstable if the product hk is outside the region

{displaystyle {bigl {}zin mathbf {C} ,{big |},|z+1|leq 1{bigr }},}

illustrated on the right. This region is called the (linear) stability region.[18] In the example, {displaystyle k=-2.3}, so if h=1 then hk=-2.3 which is outside the stability region, and thus the numerical solution is unstable.

This limitation — along with its slow convergence of error with h — means that the Euler method is not often used, except as a simple example of numerical integration[citation needed].

Rounding errors[edit]

In step n of the Euler method, the rounding error is roughly of the magnitude {displaystyle varepsilon y_{n}} where varepsilon is the machine epsilon. Assuming that the rounding errors are independent random variables, the expected total rounding error is proportional to {textstyle {frac {varepsilon }{sqrt {h}}}}.[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:

y_{n+1}=y_{n}+hf(t_{n+1},y_{n+1}).

This differs from the (standard, or forward) Euler method in that the function f 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 y_{n+1} 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:

{displaystyle y_{n+1}=y_{n}+hfleft(t_{n}+{tfrac {1}{2}}h,y_{n}+{tfrac {1}{2}}hf(t_{n},y_{n})right)}.

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:

y_{n+1}=y_{n}+{tfrac {3}{2}}hf(t_{n},y_{n})-{tfrac {1}{2}}hf(t_{n-1},y_{n-1}).

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

In popular culture[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]

  • Crank–Nicolson method
  • Gradient descent similarly uses finite steps, here to find minima of functions
  • List of Runge-Kutta methods
  • Linear multistep method
  • Numerical integration (for calculating definite integrals)
  • Numerical methods for ordinary differential equations

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): 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]

  • Atkinson, Kendall A. (1989). An Introduction to Numerical Analysis (2nd ed.). New York: John Wiley & Sons. ISBN 978-0-471-50023-0.
  • Ascher, Uri M.; Petzold, Linda R. (1998). Computer Methods for Ordinary Differential Equations and Differential-Algebraic Equations. Philadelphia: Society for Industrial and Applied Mathematics. ISBN 978-0-89871-412-8.
  • Butcher, John C. (2003). Numerical Methods for Ordinary Differential Equations. New York: John Wiley & Sons. ISBN 978-0-471-96758-3.
  • Hairer, Ernst; Nørsett, Syvert Paul; Wanner, Gerhard (1993). Solving ordinary differential equations I: Nonstiff problems. Berlin, New York: Springer-Verlag. ISBN 978-3-540-56670-0.
  • Iserles, Arieh (1996). A First Course in the Numerical Analysis of Differential Equations. Cambridge University Press. ISBN 978-0-521-55655-2.
  • Stoer, Josef; Bulirsch, Roland (2002). Introduction to Numerical Analysis (3rd ed.). Berlin, New York: Springer-Verlag. ISBN 978-0-387-95452-3.
  • Lakoba, Taras I. (2012), Simple Euler method and its modifications (PDF) (Lecture notes for MATH334), University of Vermont, retrieved 29 February 2012
  • Unni, M P. (2017). «Memory reduction for numerical solution of differential equations using compressive sensing». 2017 IEEE 13th International Colloquium on Signal Processing & its Applications (CSPA). IEEE CSPA. pp. 79–84. doi:10.1109/CSPA.2017.8064928. ISBN 978-1-5090-1184-1. S2CID 13082456.

External links[edit]

  • Media related to Euler method at Wikimedia Commons
  • Euler method implementations in different languages by Rosetta Code
  • «Euler method», Encyclopedia of Mathematics, EMS Press, 2001 [1994]

Понравилась статья? Поделить с друзьями:
  • Ошибка ман тга ebs 04476 09
  • Ошибка меткого стрелка
  • Ошибка мет на ивеко еврокарго
  • Ошибка ман тга ebs 04355 00
  • Ошибка мерседес спринтер p2463