Menu Close

Interpolation: UPSC Maths Optional PYQ Solutions (2008–2025)

All 13 questions UPSC has asked on interpolation in the Mathematics Optional (Paper II, Numerical Analysis and Computer Programming) from 2008 to 2025, solved step by step – latest first.

Try them yourself first: the same questions, without solutions, are on our Numerical Analysis and Computer Programming topic-wise PYQs page.

How we check these solutions

These are our own solutions, prepared with AI help. UPSC does not publish official answers. Every solution is checked a second way before it goes up, and says how:

  • ✓ Checked by computer the answer was worked out again independently with Python: each iteration, table or conversion was run again in double precision (or exact fractions), and algorithms were run on test equations.
  • ✓ Proof checked step by step for “prove that” questions, every step was checked against the definitions.

Spotted a mistake or a neater method? Tell us in the comments below or through Report an error.

Jump to a question (year · question number):

2025 · 7b 2024 · 8b 2021 · 8b 2020 · 8b 2018 · 5b 2017 · 6b 2016 · 6c 2015 · 6c 2013 · 5c 2012 · 7a 2011 · 7c 2009 · 7b 2008 · 7a(i)

Cover of the UPSC Prelims Topic-wise PYQ book with detailed explanations

From the Optional Province team

Preparing for Prelims too?

Our UPSC Prelims Topic-wise PYQ Book covers every Prelims question with detailed explanations, so you can see exactly where UPSC asks from. Now available as a hard copy and an eBook.

Buy Hard Copy on AmazonBuy eBook (PDF)

Download a free sample

Find the unique polynomial of degree 2 or less which fits the following data : x013f(x)1355 Also obtain the bound on the truncation error.

2025 · Paper II · Q7b · 15 marks

Solution

Divided differences. f[0,1]=3−11−0=2f[1,3]=55−33−1=26f[0,1,3]=26−23−0=8.\begin{aligned}&f[0,1]=\frac{3-1}{1-0}=2\\ &f[1,3]=\frac{55-3}{3-1}=26\\ &f[0,1,3]=\frac{26-2}{3-0}=8.\end{aligned} Newton’s divided-difference form: p(x)=1+2(x−0)+8(x−0)(x−1)=8x2−6x+1.\begin{aligned}p(x)&=1+2(x-0)\\ &\quad +8(x-0)(x-1)\\ &=8x^2-6x+1.\end{aligned} This is the unique polynomial of degree ≤2\le2 through the three points (two such polynomials would differ by a polynomial of degree ≤2\le2 with three zeros, hence by 0).

Check: p(0)=1p(0)=1, p(1)=3p(1)=3, p(3)=72−18+1=55p(3)=72-18+1=55. ✓

Truncation error. If ff has a continuous third derivative on [0,3][0,3], f(x)−p(x)=x(x−1)(x−3)3!f‴(ξ),f(x)-p(x)=\frac{x(x-1)(x-3)}{3!}\,f'''(\xi), for some ξ∈(0,3)\xi\in(0,3). Let w(x)=x(x−1)(x−3)=x3−4x2+3xw(x)=x(x-1)(x-3)=x^3-4x^2+3x. Then w′(x)=3x2−8x+3=0w'(x)=3x^2-8x+3=0 at x=4±73x=\dfrac{4\pm\sqrt7}{3}, i.e. x≈0.4514x\approx0.4514 (w≈0.6311w\approx0.6311) and x≈2.2153x\approx2.2153 (w≈−2.1126w\approx-2.1126). At the end points w=0w=0. So on [0,3][0,3], |w(x)|≤2.1126|w(x)|\le2.1126 and |f(x)−p(x)|≤2.11266M3≈0.3521M3,|f(x)-p(x)|\le\frac{2.1126}{6}\,M_3\approx0.3521\,M_3, where M3=max0≤x≤3|f‴(x)|M_3=\max_{0\le x\le3}|f'''(x)|.

✓ Checked by computer We checked by computer: 8x2−6x+18x^2-6x+1 takes the values 1, 3, 55 at x=0,1,3x=0,1,3, and the largest value of |x(x−1)(x−3)||x(x-1)(x-3)| on [0,3][0,3] is 2.11262.1126 at x=(4+7)/3x=(4+\sqrt7)/3.

↑ Back to the question list

Using Newton’s forward difference formula for interpolation, estimate the value of f(2.5) from the following data : x123456f(x)0182764125

2024 · Paper II · Q8b · 15 marks

Solution

Forward difference table (h=1h=1):

