Index

  1. 1. Euler’s Method
  2. 2. Runge-Kutta Method (or Euler’s Modified Method)

1. Euler’s Method

https://www.youtube.com/watch?v=ukNbG7muKho

Concept

Euler’s method is the simplest numerical method for solving an initial value problem of the form:

It approximates the solution by moving a small step size forward in time and using the derivative to update the value of .


Formula

If you know and want to compute with a step :

where is the step size.


Pros and Cons

  • Pros:

    • Very simple to implement.
  • Cons:

    • It is only first-order accurate (error is proportional to ); hence, for a given step size , it may not be very accurate.
    • It may require very small step sizes to achieve acceptable accuracy, increasing computational cost.

Example 1

So let’s say we have this equation and it’s derivative :

Note that this is an explicit equation, so we need to find out the derivative ourselves.

We need to approximate the value of when .

So, since this method requires very small step sizes for good accuracy, let’s set :

Another of finding the step size would be:

First, let and the starting point (since we take ) as the initial points

So if we took ,

then :

which results in a more precise step size, so we might get a more precise value if we use this step size.

But for consistency with the example in the video, we will use .

So here :

So since our equation depends on , so we will use the equation :

So let’s create a table first :

nActual value

And start off with the initial point P(1,1), where and and .

nActual value
011

Here

So the value of will increase by the step size.

Now we use the equation :

to predict the values for the next iterations.

We will continue till , that way we get the value till or iterations.

So, for ,

nActual value
011
11.11.2

Next, for

nActual value
011
11.11.2
21.21.42
31.3
41.4
51.5

Next, for

nActual value
011
11.11.2
21.21.42
31.31.66
41.4
51.5

Next, for

nActual value
011
11.11.2
21.21.42
31.31.66
41.41.92
51.5

Now, for

nActual value
011
11.11.2
21.21.42
31.31.66
41.41.92
51.52.2

Now, time to find out the actual values per value of

So we will use the original equation, .

So,

nActual value
0111
11.11.2
21.21.42
31.31.66
41.41.92
51.51.1

nActual value
0111
11.11.21.21
21.21.421.44
31.31.661.69
41.41.921.96
51.52.22.25

So, we get our final approximation of as , which is real close to the actual value,

What is the “actual value” btw?

In the cases of ODEs and not explicit equations, it’s used to update the value of , but it’s not considered the actual approximation itself.

So our final answer will be .


Example 2

https://www.youtube.com/watch?v=U8-4HLKtmDM&list=PLU6SqdYcYsfLrTna7UuaVfGZYkNo0cpVC&index=10

Note that this is NOT an explicit equation, but rather an ODE, so we don’t need to find out the derivative ourselves.

In this case, the formula becomes :

Since our given is already the derivative itself.

So we are given a starting condition as :

and and we need to find at

Let’s compute till .

So the step size will be :

So using that we construct our table:

n
0011
10.021.021.04
20.041.041.08
30.061.061.12
40.081.081.16
50.11.111.21

I got the values early on since I made a program to calculate all this

[[0, 0, 1, 1]]
[[1, 0.02, 1.0204, 1.0404]]
[[2, 0.04, 1.0416079999999999, 1.081608]]
[[3, 0.06, 1.0636401599999998, 1.1236401599999999]]
[[4, 0.08, 1.0865129632, 1.1665129632]]
[[5, 0.1, 1.110243222464, 1.210243222464]]
The value of y at x = 0.1 is: 1.110243222464 

However I will do some of them by hand to clear up any confusion.

So for

Similarly for

And so on… I assume you can do the rest of the calculations by yourself.

So the final approximation of is . And the value in the video was obtained as is due to precision differences.


2. Runge-Kutta Method (or Euler’s Modified Method)

This method is used for 2nd order differential equations.

This is based upon Euler’s method by modifying it.

(obtained by using Euler’s method)

then, we use this to get :

Example 1:

Let’s say we have :

Another ODE, not an explicit equation.

We are given the starting conditions as which means :

And we are asked to find the value of at and

So if we continue till , then the step size, will can be taken for simplicity purposes as :

Since we will be finding for two values and the difference between then is so for simplicity purposes we can take

Or for better accuracy we can :

Let’s find out which step size leads to more precise answer :

So, at

We will have our table as :

n
0011
10.02
20.04
30.06
40.08
50.10

We see that we can get the required values at a lesser number of iterations if we use

And

Now at

Now,

n
0011
10.021.0202040.0020204
20.041.0308302820.0106262816
30.06
40.08
50.10

So we have our as and