Menu Close

Numerical integration: UPSC Maths Optional PYQ Solutions (2010–2026)

All 16 questions UPSC has asked on numerical integration in the Mathematics Optional (Paper II, Numerical Analysis and Computer Programming) from 2010 to 2026, 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):

2026 · 7b 2025 · 8b 2024 · 7b 2022 · 7b 2020 · 7b 2019 · 5e 2018 · 5d 2018 · 7b 2017 · 7b 2016 · 7c 2014 · 5c 2014 · 7b 2013 · 7c 2011 · 5c 2011 · 7a 2010 · 7b

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

Evaluate the integral ∫00.8f(x)dx, where f(x)=0.2+25x−200x2+675x3−900x4+400x5 by using single application of Simpson’s 38 rule.

2026 · Paper II · Q7b · 15 marks

Solution

One application of Simpson’s 38\tfrac38 rule uses four points, so h=0.8−03=0.266667h=\dfrac{0.8-0}{3}=0.266667: ∫x0x3fdx≈3h8(f0+3f1+3f2+f3).\int_{x_0}^{x_3}f\,dx\approx\frac{3h}{8}\left(f_0+3f_1+3f_2+f_3\right).

xx f(x)f(x)
0.000000 0.200000
0.266667 1.432724
0.533333 3.487177
0.800000 0.232000

3h8=0.1,∑=15.191704\frac{3h}{8}=0.1,\qquad \textstyle\sum=15.191704 I≈0.1×15.191704=1.5192.I\approx0.1\times15.191704=1.5192. (The exact value is 1.64051.6405; the rule is exact only up to cubics, and ff is of degree 5, so an error of about 7.4%7.4\% remains with a single application.)

✓ Checked by computer We checked by computer: the rule gives 1.5191701.519170; the exact integral is 30761875=1.640533\frac{3076}{1875}=1.640533.

↑ Back to the question list

Find the constant p and error term for the quadrature formula ∫x0x1f(x)dx=h2(f0+f1)+ph2(f0′−f1′) where x0+h=x1, f0=f(x0), f1=f(x1) and prime (′) represents derivative with respect to x. Hence deduce the composite rule for integrating ∫abf(x)dx,a=x0<x1<⋯<xN=b

2025 · Paper II · Q8b · 15 marks

Solution

Shift so that x0=0x_0=0, x1=hx_1=h, and make the rule exact for f=1,x,x2,…f=1,x,x^2,\dots as far as possible.

  • f=1f=1: h=h2(1+1)h=\tfrac h2(1+1) – true for any pp.
  • f=xf=x: h22=h2(0+h)+ph2(1−1)\tfrac{h^2}{2}=\tfrac h2(0+h)+ph^2(1-1) – true.
  • f=x2f=x^2: h33=h2(h2)+ph2(0−2h)\tfrac{h^3}{3}=\tfrac h2(h^2)+ph^2(0-2h), so 2p=12−132p=\tfrac12-\tfrac13 and p=112.p=\frac1{12}.
  • f=x3f=x^3: left h44\tfrac{h^4}{4}; right h42−h212(3h2)=h44\tfrac{h^4}{2}-\tfrac{h^2}{12}(3h^2)=\tfrac{h^4}{4} – also exact (a bonus degree, by symmetry).
  • f=x4f=x^4: left h55\tfrac{h^5}{5}; right h52−h212(4h3)=h56\tfrac{h^5}{2}-\tfrac{h^2}{12}(4h^3)=\tfrac{h^5}{6}. The difference is h530\tfrac{h^5}{30}.

So the rule is exact up to degree 3, and the error is E=Cf(4)(ξ)E=C\,f^{(4)}(\xi) with C⋅24=h530C\cdot24=\tfrac{h^5}{30}: ∫x0x1fdx=h2(f0+f1)+h212(f0′−f1′)+h5720f(4)(ξ),\begin{aligned}\int_{x_0}^{x_1}f\,dx&=\frac h2(f_0+f_1)\\ &\quad+\frac{h^2}{12}(f_0'-f_1')\\ &\quad+\frac{h^5}{720}f^{(4)}(\xi),\end{aligned} where x0<ξ<x1x_0<\xi<x_1. Composite rule. With xk=a+khx_k=a+kh, h=(b−a)/Nh=(b-a)/N, add the rule over [xk−1,xk][x_{k-1},x_k], k=1,…,Nk=1,\dots,N. The derivative terms telescope: ∑k=1N(fk−1′−fk′)=f0′−fN′.\sum_{k=1}^{N}(f_{k-1}'-f_k')=f_0'-f_N' . Hence ∫abfdx=h2(f0+2f1+⋯+fN)+h212(f′(a)−f′(b))+E,\begin{aligned}\int_a^bf\,dx&=\tfrac h2\left(f_0+2f_1+\cdots+f_N\right)\\ &\quad+\tfrac{h^2}{12}\left(f'(a)-f'(b)\right)\\ &\quad+E,\end{aligned} with E=(b−a)h4720f(4)(η)E=\dfrac{(b-a)h^4}{720}f^{(4)}(\eta), a<η<ba<\eta<b. This is the trapezoidal rule with an end correction; it is of order h4h^4 instead of h2h^2.