xx yy Δy\Delta y Δ2y\Delta^2 y Δ3y\Delta^3 y Δ4y\Delta^4 y Δ5y\Delta^5 y
1 0 1 6 6 0 0
2 1 7 12 6 0
3 8 19 18 6
4 27 37 24
5 64 61
6 125

Third differences are constant, so the data come from a cubic and the series stops at Δ3\Delta^3.

Newton’s forward formula with x0=1x_0=1, p=x−x0h=1.5p=\dfrac{x-x_0}{h}=1.5: f(x0+ph)=y0+pΔy0+p(p−1)2!Δ2y0+p(p−1)(p−2)3!Δ3y0.\begin{aligned}&f(x_0+ph)=y_0+p\Delta y_0\\ &\quad +\frac{p(p-1)}{2!}\Delta^2y_0\\ &\quad+\frac{p(p-1)(p-2)}{3!}\Delta^3y_0.\end{aligned} f(2.5)=0+1.5(1)+1.5(0.5)2(6)+1.5(0.5)(−0.5)6(6)=1.5+2.25−0.375=3.375.\begin{aligned}f(2.5)&=0+1.5(1)+\frac{1.5(0.5)}{2}(6)\\ &\quad +\frac{1.5(0.5)(-0.5)}{6}(6)\\ &=1.5+2.25-0.375\\ &=3.375 .\end{aligned}

✓ Checked by computer We checked by computer: the data are f(x)=(x−1)3f(x)=(x-1)^3, so f(2.5)=1.53=3.375f(2.5)=1.5^3=3.375 exactly.

↑ Back to the question list

Derive Newton’s backward difference interpolation formula and also do error analysis.

2021 · Paper II · Q8b · 15 marks

Solution

Setting. Let yi=f(xi)y_i=f(x_i) at equally spaced points xi=x0+ihx_i=x_0+ih, i=0,1,…,ni=0,1,\dots,n, and define the backward difference ∇yi=yi−yi−1\nabla y_i=y_i-y_{i-1}, ∇k=∇(∇k−1)\nabla^k=\nabla(\nabla^{k-1}). We interpolate near the end of the table, so we write x=xn+php=x−xnh(usually −1<p≤0).\begin{aligned}&x=x_n+ph\\ &p=\frac{x-x_n}{h}\ (\text{usually } -1<p\le0).\end{aligned} Derivation. Look for the polynomial of degree nn in the form P(x)=a0+a1(x−xn)+a2(x−xn)(x−xn−1)+⋯+an(x−xn)⋯(x−x1).\begin{aligned}P(x)&=a_0+a_1(x-x_n)\\ &\quad+a_2(x-x_n)(x-x_{n-1})+\cdots\\ &\quad+a_n(x-x_n)\cdots(x-x_1).\end{aligned} Put x=xnx=x_n: a0=yna_0=y_n.

Put x=xn−1x=x_{n-1}: yn−1=yn+a1(−h)y_{n-1}=y_n+a_1(-h), so a1=yn−yn−1h=∇ynha_1=\dfrac{y_n-y_{n-1}}{h}=\dfrac{\nabla y_n}{h}.

Put x=xn−2x=x_{n-2}: yn−2=yn−2h∇ynh+a2(−2h)(−h)y_{n-2}=y_n-2h\,\dfrac{\nabla y_n}{h}+a_2(-2h)(-h), so a2=yn−2yn−1+yn−22h2=∇2yn2!h2.a_2=\frac{y_n-2y_{n-1}+y_{n-2}}{2h^2}=\frac{\nabla^2y_n}{2!\,h^2}. Continuing in the same way (or by induction on kk), ak=∇kynk!hka_k=\dfrac{\nabla^ky_n}{k!\,h^k}.

Now x−xn−j=(p+j)hx-x_{n-j}=(p+j)h, so (x−xn)(x−xn−1)⋯(x−xn−k+1)=p(p+1)⋯(p+k−1)hk(x-x_n)(x-x_{n-1})\cdots(x-x_{n-k+1})=p(p+1)\cdots(p+k-1)h^k. Substituting, P(xn+ph)=yn+p∇yn+p(p+1)2!∇2yn+p(p+1)(p+2)3!∇3yn+⋯+p(p+1)⋯(p+n−1)n!∇nyn\begin{aligned}P(x_n+ph)&=y_n+p\nabla y_n+\frac{p(p+1)}{2!}\nabla^2y_n\\ &\quad+\frac{p(p+1)(p+2)}{3!}\nabla^3y_n+\cdots\\ &\quad+\frac{p(p+1)\cdots(p+n-1)}{n!}\nabla^ny_n\end{aligned} This is Newton’s backward difference interpolation formula. (Equivalently: yn+p=Epyn=(1−∇)−pyny_{n+p}=E^py_n=(1-\nabla)^{-p}y_n, expanded by the binomial series.)

