Tip:
Highlight text to annotate it
X
.
.
In this segment, we will solve
an example for the Runge-Kutta fourth-order method.
.
And this example we have taken as the same example
for other methods for solving ordinary differential equations.|So this example says,
hey, you are given dy by dx is equal to 3 e to the power minus x,
minus 0.4 times y, and you are given the initial
condition at 0, and that's given as 5, and they're saying that find
y of 3, so you're asked to find out the value of y at 3, the dependent
variable, using a step size of, using h equal to 1.5,
which simply implies that you will have to take two steps to reach 3, because you're going to start form 0,
you'll take the first step, that'll be 1.5, and the second step will take you to the value of
x equal to 3.|So let's go ahead and see that how we're going to be able to solve this particular
problem by using the Runge-Kutta fourth-order method.|To review what the Runge-Kutta fourth-order method is
saying is that y-sub-i-plus-1, which is the point ahead, is given by
the value of y at the point where you are, plus 1 divided by 6,
k1 plus k2 plus k3 . . .
2 k2 plus 2 k3 plus k4, times h, where
k1 is the value of the function at xi, comma, yi.
k2 is the value of the function at xi
plus 1/2 h, yi plus 1/2
k1 h.|So you're using the slope
of k1 to calculate some approximate value of y at this value of x.
Same thing we're doing with k3, you are again calculating some value of the function, f,
at the halfway midpoint, but the value of y which
you are using is now the new value of slope which got for k2,
And k4 is the value of the function, f, calculated at the point where you want to go, which is the
xi plus 1, or xi plus h, in this case, and the corresponding
value of y is calculated by using yi plus
k3 times h
as the point.|So let's go ahead and take this formula, solve this particular . . .
solve this particular ordinary differential equation which we are asked to do.|So we're
going to solve this differential equation using h equal to 1.5, use this RK4
formulas which we are given to calculate the value of y of 3.
So if you look at what I'm going to do is I'm going to assume i is equal to 0,
and then, in that case, x0 is 0 and y0 is 5,
and how do I get that?|It's because initial condition is given at 0, and the corresponding value of y at that
initial condition is given to be 5, so that's how I will say x0 is 0 and
y0 is 5.|So in order to be able to calculate the value of y at
a step ahead, h is 1.5, which is given to me, so I want to be able to calculate the value of the
y at a step ahead, which will be 0 plus 1.5, which will be 1.5.
I need to calculate the values of k1, k2, k3, and k4.|So k1 is nothing but the value of the
function of . . . function, f, at x0, comma, y0, x0 is 0,
y0 is 5, so that makes it 3 e to the power -0
minus 0.4 times 5, and that turns out to be 1.|So that's the
value of k1 which I get.|Similarly, the value of k2 which I get is
the value of the function, f, in the midpoint, x0
plus 1/2 h, y0 plus 1/2 k1 h,
and k1 is something which I just calculated, which turned out to be 1 in this case.
So this is the value of the function, f, x0 is 0, h is 1.5,
y0 is 5, plus 1/2 k1 is 1, h is 1.5,
and this turns out to be the value of the function at
0.75, 5.75.|So what this basically means is that
this is the value of x at which we want to calculate the value of the slope, and this gives us some
approximate value of y so that we can calculate the value of the function, f.|So this is
3 e to the power minus x, which is -0.75, minus
0.4 times y, which is 5.75, and
this value here turns out to be -0.8829.
So we still have to calculate two more values of k,
which is k3 and k4, so let's go ahead and do that on the next board here.
k3 is the value of the function at, again, at some point,
midpoint between x0 and x1, and the corresponding value of
y is now calculated by the refined value of the slope, which is k2
now, and that's why it is half of h, because we are 1/2 h
ahead of x, and k2 is the slope, it is sort of an Euler's formula which you
are using the calculate this approximate value of y so that you can calculate the value of the function, f.
x0 is 0, h is 1.5, y0 is 5,
plus 1/2 k2 I just calculated to be -0.8829,
times h, which is 1.5.
And the value of the function is to be calculated at
0.75 and 4.338,
and that turns out to be 3 e to the power minus x, which is 0.75,
minus 0.4 times y, which is 4.338,
and this value here turns out to be equal to -1.140.
So that's what I get as the value of k3.|Similarly, I need to calculate
the value of k4, it is the last k value which I have to calculate, the last slope which I have to calculate of y as
a function of x, given by the function, f, is the value of the function,
f, at the point where I want to go, which is x0 plus h, and this one is
given as y0 plus k3 h,
and what is x0?|x0 is 0, h is 1.5, y0 is 5,
k3 I just calculated as -1.140, that's right there, and
h is 1.5, so that gives the value of the function which I need to calculate
at 1.5 and 4.523.
So that's where I have to calculate the value of k4, by the arguments of
x being 1.5, y being 4.523, and that value turns out to be
-1.140.
This k3, I think I made a mistake here, this one, this
value here is -0.3180.
So that's how we get the value of k3 and k4 and k1 and k2, so we have
all the values of k1, k2, k3, and k4.|I'm going to write those down, just for
refreshing your memory, that k1, which we obtained, was 1,
k2 we obtained was -0.8829,
k3, which we just obtained, was -0.3180,
k4, which we just obtained, was -1.140.
So we're going to calculate y1
now, y1 will be y0, plus 1 by 6, k1
plus 2 k2 plus 2 k3 plus k4, times h.
So this turns out to be y0 is 5,
k1, which we just got 1, 2 times k2 is
-0.8829, plus 2 times k3, which is
-0.3180, plus k4, which is -1.140,
times h, which is 1.5, and when you
calculate this value, you get 4.365.|So this is the
approximate value of y at x1, and what is x1?|xi is nothing but x0
plus h, x0 being 0, h being 1.5, so that gives you
1.5, so y at x1, which is same as
y at 1.5, has approximately been calculated as
4.365.|However, this is not the value which we are looking for, we're looking for the value of y
at 3, and we'll show that in the next segment.|And this is the end of
this segment.
.
.