Week 11 July 2023
Week 11 July 2023
Solution: (d) The differential equation, step size and the initial value of y are required to solve differential
equation using Runge-Kutta method.
a) 12.78
b) 13.08
c) 14.12
d) 11.36
Solution: (b)
2
𝑥 − 𝑥𝑗 (7 − 10)(7 − 15) 24
𝐿0 (𝑥) = ∏ = = = 0.48
𝑥0 − 𝑥𝑗 (5 − 10)(5 − 15) 50
𝑗=0
𝑗≠0
2
𝑥 − 𝑥𝑗 (7 − 5)(7 − 15) −16
𝐿1 (𝑥) = ∏ = = = 0.64
𝑥1 − 𝑥𝑗 (10 − 5)(10 − 15) −25
𝑗=0
𝑗≠1
2
𝑥 − 𝑥𝑗 (7 − 5)(7 − 10) −6
𝐿2 (𝑥) = ∏ = = = −0.12
𝑥1 − 𝑥𝑗 (15 − 5)(15 − 10) 50
𝑗=0
𝑗≠2
So 𝑓(7) = 0.48 ∗ 15.35 + 0.64 ∗ 9.63 − 0.12 ∗ 3.74 = 13.08
3.2
4. The value of ∫0 𝑥𝑒 𝑥 𝑑𝑥 by using one segment trapezoidal rule is
a) 172.7
b) 125.6
c) 136.2
d) 142.8
Solution: (b)
𝑏
𝑓(𝑏) − 𝑓(𝑎)
∫ 𝑓(𝑥)𝑑𝑥 = (𝑏 − 𝑎)
𝑎 2
Week 11 Assignment Solution
3.2
Here, 𝑎 = 0, 𝑏 = 3.2, 𝑓(𝑎) = 0 and 𝑓(𝑏) = 78.5. Hence, ∫0 𝑥𝑒 𝑥 𝑑𝑥 = 125.6
Solution: (c)Approximation increases with the increase of the number of segments between the lower and upper
limit.
6. Solve the ordinary differential equation below using Runge-Kutta4th order method.
Step size h=0.2.
𝑑𝑦
5 + 𝑥𝑦 3 = cos(𝑥) , 𝑦(0) = 3
𝑑𝑥
The value of y(0.2) is (upto two decimal points)
a) 2.86
b) 2.93
c) 3.13
d) 3.08
Solution: (b)
Solution: (a)
3
8. The value of ∫1 ex (ln 𝑥) dx calculated using the Trapezoidal rule with five subintervals is (* range
is given in output rather than single value to avoid approximation error)
a) 12.56 to 12.92
b) 13.12 to 13.66
c) 14.24 to 14.58
d) 15.13 to 15.45
a) 9
b) 8
c) 5
d) 2
Solution: (d) 2
func(513, 2) will return 1 + func(256, 2). All subsequent recursive calls (including func(256, 2)) will return
0 + func(n/2, 2) except the last call func(1, 2) . The last call func(1, 2) returns 1. So, the value returned by
func(513, 2) is 1 + 0 + 0…. + 0 + 1=2.
10. What is the output?
#include <stdio.h>
int fun(int n)
{
if (n == 4)
return n;
else return 2*fun(n+1);
}
int main()
{
printf("%d ", fun(2));
return 0;
}
a) 4
b) 8
c) 16
d) Error
Solution: (c) 16