Error analysis. Let f∈Cn+1f\in C^{n+1} and xx lie in the interval spanned by the nodes. The interpolation error is f(x)−P(x)=w(x)(n+1)!f(n+1)(ξ),f(x)-P(x)=\frac{w(x)}{(n+1)!}\,f^{(n+1)}(\xi), where w(x)=(x−x0)(x−x1)⋯(x−xn)w(x)=(x-x_0)(x-x_1)\cdots(x-x_n). Proof. Fix xx not a node and set g(t)=f(t)−P(t)−Kw(t)g(t)=f(t)-P(t)-K\,w(t) and KK chosen so that g(x)=0g(x)=0. Then gg has n+2n+2 zeros (x0,…,xn,xx_0,\dots,x_n,x). By Rolle’s theorem applied n+1n+1 times, g(n+1)(ξ)=0g^{(n+1)}(\xi)=0 for some ξ\xi; since P(n+1)=0P^{(n+1)}=0 and w(n+1)=(n+1)!w^{(n+1)}=(n+1)!, we get K=f(n+1)(ξ)/(n+1)!K=f^{(n+1)}(\xi)/(n+1)!.

In terms of pp: x−xn−j=(p+j)hx-x_{n-j}=(p+j)h, so E(x)=p(p+1)⋯(p+n)(n+1)!hn+1f(n+1)(ξ)≈p(p+1)⋯(p+n)(n+1)!∇n+1yn,\begin{aligned}E(x)&=\frac{p(p+1)\cdots(p+n)}{(n+1)!}\,h^{n+1}f^{(n+1)}(\xi)\\ &\approx\frac{p(p+1)\cdots(p+n)}{(n+1)!}\,\nabla^{n+1}y_n,\end{aligned} using hn+1f(n+1)≈∇n+1yh^{n+1}f^{(n+1)}\approx\nabla^{n+1}y. The error is small when pp is small, i.e. near the end xnx_n of the table – which is why the backward formula is used there.

✓ Proof checked step by step We checked the formula on f(x)=x3f(x)=x^3 (exact, as ∇4=0\nabla^4=0) and checked that the error term vanishes at every node.

↑ Back to the question list

Write the three point Lagrangian interpolating polynomial relative to the points x0, x0+ε and x1. Then by taking the limit ε→0, establish the relation f(x)=(x1−x)(x+x1−2x0)(x1−x0)2f(x0)+(x−x0)(x1−x)(x1−x0)f′(x0)+(x−x0)2(x1−x0)f(x1)+E(x) where E(x)=16(x−x0)2(x−x1)f‴(ξ) is the error function and min.(x0,x0+ε,x1)<ξ<max.(x0,x0+ε,x1)

2020 · Paper II · Q8b · 15 marks

Solution

Three-point Lagrange polynomial on x0,x0+ε,x1x_0,\ x_0+\varepsilon,\ x_1: Pε(x)=(x−x0−ε)(x−x1)(−ε)(x0−x1)f(x0)+(x−x0)(x−x1)ε(x0+ε−x1)f(x0+ε)+(x−x0)(x−x0−ε)(x1−x0)(x1−x0−ε)f(x1),\begin{aligned}P_\varepsilon(x)&=\frac{(x-x_0-\varepsilon)(x-x_1)}{(-\varepsilon)(x_0-x_1)}f(x_0)\\ &\quad+\frac{(x-x_0)(x-x_1)}{\varepsilon(x_0+\varepsilon-x_1)}f(x_0+\varepsilon)\\ &\quad+\frac{(x-x_0)(x-x_0-\varepsilon)}{(x_1-x_0)(x_1-x_0-\varepsilon)}f(x_1),\end{aligned} with error Eε(x)=(x−x0)(x−x0−ε)(x−x1)3!f‴(ξε).\begin{aligned}&E_\varepsilon(x)\\ &\quad =\frac{(x-x_0)(x-x_0-\varepsilon)(x-x_1)}{3!}f'''(\xi_\varepsilon).\end{aligned} Call the three coefficients L0,L1,L2L_0,L_1,L_2.

Taking the limit. Write f(x0+ε)=f(x0)+εf′(x0)+O(ε2)f(x_0+\varepsilon)=f(x_0)+\varepsilon f'(x_0)+O(\varepsilon^2). Then Pε=(L0+L1)f(x0)+εL1f′(x0)+L2f(x1)+O(ε2)L1.\begin{aligned}&P_\varepsilon=(L_0+L_1)f(x_0)+\varepsilon L_1\,f'(x_0)\\ &\quad+L_2f(x_1)+O(\varepsilon^2)L_1.\end{aligned}

  • Combining over a common denominator, L0+L1=(x1−x)(x+x1−2x0−ε)(x1−x0)(x1−x0−ε)→(x1−x)(x+x1−2x0)(x1−x0)2.\begin{aligned}L_0+L_1&=\frac{(x_1-x)(x+x_1-2x_0-\varepsilon)}{(x_1-x_0)(x_1-x_0-\varepsilon)}\\ &\longrightarrow\ \frac{(x_1-x)(x+x_1-2x_0)}{(x_1-x_0)^2}.\end{aligned}
  • εL1=(x−x0)(x−x1)x0+ε−x1→(x−x0)(x1−x)x1−x0\varepsilon L_1=\dfrac{(x-x_0)(x-x_1)}{x_0+\varepsilon-x_1}\ \longrightarrow\ \dfrac{(x-x_0)(x_1-x)}{x_1-x_0}.
  • L2→(x−x0)2(x1−x0)2L_2\ \longrightarrow\ \dfrac{(x-x_0)^2}{(x_1-x_0)^2}.
  • O(ε2)L1=O(ε)→0O(\varepsilon^2)L_1=O(\varepsilon)\to0, and Eε→16(x−x0)2(x−x1)f‴(ξ)E_\varepsilon\to\dfrac16(x-x_0)^2(x-x_1)f'''(\xi).

