1 / 68100%
MATH 334 - DIFFERENTIAL
EQUATIONS - Runge-Kutta methods
Question Bank - Set 4
Liberty University
Question 1
Question
Consider the initial value problem given by the differential equation:
y= 2yex, y(0) = 1
Use the second-order Runge-Kutta method (RK2) to estimate the value of y(1)
using a step size of h= 0.2.
Solution
The second-order Runge-Kutta method (RK2) is given by the following formu-
las:
k1=hf(xn, yn)
k2=hf(xn+h
2, yn+k1
2)
yn+1 =yn+k2+O(h3)
where f(x, y)=2yexis the differential equation function.
Step 1: Calculate the values of k1and k2at each step using the given
differential equation and RK2 formulas.
For x0= 0, y0= 1:
k1= 0.2·(2 ·1e0) = 0.41 = 0.6
k2= 0.2·(2·(1+0.6
2)e0+ 0.2
2)=0.2·(2·0.7e0.1)=0.2·(1.4e0.1)0.2(1.40.905) 0.2·0.495 = 0.099
Step 2: Use the RK2 formula to update the value of yat each step.
For x1= 0.2:
y1= 1 + 0.099 1.099
Repeat the process for x2= 0.4, x3= 0.6, x4= 0.8, and x5= 1.
Step 3: Calculate the estimated value of y(1) using the RK2 method with
step size h= 0.2.
The estimated value of y(1) is approximately 1.1257.
Question 2
Question
Consider the initial value problem:
dy
dx =x2+y, y(0) = 1
Use the Runge-Kutta method with step size h= 0.2 to approximate the
value of y(0.4). Perform the calculations using 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+y.
Solution
Step 1: Initialize the values using x0= 0, y0= 1, and h= 0.2.
h= 0.2, x0= 0, y0= 1
Step 2: Calculate k1,k2,k3, and k4.
k1= 0.2·f(0,1) = 0.2·(02+ 1) = 0.2
k2= 0.2·f0 + 0.2
2,1 + 0.2
2= 0.2·(0.12+ 1.1) = 0.22
k3= 0.2·f0 + 0.2
2,1 + 0.22
2= 0.2·(0.12+ 1.11) = 0.222
k4= 0.2·f(0 + 0.2,1+0.222) = 0.2·(0.22+ 1.222) 0.269
2
Step 3: Compute the new approximation for y.
y1= 1 + 1
6(0.2 + 2(0.22) + 2(0.222) + 0.269)
= 1 + 1
6(0.2+0.44 + 0.444 + 0.269)
= 1 + 1
6(1.353)
= 1 + 0.2255
= 1.2255
Therefore, using the Runge-Kutta method with step size h= 0.2, the ap-
proximate value of y(0.4) is y1.2255.
Question 3
Question
Consider the initial value problem:
dy
dx =x2y2, y(0) = 1,
approximating the solution using the Runge-Kutta method. Use a step size of
h= 0.2 to estimate yat x= 1.
Solution
To apply the Runge-Kutta method to the given initial value problem, we will
use the following equations:
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+k1+ 2k2+ 2k3+k4
6.
Here, h= 0.2 and we want to estimate yat x= 1.
Step 1: Define the function f(x, y) = x2y2and the initial condition
y(0) = 1.
3
Step 2: Calculate the values of k1,k2,k3, and k4:
k1= 0.2(0212) = 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.1968,
k4= 0.2 (0 + 0.2,1+0.1968) = 0.23936.
Step 3: Use the formula to find yn+1:
y1= 1 + 0.2 + 2(0.18) + 2(0.1968) + 0.23936
61.0328.
Therefore, with a step size of h= 0.2, the Runge-Kutta method estimates y
at x= 1 to be approximately 1.0328.
Question 4
Question
Use the fourth-order Runge-Kutta method to approximate the solution of the
initial value problem: dy
dx =x2+y2, y(0) = 1
over the interval [0,1] using a step size of h= 0.1. Calculate the approximate
value of y(1).
Solution
Given the initial value problem:
dy
dx =x2+y2, y(0) = 1
we will use the fourth-order Runge-Kutta method to approximate the value of
y(1).
The general formula for the fourth-order Runge-Kutta method is 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)
4
where his the step size, xnis the current value of x,ynis the current value
of y, and f(xn, yn) = x2
n+y2
n.
We will perform the calculations for each iteration from x= 0 to x= 1 with
a step size of h= 0.1.
Step 1: Initialize the values: x0= 0, y0= 1, and h= 0.1.
Step 2: For n= 0, calculate:
k1=h(x0, y0)=0.1(02+ 12)=0.1
k2=h(x0+h
2, y0+k1
2)=0.10 + 0.1
2= 0.005
k3=h(x0+h
2, y0+k2
2)=0.10 + 0.005
2= 0.00025
k4=h(x0+h, y0+k3)=0.1 (0 + 0.00025) = 0.000025
y1=y0+1
6(k1+ 2k2+ 2k3+k4) = 1 + 1
6(0.1 + 2(0.005) + 2(0.00025) + 0.000025) 1.09085
Step 3: Continue the process for n= 1 until x= 1.
After the final iteration, the approximate value of y(1) is 1.09085.
Question 5
Question
Use the fourth-order Runge-Kutta method to approximate the solution to the
initial value problem: dy
dx =x2+y2, y(0) = 1,
over the interval [0, 0.4]. Use a step size of h= 0.1.
Solution
Let’s denote f(x, y) = x2+y2. 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 his the step size, xnis the current value of x,ynis the current value of
y, and yn+1 is the next value of y.
5
Step 1: Initialize the values
For this problem: x0= 0, y0= 1, h= 0.1, and f(x, y) = x2+y2.
Step 2: Calculate the approximate solution
For each iteration: - Calculate k1,k2,k3, and k4using the formulas above. -
Update yusing the formula yn+1 =yn+1
6(k1+ 2k2+ 2k3+k4). - Update x.
Repeat the above steps until you reach x= 0.4.
After performing the calculations, the approximate value of yat x= 0.4
using the fourth-order Runge-Kutta method with a step size of h= 0.1 is
approximately y(0.4) 1.6929.
Question 6
Question
Consider the initial value problem dy
dx =x22ywith y(0) = 1. Use the fourth-
order Runge-Kutta method to approximate y(0.1) using a step size of h= 0.02.
Solution
Step 1: Define the function f(x, y) = x22y.
Step 2: Calculate the increments k1,k2,k3, and k4using the following formu-
las: 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).
Step 3: Update the values of xand yusing the formula: yn+1 =yn+1
6(k1+
2k2+ 2k3+k4).
Now, let’s calculate the approximation.
Step 1: f(x, y) = x22y.
Step 2:
k1= 0.02 ·(022·1) = 0.04,
k2= 0.02 ·(0 + 0.01)22·(1 0.02)=0.0397,
k3= 0.02 ·(0 + 0.01)22·(1 0.0397/2)=0.039319,
k4= 0.02 ·(0 + 0.02)22·(1 0.039319)=0.038904.
Step 3:
y1= 1 + 1
6(0.04 + 2(0.0397) + 2(0.039319) 0.038904)
= 0.960249.
Therefore, the fourth-order Runge-Kutta approximation of y(0.1) is y(0.1)
0.960249.
6
Question 7
Question
Consider the initial value problem given by dy
dx =x2+y2,y(0) = 0, and let
y(1) be approximated using the fourth-order Runge-Kutta method with step
size h= 0.1. Find the approximate value of y(1).
Solution
Step 1: We first calculate the number of steps needed to reach x= 1 with step
size h= 0.1. The number of steps is given by N=10
0.1= 10.
Step 2: Initialize the Runge-Kutta method with the given initial condition
y(0) = 0. Let x0= 0, y0= 0, and h= 0.1. We will use the 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)
Step 3: Calculate the approximate value of yat x= 1 using the Runge-
Kutta method. We repeat the following steps for n= 0,1,...,9: (i) Calculate
k1,k2,k3, and k4using the above expressions. (ii) Update yn+1 =yn+1
6(k1+
2k2+ 2k3+k4). (iii) Update xn+1 =xn+h.
Step 4: Once we have computed y(1), the approximate value is the final y
value obtained after Nsteps. After the final step, we find that y(1) 1.708.
Question 8
Question
Consider the initial value problem given by
dy
dx =x2y2, y(0) = 1.
Use the fourth-order Runge-Kutta method with step size h= 0.1 to estimate
y(0.4). Use the formula for the 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),
yn+1 =yn+1
6(k1+ 2k2+ 2k3+k4),
7
where f(x, y) = x2y2.
Solution
Given initial conditions y(0) = 1 and step size h= 0.1, we will use the fourth-
order Runge-Kutta method to estimate y(0.4). We start by applying the method
iteratively.
Step 1: Calculate k1.
k1= 0.1·f(0,1) = 0.1·(0212) = 0.1
Step 2: Calculate k2.
k2= 0.1·f0 + 0.1
2,1 + 0.1
2= 0.1·f(0.05,0.95)
= 0.1·0.0520.952 0.11245
Step 3: Calculate k3.
k3= 0.1·f0 + 0.1
2,1 + 0.11245
2= 0.1·f(0.05,0.918775)
= 0.1·0.0520.9187752 0.107863
Step 4: Calculate k4.
k4= 0.1·f(0 + 0.1,10.107863) = 0.1·f(0.1,0.892137)
= 0.1·0.120.8921372 0.080172
Step 5: Update yusing the weighted average of k1,k2,k3, and k4.
y1= 1 + 1
6(0.1 + 2(0.11245) + 2(0.107863) 0.080172) 0.882792
Therefore, the estimate for y(0.4) using the fourth-order Runge-Kutta method
with step size h= 0.1 is approximately 0.882792.
Question 9
Question
Let’s consider the initial value problem given by dy
dx =x2+y2with y(0) = 1. Use
the fourth-order Runge-Kutta method with a step size of h= 0.1 to estimate
the value of yat x= 0.4.
8
Solution
To approximate the value of yat x= 0.4, we will apply the fourth-order Runge-
Kutta method with the given step size.
Step 1: We need to calculate the values at different points 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)
where f(x, y) = x2+y2.
Step 2: Calculate the next value of yusing:
yn+1 =yn+1
6(k1+ 2k2+ 2k3+k4)
Step 3: Now, calculate the values for each iteration:
For n= 0:
k1= 0.1(02+ 12)=0.1
k2= 0.1(0 + 0.1
2)2+ (1 + 0.1
2)2= 0.1025
k3= 0.1(0 + 0.1
2)2+ (1 + 0.1025
2)2= 0.105100625
k4= 0.1(0.1) + (1.105100625) = 0.2105100625
y1= 1 + 1
6(0.1 + 2(0.1025) + 2(0.105100625) + 0.2105100625) 1.059736746
For n= 1:
k1= 0.1(0.12+ 1.0597367462)0.1130869677
k2= 0.1(0.1+ 0.1130869677
2)2+(1.059736746+ 0.1130869677
2)20.1191109287
k3= 0.1(0.1+ 0.1130869677
2)2+(1.059736746+ 0.1191109287
2)20.1254285423
k4= 0.1(0.1) + (1.1254285423) 0.2379428549
y2= 1.059736746+1
6(0.1130869677+2(0.1191109287)+2(0.1254285423)+0.2379428549) 1.122962847
Therefore, the estimate for yat x= 0.4 using the fourth-order Runge-Kutta
method with step size h= 0.1 is approximately 1.122962847.
9
Question 10
Question
Consider the initial value problem:
dy
dx =x2+y, y(0) = 1.
Use the fourth-order Runge-Kutta method to approximate y(1) using a step size
of h= 0.2.
Solution
To approximate the solution using the fourth-order Runge-Kutta method, we
will follow these steps:
Step 1: Define the function f(x, y) based on the given differential equation
f(x, y) = x2+y.
Step 2: Set the initial conditions
x0= 0, y0= 1, h = 0.2.
Step 3: Use the fourth-order Runge-Kutta formulas to compute the ap-
proximations:
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 nrepresents the current step.
Step 4: Substitute the given values into the formulas and calculate the
intermediate values:
k1= 0.2·(02+ 1) = 0.2,
k2= 0.2·(0.12+ 1 + 0.1·0.2) = 0.22067,
k3= 0.2·(0.12+ 1 + 0.1·0.22067) = 0.24216633,
k4= 0.2·(0.22+ 1 + 0.1·0.24216633) = 0.2741357,
y1= 1 + 1
6(0.2+2·0.22067 + 2 ·0.24216633 + 0.2741357) 1.09953203.
Therefore, using the fourth-order Runge-Kutta method with a step size of
h= 0.2, the approximate value of y(1) is 1.0995.
10
Question 11
Question
Consider the initial value problem dy
dx =x2+y2, with initial condition y(0) = 1.
Use the Runge-Kutta method of order four to approximate the value of y(1)
with step size h= 0.1.
Solution
The Runge-Kutta method of order four 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) = x2+y2,his the step size, xnis the current x-value, ynis
the current y-value, and yn+1 is the next y-value.
Step 1: We will evaluate the values of k1,k2,k3, and k4at each step to
find the approximations.
Step 2: At x= 0, y= 1, we have:
k1= 0.1·(02+ 12)=0.1
k2= 0.1·0 + 0.1
22
+1 + 0.1
22
= 0.11025
k3= 0.1·0 + 0.1
22
+1 + 0.11025
22
= 0.111343
k4= 0.1·(0 + 0.1)2+ (1 + 0.111343)2= 0.121576
Step 3: Now, we can calculate the next value of yusing the Runge-Kutta
formula:
y1= 1 + 1
6(0.1 + 2(0.11025) + 2(0.111343) + 0.121576); y11.122523
Therefore, the approximate value of y(1) using the Runge-Kutta method
with step size h= 0.1 is y(1) 1.122523.
11
Question 12
Question
Use the fourth-order Runge-Kutta method to approximate the solution to the
initial value problem:
dy
dx =x2+y, y(0) = 1
Find an approximation to y(0.1) using a step size of h= 0.05.
Solution
Step 1: We first represent the given initial value problem in the form required
for Runge-Kutta method. Let f(x, y) = x2+y. The general formula for the
fourth-order Runge-Kutta method is given by:
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)
where his the step size.
Step 2: We begin the computations. Let n= 0, x0= 0, and y0= 1.
k1= 0.05(02+ 1) = 0.05
k2= 0.05 0 + 1
2(0.05)(1)= 0.025
k3= 0.05 0 + 1
2(0.05)(1 + 0.025)= 0.0275
k4= 0.05 (0.05,1+0.0275) = 0.02875
y1= 1 + 1
6(0.05 + 2(0.025) + 2(0.0275) + 0.02875) 1.05606
Therefore, using the fourth-order Runge-Kutta method with a step size of
0.05 gives an approximation of y(0.1) 1.05606.
Question 13
Question
Consider the initial value problem y=x2+y2with y(0) = 1. Use the fourth-
order Runge-Kutta method to approximate y(0.4) with step size h= 0.1.
12
Solution
Let’s denote f(x, y) = x2+y2,h= 0.1, x0= 0, and y0= 1. We will use the
fourth-order Runge-Kutta method to approximate y(0.4).
Step 1: Calculate k1,k2,k3, and k4using the following formulas:
k1=hf(x0, y0)
k2=hf x0+h
2, y0+k1
2
k3=hf x0+h
2, y0+k2
2
k4=hf (x0+h, y0+k3)
Step 2: Use the following formula to update the value of y:
y1=y0+1
6(k1+ 2k2+ 2k3+k4)
Now, let’s perform the calculations.
Step 1:
k1= 0.1(02+ 12)=0.1
k2= 0.10 + 0.1
22
+1 + 0.1
22
= 0.10255
k3= 0.10 + 0.1
22
+1 + 0.10255
22
= 0.1052042
k4= 0.1 (0 + 0.1)2+ (1 + 0.1052042)2= 0.108368784
Step 2:
y1= 1 + 1
6(0.1 + 2(0.10255) + 2(0.1052042) + 0.108368784) = 1.1176246
Therefore, the approximate value of y(0.4) using the fourth-order Runge-
Kutta method is y(0.4) 1.1176 when h= 0.1.
Question 14
Question
Use the fourth-order Runge-Kutta method to approximate the solution of the
initial value problem: dy
dx =x+y, y(0) = 1
over the interval [0,1] with a step size of h= 0.1. Compute the approximation
of y(1).
13
Solution
Step 1: Define the function f(x, y) = x+y.
Step 2: Calculate the slopes k1, k2, k3,and k4using the fourth-order 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)
Step 3: Update the value of yn+1 using the formula:
yn+1 =yn+1
6(k1+ 2k2+ 2k3+k4)
Step 4: Use the initial condition y(0) = 1 and step size h= 0.1 to approxi-
mate y(1). Applying the formulas above iteratively will give the computed value
of y(1).
Question 15
Question
Given the initial value problem dy
dx =x2+y, with initial condition y(0) =
1, approximate the value of y(1) using the classical fourth-order Runge-Kutta
method with step size h= 0.1.
Solution
The classical fourth-order Runge-Kutta method consists of the following formu-
las: 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),
yn+1 =yn+1
6(k1+ 2k2+ 2k3+k4),
where f(xn, yn) = x2
n+yn.
Step 1: Initialize the given values Given h= 0.1, y(0) = 1, and we want to
find y(1).
14
Step 2: Calculate y(1) using Runge-Kutta method
k1= 0.1·(02+ 1) = 0.1,
k2= 0.1·0.052+1+0.1
2= 0.10525,
k3= 0.1·0.052+1+0.10525
2= 0.11043625,
k4= 0.1·(0.1+1+0.11043625) = 0.211043625
y(1) 1 + 1
6(0.1 + 2(0.10525) + 2(0.11043625) + 0.211043625) = 1.13564375.
Therefore, the approximate value of y(1) using the classical fourth-order
Runge-Kutta method with step size h= 0.1 is y(1) 1.13564375.
Question 16
Question
Consider the following initial value problem:
(y= 2yx,
y(0) = 1,
Approximate the value of y(0.2) using the fourth-order Runge-Kutta method
with a step size of h= 0.1.
Solution
Step 1: Define the Runge-Kutta method. For the fourth-order Runge-Kutta
method, the formula is 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 his the step size, f(x, y) is the derivative function, xnis the current
value of x,ynis the current value of y, and yn+1 is the next value of yat
xn+1 =xn+h.
15
Step 2: Define f(x, y) and calculate the values of k1,k2,k3, and k4using
the given initial value problem:
f(x, y) = 2yx,
k1= 0.1(2 ·10) = 0.2,
k2= 0.1(2 ·10+0.1·0.2
2)=0.21,
k3= 0.1(2 ·10+0.1·0.21
2) = 0.21205,
k4= 0.1(2 ·10.1+0.21205) = 0.258205,
Step 3: Calculate the new value of yusing the formula:
y1= 1 + 1
6(0.2+2·0.21 + 2 ·0.21205 + 0.258205)
= 1 + 1
6(0.2+0.42 + 0.4241 + 0.258205)
= 1 + 1
6(1.302305)
1.21705,
Therefore, the approximate value of y(0.2) using the fourth-order Runge-
Kutta method with a step size of h= 0.1 is y(0.2) 1.21705.
Question 17
Question
Consider the initial value problem
dy
dt =t2y, y(0) = 1.
Apply the fourth-order Runge-Kutta method to approximate y(1) using a step
size of h= 0.2.
Solution
The fourth-order Runge-Kutta method is given by the following formulas:
k1=hf(tn, yn),
k2=hf(tn+h
2, yn+k1
2),
k3=hf(tn+h
2, yn+k2
2),
k4=hf(tn+h, yn+k3),
yn+1 =yn+1
6(k1+ 2k2+ 2k3+k4).
16
Step 1: Define the function f(t, y) = t2yand the initial conditions.
f(t, y) = t2y, y(0) = 1.
Step 2: Apply the fourth-order Runge-Kutta method to approximate y(1)
with h= 0.2.
First, we set t0= 0 and y0= 1, then we compute:
k1= 0.2·f(0,1) = 0.2·(021) = 0.2,
k2= 0.2·f(0 + 0.1,1+0.1·(0.1)) = 0.2·(0.120.99) = 0.19801,
k3= 0.2·f(0 + 0.1,1+0.1·(0.099005)) = 0.2·(0.120.980995) = 0.19601,
k4= 0.2·f(0.2,1+0.2·(0.19601)) = 0.2·(0.220.960399) = 0.19388,
y1= 1 + 1
6(0.2 + 2(0.19801) + 2(0.19601) + (0.19388)) = 0.806264.
Therefore, the approximate value of y(1) using the fourth-order Runge-Kutta
method with h= 0.2 is y(1) 0.806264.
Question 18
Question
Use the fourth-order Runge-Kutta method to approximate the solution of the
initial value problem:
dy
dx =x2y2, y(0) = 1
Calculate the approximate value of y at x = 0.1 using a step size of h = 0.1.
Solution
To apply the fourth-order Runge-Kutta (RK4) 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 f(xn, yn) = x2
ny2
n.
Given h= 0.1, we will calculate y(0.1) using RK4.
17
Step 1: Calculate k1:
k1= 0.1·(0212) = 0.1
Step 2: Calculate k2:
k2= 0.1· 0 + 0.1
22
1 + 0.1
22!= 0.09025
Step 3: Calculate k3:
k3= 0.1· 0 + 0.1
22
1 + 0.09025
22!= 0.0849799375
Step 4: Calculate k4:
k4= 0.1·(0 + 0.1)2(1 + 0.0849799375)2= 0.0685921869
Step 5: Calculate y(0.1):
y(0.1) = 1 + 1
6(0.1 + 2(0.09025) + 2(0.0849799375) + 0.0685921869) 0.9105
Therefore, the approximate value of y(0.1) using the fourth-order Runge-
Kutta method is approximately 0.9105.
Question 19
Question
Consider the following initial value problem:
dy
dx =x2y, y(0) = 1
Use a fourth-order Runge-Kutta method with step size h= 0.2 to approximate
y(1).
Solution
To approximate y(1) using the fourth-order Runge-Kutta method, we need to
calculate the values of yat each step. We will use the 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)
18
where f(x, y) = x2y.
Step 1: Initialize the values using h= 0.2:
x0= 0, y0= 1, h = 0.2
Step 2: Calculate y1using the Runge-Kutta method:
k1= 0.2((0)21) = 0.2
k2= 0.2((0.1)2(1 0.1·0.2/2)) = 0.198
k3= 0.2((0.1)2(1 0.2·0.198/2)) = 0.19602
k4= 0.2((0.2)2(1 0.2·(0.19602))) = 0.194792
y1= 1 + 1
6(0.2 + 2(0.198) + 2(0.19602) 0.194792) 0.8373
Therefore, the approximate value of y(1) using the fourth-order Runge-Kutta
method with h= 0.2 is y(1) 0.8373.
Question 20
Question
Consider the initial value problem
dy
dx =x2y, y(0) = 1.
Use the fourth-order Runge-Kutta method to approximate the value of y(0.1)
using a step size of h= 0.02.
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) = x2y, xnis the current value of x, and ynis the current value
of y.
Let’s apply the Runge-Kutta method with h= 0.02 to approximate y(0.1):
19
Step 1: Calculate k1:
k1= 0.02 ·((0)21) = 0.02.
Step 2: Calculate k2:
k2= 0.02 ·((0 + 0.01)2(1 0.02/2)) = 0.0199.
Step 3: Calculate k3:
k3= 0.02 ·((0 + 0.01)2(1 + 0.0199/2)) = 0.019801.
Step 4: Calculate k4:
k4= 0.02 ·((0.02)2(1 + 0.019801)) = 0.01979398.
Step 5: Calculate y(0.02):
y1= 1 + 1
6(0.02 + 2(0.0199) + 2(0.019801) 0.01979398) = 0.980145.
Therefore, the approximate value of y(0.02) using the fourth-order Runge-
Kutta method is 0.980145.
Question 21
Question
Consider the initial value problem given by the differential equation:
y= 2 y
x, y(1) = 1
Use the fourth-order Runge-Kutta method to estimate the value of yat
x= 2 using a step size of h= 0.5.
Solution
To apply the fourth-order Runge-Kutta method, we follow these steps at each
iteration:
Given the initial condition y(1) = 1, we want to estimate y(2) with a step
size of h= 0.5. Let’s denote xn= 1+0.5nand ynbe an approximation of y(xn)
for n= 0,1,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)
20
where f(x, y)=2y
x.
Step 2: Update yn+1 using the formula:
yn+1 =yn+1
6(k1+ 2k2+ 2k3+k4)
Now, let’s calculate the approximations step by step:
Step 1: At x= 1, we have y0= 1. Using the RK4 formulas:
k1= 0.5(2 1) = 0.5
k2= 0.521+0.25
1+0.25= 0.5(2 5
4)=0.375
k3= 0.521+0.25
1+0.25= 0.5(2 5
4)=0.375
k4= 0.521+0.5
1+0.5= 0.5(2 3
2)=0.25
Step 2: Calculate y1:
y1= 1 + 1
6(0.5 + 2(0.375) + 2(0.375) + 0.25)
= 1 + 1
6(0.5+0.75 + 0.75 + 0.25)
= 1 + 1
6(2.25)
= 1 + 0.375
= 1.375
Therefore, the estimated value of y(2) using the fourth-order Runge-Kutta
method with step size 0.5 is y(2) 1.375.
Question 22
Question
Given the initial value problem
dy
dx =x2y, y(0) = 1,
approximate the value of y(1) using the fourth-order Runge-Kutta method with
step size h= 0.2.
Solution
To approximate the value of y(1) using the fourth-order Runge-Kutta method,
we will follow these steps:
21
Step 1: Define the function f(x, y) = x2y.
Step 2: Calculate the increments k1,k2,k3, and k4using 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).
where xnand ynare the previous values.
Step 3: Update the values of xand yusing the formula:
yn+1 =yn+1
6(k1+ 2k2+ 2k3+k4).
Step 4: Repeat Steps 2 and 3 until x= 1.
Let’s calculate the approximate value of y(1) using the given steps.
Question 23
Question
Given the initial value problem
dy
dt =t+y, y(0) = 1,
use the fourth-order Runge-Kutta method with a step size of h= 0.1 to approx-
imate y(0.5).
Solution
To approximate the value of y(0.5) using the fourth-order Runge-Kutta method,
we will iteratively calculate the values of yat various points using the provided
initial conditions and differential equation.
Step 1: Initialize the variables and set up the Runge-Kutta method for-
mulas. Let h= 0.1, t0= 0, y0= 1, and ttarget = 0.5. The fourth-order
Runge-Kutta method is given by:
k1=hf(tn, yn),
k2=hf(tn+h
2, yn+k1
2),
k3=hf(tn+h
2, yn+k2
2),
k4=hf(tn+h, yn+k3),
yn+1 =yn+1
6(k1+ 2k2+ 2k3+k4).
Step 2: Calculate the values of yn+1 at each step.
22
At t= 0:
k1= 0.1(0 + 1) = 0.1,
k2= 0.1(0 + 0.5) = 0.05,
k3= 0.1(0 + 0.5) = 0.05,
k4= 0.1(0.1+0.5) = 0.06,
y1= 1 + 1
6(0.1+2×0.05 + 2 ×0.05 + 0.06) 1.105.
At t= 0.1:
k1= 0.1(0.1+1.105) 0.1215,
k2= 0.1(0.1+0.6525) 0.06525,
k3= 0.1(0.1+0.6525) 0.06525,
k4= 0.1(0.2+0.6525) 0.08525,
y2= 1.105 + 1
6(0.1215 + 2 ×0.06525 + 2 ×0.06525 + 0.08525) 1.22128.
Step 3: Continue this process until t= 0.5. Continuing this process until
t= 0.5, we approximate y(0.5) 1.79341.
Question 24
Question
Consider the initial value problem
dy
dx =x2y2, y(0) = 1
Use the fourth-order Runge-Kutta method to approximate yat x= 0.4 with a
step size of h= 0.1.
Solution
We will use the fourth-order Runge-Kutta method to approximate the solution
of the given initial value problem. The general formula for the 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).
23
Step 1: Calculate the values of k1, k2, k3,and k4.
k1=hf(xn, yn)=0.1·((0)2(1)2) = 0.1,
k2=hf(xn+h
2, yn+k1
2)=0.1·(0 + 0.1
2)2(1 + 0.1
2)2=0.10445,
k3=hf(xn+h
2, yn+k2
2)=0.1·(0 + 0.1
2)2(1 + 0.10445
2)2=0.108916,
k4=hf(xn+h, yn+k3)=0.1·((0.1)2(1 + (0.108916))2) = 0.115727.
Step 2: Use the values of k1, k2, k3,and k4to find the next approximation
yn+1.
yn+1 =yn+1
6(k1+ 2k2+ 2k3+k4)
= 1 + 1
6(0.1 + 2(0.10445) + 2(0.108916) 0.115727)
= 0.841655.
Therefore, the fourth-order Runge-Kutta method approximates the solution
of the initial value problem at x= 0.4 to be y0.841655.
Question 25
Question
Consider the following initial value problem:
dy
dx =x2+y, y(0) = 1.
Use the fourth-order Runge-Kutta method to approximate y(1) using a step size
of x= 0.1.
Solution
To approximate y(1) using the fourth-order Runge-Kutta method, we first need
to calculate intermediate values of k1,k2,k3, and k4at different points within
the interval [0,1].
Step 1: Calculate k1:
k1= x·(02+ 1) = 0.1·1=0.1.
Step 2: Calculate k2:
k2= x·((0+0.5·x)2+(1+0.5·k1)) = 0.1·((0.05)2+(1+0.5·0.1)) = 0.10525.
Step 3: Calculate k3:
k3= x·((0+0.5·x)2+(1+0.5·k2)) = 0.1·((0.05)2+(1+0.5·0.10525)) = 0.110535125.
24
Step 4: Calculate k4:
k4= x·((0+∆x)2+(1+∆x·k3)) = 0.1·((0.1)2+(1+0.1·0.110535125)) 0.1319875688.
Step 5: Finally, calculate the approximate value of y(1) using the weighted
sum:
y(1) y(0)+1
6(k1+2k2+2k3+k4) = 1+1
6(0.1+2(0.10525)+2(0.110535125)+0.1319875688) 1.17189316.
Therefore, the approximate value of y(1) using the fourth-order Runge-Kutta
method is approximately 1.17189316.
Question 26
Question
Consider the initial value problem:
dy
dx =x+y, y(0) = 1.
Use the fourth-order Runge-Kutta method to estimate y(1) with a step size of
h= 0.1.
Solution
Step 1: Define the function and initialize variables.
Let f(x, y) = x+ybe the function, h= 0.1 be the step size, and y0= 1 be the
initial condition. Initialize x0= 0.
Step 2: Implement the fourth-order Runge-Kutta method.
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).
Step 3: Perform iterations.
25
n xnynk1yn+1
0 0 1 0.1(0 + 1) = 0.1 1 + 1
6(0.1) = 1.0167
1 0.1 1.0167 0.1(0.1+1.0167) = 0.1117 1.0167 + 1
6(0.1117) = 1.0335
2 0.2 1.0335 0.1(0.2+1.0335) = 0.1234 1.0335 + 1
6(0.1234) = 1.0512
3 0.3 1.0512 0.1(0.3+1.0512) = 0.1361 1.0512 + 1
6(0.1361) = 1.0699
4 0.4 1.0699 0.1(0.4+1.0699) = 0.1500 1.0699 + 1
6(0.1500) = 1.0895
5 0.5 1.0895 0.1(0.5+1.0895) = 0.1650 1.0895 + 1
6(0.1650) = 1.1098
6 0.6 1.1098 0.1(0.6+1.1098) = 0.1811 1.1098 + 1
6(0.1811) = 1.1309
7 0.7 1.1309 0.1(0.7+1.1309) = 0.1982 1.1309 + 1
6(0.1982) = 1.1528
8 0.8 1.1528 0.1(0.8+1.1528) = 0.2163 1.1528 + 1
6(0.2163) = 1.1754
9 0.9 1.1754 0.1(0.9+1.1754) = 0.2355 1.1754 + 1
6(0.2355) = 1.1985
10 1 1.1985 0.1(1 + 1.1985) = 0.2559 1.1985 + 1
6(0.2559) 1.2221
Therefore
Question 27
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.02.
Solution
Step 1: Initialize the problem and set up the fourth-order Runge-Kutta method.
h= 0.02
x0= 0
y0= 1
k1=hf(x0, y0) = 0.02(02+ 1) = 0.02
k2=hf(x0+h
2, y0+k1
2) = 0.02((0 + 0.01)2+ 1 + 0.01/2) = 0.0201
k3=hf(x0+h
2, y0+k2
2) = 0.02((0 + 0.01)2+ 1 + 0.0201/2) = 0.0202
k4=hf(x0+h, y0+k3)=0.02((0 + 0.02)2+ 1 + 0.0202) = 0.0204
Step 2: Compute the new value of y using the fourth-order Runge-Kutta
method.
26
y1=y0+1
6(k1+2k2+2k3+k4) = 1+1
6(0.02+20.0201+20.0202+0.0204) = 1.0401
Therefore, the estimate for y(0.1) using the fourth-order Runge-Kutta method
with a step size of h= 0.02 is y(0.1) 1.0401.
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
at x= 0.2. Perform the necessary calculations up to the fourth step.
Solution
Step 1: Calculate the step size h.
h=0.20
4= 0.05
Step 2: Initialize the variables.
x0= 0, y0= 1
Step 3: Calculate the intermediate values using Runge-Kutta method.
k1=hx2
0+y0= 0.05 02+ 1= 0.05
k2=h(x0+h
2)2+ (y0+k1
2)= 0.05 (0 + 0.05
2)2+ (1 + 0.05
2)0.0521875
k3=h(x0+h
2)2+ (y0+k2
2)= 0.05 (0 + 0.05
2)2+ (1 + 0.0521875
2)0.0534375
k4=h(x0+h)2+ (y0+k3)= 0.05 (0 + 0.05)2+ (1 + 0.0534375)0.1053125
Step 4: Update the values of xand y.
x1=x0+h= 0 + 0.05 = 0.05
y1=y0+1
6(k1+ 2k2+ 2k3+k4) = 1 + 1
6(0.05 + 2(0.0521875) + 2(0.0534375) + 0.1053125) 1.1098958
27
Question 29
Question
Use the fourth-order Runge-Kutta method to approximate the solution of the
initial value problem:
y= 2xy, y(0) = 1
at x= 0.1. Use step size h= 0.05.
Solution
Given the initial value problem y= 2xy,y(0) = 1, we want to approximate
y(0.1) using the fourth-order Runge-Kutta method with step size h= 0.05.
The fourth-order Runge-Kutta formula 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)
Step 1: Calculate k1, k2, k3,and k4using f(x, y) = 2xy.
k1=f(0,1) = 2 ·0·1=0
k2=f0 + 0.05
2,1 + 0.05
2·0=f(0.025,1) = 2 ·0.025 ·1=0.05
k3=f0 + 0.05
2,1 + 0.05
2·0.05=f(0.025,1.0025) = 2 ·0.025 ·1.0025 = 0.05025
k4=f(0 + 0.05,1+0.05 ·0.05025) = f(0.05,1.002513) = 2 ·0.05 ·1.002513 0.1002513
Step 2: Calculate the new approximation yn+1.
yn+1 = 1 + 0.05
6(0 + 2 ·0.05 + 2 ·0.05025 + 0.1002513)
= 1 + 0.05
6(0 + 0.1+0.1005 + 0.1002513)
= 1 + 0.05
6(0.3007513)
1+0.0251252
1.0251252
Therefore, the approximate solution of the initial value problem at x= 0.1
is y(0.1) 1.0251252.
28
Question 30
Question
Consider the following initial value problem:
dy
dx =x2+y, y(0) = 1
Use the fourth-order Runge-Kutta method to approximate the value of yat
x= 0.2. Take h= 0.1.
Solution
Step 1: Define the increments k1,k2,k3, and k4as follows:
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+y.
Step 2: Calculate the next approximation using the formula:
yn+1 =yn+1
6(k1+ 2k2+ 2k3+k4)
Step 3: Apply the method iteratively until x= 0.2.
Starting with x0= 0 and y0= 1, we have:
k1= 0.1(02+ 1) = 0.1
k2= 0.10 + 0.1
22
+ (1 + 0.1
2)=0.10525
k3= 0.10 + 0.10525
22
+ (1 + 0.10525
2) = 0.110770625
k4= 0.1(0 + 0.110770625) = 0.0110770625
Thus, y1is calculated as:
y1= 1 + 1
6(0.1 + 2 ×0.10525 + 2 ×0.110770625 + 0.0110770625) = 1.0158721354
Continuing this process, we will find the value of yat x= 0.2.
29
Question 31
Question
Consider the initial value problem:
dy
dx =xy, y(0) = 1.
Use the fourth-order Runge-Kutta method to approximate the value of y(0.5)
using a step size of h= 0.1.
Solution
To apply the fourth-order Runge-Kutta method, we need 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 yndenote the current values of xand y, respectively.
Step 1: Calculate k1:
f(xn, yn) = xnyn= 0 1 = 1
k1=h(1) = 0.1(1) = 0.1
Step 2: Calculate k2:
f(xn+h
2, yn+k1
2) = f(0.05,0.9) = 0.05 0.9 = 0.85
k2= 0.1(0.85) = 0.085
Step 3: Calculate k3:
f(xn+h
2, yn+k2
2) = f(0.05,0.9075) = 0.05 0.9075 = 0.8575
k3= 0.1(0.8575) = 0.08575
Step 4: Calculate k4:
f(xn+h, yn+k3) = f(0.1,0.91425) = 0.10.91425 = 0.81425
k4= 0.1(0.81425) = 0.081425
30
Step 5: Update yusing the weighted average:
yn+1 =yn+1
6(k1+ 2k2+ 2k3+k4)
= 1 + 1
6(0.1 + 2(0.085) + 2(0.08575) 0.081425)
= 0.917283
Therefore, the fourth-order Runge-Kutta method gives an approximate value
of y(0.1) 0.917283.
Question 32
Question
Consider the following initial value problem:
dy
dx =x2y, y(0) = 1
Use the fourth-order Runge-Kutta method with step size h= 0.1 to approximate
y(0.2).
Solution
To approximate the value of y(0.2) using the fourth-order Runge-Kutta method,
we will need to calculate the values of yat intermediate points using 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)
Step 1: Calculate y(0.1) using the Runge-Kutta method.
k1= 0.1·(0 1) = 0.1
k2= 0.1·0 + 0.1
2=0.05
k3= 0.1·0 + 0.05
2=0.025
k4= 0.1·(0.1+(0.025)) = 0.0075
y(0.1) = 1 + 1
6(0.1 + 2(0.05) + 2(0.025) + 0.0075) 0.89917
31
Step 2: Calculate y(0.2) using the Runge-Kutta method.
k1= 0.1·(0.120.89917) 0.01117
k2= 0.1·0.1 + 0.01117
20.10283
k3= 0.1·0.1 + 0.10283
20.10542
k4= 0.1·(0.2+0.10542) 0.30542
y(0.2) 0.89917 + 1
6(0.01117 + 2(0.10283) + 2(0.10542) + 0.30542) 0.95701
Therefore, the approximate value of y(0.2) using the fourth-order Runge-
Kutta method with step size h= 0.1 is y(0.2) 0.95701.
Question 33
Question
Use the fourth-order Runge-Kutta method to approximate the solution to the
initial value problem: dy
dx =x2+y2, y(0) = 1
over the interval 0 x1. Use a step size of h= 0.1.
Solution
To solve the given initial value problem using the fourth-order Runge-Kutta
method, we will follow these steps:
Step 1: Define the differential equation and initial condition:
dy
dx =x2+y2, y(0) = 1
Step 2: Choose the step size: Given that h= 0.1 and the interval is 0 x1,
we have n=10
0.1= 10 subintervals.
Step 3: Apply the fourth-order Runge-Kutta method: We will use the
following formulas to approximate yi+1 from yi:
k1=hf(xi, yi)
k2=hf(xi+h
2, yi+k1
2)
k3=hf(xi+h
2, yi+k2
2)
k4=hf(xi+h, yi+k3)
32
yi+1 =yi+1
6(k1+ 2k2+ 2k3+k4)
Step 4: Calculate the approximate values of y: Starting with the initial
condition y(0) = 1, we will use the fourth-order Runge-Kutta method to ap-
proximate the values of yat x= 0.1,0.2,...,1.
Step 5: Compute the solution and construct a table: Using the Runge-
Kutta method, calculate the values of yat x= 0.1,0.2,...,1 and construct a
table showing x,yapprox, and yexact.
Step 6: Analyze the results: Compare the approximate values obtained
using the fourth-order Runge-Kutta method with the exact solution to analyze
the accuracy of the method.
Question 34
Question
Consider the initial value problem dy
dx =x2y,y(0) = 1. Use the fourth-order
Runge-Kutta method to approximate y(1) using a step size of h= 0.1.
Solution
Given the initial value problem, we want to approximate y(1) using the fourth-
order Runge-Kutta method with a step size of h= 0.1.
The general formula for the fourth-order Runge-Kutta method is as follows:
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) = x2y.
We will start at x= 0 and iteratively apply the above formulas to find y(1).
Step 1: Initialize x0= 0, y0= 1, h= 0.1.
Step 2: Calculate k1, k2, k3, k4and y1using the above formulas:
For k1:
k1= 0.1(021) = 0.1
For k2:
k2= 0.10 + 0.1
2,1 + 0.1
2= 0.1(0.05 0.05) = 0
33
For k3:
k3= 0.10 + 0.1
2,1 + 0
2= 0.1(0.05) = 0.005
For k4:
k4= 0.1 (0 + 0.1,1+0.005) = 0.1(0.1+1.005) = 0.1105
Therefore,
y1= 1 + 1
6(0.1 + 2(0) + 2(0.005) + 0.1105) = 1.00184375
So, y(1) 1.00184375.
Question 35
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,1]. Use h= 0.1 and provide the approximations at x=
0.1,0.2,...,1.
Solution
Given the initial value problem dy
dx =x2+yand y(0) = 1, we want to use the
fourth-order Runge-Kutta method to approximate the solution over the interval
[0,1] with the step size h= 0.1.
The general formula for 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 xnand ynare the previous values of xand yrespectively, and his the
step size.
Let’s calculate the approximations at x= 0.1,0.2,...,1 using the fourth-
order Runge-Kutta method.
Step 1: Initialize variables: Let h= 0.1, x0= 0, and y0= 1.
34
For x1= 0.2:
y1= 1 + 0.099 1.099
Repeat the process for x2= 0.4, x3= 0.6, x4= 0.8, and x5= 1.
Step 3: Calculate the estimated value of y(1) using the RK2 method with
step size h= 0.2.
The estimated value of y(1) is approximately 1.1257.
Question 2
Question
Consider the initial value problem:
dy
dx =x2+y, y(0) = 1
Use the Runge-Kutta method with step size h= 0.2 to approximate the
value of y(0.4). Perform the calculations using 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+y.
Solution
Step 1: Initialize the values using x0= 0, y0= 1, and h= 0.2.
h= 0.2, x0= 0, y0= 1
Step 2: Calculate k1,k2,k3, and k4.
k1= 0.2·f(0,1) = 0.2·(02+ 1) = 0.2
k2= 0.2·f0 + 0.2
2,1 + 0.2
2= 0.2·(0.12+ 1.1) = 0.22
k3= 0.2·f0 + 0.2
2,1 + 0.22
2= 0.2·(0.12+ 1.11) = 0.222
k4= 0.2·f(0 + 0.2,1+0.222) = 0.2·(0.22+ 1.222) 0.269
2
Step 3: Compute the new approximation for y.
y1= 1 + 1
6(0.2 + 2(0.22) + 2(0.222) + 0.269)
= 1 + 1
6(0.2+0.44 + 0.444 + 0.269)
= 1 + 1
6(1.353)
= 1 + 0.2255
= 1.2255
Therefore, using the Runge-Kutta method with step size h= 0.2, the ap-
proximate value of y(0.4) is y1.2255.
Question 3
Question
Consider the initial value problem:
dy
dx =x2y2, y(0) = 1,
approximating the solution using the Runge-Kutta method. Use a step size of
h= 0.2 to estimate yat x= 1.
Solution
To apply the Runge-Kutta method to the given initial value problem, we will
use the following equations:
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+k1+ 2k2+ 2k3+k4
6.
Here, h= 0.2 and we want to estimate yat x= 1.
Step 1: Define the function f(x, y) = x2y2and the initial condition
y(0) = 1.
3
Step 2: Calculate the values of k1,k2,k3, and k4:
k1= 0.2(0212) = 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.1968,
k4= 0.2 (0 + 0.2,1+0.1968) = 0.23936.
Step 3: Use the formula to find yn+1:
y1= 1 + 0.2 + 2(0.18) + 2(0.1968) + 0.23936
61.0328.
Therefore, with a step size of h= 0.2, the Runge-Kutta method estimates y
at x= 1 to be approximately 1.0328.
Question 4
Question
Use the fourth-order Runge-Kutta method to approximate the solution of the
initial value problem: dy
dx =x2+y2, y(0) = 1
over the interval [0,1] using a step size of h= 0.1. Calculate the approximate
value of y(1).
Solution
Given the initial value problem:
dy
dx =x2+y2, y(0) = 1
we will use the fourth-order Runge-Kutta method to approximate the value of
y(1).
The general formula for the fourth-order Runge-Kutta method is 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)
4
where his the step size, xnis the current value of x,ynis the current value
of y, and f(xn, yn) = x2
n+y2
n.
We will perform the calculations for each iteration from x= 0 to x= 1 with
a step size of h= 0.1.
Step 1: Initialize the values: x0= 0, y0= 1, and h= 0.1.
Step 2: For n= 0, calculate:
k1=h(x0, y0)=0.1(02+ 12)=0.1
k2=h(x0+h
2, y0+k1
2)=0.10 + 0.1
2= 0.005
k3=h(x0+h
2, y0+k2
2)=0.10 + 0.005
2= 0.00025
k4=h(x0+h, y0+k3)=0.1 (0 + 0.00025) = 0.000025
y1=y0+1
6(k1+ 2k2+ 2k3+k4) = 1 + 1
6(0.1 + 2(0.005) + 2(0.00025) + 0.000025) 1.09085
Step 3: Continue the process for n= 1 until x= 1.
After the final iteration, the approximate value of y(1) is 1.09085.
Question 5
Question
Use the fourth-order Runge-Kutta method to approximate the solution to the
initial value problem: dy
dx =x2+y2, y(0) = 1,
over the interval [0, 0.4]. Use a step size of h= 0.1.
Solution
Let’s denote f(x, y) = x2+y2. 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 his the step size, xnis the current value of x,ynis the current value of
y, and yn+1 is the next value of y.
5
Step 1: Initialize the values
For this problem: x0= 0, y0= 1, h= 0.1, and f(x, y) = x2+y2.
Step 2: Calculate the approximate solution
For each iteration: - Calculate k1,k2,k3, and k4using the formulas above. -
Update yusing the formula yn+1 =yn+1
6(k1+ 2k2+ 2k3+k4). - Update x.
Repeat the above steps until you reach x= 0.4.
After performing the calculations, the approximate value of yat x= 0.4
using the fourth-order Runge-Kutta method with a step size of h= 0.1 is
approximately y(0.4) 1.6929.
Question 6
Question
Consider the initial value problem dy
dx =x22ywith y(0) = 1. Use the fourth-
order Runge-Kutta method to approximate y(0.1) using a step size of h= 0.02.
Solution
Step 1: Define the function f(x, y) = x22y.
Step 2: Calculate the increments k1,k2,k3, and k4using the following formu-
las: 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).
Step 3: Update the values of xand yusing the formula: yn+1 =yn+1
6(k1+
2k2+ 2k3+k4).
Now, let’s calculate the approximation.
Step 1: f(x, y) = x22y.
Step 2:
k1= 0.02 ·(022·1) = 0.04,
k2= 0.02 ·(0 + 0.01)22·(1 0.02)=0.0397,
k3= 0.02 ·(0 + 0.01)22·(1 0.0397/2)=0.039319,
k4= 0.02 ·(0 + 0.02)22·(1 0.039319)=0.038904.
Step 3:
y1= 1 + 1
6(0.04 + 2(0.0397) + 2(0.039319) 0.038904)
= 0.960249.
Therefore, the fourth-order Runge-Kutta approximation of y(0.1) is y(0.1)
0.960249.
6
Question 7
Question
Consider the initial value problem given by dy
dx =x2+y2,y(0) = 0, and let
y(1) be approximated using the fourth-order Runge-Kutta method with step
size h= 0.1. Find the approximate value of y(1).
Solution
Step 1: We first calculate the number of steps needed to reach x= 1 with step
size h= 0.1. The number of steps is given by N=10
0.1= 10.
Step 2: Initialize the Runge-Kutta method with the given initial condition
y(0) = 0. Let x0= 0, y0= 0, and h= 0.1. We will use the 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)
Step 3: Calculate the approximate value of yat x= 1 using the Runge-
Kutta method. We repeat the following steps for n= 0,1,...,9: (i) Calculate
k1,k2,k3, and k4using the above expressions. (ii) Update yn+1 =yn+1
6(k1+
2k2+ 2k3+k4). (iii) Update xn+1 =xn+h.
Step 4: Once we have computed y(1), the approximate value is the final y
value obtained after Nsteps. After the final step, we find that y(1) 1.708.
Question 8
Question
Consider the initial value problem given by
dy
dx =x2y2, y(0) = 1.
Use the fourth-order Runge-Kutta method with step size h= 0.1 to estimate
y(0.4). Use the formula for the 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),
yn+1 =yn+1
6(k1+ 2k2+ 2k3+k4),
7
where f(x, y) = x2y2.
Solution
Given initial conditions y(0) = 1 and step size h= 0.1, we will use the fourth-
order Runge-Kutta method to estimate y(0.4). We start by applying the method
iteratively.
Step 1: Calculate k1.
k1= 0.1·f(0,1) = 0.1·(0212) = 0.1
Step 2: Calculate k2.
k2= 0.1·f0 + 0.1
2,1 + 0.1
2= 0.1·f(0.05,0.95)
= 0.1·0.0520.952 0.11245
Step 3: Calculate k3.
k3= 0.1·f0 + 0.1
2,1 + 0.11245
2= 0.1·f(0.05,0.918775)
= 0.1·0.0520.9187752 0.107863
Step 4: Calculate k4.
k4= 0.1·f(0 + 0.1,10.107863) = 0.1·f(0.1,0.892137)
= 0.1·0.120.8921372 0.080172
Step 5: Update yusing the weighted average of k1,k2,k3, and k4.
y1= 1 + 1
6(0.1 + 2(0.11245) + 2(0.107863) 0.080172) 0.882792
Therefore, the estimate for y(0.4) using the fourth-order Runge-Kutta method
with step size h= 0.1 is approximately 0.882792.
Question 9
Question
Let’s consider the initial value problem given by dy
dx =x2+y2with y(0) = 1. Use
the fourth-order Runge-Kutta method with a step size of h= 0.1 to estimate
the value of yat x= 0.4.
8
Solution
To approximate the value of yat x= 0.4, we will apply the fourth-order Runge-
Kutta method with the given step size.
Step 1: We need to calculate the values at different points 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)
where f(x, y) = x2+y2.
Step 2: Calculate the next value of yusing:
yn+1 =yn+1
6(k1+ 2k2+ 2k3+k4)
Step 3: Now, calculate the values for each iteration:
For n= 0:
k1= 0.1(02+ 12)=0.1
k2= 0.1(0 + 0.1
2)2+ (1 + 0.1
2)2= 0.1025
k3= 0.1(0 + 0.1
2)2+ (1 + 0.1025
2)2= 0.105100625
k4= 0.1(0.1) + (1.105100625) = 0.2105100625
y1= 1 + 1
6(0.1 + 2(0.1025) + 2(0.105100625) + 0.2105100625) 1.059736746
For n= 1:
k1= 0.1(0.12+ 1.0597367462)0.1130869677
k2= 0.1(0.1+ 0.1130869677
2)2+(1.059736746+ 0.1130869677
2)20.1191109287
k3= 0.1(0.1+ 0.1130869677
2)2+(1.059736746+ 0.1191109287
2)20.1254285423
k4= 0.1(0.1) + (1.1254285423) 0.2379428549
y2= 1.059736746+1
6(0.1130869677+2(0.1191109287)+2(0.1254285423)+0.2379428549) 1.122962847
Therefore, the estimate for yat x= 0.4 using the fourth-order Runge-Kutta
method with step size h= 0.1 is approximately 1.122962847.
9
Question 10
Question
Consider the initial value problem:
dy
dx =x2+y, y(0) = 1.
Use the fourth-order Runge-Kutta method to approximate y(1) using a step size
of h= 0.2.
Solution
To approximate the solution using the fourth-order Runge-Kutta method, we
will follow these steps:
Step 1: Define the function f(x, y) based on the given differential equation
f(x, y) = x2+y.
Step 2: Set the initial conditions
x0= 0, y0= 1, h = 0.2.
Step 3: Use the fourth-order Runge-Kutta formulas to compute the ap-
proximations:
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 nrepresents the current step.
Step 4: Substitute the given values into the formulas and calculate the
intermediate values:
k1= 0.2·(02+ 1) = 0.2,
k2= 0.2·(0.12+ 1 + 0.1·0.2) = 0.22067,
k3= 0.2·(0.12+ 1 + 0.1·0.22067) = 0.24216633,
k4= 0.2·(0.22+ 1 + 0.1·0.24216633) = 0.2741357,
y1= 1 + 1
6(0.2+2·0.22067 + 2 ·0.24216633 + 0.2741357) 1.09953203.
Therefore, using the fourth-order Runge-Kutta method with a step size of
h= 0.2, the approximate value of y(1) is 1.0995.
10
Question 11
Question
Consider the initial value problem dy
dx =x2+y2, with initial condition y(0) = 1.
Use the Runge-Kutta method of order four to approximate the value of y(1)
with step size h= 0.1.
Solution
The Runge-Kutta method of order four 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) = x2+y2,his the step size, xnis the current x-value, ynis
the current y-value, and yn+1 is the next y-value.
Step 1: We will evaluate the values of k1,k2,k3, and k4at each step to
find the approximations.
Step 2: At x= 0, y= 1, we have:
k1= 0.1·(02+ 12)=0.1
k2= 0.1·0 + 0.1
22
+1 + 0.1
22
= 0.11025
k3= 0.1·0 + 0.1
22
+1 + 0.11025
22
= 0.111343
k4= 0.1·(0 + 0.1)2+ (1 + 0.111343)2= 0.121576
Step 3: Now, we can calculate the next value of yusing the Runge-Kutta
formula:
y1= 1 + 1
6(0.1 + 2(0.11025) + 2(0.111343) + 0.121576); y11.122523
Therefore, the approximate value of y(1) using the Runge-Kutta method
with step size h= 0.1 is y(1) 1.122523.
11
Question 12
Question
Use the fourth-order Runge-Kutta method to approximate the solution to the
initial value problem:
dy
dx =x2+y, y(0) = 1
Find an approximation to y(0.1) using a step size of h= 0.05.
Solution
Step 1: We first represent the given initial value problem in the form required
for Runge-Kutta method. Let f(x, y) = x2+y. The general formula for the
fourth-order Runge-Kutta method is given by:
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)
where his the step size.
Step 2: We begin the computations. Let n= 0, x0= 0, and y0= 1.
k1= 0.05(02+ 1) = 0.05
k2= 0.05 0 + 1
2(0.05)(1)= 0.025
k3= 0.05 0 + 1
2(0.05)(1 + 0.025)= 0.0275
k4= 0.05 (0.05,1+0.0275) = 0.02875
y1= 1 + 1
6(0.05 + 2(0.025) + 2(0.0275) + 0.02875) 1.05606
Therefore, using the fourth-order Runge-Kutta method with a step size of
0.05 gives an approximation of y(0.1) 1.05606.
Question 13
Question
Consider the initial value problem y=x2+y2with y(0) = 1. Use the fourth-
order Runge-Kutta method to approximate y(0.4) with step size h= 0.1.
12
Solution
Let’s denote f(x, y) = x2+y2,h= 0.1, x0= 0, and y0= 1. We will use the
fourth-order Runge-Kutta method to approximate y(0.4).
Step 1: Calculate k1,k2,k3, and k4using the following formulas:
k1=hf(x0, y0)
k2=hf x0+h
2, y0+k1
2
k3=hf x0+h
2, y0+k2
2
k4=hf (x0+h, y0+k3)
Step 2: Use the following formula to update the value of y:
y1=y0+1
6(k1+ 2k2+ 2k3+k4)
Now, let’s perform the calculations.
Step 1:
k1= 0.1(02+ 12)=0.1
k2= 0.10 + 0.1
22
+1 + 0.1
22
= 0.10255
k3= 0.10 + 0.1
22
+1 + 0.10255
22
= 0.1052042
k4= 0.1 (0 + 0.1)2+ (1 + 0.1052042)2= 0.108368784
Step 2:
y1= 1 + 1
6(0.1 + 2(0.10255) + 2(0.1052042) + 0.108368784) = 1.1176246
Therefore, the approximate value of y(0.4) using the fourth-order Runge-
Kutta method is y(0.4) 1.1176 when h= 0.1.
Question 14
Question
Use the fourth-order Runge-Kutta method to approximate the solution of the
initial value problem: dy
dx =x+y, y(0) = 1
over the interval [0,1] with a step size of h= 0.1. Compute the approximation
of y(1).
13
Solution
Step 1: Define the function f(x, y) = x+y.
Step 2: Calculate the slopes k1, k2, k3,and k4using the fourth-order 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)
Step 3: Update the value of yn+1 using the formula:
yn+1 =yn+1
6(k1+ 2k2+ 2k3+k4)
Step 4: Use the initial condition y(0) = 1 and step size h= 0.1 to approxi-
mate y(1). Applying the formulas above iteratively will give the computed value
of y(1).
Question 15
Question
Given the initial value problem dy
dx =x2+y, with initial condition y(0) =
1, approximate the value of y(1) using the classical fourth-order Runge-Kutta
method with step size h= 0.1.
Solution
The classical fourth-order Runge-Kutta method consists of the following formu-
las: 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),
yn+1 =yn+1
6(k1+ 2k2+ 2k3+k4),
where f(xn, yn) = x2
n+yn.
Step 1: Initialize the given values Given h= 0.1, y(0) = 1, and we want to
find y(1).
14
Step 2: Calculate y(1) using Runge-Kutta method
k1= 0.1·(02+ 1) = 0.1,
k2= 0.1·0.052+1+0.1
2= 0.10525,
k3= 0.1·0.052+1+0.10525
2= 0.11043625,
k4= 0.1·(0.1+1+0.11043625) = 0.211043625
y(1) 1 + 1
6(0.1 + 2(0.10525) + 2(0.11043625) + 0.211043625) = 1.13564375.
Therefore, the approximate value of y(1) using the classical fourth-order
Runge-Kutta method with step size h= 0.1 is y(1) 1.13564375.
Question 16
Question
Consider the following initial value problem:
(y= 2yx,
y(0) = 1,
Approximate the value of y(0.2) using the fourth-order Runge-Kutta method
with a step size of h= 0.1.
Solution
Step 1: Define the Runge-Kutta method. For the fourth-order Runge-Kutta
method, the formula is 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 his the step size, f(x, y) is the derivative function, xnis the current
value of x,ynis the current value of y, and yn+1 is the next value of yat
xn+1 =xn+h.
15
Step 2: Define f(x, y) and calculate the values of k1,k2,k3, and k4using
the given initial value problem:
f(x, y) = 2yx,
k1= 0.1(2 ·10) = 0.2,
k2= 0.1(2 ·10+0.1·0.2
2)=0.21,
k3= 0.1(2 ·10+0.1·0.21
2) = 0.21205,
k4= 0.1(2 ·10.1+0.21205) = 0.258205,
Step 3: Calculate the new value of yusing the formula:
y1= 1 + 1
6(0.2+2·0.21 + 2 ·0.21205 + 0.258205)
= 1 + 1
6(0.2+0.42 + 0.4241 + 0.258205)
= 1 + 1
6(1.302305)
1.21705,
Therefore, the approximate value of y(0.2) using the fourth-order Runge-
Kutta method with a step size of h= 0.1 is y(0.2) 1.21705.
Question 17
Question
Consider the initial value problem
dy
dt =t2y, y(0) = 1.
Apply the fourth-order Runge-Kutta method to approximate y(1) using a step
size of h= 0.2.
Solution
The fourth-order Runge-Kutta method is given by the following formulas:
k1=hf(tn, yn),
k2=hf(tn+h
2, yn+k1
2),
k3=hf(tn+h
2, yn+k2
2),
k4=hf(tn+h, yn+k3),
yn+1 =yn+1
6(k1+ 2k2+ 2k3+k4).
16
Step 1: Define the function f(t, y) = t2yand the initial conditions.
f(t, y) = t2y, y(0) = 1.
Step 2: Apply the fourth-order Runge-Kutta method to approximate y(1)
with h= 0.2.
First, we set t0= 0 and y0= 1, then we compute:
k1= 0.2·f(0,1) = 0.2·(021) = 0.2,
k2= 0.2·f(0 + 0.1,1+0.1·(0.1)) = 0.2·(0.120.99) = 0.19801,
k3= 0.2·f(0 + 0.1,1+0.1·(0.099005)) = 0.2·(0.120.980995) = 0.19601,
k4= 0.2·f(0.2,1+0.2·(0.19601)) = 0.2·(0.220.960399) = 0.19388,
y1= 1 + 1
6(0.2 + 2(0.19801) + 2(0.19601) + (0.19388)) = 0.806264.
Therefore, the approximate value of y(1) using the fourth-order Runge-Kutta
method with h= 0.2 is y(1) 0.806264.
Question 18
Question
Use the fourth-order Runge-Kutta method to approximate the solution of the
initial value problem:
dy
dx =x2y2, y(0) = 1
Calculate the approximate value of y at x = 0.1 using a step size of h = 0.1.
Solution
To apply the fourth-order Runge-Kutta (RK4) 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 f(xn, yn) = x2
ny2
n.
Given h= 0.1, we will calculate y(0.1) using RK4.
17
Step 1: Calculate k1:
k1= 0.1·(0212) = 0.1
Step 2: Calculate k2:
k2= 0.1· 0 + 0.1
22
1 + 0.1
22!= 0.09025
Step 3: Calculate k3:
k3= 0.1· 0 + 0.1
22
1 + 0.09025
22!= 0.0849799375
Step 4: Calculate k4:
k4= 0.1·(0 + 0.1)2(1 + 0.0849799375)2= 0.0685921869
Step 5: Calculate y(0.1):
y(0.1) = 1 + 1
6(0.1 + 2(0.09025) + 2(0.0849799375) + 0.0685921869) 0.9105
Therefore, the approximate value of y(0.1) using the fourth-order Runge-
Kutta method is approximately 0.9105.
Question 19
Question
Consider the following initial value problem:
dy
dx =x2y, y(0) = 1
Use a fourth-order Runge-Kutta method with step size h= 0.2 to approximate
y(1).
Solution
To approximate y(1) using the fourth-order Runge-Kutta method, we need to
calculate the values of yat each step. We will use the 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)
18
where f(x, y) = x2y.
Step 1: Initialize the values using h= 0.2:
x0= 0, y0= 1, h = 0.2
Step 2: Calculate y1using the Runge-Kutta method:
k1= 0.2((0)21) = 0.2
k2= 0.2((0.1)2(1 0.1·0.2/2)) = 0.198
k3= 0.2((0.1)2(1 0.2·0.198/2)) = 0.19602
k4= 0.2((0.2)2(1 0.2·(0.19602))) = 0.194792
y1= 1 + 1
6(0.2 + 2(0.198) + 2(0.19602) 0.194792) 0.8373
Therefore, the approximate value of y(1) using the fourth-order Runge-Kutta
method with h= 0.2 is y(1) 0.8373.
Question 20
Question
Consider the initial value problem
dy
dx =x2y, y(0) = 1.
Use the fourth-order Runge-Kutta method to approximate the value of y(0.1)
using a step size of h= 0.02.
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) = x2y, xnis the current value of x, and ynis the current value
of y.
Let’s apply the Runge-Kutta method with h= 0.02 to approximate y(0.1):
19
Step 1: Calculate k1:
k1= 0.02 ·((0)21) = 0.02.
Step 2: Calculate k2:
k2= 0.02 ·((0 + 0.01)2(1 0.02/2)) = 0.0199.
Step 3: Calculate k3:
k3= 0.02 ·((0 + 0.01)2(1 + 0.0199/2)) = 0.019801.
Step 4: Calculate k4:
k4= 0.02 ·((0.02)2(1 + 0.019801)) = 0.01979398.
Step 5: Calculate y(0.02):
y1= 1 + 1
6(0.02 + 2(0.0199) + 2(0.019801) 0.01979398) = 0.980145.
Therefore, the approximate value of y(0.02) using the fourth-order Runge-
Kutta method is 0.980145.
Question 21
Question
Consider the initial value problem given by the differential equation:
y= 2 y
x, y(1) = 1
Use the fourth-order Runge-Kutta method to estimate the value of yat
x= 2 using a step size of h= 0.5.
Solution
To apply the fourth-order Runge-Kutta method, we follow these steps at each
iteration:
Given the initial condition y(1) = 1, we want to estimate y(2) with a step
size of h= 0.5. Let’s denote xn= 1+0.5nand ynbe an approximation of y(xn)
for n= 0,1,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)
20
where f(x, y)=2y
x.
Step 2: Update yn+1 using the formula:
yn+1 =yn+1
6(k1+ 2k2+ 2k3+k4)
Now, let’s calculate the approximations step by step:
Step 1: At x= 1, we have y0= 1. Using the RK4 formulas:
k1= 0.5(2 1) = 0.5
k2= 0.521+0.25
1+0.25= 0.5(2 5
4)=0.375
k3= 0.521+0.25
1+0.25= 0.5(2 5
4)=0.375
k4= 0.521+0.5
1+0.5= 0.5(2 3
2)=0.25
Step 2: Calculate y1:
y1= 1 + 1
6(0.5 + 2(0.375) + 2(0.375) + 0.25)
= 1 + 1
6(0.5+0.75 + 0.75 + 0.25)
= 1 + 1
6(2.25)
= 1 + 0.375
= 1.375
Therefore, the estimated value of y(2) using the fourth-order Runge-Kutta
method with step size 0.5 is y(2) 1.375.
Question 22
Question
Given the initial value problem
dy
dx =x2y, y(0) = 1,
approximate the value of y(1) using the fourth-order Runge-Kutta method with
step size h= 0.2.
Solution
To approximate the value of y(1) using the fourth-order Runge-Kutta method,
we will follow these steps:
21
Step 1: Define the function f(x, y) = x2y.
Step 2: Calculate the increments k1,k2,k3, and k4using 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).
where xnand ynare the previous values.
Step 3: Update the values of xand yusing the formula:
yn+1 =yn+1
6(k1+ 2k2+ 2k3+k4).
Step 4: Repeat Steps 2 and 3 until x= 1.
Let’s calculate the approximate value of y(1) using the given steps.
Question 23
Question
Given the initial value problem
dy
dt =t+y, y(0) = 1,
use the fourth-order Runge-Kutta method with a step size of h= 0.1 to approx-
imate y(0.5).
Solution
To approximate the value of y(0.5) using the fourth-order Runge-Kutta method,
we will iteratively calculate the values of yat various points using the provided
initial conditions and differential equation.
Step 1: Initialize the variables and set up the Runge-Kutta method for-
mulas. Let h= 0.1, t0= 0, y0= 1, and ttarget = 0.5. The fourth-order
Runge-Kutta method is given by:
k1=hf(tn, yn),
k2=hf(tn+h
2, yn+k1
2),
k3=hf(tn+h
2, yn+k2
2),
k4=hf(tn+h, yn+k3),
yn+1 =yn+1
6(k1+ 2k2+ 2k3+k4).
Step 2: Calculate the values of yn+1 at each step.
22
At t= 0:
k1= 0.1(0 + 1) = 0.1,
k2= 0.1(0 + 0.5) = 0.05,
k3= 0.1(0 + 0.5) = 0.05,
k4= 0.1(0.1+0.5) = 0.06,
y1= 1 + 1
6(0.1+2×0.05 + 2 ×0.05 + 0.06) 1.105.
At t= 0.1:
k1= 0.1(0.1+1.105) 0.1215,
k2= 0.1(0.1+0.6525) 0.06525,
k3= 0.1(0.1+0.6525) 0.06525,
k4= 0.1(0.2+0.6525) 0.08525,
y2= 1.105 + 1
6(0.1215 + 2 ×0.06525 + 2 ×0.06525 + 0.08525) 1.22128.
Step 3: Continue this process until t= 0.5. Continuing this process until
t= 0.5, we approximate y(0.5) 1.79341.
Question 24
Question
Consider the initial value problem
dy
dx =x2y2, y(0) = 1
Use the fourth-order Runge-Kutta method to approximate yat x= 0.4 with a
step size of h= 0.1.
Solution
We will use the fourth-order Runge-Kutta method to approximate the solution
of the given initial value problem. The general formula for the 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).
23
Step 1: Calculate the values of k1, k2, k3,and k4.
k1=hf(xn, yn)=0.1·((0)2(1)2) = 0.1,
k2=hf(xn+h
2, yn+k1
2)=0.1·(0 + 0.1
2)2(1 + 0.1
2)2=0.10445,
k3=hf(xn+h
2, yn+k2
2)=0.1·(0 + 0.1
2)2(1 + 0.10445
2)2=0.108916,
k4=hf(xn+h, yn+k3)=0.1·((0.1)2(1 + (0.108916))2) = 0.115727.
Step 2: Use the values of k1, k2, k3,and k4to find the next approximation
yn+1.
yn+1 =yn+1
6(k1+ 2k2+ 2k3+k4)
= 1 + 1
6(0.1 + 2(0.10445) + 2(0.108916) 0.115727)
= 0.841655.
Therefore, the fourth-order Runge-Kutta method approximates the solution
of the initial value problem at x= 0.4 to be y0.841655.
Question 25
Question
Consider the following initial value problem:
dy
dx =x2+y, y(0) = 1.
Use the fourth-order Runge-Kutta method to approximate y(1) using a step size
of x= 0.1.
Solution
To approximate y(1) using the fourth-order Runge-Kutta method, we first need
to calculate intermediate values of k1,k2,k3, and k4at different points within
the interval [0,1].
Step 1: Calculate k1:
k1= x·(02+ 1) = 0.1·1=0.1.
Step 2: Calculate k2:
k2= x·((0+0.5·x)2+(1+0.5·k1)) = 0.1·((0.05)2+(1+0.5·0.1)) = 0.10525.
Step 3: Calculate k3:
k3= x·((0+0.5·x)2+(1+0.5·k2)) = 0.1·((0.05)2+(1+0.5·0.10525)) = 0.110535125.
24
Step 4: Calculate k4:
k4= x·((0+∆x)2+(1+∆x·k3)) = 0.1·((0.1)2+(1+0.1·0.110535125)) 0.1319875688.
Step 5: Finally, calculate the approximate value of y(1) using the weighted
sum:
y(1) y(0)+1
6(k1+2k2+2k3+k4) = 1+1
6(0.1+2(0.10525)+2(0.110535125)+0.1319875688) 1.17189316.
Therefore, the approximate value of y(1) using the fourth-order Runge-Kutta
method is approximately 1.17189316.
Question 26
Question
Consider the initial value problem:
dy
dx =x+y, y(0) = 1.
Use the fourth-order Runge-Kutta method to estimate y(1) with a step size of
h= 0.1.
Solution
Step 1: Define the function and initialize variables.
Let f(x, y) = x+ybe the function, h= 0.1 be the step size, and y0= 1 be the
initial condition. Initialize x0= 0.
Step 2: Implement the fourth-order Runge-Kutta method.
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).
Step 3: Perform iterations.
25
n xnynk1yn+1
0 0 1 0.1(0 + 1) = 0.1 1 + 1
6(0.1) = 1.0167
1 0.1 1.0167 0.1(0.1+1.0167) = 0.1117 1.0167 + 1
6(0.1117) = 1.0335
2 0.2 1.0335 0.1(0.2+1.0335) = 0.1234 1.0335 + 1
6(0.1234) = 1.0512
3 0.3 1.0512 0.1(0.3+1.0512) = 0.1361 1.0512 + 1
6(0.1361) = 1.0699
4 0.4 1.0699 0.1(0.4+1.0699) = 0.1500 1.0699 + 1
6(0.1500) = 1.0895
5 0.5 1.0895 0.1(0.5+1.0895) = 0.1650 1.0895 + 1
6(0.1650) = 1.1098
6 0.6 1.1098 0.1(0.6+1.1098) = 0.1811 1.1098 + 1
6(0.1811) = 1.1309
7 0.7 1.1309 0.1(0.7+1.1309) = 0.1982 1.1309 + 1
6(0.1982) = 1.1528
8 0.8 1.1528 0.1(0.8+1.1528) = 0.2163 1.1528 + 1
6(0.2163) = 1.1754
9 0.9 1.1754 0.1(0.9+1.1754) = 0.2355 1.1754 + 1
6(0.2355) = 1.1985
10 1 1.1985 0.1(1 + 1.1985) = 0.2559 1.1985 + 1
6(0.2559) 1.2221
Therefore
Question 27
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.02.
Solution
Step 1: Initialize the problem and set up the fourth-order Runge-Kutta method.
h= 0.02
x0= 0
y0= 1
k1=hf(x0, y0) = 0.02(02+ 1) = 0.02
k2=hf(x0+h
2, y0+k1
2) = 0.02((0 + 0.01)2+ 1 + 0.01/2) = 0.0201
k3=hf(x0+h
2, y0+k2
2) = 0.02((0 + 0.01)2+ 1 + 0.0201/2) = 0.0202
k4=hf(x0+h, y0+k3)=0.02((0 + 0.02)2+ 1 + 0.0202) = 0.0204
Step 2: Compute the new value of y using the fourth-order Runge-Kutta
method.
26
y1=y0+1
6(k1+2k2+2k3+k4) = 1+1
6(0.02+20.0201+20.0202+0.0204) = 1.0401
Therefore, the estimate for y(0.1) using the fourth-order Runge-Kutta method
with a step size of h= 0.02 is y(0.1) 1.0401.
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
at x= 0.2. Perform the necessary calculations up to the fourth step.
Solution
Step 1: Calculate the step size h.
h=0.20
4= 0.05
Step 2: Initialize the variables.
x0= 0, y0= 1
Step 3: Calculate the intermediate values using Runge-Kutta method.
k1=hx2
0+y0= 0.05 02+ 1= 0.05
k2=h(x0+h
2)2+ (y0+k1
2)= 0.05 (0 + 0.05
2)2+ (1 + 0.05
2)0.0521875
k3=h(x0+h
2)2+ (y0+k2
2)= 0.05 (0 + 0.05
2)2+ (1 + 0.0521875
2)0.0534375
k4=h(x0+h)2+ (y0+k3)= 0.05 (0 + 0.05)2+ (1 + 0.0534375)0.1053125
Step 4: Update the values of xand y.
x1=x0+h= 0 + 0.05 = 0.05
y1=y0+1
6(k1+ 2k2+ 2k3+k4) = 1 + 1
6(0.05 + 2(0.0521875) + 2(0.0534375) + 0.1053125) 1.1098958
27
Question 29
Question
Use the fourth-order Runge-Kutta method to approximate the solution of the
initial value problem:
y= 2xy, y(0) = 1
at x= 0.1. Use step size h= 0.05.
Solution
Given the initial value problem y= 2xy,y(0) = 1, we want to approximate
y(0.1) using the fourth-order Runge-Kutta method with step size h= 0.05.
The fourth-order Runge-Kutta formula 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)
Step 1: Calculate k1, k2, k3,and k4using f(x, y) = 2xy.
k1=f(0,1) = 2 ·0·1=0
k2=f0 + 0.05
2,1 + 0.05
2·0=f(0.025,1) = 2 ·0.025 ·1=0.05
k3=f0 + 0.05
2,1 + 0.05
2·0.05=f(0.025,1.0025) = 2 ·0.025 ·1.0025 = 0.05025
k4=f(0 + 0.05,1+0.05 ·0.05025) = f(0.05,1.002513) = 2 ·0.05 ·1.002513 0.1002513
Step 2: Calculate the new approximation yn+1.
yn+1 = 1 + 0.05
6(0 + 2 ·0.05 + 2 ·0.05025 + 0.1002513)
= 1 + 0.05
6(0 + 0.1+0.1005 + 0.1002513)
= 1 + 0.05
6(0.3007513)
1+0.0251252
1.0251252
Therefore, the approximate solution of the initial value problem at x= 0.1
is y(0.1) 1.0251252.
28
Question 30
Question
Consider the following initial value problem:
dy
dx =x2+y, y(0) = 1
Use the fourth-order Runge-Kutta method to approximate the value of yat
x= 0.2. Take h= 0.1.
Solution
Step 1: Define the increments k1,k2,k3, and k4as follows:
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+y.
Step 2: Calculate the next approximation using the formula:
yn+1 =yn+1
6(k1+ 2k2+ 2k3+k4)
Step 3: Apply the method iteratively until x= 0.2.
Starting with x0= 0 and y0= 1, we have:
k1= 0.1(02+ 1) = 0.1
k2= 0.10 + 0.1
22
+ (1 + 0.1
2)=0.10525
k3= 0.10 + 0.10525
22
+ (1 + 0.10525
2) = 0.110770625
k4= 0.1(0 + 0.110770625) = 0.0110770625
Thus, y1is calculated as:
y1= 1 + 1
6(0.1 + 2 ×0.10525 + 2 ×0.110770625 + 0.0110770625) = 1.0158721354
Continuing this process, we will find the value of yat x= 0.2.
29
Question 31
Question
Consider the initial value problem:
dy
dx =xy, y(0) = 1.
Use the fourth-order Runge-Kutta method to approximate the value of y(0.5)
using a step size of h= 0.1.
Solution
To apply the fourth-order Runge-Kutta method, we need 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 yndenote the current values of xand y, respectively.
Step 1: Calculate k1:
f(xn, yn) = xnyn= 0 1 = 1
k1=h(1) = 0.1(1) = 0.1
Step 2: Calculate k2:
f(xn+h
2, yn+k1
2) = f(0.05,0.9) = 0.05 0.9 = 0.85
k2= 0.1(0.85) = 0.085
Step 3: Calculate k3:
f(xn+h
2, yn+k2
2) = f(0.05,0.9075) = 0.05 0.9075 = 0.8575
k3= 0.1(0.8575) = 0.08575
Step 4: Calculate k4:
f(xn+h, yn+k3) = f(0.1,0.91425) = 0.10.91425 = 0.81425
k4= 0.1(0.81425) = 0.081425
30
Step 5: Update yusing the weighted average:
yn+1 =yn+1
6(k1+ 2k2+ 2k3+k4)
= 1 + 1
6(0.1 + 2(0.085) + 2(0.08575) 0.081425)
= 0.917283
Therefore, the fourth-order Runge-Kutta method gives an approximate value
of y(0.1) 0.917283.
Question 32
Question
Consider the following initial value problem:
dy
dx =x2y, y(0) = 1
Use the fourth-order Runge-Kutta method with step size h= 0.1 to approximate
y(0.2).
Solution
To approximate the value of y(0.2) using the fourth-order Runge-Kutta method,
we will need to calculate the values of yat intermediate points using 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)
Step 1: Calculate y(0.1) using the Runge-Kutta method.
k1= 0.1·(0 1) = 0.1
k2= 0.1·0 + 0.1
2=0.05
k3= 0.1·0 + 0.05
2=0.025
k4= 0.1·(0.1+(0.025)) = 0.0075
y(0.1) = 1 + 1
6(0.1 + 2(0.05) + 2(0.025) + 0.0075) 0.89917
31
Step 2: Calculate y(0.2) using the Runge-Kutta method.
k1= 0.1·(0.120.89917) 0.01117
k2= 0.1·0.1 + 0.01117
20.10283
k3= 0.1·0.1 + 0.10283
20.10542
k4= 0.1·(0.2+0.10542) 0.30542
y(0.2) 0.89917 + 1
6(0.01117 + 2(0.10283) + 2(0.10542) + 0.30542) 0.95701
Therefore, the approximate value of y(0.2) using the fourth-order Runge-
Kutta method with step size h= 0.1 is y(0.2) 0.95701.
Question 33
Question
Use the fourth-order Runge-Kutta method to approximate the solution to the
initial value problem: dy
dx =x2+y2, y(0) = 1
over the interval 0 x1. Use a step size of h= 0.1.
Solution
To solve the given initial value problem using the fourth-order Runge-Kutta
method, we will follow these steps:
Step 1: Define the differential equation and initial condition:
dy
dx =x2+y2, y(0) = 1
Step 2: Choose the step size: Given that h= 0.1 and the interval is 0 x1,
we have n=10
0.1= 10 subintervals.
Step 3: Apply the fourth-order Runge-Kutta method: We will use the
following formulas to approximate yi+1 from yi:
k1=hf(xi, yi)
k2=hf(xi+h
2, yi+k1
2)
k3=hf(xi+h
2, yi+k2
2)
k4=hf(xi+h, yi+k3)
32
yi+1 =yi+1
6(k1+ 2k2+ 2k3+k4)
Step 4: Calculate the approximate values of y: Starting with the initial
condition y(0) = 1, we will use the fourth-order Runge-Kutta method to ap-
proximate the values of yat x= 0.1,0.2,...,1.
Step 5: Compute the solution and construct a table: Using the Runge-
Kutta method, calculate the values of yat x= 0.1,0.2,...,1 and construct a
table showing x,yapprox, and yexact.
Step 6: Analyze the results: Compare the approximate values obtained
using the fourth-order Runge-Kutta method with the exact solution to analyze
the accuracy of the method.
Question 34
Question
Consider the initial value problem dy
dx =x2y,y(0) = 1. Use the fourth-order
Runge-Kutta method to approximate y(1) using a step size of h= 0.1.
Solution
Given the initial value problem, we want to approximate y(1) using the fourth-
order Runge-Kutta method with a step size of h= 0.1.
The general formula for the fourth-order Runge-Kutta method is as follows:
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) = x2y.
We will start at x= 0 and iteratively apply the above formulas to find y(1).
Step 1: Initialize x0= 0, y0= 1, h= 0.1.
Step 2: Calculate k1, k2, k3, k4and y1using the above formulas:
For k1:
k1= 0.1(021) = 0.1
For k2:
k2= 0.10 + 0.1
2,1 + 0.1
2= 0.1(0.05 0.05) = 0
33
For k3:
k3= 0.10 + 0.1
2,1 + 0
2= 0.1(0.05) = 0.005
For k4:
k4= 0.1 (0 + 0.1,1+0.005) = 0.1(0.1+1.005) = 0.1105
Therefore,
y1= 1 + 1
6(0.1 + 2(0) + 2(0.005) + 0.1105) = 1.00184375
So, y(1) 1.00184375.
Question 35
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,1]. Use h= 0.1 and provide the approximations at x=
0.1,0.2,...,1.
Solution
Given the initial value problem dy
dx =x2+yand y(0) = 1, we want to use the
fourth-order Runge-Kutta method to approximate the solution over the interval
[0,1] with the step size h= 0.1.
The general formula for 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 xnand ynare the previous values of xand yrespectively, and his the
step size.
Let’s calculate the approximations at x= 0.1,0.2,...,1 using the fourth-
order Runge-Kutta method.
Step 1: Initialize variables: Let h= 0.1, x0= 0, and y0= 1.
34
Step 2: Calculate approximations using the fourth-order Runge-Kutta method:
At x= 0.1 : k1= 0.1(02+ 1) = 0.1,
k2= 0.10 + 0.1
22
+ (1 + 0.1
2)=0.1025,
k3= 0.10 + 0.1
22
+ (1 + 0.1025
2)=0.1051,
k4= 0.1 (0 + 0.1)2+ (1 + 0.1051) = 0.1151,
y1= 1 + 1
6(0.1 + 2(0.1025) + 2(0.1051) + 0.1151) = 1.1133.
At x= 0.2 : (Continue this process for each point in the interval.)
Continue this process until you have approximations at x= 0,0.1,0.2,...,1.
35
Students also viewed