##### Related Content

# Euler's Method Calculator

*y '*=

*f(*

*t*,

*y*) =

*t*=

_{0}*y*=

_{0}*t*) =

*n*) =

*y*(

*t*) =

_{target}*y*( )

*y*= ...

_{i+1}**Voovers+ Full Solution Steps Preview:**

## Euler's Method Lesson

#### Lesson Contents

### What is Euler's Method?

**Euler’s Method is an iterative procedure for approximating the solution to an ordinary differential equation (ODE) with a given initial condition.**

Euler’s method is particularly useful for approximating the solution to a differential equation that we may not be able to find an exact solution for. Since this is a numerical method that uses several iterations to approach a final approximation, computers are great tools for utilizing this approach as they can carry out a large number of calculations very quickly as you may have already seen with the Euler’s Method Calculator found above.

### Why do we Learn Euler's Method?

We learn Euler’s method as a foundation for solving ordinary differential equations numerically. **However, it is so powerful and flexible that we can also utilize it for high-level engineering feats such as the optimization of a fighter jet’s wing design.**

water vapor during hard maneuvering

Fighter jets (like the F-22 shown above) are designed to operate across an extremely wide variety of flight conditions. Since the wings generate the massive amount of lift required for hard aerial maneuvers, we must calculate the forces that air imparts on them as the jet flies. Ideally, we will use a computer to calculate these forces for all foreseen flight conditions and tweak the wing’s design accordingly.

There is an extremely useful set of equations in engineering called the *Navier–Stokes equations*, which are based on the laws of conservation of momentum and conservation of mass. These equations can tell us how a fluid (air in this case) behaves as it flows. They are commonly utilized in *computational fluid dynamics (CFD)*, which is a simulation method used by computer software that allows one to import the wing’s geometry for design optimizations.

The Navier-Stokes equations form a system of partial differential equations. However, we can reduce them down into ordinary differential equations and format Euler’s method to solve this newly created system of ordinary differential equations.

By programming this routine into a computer’s CFD software, we can input our flight condition parameters, quickly get outputs for how the wings perform under those conditions, tweak the design, and re-run the solver. When we have iterated to the point of satisfactory optimization, we will have a high-performance fighter jet wing design!

### How does Euler's Method Work?

Below, we have a basic graph of some function *y*(*t*).

In this case, we do not know what the exact solution is. However, we can use Euler’s Method to approximate the solution at a point of interest. We begin at a given a set of initial conditions in the form of an initial *t* value (*t*_{0}), an initial y value (*y _{0}*), and a function

*y’*that can be identified as a function of

*t*and

*y*. In other words, this function

*y*‘ =

*f*(

*t, y*). Using this given information in conjunction with the Euler’s Method equation (Equation 1), we can model a tangent line (as seen in Figure 1) that will allow us to begin approximating the solution curve. This is an iterative process where we calculate intermediate

*t*and

*y*values based on a specified step size (Δ

*t*) until we reach our desired end value in the form of a

*y*value at some

*t*value we will call

*t*. In other words, we are solving for

_{target}*y*(

*t*).

_{target}Now let’s take a look at the Euler’s Method Equation:

$$\begin{align} & y_{i+1} = y_{i} + f (t_{i}, y_{i})\Delta t \hspace{7ex} \text{(1)} \end{align}$$

Where *f* (*t _{i}*,

*y*) is a function of

_{i}*t*and

*y*that characterizes the slope of the tangent line at coordinates (

*t*,

_{i}*y*),

_{i}*t*is the

_{i}*t*coordinate at the current point,

*y*is the

_{i}*y*coordinate at the currrent point, and

*y*is the

_{i+1}*y*coordinate at the next point.

Now, you might be wondering why or how the tangent line is modeled from the Euler’s Method equation. To answer that, we will review the point-slope form equation (Equation 2):

$$\begin{align} & y_{1} \: – \: y_{0} = m (x_{1} \: – \: x_{0}) \hspace{7ex} \text{(2)} \end{align}$$

Where m is the slope, *x _{0}* is the

*x*coordinate at the first point,

*x*is the

_{1}*x*coordinate at the second point,

*y*is the

_{0}*y*coordinate at the first point, and

