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
Evaluate the integral , where by using single application of Simpson’s rule.
Solution
One application of Simpson’s rule uses four points, so :
| 0.000000 | 0.200000 |
| 0.266667 | 1.432724 |
| 0.533333 | 3.487177 |
| 0.800000 | 0.232000 |
(The exact value is ; the rule is exact only up to cubics, and is of degree 5, so an error of about remains with a single application.)
✓ Checked by computer We checked by computer: the rule gives ; the exact integral is .
Find the constant and error term for the quadrature formula where , , and prime () represents derivative with respect to . Hence deduce the composite rule for integrating
Solution
Shift so that , , and make the rule exact for as far as possible.
- : – true for any .
- : – true.
- : , so and
- : left ; right – also exact (a bonus degree, by symmetry).
- : left ; right . The difference is .
So the rule is exact up to degree 3, and the error is with : where . Composite rule. With , , add the rule over , . The derivative terms telescope: Hence with , . This is the trapezoidal rule with an end correction; it is of order instead of .
✓ Checked by computer We checked by computer (SymPy): with the rule is exact for and leaves for , i.e. error .
Integrate from to using (i) Simpson’s rule with width , and (ii) Trapezoidal rule with width .
Solution
, so the nodes are (six sub-intervals):
| -2 | -1 | 0 | 1 | 2 | 3 | 4 | |
|---|---|---|---|---|---|---|---|
| -55 | -9 | 1 | 5 | 33 | 115 | 281 |
(i) Simpson’s rule (six sub-intervals, a multiple of 3):
(ii) Trapezoidal rule:
Comparison. The exact value is . Simpson’s rule is exact for cubics, so it gives exactly; the trapezoidal rule overestimates by .
✓ Checked by computer We checked by computer: the exact integral is ; Simpson’s rule gives and the trapezoidal rule .
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 : Using Simpson’s rd rule, estimate approximately in km the total distance run in 20 minutes.
Solution
Since the train starts from rest, at . Distance . With time in minutes, and there are 10 sub-intervals (an even number), so Simpson’s rule applies:
| (min) | 0 | 2 | 4 | 6 | 8 | 10 | 12 | 14 | 16 | 18 | 20 |
|---|---|---|---|---|---|---|---|---|---|---|---|
| (km/h) | 0 | 16 | 28.8 | 40 | 46.4 | 51.2 | 32 | 17.6 | 8 | 3.2 | 0 |
The unit here is (km/h)·min, so divide by 60:
✓ Checked by computer We checked by computer: Simpson’s rule on the eleven values gives (km/h)·min km.
Find a quadrature formula which is exact for polynomials of highest possible degree. Then use the formula to evaluate (correct up to three decimal places).
Solution
Moments. Put , so and By Wallis’ formula: , , , , .
Weights. Exactness for : Subtracting the last two: , so , then , : Highest degree. For : – exact. For : . So the formula is exact for all polynomials of degree – the highest possible with these three nodes.
Application. , so with . , , : (For comparison, accurate numerical integration gives .)
✓ Checked by computer We checked by computer: the moments are ; the weights are ; the formula gives , and numerical integration gives .
Draw a flow chart and write a basic algorithm (in FORTRAN/C/C) for evaluating using Trapezoidal rule.
Solution
Trapezoidal rule. With and , with . Algorithm
- Read ; set , , .
- .
- For to : .
- ; print .
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 () the program prints ; the exact value is , and larger brings the result closer.
✓ Checked by computer We ran the same loop in Python: gives , gives ; the exact value is .
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 rd rule, find the approximate distance travelled (in Km) in 20 minutes from the beginning.
Solution
The train starts from rest, so at . Then min and there are 10 sub-intervals:
| (min) | 0 | 2 | 4 | 6 | 8 | 10 | 12 | 14 | 16 | 18 | 20 |
|---|---|---|---|---|---|---|---|---|---|---|---|
| (km/h) | 0 | 10 | 18 | 25 | 29 | 32 | 20 | 11 | 5 | 2 | 8.5 |
Simpson’s rule:
Converting minutes to hours,
✓ Checked by computer We checked by computer: Simpson’s rule gives (km/h)·min km.
Find the values of the constants , , such that the quadrature formula is exact for polynomials of as high degree as possible, and hence find the order of the truncation error.
Solution
Make the rule exact for :
- : , so .
- : , so .
- : , so .
Subtracting the last two: , so ; then and : that is, . Degree of exactness. For : exact value , formula . These differ, so the rule is exact for polynomials of degree only.
Truncation error. The error is , and () gives : So the error is of order on one step (order when the rule is used repeatedly over a fixed interval). (This is the Radau-type rule with the fixed node at .)
✓ Checked by computer We checked by computer (SymPy): integrate exactly, and leave for .
Derive the formula Is there any restriction on ? State that condition. What is the error bound in the case of Simpson’s rule?
Solution
One panel (Simpson’s rule). Take four equally spaced points , put , and integrate Newton’s forward cubic from to : The four integrals are , so Writing the differences in terms of : Composite rule. Divide into equal parts, , and apply this to . Adding, each interior “junction” ordinate appears in two panels (coefficient ), every other interior ordinate once with coefficient 3: where Restriction: the panels use 3 sub-intervals each, so must be a multiple of 3.
Error. For one panel the error is (test with on : exact , rule , difference ). Over panels the errors add up to
✓ Proof checked step by step We checked the composite formula and the panel error in SymPy (integrating the cubic through four points, and testing ).
For an integral , show that the two-point Gauss quadrature rule is given by . Using this rule, estimate .
Solution
Deriving the rule. Seek exact for (four conditions, four unknowns): From the 2nd and 4th: , and since and (else the 3rd fails), . Then the 2nd gives , and the 3rd gives , . Hence exact for polynomials of degree .
Estimate of . Map to by , : where .
(Exact: ; the error is about .)
✓ Checked by computer We checked by computer: the two-point rule gives and the exact value is .
Use five subintervals to integrate using trapezoidal rule.
Solution
Five sub-intervals: .
| 0.0 | 0.2 | 0.4 | 0.6 | 0.8 | 1.0 | |
|---|---|---|---|---|---|---|
| 1.000000 | 0.961538 | 0.862069 | 0.735294 | 0.609756 | 0.500000 |
(The exact value is .)
✓ Checked by computer We checked by computer: the trapezoidal sum is ; the exact value is .
Draw a flowchart for Simpson’s one-third rule.
Solution
Simpson’s rule ( even, , ):
✓ Checked by computer We ran the same steps in Python on with : the result is , matching to six decimals.
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. Estimate approximately the total distance run in 30 minutes by using composite Simpson’s rule.
Solution
Since the train starts from rest, at . Distance . With time in minutes, and there are 10 sub-intervals (an even number), so Simpson’s rule applies:
| (min) | 0 | 2 | 4 | 6 | 8 | 10 | 12 | 14 | 16 | 18 | 20 |
|---|---|---|---|---|---|---|---|---|---|---|---|
| (km/h) | 0 | 16 | 28.8 | 40 | 46.4 | 51.2 | 32 | 17.6 | 8 | 3.2 | 0 |
The unit here is (km/h)·min, so divide by 60:
About “30 minutes”. The table stops at 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 (km/h)·min km.
Calculate (upto 3 places of decimal) by dividing the range into 8 equal parts by Simpson’s rd Rule.
Solution
Eight equal parts: , .
| 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | |
|---|---|---|---|---|---|---|---|---|---|
| 0.33333 | 0.25000 | 0.20000 | 0.16667 | 0.14286 | 0.12500 | 0.11111 | 0.10000 | 0.09091 |
Hence is (Exact: .)
✓ Checked by computer We checked by computer: Simpson’s rule gives ; the exact value is .
A solid of revolution is formed by rotating about the -axis, the area between the -axis, the line and and a curve through the points with the following co-ordinates : Find the volume of the solid.
Solution
The volume of revolution about the -axis is Square the ordinates ():
| 0 | 0.25 | 0.50 | 0.75 | 1 | |
|---|---|---|---|---|---|
| 1 | 0.9896 | 0.9589 | 0.9089 | 0.8415 | |
| 1.000000 | 0.979308 | 0.919489 | 0.826099 | 0.708122 |
Simpson’s rule (four sub-intervals):
✓ Checked by computer We checked by computer: . (The ordinates are those of , for which .)
Find the value of the integral by using Simpson’s -rule correct up to 4 decimal places. Take 8 subintervals in your computation.
Solution
Eight sub-intervals: .
| 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 |
(Exact: .)
✓ Checked by computer We checked by computer: Simpson’s rule gives ; the exact value is .
More on Numerical Analysis and Computer Programming
- Numerical Analysis and Computer Programming topic-wise PYQs (questions only, for practice)
- Mathematics PYQ analysis: which units carry the marks year by year
- Year-wise question papers
- Mathematics booklist
Questions: UPSC Civil Services (Main) Examination, Mathematics Paper II, 2010–2026. Solutions: Optional Province. Found an error? Tell us.