✓ Checked by computer We checked by computer (SymPy): with p=1/12p=1/12 the rule is exact for 1,x,x2,x31,x,x^2,x^3 and leaves h5/30h^5/30 for x4x^4, i.e. error h5720f(4)(ξ)\frac{h^5}{720}f^{(4)}(\xi).

↑ Back to the question list

Integrate f(x)=5x3−3x2+2x+1 from x=−2 to x=4 using (i) Simpson’s 38 rule with width h=1, and (ii) Trapezoidal rule with width h=1.

2024 · Paper II · Q7b · 15 marks

Solution

h=1h=1, so the nodes are x=−2,−1,0,1,2,3,4x=-2,-1,0,1,2,3,4 (six sub-intervals):

xx -2 -1 0 1 2 3 4
f(x)f(x) -55 -9 1 5 33 115 281

(i) Simpson’s 38\tfrac38 rule (six sub-intervals, a multiple of 3): ∫−24fdx≈3h8[(f0+f6)+3(f1+f2+f4+f5)+2f3]\begin{aligned}\int_{-2}^{4}f\,dx&\approx\tfrac{3h}{8}\big[(f_0+f_6)\\ &\quad+3(f_1+f_2+f_4+f_5)\\ &\quad+2f_3\big]\end{aligned} =38[(−55+281)+3(−9+1+33+115)+2(5)]\begin{aligned}&=\tfrac38\big[(-55+281)\\ &\quad+3(-9+1+33+115)+2(5)\big]\end{aligned} =38[226+420+10]=38(656)=246.=\frac38\left[226+420+10\right]=\frac38(656)=246.

(ii) Trapezoidal rule: ∫−24fdx≈h2[(f0+f6)+2(f1+⋯+f5)]\begin{aligned}\int_{-2}^{4}f\,dx&\approx\tfrac h2\big[(f_0+f_6)\\ &\quad+2(f_1+\cdots+f_5)\big]\end{aligned} =12[226+2(145)]=258.=\frac12\left[226+2(145)\right]=258.

Comparison. The exact value is [54x4−x3+x2+x]−24=246\left[\tfrac54x^4-x^3+x^2+x\right]_{-2}^{4}=246. Simpson’s 38\tfrac38 rule is exact for cubics, so it gives 246246 exactly; the trapezoidal rule overestimates by 1212.

✓ Checked by computer We checked by computer: the exact integral is 246246; Simpson’s 38\tfrac38 rule gives 246246 and the trapezoidal rule 258258.

↑ Back to the question list

The velocity of a train which starts from rest is given by the following table, the time being reckoned in minutes from the start and the velocity in km/hour : t(minutes)2468101214161820v(km/hour)1628.84046.451.23217.683.20 Using Simpson’s 13rd rule, estimate approximately in km the total distance run in 20 minutes.

2022 · Paper II · Q7b · 15 marks

Solution

Since the train starts from rest, v=0v=0 at t=0t=0. Distance =∫vdt=\int v\,dt. With time in minutes, h=2h=2 and there are 10 sub-intervals (an even number), so Simpson’s 13\tfrac13 rule applies:

tt (min) 0 2 4 6 8 10 12 14 16 18 20
vv (km/h) 0 16 28.8 40 46.4 51.2 32 17.6 8 3.2 0

∫020vdt≈h3[(v0+v10)+4(v1+v3+⋯+v9)+2(v2+v4+⋯+v8)]\begin{aligned}\int_0^{20}v\,dt&\approx\frac h3\big[(v_0+v_{10})\\ &\quad+4(v_1+v_3+\cdots+v_9)\\ &\quad+2(v_2+v_4+\cdots+v_8)\big]\end{aligned}

  • v0+v10=0v_0+v_{10}=0
  • v1+v3+v5+v7+v9=16+40+51.2+17.6+3.2=128v_1+v_3+v_5+v_7+v_9=16+40+51.2+17.6+3.2=128
  • v2+v4+v6+v8=28.8+46.4+32+8=115.2v_2+v_4+v_6+v_8=28.8+46.4+32+8=115.2