Hence f(x)=(x1−x)(x+x1−2x0)(x1−x0)2f(x0)+(x−x0)(x1−x)x1−x0f′(x0)+(x−x0)2(x1−x0)2f(x1)+E(x),\begin{aligned}&f(x)=\frac{(x_1-x)(x+x_1-2x_0)}{(x_1-x_0)^2}f(x_0)\\ &\quad+\frac{(x-x_0)(x_1-x)}{x_1-x_0}f'(x_0)\\ &\quad +\frac{(x-x_0)^2}{(x_1-x_0)^2}f(x_1)+E(x),\end{aligned} E(x)=16(x−x0)2(x−x1)f‴(ξ),E(x)=\frac16(x-x_0)^2(x-x_1)f'''(\xi), with min(x0,x0+ε,x1)<ξ<max(x0,x0+ε,x1)\min(x_0,x_0+\varepsilon,x_1)<\xi<\max(x_0,x_0+\varepsilon,x_1). Note on the printed formula. The coefficient of f(x1)f(x_1) must be (x−x0)2(x1−x0)2\dfrac{(x-x_0)^2}{(x_1-x_0)^2} (squared denominator), as derived; with (x1−x0)(x_1-x_0) alone the formula would not give f(x1)f(x_1) at x=x1x=x_1 unless x1−x0=1x_1-x_0=1.

Check. At x=x0x=x_0 the right side is f(x0)f(x_0); at x=x1x=x_1 it is f(x1)f(x_1); and its derivative at x0x_0 is f′(x0)f'(x_0) – this is the quadratic matching f(x0),f′(x0),f(x1)f(x_0),\ f'(x_0),\ f(x_1) (a Hermite-type interpolant).

✓ Checked by computer We checked by computer (SymPy): the limits of the Lagrange coefficients as ε→0\varepsilon\to0 are exactly the three coefficients derived.

↑ Back to the question list

Using Newton’s forward difference formula find the lowest degree polynomial ux when it is given that u1=1, u2=9, u3=25, u4=55 and u5=105.

2018 · Paper II · Q5b · 10 marks

Solution

Difference table:

xx yy Δy\Delta y Δ2y\Delta^2 y Δ3y\Delta^3 y Δ4y\Delta^4 y
1 1 8 8 6 0
2 9 16 14 6
3 25 30 20
4 55 50
5 105

Δ4=0\Delta^4=0, so the lowest-degree polynomial is a cubic. Newton’s forward formula with x0=1x_0=1, h=1h=1, p=x−1p=x-1: ux=u1+pΔu1+p(p−1)2Δ2u1+p(p−1)(p−2)6Δ3u1=1+8p+4p(p−1)+p(p−1)(p−2)=p3+p2+6p+1.\begin{aligned}u_x&=u_1+p\Delta u_1\\ &\quad +\frac{p(p-1)}{2}\Delta^2u_1\\ &\quad +\frac{p(p-1)(p-2)}{6}\Delta^3u_1\\ &=1+8p+4p(p-1)\\ &\quad+p(p-1)(p-2)\\ &=p^3+p^2+6p+1 .\end{aligned} Putting p=x−1p=x-1: ux=x3−2x2+7x−5.u_x=x^{3} – 2 x^{2} + 7 x – 5 . Check: u3=27−18+21−5=25u_3=27-18+21-5=25. ✓

