MATH 334 - DIFFERENTIAL
EQUATIONS - Runge-Kutta methods
Question Bank - Set 1
Liberty University
Question 1
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) using a step
size of h= 0.1. Round your final answer to four decimal places.
Solution
Step 1: Define the function f(x, y) = x2+y.
Step 2: Set up the fourth-order Runge-Kutta method:
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 xn+1 =xn+hand yn+1 =yn+1
6(k1+ 2k2+ 2k3+k4).
Step 3: Implement the method with x0= 0, y0= 1, and h= 0.1:
k1= 0.1·(02+ 1) = 0.1,
k2= 0.1·0 + 1 + 0.1
2= 0.105,
k3= 0.1·0 + 1 + 0.105
2= 0.11025,
k4= 0.1·(0.1+1+0.11025) = 0.211025.
Using these values, we can calculate y(0.1):
y(0.1) = 1 + 1
6(0.1+2×0.105 + 2 ×0.11025 + 0.211025)
= 1 + 1
6(0.1+0.21 + 0.2205 + 0.211025)
= 1 + 1
6(0.741525)
= 1.123588.
Step 4: Repeat the process with x= 0.1 and y= 1.123588:
k1= 0.1·(0.12+ 1.123588) ≈0.11236,
k2= 0.1·0.1+1.123588 + 0.11236
2≈0.124476,
k3= 0.1·0.1+1.123588 + 0.124476
2≈0.136716,
k4= 0.1·(0.1+1.123588 + 0.136716) ≈0.136771.
Now, calculating y(0.2):
y(0.2) = 1.123588 + 1
6(0.11236 + 2 ×0.124476 + 2 ×0.136716 + 0.136771)
= 1.123588 + 1
6(0.808515)
≈1.256256.
Therefore, the approximate value of y(0.2) using the fourth-order Runge-
Kutta method is 1.2563.
Question 2
Question
Consider the initial value problem
(y′=−2y+ 4t
y(0) = 1
Use the classical fourth-order Runge-Kutta method to approximate y(0.2) with
a step size of h= 0.1.
2
Solution
Step 1: We first need to set up the fourth-order Runge-Kutta method. The
formulas for this method are:
k1=hf(tn, yn)
k2=hf(tn+ 0.5h, yn+ 0.5k1)
k3=hf(tn+ 0.5h, yn+ 0.5k2)
k4=hf(tn+h, yn+k3)
yn+1 =yn+1
6(k1+ 2k2+ 2k3+k4)
where f(t, y) = −2y+ 4t.
Step 2: We will apply the Runge-Kutta method with h= 0.1 to approximate
y(0.2).
k1= 0.1(−2·1+4·0) = 0
k2= 0.1(−2·1+4·0.05) = 0.3
k3= 0.1(−2·1+4·0.05) = 0.3
k4= 0.1(−2·1+4·0.1) = 0.2
y1= 1 + 1
6(0 + 2 ·0.3+2·0.3+0.2) = 1.05
Therefore, the approximation of y(0.2) using the fourth-order Runge-Kutta
method with step size h= 0.1 is y(0.2) ≈1.05.
Question 3
Question
Consider the initial value problem dy
dx =x2−y,y(0) = 1. Use the fourth-order
Runge-Kutta method to approximate y(1) with a step size of h= 0.1.
Solution
To approximate y(1) 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 step size h= 0.1 and the initial values x0= 0, y0= 1.
Step 3: Calculate the approximate values of yat each step using the fourth-
order Runge-Kutta method:
3
k1=h·f(x0, y0)=0.1·(02−1) = −0.1
k2=h·f(x0+h
2, y0+k1
2)=0.1·(0.052−0.05) = −0.00975
k3=h·f(x0+h
2, y0+k2
2)=0.1·(0.052−0.049375) = −0.009500625
k4=h·f(x0+h, y0+k3)=0.1·(0.12−0.058375) = −0.0038375
Step 4: Use the formula for the next approximation:
y1=y0+1
6(k1+2k2+2k3+k4) = 1+1
6(−0.1−2·0.00975−2·0.009500625−0.0038375) ≈0.89471
Therefore, the approximate value of y(1) using the fourth-order Runge-Kutta
method with a step size of h= 0.1 is 0.89471.
Question 4
Question
Use the fourth-order Runge-Kutta method to approximate the solution to the
initial value problem dy
dx =−2y+ 4x, y(0) = 1
over the interval [0,1] using a step size of h= 0.1.
Solution
The fourth-order Runge-Kutta method is given by 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+1
6(k1+ 2k2+ 2k3+k4),
where f(x, y) is the function in the initial value problem.
We will iterate from x= 0 to x= 1 with a step size of h= 0.1, calculating
the value of yat each step using the Runge-Kutta method.
Step 1: Initialize the variables. Let h= 0.1, x0= 0, y0= 1, and xf= 1.
4
Step 2: Calculate the approximations.
k1= 0.1(−2(1) + 4(0)) = −0.2,
k2= 0.1(−2(1 + 0.1/2) + 4(0 + 0.1/2)) = −0.19,
k3= 0.1(−2(1 + 0.1/2) + 4(0 −0.19/2)) = −0.17,
k4= 0.1(−2(1 + 0.1) + 4(0 −0.17)) = −0.15,
y1= 1 + 1
6(−0.2 + 2(−0.19) + 2(−0.17) −0.15) = 0.79.
Repeat this process for x= 0.1,0.2,0.3, ..., 1 until the value at x= 1 is
found.
Question 5
Question
Using the fourth-order Runge-Kutta method, approximate the solution of the
initial value problem dy
dx =x2−y, y(0) = 1,
at x= 0.1. Use a step size of h= 0.05.
Solution
To approximate the solution at x= 0.1 using the fourth-order Runge-Kutta
method, we will take several steps to update our estimate of y.
Step 1: Define the functions f(x, y) = x2−yand set the initial conditions
x0= 0, y0= 1, and h= 0.05.
Step 2: Calculate the four intermediate values 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 values of xand yat the current step.
Step 3: Compute the weighted average of the four slopes k1,k2,k3, and k4
to get the next approximation yn+1:
yn+1 =yn+1
6(k1+ 2k2+ 2k3+k4).
Step 4: Repeat steps 2 and 3 until you reach x= 0.1. Applying these steps
iteratively, we can find the approximate solution of the initial value problem at
x= 0.1.
5
Question 6
Question
Consider the initial value problem y′=x2−ywith initial condition y(0) = 1.
Use the Runge-Kutta method of order four to approximate y(1), using step size
h= 0.1.
Solution
To apply the Runge-Kutta method of order four, we will compute the values of
y(x) at discrete 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)
where f(x, y) = x2−yis the differential equation.
Using h= 0.1 and starting at x= 0, we will calculate the approximate value
of y(1).
Step 1: Calculate the values of k1, k2, k3,and k4at each step.
At x= 0:
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+1+2·(−0.00025)) = 0.09475
Step 2: Update yusing the weighted sum.
y1= 1 + 1
6(−0.1 + 2(−0.005) + 2(−0.00025) + 0.09475) = 0.94195833333
Question 7
Question
Consider the initial value problem dy
dx =x2−ywith initial condition y(0) = 1.
Use the fourth-order Runge-Kutta method to approximate y(1) with a step size
of h= 0.1.
6
Solution
To approximate the value of y(1) 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 up the fourth-order 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)
yn+1 =yn+1
6(k1+ 2k2+ 2k3+k4)
Step 3: Iterate through the given steps for n= 0,1,2, ..., 10 with h= 0.1:
-n= 0: - x0= 0 - y0= 1 - Calculate k1, k2, k3, k4using the above formulas -
Update y1using the formula: y1=y0+1
6(k1+ 2k2+ 2k3+k4) - Continue this
process until reaching n= 10
Step 4: After iterating through the steps, the approximated value of y(1)
using the fourth-order Runge-Kutta method with a step size of h= 0.1 will be
the value of yat x= 1 after 10 iterations.
Question 8
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
Given the initial value problem, we will use the fourth-order Runge-Kutta
method to approximate the value of y(1). The general formula for the fourth-
7
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 f(x, y) = x2−y.
Step 1: Calculate the values of k1,k2,k3, and k4.
k1= 0.2(02−1) = −0.2
k2= 0.20 + −0.2
22−(1 + −0.2
2) = 0.22
k3= 0.20 + 0.22
22−(1 + 0.22
2) = −0.2244
k4= 0.2 (0.2,1−0.2244)2−(1 −0.2244) = 0.09042
Step 2: Calculate the next approximation using the formula.
y1= 1 + 1
6(−0.2 + 2(0.22) + 2(−0.2244) + 0.09042)
= 1 + 1
6(0.12312)
= 1.02052.
Therefore, the fourth-order Runge-Kutta method gives us an approximation
of y(1) ≈1.02052.
Question 9
Question
Consider the initial value problem given by the differential equation
y′= 2y−x2, y(0) = 1,
and let h= 0.1. Use the fourth-order Runge-Kutta method to approximate
y(0.4).
8
Solution
To approximate y(0.4) using the fourth-order Runge-Kutta method, we will
iteratively calculate the values of yiat each step.
Step 1: Calculate k1,k2,k3, and k4for each iteration using the formulas:
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)
Step 2: Update yiusing the formula:
yi+1 =yi+1
6(k1+ 2k2+ 2k3+k4)
Step 3: Repeat these steps until xi= 0.4.
Now, let’s begin with the calculations:
Step 1: At x= 0, we have y= 1.
k1= 0.1(2(1) −02)=0.2
k2= 0.1(2(1 + 0.05) −(0 + 0.05)2)=0.209375
k3= 0.1(2(1 + 0.05) −(0 + 0.05)2)=0.209375
k4= 0.1(2(1 + 0.1) −(0 + 0.1)2)=0.218
Step 2:
y1= 1 + 1
6(0.2 + 2(0.209375) + 2(0.209375) + 0.218) = 1.016042
Now continue these calculations iteratively until we reach x= 0.4.
Question 10
Question
Consider the following initial value problem:
dy
dt =t−y, y(0) = 1
Approximate the value of y(0.1) using the fourth-order Runge-Kutta method
with h= 0.05.
9
Solution
Let’s denote f(t, y) = t−y. Using the formula for the fourth-order Runge-Kutta
method: k1=hf(tn, yn)
k2=hf(tn+ 0.5h, yn+ 0.5k1)
k3=hf(tn+ 0.5h, yn+ 0.5k2)
k4=hf(tn+h, yn+k3)
yn+1 =yn+1
6(k1+ 2k2+ 2k3+k4)
Step 1: Calculate y(0.05)
k1= 0.05(0 −1) = −0.05
k2= 0.05 (0 + 0.5(0.05)(−0.05)) = −0.0625
k3= 0.05 (0 + 0.5(0.05)(−0.0625)) = −0.065625
k4= 0.05 (0.05,−0.065625) = −0.06015625
y(0.05) = 1 + 1
6(−0.05 + 2(−0.0625) + 2(−0.065625) −0.06015625) ≈0.920859375
Step 2: Calculate y(0.1)
k1= 0.05(0.05 −0.920859375) ≈ −0.04390703125
k2= 0.05 (0.05 + 0.5(0.05)(−0.04390703125)) ≈ −0.048261538089
k3= 0.05 (0.05 + 0.5(0.05)(−0.048261538089)) ≈ −0.051143131755
k4= 0.05 (0.1,−0.051143131755) ≈ −0.046263126158
y(0.1) ≈0.920859375 + 1
6(−0.04390703125 + 2(−0.048261538089) + 2(−0.051143131755) −0.046263126158) ≈0.871068758692
Therefore, y(0.1) ≈0.8711.
Question 11
Question
Use the fourth-order Runge-Kutta method to approximate the solution to the
initial value problem
dy
dx =y−x2+ 1, y(0) = 0,
over the interval x∈[0,1]. Use a step size of h= 0.1.
10
Solution
To apply the fourth-order Runge-Kutta method, we first need to define 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) = y−x2+ 1.
Step 1: Initialize the problem by defining the step size h, the number of
steps N, and the initial conditions.
h= 0.1,
N=1−0
h= 10,
y0= 0.
Step 2: Use the formulas to approximate the solution.
For n= 0 :
k1= 0.1(0 −02+ 1) = 0.1,
k2= 0.10 + 0.1
2= 0.05,
k3= 0.10 + 0.05
2= 0.025,
k4= 0.1(0.025 −(0.1)2+ 1) = 0.11125,
y1= 0 + 1
6(0.1 + 2(0.05) + 2(0.025) + 0.11125) = 0.052083.
Continue this process for n= 1,2,...,10 to approximate the solution over
the interval x∈[0,1].
Question 12
Question
Consider the following initial value problem:
dy
dx =x2−y, y(0) = 1
Use the fourth-order Runge-Kutta method with step size 0.1 to approximate
the value of yat x= 0.4.
11
Solution
Step 1: Define f(x, y) = x2−yand the step size h= 0.1.
Step 2: Calculate the four increments:
k1=h·f(x, y)=0.1·(02−1) = −0.1
k2=h·f(x+h
2, y +k1
2)=0.1·(0.052−(1 + 0.05(−0.1))) ≈ −0.097375
k3=h·f(x+h
2, y +k2
2)=0.1·(0.052−(1 + 0.05(−0.097375))) ≈ −0.09578062
k4=h·f(x+h, y +k3)=0.1·(0.12−(1 + 0.1(−0.09578062))) ≈ −0.090437959
Step 3: Compute the new value of yusing the weighted sum:
y1=y+1
6(k1+ 2k2+ 2k3+k4)
= 1 + 1
6(−0.1 + 2(−0.097375) + 2(−0.09578062) −0.090437959)
≈0.904303933
Therefore, the approximate value of yat x= 0.4 using the fourth-order
Runge-Kutta method with step size 0.1 is y≈0.904303933.
Question 13
Question
Consider the initial value problem:
dy
dx =x2−y, y(0) = 1.
Use the classical fourth-order Runge-Kutta method with step size h= 0.2
to approximate y(0.4).
Solution
We will approximate the value of y(0.4) using the classical fourth-order Runge-
Kutta method with step size h= 0.2.
Step 1: Initialize the values and setup the formula for Runge-Kutta method.
Let y0= 1, x0= 0, and h= 0.2. Then, we have:
k1=h·f(x0, y0)=0.2·((0)2−1) = −0.2
k2=h·f(x0+h
2, y0+k1
2) = 0.2·((0.1)2−(1 −0.1(0.2))) = −0.18
k3=h·f(x0+h
2, y0+k2
2) = 0.2·((0.1)2−(1 −0.1(0.18))) = −0.1762
12
k4=h·f(x0+h, y0+k3) = 0.2·((0.2)2−(1 −0.1762)) = −0.1617
Step 2: Calculate the approximate value of y(0.4).
y1=y0+1
6(k1+ 2k2+ 2k3+k4)
y1= 1 + 1
6(−0.2−2(0.18) −2(0.1762) −0.1617)
y1≈0.8268
Therefore, the approximate value of y(0.4) using the classical fourth-order
Runge-Kutta method with step size h= 0.2 is approximately 0.8268.
Question 14
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.2 to estimate
y(0.4). Show all your steps.
Solution
Step 1: We first compute the increments using the Runge-Kutta formulas:
k1=h·f(x0, y0)=0.2·(02+ 1) = 0.2
k2=h·f(x0+h
2, y0+k1
2)=0.2·(0.12+ 1 + 0.1·0.2/2) ≈0.201
k3=h·f(x0+h
2, y0+k2
2)=0.2·(0.12+ 1 + 0.1·0.201/2) ≈0.202
k4=h·f(x0+h, y0+k3)=0.2·(0.22+ 1 + 0.2·0.202) ≈0.208
Step 2: Next, we use the increments to compute the estimate of y(0.4):
y(0.4) ≈y0+1
6(k1+ 2k2+ 2k3+k4)
≈1 + 1
6(0.2+2·0.201 + 2 ·0.202 + 0.208)
≈1 + 1
6(0.2+0.402 + 0.404 + 0.208)
≈1 + 1
6·1.214
≈1.202
Therefore, the approximate value of y(0.4) using the fourth-order Runge-
Kutta method is 1.202.
13
Question 15
Question
Consider the differential equation dy
dx =x2−ywith initial condition y(0) = 1.
Use the fourth-order Runge-Kutta method to approximate the value of y(1)
using a step size of h= 0.1.
Solution
To approximate the value of y(1) using the fourth-order Runge-Kutta method,
we will follow these steps:
Step 1: Define the function f(x, y) = x2−y.
Step 2: Calculate the increments k1,k2,k3, and k4using 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)
Step 3: Update the values of xand yusing the weighted average of the
increments:
yn+1 =yn+1
6(k1+ 2k2+ 2k3+k4)
Step 4: Repeat steps 2 and 3 for n= 0,1,2, ..., 10 until x= 1.
Now, let’s compute the solution using the fourth-order Runge-Kutta method
with a step size of h= 0.1.
Step 1: Define the function f(x, y) = x2−y.
Step 2: Calculate the increments k1,k2,k3, and k4:
At x= 0: k1= 0.1(02−1) = −0.1
k2= 0.10 + 0.1
2,1 + −0.1
2= 0.405
k3= 0.10 + 0.1
2,1 + 0.405
2= 0.404875
k4= 0.1 (0 + 0.1,1+0.404875) = 0.5404875
Step 3: Update the values of xand y:
y1= 1 + 1
6(−0.1 + 2(0.405) + 2(0.404875) + 0.5404875) = 1.11735625
Continue these calculations until x= 1 to find the approximate value of
y(1).
14
Question 16
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] using a step size of h= 0.1. Show all your calculations
to at least 4 decimal places.
Solution
To approximate the solution using the fourth-order Runge-Kutta method, we
will follow these steps:
Step 1: Determine the number of subintervals Given that the interval
is [0,0.4] and the step size is h= 0.1, the number of subintervals is:
n=0.4−0
0.1= 4
Step 2: Initialize variables Let us set x0= 0 and y0= 1. Also, set
h= 0.1 and n= 4.
Step 3: Calculate the approximate values Using the fourth-order
Runge-Kutta method, calculate the approximate values of yat each iteration
as follows:
Step x k1k2k3k4
1 0.0 - - - -
2 0.1 - - - -
3 0.2 - - - -
4 0.3 - - - -
5 0.4 - - - -
Now, let’s calculate the values for each step:
Step 1: At x= 0, we have:
k1= 02+ 12= 1
k2= (0 + 0.05)2+ (1 + 0.05 ·1)2= 0.0025 + 1.1025 = 1.105
k3= (0 + 0.05)2+ (1 + 0.05 ·1.105)2= 0.0025 + 1.2175 = 1.22
k4= (0 + 0.1)2+ (1 + 0.1·1.22)2= 0.01 + 1.5884 = 1.5984
Thus, at x= 0.1:
y1= 1 + 0.1
6(1 + 2(1.105) + 2(1.22) + 1.5984) = 1.22073
Step 2: Repeat the procedure for the next steps.
Step 3: Continue the process until x= 0.4, and calculate the final approx-
imation of the solution.
15
Question 17
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.2. Use a step size of h= 0.1.
Solution
To approximate the solution using the fourth-order Runge-Kutta method, we
will follow these steps: Let h= 0.1 and xi= 0, yi= 1. Then we have: Step 1:
Calculate k1,k2,k3, and k4. Step 2: Update the values of xand yusing the
weighted sum of the four slopes. Step 3: Repeat until x= 0.2.
Step 1: We have
k1=h·f(xi, yi)=0.1·(02+ 1) = 0.1
k2=h·f(xi+ 0.5h, yi+ 0.5k1)=0.1·(0.052+ 1.05) = 0.10625
k3=h·f(xi+ 0.5h, yi+ 0.5k2)=0.1·(0.052+ 1.053125) = 0.1065625
k4=h·f(xi+h, yi+k3)=0.1·(0.12+ 1.15914375) = 0.115914375
Step 2: Now we calculate the weighted sum of the slopes:
yi+1 =yi+1
6(k1+2k2+2k3+k4) = 1+1
6(0.1+2·0.10625+2·0.1065625+0.115914375) = 1.0239984375
Step 3: Since x= 0.2 is not reached in one step, we need to repeat the
process with updated values of xand yuntil x= 0.2.
Therefore, the approximate value of yat x= 0.2 is y≈1.0239984375.
Question 18
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] with a step size of h= 0.1.
16
Solution
To use the fourth-order Runge-Kutta method, we will follow these steps at each
iteration: 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 f(x, y) = x2+y.
Step 1: Initialize the values x0= 0, y0= 1, and the step size h= 0.1.
Step 2: Using the Runge-Kutta formula, calculate the values of k1,k2,k3,
and k4at each step.
k1= 0.1·(02+ 1) = 0.1
k2= 0.1·(0 + 0.1
2)2+ (1 + 0.1
2= 0.10505
k3= 0.1·(0 + 0.1
2)2+ (1 + 0.10505
2= 0.1103460038
k4= 0.1·((0 + 0.1)2+ (1 + 0.1103460038)) = 0.1159310038
Step 3: Update the values of xand yusing the weighted average of k1,k2,
k3, and k4.
x1= 0 + 0.1 = 0.1
y1= 1 + 1
6(0.1 + 2(0.10505 + 0.1103460038) + 0.1159310038) ≈1.1163334606
Step 4: Repeat Steps 2 and 3 until the end of the interval.
Continue these steps until you reach the end of the interval, x= 1, to
approximate the solution using the fourth-order Runge-Kutta method.
Question 19
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 ≤x≤1 with
step size h= 0.1.
Solution
To apply the fourth-order Runge-Kutta method, we need to follow the steps
outlined below:
17
Step 1: Define the differential equation and initial condition: The given
initial value problem is dy
dx =x2+y2,y(0) = 1.
Step 2: Determine the number of subintervals: The interval [0,1] with step
size h= 0.1 gives us 10 subintervals.
Step 3: Set up the algorithm for the fourth-order Runge-Kutta method:
The fourth-order Runge-Kutta method is given by the following equations:
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+y2.
Step 4: Perform the calculations for each subinterval: Starting with y0= 1,
we will calculate y1, y2, . . . , y10 using the Runge-Kutta method.
Step 5: Calculate the approximate solution: After completing calculations
for all subintervals, we obtain the approximations y1, y2, . . . , y10.
Step 6: Present the final approximate solution: The final approximate
solution to the initial value problem dy
dx =x2+y2,y(0) = 1 over the interval
0≤x≤1 with step size h= 0.1 is given by the values of y1, y2, . . . , y10.
Question 20
Question
Use the Runge-Kutta method to approximate the solution to the initial value
problem dy
dx =x2−y, y(0) = 1
over the interval [0,1] using four steps. Use step size h= 0.25.
Solution
To approximate the solution to the initial value problem using the fourth-order
Runge-Kutta method, we will follow these steps: Let h= 0.25 so that we take
four steps over the interval [0,1].
Step 1: Calculate y1using the formula
k1=h·f(x0, y0)=0.25 ·((0)2−1) = −0.25
k2=h·f(x0+ 0.5h, y0+ 0.5k1) = 0.25 ·((0.25)2−1+0.5(−0.25)) = −0.21875
k3=h·f(x0+0.5h, y0+0.5k2)=0.25·((0.25)2−1+0.5(−0.21875)) = −0.22167969
18
k4=h·f(x0+h, y0+k3)=0.25 ·((0.5)2−1 + (−0.22167969)) = −0.18286133
y1=y0+1
6(k1+2k2+2k3+k4) = 1+1
6(−0.25+2(−0.21875)+2(−0.22167969)−0.18286133) ≈0.85561
Step 2: Calculate y2using the formula Proceeding in a similar manner as
above we find y2≈0.73284.
Step 3: Calculate y3using the formula Similarly, we find y3≈0.63831.
Step 4: Calculate y4using the formula Finally, we find y4≈0.56382.
Therefore, the approximate solution to the initial value problem over the
interval [0,1] using four steps with step size h= 0.25 is y(1) ≈0.56382.
Question 21
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 ≤x≤1 using a step size of h= 0.1.
Solution
To apply the fourth-order Runge-Kutta method to the given initial value prob-
lem, we will use the following iterative 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: Set up the table for the iterative calculations.
19
n xnynk1k2k3
k4yn+1
0 0 1
1
2
3
4
Step 2: Fill in the table using the Runge-Kutta formulas.
For n= 0:
k1= 0.1(02−1) = −0.1,
k2= 0.1(0 + 0.05)2−(1 −0.05)=−0.0975,
k3= 0.1(0 + 0.05)2−(1 −0.0975/2)=−0.09581,
k4= 0.1(0 + 0.1)2−(1 −0.09581)=−0.09401,
yn+1 = 1 + 1
6(−0.1 + 2(−0.0975) + 2(−0.09581) −0.09401) = 0.904215.
Continue this process for n= 1,2,3,4 until n= 10.
Step 3: Compute the approximate solution for the given initial value prob-
lem.
After completing the table, you should obtain the approximation of y(1) as
0.249985 using the fourth-order Runge-Kutta method.
Question 22
Question
Consider the Initial Value Problem (IVP) given by:
dy
dx =x2−y2, y(0) = 1
Apply the classical fourth-order Runge-Kutta method to approximate y(0.5)
with a step size of h= 0.1.
Solution
Given an Initial Value Problem (IVP) by
dy
dx =x2−y2, y(0) = 1
20
we want to approximate the value of y(0.5) using the classical fourth-order
Runge-Kutta method with a step size of h= 0.1.
Step 1: Define the function f(x, y) = x2−y2.
Step 2: Using the fourth-order Runge-Kutta method, we have the following
iteration 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 3: Using the initial condition y(0) = 1, we can start the iteration.
Step 4: Now, we compute the values of yat each iteration.
n xnynk1k2
k3k4yn+1
0 0 1 . . . . . .
. . . . . . . . .
1 0.1. . . . . . . . .
. . . . . . . . .
2 0.2. . . . . . . . .
. . . . . . . . .
3 0.3. . . . . . . . .
. . . . . . . . .
4 0.4. . . . . . . . .
. . . . . . . . .
5 0.5. . . . . . . . .
. . . . . . . . .
By completing the table above, we can approximate y(0.5).
Question 23
Question
Consider the initial value problem:
dy
dx =x2−y, y(0) = 1
Use the fourth-order Runge-Kutta method to estimate y(1) by taking steps of
size h= 0.1.
21
Solution
The fourth-order Runge-Kutta method is given by 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)
yn+1 =yn+1
6(k1+ 2k2+ 2k3+k4)
Step 1: Define the function f(x, y) = x2−y.
Step 2: Set the initial values x0= 0 and y0= 1.
Step 3: Calculate the values using the fourth-order Runge-Kutta method:
k1= 0.1·(02−1) = −0.1
k2= 0.1·0 + 0.1
2−1 + −0.1
2=−0.0975
k3= 0.1·0 + 0.1
2−1 + −0.0975
2=−0.095
k4= 0.1·(0.1−0.095) = 0.0005
y1= 1 + 1
6(−0.1 + 2(−0.0975) + 2(−0.095) + 0.0005) = 0.900083
Therefore, the estimated value of y(1) using the fourth-order Runge-Kutta
method with step size h= 0.1 is approximately 0.900083.
Question 24
Question
Consider the initial value problem:
dy
dx =x2−y, y(0) = 1
Use the classical fourth-order Runge-Kutta method with step size h= 0.2 to
estimate y(0.8).
Solution
Let’s denote f(x, y) = x2−y. The classical fourth-order Runge-Kutta method
can be implemented using the following formulae:
k1=hf(xn, yn)
22
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)
Applying these formulae with x0= 0 and y0= 1, and with h= 0.2, we get:
Step 1:
k1= 0.2(02−1) = −0.2
k2= 0.2(0.12−1 + −0.2
2) = −0.194
k3= 0.2(0.12−1 + −0.194
2) = −0.1862
k4= 0.2(0.22−1 + −0.1862) = −0.1708
y1= 1 + 1
6(−0.2 + 2(−0.194) + 2(−0.1862) −0.1708) = 0.8561
So, the estimated value of y(0.2) using the fourth-order Runge-Kutta method
is approximately 0.8561.
Question 25
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 ≤x≤1 with a step size h= 0.1.
Solution
To apply the fourth-order Runge-Kutta method, we calculate the values of yi
at each step using the formula:
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),
yi+1 =yi+1
6(k1+ 2k2+ 2k3+k4),
23
where f(x, y) = x2−y2.
Step 1: For i= 0, we have x0= 0 and y0= 1.
Step 2: Using the formula above, we can calculate k1,k2,k3, and k4to find
y1:
k1= 0.1(02−12) = −0.1,
k2= 0.1(0 + 0.1
2)2−(1 −0.1
2)2=−0.10125,
k3= 0.1(0 + 0.1
2)2−(1 −0.10125
2)2=−0.102500625,
k4= 0.1(0 + 0.1)2−(1 −0.102500625)2=−0.103781628197875,
y1= 1 + 1
6(−0.1 + 2(−0.10125) + 2(−0.102500625) −0.103781628197875) = 0.840222984805.
Repeating this process for i= 1,2, ..., 10, we can approximate the solution
over the interval 0 ≤x≤1 with a step size of h= 0.1.
Question 26
Question
Consider the following initial value problem:
(y′=y−t2+ 1
y(0) = 0
Use the fourth-order Runge-Kutta method to estimate y(0.1) with step size
h= 0.02.
Solution
Step 1: Define the function f(t, y) based on the differential equation y′=y−
t2+ 1:
f(t, y) = y−t2+ 1
Step 2: Implement the fourth-order Runge-Kutta method with step size
h= 0.02 to approximate y(0.1).
k1=hf(t0, y0)=0.02f(0,0) = 0.02(0 −02+ 1) = 0.02
k2=hf(t0+h
2, y0+k1
2)=0.02f0 + 0.02
2,0 + 0.02
2= 0.02f(0.01,0.01) = 0.02(0.01 −0.012+ 1) = 0.0201
k3=hf(t0+h
2, y0+k2
2)=0.02f0 + 0.02
2,0 + 0.0201
2= 0.02f(0.01,0.01005) = 0.02(0.01005 −0.012+ 1) = 0.02010025
k4=hf(t0+h, y0+k3)=0.02f(0 + 0.02,0.02010025) = 0.02(0.02010025 −0.022+ 1) = 0.02010050004
y1=y0+1
6(k1+ 2k2+ 2k3+k4) = 0 + 1
6(0.02 + 2(0.0201) + 2(0.02010025) + 0.02010050004) ≈0.02010133834
24
Therefore, using the fourth-order Runge-Kutta method, the approximation
for y(0.1) is approximately 0.0201.
Question 27
Question
Consider the initial value problem:
(y′=y−t2+ 1
y(0) = 0
Use the fourth-order Runge-Kutta method to approximate y(1) with step size
h= 0.1.
Solution
Step 1: We first need to compute the increments k1,k2,k3, and k4using the
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)
where f(t, y) = y−t2+ 1.
Step 2: Now we apply the formula for updating y:
yn+1 =yn+1
6(k1+ 2k2+ 2k3+k4)
Step 3: Now, let’s calculate the approximate value of y(1) using the given
initial condition and step size.
Step 4: Let’s start the calculations:
k1= 0.1(0 −(0)2+ 1) = 0.1
k2= 0.1(0 −(0 + 0.1/2)2+ 1) = 0.1(0 −0.0025 + 1) = 0.09975
k3= 0.1(0 −(0 + 0.1/2)2+ 1) = 0.1(0 −0.0025 + 1) = 0.09975
k4= 0.1(0 −0.12+ 1) = 0.1(0 −0.01 + 1) = 0.099
Step 5: Now, let’s update the value of y:
y1= 0 + 1
6(0.1 + 2(0.09975) + 2(0.09975) + 0.099)
y1= 0.015975
Therefore, the approximate value of y(1) using the fourth-order Runge-Kutta
method with step size h= 0.1 is 0.015975.
25
Question 28
Question
Consider the initial value problem given by the ordinary differential equation:
dy
dt =t2−ywith y(0) = 1
Use the fourth-order Runge-Kutta method with step size h= 0.1 to estimate
y(0.4).
Solution
Step 1: Define the differential equation and the Runge-Kutta method.
dy
dt =t2−y, y(0) = 1
The fourth-order Runge-Kutta method is given by the formulas:
k1=h·f(tn, yn)
k2=h·f(tn+h
2, yn+k1
2)
k3=h·f(tn+h
2, yn+k2
2)
k4=h·f(tn+h, yn+k3)
yn+1 =yn+1
6(k1+ 2k2+ 2k3+k4)
where his the step size.
Step 2: Implement the Runge-Kutta method to estimate y(0.4).
h= 0.1
t0= 0, y0= 1
t1=t0+h= 0.1, y1=y0+1
6(k1+ 2k2+ 2k3+k4)
First, calculate k1,k2,k3, and k4:
k1= 0.1·(02−1) = −0.1
k2= 0.1·0.12−1−0.1·0.1
2=−0.0825
k3= 0.1·0.12−1−0.1·0.0825
2=−0.065625
k4= 0.1·0.12−(1 −0.1·(−0.065625))=−0.04845625
26
Now, calculate y1:
y1= 1 + 1
6(−0.1 + 2(−0.0825) + 2(−0.065625) −0.04845625) ≈0.92638
Therefore, the estimated value of y(0.4) using the fourth-order Runge-Kutta
method with a step size of h= 0.1 is approximately 0.92638.
Question 29
Question
Consider the initial value problem:
y′= (t−y2), y(0) = 1
Use the fourth-order Runge-Kutta method to approximate the value of y(1)
with 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)
Substitute the given values into the formulas and perform the calculations
for each iteration:
Step 1: Calculate k1:
k1= 0.2((0) −(1)2) = −0.2
Step 2: Calculate k2:
k2= 0.2((0 + 0.2
2)−(1 −0.2
2)2) = −0.18
Step 3: Calculate k3:
k3= 0.2((0 + 0.2
2)−(1 −0.18
2)2) = −0.162
27
Step 4: Calculate k4:
k4= 0.2((0 + 0.2) −(1 −0.162)2) = −0.486
Step 5: Calculate yn+1:
yn+1 = 1 + 1
6(−0.2 + 2(−0.18) + 2(−0.162) −0.486) = 0.8836
Therefore, using the fourth-order Runge-Kutta method with a step size of
0.2, the approximate value of y(1) is 0.8836.
Question 30
Question
Consider the initial value problem:
dy
dx =x2−y, y(0) = 1
Use the classical fourth-order Runge-Kutta method with step size h= 0.2 to
estimate the value of y(1).
Solution
To approximate the value of y(1) using the classical fourth-order Runge-Kutta
method, we will first calculate the values of yat each step.
Let yndenote the approximate value of yat x=xn, where xn=x0+nh.
The Runge-Kutta method involves the following steps for each iteration:
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−y.
Now, we will apply the Runge-Kutta method with step size h= 0.2 to
estimate y(1):
n xnynk1k2k3
0 0 1
1 0.2
2 0.4
3 0.6
4 0.8
5 1.0
28
Step 1: Calculate k1,k2,k3, and k4at each step.
At x= 0, y= 1:
k1=hf(x0, y0) = 0.2(02−1) = −0.2
Step 2: Repeat the process for yn+1 at each step until x= 1 is reached and
calculate the final approximation y(1).
Continue this process for k2,k3, and k4at each step until x= 1 is reached.
Finally, calculate y(1) using the formula:
yn+1 =yn+1
6(k1+ 2k2+ 2k3+k4)
Question 31
Question
Consider the initial value problem:
dy
dx =x2+y2, y(0) = 0,
and use the Runge-Kutta method with step size h= 0.1 to approximate y(0.5).
Solution
To approximate y(0.5) using the Runge-Kutta method, we will perform the
following steps:
Step 1: Define the increments k1,k2,k3, and k4as follows:
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.
Step 2: Update the values of xand y:
xn+1 =xn+h,
yn+1 =yn+1
6(k1+ 2k2+ 2k3+k4).
Step 3: Apply the above steps iteratively until we reach x= 0.5.
Now, let’s calculate the approximation of y(0.5) using the Runge-Kutta
method:
29
Step 1: Calculate the increments
k1= 0.1·(02+ 02)=0,
k2= 0.1· 0 + 0.1
22
+0 + 0
22!= 0.0005,
k3= 0.1· 0 + 0.1
22
+0 + 0.0005
22!≈0.0005000125,
k4= 0.1·(0.1+0.0005000125)2≈0.0001025.
Step 2: Update
y1= 0 + 1
6(0 + 2(0.0005) + 2(0.0005000125) + 0.0001025) ≈0.0002675.
Since x= 0.5 has not been reached, we would need to iterate the process
further to obtain the approximation of y(0.5).
Question 32
Question
Consider the initial value problem
y′=−2y+ 4t, y(0) = 1.
Use the fourth-order Runge-Kutta method with step size h= 0.2 to approximate
y(1).
Solution
Given the initial value problem, we will approximate the solution using the
fourth-order Runge-Kutta method with step size h= 0.2.
Let t0= 0 be the initial point, and t1= 0.2 be the next point where we want
to estimate y(t).
Step 1: Calculate the four slopes k1,k2,k3, and k4.
k1=f(t0, y0) = −2(1) + 4(0) = −2,
k2=f(t0+h
2, y0+h
2k1) = −2(1 + 0.1× −2) + 4(0.1) = −1.8,
k3=f(t0+h
2, y0+h
2k2) = −2(1 + 0.1× −1.8) + 4(0.1) = −1.64,
k4=f(t0+h, y0+hk3) = −2(1 + 0.2× −1.64) + 4(0.2) = −1.296.
Step 2: Use the weighted average of these slopes to find y1.
y1=y0+h
6(k1+2k2+2k3+k4) = 1+0.2×1
6(−2+2(−1.8)+2(−1.64)−1.296) = 0.757.
Therefore, the fourth-order Runge-Kutta approximation of y(0.2) is y(0.2) ≈
0.757.
30
Question 33
Question
Consider the initial value problem
dy
dx =x2−y, y(0) = 1
Use the classical fourth-order Runge-Kutta method with step size h= 0.1 to
estimate the value of y(0.5).
Solution
To apply the classical fourth-order Runge-Kutta method, we use 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),
where f(x, y) is the differential equation and (xn, yn) is the current value of x
and y.
Step 1: Calculate the estimates of yat x= 0.1, 0.2, 0.3, 0.4, and 0.5 using
the Runge-Kutta method.
xnk1k2k3k4yn+1
0.1
0.2
0.3
0.4
0.5
Step 2: Use the Runge-Kutta method to estimate y(0.5).
The completed table is as follows:
xnk1k2k3k4yn+1
0.1 -0.91 -0.6226 -0.7177 -0.4435 0.9873
0.2 -0.74 -0.5988 -0.5128 -0.1845 0.9364
0.3 -0.49 -0.5816 -0.3389 0.0828 0.9011
0.4 -0.18 -0.5664 -0.2073 0.2588 0.8841
0.5 0.11 - - - 0.88
Therefore, the estimate of y(0.5) using the classical fourth-order Runge-
Kutta method is 0.88.
31
Question 34
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
y(0.5). Show all your work and round your final answer to four decimal places.
Solution
To solve the initial value problem using the fourth-order Runge-Kutta method,
we will use 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.
Step 1: Initialize x0= 0, y0= 1, and h= 0.1. We want to find y(0.5).
Step 2: Calculate k1, k2, k3, k4using the formulas above.
k1= 0.1·f(0,1) = 0.1(02+ 1) = 0.1,
k2= 0.1·f(0 + 0.05,1 + 0.1
2)=0.1((0.05)2+ 1.05) ≈0.10263,
k3= 0.1·f(0 + 0.05,1 + 0.10263
2)=0.1((0.05)2+ 1.051315) ≈0.10295,
k4= 0.1·f(0.1,1+0.10295) = 0.1(0.12+ 1.10295) ≈0.1103.
Step 3: Compute the new value of yusing the weighted average of the four
slopes:
32
y1= 1 + 1
6(0.1 + 2(0.10263) + 2(0.10295) + 0.1103)
≈1 + 1
6(0.1 + 2(0.10263) + 2(0.10295) + 0.1103)
≈1 + 1
6(0.1+0.20526 + 0.2059 + 0.1103)
≈1 + 1
6(0.62146)
≈1.10358.
Therefore, the estimate of y(0.5) using the fourth-order Runge-Kutta method
with step size h= 0.1 is approximately 1.1036.
Question 35
Question
Consider the initial value problem y′= sin(x)−y,y(0) = 1. Use the fourth-order
Runge-Kutta method with step size h= 0.1 to approximate y(0.4).
Solution
We will use the fourth-order Runge-Kutta method to approximate the value of
y(0.4).
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)
where xnis the current value of x,ynis the current value of y, and his the
step size.
Step 1: Calculate the approximations using the fourth-order Runge-Kutta
method.
k1= 0.1(sin(0) −1) = −0.1
k2= 0.1(sin(0 + 0.05) −(1 −0.05(0.1/2))) = −0.0998844
k3= 0.1(sin(0 + 0.05) −(1 −0.05(0.0998844/2))) = −0.0997688
k4= 0.1(sin(0.1) −(1 −0.0997688)) = −0.0995301
y1= 1 + 1
6(−0.1 + 2(−0.0998844) + 2(−0.0997688) −0.0995301) ≈0.902
33
Using these values, we can calculate y(0.1):
y(0.1) = 1 + 1
6(0.1+2×0.105 + 2 ×0.11025 + 0.211025)
= 1 + 1
6(0.1+0.21 + 0.2205 + 0.211025)
= 1 + 1
6(0.741525)
= 1.123588.
Step 4: Repeat the process with x= 0.1 and y= 1.123588:
k1= 0.1·(0.12+ 1.123588) ≈0.11236,
k2= 0.1·0.1+1.123588 + 0.11236
2≈0.124476,
k3= 0.1·0.1+1.123588 + 0.124476
2≈0.136716,
k4= 0.1·(0.1+1.123588 + 0.136716) ≈0.136771.
Now, calculating y(0.2):
y(0.2) = 1.123588 + 1
6(0.11236 + 2 ×0.124476 + 2 ×0.136716 + 0.136771)
= 1.123588 + 1
6(0.808515)
≈1.256256.
Therefore, the approximate value of y(0.2) using the fourth-order Runge-
Kutta method is 1.2563.
Question 2
Question
Consider the initial value problem
(y′=−2y+ 4t
y(0) = 1
Use the classical fourth-order Runge-Kutta method to approximate y(0.2) with
a step size of h= 0.1.
2
Solution
Step 1: We first need to set up the fourth-order Runge-Kutta method. The
formulas for this method are:
k1=hf(tn, yn)
k2=hf(tn+ 0.5h, yn+ 0.5k1)
k3=hf(tn+ 0.5h, yn+ 0.5k2)
k4=hf(tn+h, yn+k3)
yn+1 =yn+1
6(k1+ 2k2+ 2k3+k4)
where f(t, y) = −2y+ 4t.
Step 2: We will apply the Runge-Kutta method with h= 0.1 to approximate
y(0.2).
k1= 0.1(−2·1+4·0) = 0
k2= 0.1(−2·1+4·0.05) = 0.3
k3= 0.1(−2·1+4·0.05) = 0.3
k4= 0.1(−2·1+4·0.1) = 0.2
y1= 1 + 1
6(0 + 2 ·0.3+2·0.3+0.2) = 1.05
Therefore, the approximation of y(0.2) using the fourth-order Runge-Kutta
method with step size h= 0.1 is y(0.2) ≈1.05.
Question 3
Question
Consider the initial value problem dy
dx =x2−y,y(0) = 1. Use the fourth-order
Runge-Kutta method to approximate y(1) with a step size of h= 0.1.
Solution
To approximate y(1) 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 step size h= 0.1 and the initial values x0= 0, y0= 1.
Step 3: Calculate the approximate values of yat each step using the fourth-
order Runge-Kutta method:
3
k1=h·f(x0, y0)=0.1·(02−1) = −0.1
k2=h·f(x0+h
2, y0+k1
2)=0.1·(0.052−0.05) = −0.00975
k3=h·f(x0+h
2, y0+k2
2)=0.1·(0.052−0.049375) = −0.009500625
k4=h·f(x0+h, y0+k3)=0.1·(0.12−0.058375) = −0.0038375
Step 4: Use the formula for the next approximation:
y1=y0+1
6(k1+2k2+2k3+k4) = 1+1
6(−0.1−2·0.00975−2·0.009500625−0.0038375) ≈0.89471
Therefore, the approximate value of y(1) using the fourth-order Runge-Kutta
method with a step size of h= 0.1 is 0.89471.
Question 4
Question
Use the fourth-order Runge-Kutta method to approximate the solution to the
initial value problem dy
dx =−2y+ 4x, y(0) = 1
over the interval [0,1] using a step size of h= 0.1.
Solution
The fourth-order Runge-Kutta method is given by 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+1
6(k1+ 2k2+ 2k3+k4),
where f(x, y) is the function in the initial value problem.
We will iterate from x= 0 to x= 1 with a step size of h= 0.1, calculating
the value of yat each step using the Runge-Kutta method.
Step 1: Initialize the variables. Let h= 0.1, x0= 0, y0= 1, and xf= 1.
4
Step 2: Calculate the approximations.
k1= 0.1(−2(1) + 4(0)) = −0.2,
k2= 0.1(−2(1 + 0.1/2) + 4(0 + 0.1/2)) = −0.19,
k3= 0.1(−2(1 + 0.1/2) + 4(0 −0.19/2)) = −0.17,
k4= 0.1(−2(1 + 0.1) + 4(0 −0.17)) = −0.15,
y1= 1 + 1
6(−0.2 + 2(−0.19) + 2(−0.17) −0.15) = 0.79.
Repeat this process for x= 0.1,0.2,0.3, ..., 1 until the value at x= 1 is
found.
Question 5
Question
Using the fourth-order Runge-Kutta method, approximate the solution of the
initial value problem dy
dx =x2−y, y(0) = 1,
at x= 0.1. Use a step size of h= 0.05.
Solution
To approximate the solution at x= 0.1 using the fourth-order Runge-Kutta
method, we will take several steps to update our estimate of y.
Step 1: Define the functions f(x, y) = x2−yand set the initial conditions
x0= 0, y0= 1, and h= 0.05.
Step 2: Calculate the four intermediate values 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 values of xand yat the current step.
Step 3: Compute the weighted average of the four slopes k1,k2,k3, and k4
to get the next approximation yn+1:
yn+1 =yn+1
6(k1+ 2k2+ 2k3+k4).
Step 4: Repeat steps 2 and 3 until you reach x= 0.1. Applying these steps
iteratively, we can find the approximate solution of the initial value problem at
x= 0.1.
5
Question 6
Question
Consider the initial value problem y′=x2−ywith initial condition y(0) = 1.
Use the Runge-Kutta method of order four to approximate y(1), using step size
h= 0.1.
Solution
To apply the Runge-Kutta method of order four, we will compute the values of
y(x) at discrete 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)
where f(x, y) = x2−yis the differential equation.
Using h= 0.1 and starting at x= 0, we will calculate the approximate value
of y(1).
Step 1: Calculate the values of k1, k2, k3,and k4at each step.
At x= 0:
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+1+2·(−0.00025)) = 0.09475
Step 2: Update yusing the weighted sum.
y1= 1 + 1
6(−0.1 + 2(−0.005) + 2(−0.00025) + 0.09475) = 0.94195833333
Question 7
Question
Consider the initial value problem dy
dx =x2−ywith initial condition y(0) = 1.
Use the fourth-order Runge-Kutta method to approximate y(1) with a step size
of h= 0.1.
6
Solution
To approximate the value of y(1) 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 up the fourth-order 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)
yn+1 =yn+1
6(k1+ 2k2+ 2k3+k4)
Step 3: Iterate through the given steps for n= 0,1,2, ..., 10 with h= 0.1:
-n= 0: - x0= 0 - y0= 1 - Calculate k1, k2, k3, k4using the above formulas -
Update y1using the formula: y1=y0+1
6(k1+ 2k2+ 2k3+k4) - Continue this
process until reaching n= 10
Step 4: After iterating through the steps, the approximated value of y(1)
using the fourth-order Runge-Kutta method with a step size of h= 0.1 will be
the value of yat x= 1 after 10 iterations.
Question 8
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
Given the initial value problem, we will use the fourth-order Runge-Kutta
method to approximate the value of y(1). The general formula for the fourth-
7
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 f(x, y) = x2−y.
Step 1: Calculate the values of k1,k2,k3, and k4.
k1= 0.2(02−1) = −0.2
k2= 0.20 + −0.2
22−(1 + −0.2
2) = 0.22
k3= 0.20 + 0.22
22−(1 + 0.22
2) = −0.2244
k4= 0.2 (0.2,1−0.2244)2−(1 −0.2244) = 0.09042
Step 2: Calculate the next approximation using the formula.
y1= 1 + 1
6(−0.2 + 2(0.22) + 2(−0.2244) + 0.09042)
= 1 + 1
6(0.12312)
= 1.02052.
Therefore, the fourth-order Runge-Kutta method gives us an approximation
of y(1) ≈1.02052.
Question 9
Question
Consider the initial value problem given by the differential equation
y′= 2y−x2, y(0) = 1,
and let h= 0.1. Use the fourth-order Runge-Kutta method to approximate
y(0.4).
8
Solution
To approximate y(0.4) using the fourth-order Runge-Kutta method, we will
iteratively calculate the values of yiat each step.
Step 1: Calculate k1,k2,k3, and k4for each iteration using the formulas:
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)
Step 2: Update yiusing the formula:
yi+1 =yi+1
6(k1+ 2k2+ 2k3+k4)
Step 3: Repeat these steps until xi= 0.4.
Now, let’s begin with the calculations:
Step 1: At x= 0, we have y= 1.
k1= 0.1(2(1) −02)=0.2
k2= 0.1(2(1 + 0.05) −(0 + 0.05)2)=0.209375
k3= 0.1(2(1 + 0.05) −(0 + 0.05)2)=0.209375
k4= 0.1(2(1 + 0.1) −(0 + 0.1)2)=0.218
Step 2:
y1= 1 + 1
6(0.2 + 2(0.209375) + 2(0.209375) + 0.218) = 1.016042
Now continue these calculations iteratively until we reach x= 0.4.
Question 10
Question
Consider the following initial value problem:
dy
dt =t−y, y(0) = 1
Approximate the value of y(0.1) using the fourth-order Runge-Kutta method
with h= 0.05.
9
Solution
Let’s denote f(t, y) = t−y. Using the formula for the fourth-order Runge-Kutta
method: k1=hf(tn, yn)
k2=hf(tn+ 0.5h, yn+ 0.5k1)
k3=hf(tn+ 0.5h, yn+ 0.5k2)
k4=hf(tn+h, yn+k3)
yn+1 =yn+1
6(k1+ 2k2+ 2k3+k4)
Step 1: Calculate y(0.05)
k1= 0.05(0 −1) = −0.05
k2= 0.05 (0 + 0.5(0.05)(−0.05)) = −0.0625
k3= 0.05 (0 + 0.5(0.05)(−0.0625)) = −0.065625
k4= 0.05 (0.05,−0.065625) = −0.06015625
y(0.05) = 1 + 1
6(−0.05 + 2(−0.0625) + 2(−0.065625) −0.06015625) ≈0.920859375
Step 2: Calculate y(0.1)
k1= 0.05(0.05 −0.920859375) ≈ −0.04390703125
k2= 0.05 (0.05 + 0.5(0.05)(−0.04390703125)) ≈ −0.048261538089
k3= 0.05 (0.05 + 0.5(0.05)(−0.048261538089)) ≈ −0.051143131755
k4= 0.05 (0.1,−0.051143131755) ≈ −0.046263126158
y(0.1) ≈0.920859375 + 1
6(−0.04390703125 + 2(−0.048261538089) + 2(−0.051143131755) −0.046263126158) ≈0.871068758692
Therefore, y(0.1) ≈0.8711.
Question 11
Question
Use the fourth-order Runge-Kutta method to approximate the solution to the
initial value problem
dy
dx =y−x2+ 1, y(0) = 0,
over the interval x∈[0,1]. Use a step size of h= 0.1.
10
Solution
To apply the fourth-order Runge-Kutta method, we first need to define 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) = y−x2+ 1.
Step 1: Initialize the problem by defining the step size h, the number of
steps N, and the initial conditions.
h= 0.1,
N=1−0
h= 10,
y0= 0.
Step 2: Use the formulas to approximate the solution.
For n= 0 :
k1= 0.1(0 −02+ 1) = 0.1,
k2= 0.10 + 0.1
2= 0.05,
k3= 0.10 + 0.05
2= 0.025,
k4= 0.1(0.025 −(0.1)2+ 1) = 0.11125,
y1= 0 + 1
6(0.1 + 2(0.05) + 2(0.025) + 0.11125) = 0.052083.
Continue this process for n= 1,2,...,10 to approximate the solution over
the interval x∈[0,1].
Question 12
Question
Consider the following initial value problem:
dy
dx =x2−y, y(0) = 1
Use the fourth-order Runge-Kutta method with step size 0.1 to approximate
the value of yat x= 0.4.
11
Solution
Step 1: Define f(x, y) = x2−yand the step size h= 0.1.
Step 2: Calculate the four increments:
k1=h·f(x, y)=0.1·(02−1) = −0.1
k2=h·f(x+h
2, y +k1
2)=0.1·(0.052−(1 + 0.05(−0.1))) ≈ −0.097375
k3=h·f(x+h
2, y +k2
2)=0.1·(0.052−(1 + 0.05(−0.097375))) ≈ −0.09578062
k4=h·f(x+h, y +k3)=0.1·(0.12−(1 + 0.1(−0.09578062))) ≈ −0.090437959
Step 3: Compute the new value of yusing the weighted sum:
y1=y+1
6(k1+ 2k2+ 2k3+k4)
= 1 + 1
6(−0.1 + 2(−0.097375) + 2(−0.09578062) −0.090437959)
≈0.904303933
Therefore, the approximate value of yat x= 0.4 using the fourth-order
Runge-Kutta method with step size 0.1 is y≈0.904303933.
Question 13
Question
Consider the initial value problem:
dy
dx =x2−y, y(0) = 1.
Use the classical fourth-order Runge-Kutta method with step size h= 0.2
to approximate y(0.4).
Solution
We will approximate the value of y(0.4) using the classical fourth-order Runge-
Kutta method with step size h= 0.2.
Step 1: Initialize the values and setup the formula for Runge-Kutta method.
Let y0= 1, x0= 0, and h= 0.2. Then, we have:
k1=h·f(x0, y0)=0.2·((0)2−1) = −0.2
k2=h·f(x0+h
2, y0+k1
2) = 0.2·((0.1)2−(1 −0.1(0.2))) = −0.18
k3=h·f(x0+h
2, y0+k2
2) = 0.2·((0.1)2−(1 −0.1(0.18))) = −0.1762
12
k4=h·f(x0+h, y0+k3) = 0.2·((0.2)2−(1 −0.1762)) = −0.1617
Step 2: Calculate the approximate value of y(0.4).
y1=y0+1
6(k1+ 2k2+ 2k3+k4)
y1= 1 + 1
6(−0.2−2(0.18) −2(0.1762) −0.1617)
y1≈0.8268
Therefore, the approximate value of y(0.4) using the classical fourth-order
Runge-Kutta method with step size h= 0.2 is approximately 0.8268.
Question 14
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.2 to estimate
y(0.4). Show all your steps.
Solution
Step 1: We first compute the increments using the Runge-Kutta formulas:
k1=h·f(x0, y0)=0.2·(02+ 1) = 0.2
k2=h·f(x0+h
2, y0+k1
2)=0.2·(0.12+ 1 + 0.1·0.2/2) ≈0.201
k3=h·f(x0+h
2, y0+k2
2)=0.2·(0.12+ 1 + 0.1·0.201/2) ≈0.202
k4=h·f(x0+h, y0+k3)=0.2·(0.22+ 1 + 0.2·0.202) ≈0.208
Step 2: Next, we use the increments to compute the estimate of y(0.4):
y(0.4) ≈y0+1
6(k1+ 2k2+ 2k3+k4)
≈1 + 1
6(0.2+2·0.201 + 2 ·0.202 + 0.208)
≈1 + 1
6(0.2+0.402 + 0.404 + 0.208)
≈1 + 1
6·1.214
≈1.202
Therefore, the approximate value of y(0.4) using the fourth-order Runge-
Kutta method is 1.202.
13
Question 15
Question
Consider the differential equation dy
dx =x2−ywith initial condition y(0) = 1.
Use the fourth-order Runge-Kutta method to approximate the value of y(1)
using a step size of h= 0.1.
Solution
To approximate the value of y(1) using the fourth-order Runge-Kutta method,
we will follow these steps:
Step 1: Define the function f(x, y) = x2−y.
Step 2: Calculate the increments k1,k2,k3, and k4using 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)
Step 3: Update the values of xand yusing the weighted average of the
increments:
yn+1 =yn+1
6(k1+ 2k2+ 2k3+k4)
Step 4: Repeat steps 2 and 3 for n= 0,1,2, ..., 10 until x= 1.
Now, let’s compute the solution using the fourth-order Runge-Kutta method
with a step size of h= 0.1.
Step 1: Define the function f(x, y) = x2−y.
Step 2: Calculate the increments k1,k2,k3, and k4:
At x= 0: k1= 0.1(02−1) = −0.1
k2= 0.10 + 0.1
2,1 + −0.1
2= 0.405
k3= 0.10 + 0.1
2,1 + 0.405
2= 0.404875
k4= 0.1 (0 + 0.1,1+0.404875) = 0.5404875
Step 3: Update the values of xand y:
y1= 1 + 1
6(−0.1 + 2(0.405) + 2(0.404875) + 0.5404875) = 1.11735625
Continue these calculations until x= 1 to find the approximate value of
y(1).
14
Question 16
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] using a step size of h= 0.1. Show all your calculations
to at least 4 decimal places.
Solution
To approximate the solution using the fourth-order Runge-Kutta method, we
will follow these steps:
Step 1: Determine the number of subintervals Given that the interval
is [0,0.4] and the step size is h= 0.1, the number of subintervals is:
n=0.4−0
0.1= 4
Step 2: Initialize variables Let us set x0= 0 and y0= 1. Also, set
h= 0.1 and n= 4.
Step 3: Calculate the approximate values Using the fourth-order
Runge-Kutta method, calculate the approximate values of yat each iteration
as follows:
Step x k1k2k3k4
1 0.0 - - - -
2 0.1 - - - -
3 0.2 - - - -
4 0.3 - - - -
5 0.4 - - - -
Now, let’s calculate the values for each step:
Step 1: At x= 0, we have:
k1= 02+ 12= 1
k2= (0 + 0.05)2+ (1 + 0.05 ·1)2= 0.0025 + 1.1025 = 1.105
k3= (0 + 0.05)2+ (1 + 0.05 ·1.105)2= 0.0025 + 1.2175 = 1.22
k4= (0 + 0.1)2+ (1 + 0.1·1.22)2= 0.01 + 1.5884 = 1.5984
Thus, at x= 0.1:
y1= 1 + 0.1
6(1 + 2(1.105) + 2(1.22) + 1.5984) = 1.22073
Step 2: Repeat the procedure for the next steps.
Step 3: Continue the process until x= 0.4, and calculate the final approx-
imation of the solution.
15
Question 17
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.2. Use a step size of h= 0.1.
Solution
To approximate the solution using the fourth-order Runge-Kutta method, we
will follow these steps: Let h= 0.1 and xi= 0, yi= 1. Then we have: Step 1:
Calculate k1,k2,k3, and k4. Step 2: Update the values of xand yusing the
weighted sum of the four slopes. Step 3: Repeat until x= 0.2.
Step 1: We have
k1=h·f(xi, yi)=0.1·(02+ 1) = 0.1
k2=h·f(xi+ 0.5h, yi+ 0.5k1)=0.1·(0.052+ 1.05) = 0.10625
k3=h·f(xi+ 0.5h, yi+ 0.5k2)=0.1·(0.052+ 1.053125) = 0.1065625
k4=h·f(xi+h, yi+k3)=0.1·(0.12+ 1.15914375) = 0.115914375
Step 2: Now we calculate the weighted sum of the slopes:
yi+1 =yi+1
6(k1+2k2+2k3+k4) = 1+1
6(0.1+2·0.10625+2·0.1065625+0.115914375) = 1.0239984375
Step 3: Since x= 0.2 is not reached in one step, we need to repeat the
process with updated values of xand yuntil x= 0.2.
Therefore, the approximate value of yat x= 0.2 is y≈1.0239984375.
Question 18
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] with a step size of h= 0.1.
16
Solution
To use the fourth-order Runge-Kutta method, we will follow these steps at each
iteration: 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 f(x, y) = x2+y.
Step 1: Initialize the values x0= 0, y0= 1, and the step size h= 0.1.
Step 2: Using the Runge-Kutta formula, calculate the values of k1,k2,k3,
and k4at each step.
k1= 0.1·(02+ 1) = 0.1
k2= 0.1·(0 + 0.1
2)2+ (1 + 0.1
2= 0.10505
k3= 0.1·(0 + 0.1
2)2+ (1 + 0.10505
2= 0.1103460038
k4= 0.1·((0 + 0.1)2+ (1 + 0.1103460038)) = 0.1159310038
Step 3: Update the values of xand yusing the weighted average of k1,k2,
k3, and k4.
x1= 0 + 0.1 = 0.1
y1= 1 + 1
6(0.1 + 2(0.10505 + 0.1103460038) + 0.1159310038) ≈1.1163334606
Step 4: Repeat Steps 2 and 3 until the end of the interval.
Continue these steps until you reach the end of the interval, x= 1, to
approximate the solution using the fourth-order Runge-Kutta method.
Question 19
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 ≤x≤1 with
step size h= 0.1.
Solution
To apply the fourth-order Runge-Kutta method, we need to follow the steps
outlined below:
17
Step 1: Define the differential equation and initial condition: The given
initial value problem is dy
dx =x2+y2,y(0) = 1.
Step 2: Determine the number of subintervals: The interval [0,1] with step
size h= 0.1 gives us 10 subintervals.
Step 3: Set up the algorithm for the fourth-order Runge-Kutta method:
The fourth-order Runge-Kutta method is given by the following equations:
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+y2.
Step 4: Perform the calculations for each subinterval: Starting with y0= 1,
we will calculate y1, y2, . . . , y10 using the Runge-Kutta method.
Step 5: Calculate the approximate solution: After completing calculations
for all subintervals, we obtain the approximations y1, y2, . . . , y10.
Step 6: Present the final approximate solution: The final approximate
solution to the initial value problem dy
dx =x2+y2,y(0) = 1 over the interval
0≤x≤1 with step size h= 0.1 is given by the values of y1, y2, . . . , y10.
Question 20
Question
Use the Runge-Kutta method to approximate the solution to the initial value
problem dy
dx =x2−y, y(0) = 1
over the interval [0,1] using four steps. Use step size h= 0.25.
Solution
To approximate the solution to the initial value problem using the fourth-order
Runge-Kutta method, we will follow these steps: Let h= 0.25 so that we take
four steps over the interval [0,1].
Step 1: Calculate y1using the formula
k1=h·f(x0, y0)=0.25 ·((0)2−1) = −0.25
k2=h·f(x0+ 0.5h, y0+ 0.5k1) = 0.25 ·((0.25)2−1+0.5(−0.25)) = −0.21875
k3=h·f(x0+0.5h, y0+0.5k2)=0.25·((0.25)2−1+0.5(−0.21875)) = −0.22167969
18
k4=h·f(x0+h, y0+k3)=0.25 ·((0.5)2−1 + (−0.22167969)) = −0.18286133
y1=y0+1
6(k1+2k2+2k3+k4) = 1+1
6(−0.25+2(−0.21875)+2(−0.22167969)−0.18286133) ≈0.85561
Step 2: Calculate y2using the formula Proceeding in a similar manner as
above we find y2≈0.73284.
Step 3: Calculate y3using the formula Similarly, we find y3≈0.63831.
Step 4: Calculate y4using the formula Finally, we find y4≈0.56382.
Therefore, the approximate solution to the initial value problem over the
interval [0,1] using four steps with step size h= 0.25 is y(1) ≈0.56382.
Question 21
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 ≤x≤1 using a step size of h= 0.1.
Solution
To apply the fourth-order Runge-Kutta method to the given initial value prob-
lem, we will use the following iterative 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: Set up the table for the iterative calculations.
19
n xnynk1k2k3
k4yn+1
0 0 1
1
2
3
4
Step 2: Fill in the table using the Runge-Kutta formulas.
For n= 0:
k1= 0.1(02−1) = −0.1,
k2= 0.1(0 + 0.05)2−(1 −0.05)=−0.0975,
k3= 0.1(0 + 0.05)2−(1 −0.0975/2)=−0.09581,
k4= 0.1(0 + 0.1)2−(1 −0.09581)=−0.09401,
yn+1 = 1 + 1
6(−0.1 + 2(−0.0975) + 2(−0.09581) −0.09401) = 0.904215.
Continue this process for n= 1,2,3,4 until n= 10.
Step 3: Compute the approximate solution for the given initial value prob-
lem.
After completing the table, you should obtain the approximation of y(1) as
0.249985 using the fourth-order Runge-Kutta method.
Question 22
Question
Consider the Initial Value Problem (IVP) given by:
dy
dx =x2−y2, y(0) = 1
Apply the classical fourth-order Runge-Kutta method to approximate y(0.5)
with a step size of h= 0.1.
Solution
Given an Initial Value Problem (IVP) by
dy
dx =x2−y2, y(0) = 1
20
we want to approximate the value of y(0.5) using the classical fourth-order
Runge-Kutta method with a step size of h= 0.1.
Step 1: Define the function f(x, y) = x2−y2.
Step 2: Using the fourth-order Runge-Kutta method, we have the following
iteration 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 3: Using the initial condition y(0) = 1, we can start the iteration.
Step 4: Now, we compute the values of yat each iteration.
n xnynk1k2
k3k4yn+1
0 0 1 . . . . . .
. . . . . . . . .
1 0.1. . . . . . . . .
. . . . . . . . .
2 0.2. . . . . . . . .
. . . . . . . . .
3 0.3. . . . . . . . .
. . . . . . . . .
4 0.4. . . . . . . . .
. . . . . . . . .
5 0.5. . . . . . . . .
. . . . . . . . .
By completing the table above, we can approximate y(0.5).
Question 23
Question
Consider the initial value problem:
dy
dx =x2−y, y(0) = 1
Use the fourth-order Runge-Kutta method to estimate y(1) by taking steps of
size h= 0.1.
21
Solution
The fourth-order Runge-Kutta method is given by 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)
yn+1 =yn+1
6(k1+ 2k2+ 2k3+k4)
Step 1: Define the function f(x, y) = x2−y.
Step 2: Set the initial values x0= 0 and y0= 1.
Step 3: Calculate the values using the fourth-order Runge-Kutta method:
k1= 0.1·(02−1) = −0.1
k2= 0.1·0 + 0.1
2−1 + −0.1
2=−0.0975
k3= 0.1·0 + 0.1
2−1 + −0.0975
2=−0.095
k4= 0.1·(0.1−0.095) = 0.0005
y1= 1 + 1
6(−0.1 + 2(−0.0975) + 2(−0.095) + 0.0005) = 0.900083
Therefore, the estimated value of y(1) using the fourth-order Runge-Kutta
method with step size h= 0.1 is approximately 0.900083.
Question 24
Question
Consider the initial value problem:
dy
dx =x2−y, y(0) = 1
Use the classical fourth-order Runge-Kutta method with step size h= 0.2 to
estimate y(0.8).
Solution
Let’s denote f(x, y) = x2−y. The classical fourth-order Runge-Kutta method
can be implemented using the following formulae:
k1=hf(xn, yn)
22
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)
Applying these formulae with x0= 0 and y0= 1, and with h= 0.2, we get:
Step 1:
k1= 0.2(02−1) = −0.2
k2= 0.2(0.12−1 + −0.2
2) = −0.194
k3= 0.2(0.12−1 + −0.194
2) = −0.1862
k4= 0.2(0.22−1 + −0.1862) = −0.1708
y1= 1 + 1
6(−0.2 + 2(−0.194) + 2(−0.1862) −0.1708) = 0.8561
So, the estimated value of y(0.2) using the fourth-order Runge-Kutta method
is approximately 0.8561.
Question 25
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 ≤x≤1 with a step size h= 0.1.
Solution
To apply the fourth-order Runge-Kutta method, we calculate the values of yi
at each step using the formula:
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),
yi+1 =yi+1
6(k1+ 2k2+ 2k3+k4),
23
where f(x, y) = x2−y2.
Step 1: For i= 0, we have x0= 0 and y0= 1.
Step 2: Using the formula above, we can calculate k1,k2,k3, and k4to find
y1:
k1= 0.1(02−12) = −0.1,
k2= 0.1(0 + 0.1
2)2−(1 −0.1
2)2=−0.10125,
k3= 0.1(0 + 0.1
2)2−(1 −0.10125
2)2=−0.102500625,
k4= 0.1(0 + 0.1)2−(1 −0.102500625)2=−0.103781628197875,
y1= 1 + 1
6(−0.1 + 2(−0.10125) + 2(−0.102500625) −0.103781628197875) = 0.840222984805.
Repeating this process for i= 1,2, ..., 10, we can approximate the solution
over the interval 0 ≤x≤1 with a step size of h= 0.1.
Question 26
Question
Consider the following initial value problem:
(y′=y−t2+ 1
y(0) = 0
Use the fourth-order Runge-Kutta method to estimate y(0.1) with step size
h= 0.02.
Solution
Step 1: Define the function f(t, y) based on the differential equation y′=y−
t2+ 1:
f(t, y) = y−t2+ 1
Step 2: Implement the fourth-order Runge-Kutta method with step size
h= 0.02 to approximate y(0.1).
k1=hf(t0, y0)=0.02f(0,0) = 0.02(0 −02+ 1) = 0.02
k2=hf(t0+h
2, y0+k1
2)=0.02f0 + 0.02
2,0 + 0.02
2= 0.02f(0.01,0.01) = 0.02(0.01 −0.012+ 1) = 0.0201
k3=hf(t0+h
2, y0+k2
2)=0.02f0 + 0.02
2,0 + 0.0201
2= 0.02f(0.01,0.01005) = 0.02(0.01005 −0.012+ 1) = 0.02010025
k4=hf(t0+h, y0+k3)=0.02f(0 + 0.02,0.02010025) = 0.02(0.02010025 −0.022+ 1) = 0.02010050004
y1=y0+1
6(k1+ 2k2+ 2k3+k4) = 0 + 1
6(0.02 + 2(0.0201) + 2(0.02010025) + 0.02010050004) ≈0.02010133834
24
Therefore, using the fourth-order Runge-Kutta method, the approximation
for y(0.1) is approximately 0.0201.
Question 27
Question
Consider the initial value problem:
(y′=y−t2+ 1
y(0) = 0
Use the fourth-order Runge-Kutta method to approximate y(1) with step size
h= 0.1.
Solution
Step 1: We first need to compute the increments k1,k2,k3, and k4using the
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)
where f(t, y) = y−t2+ 1.
Step 2: Now we apply the formula for updating y:
yn+1 =yn+1
6(k1+ 2k2+ 2k3+k4)
Step 3: Now, let’s calculate the approximate value of y(1) using the given
initial condition and step size.
Step 4: Let’s start the calculations:
k1= 0.1(0 −(0)2+ 1) = 0.1
k2= 0.1(0 −(0 + 0.1/2)2+ 1) = 0.1(0 −0.0025 + 1) = 0.09975
k3= 0.1(0 −(0 + 0.1/2)2+ 1) = 0.1(0 −0.0025 + 1) = 0.09975
k4= 0.1(0 −0.12+ 1) = 0.1(0 −0.01 + 1) = 0.099
Step 5: Now, let’s update the value of y:
y1= 0 + 1
6(0.1 + 2(0.09975) + 2(0.09975) + 0.099)
y1= 0.015975
Therefore, the approximate value of y(1) using the fourth-order Runge-Kutta
method with step size h= 0.1 is 0.015975.
25
Question 28
Question
Consider the initial value problem given by the ordinary differential equation:
dy
dt =t2−ywith y(0) = 1
Use the fourth-order Runge-Kutta method with step size h= 0.1 to estimate
y(0.4).
Solution
Step 1: Define the differential equation and the Runge-Kutta method.
dy
dt =t2−y, y(0) = 1
The fourth-order Runge-Kutta method is given by the formulas:
k1=h·f(tn, yn)
k2=h·f(tn+h
2, yn+k1
2)
k3=h·f(tn+h
2, yn+k2
2)
k4=h·f(tn+h, yn+k3)
yn+1 =yn+1
6(k1+ 2k2+ 2k3+k4)
where his the step size.
Step 2: Implement the Runge-Kutta method to estimate y(0.4).
h= 0.1
t0= 0, y0= 1
t1=t0+h= 0.1, y1=y0+1
6(k1+ 2k2+ 2k3+k4)
First, calculate k1,k2,k3, and k4:
k1= 0.1·(02−1) = −0.1
k2= 0.1·0.12−1−0.1·0.1
2=−0.0825
k3= 0.1·0.12−1−0.1·0.0825
2=−0.065625
k4= 0.1·0.12−(1 −0.1·(−0.065625))=−0.04845625
26
Now, calculate y1:
y1= 1 + 1
6(−0.1 + 2(−0.0825) + 2(−0.065625) −0.04845625) ≈0.92638
Therefore, the estimated value of y(0.4) using the fourth-order Runge-Kutta
method with a step size of h= 0.1 is approximately 0.92638.
Question 29
Question
Consider the initial value problem:
y′= (t−y2), y(0) = 1
Use the fourth-order Runge-Kutta method to approximate the value of y(1)
with 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)
Substitute the given values into the formulas and perform the calculations
for each iteration:
Step 1: Calculate k1:
k1= 0.2((0) −(1)2) = −0.2
Step 2: Calculate k2:
k2= 0.2((0 + 0.2
2)−(1 −0.2
2)2) = −0.18
Step 3: Calculate k3:
k3= 0.2((0 + 0.2
2)−(1 −0.18
2)2) = −0.162
27
Step 4: Calculate k4:
k4= 0.2((0 + 0.2) −(1 −0.162)2) = −0.486
Step 5: Calculate yn+1:
yn+1 = 1 + 1
6(−0.2 + 2(−0.18) + 2(−0.162) −0.486) = 0.8836
Therefore, using the fourth-order Runge-Kutta method with a step size of
0.2, the approximate value of y(1) is 0.8836.
Question 30
Question
Consider the initial value problem:
dy
dx =x2−y, y(0) = 1
Use the classical fourth-order Runge-Kutta method with step size h= 0.2 to
estimate the value of y(1).
Solution
To approximate the value of y(1) using the classical fourth-order Runge-Kutta
method, we will first calculate the values of yat each step.
Let yndenote the approximate value of yat x=xn, where xn=x0+nh.
The Runge-Kutta method involves the following steps for each iteration:
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−y.
Now, we will apply the Runge-Kutta method with step size h= 0.2 to
estimate y(1):
n xnynk1k2k3
0 0 1
1 0.2
2 0.4
3 0.6
4 0.8
5 1.0
28
Step 1: Calculate k1,k2,k3, and k4at each step.
At x= 0, y= 1:
k1=hf(x0, y0) = 0.2(02−1) = −0.2
Step 2: Repeat the process for yn+1 at each step until x= 1 is reached and
calculate the final approximation y(1).
Continue this process for k2,k3, and k4at each step until x= 1 is reached.
Finally, calculate y(1) using the formula:
yn+1 =yn+1
6(k1+ 2k2+ 2k3+k4)
Question 31
Question
Consider the initial value problem:
dy
dx =x2+y2, y(0) = 0,
and use the Runge-Kutta method with step size h= 0.1 to approximate y(0.5).
Solution
To approximate y(0.5) using the Runge-Kutta method, we will perform the
following steps:
Step 1: Define the increments k1,k2,k3, and k4as follows:
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.
Step 2: Update the values of xand y:
xn+1 =xn+h,
yn+1 =yn+1
6(k1+ 2k2+ 2k3+k4).
Step 3: Apply the above steps iteratively until we reach x= 0.5.
Now, let’s calculate the approximation of y(0.5) using the Runge-Kutta
method:
29
Step 1: Calculate the increments
k1= 0.1·(02+ 02)=0,
k2= 0.1· 0 + 0.1
22
+0 + 0
22!= 0.0005,
k3= 0.1· 0 + 0.1
22
+0 + 0.0005
22!≈0.0005000125,
k4= 0.1·(0.1+0.0005000125)2≈0.0001025.
Step 2: Update
y1= 0 + 1
6(0 + 2(0.0005) + 2(0.0005000125) + 0.0001025) ≈0.0002675.
Since x= 0.5 has not been reached, we would need to iterate the process
further to obtain the approximation of y(0.5).
Question 32
Question
Consider the initial value problem
y′=−2y+ 4t, y(0) = 1.
Use the fourth-order Runge-Kutta method with step size h= 0.2 to approximate
y(1).
Solution
Given the initial value problem, we will approximate the solution using the
fourth-order Runge-Kutta method with step size h= 0.2.
Let t0= 0 be the initial point, and t1= 0.2 be the next point where we want
to estimate y(t).
Step 1: Calculate the four slopes k1,k2,k3, and k4.
k1=f(t0, y0) = −2(1) + 4(0) = −2,
k2=f(t0+h
2, y0+h
2k1) = −2(1 + 0.1× −2) + 4(0.1) = −1.8,
k3=f(t0+h
2, y0+h
2k2) = −2(1 + 0.1× −1.8) + 4(0.1) = −1.64,
k4=f(t0+h, y0+hk3) = −2(1 + 0.2× −1.64) + 4(0.2) = −1.296.
Step 2: Use the weighted average of these slopes to find y1.
y1=y0+h
6(k1+2k2+2k3+k4) = 1+0.2×1
6(−2+2(−1.8)+2(−1.64)−1.296) = 0.757.
Therefore, the fourth-order Runge-Kutta approximation of y(0.2) is y(0.2) ≈
0.757.
30
Question 33
Question
Consider the initial value problem
dy
dx =x2−y, y(0) = 1
Use the classical fourth-order Runge-Kutta method with step size h= 0.1 to
estimate the value of y(0.5).
Solution
To apply the classical fourth-order Runge-Kutta method, we use 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),
where f(x, y) is the differential equation and (xn, yn) is the current value of x
and y.
Step 1: Calculate the estimates of yat x= 0.1, 0.2, 0.3, 0.4, and 0.5 using
the Runge-Kutta method.
xnk1k2k3k4yn+1
0.1
0.2
0.3
0.4
0.5
Step 2: Use the Runge-Kutta method to estimate y(0.5).
The completed table is as follows:
xnk1k2k3k4yn+1
0.1 -0.91 -0.6226 -0.7177 -0.4435 0.9873
0.2 -0.74 -0.5988 -0.5128 -0.1845 0.9364
0.3 -0.49 -0.5816 -0.3389 0.0828 0.9011
0.4 -0.18 -0.5664 -0.2073 0.2588 0.8841
0.5 0.11 - - - 0.88
Therefore, the estimate of y(0.5) using the classical fourth-order Runge-
Kutta method is 0.88.
31
Question 34
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
y(0.5). Show all your work and round your final answer to four decimal places.
Solution
To solve the initial value problem using the fourth-order Runge-Kutta method,
we will use 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.
Step 1: Initialize x0= 0, y0= 1, and h= 0.1. We want to find y(0.5).
Step 2: Calculate k1, k2, k3, k4using the formulas above.
k1= 0.1·f(0,1) = 0.1(02+ 1) = 0.1,
k2= 0.1·f(0 + 0.05,1 + 0.1
2)=0.1((0.05)2+ 1.05) ≈0.10263,
k3= 0.1·f(0 + 0.05,1 + 0.10263
2)=0.1((0.05)2+ 1.051315) ≈0.10295,
k4= 0.1·f(0.1,1+0.10295) = 0.1(0.12+ 1.10295) ≈0.1103.
Step 3: Compute the new value of yusing the weighted average of the four
slopes:
32
y1= 1 + 1
6(0.1 + 2(0.10263) + 2(0.10295) + 0.1103)
≈1 + 1
6(0.1 + 2(0.10263) + 2(0.10295) + 0.1103)
≈1 + 1
6(0.1+0.20526 + 0.2059 + 0.1103)
≈1 + 1
6(0.62146)
≈1.10358.
Therefore, the estimate of y(0.5) using the fourth-order Runge-Kutta method
with step size h= 0.1 is approximately 1.1036.
Question 35
Question
Consider the initial value problem y′= sin(x)−y,y(0) = 1. Use the fourth-order
Runge-Kutta method with step size h= 0.1 to approximate y(0.4).
Solution
We will use the fourth-order Runge-Kutta method to approximate the value of
y(0.4).
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)
where xnis the current value of x,ynis the current value of y, and his the
step size.
Step 1: Calculate the approximations using the fourth-order Runge-Kutta
method.
k1= 0.1(sin(0) −1) = −0.1
k2= 0.1(sin(0 + 0.05) −(1 −0.05(0.1/2))) = −0.0998844
k3= 0.1(sin(0 + 0.05) −(1 −0.05(0.0998844/2))) = −0.0997688
k4= 0.1(sin(0.1) −(1 −0.0997688)) = −0.0995301
y1= 1 + 1
6(−0.1 + 2(−0.0998844) + 2(−0.0997688) −0.0995301) ≈0.902
33
Therefore, the approximation of y(0.1) using the fourth-order Runge-Kutta
method is 0.902.
34