∫020vdt≈23[4(128)+2(115.2)]=23(742.4)=494.93.\begin{aligned}\int_0^{20}v\,dt&\approx\tfrac23\left[4(128)+2(115.2)\right]\\ &=\tfrac23(742.4)=494.93.\end{aligned} The unit here is (km/h)·min, so divide by 60: distance≈494.9360≈8.25km.\text{distance}\approx\frac{494.93}{60}\approx8.25\ \text{km}.

✓ Checked by computer We checked by computer: Simpson’s rule on the eleven values gives 494.9333494.9333 (km/h)·min =8.2489=8.2489 km.

↑ Back to the question list

Find a quadrature formula ∫01f(x)dxx(1−x)=α1f(0)+α2f(12)+α3f(1) which is exact for polynomials of highest possible degree. Then use the formula to evaluate ∫01dxx−x3 (correct up to three decimal places).

2020 · Paper II · Q7b · 20 marks

Solution

Moments. Put x=sin2θx=\sin^2\theta, so dx/x(1−x)=2dθdx/\sqrt{x(1-x)}=2\,d\theta and μk=∫01xkdxx(1−x)=2∫0π/2sin2kθdθ.\mu_k=\int_0^1\frac{x^k\,dx}{\sqrt{x(1-x)}}=2\int_0^{\pi/2}\sin^{2k}\theta\,d\theta . By Wallis’ formula: μ0=π\mu_0=\pi, μ1=π2\mu_1=\tfrac\pi2, μ2=3π8\mu_2=\tfrac{3\pi}{8}, μ3=5π16\mu_3=\tfrac{5\pi}{16}, μ4=35π128\mu_4=\tfrac{35\pi}{128}.

Weights. Exactness for 1,x,x21,x,x^2: α1+α2+α3=π12α2+α3=π214α2+α3=3π8\begin{aligned}\alpha_1+\alpha_2+\alpha_3&=\pi\\ \tfrac12\alpha_2+\alpha_3&=\tfrac\pi2\\ \tfrac14\alpha_2+\alpha_3&=\tfrac{3\pi}{8}\end{aligned} Subtracting the last two: 14α2=π8\tfrac14\alpha_2=\tfrac\pi8, so α2=π2\alpha_2=\tfrac\pi2, then α3=π4\alpha_3=\tfrac\pi4, α1=π4\alpha_1=\tfrac\pi4: ∫01f(x)dxx(1−x)≈π4f(0)+π2f(12)+π4f(1).\begin{aligned}\int_0^1\frac{f(x)\,dx}{\sqrt{x(1-x)}}&\approx\frac\pi4f(0)+\frac\pi2f\!\left(\tfrac12\right)\\ &\quad+\frac\pi4f(1).\end{aligned} Highest degree. For x3x^3: π2⋅18+π4=5π16=μ3\tfrac\pi2\cdot\tfrac18+\tfrac\pi4=\tfrac{5\pi}{16}=\mu_3 – exact. For x4x^4: π2⋅116+π4=9π32≠35π128\tfrac\pi2\cdot\tfrac1{16}+\tfrac\pi4=\tfrac{9\pi}{32}\ne\tfrac{35\pi}{128}. So the formula is exact for all polynomials of degree ≤3\le3 – the highest possible with these three nodes.

Application. x−x3=x(1−x)(1+x)x-x^3=x(1-x)(1+x), so ∫01dxx−x3=∫01f(x)dxx(1−x),\int_0^1\frac{dx}{\sqrt{x-x^3}}=\int_0^1\frac{f(x)\,dx}{\sqrt{x(1-x)}}, with f(x)=11+xf(x)=\dfrac1{\sqrt{1+x}}. f(0)=1f(0)=1, f(12)=2/3=0.816497f(\tfrac12)=\sqrt{2/3}=0.816497, f(1)=0.707107f(1)=0.707107: I≈π4(1)+π2(0.816497)+π4(0.707107)=0.785398+1.282549+0.555360≈2.623.\begin{aligned}I&\approx\tfrac\pi4(1)+\tfrac\pi2(0.816497)\\ &\quad+\tfrac\pi4(0.707107)\\ &=0.785398+1.282549+0.555360\\ &\approx2.623.\end{aligned} (For comparison, accurate numerical integration gives 2.62212.6221.)

✓ Checked by computer We checked by computer: the moments are π,π/2,3π/8,5π/16,35π/128\pi,\ \pi/2,\ 3\pi/8,\ 5\pi/16,\ 35\pi/128; the weights are π/4,π/2,π/4\pi/4,\ \pi/2,\ \pi/4; the formula gives 2.623312.62331, and numerical integration gives 2.622062.62206.