✓ Checked by computer We checked by computer: ux=x3−2x2+7x−5u_x=x^{3} – 2 x^{2} + 7 x – 5 gives 1, 9, 25, 55, 105 at x=1,…,5x=1,\dots,5.

↑ Back to the question list

For given equidistant values u−1, u0, u1 and u2, a value is interpolated by Lagrange’s formula. Show that it may be written in the form ux=yu0+xu1+y(y2−1)3!Δ2u−1+x(x2−1)3!Δ2u0, where x+y=1.

2017 · Paper II · Q6b · 15 marks

Solution

The Lagrange polynomial through the four equidistant values u−1,u0,u1,u2u_{-1},u_0,u_1,u_2 (at x=−1,0,1,2x=-1,0,1,2) is the unique polynomial of degree ≤3\le3 taking these values. So it is enough to show that the right-hand side R(x)=yu0+xu1+y(y2−1)3!Δ2u−1+x(x2−1)3!Δ2u0y=1−x,\begin{aligned}&R(x)=yu_0+xu_1+\frac{y(y^2-1)}{3!}\Delta^2u_{-1}\\ &\quad +\frac{x(x^2-1)}{3!}\Delta^2u_0\\ &y=1-x,\end{aligned} is a polynomial of degree ≤3\le3 in xx with the same four values.

Degree. Each term is a polynomial in xx of degree at most 3. ✓

Values. Recall Δ2u−1=u1−2u0+u−1\Delta^2u_{-1}=u_1-2u_0+u_{-1} and Δ2u0=u2−2u1+u0\Delta^2u_0=u_2-2u_1+u_0.

  • x=0x=0 (y=1y=1): y(y2−1)=0y(y^2-1)=0 and x(x2−1)=0x(x^2-1)=0, so R=u0R=u_0. ✓
  • x=1x=1 (y=0y=0): both cubic terms vanish, so R=u1R=u_1. ✓
  • x=−1x=-1 (y=2y=2): y(y2−1)/6=1y(y^2-1)/6=1 and x(x2−1)=0x(x^2-1)=0, so R=2u0−u1+(u1−2u0+u−1)=u−1.✓\begin{aligned}R&=2u_0-u_1+(u_1-2u_0+u_{-1})\\ &=u_{-1}. \ ✓\end{aligned}
  • x=2x=2 (y=−1y=-1): y(y2−1)=0y(y^2-1)=0 and x(x2−1)/6=1x(x^2-1)/6=1, so R=−u0+2u1+(u2−2u1+u0)=u2.✓\begin{aligned}R&=-u_0+2u_1+(u_2-2u_1+u_0)\\ &=u_2. \ ✓\end{aligned} Two polynomials of degree ≤3\le3 that agree at four points are identical. Hence the value interpolated by Lagrange’s formula can be written as ux=yu0+xu1+y(y2−1)3!Δ2u−1+x(x2−1)3!Δ2u0x+y=1.\begin{aligned}&u_x=yu_0+xu_1+\frac{y(y^2-1)}{3!}\Delta^2u_{-1}\\ &\quad +\frac{x(x^2-1)}{3!}\Delta^2u_0\\ &x+y=1.\end{aligned} (This is Everett’s formula truncated after second differences.)

✓ Proof checked step by step We checked the identity symbolically (SymPy): the right side, with y=1−xy=1-x, equals the Lagrange cubic through u−1,u0,u1,u2u_{-1},u_0,u_1,u_2 for all xx.

↑ Back to the question list

Cover of the UPSC Mains Topic-wise and Year-wise PYQs book (2013–2026)

From the Optional Province team

Strengthen your GS papers

Our UPSC Mains Topic-wise & Year-wise PYQ Book (2013–2026) maps every GS question to the syllabus, so you know what UPSC asks and how often. Now available as a hard copy and an eBook.

Buy Hard Copy on AmazonBuy eBook (PDF)

Download a free sample

Let f(x)=e2xcos3x, for x∈[0,1]. Estimate the value of f(0.5) using Lagrange interpolating polynomial of degree 3 over the nodes x=0, x=0.3, x=0.6 and x=1. Also, compute the error bound over the interval [0,1] and the actual error E(0.5).

2016 · Paper II · Q6c · 20 marks

Solution