*y*is the

_{1}*y*coordinate at the second point.

If you see the similarities between the Euler’s Method equation and the point-slope form of a line, it is because Equation 1 is essentially the point-slope form equation of a line. This is what allows us to model tangent lines for the approximation of subsequent *y* values. If our step size (Δ*t*) is sufficiently small, that would mean that as we move along the tangent line from *t _{0}* to

*t*, the

_{1}*y*value on the tangent line at

*t*is fairly close to the

_{1}*y*value on the solution curve at

*t*, making

_{1}*y*a reasonable approximation. This process is repeated until the desired target

_{1}*y*value is reached at

*t*.

_{target}Now that we have some background information on Euler’s Method, let’s learn how to utilize it to approximate a solution in the next section.

### How to use Euler's Method to Approximate a Solution

Let’s say we have the following givens:

*y’ = *2*t *+ *y *and *y*(1) = 2

And we want to use Euler’s Method with a step size, of Δ*t* = 1 to approximate *y*(4).

To do this, we begin by recalling the equation for Euler’s Method:

$$\begin{align} & y_{i+1} = y_{i} + f (t_{i}, y_{i})\Delta t\end{align}$$

Where *f* (*t _{i}*,

*y*) is a function of

_{i}*t*and

*y*that characterizes the slope of the tangent line at coordinates (

*t*,

_{i}*y*),

_{i}*t*is the

_{i}*t*coordinate at the current point,

*y*is the

_{i}*y*coordinate at the current point,

*y*is the

_{i+1}*y*coordinate at the next point, and

*Δt*is the step size.

NOTE: If you are given number of steps (*n*) instead of step size (Δ*t*), you can calculate the step size with Equation 3:

$$\begin{align} & \Delta t = \frac{t_{target} \: – \: t_{0}}{n} \hspace{7ex} \text{(3)}\end{align}$$

Where Δ*t* is the step size, *t _{target}* is the

*t*value that we are interested in using to find our target

*y*value,

*t*is our initial

_{0}*t*value, and

*n*is the number of steps.

Now, let’s create a basic table that we can enter our data into as we go along:

i | t_{i} | y_{i} |
---|---|---|

0 | t = 1_{0} | y = 2_{0} |

1 | t = _{1}t + Δ_{0}t = 2 | y = _{1}y + _{0}f (t, _{0}y)Δ_{0}t |

2 | t = _{2}t + Δ_{1}t = 3 | y = _{2}y + _{1}f (t, _{1}y)Δ_{1}t |

3 | t = _{3}t + Δ_{2}t = 4 | y = _{3}y + _{2}f (t, _{2}y)Δ_{2}t |

The table is laid out such that the first column serves as the index for each row, the second column contains all of the *t* values beginning with *t _{0}* and indexing by Δt until we reach our desired

*t*value (

_{target}*t*= 4 in this demonstration), and the third column is where we track our

_{target}*y*values beginning with

*y*and ending where we get the

_{0}*y*value that corresponds with

*t*.

_{target}Let’s begin adapting the Euler’s Method Equation to our example and begin approximating:

As a reminder our givens were:

*y*‘ = *f *(*t, y*) = 2*t* + *y, *t_{0} = 1, *y*_{0} = 2, and Δ*t *= 1

### Example Problem 1

### Example Problem 2

## How the Calculator Works

The Euler’s Method Calculator was developed using HTML (Hypertext Markup Language), CSS (Cascading Style Sheets), and JS (JavaScript). The HTML portion of the code creates the framework of the calculator. This is what defines various entities such as the calculator space, solution box, and table space.

CSS is then utilized for the aesthetic design of these elements. This includes everything from the size and shape of the calculator, to the convenient scroll bars that allow the user to view all of their custom solution text without taking up any more space on the webpage than necessary.

JavaScript is used to provide functionality to the built-in calculator keys, perform the Euler’s Method approximation of the user’s input functions and conditions, and dynamically build the table of values that can be copied with the single click of a button. Once copied, the user can simply paste the table into a spreadsheet or text document and retain the original row and column structure from the calculator page.

All of these different elements come together to produce a highly detailed and intuitive experience that helps the user understand the concepts more easily.