11. Euler's Method - a numerical solution for Differential Equations (2024)

Why numerical solutions?

For many of the differential equations we need to solve in the real world, there is no "nice" algebraic solution. That is, we can't solve it using the techniques we have met in this chapter (separation of variables, integrable combinations, or using an integrating factor), or other similar means.

As a result, we need to resort to using numerical methods for solving such DEs. The concept is similar to the numerical approaches we saw in an earlier integration chapter (Trapezoidal Rule, Simpson's Rule and Riemann Sums).

Even if we can solve some differential equations algebraically, the solutions may be quite complicated and so are not very useful. In such cases, a numerical approach gives us a good approximate solution.

The General Initial Value Problem

We are trying to solve problems that are presented in the following way:

`dy/dx=f(x,y)`; and

`y(a)` (the inital value) is known,

where `f(x,y)` is some function of the variables `x`, and `y` that are involved in the problem.

Examples of Initial Value Problems

(a) `dy/dx=6-2y/x`

`y(3)=1`

(b) `dy/dx=(y ln y)/x`

`y(2)=e`

(c) `dy/dx=(50x^2-10y)/3`

`y(0)=0`

Note that the right hand side is a function of `x` and `y` in each case.

Let's now see how to solve such problems using a numerical approach.

Euler's Method

Euler's Method assumes our solution is written in the form of a Taylor's Series.

That is, we'll have a function of the form:

`y(x+h)` `~~y(x)+h y'(x)+(h^2y''(x))/(2!)` `+(h^3y'''(x))/(3!)` `+(h^4y^("iv")(x))/(4!)` `+...`

This gives us a reasonably good approximation if we take plenty of terms, and if the value of `h` is reasonably small.

For Euler's Method, we just take the first 2 terms only.

`y(x+h)` `~~y(x)+h y'(x)`

The last term is just `h` times our `dy/dx` expression, so we can write Euler's Method as follows:

`y(x+h)` `~~y(x)+h f(x,y)`

How do we use this formula?

We start with some known value for `y`, which we could call `y_0`. It has this value when `x=x_0`. (We make use of the initial value `(x_0,y_0)`.)

The result of using this formula is the value for `y`, one `h` step to the right of the current value. Let's call it `y_1`. So we have:

`y_1` `~~y_0+h f(x_0,y_0)`

where

`y_1` is the next estimated solution value;

`y_0` is the current value;

`h` is the interval between steps; and

`f(x_0,y_0)` is the value of the derivative at the starting point, `(x_0,y_0)`.

Next value: To get the next value `y_2`, we would use the value we just found for `y_1` as follows:

`y_2` `~~y_1+h f(x_1,y_1)`

where

`y_2` is the next estimated solution value;

`y_1` is the current value;

`h` is the interval between steps;

`x_1 = x_0+h`; and

`f(x_1,y_1)` is the value of the derivative at the current `(x_1,y_1)` point.

We continue this process for as many steps as required.

What's going on?

The right hand side of the formula above means, "start at the known `y` value, then move one step `h` units to the right in the direction of the slope at that point,which is `dy/dx = f(x,y)`. We will arrive at a good approximation to the curve's y-value at that new point."

We'll do this for each of the sub-points, `h` apart, from some starting value `x=a` to some finishing value, `x=b`, as shown in the graph below.

11. Euler's Method - a numerical solution for Differential Equations (1)

Let's see how it works with an example.

Example: Euler's Method

Let's solve example (b) from above. We had the initial value problem:

`dy/dx=(y ln y)/x`

`y(2)=e`

Step 1

We'll start at the point `(x_0,y_0)=(2,e)` and use step size of `h=0.1` and proceed for 10 steps. That is, we'll approximate the solution from `t=2` to `t=3` for our differential equation. We'll finish with a set of points that represent the solution, numerically.

We already know the first value, when `x_0=2`, which is `y_0=e` (the initial value).

We now calculate the value of the derivative at this initial point. (This tells us the direction to move.)

`dy/dx = f(2,e)` `=(e ln e)/2` ` = e/2~~1.3591409`

This means the slope of the line from `t=2` to `t=2.1` is approximately `1.3591409`.

Step 2

Now, for the second step, (since `h=0.1`, the next point is `x+h=2+0.1=2.1`), we substitute what we know into Euler's Method formula, and we have:

`y(x+h)` `~~y(x)+h f(x,y)`

`y_1 = y(2.1)` ` ~~ e + 0.1(e/2)` ` = 2.8541959`

This means the approximate value of the solution when `x=2.1` is `2.8540959`.

Let's see what we've done on a graph.

11. Euler's Method - a numerical solution for Differential Equations (2)

We'll need the new slope at this point, so we'll know where to head next.

`dy/dx = f(2.1,2.8541959)` `=(2.8541959 ln 2.8541959)/2.1` ` = 1.4254536`

This means the slope of the approximation line from `x=2.1` to `x=2.2` is `1.4254536`. So it's a little bit steeper than the first slope we found.

Step 3

Now we are trying to find the solution value when `x=2.2`. We substitute our known values:

`y(x+h)` `~~y(x)+h f(x,y)`

`y(2.2) ~~` ` 2.8540959 + 0.1(1.4254536)` ` = 2.99664126`

With this new value, our graph is now:

11. Euler's Method - a numerical solution for Differential Equations (3)

We'll need the new slope at this point, so we'll know where to head next.

`f(2.2,2.99664126)` `=(2.99664126 ln 2.99664126)/2.2` ` = 1.49490457`

This means the slope of the approximation line from `x=2.2` to `x=2.3` is `1.49490456`. So it's a little more steep than the first 2 slopes we found.

Step 4

Now we are trying to find the solution value when `x=2.3`. We substitute our known values:

`y(x+h)` `~~y(x)+h f(x,y)`

`y(2.3) ~~` ` 2.99664126 + 0.1(1.49490456)` ` = 3.1461317`

With this new value, our graph is now:

11. Euler's Method - a numerical solution for Differential Equations (4)

Subsequent Steps

We present all the values up to `x=3` in the following table.

Of course, most of the time we'll use computers to find these approximations. I used a spreadsheet to obtain the following values. Don't use your calculator for these problems - it's very tedious and prone to error. You could use an online calculator, or Google search.

`x``y``dy/dx`
2.0e = 2.7182818285(e ln e)/2 = 1.3591409142
2.1e+0.1(e/2) = 2.8541959199(2.8541959199 ln 2.8541959199)/2 = 1.4254536226
2.22.99674128211.4949999323
2.33.14624127541.5679341197
2.43.30303468731.6444180873
2.53.46747649611.7246216904
2.63.63993866511.8087230858
2.73.82081097371.8969091045
2.84.01050188411.9893756448
2.94.20943944862.08632809
3.04.4180722576

(There's no final `dy/dx` value because we don't need it. We've found all the required `y` values.)

Here is the graph of our estimated solution values from `x=2` to `x=3`.

11. Euler's Method - a numerical solution for Differential Equations (5)

How good is it?

This particular question actually is easy to solve algebraically, and we did it back in the Separation of Variables section. (It was Example 7.)

Our solution was `y = e^(x"/"2)`. In the next graph, we see the estimated values we got using Euler's Method (the dark-colored curve) and the graph of the real solution `y = e^(x"/"2)` in magenta (pinkish). We can see they are very close.

11. Euler's Method - a numerical solution for Differential Equations (6)

In this case, the solution graph is only slightly curved, so it's "easy" for Euler's Method to produce a fairly close result.

In fact, at `x=3` the actual solution is `y=4.4816890703`, and we obtained the approximation `y=4.4180722576`, so the error is only:

`(4.4816890703 - 4.4180722576)/4.4816890703` ` = 1.42%`.

Exercise

The following question cannot be solved using the algebraic techniques we learned earlier in this chapter, so the only way to solve it is numerically.

Solve using Euler's Method:

`dy/dx=sin(x+y)-e^x`

`y(0) = 4`

Use `h=0.1`

Answer

Step 1

We start at the initial value `(0,4)` and calculate the value of the derivative at this point. We have:

`dy/dx=sin(x+y)-e^x`

`=sin(0+4)-e^0`

`=-1.75680249531`

We substitute our starting point and the derivative we just found to obtain the next point along.

`y(x+h)~~y(x)+hf(x,y)`

`y(0.1)~~4+0.1(-1.75680249531)`

`~~3.82431975047`

Step 2

Now we need to calculate the value of the derivative at this new point `(0.1,3.82431975047)`. We have:

`dy/dx=sin(x+y)-e^x`

`=sin(0.1+3.82431975047)` `-e^0.1`

`=-1.8103864498`

Once again, we substitute our current point and the derivative we just found to obtain the next point along.

`y(x+h)~~y(x)+hf(x,y)`

`y(0.2)~~3.82431975047+` `0.1(-1.8103864498)`

`~~3.64328110549`

We proceed for the required number of steps and obtain these values:

`x``y``dy/dx`
04-1.7568024953
0.13.8243197505-1.8103864498
0.23.6432811055-1.8669109257
0.33.4565900129-1.926815173
0.43.2639084956-1.9907132334
0.53.0648371723-2.0594421065
0.62.8588929616-2.1341215746
0.72.6454808042-2.2162311734
0.82.4238576868-2.3077132045
0.92.1930863664-2.4111158431
11.9519747821

Here's the graph of this solution.

11. Euler's Method - a numerical solution for Differential Equations (7)

In the next section, we see a more sophisticated numerical solution method for differential equations, called the Runge-Kutta Method.


Need help solving a different Calculus problem? Try the Problem Solver.


Disclaimer: IntMath.com does not guarantee the accuracy of results. Problem Solver provided by Mathway.

11. Euler's Method - a numerical solution for Differential Equations (2024)

FAQs

What is Euler method to solve differential equation? ›

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). (Figure 1) Illustration of the Euler method.

Is Euler's method a numerical method? ›

It is but one of many methods for generating numerical solutions to differential equations. We choose it as the first numerical method to study because is relatively simple, and, using it, you will be able to see many of the advantages and the disadvantages of numerical solutions.

What is the exact solution in Euler's method? ›

In particular, Euler's method will only be exact if the solution is affine (of the form y=ax+b) so that all derivatives beyond the first derivative are zero.

What is Euler's equation in differential equation? ›

In mathematics, an Euler–Cauchy equation, or Cauchy–Euler equation, or simply Euler's equation is a linear hom*ogeneous ordinary differential equation with variable coefficients. It is sometimes referred to as an equidimensional equation.

What is the formula for the Euler's method? ›

What is Euler's method formula? The formula for Euler's method is y_{n+1} = y_n + h f(x_n, y_n). y_n represents the current value of a point on the solution, and y_{n+1} is the next value, for an increment in the x variable equal to the step size h.

What is Euler's formula used for? ›

What is Euler's Formula Used For? Euler's formula in geometry is used for determining the relation between the faces and vertices of polyhedra. And in trigonometry, Euler's formula is used for tracing the unit circle.

What is the numerical method of differential equations? ›

Numerical methods for ordinary differential equations are methods used to find numerical approximations to the solutions of ordinary differential equations (ODEs). Their use is also known as "numerical integration", although this term can also refer to the computation of integrals.

Why is Euler's method useful? ›

Euler's method is useful because differential equations appear frequently in physics, chemistry, and economics, but usually cannot be solved explicitly, requiring their solutions to be approximated.

What is the main disadvantage of Euler's method? ›

The advantage of using Euler's method is that it can be used to solve many nonlinear differential equations as well as linear differential equations. , ∆t, to use. You must also decide on a start value for t and for x. The disadvantage of using Euler's method is that you must use a small enough of a step size.

Is Euler's method an overestimate? ›

If a solution lies above, it is concave up. If a solution lies below, it is concave down. For any starting point of the form (x, y) where y > 0, Euler's method will produce an underestimate. For any starting point of the form (x, y) where y < 0, Euler's method will produce an overestimate.

What is the conclusion of the Euler method? ›

The method will provide error-free predictions if the solution of the differential equation is linear, because for a straight line the second derivative would be zero. This latter conclusion makes intuitive sense because Euler's method uses straight-line segments to approximate the solution.

What is the real part of Euler's formula? ›

Definition. Euler's Formula states that for any real x , eix=cosx+isinx, e i x = cos ⁡ x + i sin ⁡ where i is the imaginary unit, i=√−1 .

What is the Euler method of numerical methods? ›

In Euler's method, you can approximate the curve of the solution by the tangent in each interval (that is, by a sequence of short line segments), at steps of h . In general, if you use small step size, the accuracy of approximation increases.

What is Euler's theorem for differential calculus? ›

Euler's theorem is used to establish a relationship between the partial derivatives and the function product with its degree. A hom*ogeneous function of degree n, with x,y & z variables is a function in which all terms are of degree n.

How to know which method to use for differential equations? ›

  1. First-order separable ODEs (example: y' = y3cos(x)) can be solved by "separation of variables". ...
  2. First-order linear ODEs (example: y' = t y + t3) can be solved by any of three different methods: a direct formula, "integrating factors", or "variation of parameters".
Oct 12, 2023

What is the idea behind the Euler method? ›

Euler's method is based on the idea of approximating a curve using tangent lines. The tangent line to a curve at a point is the line that touches the curve at that point and has the same slope as the curve at that point. We can use the slope of the tangent line to estimate the slope of the curve at that point.

What is the Euler formula in differential geometry? ›

(Euler formula): If G is a plane graph with p vertices, q edges, and r faces, then p − q + r = 2. The above result is a useful and powerful tool in proving that certain graphs are not planar.

Which method is used to solve differential equations? ›

For some differential equations, application of standard methods—such as the Euler method, explicit Runge–Kutta methods, or multistep methods (for example, Adams–Bashforth methods)—exhibit instability in the solutions, though other methods may produce stable solutions.

What is the statement of Euler's method? ›

Euler's Method (The Math)

Sinc the number of steps over the whole interval is proportional to 1/h (or O(h-1)) we might expect the overall accuracy to be the O(h2)·O(h-1)=O(h). A rigourous analysis proves that this is true.

References

Top Articles
Latest Posts
Article information

Author: Madonna Wisozk

Last Updated:

Views: 6090

Rating: 4.8 / 5 (48 voted)

Reviews: 87% of readers found this page helpful

Author information

Name: Madonna Wisozk

Birthday: 2001-02-23

Address: 656 Gerhold Summit, Sidneyberg, FL 78179-2512

Phone: +6742282696652

Job: Customer Banking Liaison

Hobby: Flower arranging, Yo-yoing, Tai chi, Rowing, Macrame, Urban exploration, Knife making

Introduction: My name is Madonna Wisozk, I am a attractive, healthy, thoughtful, faithful, open, vivacious, zany person who loves writing and wants to share my knowledge and understanding with you.