Interpolating values (f(x)=e2xcos3xf(x)=e^{2x}\cos3x) and Lagrange coefficients at x=0.5x=0.5: Li(0.5)=∏j≠i0.5−xjxi−xjL_i(0.5)=\prod_{j\ne i}\frac{0.5-x_j}{x_i-x_j}

xix_i f(xi)f(x_i) Li(0.5)L_i(0.5) f(xi)Li(0.5)f(x_i)L_i(0.5)
0 1.000000 −0.055556 −0.055556
0.3 1.132647 0.396825 0.449463
0.6 −0.754338 0.694444 −0.523845
1.0 −7.315110 −0.035714 0.261254

P3(0.5)=∑if(xi)Li(0.5)≈0.131316.P_3(0.5)=\sum_i f(x_i)L_i(0.5)\approx0.131316.

Error bound on [0,1][0,1]. f(x)−P3(x)=w(x)4!f(4)(ξ),f(x)-P_3(x)=\frac{w(x)}{4!}f^{(4)}(\xi), where w(x)=x(x−0.3)(x−0.6)(x−1)w(x)=x(x-0.3)(x-0.6)(x-1). Writing f=Ree(2+3i)xf=\operatorname{Re}\,e^{(2+3i)x} and (2+3i)4=−119−120i(2+3i)^4=-119-120i, f(4)(x)=e2x(−119cos3x+120sin3x).f^{(4)}(x)=e^{2x}(-119\cos3x+120\sin3x). On [0,1][0,1], |f(4)||f^{(4)}| is largest at x=0.9800x=0.9800, where it is about 998.29998.29 (the crude bound 169e2≈1248.7169e^2\approx1248.7 also works). The largest value of |w(x)||w(x)| on [0,1][0,1] is about 0.0175460.017546 (at x≈0.8549x\approx0.8549). Hence |f(x)−P3(x)|≤0.017546×998.2924|f(x)-P_3(x)|\le\frac{0.017546\times998.29}{24} ≈0.7298for all x∈[0,1].\approx0.7298\quad\text{for all }x\in[0,1].

Actual error at 0.5. f(0.5)=ecos1.5=0.192284f(0.5)=e\cos1.5=0.192284, so E(0.5)=f(0.5)−P3(0.5)≈0.060968,E(0.5)=f(0.5)-P_3(0.5)\approx0.060968, well within the bound.

✓ Checked by computer We checked by computer: P3(0.5)=0.131316P_3(0.5)=0.131316, f(0.5)=0.192284f(0.5)=0.192284, max|f(4)|=998.29\max|f^{(4)}|=998.29 on [0,1][0,1] and max|w|=0.017546\max|w|=0.017546.

↑ Back to the question list

Find the Lagrange interpolating polynomial that fits the following data : x−1234f(x)−1113169 Find f(1.5).

2015 · Paper II · Q6c · 20 marks

Solution

Lagrange form with nodes −1,2,3,4-1,2,3,4: P(x)=−1⋅(x−2)(x−3)(x−4)(−3)(−4)(−5)+11⋅(x+1)(x−3)(x−4)(3)(−1)(−2)+31⋅(x+1)(x−2)(x−4)(4)(1)(−1)+69⋅(x+1)(x−2)(x−3)(5)(2)(1)=(x−2)(x−3)(x−4)60+11(x+1)(x−3)(x−4)6−31(x+1)(x−2)(x−4)4+69(x+1)(x−2)(x−3)10.\begin{aligned}P(x)&=-1\cdot\frac{(x-2)(x-3)(x-4)}{(-3)(-4)(-5)}\\ &\quad +11\cdot\frac{(x+1)(x-3)(x-4)}{(3)(-1)(-2)}\\ &\quad+31\cdot\frac{(x+1)(x-2)(x-4)}{(4)(1)(-1)}\\ &\quad +69\cdot\frac{(x+1)(x-2)(x-3)}{(5)(2)(1)}\\ &=\frac{(x-2)(x-3)(x-4)}{60}\\ &\quad +\frac{11(x+1)(x-3)(x-4)}{6}\\ &\quad-\frac{31(x+1)(x-2)(x-4)}{4}\\ &\quad +\frac{69(x+1)(x-2)(x-3)}{10}.\end{aligned} Expanding and collecting, P(x)=x3+x+1.P(x)=x^{3} + x + 1 . Check: substituting x=−1,2,3,4x=-1,2,3,4 gives −1,11,31,69-1,\ 11,\ 31,\ 69. ✓

P(1.5)=478=5.8750.P(1.5)=\frac{47}{8}=5.8750.

✓ Checked by computer We checked by computer: P(x)=x3+x+1P(x)=x^{3} + x + 1 passes through all four points and P(1.5)=478P(1.5)=\frac{47}{8}.

