← 2016 Paper 2
UPSC 2016 Maths Optional Paper 2 Q6c — Step-by-Step Solution 20 marks · Section B
Lagrange's interpolation · Numerical Analysis · asked 5× in 13 yrs · Read the full method →
Question
Let f ( x ) = e 2 x cos 3 x f(x)=e^{2x}\cos 3x f ( x ) = e 2 x cos 3 x , for x ∈ [ 0 , 1 ] x\in[0,1] x ∈ [ 0 , 1 ] . Estimate the value of f ( 0.5 ) f(0.5) f ( 0.5 ) using Lagrange interpolating polynomial of degree 3 over the nodes x = 0 , x = 0.3 , x = 0.6 x=0,\ x=0.3,\ x=0.6 x = 0 , x = 0.3 , x = 0.6 and x = 1 x=1 x = 1 . Also, compute the error bound over the interval [ 0 , 1 ] [0,1] [ 0 , 1 ] and the actual error E ( 0.5 ) E(0.5) E ( 0.5 ) .
Technique
Cubic Lagrange interpolation on four nodes; basis values at 0.5 0.5 0.5 (check ∑ L i = 1 \sum L_i=1 ∑ L i = 1 ); standard remainder E = f ( 4 ) ( ξ ) 4 ! W ( x ) E=\frac{f^{(4)}(\xi)}{4!}W(x) E = 4 ! f ( 4 ) ( ξ ) W ( x ) ; bound ∣ f ( 4 ) ∣ |f^{(4)}| ∣ f ( 4 ) ∣ by recognising the constant-amplitude form e 2 x ( 120 sin 3 x − 119 cos 3 x ) e^{2x}(120\sin3x-119\cos3x) e 2 x ( 120 sin 3 x − 119 cos 3 x ) with amplitude 169 169 169 .
Solution
Setup. Four nodes x 0 = 0 , x 1 = 0.3 , x 2 = 0.6 , x 3 = 1 x_0=0,\ x_1=0.3,\ x_2=0.6,\ x_3=1 x 0 = 0 , x 1 = 0.3 , x 2 = 0.6 , x 3 = 1 give a degree-3 3 3 Lagrange polynomial
P 3 ( x ) = ∑ i = 0 3 f ( x i ) L i ( x ) , L i ( x ) = ∏ j ≠ i x − x j x i − x j . P_3(x)=\sum_{i=0}^{3}f(x_i)\,L_i(x),\qquad L_i(x)=\prod_{j\neq i}\frac{x-x_j}{x_i-x_j}. P 3 ( x ) = i = 0 ∑ 3 f ( x i ) L i ( x ) , L i ( x ) = j = i ∏ x i − x j x − x j .
Step 1 — Node values of f ( x ) = e 2 x cos 3 x f(x)=e^{2x}\cos 3x f ( x ) = e 2 x cos 3 x
x i x_i x i e 2 x i e^{2x_i} e 2 x i cos 3 x i \cos 3x_i cos 3 x i f ( x i ) f(x_i) f ( x i ) 0.0 0.0 0.0 1.000000 1.000000 1.000000 cos 0 = 1.000000 \cos 0=1.000000 cos 0 = 1.000000 1.000000 1.000000 1.000000 0.3 0.3 0.3 1.822119 1.822119 1.822119 cos 0.9 = 0.621610 \cos 0.9=0.621610 cos 0.9 = 0.621610 1.132643 1.132643 1.132643 0.6 0.6 0.6 3.320117 3.320117 3.320117 cos 1.8 = − 0.227202 \cos 1.8=-0.227202 cos 1.8 = − 0.227202 − 0.754338 -0.754338 − 0.754338 1.0 1.0 1.0 7.389056 7.389056 7.389056 cos 3 = − 0.989992 \cos 3=-0.989992 cos 3 = − 0.989992 − 7.315129 -7.315129 − 7.315129
Step 2 — Evaluate the Lagrange basis at x = 0.5 x=0.5 x = 0.5
With x = 0.5 x=0.5 x = 0.5 , the denominators are ∏ j ≠ i ( x i − x j ) \prod_{j\neq i}(x_i-x_j) ∏ j = i ( x i − x j ) and the numerators ∏ j ≠ i ( 0.5 − x j ) \prod_{j\neq i}(0.5-x_j) ∏ j = i ( 0.5 − x j ) :
L 0 ( 0.5 ) = ( 0.5 − 0.3 ) ( 0.5 − 0.6 ) ( 0.5 − 1 ) ( 0 − 0.3 ) ( 0 − 0.6 ) ( 0 − 1 ) = ( 0.2 ) ( − 0.1 ) ( − 0.5 ) ( − 0.3 ) ( − 0.6 ) ( − 1 ) = 0.01 − 0.18 = − 0.055556 , L_0(0.5)=\frac{(0.5-0.3)(0.5-0.6)(0.5-1)}{(0-0.3)(0-0.6)(0-1)}=\frac{(0.2)(-0.1)(-0.5)}{(-0.3)(-0.6)(-1)}=\frac{0.01}{-0.18}=-0.055556, L 0 ( 0.5 ) = ( 0 − 0.3 ) ( 0 − 0.6 ) ( 0 − 1 ) ( 0.5 − 0.3 ) ( 0.5 − 0.6 ) ( 0.5 − 1 ) = ( − 0.3 ) ( − 0.6 ) ( − 1 ) ( 0.2 ) ( − 0.1 ) ( − 0.5 ) = − 0.18 0.01 = − 0.055556 ,
L 1 ( 0.5 ) = ( 0.5 ) ( − 0.1 ) ( − 0.5 ) ( 0.3 ) ( − 0.3 ) ( − 0.7 ) = 0.025 0.063 = 0.396825 , L_1(0.5)=\frac{(0.5)(-0.1)(-0.5)}{(0.3)(-0.3)(-0.7)}=\frac{0.025}{0.063}=0.396825, L 1 ( 0.5 ) = ( 0.3 ) ( − 0.3 ) ( − 0.7 ) ( 0.5 ) ( − 0.1 ) ( − 0.5 ) = 0.063 0.025 = 0.396825 ,
L 2 ( 0.5 ) = ( 0.5 ) ( 0.2 ) ( − 0.5 ) ( 0.6 ) ( 0.3 ) ( − 0.4 ) = − 0.05 − 0.072 = 0.694444 , L_2(0.5)=\frac{(0.5)(0.2)(-0.5)}{(0.6)(0.3)(-0.4)}=\frac{-0.05}{-0.072}=0.694444, L 2 ( 0.5 ) = ( 0.6 ) ( 0.3 ) ( − 0.4 ) ( 0.5 ) ( 0.2 ) ( − 0.5 ) = − 0.072 − 0.05 = 0.694444 ,
L 3 ( 0.5 ) = ( 0.5 ) ( 0.2 ) ( − 0.1 ) ( 1 ) ( 0.7 ) ( 0.4 ) = − 0.01 0.28 = − 0.035714. L_3(0.5)=\frac{(0.5)(0.2)(-0.1)}{(1)(0.7)(0.4)}=\frac{-0.01}{0.28}=-0.035714. L 3 ( 0.5 ) = ( 1 ) ( 0.7 ) ( 0.4 ) ( 0.5 ) ( 0.2 ) ( − 0.1 ) = 0.28 − 0.01 = − 0.035714.
(Sum = 1 =1 = 1 , a useful check. ✓)
Step 3 — The estimate P 3 ( 0.5 ) P_3(0.5) P 3 ( 0.5 )
P 3 ( 0.5 ) = ∑ f ( x i ) L i ( 0.5 ) P_3(0.5)=\sum f(x_i)L_i(0.5) P 3 ( 0.5 ) = ∑ f ( x i ) L i ( 0.5 )
= ( 1 ) ( − 0.055556 ) + ( 1.132643 ) ( 0.396825 ) + ( − 0.754338 ) ( 0.694444 ) + ( − 7.315129 ) ( − 0.035714 ) =(1)(-0.055556)+(1.132643)(0.396825)+(-0.754338)(0.694444)+(-7.315129)(-0.035714) = ( 1 ) ( − 0.055556 ) + ( 1.132643 ) ( 0.396825 ) + ( − 0.754338 ) ( 0.694444 ) + ( − 7.315129 ) ( − 0.035714 )
= − 0.055556 + 0.449461 − 0.523846 + 0.261254 = 0.131316. =-0.055556+0.449461-0.523846+0.261254=\boxed{0.131316.} = − 0.055556 + 0.449461 − 0.523846 + 0.261254 = 0.131316.
Step 4 — Error bound on [ 0 , 1 ] [0,1] [ 0 , 1 ]
The interpolation error is
E ( x ) = f ( x ) − P 3 ( x ) = f ( 4 ) ( ξ ) 4 ! W ( x ) , W ( x ) = ∏ i ( x − x i ) , ξ ∈ ( 0 , 1 ) . E(x)=f(x)-P_3(x)=\frac{f^{(4)}(\xi)}{4!}\,W(x),\qquad W(x)=\prod_{i}(x-x_i),\ \xi\in(0,1). E ( x ) = f ( x ) − P 3 ( x ) = 4 ! f ( 4 ) ( ξ ) W ( x ) , W ( x ) = i ∏ ( x − x i ) , ξ ∈ ( 0 , 1 ) .
Differentiating f = e 2 x cos 3 x f=e^{2x}\cos 3x f = e 2 x cos 3 x four times,
f ( 4 ) ( x ) = e 2 x ( 120 sin 3 x − 119 cos 3 x ) . f^{(4)}(x)=e^{2x}\big(120\sin 3x-119\cos 3x\big). f ( 4 ) ( x ) = e 2 x ( 120 sin 3 x − 119 cos 3 x ) .
The bracket has amplitude 120 2 + 119 2 = 28561 = 169 \sqrt{120^2+119^2}=\sqrt{28561}=169 12 0 2 + 11 9 2 = 28561 = 169 , so
∣ f ( 4 ) ( x ) ∣ ≤ 169 e 2 x ≤ 169 e 2 ≈ 1248.75 on [ 0 , 1 ] . |f^{(4)}(x)|\le 169\,e^{2x}\le 169\,e^{2}\approx 1248.75\quad\text{on }[0,1]. ∣ f ( 4 ) ( x ) ∣ ≤ 169 e 2 x ≤ 169 e 2 ≈ 1248.75 on [ 0 , 1 ] .
Take M 4 = 169 e 2 M_4=169e^2 M 4 = 169 e 2 . At x = 0.5 x=0.5 x = 0.5 , W ( 0.5 ) = ( 0.5 ) ( 0.2 ) ( − 0.1 ) ( − 0.5 ) = 0.005 = 1 200 W(0.5)=(0.5)(0.2)(-0.1)(-0.5)=0.005=\tfrac{1}{200} W ( 0.5 ) = ( 0.5 ) ( 0.2 ) ( − 0.1 ) ( − 0.5 ) = 0.005 = 200 1 , so the pointwise error bound at 0.5 0.5 0.5 is
∣ E ( 0.5 ) ∣ ≤ M 4 4 ! ∣ W ( 0.5 ) ∣ = 169 e 2 24 ⋅ 1 200 ≈ 0.260. |E(0.5)|\le\frac{M_4}{4!}\,|W(0.5)|=\frac{169e^{2}}{24}\cdot\frac{1}{200}\approx\boxed{0.260.} ∣ E ( 0.5 ) ∣ ≤ 4 ! M 4 ∣ W ( 0.5 ) ∣ = 24 169 e 2 ⋅ 200 1 ≈ 0.260.
(Over the whole interval, max [ 0 , 1 ] ∣ W ( x ) ∣ ≈ 0.01755 \max_{[0,1]}|W(x)|\approx0.01755 max [ 0 , 1 ] ∣ W ( x ) ∣ ≈ 0.01755 , giving the uniform bound ∣ E ∣ ≤ 169 e 2 24 ( 0.01755 ) ≈ 0.913 |E|\le\frac{169e^2}{24}(0.01755)\approx0.913 ∣ E ∣ ≤ 24 169 e 2 ( 0.01755 ) ≈ 0.913 .)
Step 5 — Actual error E ( 0.5 ) E(0.5) E ( 0.5 )
f ( 0.5 ) = e 1 cos 1.5 = 2.718282 × 0.070737 = 0.192284. f(0.5)=e^{1}\cos 1.5=2.718282\times0.070737=0.192284. f ( 0.5 ) = e 1 cos 1.5 = 2.718282 × 0.070737 = 0.192284.
E ( 0.5 ) = f ( 0.5 ) − P 3 ( 0.5 ) = 0.192284 − 0.131316 = 0.060968. E(0.5)=f(0.5)-P_3(0.5)=0.192284-0.131316=\boxed{0.060968.} E ( 0.5 ) = f ( 0.5 ) − P 3 ( 0.5 ) = 0.192284 − 0.131316 = 0.060968.
This respects the bound 0.060968 ≤ 0.260 0.060968\le0.260 0.060968 ≤ 0.260 . ✓
Verification
python3 (sympy / numpy):
P₃(0.5) = 0.131316055 ✓
f(0.5) = e·cos1.5 = 0.192283650 ✓
actual error E(0.5) = f − P₃ = 0.060967595 ✓
f⁽⁴⁾ = e^{2x}(120 sin3x − 119 cos3x), amplitude √(120²+119²)=169 ✓
max|f⁽⁴⁾| on [0,1] ≈ 998.3 (at x≈0.98) ≤ 169e² = 1248.75 ✓
W(0.5)=1/200; bound 169e²/(24·200)=0.2602 ≥ 0.0610 ✓
max|W| on [0,1] ≈ 0.017546 ✓