ASSIGNMENT SOLUTION WEEK 11
1. Interpolation is a process for
a) extracting feasible data set from a given set of data
b) finding a value between two points on a line or curve.
c) removing unnecessary points from a curve
d) all of the mentioned
Solution: (b) Interpolation is the process of finding a value between two points on a line or
curve.
2. Given two data points (𝑎, 𝑓(𝑎)) and (𝑏, 𝑓(𝑏)), the linear Lagrange polynomial 𝑓(𝑥) that
passes through these two points are given as
𝑥−𝑏 𝑥−𝑎
a) 𝑓(𝑥) = 𝑎−𝑏 𝑓(𝑎) + 𝑎−𝑏 𝑓(𝑏)
𝑥 𝑥
b) 𝑓(𝑥) = 𝑎−𝑏 𝑓(𝑎) + 𝑏−𝑎 𝑓(𝑏)
𝑓(𝑏)−𝑓(𝑎)
c) 𝑓(𝑥) = 𝑓(𝑎) + 𝑓(𝑏)
𝑏−𝑎
𝑥−𝑏 𝑥−𝑎
d) 𝑓(𝑥) = 𝑎−𝑏 𝑓(𝑎) + 𝑏−𝑎 𝑓(𝑏)
Solution: (d)
Given a set of n points, Lagrange interpolation formula is
𝑛−1
𝑓(𝑥) = ∑ 𝐿𝑖 (𝑥)𝑓(𝑥𝑖 )
𝑖=0
𝑛−1
𝑥 − 𝑥𝑗
𝐿𝑖 (𝑥) = ∏
𝑥𝑖 − 𝑥𝑗
𝑗=0
𝑗≠𝑖
𝑥−𝑏 𝑥−𝑎
Thus, 𝑓(𝑥) = 𝑓(𝑎) + 𝑓(𝑏)
𝑎−𝑏 𝑏−𝑎
3. A Lagrange polynomial passes through three data points as given below
𝑥 5 10 15
𝑓(𝑥) 15.35 9.63 3.74
The polynomial is determined as 𝑓(𝑥) = 𝐿0 (𝑥). (15.35) + 𝐿1 (𝑥). (9.63) + 𝐿2 (𝑥). (3.74)
The value of 𝑓(𝑥) at 𝑥 = 7 is
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
ASSIGNMENT SOLUTION WEEK 11
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
1.5
4. The value of ∫0 𝑥𝑒 2𝑥 𝑑𝑥 by using one segment trapezoidal rule is (up to four decimal
places)
Solution: 22.5962 (Short answer type)
𝑏
𝑓(𝑏) + 𝑓(𝑎)
∫ 𝑓(𝑥)𝑑𝑥 = (𝑏 − 𝑎)
𝑎 2
1.5
Here, 𝑎 = 0, 𝑏 = 1.5, 𝑓(𝑎) = 0 and 𝑓(𝑏) = 30.1283. Hence, ∫0 𝑥𝑒 2𝑥 𝑑𝑥 = 22.5962
5. Accuracy of the trapezoidal rule increases when
a) integration is carried out for sufficiently large range
b) instead of trapezoid, we take rectangular approximation function
c) number of segments are increased
d) integration is performedfor only integer range
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-Kutta 4th 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)
7. Using Bisection method, negative root of 𝑥 3 − 4𝑥 + 9 = 0 , correct to three
decimal places is
a) -2.506
b) -2.706
c) -2.406
d) None
Solution: (b) -2.706
ASSIGNMENT SOLUTION WEEK 11
8. Match the following
A. Newton Method 1. Integration
B. Lagrange Polynomial 2. Root finding
C. Trapezoidal Method 3. Differential Equation
D. RungeKutta Method 4. Interpolation
a) A-2, B-4, C-1, D-3
b) A-3, B-1, C-2, D-4
c) A-1, B-4, C-3, D-2
d) A-2, B-3, C-4, D-1
Solution: (a)
9. The real root of the equation 5x − 2cosx −1 = 0 (up to two decimal accuracy) is
[You can use any method known to you. A range is given in output rather than
single value to avoid approximation error]
a) 0.53 to 0.56
b) 0.45 to 0.47
c) 0.35 to 0.37
d) 0.41 to 0.43
Solution: (a) 0.53 to 0.56
10. Consider the same recursive C function that takes two arguments
unsignedint func(unsigned int n, unsigned int r)
{
if (n > 0) return (n%r + func (n/r, r ));
else return 0;
}
What is the return value of the function func() when it is called as func(513, 2)?
Solution: 2 (short answer type)
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.