↑ Back to the question list

In an examination, the number of students who obtained marks between certain limits were given in the following table : Marks30−4040−5050−6060−7070−80No. of Students3142513531 Using Newton forward interpolation formula, find the number of students whose marks lie between 45 and 50.

2013 · Paper II · Q5c · 10 marks

Solution

Interpolate the cumulative frequency y(x)y(x) = number of students with marks below xx:

xx yy Δy\Delta y Δ2y\Delta^2 y Δ3y\Delta^3 y Δ4y\Delta^4 y
40 31 42 9 -25 37
50 73 51 -16 12
60 124 35 -4
70 159 31
80 190

Newton’s forward formula with x0=40x_0=40, h=10h=10, p=45−4010=0.5p=\dfrac{45-40}{10}=0.5:

  • pΔy0=0.5×42=21p\,\Delta y_0=0.5\times42=21
  • p(p−1)2Δ2y0=−0.125×9=−1.125\frac{p(p-1)}{2}\Delta^2y_0=-0.125\times9=-1.125
  • p(p−1)(p−2)6Δ3y0=0.0625×(−25)=−1.5625\frac{p(p-1)(p-2)}{6}\Delta^3y_0=0.0625\times(-25)=-1.5625
  • p(p−1)(p−2)(p−3)24Δ4y0=−0.0390625×37=−1.4453\frac{p(p-1)(p-2)(p-3)}{24}\Delta^4y_0=-0.0390625\times37=-1.4453

y(45)=31+21−1.125−1.5625−1.4453=47.8672.\begin{aligned}y(45)&=31+21-1.125\\ &\quad -1.5625-1.4453\\ &=47.8672.\end{aligned} So about 48 students scored below 45. Students scoring below 50: 73. Hence the number with marks between 45 and 50 is 73−47.87=25.13≈25.73-47.87=25.13\approx 25 .

✓ Checked by computer We checked by computer: the quartic through the five cumulative values gives y(45)=47.8672y(45)=47.8672, so about 25.13≈2525.13\approx25 students.

↑ Back to the question list

Find dydx at x=0.1 from the following data : x0.10.20.30.4y0.99750.99000.97760.9604

2012 · Paper II · Q7a · 20 marks

Solution

Difference table (h=0.1h=0.1):

xx yy Δy\Delta y Δ2y\Delta^2 y Δ3y\Delta^3 y
0.1 0.9975 -0.0075 -0.0049 0.0001
0.2 0.9900 -0.0124 -0.0048
0.3 0.9776 -0.0172
0.4 0.9604

Differentiate Newton’s forward formula y=y0+pΔy0+p(p−1)2Δ2y0+p(p−1)(p−2)6Δ3y0y=y_0+p\Delta y_0+\frac{p(p-1)}{2}\Delta^2y_0+\frac{p(p-1)(p-2)}{6}\Delta^3y_0 with respect to x=x0+phx=x_0+ph. At x=x0x=x_0 (p=0p=0): dydx|x0=1h(Δy0−12Δ2y0+13Δ3y0).\left.\frac{dy}{dx}\right|_{x_0}=\frac1h\left(\Delta y_0-\frac12\Delta^2y_0+\frac13\Delta^3y_0\right). With x0=0.1x_0=0.1: dydx=10(−0.0075+0.00492+0.00013)\frac{dy}{dx}=10\left(-0.0075+\tfrac{0.0049}{2}+\tfrac{0.0001}{3}\right) =10(−0.0050167)≈−0.0502.=10(-0.0050167)\approx-0.0502.

✓ Checked by computer We checked by computer: differentiating the cubic through the four points at x=0.1x=0.1 gives −0.05017-0.05017.

↑ Back to the question list

Draw a flow chart for Lagrange’s interpolation formula.

2011 · Paper II · Q7c · 20 marks

Solution

Formula. For nn points (xi,yi)(x_i,y_i), f(x)≈∑i=1nyi∏j=1,j≠inx−xjxi−xj.f(x)\approx\sum_{i=1}^{n}y_i\prod_{j=1,\,j\ne i}^{n}\frac{x-x_j}{x_i-x_j} . The outer loop runs over ii (one term per data point); the inner loop over jj builds the product for that term.

StartRead n, (xᵢ, yᵢ) for i = 1..n,and the point xs ← 0, i ← 1t ← yᵢ, j ← 1If j ≠ i:t ← t·(x − xⱼ)/(xᵢ − xⱼ)j ← j + 1j ≤ n ?NoYess ← s + t, i ← i + 1i ≤ n ?NoYesPrint s (= f(x))Stop
Lagrange interpolation: the inner loop builds each term, the outer loop adds them