↑ Back to the question list

Draw a flow chart and write a basic algorithm (in FORTRAN/C/C++) for evaluating y=∫06dx1+x2 using Trapezoidal rule.

2019 · Paper II · Q5e · 10 marks

Solution

Trapezoidal rule. With h=(b−a)/nh=(b-a)/n and xi=a+ihx_i=a+ih, y≈h2[f(x0)+f(xn)+2(f(x1)+⋯+f(xn−1))],\begin{aligned}y&\approx\frac h2\big[f(x_0)+f(x_n)\\ &\quad+2\left(f(x_1)+\cdots+f(x_{n-1})\right)\big],\end{aligned} with f(x)=11+x2f(x)=\dfrac{1}{1+x^2}. Algorithm

  1. Read nn; set a=0a=0, b=6b=6, h=(b−a)/nh=(b-a)/n.
  2. s←f(a)+f(b)s\leftarrow f(a)+f(b).
  3. For i=1i=1 to n−1n-1: s←s+2f(a+ih)s\leftarrow s+2f(a+ih).
  4. y←h2sy\leftarrow \tfrac h2\,s; print yy.
StartRead a = 0, b = 6, nh ← (b − a)/ns ← f(a) + f(b), i ← 1s ← s + 2·f(a + i·h)i ← i + 1i ≤ n − 1 ?NoYesy ← (h/2)·sPrint yStop
Trapezoidal rule, f(x) = 1/(1 + x²)

Program (C)

/* Trapezoidal rule for y = integral of 1/(1+x*x) from 0 to 6 */
#include <stdio.h>
double f(double x) { return 1.0/(1.0 + x*x); }
int main(void) {
    double a = 0.0, b = 6.0, h, s, y;
    int n, i;
    printf("Number of sub-intervals n: ");
    scanf("%d", &n);
    h = (b - a)/n;
    s = f(a) + f(b);
    for (i = 1; i <= n - 1; i++)
        s = s + 2.0*f(a + i*h);
    y = h/2.0*s;
    printf("Integral = %f\n", y);
    return 0;
}

With n=6n=6 (h=1h=1) the program prints y≈1.4108y\approx1.4108; the exact value is tan−16≈1.4056\tan^{-1}6\approx1.4056, and larger nn brings the result closer.

✓ Checked by computer We ran the same loop in Python: n=6n=6 gives 1.4107991.410799, n=60n=60 gives 1.4056401.405640; the exact value is tan−16=1.405648\tan^{-1}6=1.405648.

↑ Back to the question list

Time (Minutes)2468101214161820Speed (Km/h)10182529322011528.5 Starting from rest in the beginning, the speed (in Km/h) of a train at different times (in minutes) is given by the above table : Using Simpson’s 13rd rule, find the approximate distance travelled (in Km) in 20 minutes from the beginning.

2018 · Paper II · Q5d · 10 marks

Solution

The train starts from rest, so v=0v=0 at t=0t=0. Then h=2h=2 min and there are 10 sub-intervals:

tt (min) 0 2 4 6 8 10 12 14 16 18 20
vv (km/h) 0 10 18 25 29 32 20 11 5 2 8.5

Simpson’s 13\tfrac13 rule:

  • v0+v10=0+8.5=8.5v_0+v_{10}=0+8.5=8.5
  • v1+v3+v5+v7+v9=10+25+32+11+2=80v_1+v_3+v_5+v_7+v_9=10+25+32+11+2=80
  • v2+v4+v6+v8=18+29+20+5=72v_2+v_4+v_6+v_8=18+29+20+5=72

∫020vdt≈23[8.5+4(80)+2(72)]=23(472.5)=315.\begin{aligned}\int_0^{20}v\,dt&\approx\tfrac23\left[8.5+4(80)+2(72)\right]\\ &=\tfrac23(472.5)=315.\end{aligned} Converting minutes to hours, distance≈31560=5.25km.\text{distance}\approx\frac{315}{60}=5.25\ \text{km}.

✓ Checked by computer We checked by computer: Simpson’s rule gives 315.0000315.0000 (km/h)·min =5.2500=5.2500 km.

↑ Back to the question list

Find the values of the constants a, b, c such that the quadrature formula ∫ohf(x)dx=h[af(o)+bf(h3)+cf(h)] is exact for polynomials of as high degree as possible, and hence find the order of the truncation error.

2018 · Paper II · Q7b · 15 marks

Solution

Make the rule exact for f=1,x,x2f=1,x,x^2:

  • f=1f=1: h=h(a+b+c)h=h(a+b+c), so a+b+c=1a+b+c=1.
  • f=xf=x: h22=h(bh3+ch)\tfrac{h^2}{2}=h\left(\tfrac{bh}{3}+ch\right), so b3+c=12\tfrac b3+c=\tfrac12.
  • f=x2f=x^2: h33=h(bh29+ch2)\tfrac{h^3}{3}=h\left(\tfrac{bh^2}{9}+ch^2\right), so b9+c=13\tfrac b9+c=\tfrac13.

Subtracting the last two: 2b9=16\tfrac{2b}{9}=\tfrac16, so b=34b=\tfrac34; then c=12−14=14c=\tfrac12-\tfrac14=\tfrac14 and a=1−34−14=0a=1-\tfrac34-\tfrac14=0: ∫0hf(x)dx≈h[34f(h3)+14f(h)],\int_0^hf(x)\,dx\approx h\left[\tfrac34f\!\left(\tfrac h3\right)+\tfrac14f(h)\right], that is, a=0,b=34,c=14a=0,\ b=\tfrac34,\ c=\tfrac14. Degree of exactness. For f=x3f=x^3: exact value h44\tfrac{h^4}{4}, formula h(34⋅h327+14h3)=5h418h\left(\tfrac34\cdot\tfrac{h^3}{27}+\tfrac14h^3\right)=\tfrac{5h^4}{18}. These differ, so the rule is exact for polynomials of degree ≤2\le2 only.

Truncation error. The error is E=Cf‴(ξ)E=C\,f'''(\xi), and f=x3f=x^3 (f‴=6f'''=6) gives 6C=h44−5h418=−h4366C=\tfrac{h^4}{4}-\tfrac{5h^4}{18}=-\tfrac{h^4}{36}: E=−h4216f‴(ξ),0<ξ<h.E=-\frac{h^4}{216}f'''(\xi),\qquad 0<\xi<h . So the error is of order h4h^4 on one step (order h3h^3 when the rule is used repeatedly over a fixed interval). (This is the Radau-type rule with the fixed node at x=hx=h.)

✓ Checked by computer We checked by computer (SymPy): a=0,b=34,c=14a=0,\ b=\tfrac34,\ c=\tfrac14 integrate 1,x,x21,x,x^2 exactly, and leave −h4/36-h^4/36 for x3x^3.

↑ 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

Derive the formula ∫abydx=3h8[(y0+yn)+3(y1+y2+y4+y5+⋯+yn−1)+2(y3+y6+⋯+yn−3)]. Is there any restriction on n? State that condition. What is the error bound in the case of Simpson’s 38 rule?

2017 · Paper II · Q7b · 20 marks

Solution

One panel (Simpson’s 38\tfrac38 rule). Take four equally spaced points x0,x0+h,x0+2h,x0+3hx_0,x_0+h,x_0+2h,x_0+3h, put x=x0+phx=x_0+ph, and integrate Newton’s forward cubic from p=0p=0 to 33: ∫x0x3ydx=h∫03[y0+pΔy0+p(p−1)2Δ2y0+p(p−1)(p−2)6Δ3y0]dp.\begin{aligned}\int_{x_0}^{x_3}y\,dx&=h\int_0^3\Big[y_0+p\Delta y_0\\ &\qquad+\tfrac{p(p-1)}{2}\Delta^2y_0\\ &\qquad+\tfrac{p(p-1)(p-2)}{6}\Delta^3y_0\Big]dp .\end{aligned} The four integrals are 3,92,94,383,\ \tfrac92,\ \tfrac94,\ \tfrac38, so ∫x0x3ydx=h[3y0+92Δy0+94Δ2y0+38Δ3y0].\begin{aligned}\int_{x_0}^{x_3}y\,dx&=h\big[3y_0+\tfrac92\Delta y_0\\ &\quad+\tfrac94\Delta^2y_0+\tfrac38\Delta^3y_0\big].\end{aligned} Writing the differences in terms of y0,…,y3y_0,\dots,y_3: ∫x0x3ydx=3h8(y0+3y1+3y2+y3).\int_{x_0}^{x_3}y\,dx=\frac{3h}{8}\left(y_0+3y_1+3y_2+y_3\right). Composite rule. Divide [a,b][a,b] into nn equal parts, h=(b−a)/nh=(b-a)/n, and apply this to [x0,x3],[x3,x6],…,[xn−3,xn][x_0,x_3],[x_3,x_6],\dots,[x_{n-3},x_n]. Adding, each interior “junction” ordinate y3,y6,…,yn−3y_3,y_6,\dots,y_{n-3} appears in two panels (coefficient 1+1=21+1=2), every other interior ordinate once with coefficient 3: ∫abydx=3h8S,\int_a^by\,dx=\frac{3h}{8}\,S, where S=(y0+yn)+3(y1+y2+y4+⋯+yn−1)+2(y3+y6+⋯+yn−3).\begin{aligned}S&=(y_0+y_n)\\ &\quad+3(y_1+y_2+y_4+\cdots+y_{n-1})\\ &\quad+2(y_3+y_6+\cdots+y_{n-3}).\end{aligned} Restriction: the panels use 3 sub-intervals each, so nn must be a multiple of 3.

Error. For one panel the error is E=−3h580f(4)(ξ),x0<ξ<x3E=-\frac{3h^5}{80}f^{(4)}(\xi),\qquad x_0<\xi<x_3 (test with f=x4f=x^4 on [0,3h][0,3h]: exact 243h55\tfrac{243h^5}{5}, rule 3h8(3h4+48h4+81h4)=99h52\tfrac{3h}{8}(3h^4+48h^4+81h^4)=\tfrac{99h^5}{2}, difference −9h510=24⋅(−3h580)-\tfrac{9h^5}{10}=24\cdot\left(-\tfrac{3h^5}{80}\right)). Over n/3n/3 panels the errors add up to |E|≤(b−a)h480maxa≤x≤b|f(4)(x)|.|E|\le\frac{(b-a)h^4}{80}\max_{a\le x\le b}|f^{(4)}(x)| .

✓ Proof checked step by step We checked the composite formula and the panel error −3h580f(4)-\frac{3h^5}{80}f^{(4)} in SymPy (integrating the cubic through four points, and testing f=x4f=x^4).

↑ Back to the question list

For an integral ∫−11f(x)dx, show that the two-point Gauss quadrature rule is given by ∫−11f(x)dx=f(13)+f(−13). Using this rule, estimate ∫242xexdx.

2016 · Paper II · Q7c · 15 marks

Solution

Deriving the rule. Seek ∫−11fdx≈w1f(x1)+w2f(x2)\int_{-1}^1f\,dx\approx w_1f(x_1)+w_2f(x_2) exact for 1,x,x2,x31,x,x^2,x^3 (four conditions, four unknowns): w1+w2=2w1x1+w2x2=0w1x12+w2x22=23w1x13+w2x23=0\begin{aligned}w_1+w_2&=2\\ w_1x_1+w_2x_2&=0\\ w_1x_1^2+w_2x_2^2&=\tfrac23\\ w_1x_1^3+w_2x_2^3&=0\end{aligned} From the 2nd and 4th: w1x1(x12−x22)=0w_1x_1(x_1^2-x_2^2)=0, and since x1≠x2x_1\neq x_2 and x1≠0x_1\neq0 (else the 3rd fails), x2=−x1x_2=-x_1. Then the 2nd gives w1=w2=1w_1=w_2=1, and the 3rd gives 2x12=232x_1^2=\tfrac23, x1=13x_1=\tfrac1{\sqrt3}. Hence ∫−11f(x)dx≈f(13)+f(−13),\int_{-1}^1f(x)\,dx\approx f\!\left(\tfrac1{\sqrt3}\right)+f\!\left(-\tfrac1{\sqrt3}\right), exact for polynomials of degree ≤3\le3.

Estimate of ∫242xexdx\int_2^42xe^x\,dx. Map [2,4][2,4] to [−1,1][-1,1] by x=3+tx=3+t, dx=dtdx=dt: ∫242xexdx=∫−11g(t)dt,\int_2^42xe^x\,dx=\int_{-1}^1g(t)\,dt, where g(t)=2(3+t)e3+tg(t)=2(3+t)e^{3+t}.

  • g(0.577350)=2(3.577350)e3.577350=255.9853g(0.577350)=2(3.577350)e^{3.577350}=255.9853
  • g(−0.577350)=2(2.422650)e2.422650=54.6341g(-0.577350)=2(2.422650)e^{2.422650}=54.6341

∫242xexdx≈310.62.\int_2^42xe^x\,dx\approx310.62. (Exact: [2(x−1)ex]24=6e4−2e2≈312.81\left[2(x-1)e^x\right]_2^4=6e^4-2e^2\approx312.81; the error is about 0.70%0.70\%.)

✓ Checked by computer We checked by computer: the two-point rule gives 310.6194310.6194 and the exact value is 6e4−2e2=312.81086e^4-2e^2=312.8108.

↑ Back to the question list

Use five subintervals to integrate ∫01dx1+x2 using trapezoidal rule.

2014 · Paper II · Q5c · 10 marks

Solution

Five sub-intervals: h=0.2h=0.2.

xx 0.0 0.2 0.4 0.6 0.8 1.0
f(x)=11+x2f(x)=\frac1{1+x^2} 1.000000 0.961538 0.862069 0.735294 0.609756 0.500000

∫01dx1+x2≈h2[(f0+f5)+2(f1+f2+f3+f4)]\begin{aligned}\int_0^1\frac{dx}{1+x^2}&\approx\frac h2\big[(f_0+f_5)\\ &\quad+2(f_1+f_2+f_3+f_4)\big]\end{aligned} =0.1[1.5+2(3.168658)]=0.7837.=0.1\left[1.5+2(3.168658)\right]=0.7837. (The exact value is π/4≈0.7854\pi/4\approx0.7854.)

✓ Checked by computer We checked by computer: the trapezoidal sum is 0.7837320.783732; the exact value is π/4=0.785398\pi/4=0.785398.

↑ Back to the question list

Draw a flowchart for Simpson’s one-third rule.

2014 · Paper II · Q7b · 15 marks

Solution

Simpson’s 13\tfrac13 rule (nn even, h=(b−a)/nh=(b-a)/n, xi=a+ihx_i=a+ih): ∫abfdx≈h3[f0+fn+4(f1+f3+⋯+fn−1)+2(f2+f4+⋯+fn−2)].\begin{aligned}\int_a^bf\,dx&\approx\frac h3\big[f_0+f_n\\ &\quad+4(f_1+f_3+\cdots+f_{n-1})\\ &\quad+2(f_2+f_4+\cdots+f_{n-2})\big].\end{aligned}

StartRead a, b, n (n even)h ← (b − a)/ns ← f(a) + f(b), i ← 1i odd ?Yess ← s + 4·f(a + ih)Nos ← s + 2·f(a + ih)i ← i + 1i ≤ n − 1 ?NoYesI ← (h/3)·sPrint IStop
Simpson’s ⅓ rule: odd-numbered ordinates get weight 4, even-numbered interior ordinates weight 2

✓ Checked by computer We ran the same steps in Python on ∫01dx1+x2\int_0^1\frac{dx}{1+x^2} with n=10n=10: the result is 0.7853980.785398, matching π/4\pi/4 to six decimals.

↑ Back to the question list

The velocity of a train which starts from rest is given in the following table. The time is in minutes and velocity is in km/hour. t2468101214161820v1628.84046.451.232.017.683.20 Estimate approximately the total distance run in 30 minutes by using composite Simpson’s 13 rule.

2013 · Paper II · Q7c · 15 marks

Solution

Since the train starts from rest, v=0v=0 at t=0t=0. Distance =∫vdt=\int v\,dt. With time in minutes, h=2h=2 and there are 10 sub-intervals (an even number), so Simpson’s 13\tfrac13 rule applies:

tt (min) 0 2 4 6 8 10 12 14 16 18 20
vv (km/h) 0 16 28.8 40 46.4 51.2 32 17.6 8 3.2 0

∫020vdt≈h3[(v0+v10)+4(v1+v3+⋯+v9)+2(v2+v4+⋯+v8)]\begin{aligned}\int_0^{20}v\,dt&\approx\frac h3\big[(v_0+v_{10})\\ &\quad+4(v_1+v_3+\cdots+v_9)\\ &\quad+2(v_2+v_4+\cdots+v_8)\big]\end{aligned}

  • v0+v10=0v_0+v_{10}=0
  • v1+v3+v5+v7+v9=16+40+51.2+17.6+3.2=128v_1+v_3+v_5+v_7+v_9=16+40+51.2+17.6+3.2=128
  • v2+v4+v6+v8=28.8+46.4+32+8=115.2v_2+v_4+v_6+v_8=28.8+46.4+32+8=115.2

∫020vdt≈23[4(128)+2(115.2)]=23(742.4)=494.93.\begin{aligned}\int_0^{20}v\,dt&\approx\tfrac23\left[4(128)+2(115.2)\right]\\ &=\tfrac23(742.4)=494.93.\end{aligned} The unit here is (km/h)·min, so divide by 60: distance≈494.9360≈8.25km.\text{distance}\approx\frac{494.93}{60}\approx8.25\ \text{km}.

About “30 minutes”. The table stops at t=20t=20 minutes, where the velocity is 0 – the train has come to rest. With no further data, we take it to stay at rest, so the distance run in 30 minutes is the same, about 8.25 km. (The same table appears in the 2022 question, which asks for 20 minutes.)

✓ Checked by computer We checked by computer: Simpson’s rule on the eleven values gives 494.9333494.9333 (km/h)·min =8.2489=8.2489 km.

↑ Back to the question list

Calculate ∫210dx1+x (upto 3 places of decimal) by dividing the range into 8 equal parts by Simpson’s 13rd Rule.

2011 · Paper II · Q5c · 12 marks

Solution

Eight equal parts: h=1h=1, x=2,3,…,10x=2,3,\dots,10.

xx 2 3 4 5 6 7 8 9 10
11+x\frac1{1+x} 0.33333 0.25000 0.20000 0.16667 0.14286 0.12500 0.11111 0.10000 0.09091
  • y0+y8=0.33333+0.09091=0.42424y_0+y_8=0.33333+0.09091=0.42424
  • y1+y3+y5+y7=0.64167y_1+y_3+y_5+y_7=0.64167
  • y2+y4+y6=0.45397y_2+y_4+y_6=0.45397

Hence I=∫210dx1+xI=\int_2^{10}\frac{dx}{1+x} is I≈13[0.42424+4(0.64167)+2(0.45397)]=1.300.\begin{aligned}I&\approx\tfrac13\big[0.42424\\ &\quad+4(0.64167)+2(0.45397)\big]\\ &=1.300.\end{aligned} (Exact: ln113=1.2993\ln\tfrac{11}{3}=1.2993.)

✓ Checked by computer We checked by computer: Simpson’s rule gives 1.2996151.299615; the exact value is ln(11/3)=1.299283\ln(11/3)=1.299283.

↑ Back to the question list

A solid of revolution is formed by rotating about the x-axis, the area between the x-axis, the line x=0 and x=1 and a curve through the points with the following co-ordinates : x.00.25.50.751y1.9896.9589.9089.8415 Find the volume of the solid.

2011 · Paper II · Q7a · 20 marks

Solution

The volume of revolution about the xx-axis is V=π∫01y2dx.V=\pi\int_0^1y^2\,dx . Square the ordinates (h=0.25h=0.25):

xx 0 0.25 0.50 0.75 1
yy 1 0.9896 0.9589 0.9089 0.8415
y2y^2 1.000000 0.979308 0.919489 0.826099 0.708122

Simpson’s 13\tfrac13 rule (four sub-intervals): ∫01y2dx≈0.253[(y02+y42)+4(y12+y32)+2y22]\begin{aligned}\int_0^1y^2dx&\approx\frac{0.25}{3}\big[(y_0^2+y_4^2)\\ &\quad+4(y_1^2+y_3^2)+2y_2^2\big]\end{aligned} =0.253[1.708122+4(1.805407)+2(0.919489)]=0.897394.\begin{aligned}&=\tfrac{0.25}{3}\big[1.708122\\ &\quad+4(1.805407)+2(0.919489)\big]\\ &=0.897394.\end{aligned} V≈π×0.897394≈2.8192cubic units.V\approx\pi\times0.897394\approx2.8192\ \text{cubic units}.

✓ Checked by computer We checked by computer: π×0.897394=2.819247\pi\times0.897394=2.819247. (The ordinates are those of y=sinxxy=\frac{\sin x}{x}, for which π∫01y2dx=2.8191\pi\int_0^1y^2dx=2.8191.)

↑ Back to the question list

Find the value of the integral ∫15log10xdx by using Simpson’s 13-rule correct up to 4 decimal places. Take 8 subintervals in your computation.

2010 · Paper II · Q7b · 20 marks

Solution

Eight sub-intervals: h=5−18=0.5h=\dfrac{5-1}{8}=0.5.

xx log10x\log_{10}x
1 0.000000
1.5 0.176091
2 0.301030
2.5 0.397940
3 0.477121
3.5 0.544068
4 0.602060
4.5 0.653213
5 0.698970
  • y0+y8=0.698970y_0+y_8=0.698970
  • y1+y3+y5+y7=1.771312y_1+y_3+y_5+y_7=1.771312
  • y2+y4+y6=1.380211y_2+y_4+y_6=1.380211

∫15log10xdx≈0.53[0.69897+4(1.771312)+2(1.380211)]\begin{aligned}\int_1^5\log_{10}x\,dx&\approx\tfrac{0.5}{3}\big[0.69897\\ &\quad+4(1.771312)\\ &\quad+2(1.380211)\big]\end{aligned} ≈1.7574.\approx1.7574. (Exact: [xlog10x−xlog10e]15=1.7577\left[x\log_{10}x-x\log_{10}e\right]_1^5=1.7577.)

✓ Checked by computer We checked by computer: Simpson’s rule gives 1.7574401.757440; the exact value is 5log105−4log10e=1.7576725\log_{10}5-4\log_{10}e=1.757672.

↑ Back to the question list

More on Numerical Analysis and Computer Programming

Questions: UPSC Civil Services (Main) Examination, Mathematics Paper II, 2010–2026. 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