Вы находитесь на странице: 1из 3

ASSIGNMENT 11 SOLUTION

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 11 SOLUTION

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 (upto 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 performed for 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. Which of the following cannot be a structure member?


a) another structure
b) function
c) array
d) none of the above
Solution: (b) A function cannot be a structure member.

8. Match the following


ASSIGNMENT 11 SOLUTION

A. Newton Method 1. Integration


B. Lagrange Polynomial 2. Root finding
C. Trapezoidal Method 3. Differential Equation
D. Runge Kutta 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)
3
9. 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

Solution: (c) The 14.24 to 14.58


From the formula of trapezoidal rule we get, the following
Δx/2=1/5:
3
∫1 ex (ln 𝑥) =(1/5)(0+2.72892440558099+7.11180421388169+14.2316766420315+25.7295115705906+22
.066217688311)=14.3736269040792

10. Consider the same recursive C function that takes two arguments

unsigned int 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)?

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.

Вам также может понравиться