✓ Proof checked step by step We ran the same steps in Python on the data of the 2009 question (six points): it returns f(3)=10f(3)=10, as obtained there by hand.

↑ Back to the question list

Using Lagrange interpolation formula, calculate the value of f(3) from the following table of values of x and f(x) : x012456f(x)114155619

2009 · Paper II · Q7b · 15 marks

Solution

f(3)≈∑if(xi)Li(3)Li(3)=∏j≠i3−xjxi−xj.\begin{aligned}&f(3)\approx\sum_{i}f(x_i)L_i(3)\\ &L_i(3)=\prod_{j\ne i}\frac{3-x_j}{x_i-x_j}.\end{aligned} For example L0(3)=(2)(1)(−1)(−2)(−3)(−1)(−2)(−4)(−5)(−6)=−12−240=120.\begin{aligned}L_0(3)&=\frac{(2)(1)(-1)(-2)(-3)}{(-1)(-2)(-4)(-5)(-6)}\\ &=\frac{-12}{-240}\\ &=\frac1{20}.\end{aligned} All six:

xix_i f(xi)f(x_i) Li(3)L_i(3) f(xi)Li(3)f(x_i)L_i(3)
0 1 120\tfrac{1}{20} 120\tfrac{1}{20}
1 14 −310-\tfrac{3}{10} −215-\tfrac{21}{5}
2 15 34\tfrac{3}{4} 454\tfrac{45}{4}
4 5 34\tfrac{3}{4} 154\tfrac{15}{4}
5 6 −310-\tfrac{3}{10} −95-\tfrac{9}{5}
6 19 120\tfrac{1}{20} 1920\tfrac{19}{20}

(The Li(3)L_i(3) add up to 1, as they must.) Adding the last column, f(3)=10.f(3)=10 .

✓ Checked by computer We checked by computer: the degree-5 interpolating polynomial gives f(3)=10f(3)=10 exactly.

↑ Back to the question list

The following values of the function f(x)=sinx+cosx are given: x10∘20∘30∘f(x)1.15851.28171.3360 Construct the quadratic interpolating polynomial that fits the data. Hence calculate f(π12). Compare with exact value.

2008 · Paper II · Q7a(i) · 15 marks

Solution

Use θ\theta in degrees, h=10∘h=10^\circ.

xx yy Δy\Delta y Δ2y\Delta^2 y
10° 1.1585 0.1232 -0.0689
20° 1.2817 0.0543
30° 1.3360

Quadratic (Newton’s forward form, p=(θ−10)/10p=(\theta-10)/10): P(θ)=1.1585+0.1232θ−1010−0.0689(θ−10)(θ−20)200,\begin{aligned}&P(\theta)=1.1585+0.1232\,\frac{\theta-10}{10}\\ &\quad-0.0689\,\frac{(\theta-10)(\theta-20)}{200},\end{aligned} which expands to P(θ)≈0.9664+0.022655θ−0.0003445θ2.\begin{aligned}&P(\theta)\approx0.9664\\ &\quad+0.022655\,\theta-0.0003445\,\theta^2.\end{aligned} Value at π/12=15∘\pi/12=15^\circ (p=0.5p=0.5): P(15)=1.1585+0.5(0.1232)+0.5(−0.5)2(−0.0689)=1.1585+0.0616+0.0086=1.2287.\begin{aligned}P(15)&=1.1585+0.5(0.1232)\\ &\quad +\frac{0.5(-0.5)}{2}(-0.0689)\\ &=1.1585+0.0616+0.0086\\ &=1.2287.\end{aligned} Exact value: sin15∘+cos15∘=3/2=1.2247\sin15^\circ+\cos15^\circ=\sqrt{3/2}=1.2247. The error is about 0.00400.0040 (about 0.3%0.3\%); a quadratic through three widely spaced points cannot follow the curve more closely.

✓ Checked by computer We checked by computer: the quadratic gives f(15∘)=1.228713f(15^\circ)=1.228713, while sin15∘+cos15∘=1.224745\sin15^\circ+\cos15^\circ=1.224745.

↑ Back to the question list

More on Numerical Analysis and Computer Programming

Questions: UPSC Civil Services (Main) Examination, Mathematics Paper II, 2008–2025. Solutions: Optional Province. Found an error? Tell us.

Spotted an error? Tell us.

We classify every PYQ with care, but mistakes can slip in. If a question is in the wrong topic, has a typo, the wrong year, or is missing, let us know. We review every report and update the page.

Report an Error
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted