MATH 334 - DIFFERENTIAL
EQUATIONS - Runge-Kutta methods
Question Bank - Set 2
Liberty University
Question 1
Question
Consider the initial value problem
dy
dx =x2−y2, y(0) = 1.
Use the fourth-order Runge-Kutta method to approximate y(0.2) with a step
size of h= 0.1.
Solution
To approximate y(0.2) using the fourth-order Runge-Kutta method, we first
need to calculate intermediate values using the following steps:
Step 1: Calculate k1,k2,k3, and k4.
k1=h·f(xn, yn)=0.1·(02−12) = −0.1,
k2=h·f(xn+h
2, yn+k1
2)
= 0.1·(0.052−0.52)≈ −0.124375,
k3=h·f(xn+h
2, yn+k2
2)
= 0.1·(0.12−0.56218752)≈ −0.1322098,
k4=h·f(xn+h, yn+k3)=0.1·(0.22−0.69466252)≈ −0.096695.
Step 2: Calculate the next approximation yn+1.
yn+1 =yn+1
6(k1+ 2k2+ 2k3+k4)
= 1 + 1
6(−0.1 + 2(−0.124375) + 2(−0.1322098) −0.096695)
≈0.8271489.
Therefore, the fourth-order Runge-Kutta approximation for y(0.2) is y(0.2) ≈
0.8271489.
Question 2
Question
Use the fourth-order Runge-Kutta method to approximate the solution of the
initial value problem
y′= 2y−x, y(0) = 1
at x= 0.2. Use step size h= 0.1.
Solution
Let’s denote f(x, y)=2y−xand h= 0.1. We will apply the fourth-order
Runge-Kutta method to approximate the solution at x= 0.2.
Step 1: Calculate k1,k2,k3, and k4using the formulas:
k1=hf(xn, yn)
k2=hf(xn+h
2, yn+k1
2)
k3=hf(xn+h
2, yn+k2
2)
k4=hf(xn+h, yn+k3)
Substitute f(x, y) = 2y−x,h= 0.1, x0= 0, and y0= 1:
k1= 0.1(2 ·1−0) = 0.2
k2= 0.1(2 ·1−0.05) = 0.195
k3= 0.1(2 ·1−0.0475) = 0.19525
k4= 0.1(2 ·1−0.1) = 0.19
Step 2: Calculate the weighted average for the final approximation:
yn+1 =yn+1
6(k1+ 2k2+ 2k3+k4)
Substitute the values we calculated:
y1= 1 + 1
6(0.2+2·0.195 + 2 ·0.19525 + 0.19)
y1= 1 + 1
6(0.2+0.39 + 0.3905 + 0.19)
y1= 1 + 1
6(1.1705)
2
y1= 1 + 0.1950833
y1≈1.1951
Therefore, the fourth-order Runge-Kutta method approximates the solution
at x= 0.2 to be y≈1.1951.
Question 3
Question
Consider the initial value problem
dy
dx =y−x2+ 1, y(0) = 0,
and approximate y(1) using the fourth-order Runge-Kutta method with step
size h= 0.2.
Solution
Given the initial value problem, we can apply the fourth-order Runge-Kutta
method to approximate y(1) with step size h= 0.2. The formula for the method
is as follows:
k1=h(f(xn, yn)),
k2=h(f(xn+h
2, yn+k1
2)),
k3=h(f(xn+h
2, yn+k2
2)),
k4=h(f(xn+h, yn+k3)),
yn+1 =yn+1
6(k1+ 2k2+ 2k3+k4),
where f(x, y) = y−x2+ 1, y0= 0, and h= 0.2. We will approximate y(1) using
this method.
Step 1: Calculate the values of k1,k2,k3, and k4.
k1= 0.2(f(0,0)) = 0.2(0 −02+ 1) = 0.2,
k2= 0.2(f(0 + 0.2
2,0 + 0.2
2)) = 0.2(0 −0.12+ 1) ≈0.195,
k3= 0.2(f(0 + 0.2
2,0 + 0.195
2)) = 0.2(0 −0.052+ 1) ≈0.1975,
k4= 0.2(f(0 + 0.2,0+0.1975)) = 0.2(0.1975 −0.22+ 1) ≈0.1965.
Step 2: Use the values of k1,k2,k3, and k4to find yn+1.
y1≈0 + 1
6(0.2 + 2(0.195) + 2(0.1975) + 0.1965) ≈0.31425.
Therefore, the approximate value of y(1) using the fourth-order Runge-Kutta
method with h= 0.2 is 0.31425.
3
Question 4
Question
Consider the initial value problem dy
dx =x2−ywith y(0) = 1. Use the 4th-order
Runge-Kutta method to approximate y(1) with step size h= 0.2.
Solution
Step 1: Define the function f(x, y) = x2−y.
Step 2: Calculate the increments k1,k2,k3, and k4using the Runge-Kutta
formula: k1=hf(xn, yn)
k2=hf(xn+h
2, yn+k1
2)
k3=hf(xn+h
2, yn+k2
2)
k4=hf(xn+h, yn+k3)
where xn= 0 and yn= 1.
Step 3: Use the increments to update the approximation:
yn+1 =yn+1
6(k1+ 2k2+ 2k3+k4)
Step 4: Repeat the process for each step until x= 1 is reached.
Step 5: Calculate the approximation for y(1) using the above method.
Now, let’s solve the problem using the above steps.
Step 1: The function f(x, y) = x2−y.
Step 2: Calculating the increments:
k1= 0.2(02−1) = −0.2
k2= 0.20 + 0.2
2,1 + −0.2
2= 0.18
k3= 0.20 + 0.2
2,1 + 0.18
2= 0.176
k4= 0.2 (0 + 0.2,1+0.176) = 0.2352
Step 3: Updating the approximation:
yn+1 = 1 + 1
6(−0.2+2∗0.18 + 2 ∗0.176 + 0.2352) ≈1.2357
Therefore, using the 4th-order Runge-Kutta method with step size h= 0.2,
we approximate y(1) ≈1.2357.
4
Question 5
Question
Consider the initial value problem:
dy
dx =x2−y, y(0) = 1.
Apply the classical fourth-order Runge-Kutta method to approximate the value
of y(1) using a step size of h= 0.2.
Solution
To solve this problem using the classical fourth-order Runge-Kutta method, we
will follow these steps:
Step 1: Define the function and initialize variables.
Given ODE: dy
dx =x2−y, y(0) = 1
Step size:h= 0.2
Number of steps:n=1
h= 5
Initial condition:y0= 1
Initialize:x0= 0
Step 2: Perform iterations using the Runge-Kutta method.
For i= 1,2, . . . , n :
k1=h·(x2
i−1−yi−1)
k2=h·((xi−1+h
2)2−(yi−1+k1
2))
k3=h·((xi−1+h
2)2−(yi−1+k2
2))
k4=h·((xi−1+h)2−(yi−1+k3))
yi=yi−1+1
6·(k1+ 2k2+ 2k3+k4)
xi=xi−1+h
Step 3: Calculate the approximate value of y(1) using the Runge-Kutta
method. After performing the iterations, we find y(1) ≈0.381417.
5
Question 6
Question
Consider the initial value problem
(y′= 2xy +y2,
y(0) = 1.
Use a fourth-order Runge-Kutta method to estimate y(0.2) with step size h=
0.1.
Solution
Step 1: Define the function f(x, y) based on the given differential equation:
f(x, y) = 2xy +y2.
Step 2: Implement the fourth-order Runge-Kutta method with the given
step size h= 0.1:
k1 = h·f(0,1) = 0.1·(2 ·0·1+12)=0.1,
k2 = h·f(0.05,1+0.5·k1) = 0.1·2·(0.05)(1 + 0.5·0.1) + (1 + 0.5·0.1)2≈0.123,
k3 = h·f(0.05,1+0.5·k2) = 0.1·2·(0.05)(1 + 0.5·0.123) + (1 + 0.5·0.123)2≈0.145,
k4 = h·f(0.1,1 + k3) = 0.1·2·0.1·(1 + 0.145) + (1 + 0.145)2≈0.202.
Step 3: Calculate the estimated value of y(0.2) using the weighted average:
y(0.2) ≈1 + 1
6·(0.1+2·0.123 + 2 ·0.145 + 0.202) ≈1.254.
Therefore, the estimate of y(0.2) using the fourth-order Runge-Kutta method
with step size h= 0.1 is approximately 1.254.
Question 7
Question
Use the fourth-order Runge-Kutta method to approximate the solution to the
initial value problem:
dy
dx =x2+y, y(0) = 1
Calculate an approximation to y(0.1) using a step size of h= 0.02.
6
Solution
Step 1: Define the function f(x, y) based on the given differential equation:
f(x, y) = x2+y
Step 2: Implement the fourth-order Runge-Kutta method to approximate
y(0.1) using the given initial condition y(0) = 1 and step size h= 0.02.
k1=hf(0,1) = 0.02[(0)2+ 1] = 0.02
k2=hf 0 + h
2,1 + k1
2= 0.02 "0+0.02
22
+1+0.02/2
2#= 0.0201
k3=hf 0 + h
2,1 + k2
2= 0.02 "0+0.02
22
+1+0.0201/2
2#= 0.020101
k4=hf(0 + h, 1 + k3)=0.02[(0.02)2+ 1 + 0.020101] = 0.020605
Step 3: Calculate the weighted average of the k’s to find the approximation:
y(0.02) = 1 + 1
6(0.02 + 2(0.0201) + 2(0.020101) + 0.020605)
= 1 + 1
6(0.020 + 0.0402 + 0.040202 + 0.020605)
= 1 + 1
6(0.120807)
≈1.0201345
Therefore, the approximate value of y(0.1) using the fourth-order Runge-
Kutta method with a step size of 0.02 is approximately 1.0201345.
Question 8
Question
Consider the following initial value problem:
dy
dx =x2−y, y(0) = 1
Approximate the value of y(1) using the fourth-order Runge-Kutta method with
a step size of h= 0.2.
Solution
To approximate the value of y(1) using the fourth-order Runge-Kutta method,
we will iterate through the following steps:
Step 1: Define the function f(x, y) = x2−y.
7
Step 2: Set h= 0.2, x0= 0, y0= 1, and x1= 1.
Step 3: Calculate the intermediate values k1,k2,k3, and k4using the
formulas: k1=h·f(x0, y0)
k2=h·f(x0+h
2, y0+k1
2)
k3=h·f(x0+h
2, y0+k2
2)
k4=h·f(x0+h, y0+k3)
Step 4: Calculate the approximated value of y1at x1using the formula:
y1=y0+1
6(k1+ 2k2+ 2k3+k4)
Step 5: Substitute the given values into the formulas and compute the final
approximated value of y(1):
k1= 0.2·(02−1) = −0.2
k2= 0.2·(0.12−0.9) = −0.196
k3= 0.2·(0.12−0.9) = −0.196
k4= 0.2·(0.22−0.8) = −0.184
y1= 1 + 1
6(−0.2 + 2(−0.196) + 2(−0.196) −0.184) = 0.8128
Therefore, the approximate value of y(1) using the fourth-order Runge-Kutta
method with a step size of h= 0.2 is y(1) ≈0.8128.
Question 9
Question
Use the Runge-Kutta method of order 4 to approximate the solution to the
initial value problem:
dy
dx =x2+y2, y(0) = 1
over the interval [0,1]. Use a step size of h= 0.2.
Solution
The Runge-Kutta method of order 4 is given by the following formulas:
8
k1=hf(xn, yn)
k2=hf(xn+h
2, yn+k1
2)
k3=hf(xn+h
2, yn+k2
2)
k4=hf(xn+h, yn+k3)
yn+1 =yn+1
6(k1+ 2k2+ 2k3+k4)
where ynis the approximate value of y(xn).
Let’s approximate the solution using the given initial conditions and interval:
Step 1: Calculate the values of yusing the Runge-Kutta method of order
4. Start with x0= 0 and y0= 1.
k1= 0.2·(02+ 12)=0.2
k2= 0.2·(0.12+ 12)=0.201
k3= 0.2·(0.12+ 1.12)≈0.425
k4= 0.2·(0.22+ 1.4252)≈0.492
y1= 1 + 1
6(0.2+2·0.201 + 2 ·0.425 + 0.492) ≈1.255
Step 2: Repeat the process for x1= 0.2 and y1≈1.255.
k1= 0.2·(0.22+ 1.2552)≈0.322
k2= 0.2·(0.32+ 1.3222)≈0.369
k3= 0.2·(0.32+ 1.3692)≈0.581
k4= 0.2·(0.42+ 1.5812)≈0.741
y2≈1.255 + 1
6(0.322 + 2 ·0.369 + 2 ·0.581 + 0.741) ≈1.872
Continue this process until you reach the final point x= 1.
Question 10
Question
Use the fourth-order Runge-Kutta method with a step size of h= 0.1 to ap-
proximate the solution to the initial value problem
dy
dx = 2x−y, y(0) = 1,
at x= 0.4. Round your final answer to four decimal places.
9
Solution
Step 1: Define the Runge-Kutta formulas. The fourth-order Runge-Kutta
method for solving the initial value problem y′=f(x, y) with step size his
given by:
k1=hf(xn, yn),
k2=hf(xn+h
2, yn+k1
2),
k3=hf(xn+h
2, yn+k2
2),
k4=hf(xn+h, yn+k3),
yn+1 =yn+1
6(k1+ 2k2+ 2k3+k4),
where (xn, yn) is the current point and (xn+1, yn+1) is the next point to be
computed.
Step 2: Apply the Runge-Kutta formulas. Starting at x= 0 with y(0) = 1,
first compute k1:
k1= 0.1(2(0) −1) = −0.1.
Then, compute k2:
k2= 0.1(2(0 + 0.05) −(1 −0.05)) = 0.195.
Next, calculate k3:
k3= 0.1(2(0 + 0.05) −(1 + 0.0975)) = 0.1925.
Finally, compute k4:
k4= 0.1(2(0.1) −(1 + 0.19625)) = 0.26125.
Now, find the next value of y:
y1= 1 + 1
6(−0.1 + 2(0.195) + 2(0.1925) + 0.26125)
= 1.208.
Therefore, the approximate solution to the initial value problem at x= 0.4
using the fourth-order Runge-Kutta method is y(0.4) ≈1.208.
Question 11
Question
Consider the initial value problem: dy
dx =x2−y,y(0) = 1. Use the fourth-order
Runge-Kutta method with step size h= 0.1 to estimate the value of y(0.4).
10
Solution
We will use the fourth-order Runge-Kutta method to approximate the value of
y(0.4) by taking steps of size h= 0.1.
The general form of the fourth-order Runge-Kutta method is:
k1=hf(xn, yn)
k2=hf(xn+h
2, yn+k1
2)
k3=hf(xn+h
2, yn+k2
2)
k4=hf(xn+h, yn+k3)
yn+1 =yn+1
6(k1+ 2k2+ 2k3+k4)
where xn+1 =xn+h,ynis the previous value of y, and f(x, y) = x2−y.
Step 1: Define f(x, y) = x2−y.
Step 2: Implement the fourth-order Runge-Kutta method with the given
initial conditions. Iterate until x= 0.4.
n xnynk1k2k3
0 0 1 -0.1 -0.175 -0.175
1 0.1 0.935833 -0.092083 -0.162006 -0.162006
2 0.2 0.876679 -0.084167 -0.148856 -0.148856
3 0.3 0.822821 -0.07625 -0.135687 -0.135687
4 0.4 0.773608 -0.068334
Step 3: Calculate k4and yn+1 at x= 0.4.
k4= 0.1×(−0.068334 + 0.42−0.822821) = −0.004333
y5= 0.773608 + 1
6(−0.1−2(0.162006) −2(0.148856) −0.004333) = 0.739409
Therefore, the estimated value of y(0.4) using the fourth-order Runge-Kutta
method with step size h= 0.1 is 0.739409.
Question 12
Question
Use the classical 4th order Runge-Kutta method to approximate the solution of
the initial value problem:
dy
dx =x2−y, y(0) = 1
over the interval 0 ≤x≤1. Use a step size of h= 0.1.
11
Solution
To approximate the solution using the classical 4th order Runge-Kutta method,
we will compute the values of y(x) at each step using the following formula:
k1=hf(xn, yn),
k2=hf xn+h
2, yn+k1
2,
k3=hf xn+h
2, yn+k2
2,
k4=hf (xn+h, yn+k3),
yn+1 =yn+1
6(k1+ 2k2+ 2k3+k4).
Step 1: Initialize the variables.
Let h= 0.1 be the step size and x0= 0, y0= 1 be the initial values.
Step 2: Compute y1using the Runge-Kutta method.
k1= 0.1(02−1) = −0.1,
k2= 0.10 + 0.1
2−(1 −0.1/2)=−0.095,
k3= 0.10 + 0.1
2−(1 −0.095/2)=−0.09025,
k4= 0.1 (0.1,1−0.09025) = 0.001975,
y1= 1 + 1
6(−0.1 + 2(−0.095) + 2(−0.09025) + 0.001975) = 0.9024208333.
Repeat the above calculations until x= 1 to obtain the approximation of
the solution over the interval 0 ≤x≤1.
Question 13
Question
Consider the initial value problem:
(y′= 2xy + 2x
y(0) = 1
Use the Runge-Kutta Method with step size h= 0.2 to estimate y(0.4) after
two steps.
Solution
The Runge-Kutta Method is given by the formula:
yn+1 =yn+h
6(k1+ 2k2+ 2k3+k4)
12
where k1=f(xn, yn)
k2=fxn+h
2, yn+h
2k1
k3=fxn+h
2, yn+h
2k2
k4=f(xn+h, yn+hk3)
Step 1: Calculate y1.
k1=f(0,1) = 2(0)(1) + 2(0) = 0
k2=f0 + 0.2
2,1 + 0.2
2(0)= 2 0.2
2+ 2 0.2
2= 0.2
k3=f0 + 0.2
2,1 + 0.2
2(0.2)= 2 0.2
2+ 2 0.2
2= 0.2
k4=f(0 + 0.2,1+0.2(0.2)) = 2(0.2)(1) + 2(0.2) = 0.8
y1= 1 + 0.2
6(0 + 2(0.2) + 2(0.2) + 0.8) = 1.08
Step 2: Calculate y2.
k1=f(0.2,1.08) = 2(0.2)(1.08) + 2(0.2) = 0.696
k2=f0.2 + 0.2
2,1.08 + 0.2
2(0.696)= 2 0.2 + 0.2
2·0.696+ 2 (0.2) = 0.7916
k3=f0.2 + 0.2
2,1.08 + 0.2
2(0.7916)= 2 0.2 + 0.2
2·0.7916+ 2 (0.2) = 0.79424
k4=f(0.4,1.08 + 0.2(0.79424)) = 2(0.4)(1.08 + 0.2·0.79424) + 2(0.4) = 1.003104
y2= 1.08 + 0.2
6(0.696 + 2(0.7916) + 2(0.79424) + 1.003104) ≈1.20776
Therefore, after two steps with a step size of 0.2, the Runge-Kutta method
estimates that y(0.4) ≈1.20776.
Question 14
Question
Consider the initial value problem
dy
dx =x2−y, y(0) = 1.
Use the fourth-order Runge-Kutta method to estimate y(0.1) with a step size
of h= 0.05.
13
Solution
The fourth-order Runge-Kutta method is given by the following formulas:
k1=h(f(xn, yn)),
k2=hfxn+h
2, yn+k1
2,
k3=hfxn+h
2, yn+k2
2,
k4=h(f(xn+h, yn+k3)),
yn+1 =yn+1
6(k1+ 2k2+ 2k3+k4).
Step 1: First, we calculate k1,k2,k3, and k4.
k1= 0.05[(0)2−1] = −0.05,
k2= 0.05 (0 + 0.05
2)2−(1 −0.05
2)=−0.04875,
k3= 0.05 (0 + 0.05
2)2−(1 −0.04875
2)=−0.048125,
k4= 0.05[(0 + 0.05)2−(1 −0.048125)] = −0.04503594.
Step 2: Now, we calculate the estimated value of yat x= 0.1.
y1= 1 + 1
6(−0.05 + 2(−0.04875) + 2(−0.048125) −0.04503594)
= 1 + 1
6(−0.05 −0.0975 −0.09625 −0.04503594)
= 1 + 1
6(−0.28878594) ≈0.950357.
Therefore, the estimated value of y(0.1) using the fourth-order Runge-Kutta
method with a step size of 0.05 is approximately 0.950357.
Question 15
Question
Consider the initial value problem:
dy
dx =x2−y, y(0) = 1
Approximate the value of yat x= 0.2 using the 2nd-order Runge-Kutta method
with a step size of h= 0.1. Use two iterations of the method.
14
Solution
To approximate the solution at x= 0.2 using the 2nd-order Runge-Kutta
method, we will perform two iterations with the given step size h= 0.1.
Given the initial value problem:
dy
dx =x2−y, y(0) = 1
The general formula for the 2nd-order Runge-Kutta method is:
yn+1 =yn+h
2(k1+k2)
where:
k1=f(xn, yn); k2=f(xn+h, yn+hk1)
Step 1: Calculate the first iteration
k1=f(x0, y0) = x2
0−y0= 0 −1 = −1
k2=f(x0+h, y0+hk1) = (0 + 0.1)2−(1 + 0.1∗(−1)) = 0.01 −0.1 = −0.09
y1=y0+h
2(k1+k2) = 1 + 0.1
2(−1+(−0.09)) = 0.95
Step 2: Calculate the second iteration
k1=f(x1, y1) = (0.1)2−0.95 = 0.01 −0.95 = −0.94
k2=f(x1+h, y1+hk1) = (0.1+0.1)2−(0.95 + 0.1∗(−0.94)) = 0.04 −0.95 + 0.094 = −0.856
y2=y1+h
2(k1+k2)=0.95 + 0.1
2(−0.94 + (−0.856)) = 0.902
Therefore, the approximate value of yat x= 0.2 using the 2nd-order Runge-
Kutta method with two iterations is y≈0.902.
Question 16
Question
Consider the initial value problem defined by the differential equation y′=
x2−y2with initial condition y(0) = 1. Use the fourth-order Runge-Kutta
method to estimate the value of y(0.4) with step size h= 0.1.
Solution
To apply the fourth-order Runge-Kutta method, we need to compute the incre-
ments k1,k2,k3, and k4at each step. Let h= 0.1, then we have x0= 0, y0= 1,
and we want to find y(0.4).
15
Step 1: Calculate k1,k2,k3, and k4using the following formulas:
k1=h·f(xn, yn)
k2=h·fxn+h
2, yn+k1
2
k3=h·fxn+h
2, yn+k2
2
k4=h·f(xn+h, yn+k3)
where f(x, y) = x2−y2.
Substitute the values xn= 0, yn= 1, and h= 0.1 into the above formulas
to calculate k1,k2,k3, and k4.
Step 2: Calculate the next approximation using the formula:
yn+1 =yn+1
6(k1+ 2k2+ 2k3+k4)
Substitute the values of k1,k2,k3, and k4into the formula to find yn+1.
Step 3: Repeat Steps 1 and 2 until x= 0.4.
Following these steps, we can estimate the value of y(0.4) using the fourth-
order Runge-Kutta method.
Question 17
Question
Consider the initial value problem:
dy
dx =x2−y, y(0) = 1
Use the fourth-order Runge-Kutta method to estimate the value of y(0.2). Use
a step size of h= 0.1 and show all intermediate steps up to y(0.2).
Solution
We will use the fourth-order Runge-Kutta method to estimate y(0.2) with a
step size of h= 0.1. Let’s denote f(x, y) = x2−y.
Step 1: Initialize the variables:
h= 0.1, x0= 0, y0= 1
16
Step 2: Calculate intermediate values:
k1=h·f(x0, y0) = 0.1·(02−1) = −0.1
k2=h·f(x0+h
2, y0+k1
2) = 0.1·f0 + 0.1
2,1 + −0.1
2
= 0.1·f(0.05,0.95) = 0.1·(0.052−0.95) ≈ −0.095
k3=h·f(x0+h
2, y0+k2
2) = 0.1·f0.05,0.95 + −0.095
2
= 0.1·f(0.05,0.9025) = 0.1·(0.052−0.9025) ≈ −0.09075
k4=h·f(x0+h, y0+k3) = 0.1·f(0.1,1+(−0.09075))
= 0.1·f(0.1,0.90925) = 0.1·(0.12−0.90925) ≈ −0.089075
Step 3: Calculate the new value of y:
y1=y0+1
6(k1+ 2k2+ 2k3+k4)
= 1 + 1
6(−0.1 + 2(−0.095) + 2(−0.09075) −0.089075)
= 1 + 1
6(−0.1−0.19 −0.1815 −0.089075) ≈0.78055
Therefore, the estimated value of y(0.2) using the fourth-order Runge-Kutta
method with a step size of 0.1 is approximately 0.78055.
Question 18
Question
Use the fourth-order Runge-Kutta method with step size h= 0.1 to approximate
the solution of the initial value problem
dy
dx =x2−y, y(0) = 1
in the interval 0 ≤x≤0.5. Provide the approximate value of y(0.5).
Solution
To solve the initial value problem using the fourth-order Runge-Kutta method,
we will follow these steps:
Step 1: Define the function f(x, y) = x2−y.
Step 2: Set the initial condition y0= 1 and the step size h= 0.1.
Step 3: Calculate the values of y1,y2,y3, and y4using the fourth-order
Runge-Kutta method:
17
k1=hf(x0, y0)=0.1×(02−1) = −0.1
k2=hf(x0+ 0.5h, y0+ 0.5k1)=0.1×(0.052−0.95) = −0.095225
k3=hf(x0+ 0.5h, y0+ 0.5k2)=0.1×(0.052−0.9526125) = −0.090673
k4=hf(x0+h, y0+k3)=0.1×(0.12−0.94238475) = −0.090261
y1=y0+1
6(k1+ 2k2+ 2k3+k4) = 1 + 1
6(−0.1−2×0.095225 −2×0.090673 −0.090261) = 0.904257
Step 4: Repeat the process for each interval until we reach x= 0.5.
After calculations, the approximate value of y(0.5) using the fourth-order
Runge-Kutta method is y(0.5) ≈0.653193.
Question 19
Question
Use the fourth-order Runge-Kutta method to approximate the solution to the
initial value problem given by the differential equation y′=ex−y, with initial
condition y(0) = 1, at x= 1 using a step size of h= 0.2.
Solution
We can apply the fourth-order Runge-Kutta method to approximate the solution
to the initial value problem. The general formula for the fourth-order Runge-
Kutta method is given by:
yn+1 =yn+h
6(k1+ 2k2+ 2k3+k4)
where k1=f(xn, yn)
k2=f(xn+h
2, yn+h
2k1)
k3=f(xn+h
2, yn+h
2k2)
k4=f(xn+h, yn+hk3)
Let’s proceed with the calculation step by step.
Step 1: Compute k1, k2, k3,and k4.
k1=ex
n−yn=e0−1=1
k2=e(xn+h
2)−(yn+h
2k1) = e0.1−(1 + 0.1(1)) = 1.1051
k3=e(xn+h
2)−(yn+h
2k2) = e0.1−(1 + 0.1(1.1051)) = 1.106021
k4=e(xn+h)−(yn+hk3) = e0.2−(1 + 0.2(1.106021)) = 1.221281
18
Step 2: Use the formula to compute the approximation yn+1.
yn+1 =yn+h
6(k1+ 2k2+ 2k3+k4)
= 1 + 0.2
6(1 + 2(1.1051) + 2(1.106021) + 1.221281)
≈1.220929
Therefore, using the fourth-order Runge-Kutta method with a step size of
h= 0.2, the approximate value of y(1) is 1.220929.
Question 20
Question
Use the fourth-order Runge-Kutta method to approximate the solution to the
differential equation y′=x2+ywith initial condition y(0) = 1 at x= 0.2. Use
a step size of h= 0.1.
Solution
Step 1: Define the function f(x, y) = x2+y.
Step 2: Calculate the increments k1,k2,k3, and k4using the fourth-order
Runge-Kutta method:
k1=hf(xn, yn)
k2=hf(xn+h
2, yn+k1
2)
k3=hf(xn+h
2, yn+k2
2)
k4=hf(xn+h, yn+k3)
Step 3: Update the approximate solution using the formula:
yn+1 =yn+1
6(k1+ 2k2+ 2k3+k4)
Step 4: Substitute the initial condition y(0) = 1 and calculate the values at
each step until x= 0.2 with h= 0.1.
With h= 0.1, we have:
x0= 0, y0= 1
n xnynk1, k2, k3, k4yn+1
0 0.0 1.0 - -
1 0.1 - - -
2 0.2 - - -
Now, let’s proceed with the calculations.
19
Question 21
Question
Consider the initial value problem: dy
dx =x2+y2,y(0) = 1. Use the fourth-order
Runge-Kutta method with step size h= 0.1 to approximate the value of y(0.2).
Solution
Let’s denote f(x, y) = x2+y2. The fourth-order Runge-Kutta method is given
by the formulas:
k1=h·f(xn, yn),
k2=h·f(xn+h
2, yn+k1
2),
k3=h·f(xn+h
2, yn+k2
2),
k4=h·f(xn+h, yn+k3),
yn+1 =yn+1
6(k1+ 2k2+ 2k3+k4),
where his the step size, ynis the approximation of y(xn), kiare intermediate
values, and (xn, yn) are the known values.
Step 1: Calculate the approximations using the Runge-Kutta method.
First, let’s calculate k1,k2,k3, and k4:
k1= 0.1·(02+ 12) = 0.1,
k2= 0.1·((0 + 0.05)2+ (1 + 0.05)2)=0.105625,
k3= 0.1·((0 + 0.05)2+ (1 + 0.0528125)2) = 0.1104233,
k4= 0.1·((0 + 0.1)2+ (1 + 0.1104233)2)=0.1268839.
Now, calculate yn+1:
yn+1 = 1 + 1
6(0.1+2·0.105625 + 2 ·0.1104233 + 0.1268839)
= 1 + 1
6(0.1+0.21125 + 0.2208466 + 0.1268839)
= 1 + 0.66
6
= 1.11.
Therefore, using the fourth-order Runge-Kutta method, the approximation
of y(0.2) is y(0.2) ≈1.11.
20
Question 22
Question
Use the fourth-order Runge-Kutta method to approximate the solution to the
initial value problem dy
dx =x2+y, y(0) = 1
over the interval [0,2] with a step size of h= 0.5.
Solution
To approximate the solution to the given initial value problem using the fourth-
order Runge-Kutta method, we will follow these steps:
Step 1: Define the function f(x, y) = x2+y.
Step 2: Determine the number of subintervals based on the step size hand
the interval [0,2]:
N=2−0
0.5= 4
Step 3: Initialize the values with x0= 0 and y0= 1, and calculate the
approximations for yi+1:
k1=hf(xi, yi) = 0.5·(02+ 1) = 0.5
k2=hf(xi+h
2, yi+k1
2) = 0.5·(0.25 + 1.25) = 0.75
k3=hf(xi+h
2, yi+k2
2) = 0.5·(0.25 + 1.375) = 0.6875
k4=hf(xi+h, yi+k3) = 0.5·(1 + 1.6875) = 1.34375
yi+1 =yi+1
6(k1+ 2k2+ 2k3+k4) = 1 + 1
6(0.5+2·0.75 + 2 ·0.6875 + 1.34375)
= 1 + 1
6(0.5+1.5+1.375 + 1.34375) = 1 + 1
6(4.71875) ≈1.78646
Therefore, the approximate solution to the initial value problem over the
interval [0,2] with a step size of h= 0.5 is y(2) ≈1.78646.
Question 23
Question
Consider the initial value problem:
dy
dx =x2−y, y(0) = 1.
Use the fourth order Runge-Kutta method to approximate the value of yat
x= 1, using a step size of h= 0.2.
21
Solution
To approximate the value of yat x= 1 using the fourth order Runge-Kutta
method, we follow these steps:
Step 1: Define the function f(x, y) = x2−y.
Step 2: Calculate the intermediate values k1,k2,k3, and k4using the
following formulas:
k1=h·f(xn, yn),
k2=h·f(xn+h
2, yn+k1
2),
k3=h·f(xn+h
2, yn+k2
2),
k4=h·f(xn+h, yn+k3),
where xnand ynare the current values of xand y, respectively.
Step 3: Update the value of y:
yn+1 =yn+1
6(k1+ 2k2+ 2k3+k4).
Now, let’s perform the calculations:
Step 1: f(x, y) = x2−y.
Step 2:
k1= 0.2(02−1) = −0.2,
k2= 0.2(0.12−(1 −0.1·0.2/2)) = −0.19595,
k3= 0.2(0.12−(1 −0.1·0.19595/2)) = −0.19194,
k4= 0.2(0.22−(1 −0.1·0.19194)) = −0.18787.
Step 3:
y1= 1 + 1
6(−0.2 + 2(−0.19595) + 2(−0.19194) −0.18787)
= 1 + 1
6(−0.2−0.39190 −0.38388 −0.18787)
= 0.86938.
Therefore, the approximate value of yat x= 1 using the fourth order Runge-
Kutta method with a step size of h= 0.2 is y≈0.86938.
Question 24
Question
Consider the differential equation dy
dx = 2x2+ywith the initial condition y(0) =
1. Use the fourth-order Runge-Kutta method to estimate the value of yat x= 1
using step size h= 0.1.
22
Solution
To approximate the solution of the given initial value problem using the fourth-
order Runge-Kutta method, we will use the following formulas:
k1=hf(xn, yn)
k2=hf(xn+h
2, yn+k1
2)
k3=hf(xn+h
2, yn+k2
2)
k4=hf(xn+h, yn+k3)
yn+1 =yn+1
6(k1+ 2k2+ 2k3+k4)
where h= 0.1 and we will calculate the value of yat x= 1.
Step 1: Initialize the variables
We have x0= 0, y0= 1, and h= 0.1. We aim to estimate yat x= 1.
Step 2: Calculate the values of k1,k2,k3, and k4
Calculating:
k1= 0.1(2(0)2+ 1) = 0.1
k2= 0.1(2(0 + 0.05)2+ 1 + 0.05(0.1)/2) = 0.10125
k3= 0.1(2(0 + 0.05)2+ 1 + 0.10125/2) = 0.10150625
k4= 0.1(2(0.1)2+ 1 + 0.10150625) = 0.120150625
Step 3: Calculate the value of yat x= 1
y1= 1 + 1
6(0.1 + 2(0.10125) + 2(0.10150625) + 0.120150625) = 1.02484375
Therefore, the estimated value of yat x= 1 using the fourth-order Runge-
Kutta method with step size h= 0.1 is approximately 1.0248.
Question 25
Question
Use the fourth-order Runge-Kutta method to approximate the solution to the
initial value problem dy
dx =x2−y, y(0) = 1,
at x= 0.1 using a step size of h= 0.05.
23
Solution
Given the initial value problem
dy
dx =x2−y, y(0) = 1,
we will approximate the solution at x= 0.1 using the fourth-order Runge-Kutta
method with step size h= 0.05.
Step 1: Define the function f(x, y) based on the given differential equation:
f(x, y) = x2−y
Step 2: Implement the fourth-order Runge-Kutta method using the follow-
ing formulas:
k1=hf(xn, yn)
k2=hf(xn+h
2, yn+k1
2)
k3=hf(xn+h
2, yn+k2
2)
k4=hf(xn+h, yn+k3)
yn+1 =yn+1
6(k1+ 2k2+ 2k3+k4)
Step 3: Calculate the approximate value of yat x= 0.1 using the Runge-
Kutta method.
k1= 0.05 ·f(0,1) = 0.05 ·(02−1) = −0.05
k2= 0.05 ·f0 + 0.05
2,1 + −0.05
2= 0.05 ·f(0.025,0.975) = 0.05 ·(0.0252−0.975) ≈ −0.04984375
k3= 0.05 ·f0 + 0.05
2,1 + −0.04984375
2= 0.05 ·f(0.025,0.975078125) = 0.05 ·(0.0252−0.975078125) ≈ −0.04968749844
k4= 0.05 ·f(0 + 0.05,1+(−0.04968749844)) = 0.05 ·f(0.05,0.9503125016) = 0.05 ·(0.052−0.9503125016) ≈ −0.0495312458
y1= 1 + 1
6(−0.05 + 2(−0.04984375) + 2(−0.04968749844) −0.0495312458) ≈0.9502604168
Therefore, the approximate value of yat x= 0.1 using the fourth-order
Runge-Kutta method with a step size of h= 0.05 is approximately 0.9503.
Question 26
Question
Consider the initial value problem:
dy
dx =x2−y, y(0) = 1
Use the fourth-order Runge-Kutta method to approximate y(0.2) with a step
size of h= 0.1.
24
Solution
To approximate the value of y(0.2) using the fourth-order Runge-Kutta method,
we will need to compute the values of yat each step using the following formulas:
k1=hf(xn, yn),
k2=hf(xn+h
2, yn+k1
2),
k3=hf(xn+h
2, yn+k2
2),
k4=hf(xn+h, yn+k3),
where f(x, y) = x2−yfor our given differential equation.
Let’s start by computing the approximation using the fourth-order Runge-
Kutta method:
Step 1: k1= 0.1·(02−1) = −0.1,
Step 2: k2= 0.1·0 + −0.1
22
−(1 + −0.1
2) = −0.0775,
Step 3: k3= 0.1·0 + −0.0775
22
−(1 + −0.0775
2) = −0.07573125,
Step 4: k4= 0.1·(0 + (−0.07573125))2−(1 + (−0.07573125)) = −0.0227991675,
Step 5: y1= 1 + 1
6·(−0.1 + 2(−0.0775) + 2(−0.07573125) −0.0227991675) = 0.881200208.
Therefore, the approximate value of y(0.2) using the fourth-order Runge-Kutta
method with a step size of 0.1 is y(0.2) ≈0.8812.
Question 27
Question
Use the classical fourth-order Runge-Kutta method to approximate the solution
of the initial value problem
dy
dx =x2+y, y(0) = 1
over the interval [0,1] using a step size of h= 0.2.
Solution
We will use the classical fourth-order Runge-Kutta method to solve the initial
value problem step by step. Given the initial value problem:
dy
dx =x2+y, y(0) = 1
25
we will approximate the solution with a step size h= 0.2 on the interval [0,1]
using the fourth-order Runge-Kutta method.
Step 1: Initialize the problem
Given h= 0.2, a= 0, b= 1, y0= 1 and f(x, y) = x2+y.
Step 2: Calculate the slopes using the Runge-Kutta method
Using the fourth-order Runge-Kutta method, we calculate the slopes at four
intermediate points:
k1=hf(xn, yn)=0.2·((0)2+ 1) = 0.2
k2=hf(xn+h
2, yn+k1
2)=0.2·(0.1)2+ (1 + 0.2
2)= 0.2202
k3=hf(xn+h
2, yn+k2
2)=0.2·(0.1)2+ (1 + 0.2202
2)= 0.22084104
k4=hf(xn+h, yn+k3)=0.2·(0.2)2+ (1 + 0.22084104)= 0.24880821
Step 3: Use the slopes to calculate the next approximation
The next approximation is calculated as:
yn+1 =yn+1
6(k1+2k2+2k3+k4) = 1+1
6(0.2+2(0.2202)+2(0.22084104)+0.24880821) = 1.10996869
Therefore, using the fourth-order Runge-Kutta method with a step size of
0.2, the approximate solution to the initial value problem dy
dx =x2+y,y(0) = 1
at x= 1 is y≈1.10996869.
Question 28
Question
Use the fourth-order Runge-Kutta method to approximate the solution of the
initial value problem dy
dx =x2+y, y(0) = 1
over the interval [0,0.4] using a step size of h= 0.1. Provide the approximations
at x= 0.4.
Solution
Given the initial value problem
dy
dx =x2+y, y(0) = 1,
we will use the fourth-order Runge-Kutta method to approximate the solution.
Step 1: Define the step size and the number of steps. Given h= 0.1 and
the interval [0,0.4], we have n=0.4
0.1= 4 steps.
26
Step 2: Set up the Runge-Kutta formulas:
k1=hf(xn, yn),
k2=hf(xn+h
2, yn+k1
2),
k3=hf(xn+h
2, yn+k2
2),
k4=hf(xn+h, yn+k3),
yn+1 =yn+1
6(k1+ 2k2+ 2k3+k4).
Step 3: Perform the computations. Starting at x= 0 and y= 1, we have:
k1= 0.1(02+ 1) = 0.1,
k2= 0.1((0 + 0.05)2+ (1 + 0.05 ·0.1/2)) = 0.102625,
k3= 0.1((0 + 0.05)2+ (1 + 0.102625/2)) = 0.105262625,
k4= 0.1((0.1)2+ (1 + 0.105262625)) = 0.120115263,
y1= 1 + 1
6(0.1 + 2(0.102625) + 2(0.105262625) + 0.120115263) = 1.113772175.
Repeating these calculations for n= 1,2,3,4, we find:
y2= 1.238735054,
y3= 1.475485789,
y4= 1.833300142,
y5= 2.328068059.
Therefore, the approximate solution at x= 0.4 using the fourth-order Runge-
Kutta method is y(0.4) ≈2.328068059.
Question 29
Question
Use the fourth-order Runge-Kutta method with step size h= 0.1 to approximate
the solution of the initial value problem:
dy
dx =x2−y, y(0) = 1
over the interval 0 ≤x≤0.5.
Solution
To approximate the solution using the fourth-order Runge-Kutta method, we
will follow these steps:
27
Step 1: Define the function f(x, y) = x2−y.
Step 2: Set up the Runge-Kutta formula:
k1=h·f(xn, yn),
k2=h·f(xn+h
2, yn+k1
2),
k3=h·f(xn+h
2, yn+k2
2),
k4=h·f(xn+h, yn+k3),
yn+1 =yn+1
6(k1+ 2k2+ 2k3+k4)
Step 3: Implementing the method computationally, we have:
k1= 0.1·(02−1) = −0.1,
k2= 0.1·(0.052−(1 + −0.1
2)) = −0.0925,
k3= 0.1·(0.052−(1 + −0.0925
2)) = −0.085725,
k4= 0.1·(0.12−(1 −0.085725)) = −0.0734175,
y1= 1 + 1
6(−0.1 + 2(−0.0925) + 2(−0.085725) −0.0734175) ≈0.92242875
Therefore, the approximate solution at x= 0.1 is y1≈0.92242875.
Question 30
Question
Consider the initial value problem
dy
dx =e−2x−2y, y(0) = 1.
Use the 4th order Runge-Kutta method to estimate y(1) with a step size of
h= 0.1.
Solution
The 4th order Runge-Kutta method is given by the following formulas:
k1=hf(xn, yn),
k2=hf(xn+1
2h, yn+1
2k1),
k3=hf(xn+1
2h, yn+1
2k2),
k4=hf(xn+h, yn+k3),
yn+1 =yn+1
6(k1+ 2k2+ 2k3+k4),
28
where f(x, y) = e−2x−2y.
Step 1: Evaluate y1using x0= 0 and y0= 1.
k1= 0.1(e0−2(1)) = 0.1(e−2),
k2= 0.1(e−1
2−2(1 + 1
2(0.1(e−2)))) = 0.1(e−1
2−2(1.05e−2.1)),
k3= 0.1(e−1
2−2(1 + 1
2(0.1(e−1
2−2(1.05e−2.1)))))
= 0.1(e−1
2−2(1.0525e−2.104)),
k4= 0.1(e−1−2(1.105e−2.207)) = 0.1(e−1−2.21e−4.414),
y1= 1 + 1
6(0.1(e−2) + 2(0.1(e−1
2−2(1.05e−2.1))
+ 2(0.1(e−1
2−2(1.0525e−2.104)) + 0.1(e−1−2.21e−4.414)))
≈0.843376.
Therefore, the estimate for y(1) using the 4th order Runge-Kutta method
with step size h= 0.1 is approximately 0.843376.
Question 31
Question
Use the fourth-order Runge-Kutta method to approximate the solution to the
initial value problem dy
dx =x2−2y, y(0) = 1
over the interval [0,1] using a step size of h= 0.1.
Solution
We will use the fourth-order Runge-Kutta method to approximate the solution
to the initial value problem. The fourth-order Runge-Kutta method is given by
the following formulas:
k1=h·f(xn, yn),
k2=h·f(xn+h
2, yn+k1
2),
k3=h·f(xn+h
2, yn+k2
2),
k4=h·f(xn+h, yn+k3),
yn+1 =yn+1
6(k1+ 2k2+ 2k3+k4),
where f(x, y) = x2−2y.
Step 1: First, we start by calculating the values of yat each step using the
fourth-order Runge-Kutta method.
29
Step 2: For x0= 0 and y0= 1, we have:
k1= 0.1·(02−2·1) = −0.2,
k2= 0.1·((0 + 0.05)2−2·(1 −0.1·0.2/2)) = −0.184,
k3= 0.1·((0 + 0.05)2−2·(1 −0.1·0.184/2)) = −0.18428,
k4= 0.1·((0 + 0.1)2−2·(1 −0.1·(−0.18428))) = −0.1643344,
y1= 1 + 1
6(−0.2 + 2(−0.184) + 2(−0.18428) −0.1643344) = 0.85286356.
The approximate solution at x= 0.1 is y1≈0.85286356.
Step 3: We repeat the process to find y2, y3, . . . , y10 until x= 1.
Step 4: Finally, we tabulate the values of xand y:
x y
0.0 1.0
0.1 0.85286356
0.2 ?
0.3 ?
0.4 ?
0.5 ?
0.6 ?
0.7 ?
0.8 ?
0.9 ?
1.0 ?
Question 32
Question
Use the fourth-order Runge-Kutta method with step size h= 0.1 to approximate
the solution to the initial value problem:
dy
dx =x2−y, y(0) = 1
for x= 0.1,0.2,0.3,0.4.
Solution
To apply the fourth-order Runge-Kutta method to approximate the solution,
we first need to calculate the increments kifor i= 1,2,3,4 using the following
formulas:
k1=hf(xn, yn)
k2=hf(xn+h
2, yn+k1
2)
30
k3=hf(xn+h
2, yn+k2
2)
k4=hf(xn+h, yn+k3)
where f(x, y) = x2−y.
Then, we use these increments to calculate the next value of y:
yn+1 =yn+1
6(k1+ 2k2+ 2k3+k4)
Let’s proceed to calculate the solution.
Step 1: For x= 0.1:
k1= 0.1(02−1) = −0.1
k2= 0.1(0 + −0.1
2) = −0.005
k3= 0.1(0 + −0.005
2) = −0.00025
k4= 0.1(0.1+(−0.00025)) = 0.009975
y1= 1 + 1
6(−0.1 + 2(−0.005) + 2(−0.00025) + 0.009975) = 0.998370833
Step 2: For x= 0.2:
k1= 0.1((0.1)2−0.998370833) ≈ −0.097621667
k2≈0.1(0.1 + −0.097621667
2)≈ −0.009661667
k3≈0.1(0.1 + −0.009661667
2)≈ −0.000483083
k4≈0.1(0.2+(−0.000483083)) ≈0.019951918
y2= 0.998370833 + 1
6(−0.097621667 + 2(−0.009661667) + 2(−0.000483083) + 0.019951918) ≈0.993691273
Step 3: For x= 0.3 and x= 0.4: Similarly, we calculate kifor i= 1,2,3,4
and find y3and y4.
The approximate solution values are y1≈0.998370833, y2≈0.993691273,
y3≈0.986974342, and y4≈0.977399948.
Question 33
Question
Use the Runge-Kutta method with four steps to approximate the solution to
the initial value problem: dy
dx =x−y,y(0) = 1, for h= 0.2. Find the value of
y(0.8).
31
Solution
The Runge-Kutta method with four steps is given by:
yn+1 =yn+h
6(k1+ 2k2+ 2k3+k4)
where
k1=f(xn, yn)
k2=f(xn+h
2, yn+h
2k1)
k3=f(xn+h
2, yn+h
2k2)
k4=f(xn+h, yn+hk3)
Here, f(x, y) = x−y. For this problem, x0= 0, y0= 1, and h= 0.2. We
want to find y(0.8).
h= 0.2
x0= 0
y0= 1
x1= 0.2
x2= 0.4
x3= 0.6
x4= 0.8
Step 1: Calculate k1, Since k1=x0−y0,
k1= 0 −1 = −1
Step 2: Calculate k2,
k2=f(x0+h
2, y0+h
2k1)
=f(0.1,1+0.1(−1))
=f(0.1,0.9)
= 0.1−0.9
=−0.8
Step 3: Calculate k3,
k3=f(x0+h
2, y0+h
2k2)
=f(0.1,1+0.1(−0.8))
=f(0.1,0.92)
= 0.1−0.92
=−0.82
32
Step 4: Calculate k4,
k4=f(x0+h, y0+hk3)
=f(0.2,1+0.2(−0.82))
=f(0.2,0.836)
= 0.2−0.836
=−0.636
Step 5: Calculate the next approximation value y1,
y1=y0+h
6(k1+ 2k2+ 2k3+k4)
= 1 + 0.2
6(−1 + 2(−0.8) + 2(−0.82) −0.636)
= 1 + 0.2
6(−1−1.6−1.64 −0.636)
= 1 + 0.2
6(−4.276)
= 1 + −0.71333
6
= 1 −0.11889
= 0.88111
Therefore, the approximation for the value of y(0.8) using the Runge-Kutta
method with four steps is y(0.8) = 0.88111
Question 34
Question
Consider the initial value problem:
(y′=−2xy
y(0) = 1
Use the fourth-order Runge-Kutta method to approximate y(0.5) using a step
size of h= 0.1.
33
Solution
The fourth-order Runge-Kutta method is given by the following formulas:
k1=hf(xn, yn)
k2=hf(xn+h
2, yn+k1
2)
k3=hf(xn+h
2, yn+k2
2)
k4=hf(xn+h, yn+k3)
yn+1 =yn+1
6(k1+ 2k2+ 2k3+k4)
where
f(x, y) = −2xy
Step 1: Define the necessary variables:
h= 0.1
x0= 0
y0= 1
x1=x0+h
k1=hf(x0, y0)=0.1(−2(0)(1)) = 0
k2=hf(x0+h
2, y0+k1
2)
k3=hf(x0+h
2, y0+k2
2)
k4=hf(x1, y0+k3)
Step 2: Calculate k2:
k2= 0.1f(0 + 0.1
2,1 + 0
2)
= 0.1(−2(0.1
2)(1))
=−0.001
Step 3: Calculate k3:
k3= 0.1f(0 + 0.1
2,1 + −0.001
2)
= 0.1(−2(0.1
2)(1 + −0.001
2))
=−0.0019995
Step 4: Calculate k4:
k4= 0.1f(0.1,1−0.0019995)
= 0.1(−2(0.1)(0.9980005))
=−0.001996010
34
Step 5: Finally, calculate y1:
y1= 1 + 1
6(0 + 2(−0.001) + 2(−0.0019995) −0.001996010)
= 1 + 1
6(−0.003999)
= 0.999333
Therefore, the approximate value of y(0.1) using the fourth-order Runge-
Kutta method is 0.999333.
Question 35
Question
Consider the initial value problem
dy
dx =x2+y, y(0) = 1
Use the fourth-order Runge-Kutta method to approximate y(0.1) with a step
size of h= 0.05.
Solution
Let h= 0.05 be the step size, so x0= 0, y0= 1, and x1=x0+h= 0.05.
Step 1: Calculate the intermediate values of k1,k2,k3, and k4:
k1=hf(x0, y0)=0.05[(0)2+ 1] = 0.05
k2=hf(x0+ 0.5h, y0+ 0.5k1)=0.05[(0.025)2+ 1.025] = 0.05256
k3=hf(x0+ 0.5h, y0+ 0.5k2)=0.05[(0.025)2+ 1.02628] = 0.052635
k4=hf(x0+h, y0+k3)=0.05[(0.05)2+ 1.0798] = 0.05495
Step 2: Use these values to find the next approximation y1:
y1=y0+1
6(k1+ 2k2+ 2k3+k4)
= 1 + 1
6(0.05 + 2(0.05256) + 2(0.052635) + 0.05495)
= 1 + 1
6(0.05 + 0.10512 + 0.10527 + 0.05495)
= 1 + 1
6(0.31534)
= 1.05256
Therefore, the approximate value of y(0.1) using the fourth-order Runge-
Kutta method with h= 0.05 is y(0.1) ≈1.05256.
35
Therefore, the fourth-order Runge-Kutta approximation for y(0.2) is y(0.2) ≈
0.8271489.
Question 2
Question
Use the fourth-order Runge-Kutta method to approximate the solution of the
initial value problem
y′= 2y−x, y(0) = 1
at x= 0.2. Use step size h= 0.1.
Solution
Let’s denote f(x, y)=2y−xand h= 0.1. We will apply the fourth-order
Runge-Kutta method to approximate the solution at x= 0.2.
Step 1: Calculate k1,k2,k3, and k4using the formulas:
k1=hf(xn, yn)
k2=hf(xn+h
2, yn+k1
2)
k3=hf(xn+h
2, yn+k2
2)
k4=hf(xn+h, yn+k3)
Substitute f(x, y) = 2y−x,h= 0.1, x0= 0, and y0= 1:
k1= 0.1(2 ·1−0) = 0.2
k2= 0.1(2 ·1−0.05) = 0.195
k3= 0.1(2 ·1−0.0475) = 0.19525
k4= 0.1(2 ·1−0.1) = 0.19
Step 2: Calculate the weighted average for the final approximation:
yn+1 =yn+1
6(k1+ 2k2+ 2k3+k4)
Substitute the values we calculated:
y1= 1 + 1
6(0.2+2·0.195 + 2 ·0.19525 + 0.19)
y1= 1 + 1
6(0.2+0.39 + 0.3905 + 0.19)
y1= 1 + 1
6(1.1705)
2
y1= 1 + 0.1950833
y1≈1.1951
Therefore, the fourth-order Runge-Kutta method approximates the solution
at x= 0.2 to be y≈1.1951.
Question 3
Question
Consider the initial value problem
dy
dx =y−x2+ 1, y(0) = 0,
and approximate y(1) using the fourth-order Runge-Kutta method with step
size h= 0.2.
Solution
Given the initial value problem, we can apply the fourth-order Runge-Kutta
method to approximate y(1) with step size h= 0.2. The formula for the method
is as follows:
k1=h(f(xn, yn)),
k2=h(f(xn+h
2, yn+k1
2)),
k3=h(f(xn+h
2, yn+k2
2)),
k4=h(f(xn+h, yn+k3)),
yn+1 =yn+1
6(k1+ 2k2+ 2k3+k4),
where f(x, y) = y−x2+ 1, y0= 0, and h= 0.2. We will approximate y(1) using
this method.
Step 1: Calculate the values of k1,k2,k3, and k4.
k1= 0.2(f(0,0)) = 0.2(0 −02+ 1) = 0.2,
k2= 0.2(f(0 + 0.2
2,0 + 0.2
2)) = 0.2(0 −0.12+ 1) ≈0.195,
k3= 0.2(f(0 + 0.2
2,0 + 0.195
2)) = 0.2(0 −0.052+ 1) ≈0.1975,
k4= 0.2(f(0 + 0.2,0+0.1975)) = 0.2(0.1975 −0.22+ 1) ≈0.1965.
Step 2: Use the values of k1,k2,k3, and k4to find yn+1.
y1≈0 + 1
6(0.2 + 2(0.195) + 2(0.1975) + 0.1965) ≈0.31425.
Therefore, the approximate value of y(1) using the fourth-order Runge-Kutta
method with h= 0.2 is 0.31425.
3
Question 4
Question
Consider the initial value problem dy
dx =x2−ywith y(0) = 1. Use the 4th-order
Runge-Kutta method to approximate y(1) with step size h= 0.2.
Solution
Step 1: Define the function f(x, y) = x2−y.
Step 2: Calculate the increments k1,k2,k3, and k4using the Runge-Kutta
formula: k1=hf(xn, yn)
k2=hf(xn+h
2, yn+k1
2)
k3=hf(xn+h
2, yn+k2
2)
k4=hf(xn+h, yn+k3)
where xn= 0 and yn= 1.
Step 3: Use the increments to update the approximation:
yn+1 =yn+1
6(k1+ 2k2+ 2k3+k4)
Step 4: Repeat the process for each step until x= 1 is reached.
Step 5: Calculate the approximation for y(1) using the above method.
Now, let’s solve the problem using the above steps.
Step 1: The function f(x, y) = x2−y.
Step 2: Calculating the increments:
k1= 0.2(02−1) = −0.2
k2= 0.20 + 0.2
2,1 + −0.2
2= 0.18
k3= 0.20 + 0.2
2,1 + 0.18
2= 0.176
k4= 0.2 (0 + 0.2,1+0.176) = 0.2352
Step 3: Updating the approximation:
yn+1 = 1 + 1
6(−0.2+2∗0.18 + 2 ∗0.176 + 0.2352) ≈1.2357
Therefore, using the 4th-order Runge-Kutta method with step size h= 0.2,
we approximate y(1) ≈1.2357.
4
Question 5
Question
Consider the initial value problem:
dy
dx =x2−y, y(0) = 1.
Apply the classical fourth-order Runge-Kutta method to approximate the value
of y(1) using a step size of h= 0.2.
Solution
To solve this problem using the classical fourth-order Runge-Kutta method, we
will follow these steps:
Step 1: Define the function and initialize variables.
Given ODE: dy
dx =x2−y, y(0) = 1
Step size:h= 0.2
Number of steps:n=1
h= 5
Initial condition:y0= 1
Initialize:x0= 0
Step 2: Perform iterations using the Runge-Kutta method.
For i= 1,2, . . . , n :
k1=h·(x2
i−1−yi−1)
k2=h·((xi−1+h
2)2−(yi−1+k1
2))
k3=h·((xi−1+h
2)2−(yi−1+k2
2))
k4=h·((xi−1+h)2−(yi−1+k3))
yi=yi−1+1
6·(k1+ 2k2+ 2k3+k4)
xi=xi−1+h
Step 3: Calculate the approximate value of y(1) using the Runge-Kutta
method. After performing the iterations, we find y(1) ≈0.381417.
5
Question 6
Question
Consider the initial value problem
(y′= 2xy +y2,
y(0) = 1.
Use a fourth-order Runge-Kutta method to estimate y(0.2) with step size h=
0.1.
Solution
Step 1: Define the function f(x, y) based on the given differential equation:
f(x, y) = 2xy +y2.
Step 2: Implement the fourth-order Runge-Kutta method with the given
step size h= 0.1:
k1 = h·f(0,1) = 0.1·(2 ·0·1+12)=0.1,
k2 = h·f(0.05,1+0.5·k1) = 0.1·2·(0.05)(1 + 0.5·0.1) + (1 + 0.5·0.1)2≈0.123,
k3 = h·f(0.05,1+0.5·k2) = 0.1·2·(0.05)(1 + 0.5·0.123) + (1 + 0.5·0.123)2≈0.145,
k4 = h·f(0.1,1 + k3) = 0.1·2·0.1·(1 + 0.145) + (1 + 0.145)2≈0.202.
Step 3: Calculate the estimated value of y(0.2) using the weighted average:
y(0.2) ≈1 + 1
6·(0.1+2·0.123 + 2 ·0.145 + 0.202) ≈1.254.
Therefore, the estimate of y(0.2) using the fourth-order Runge-Kutta method
with step size h= 0.1 is approximately 1.254.
Question 7
Question
Use the fourth-order Runge-Kutta method to approximate the solution to the
initial value problem:
dy
dx =x2+y, y(0) = 1
Calculate an approximation to y(0.1) using a step size of h= 0.02.
6
Solution
Step 1: Define the function f(x, y) based on the given differential equation:
f(x, y) = x2+y
Step 2: Implement the fourth-order Runge-Kutta method to approximate
y(0.1) using the given initial condition y(0) = 1 and step size h= 0.02.
k1=hf(0,1) = 0.02[(0)2+ 1] = 0.02
k2=hf 0 + h
2,1 + k1
2= 0.02 "0+0.02
22
+1+0.02/2
2#= 0.0201
k3=hf 0 + h
2,1 + k2
2= 0.02 "0+0.02
22
+1+0.0201/2
2#= 0.020101
k4=hf(0 + h, 1 + k3)=0.02[(0.02)2+ 1 + 0.020101] = 0.020605
Step 3: Calculate the weighted average of the k’s to find the approximation:
y(0.02) = 1 + 1
6(0.02 + 2(0.0201) + 2(0.020101) + 0.020605)
= 1 + 1
6(0.020 + 0.0402 + 0.040202 + 0.020605)
= 1 + 1
6(0.120807)
≈1.0201345
Therefore, the approximate value of y(0.1) using the fourth-order Runge-
Kutta method with a step size of 0.02 is approximately 1.0201345.
Question 8
Question
Consider the following initial value problem:
dy
dx =x2−y, y(0) = 1
Approximate the value of y(1) using the fourth-order Runge-Kutta method with
a step size of h= 0.2.
Solution
To approximate the value of y(1) using the fourth-order Runge-Kutta method,
we will iterate through the following steps:
Step 1: Define the function f(x, y) = x2−y.
7
Step 2: Set h= 0.2, x0= 0, y0= 1, and x1= 1.
Step 3: Calculate the intermediate values k1,k2,k3, and k4using the
formulas: k1=h·f(x0, y0)
k2=h·f(x0+h
2, y0+k1
2)
k3=h·f(x0+h
2, y0+k2
2)
k4=h·f(x0+h, y0+k3)
Step 4: Calculate the approximated value of y1at x1using the formula:
y1=y0+1
6(k1+ 2k2+ 2k3+k4)
Step 5: Substitute the given values into the formulas and compute the final
approximated value of y(1):
k1= 0.2·(02−1) = −0.2
k2= 0.2·(0.12−0.9) = −0.196
k3= 0.2·(0.12−0.9) = −0.196
k4= 0.2·(0.22−0.8) = −0.184
y1= 1 + 1
6(−0.2 + 2(−0.196) + 2(−0.196) −0.184) = 0.8128
Therefore, the approximate value of y(1) using the fourth-order Runge-Kutta
method with a step size of h= 0.2 is y(1) ≈0.8128.
Question 9
Question
Use the Runge-Kutta method of order 4 to approximate the solution to the
initial value problem:
dy
dx =x2+y2, y(0) = 1
over the interval [0,1]. Use a step size of h= 0.2.
Solution
The Runge-Kutta method of order 4 is given by the following formulas:
8
k1=hf(xn, yn)
k2=hf(xn+h
2, yn+k1
2)
k3=hf(xn+h
2, yn+k2
2)
k4=hf(xn+h, yn+k3)
yn+1 =yn+1
6(k1+ 2k2+ 2k3+k4)
where ynis the approximate value of y(xn).
Let’s approximate the solution using the given initial conditions and interval:
Step 1: Calculate the values of yusing the Runge-Kutta method of order
4. Start with x0= 0 and y0= 1.
k1= 0.2·(02+ 12)=0.2
k2= 0.2·(0.12+ 12)=0.201
k3= 0.2·(0.12+ 1.12)≈0.425
k4= 0.2·(0.22+ 1.4252)≈0.492
y1= 1 + 1
6(0.2+2·0.201 + 2 ·0.425 + 0.492) ≈1.255
Step 2: Repeat the process for x1= 0.2 and y1≈1.255.
k1= 0.2·(0.22+ 1.2552)≈0.322
k2= 0.2·(0.32+ 1.3222)≈0.369
k3= 0.2·(0.32+ 1.3692)≈0.581
k4= 0.2·(0.42+ 1.5812)≈0.741
y2≈1.255 + 1
6(0.322 + 2 ·0.369 + 2 ·0.581 + 0.741) ≈1.872
Continue this process until you reach the final point x= 1.
Question 10
Question
Use the fourth-order Runge-Kutta method with a step size of h= 0.1 to ap-
proximate the solution to the initial value problem
dy
dx = 2x−y, y(0) = 1,
at x= 0.4. Round your final answer to four decimal places.
9
Solution
Step 1: Define the Runge-Kutta formulas. The fourth-order Runge-Kutta
method for solving the initial value problem y′=f(x, y) with step size his
given by:
k1=hf(xn, yn),
k2=hf(xn+h
2, yn+k1
2),
k3=hf(xn+h
2, yn+k2
2),
k4=hf(xn+h, yn+k3),
yn+1 =yn+1
6(k1+ 2k2+ 2k3+k4),
where (xn, yn) is the current point and (xn+1, yn+1) is the next point to be
computed.
Step 2: Apply the Runge-Kutta formulas. Starting at x= 0 with y(0) = 1,
first compute k1:
k1= 0.1(2(0) −1) = −0.1.
Then, compute k2:
k2= 0.1(2(0 + 0.05) −(1 −0.05)) = 0.195.
Next, calculate k3:
k3= 0.1(2(0 + 0.05) −(1 + 0.0975)) = 0.1925.
Finally, compute k4:
k4= 0.1(2(0.1) −(1 + 0.19625)) = 0.26125.
Now, find the next value of y:
y1= 1 + 1
6(−0.1 + 2(0.195) + 2(0.1925) + 0.26125)
= 1.208.
Therefore, the approximate solution to the initial value problem at x= 0.4
using the fourth-order Runge-Kutta method is y(0.4) ≈1.208.
Question 11
Question
Consider the initial value problem: dy
dx =x2−y,y(0) = 1. Use the fourth-order
Runge-Kutta method with step size h= 0.1 to estimate the value of y(0.4).
10
Solution
We will use the fourth-order Runge-Kutta method to approximate the value of
y(0.4) by taking steps of size h= 0.1.
The general form of the fourth-order Runge-Kutta method is:
k1=hf(xn, yn)
k2=hf(xn+h
2, yn+k1
2)
k3=hf(xn+h
2, yn+k2
2)
k4=hf(xn+h, yn+k3)
yn+1 =yn+1
6(k1+ 2k2+ 2k3+k4)
where xn+1 =xn+h,ynis the previous value of y, and f(x, y) = x2−y.
Step 1: Define f(x, y) = x2−y.
Step 2: Implement the fourth-order Runge-Kutta method with the given
initial conditions. Iterate until x= 0.4.
n xnynk1k2k3
0 0 1 -0.1 -0.175 -0.175
1 0.1 0.935833 -0.092083 -0.162006 -0.162006
2 0.2 0.876679 -0.084167 -0.148856 -0.148856
3 0.3 0.822821 -0.07625 -0.135687 -0.135687
4 0.4 0.773608 -0.068334
Step 3: Calculate k4and yn+1 at x= 0.4.
k4= 0.1×(−0.068334 + 0.42−0.822821) = −0.004333
y5= 0.773608 + 1
6(−0.1−2(0.162006) −2(0.148856) −0.004333) = 0.739409
Therefore, the estimated value of y(0.4) using the fourth-order Runge-Kutta
method with step size h= 0.1 is 0.739409.
Question 12
Question
Use the classical 4th order Runge-Kutta method to approximate the solution of
the initial value problem:
dy
dx =x2−y, y(0) = 1
over the interval 0 ≤x≤1. Use a step size of h= 0.1.
11
Solution
To approximate the solution using the classical 4th order Runge-Kutta method,
we will compute the values of y(x) at each step using the following formula:
k1=hf(xn, yn),
k2=hf xn+h
2, yn+k1
2,
k3=hf xn+h
2, yn+k2
2,
k4=hf (xn+h, yn+k3),
yn+1 =yn+1
6(k1+ 2k2+ 2k3+k4).
Step 1: Initialize the variables.
Let h= 0.1 be the step size and x0= 0, y0= 1 be the initial values.
Step 2: Compute y1using the Runge-Kutta method.
k1= 0.1(02−1) = −0.1,
k2= 0.10 + 0.1
2−(1 −0.1/2)=−0.095,
k3= 0.10 + 0.1
2−(1 −0.095/2)=−0.09025,
k4= 0.1 (0.1,1−0.09025) = 0.001975,
y1= 1 + 1
6(−0.1 + 2(−0.095) + 2(−0.09025) + 0.001975) = 0.9024208333.
Repeat the above calculations until x= 1 to obtain the approximation of
the solution over the interval 0 ≤x≤1.
Question 13
Question
Consider the initial value problem:
(y′= 2xy + 2x
y(0) = 1
Use the Runge-Kutta Method with step size h= 0.2 to estimate y(0.4) after
two steps.
Solution
The Runge-Kutta Method is given by the formula:
yn+1 =yn+h
6(k1+ 2k2+ 2k3+k4)
12
where k1=f(xn, yn)
k2=fxn+h
2, yn+h
2k1
k3=fxn+h
2, yn+h
2k2
k4=f(xn+h, yn+hk3)
Step 1: Calculate y1.
k1=f(0,1) = 2(0)(1) + 2(0) = 0
k2=f0 + 0.2
2,1 + 0.2
2(0)= 2 0.2
2+ 2 0.2
2= 0.2
k3=f0 + 0.2
2,1 + 0.2
2(0.2)= 2 0.2
2+ 2 0.2
2= 0.2
k4=f(0 + 0.2,1+0.2(0.2)) = 2(0.2)(1) + 2(0.2) = 0.8
y1= 1 + 0.2
6(0 + 2(0.2) + 2(0.2) + 0.8) = 1.08
Step 2: Calculate y2.
k1=f(0.2,1.08) = 2(0.2)(1.08) + 2(0.2) = 0.696
k2=f0.2 + 0.2
2,1.08 + 0.2
2(0.696)= 2 0.2 + 0.2
2·0.696+ 2 (0.2) = 0.7916
k3=f0.2 + 0.2
2,1.08 + 0.2
2(0.7916)= 2 0.2 + 0.2
2·0.7916+ 2 (0.2) = 0.79424
k4=f(0.4,1.08 + 0.2(0.79424)) = 2(0.4)(1.08 + 0.2·0.79424) + 2(0.4) = 1.003104
y2= 1.08 + 0.2
6(0.696 + 2(0.7916) + 2(0.79424) + 1.003104) ≈1.20776
Therefore, after two steps with a step size of 0.2, the Runge-Kutta method
estimates that y(0.4) ≈1.20776.
Question 14
Question
Consider the initial value problem
dy
dx =x2−y, y(0) = 1.
Use the fourth-order Runge-Kutta method to estimate y(0.1) with a step size
of h= 0.05.
13
Solution
The fourth-order Runge-Kutta method is given by the following formulas:
k1=h(f(xn, yn)),
k2=hfxn+h
2, yn+k1
2,
k3=hfxn+h
2, yn+k2
2,
k4=h(f(xn+h, yn+k3)),
yn+1 =yn+1
6(k1+ 2k2+ 2k3+k4).
Step 1: First, we calculate k1,k2,k3, and k4.
k1= 0.05[(0)2−1] = −0.05,
k2= 0.05 (0 + 0.05
2)2−(1 −0.05
2)=−0.04875,
k3= 0.05 (0 + 0.05
2)2−(1 −0.04875
2)=−0.048125,
k4= 0.05[(0 + 0.05)2−(1 −0.048125)] = −0.04503594.
Step 2: Now, we calculate the estimated value of yat x= 0.1.
y1= 1 + 1
6(−0.05 + 2(−0.04875) + 2(−0.048125) −0.04503594)
= 1 + 1
6(−0.05 −0.0975 −0.09625 −0.04503594)
= 1 + 1
6(−0.28878594) ≈0.950357.
Therefore, the estimated value of y(0.1) using the fourth-order Runge-Kutta
method with a step size of 0.05 is approximately 0.950357.
Question 15
Question
Consider the initial value problem:
dy
dx =x2−y, y(0) = 1
Approximate the value of yat x= 0.2 using the 2nd-order Runge-Kutta method
with a step size of h= 0.1. Use two iterations of the method.
14
Solution
To approximate the solution at x= 0.2 using the 2nd-order Runge-Kutta
method, we will perform two iterations with the given step size h= 0.1.
Given the initial value problem:
dy
dx =x2−y, y(0) = 1
The general formula for the 2nd-order Runge-Kutta method is:
yn+1 =yn+h
2(k1+k2)
where:
k1=f(xn, yn); k2=f(xn+h, yn+hk1)
Step 1: Calculate the first iteration
k1=f(x0, y0) = x2
0−y0= 0 −1 = −1
k2=f(x0+h, y0+hk1) = (0 + 0.1)2−(1 + 0.1∗(−1)) = 0.01 −0.1 = −0.09
y1=y0+h
2(k1+k2) = 1 + 0.1
2(−1+(−0.09)) = 0.95
Step 2: Calculate the second iteration
k1=f(x1, y1) = (0.1)2−0.95 = 0.01 −0.95 = −0.94
k2=f(x1+h, y1+hk1) = (0.1+0.1)2−(0.95 + 0.1∗(−0.94)) = 0.04 −0.95 + 0.094 = −0.856
y2=y1+h
2(k1+k2)=0.95 + 0.1
2(−0.94 + (−0.856)) = 0.902
Therefore, the approximate value of yat x= 0.2 using the 2nd-order Runge-
Kutta method with two iterations is y≈0.902.
Question 16
Question
Consider the initial value problem defined by the differential equation y′=
x2−y2with initial condition y(0) = 1. Use the fourth-order Runge-Kutta
method to estimate the value of y(0.4) with step size h= 0.1.
Solution
To apply the fourth-order Runge-Kutta method, we need to compute the incre-
ments k1,k2,k3, and k4at each step. Let h= 0.1, then we have x0= 0, y0= 1,
and we want to find y(0.4).
15
Step 1: Calculate k1,k2,k3, and k4using the following formulas:
k1=h·f(xn, yn)
k2=h·fxn+h
2, yn+k1
2
k3=h·fxn+h
2, yn+k2
2
k4=h·f(xn+h, yn+k3)
where f(x, y) = x2−y2.
Substitute the values xn= 0, yn= 1, and h= 0.1 into the above formulas
to calculate k1,k2,k3, and k4.
Step 2: Calculate the next approximation using the formula:
yn+1 =yn+1
6(k1+ 2k2+ 2k3+k4)
Substitute the values of k1,k2,k3, and k4into the formula to find yn+1.
Step 3: Repeat Steps 1 and 2 until x= 0.4.
Following these steps, we can estimate the value of y(0.4) using the fourth-
order Runge-Kutta method.
Question 17
Question
Consider the initial value problem:
dy
dx =x2−y, y(0) = 1
Use the fourth-order Runge-Kutta method to estimate the value of y(0.2). Use
a step size of h= 0.1 and show all intermediate steps up to y(0.2).
Solution
We will use the fourth-order Runge-Kutta method to estimate y(0.2) with a
step size of h= 0.1. Let’s denote f(x, y) = x2−y.
Step 1: Initialize the variables:
h= 0.1, x0= 0, y0= 1
16
Step 2: Calculate intermediate values:
k1=h·f(x0, y0) = 0.1·(02−1) = −0.1
k2=h·f(x0+h
2, y0+k1
2) = 0.1·f0 + 0.1
2,1 + −0.1
2
= 0.1·f(0.05,0.95) = 0.1·(0.052−0.95) ≈ −0.095
k3=h·f(x0+h
2, y0+k2
2) = 0.1·f0.05,0.95 + −0.095
2
= 0.1·f(0.05,0.9025) = 0.1·(0.052−0.9025) ≈ −0.09075
k4=h·f(x0+h, y0+k3) = 0.1·f(0.1,1+(−0.09075))
= 0.1·f(0.1,0.90925) = 0.1·(0.12−0.90925) ≈ −0.089075
Step 3: Calculate the new value of y:
y1=y0+1
6(k1+ 2k2+ 2k3+k4)
= 1 + 1
6(−0.1 + 2(−0.095) + 2(−0.09075) −0.089075)
= 1 + 1
6(−0.1−0.19 −0.1815 −0.089075) ≈0.78055
Therefore, the estimated value of y(0.2) using the fourth-order Runge-Kutta
method with a step size of 0.1 is approximately 0.78055.
Question 18
Question
Use the fourth-order Runge-Kutta method with step size h= 0.1 to approximate
the solution of the initial value problem
dy
dx =x2−y, y(0) = 1
in the interval 0 ≤x≤0.5. Provide the approximate value of y(0.5).
Solution
To solve the initial value problem using the fourth-order Runge-Kutta method,
we will follow these steps:
Step 1: Define the function f(x, y) = x2−y.
Step 2: Set the initial condition y0= 1 and the step size h= 0.1.
Step 3: Calculate the values of y1,y2,y3, and y4using the fourth-order
Runge-Kutta method:
17
k1=hf(x0, y0)=0.1×(02−1) = −0.1
k2=hf(x0+ 0.5h, y0+ 0.5k1)=0.1×(0.052−0.95) = −0.095225
k3=hf(x0+ 0.5h, y0+ 0.5k2)=0.1×(0.052−0.9526125) = −0.090673
k4=hf(x0+h, y0+k3)=0.1×(0.12−0.94238475) = −0.090261
y1=y0+1
6(k1+ 2k2+ 2k3+k4) = 1 + 1
6(−0.1−2×0.095225 −2×0.090673 −0.090261) = 0.904257
Step 4: Repeat the process for each interval until we reach x= 0.5.
After calculations, the approximate value of y(0.5) using the fourth-order
Runge-Kutta method is y(0.5) ≈0.653193.
Question 19
Question
Use the fourth-order Runge-Kutta method to approximate the solution to the
initial value problem given by the differential equation y′=ex−y, with initial
condition y(0) = 1, at x= 1 using a step size of h= 0.2.
Solution
We can apply the fourth-order Runge-Kutta method to approximate the solution
to the initial value problem. The general formula for the fourth-order Runge-
Kutta method is given by:
yn+1 =yn+h
6(k1+ 2k2+ 2k3+k4)
where k1=f(xn, yn)
k2=f(xn+h
2, yn+h
2k1)
k3=f(xn+h
2, yn+h
2k2)
k4=f(xn+h, yn+hk3)
Let’s proceed with the calculation step by step.
Step 1: Compute k1, k2, k3,and k4.
k1=ex
n−yn=e0−1=1
k2=e(xn+h
2)−(yn+h
2k1) = e0.1−(1 + 0.1(1)) = 1.1051
k3=e(xn+h
2)−(yn+h
2k2) = e0.1−(1 + 0.1(1.1051)) = 1.106021
k4=e(xn+h)−(yn+hk3) = e0.2−(1 + 0.2(1.106021)) = 1.221281
18
Step 2: Use the formula to compute the approximation yn+1.
yn+1 =yn+h
6(k1+ 2k2+ 2k3+k4)
= 1 + 0.2
6(1 + 2(1.1051) + 2(1.106021) + 1.221281)
≈1.220929
Therefore, using the fourth-order Runge-Kutta method with a step size of
h= 0.2, the approximate value of y(1) is 1.220929.
Question 20
Question
Use the fourth-order Runge-Kutta method to approximate the solution to the
differential equation y′=x2+ywith initial condition y(0) = 1 at x= 0.2. Use
a step size of h= 0.1.
Solution
Step 1: Define the function f(x, y) = x2+y.
Step 2: Calculate the increments k1,k2,k3, and k4using the fourth-order
Runge-Kutta method:
k1=hf(xn, yn)
k2=hf(xn+h
2, yn+k1
2)
k3=hf(xn+h
2, yn+k2
2)
k4=hf(xn+h, yn+k3)
Step 3: Update the approximate solution using the formula:
yn+1 =yn+1
6(k1+ 2k2+ 2k3+k4)
Step 4: Substitute the initial condition y(0) = 1 and calculate the values at
each step until x= 0.2 with h= 0.1.
With h= 0.1, we have:
x0= 0, y0= 1
n xnynk1, k2, k3, k4yn+1
0 0.0 1.0 - -
1 0.1 - - -
2 0.2 - - -
Now, let’s proceed with the calculations.
19
Question 21
Question
Consider the initial value problem: dy
dx =x2+y2,y(0) = 1. Use the fourth-order
Runge-Kutta method with step size h= 0.1 to approximate the value of y(0.2).
Solution
Let’s denote f(x, y) = x2+y2. The fourth-order Runge-Kutta method is given
by the formulas:
k1=h·f(xn, yn),
k2=h·f(xn+h
2, yn+k1
2),
k3=h·f(xn+h
2, yn+k2
2),
k4=h·f(xn+h, yn+k3),
yn+1 =yn+1
6(k1+ 2k2+ 2k3+k4),
where his the step size, ynis the approximation of y(xn), kiare intermediate
values, and (xn, yn) are the known values.
Step 1: Calculate the approximations using the Runge-Kutta method.
First, let’s calculate k1,k2,k3, and k4:
k1= 0.1·(02+ 12) = 0.1,
k2= 0.1·((0 + 0.05)2+ (1 + 0.05)2)=0.105625,
k3= 0.1·((0 + 0.05)2+ (1 + 0.0528125)2) = 0.1104233,
k4= 0.1·((0 + 0.1)2+ (1 + 0.1104233)2)=0.1268839.
Now, calculate yn+1:
yn+1 = 1 + 1
6(0.1+2·0.105625 + 2 ·0.1104233 + 0.1268839)
= 1 + 1
6(0.1+0.21125 + 0.2208466 + 0.1268839)
= 1 + 0.66
6
= 1.11.
Therefore, using the fourth-order Runge-Kutta method, the approximation
of y(0.2) is y(0.2) ≈1.11.
20
Question 22
Question
Use the fourth-order Runge-Kutta method to approximate the solution to the
initial value problem dy
dx =x2+y, y(0) = 1
over the interval [0,2] with a step size of h= 0.5.
Solution
To approximate the solution to the given initial value problem using the fourth-
order Runge-Kutta method, we will follow these steps:
Step 1: Define the function f(x, y) = x2+y.
Step 2: Determine the number of subintervals based on the step size hand
the interval [0,2]:
N=2−0
0.5= 4
Step 3: Initialize the values with x0= 0 and y0= 1, and calculate the
approximations for yi+1:
k1=hf(xi, yi) = 0.5·(02+ 1) = 0.5
k2=hf(xi+h
2, yi+k1
2) = 0.5·(0.25 + 1.25) = 0.75
k3=hf(xi+h
2, yi+k2
2) = 0.5·(0.25 + 1.375) = 0.6875
k4=hf(xi+h, yi+k3) = 0.5·(1 + 1.6875) = 1.34375
yi+1 =yi+1
6(k1+ 2k2+ 2k3+k4) = 1 + 1
6(0.5+2·0.75 + 2 ·0.6875 + 1.34375)
= 1 + 1
6(0.5+1.5+1.375 + 1.34375) = 1 + 1
6(4.71875) ≈1.78646
Therefore, the approximate solution to the initial value problem over the
interval [0,2] with a step size of h= 0.5 is y(2) ≈1.78646.
Question 23
Question
Consider the initial value problem:
dy
dx =x2−y, y(0) = 1.
Use the fourth order Runge-Kutta method to approximate the value of yat
x= 1, using a step size of h= 0.2.
21
Solution
To approximate the value of yat x= 1 using the fourth order Runge-Kutta
method, we follow these steps:
Step 1: Define the function f(x, y) = x2−y.
Step 2: Calculate the intermediate values k1,k2,k3, and k4using the
following formulas:
k1=h·f(xn, yn),
k2=h·f(xn+h
2, yn+k1
2),
k3=h·f(xn+h
2, yn+k2
2),
k4=h·f(xn+h, yn+k3),
where xnand ynare the current values of xand y, respectively.
Step 3: Update the value of y:
yn+1 =yn+1
6(k1+ 2k2+ 2k3+k4).
Now, let’s perform the calculations:
Step 1: f(x, y) = x2−y.
Step 2:
k1= 0.2(02−1) = −0.2,
k2= 0.2(0.12−(1 −0.1·0.2/2)) = −0.19595,
k3= 0.2(0.12−(1 −0.1·0.19595/2)) = −0.19194,
k4= 0.2(0.22−(1 −0.1·0.19194)) = −0.18787.
Step 3:
y1= 1 + 1
6(−0.2 + 2(−0.19595) + 2(−0.19194) −0.18787)
= 1 + 1
6(−0.2−0.39190 −0.38388 −0.18787)
= 0.86938.
Therefore, the approximate value of yat x= 1 using the fourth order Runge-
Kutta method with a step size of h= 0.2 is y≈0.86938.
Question 24
Question
Consider the differential equation dy
dx = 2x2+ywith the initial condition y(0) =
1. Use the fourth-order Runge-Kutta method to estimate the value of yat x= 1
using step size h= 0.1.
22
Solution
To approximate the solution of the given initial value problem using the fourth-
order Runge-Kutta method, we will use the following formulas:
k1=hf(xn, yn)
k2=hf(xn+h
2, yn+k1
2)
k3=hf(xn+h
2, yn+k2
2)
k4=hf(xn+h, yn+k3)
yn+1 =yn+1
6(k1+ 2k2+ 2k3+k4)
where h= 0.1 and we will calculate the value of yat x= 1.
Step 1: Initialize the variables
We have x0= 0, y0= 1, and h= 0.1. We aim to estimate yat x= 1.
Step 2: Calculate the values of k1,k2,k3, and k4
Calculating:
k1= 0.1(2(0)2+ 1) = 0.1
k2= 0.1(2(0 + 0.05)2+ 1 + 0.05(0.1)/2) = 0.10125
k3= 0.1(2(0 + 0.05)2+ 1 + 0.10125/2) = 0.10150625
k4= 0.1(2(0.1)2+ 1 + 0.10150625) = 0.120150625
Step 3: Calculate the value of yat x= 1
y1= 1 + 1
6(0.1 + 2(0.10125) + 2(0.10150625) + 0.120150625) = 1.02484375
Therefore, the estimated value of yat x= 1 using the fourth-order Runge-
Kutta method with step size h= 0.1 is approximately 1.0248.
Question 25
Question
Use the fourth-order Runge-Kutta method to approximate the solution to the
initial value problem dy
dx =x2−y, y(0) = 1,
at x= 0.1 using a step size of h= 0.05.
23
Solution
Given the initial value problem
dy
dx =x2−y, y(0) = 1,
we will approximate the solution at x= 0.1 using the fourth-order Runge-Kutta
method with step size h= 0.05.
Step 1: Define the function f(x, y) based on the given differential equation:
f(x, y) = x2−y
Step 2: Implement the fourth-order Runge-Kutta method using the follow-
ing formulas:
k1=hf(xn, yn)
k2=hf(xn+h
2, yn+k1
2)
k3=hf(xn+h
2, yn+k2
2)
k4=hf(xn+h, yn+k3)
yn+1 =yn+1
6(k1+ 2k2+ 2k3+k4)
Step 3: Calculate the approximate value of yat x= 0.1 using the Runge-
Kutta method.
k1= 0.05 ·f(0,1) = 0.05 ·(02−1) = −0.05
k2= 0.05 ·f0 + 0.05
2,1 + −0.05
2= 0.05 ·f(0.025,0.975) = 0.05 ·(0.0252−0.975) ≈ −0.04984375
k3= 0.05 ·f0 + 0.05
2,1 + −0.04984375
2= 0.05 ·f(0.025,0.975078125) = 0.05 ·(0.0252−0.975078125) ≈ −0.04968749844
k4= 0.05 ·f(0 + 0.05,1+(−0.04968749844)) = 0.05 ·f(0.05,0.9503125016) = 0.05 ·(0.052−0.9503125016) ≈ −0.0495312458
y1= 1 + 1
6(−0.05 + 2(−0.04984375) + 2(−0.04968749844) −0.0495312458) ≈0.9502604168
Therefore, the approximate value of yat x= 0.1 using the fourth-order
Runge-Kutta method with a step size of h= 0.05 is approximately 0.9503.
Question 26
Question
Consider the initial value problem:
dy
dx =x2−y, y(0) = 1
Use the fourth-order Runge-Kutta method to approximate y(0.2) with a step
size of h= 0.1.
24
Solution
To approximate the value of y(0.2) using the fourth-order Runge-Kutta method,
we will need to compute the values of yat each step using the following formulas:
k1=hf(xn, yn),
k2=hf(xn+h
2, yn+k1
2),
k3=hf(xn+h
2, yn+k2
2),
k4=hf(xn+h, yn+k3),
where f(x, y) = x2−yfor our given differential equation.
Let’s start by computing the approximation using the fourth-order Runge-
Kutta method:
Step 1: k1= 0.1·(02−1) = −0.1,
Step 2: k2= 0.1·0 + −0.1
22
−(1 + −0.1
2) = −0.0775,
Step 3: k3= 0.1·0 + −0.0775
22
−(1 + −0.0775
2) = −0.07573125,
Step 4: k4= 0.1·(0 + (−0.07573125))2−(1 + (−0.07573125)) = −0.0227991675,
Step 5: y1= 1 + 1
6·(−0.1 + 2(−0.0775) + 2(−0.07573125) −0.0227991675) = 0.881200208.
Therefore, the approximate value of y(0.2) using the fourth-order Runge-Kutta
method with a step size of 0.1 is y(0.2) ≈0.8812.
Question 27
Question
Use the classical fourth-order Runge-Kutta method to approximate the solution
of the initial value problem
dy
dx =x2+y, y(0) = 1
over the interval [0,1] using a step size of h= 0.2.
Solution
We will use the classical fourth-order Runge-Kutta method to solve the initial
value problem step by step. Given the initial value problem:
dy
dx =x2+y, y(0) = 1
25
we will approximate the solution with a step size h= 0.2 on the interval [0,1]
using the fourth-order Runge-Kutta method.
Step 1: Initialize the problem
Given h= 0.2, a= 0, b= 1, y0= 1 and f(x, y) = x2+y.
Step 2: Calculate the slopes using the Runge-Kutta method
Using the fourth-order Runge-Kutta method, we calculate the slopes at four
intermediate points:
k1=hf(xn, yn)=0.2·((0)2+ 1) = 0.2
k2=hf(xn+h
2, yn+k1
2)=0.2·(0.1)2+ (1 + 0.2
2)= 0.2202
k3=hf(xn+h
2, yn+k2
2)=0.2·(0.1)2+ (1 + 0.2202
2)= 0.22084104
k4=hf(xn+h, yn+k3)=0.2·(0.2)2+ (1 + 0.22084104)= 0.24880821
Step 3: Use the slopes to calculate the next approximation
The next approximation is calculated as:
yn+1 =yn+1
6(k1+2k2+2k3+k4) = 1+1
6(0.2+2(0.2202)+2(0.22084104)+0.24880821) = 1.10996869
Therefore, using the fourth-order Runge-Kutta method with a step size of
0.2, the approximate solution to the initial value problem dy
dx =x2+y,y(0) = 1
at x= 1 is y≈1.10996869.
Question 28
Question
Use the fourth-order Runge-Kutta method to approximate the solution of the
initial value problem dy
dx =x2+y, y(0) = 1
over the interval [0,0.4] using a step size of h= 0.1. Provide the approximations
at x= 0.4.
Solution
Given the initial value problem
dy
dx =x2+y, y(0) = 1,
we will use the fourth-order Runge-Kutta method to approximate the solution.
Step 1: Define the step size and the number of steps. Given h= 0.1 and
the interval [0,0.4], we have n=0.4
0.1= 4 steps.
26
Step 2: Set up the Runge-Kutta formulas:
k1=hf(xn, yn),
k2=hf(xn+h
2, yn+k1
2),
k3=hf(xn+h
2, yn+k2
2),
k4=hf(xn+h, yn+k3),
yn+1 =yn+1
6(k1+ 2k2+ 2k3+k4).
Step 3: Perform the computations. Starting at x= 0 and y= 1, we have:
k1= 0.1(02+ 1) = 0.1,
k2= 0.1((0 + 0.05)2+ (1 + 0.05 ·0.1/2)) = 0.102625,
k3= 0.1((0 + 0.05)2+ (1 + 0.102625/2)) = 0.105262625,
k4= 0.1((0.1)2+ (1 + 0.105262625)) = 0.120115263,
y1= 1 + 1
6(0.1 + 2(0.102625) + 2(0.105262625) + 0.120115263) = 1.113772175.
Repeating these calculations for n= 1,2,3,4, we find:
y2= 1.238735054,
y3= 1.475485789,
y4= 1.833300142,
y5= 2.328068059.
Therefore, the approximate solution at x= 0.4 using the fourth-order Runge-
Kutta method is y(0.4) ≈2.328068059.
Question 29
Question
Use the fourth-order Runge-Kutta method with step size h= 0.1 to approximate
the solution of the initial value problem:
dy
dx =x2−y, y(0) = 1
over the interval 0 ≤x≤0.5.
Solution
To approximate the solution using the fourth-order Runge-Kutta method, we
will follow these steps:
27
Step 1: Define the function f(x, y) = x2−y.
Step 2: Set up the Runge-Kutta formula:
k1=h·f(xn, yn),
k2=h·f(xn+h
2, yn+k1
2),
k3=h·f(xn+h
2, yn+k2
2),
k4=h·f(xn+h, yn+k3),
yn+1 =yn+1
6(k1+ 2k2+ 2k3+k4)
Step 3: Implementing the method computationally, we have:
k1= 0.1·(02−1) = −0.1,
k2= 0.1·(0.052−(1 + −0.1
2)) = −0.0925,
k3= 0.1·(0.052−(1 + −0.0925
2)) = −0.085725,
k4= 0.1·(0.12−(1 −0.085725)) = −0.0734175,
y1= 1 + 1
6(−0.1 + 2(−0.0925) + 2(−0.085725) −0.0734175) ≈0.92242875
Therefore, the approximate solution at x= 0.1 is y1≈0.92242875.
Question 30
Question
Consider the initial value problem
dy
dx =e−2x−2y, y(0) = 1.
Use the 4th order Runge-Kutta method to estimate y(1) with a step size of
h= 0.1.
Solution
The 4th order Runge-Kutta method is given by the following formulas:
k1=hf(xn, yn),
k2=hf(xn+1
2h, yn+1
2k1),
k3=hf(xn+1
2h, yn+1
2k2),
k4=hf(xn+h, yn+k3),
yn+1 =yn+1
6(k1+ 2k2+ 2k3+k4),
28
where f(x, y) = e−2x−2y.
Step 1: Evaluate y1using x0= 0 and y0= 1.
k1= 0.1(e0−2(1)) = 0.1(e−2),
k2= 0.1(e−1
2−2(1 + 1
2(0.1(e−2)))) = 0.1(e−1
2−2(1.05e−2.1)),
k3= 0.1(e−1
2−2(1 + 1
2(0.1(e−1
2−2(1.05e−2.1)))))
= 0.1(e−1
2−2(1.0525e−2.104)),
k4= 0.1(e−1−2(1.105e−2.207)) = 0.1(e−1−2.21e−4.414),
y1= 1 + 1
6(0.1(e−2) + 2(0.1(e−1
2−2(1.05e−2.1))
+ 2(0.1(e−1
2−2(1.0525e−2.104)) + 0.1(e−1−2.21e−4.414)))
≈0.843376.
Therefore, the estimate for y(1) using the 4th order Runge-Kutta method
with step size h= 0.1 is approximately 0.843376.
Question 31
Question
Use the fourth-order Runge-Kutta method to approximate the solution to the
initial value problem dy
dx =x2−2y, y(0) = 1
over the interval [0,1] using a step size of h= 0.1.
Solution
We will use the fourth-order Runge-Kutta method to approximate the solution
to the initial value problem. The fourth-order Runge-Kutta method is given by
the following formulas:
k1=h·f(xn, yn),
k2=h·f(xn+h
2, yn+k1
2),
k3=h·f(xn+h
2, yn+k2
2),
k4=h·f(xn+h, yn+k3),
yn+1 =yn+1
6(k1+ 2k2+ 2k3+k4),
where f(x, y) = x2−2y.
Step 1: First, we start by calculating the values of yat each step using the
fourth-order Runge-Kutta method.
29
Step 2: For x0= 0 and y0= 1, we have:
k1= 0.1·(02−2·1) = −0.2,
k2= 0.1·((0 + 0.05)2−2·(1 −0.1·0.2/2)) = −0.184,
k3= 0.1·((0 + 0.05)2−2·(1 −0.1·0.184/2)) = −0.18428,
k4= 0.1·((0 + 0.1)2−2·(1 −0.1·(−0.18428))) = −0.1643344,
y1= 1 + 1
6(−0.2 + 2(−0.184) + 2(−0.18428) −0.1643344) = 0.85286356.
The approximate solution at x= 0.1 is y1≈0.85286356.
Step 3: We repeat the process to find y2, y3, . . . , y10 until x= 1.
Step 4: Finally, we tabulate the values of xand y:
x y
0.0 1.0
0.1 0.85286356
0.2 ?
0.3 ?
0.4 ?
0.5 ?
0.6 ?
0.7 ?
0.8 ?
0.9 ?
1.0 ?
Question 32
Question
Use the fourth-order Runge-Kutta method with step size h= 0.1 to approximate
the solution to the initial value problem:
dy
dx =x2−y, y(0) = 1
for x= 0.1,0.2,0.3,0.4.
Solution
To apply the fourth-order Runge-Kutta method to approximate the solution,
we first need to calculate the increments kifor i= 1,2,3,4 using the following
formulas:
k1=hf(xn, yn)
k2=hf(xn+h
2, yn+k1
2)
30
k3=hf(xn+h
2, yn+k2
2)
k4=hf(xn+h, yn+k3)
where f(x, y) = x2−y.
Then, we use these increments to calculate the next value of y:
yn+1 =yn+1
6(k1+ 2k2+ 2k3+k4)
Let’s proceed to calculate the solution.
Step 1: For x= 0.1:
k1= 0.1(02−1) = −0.1
k2= 0.1(0 + −0.1
2) = −0.005
k3= 0.1(0 + −0.005
2) = −0.00025
k4= 0.1(0.1+(−0.00025)) = 0.009975
y1= 1 + 1
6(−0.1 + 2(−0.005) + 2(−0.00025) + 0.009975) = 0.998370833
Step 2: For x= 0.2:
k1= 0.1((0.1)2−0.998370833) ≈ −0.097621667
k2≈0.1(0.1 + −0.097621667
2)≈ −0.009661667
k3≈0.1(0.1 + −0.009661667
2)≈ −0.000483083
k4≈0.1(0.2+(−0.000483083)) ≈0.019951918
y2= 0.998370833 + 1
6(−0.097621667 + 2(−0.009661667) + 2(−0.000483083) + 0.019951918) ≈0.993691273
Step 3: For x= 0.3 and x= 0.4: Similarly, we calculate kifor i= 1,2,3,4
and find y3and y4.
The approximate solution values are y1≈0.998370833, y2≈0.993691273,
y3≈0.986974342, and y4≈0.977399948.
Question 33
Question
Use the Runge-Kutta method with four steps to approximate the solution to
the initial value problem: dy
dx =x−y,y(0) = 1, for h= 0.2. Find the value of
y(0.8).
31
Solution
The Runge-Kutta method with four steps is given by:
yn+1 =yn+h
6(k1+ 2k2+ 2k3+k4)
where
k1=f(xn, yn)
k2=f(xn+h
2, yn+h
2k1)
k3=f(xn+h
2, yn+h
2k2)
k4=f(xn+h, yn+hk3)
Here, f(x, y) = x−y. For this problem, x0= 0, y0= 1, and h= 0.2. We
want to find y(0.8).
h= 0.2
x0= 0
y0= 1
x1= 0.2
x2= 0.4
x3= 0.6
x4= 0.8
Step 1: Calculate k1, Since k1=x0−y0,
k1= 0 −1 = −1
Step 2: Calculate k2,
k2=f(x0+h
2, y0+h
2k1)
=f(0.1,1+0.1(−1))
=f(0.1,0.9)
= 0.1−0.9
=−0.8
Step 3: Calculate k3,
k3=f(x0+h
2, y0+h
2k2)
=f(0.1,1+0.1(−0.8))
=f(0.1,0.92)
= 0.1−0.92
=−0.82
32
Step 4: Calculate k4,
k4=f(x0+h, y0+hk3)
=f(0.2,1+0.2(−0.82))
=f(0.2,0.836)
= 0.2−0.836
=−0.636
Step 5: Calculate the next approximation value y1,
y1=y0+h
6(k1+ 2k2+ 2k3+k4)
= 1 + 0.2
6(−1 + 2(−0.8) + 2(−0.82) −0.636)
= 1 + 0.2
6(−1−1.6−1.64 −0.636)
= 1 + 0.2
6(−4.276)
= 1 + −0.71333
6
= 1 −0.11889
= 0.88111
Therefore, the approximation for the value of y(0.8) using the Runge-Kutta
method with four steps is y(0.8) = 0.88111
Question 34
Question
Consider the initial value problem:
(y′=−2xy
y(0) = 1
Use the fourth-order Runge-Kutta method to approximate y(0.5) using a step
size of h= 0.1.
33
Solution
The fourth-order Runge-Kutta method is given by the following formulas:
k1=hf(xn, yn)
k2=hf(xn+h
2, yn+k1
2)
k3=hf(xn+h
2, yn+k2
2)
k4=hf(xn+h, yn+k3)
yn+1 =yn+1
6(k1+ 2k2+ 2k3+k4)
where
f(x, y) = −2xy
Step 1: Define the necessary variables:
h= 0.1
x0= 0
y0= 1
x1=x0+h
k1=hf(x0, y0)=0.1(−2(0)(1)) = 0
k2=hf(x0+h
2, y0+k1
2)
k3=hf(x0+h
2, y0+k2
2)
k4=hf(x1, y0+k3)
Step 2: Calculate k2:
k2= 0.1f(0 + 0.1
2,1 + 0
2)
= 0.1(−2(0.1
2)(1))
=−0.001
Step 3: Calculate k3:
k3= 0.1f(0 + 0.1
2,1 + −0.001
2)
= 0.1(−2(0.1
2)(1 + −0.001
2))
=−0.0019995
Step 4: Calculate k4:
k4= 0.1f(0.1,1−0.0019995)
= 0.1(−2(0.1)(0.9980005))
=−0.001996010
34
Step 5: Finally, calculate y1:
y1= 1 + 1
6(0 + 2(−0.001) + 2(−0.0019995) −0.001996010)
= 1 + 1
6(−0.003999)
= 0.999333
Therefore, the approximate value of y(0.1) using the fourth-order Runge-
Kutta method is 0.999333.
Question 35
Question
Consider the initial value problem
dy
dx =x2+y, y(0) = 1
Use the fourth-order Runge-Kutta method to approximate y(0.1) with a step
size of h= 0.05.
Solution
Let h= 0.05 be the step size, so x0= 0, y0= 1, and x1=x0+h= 0.05.
Step 1: Calculate the intermediate values of k1,k2,k3, and k4:
k1=hf(x0, y0)=0.05[(0)2+ 1] = 0.05
k2=hf(x0+ 0.5h, y0+ 0.5k1)=0.05[(0.025)2+ 1.025] = 0.05256
k3=hf(x0+ 0.5h, y0+ 0.5k2)=0.05[(0.025)2+ 1.02628] = 0.052635
k4=hf(x0+h, y0+k3)=0.05[(0.05)2+ 1.0798] = 0.05495
Step 2: Use these values to find the next approximation y1:
y1=y0+1
6(k1+ 2k2+ 2k3+k4)
= 1 + 1
6(0.05 + 2(0.05256) + 2(0.052635) + 0.05495)
= 1 + 1
6(0.05 + 0.10512 + 0.10527 + 0.05495)
= 1 + 1
6(0.31534)
= 1.05256
Therefore, the approximate value of y(0.1) using the fourth-order Runge-
Kutta method with h= 0.05 is y(0.1) ≈1.05256.
35