Menu Close

Solution of equations: UPSC Maths Optional PYQ Solutions (2008–2026)

All 28 questions UPSC has asked on numerical solution of algebraic, transcendental and linear equations in the Mathematics Optional (Paper II, Numerical Analysis and Computer Programming) from 2008 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 · 5b 2025 · 5b 2024 · 5b 2023 · 6b 2023 · 8b 2022 · 5b 2021 · 5b 2021 · 7b 2020 · 5b 2020 · 6b 2019 · 5b 2019 · 7b 2018 · 5e 2017 · 5b 2017 · 8b 2015 · 8b 2014 · 5b 2014 · 6b 2013 · 7a 2012 · 5b 2012 · 6c 2010 · 5c 2010 · 7a 2009 · 5c(i) 2009 · 7a 2008 · 5c 2008 · 7a(ii) 2008 · 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

By using the Newton-Raphson iterative formula, establish the formula xi+1=13(2xi+Nxi2) to find the cube root of N. Use this formula, if established, to find the cube root of 63 correct to four decimal places with the initial approximation 3.9.

2026 · Paper II · Q5b · 10 marks

Solution

Finding N3\sqrt[3]{N} means solving f(x)=x3−N=0f(x)=x^3-N=0, with f′(x)=3x2f'(x)=3x^2. The Newton–Raphson step is xi+1=xi−xi3−N3xi2=3xi3−xi3+N3xi2=13(2xi+Nxi2),\begin{aligned}x_{i+1}&=x_i-\frac{x_i^3-N}{3x_i^2}\\ &=\frac{3x_i^3-x_i^3+N}{3x_i^2}\\ &=\frac{1}{3}\left(2x_i+\frac{N}{x_i^2}\right),\end{aligned} which is the required formula.

Cube root of 63. With N=63N=63 and x0=3.9x_0=3.9:

ii xix_i xi+1=13(2xi+63/xi2)x_{i+1}=\frac13\left(2x_i+63/x_i^2\right)
0 3.900000 3.980671
1 3.980671 3.979058
2 3.979058 3.979057
3 3.979057 3.979057

x2x_2 and x3x_3 agree to more than four decimal places, so 633≈3.9791.\sqrt[3]{63}\approx 3.9791 .

✓ Checked by computer We checked by computer: 631/3=3.9790572163^{1/3}=3.97905721, so the iterates settle at 3.97913.9791 to four decimal places.

↑ Back to the question list

Solve the following system of linear equations by Gauss-Seidel method : 10x+2y+z=92x+20y−2z=−44−2x+3y+10z=22

2025 · Paper II · Q5b · 10 marks

Solution

The coefficient matrix is diagonally dominant (10>2+110>2+1, 20>2+220>2+2, 10>2+310>2+3), so Gauss–Seidel converges. Solve each equation for its diagonal unknown: x=110(9−2y−z)y=120(−44−2x+2z)z=110(22+2x−3y)\begin{aligned}x&=\tfrac{1}{10}(9-2y-z)\\ y&=\tfrac{1}{20}(-44-2x+2z)\\ z&=\tfrac{1}{10}(22+2x-3y)\end{aligned} Start from x=y=z=0x=y=z=0 and always use the newest values:

Iteration xx yy zz
1 0.9000 −2.2900 3.0670
2 1.0513 −1.9984 3.0098
3 0.9987 −1.9989 2.9994
4 0.9998 −2.0000 3.0000
5 1.0000 −2.0000 3.0000
6 1.0000 −2.0000 3.0000

The values have settled, so x=1,y=−2,z=3.x=1,\quad y=-2,\quad z=3 .

✓ Checked by computer We checked by computer: the system has the exact solution x=1,y=−2,z=3x=1,\ y=-2,\ z=3, and the iterations above converge to it.

↑ Back to the question list

Solve the following system of linear equations by Gauss-Jordan method : 2x+3y−z=54x+4y−3z=32x−3y+2z=2

2024 · Paper II · Q5b · 10 marks

Solution

In the Gauss–Jordan method we reduce the augmented matrix [A|b][A\,|\,b] until AA becomes the identity; the last column is then the solution. [23−1|544−3|32−32|2]\left[\begin{array}{rrrcr} 2 & 3 & -1 &\vert& 5 \\ 4 & 4 & -3 &\vert& 3 \\ 2 & -3 & 2 &\vert& 2 \end{array}\right] R2→R2−2R1,R3→R3−R1R_2\to R_2-2R_1,\ R_3\to R_3-R_1: [23−1|50−2−1|−70−63|−3]\left[\begin{array}{rrrcr} 2 & 3 & -1 &\vert& 5 \\ 0 & -2 & -1 &\vert& -7 \\ 0 & -6 & 3 &\vert& -3 \end{array}\right]

R2→−12R2R_2\to -\tfrac12 R_2: [23−1|50112|720−63|−3]\left[\begin{array}{rrrcr} 2 & 3 & -1 &\vert& 5 \\ 0 & 1 & \tfrac{1}{2} &\vert& \tfrac{7}{2} \\ 0 & -6 & 3 &\vert& -3 \end{array}\right]

R1→R1−3R2,R3→R3+6R2R_1\to R_1-3R_2,\ R_3\to R_3+6R_2: [20−52|−1120112|72006|18]\left[\begin{array}{rrrcr} 2 & 0 & -\tfrac{5}{2} &\vert& -\tfrac{11}{2} \\ 0 & 1 & \tfrac{1}{2} &\vert& \tfrac{7}{2} \\ 0 & 0 & 6 &\vert& 18 \end{array}\right]

R3→16R3R_3\to \tfrac{1}{6}R_3: [20−52|−1120112|72001|3]\left[\begin{array}{rrrcr} 2 & 0 & -\tfrac{5}{2} &\vert& -\tfrac{11}{2} \\ 0 & 1 & \tfrac{1}{2} &\vert& \tfrac{7}{2} \\ 0 & 0 & 1 &\vert& 3 \end{array}\right]

R1→R1+52R3,R2→R2−12R3R_1\to R_1+\tfrac{5}{2}R_3,\ R_2\to R_2-\tfrac12R_3: [200|2010|2001|3]\left[\begin{array}{rrrcr} 2 & 0 & 0 &\vert& 2 \\ 0 & 1 & 0 &\vert& 2 \\ 0 & 0 & 1 &\vert& 3 \end{array}\right]

R1→12R1R_1\to \tfrac12 R_1: [100|1010|2001|3]\left[\begin{array}{rrrcr} 1 & 0 & 0 &\vert& 1 \\ 0 & 1 & 0 &\vert& 2 \\ 0 & 0 & 1 &\vert& 3 \end{array}\right]

So x=1,y=2,z=3x=1,\ y=2,\ z=3.

Check. 2+6−3=52+6-3=5, 4+8−9=34+8-9=3, 2−6+6=22-6+6=2. ✓

✓ Checked by computer We checked by computer: substituting x=1,y=2,z=3x=1,\ y=2,\ z=3 satisfies all three equations exactly.

↑ Back to the question list

Solve the system of linear equations 7x1−x2+2x3=112x1+8x2−x3=9x1−2x2+9x3=7 correct up to 4 significant figures by the Gauss-Seidel iterative method. Take initially guessed solution as x1=x2=x3=0.

2023 · Paper II · Q6b · 15 marks

Solution

The matrix is diagonally dominant (7>1+27>1+2, 8>2+18>2+1, 9>1+29>1+2), so Gauss–Seidel converges. Write x1=17(11+x2−2x3)x2=18(9−2x1+x3)x3=19(7−x1+2x2)\begin{aligned}x_1&=\tfrac17(11+x_2-2x_3)\\ x_2&=\tfrac18(9-2x_1+x_3)\\ x_3&=\tfrac19(7-x_1+2x_2)\end{aligned} and start from x1=x2=x3=0x_1=x_2=x_3=0:

Iteration x1x_1 x2x_2 x3x_3
1 1.57143 0.73214 0.76587
2 1.45720 0.85643 0.80619
3 1.46344 0.85991 0.80627
4 1.46391 0.85981 0.80619
5 1.46392 0.85979 0.80619
6 1.46392 0.85979 0.80619

The last two iterations agree to four significant figures, so x1≈1.464,x2≈0.8598,x3≈0.8062.x_1\approx 1.464,\quad x_2\approx 0.8598,\quad x_3\approx 0.8062.

✓ Checked by computer We checked by computer: the exact solution is x1=14297≈1.46392x_1=\frac{142}{97}\approx1.46392, x2=417485≈0.85979x_2=\frac{417}{485}\approx0.85979, x3=391485≈0.80619x_3=\frac{391}{485}\approx0.80619.

↑ Back to the question list

Compute a root of the equation log10(2x+1)−x2+3=0, in the interval [0,3], by Regula-Falsi method, correct to 6 decimal places.

2023 · Paper II · Q8b · 15 marks

Solution

Let f(x)=log10(2x+1)−x2+3f(x)=\log_{10}(2x+1)-x^2+3. Then f(0)=3>0f(0)=3>0 and f(3)=log107−6≈−5.1549<0f(3)=\log_{10}7-6\approx-5.1549<0, so there is a root in [0,3][0,3].

Regula–falsi replaces the curve by the chord through (a,f(a))(a,f(a)) and (b,f(b))(b,f(b)): x=af(b)−bf(a)f(b)−f(a),x=\frac{a\,f(b)-b\,f(a)}{f(b)-f(a)}, and keeps the sub-interval on which ff changes sign.

Step aa bb f(a)f(a) f(b)f(b) xx f(x)f(x)
1 0.000000 3.000000 3.000000 −5.154902 1.103631 2.288134
2 1.103631 3.000000 2.288134 −5.154902 1.686611 0.796143
3 1.686611 3.000000 0.796143 −5.154902 1.862319 0.206135
4 1.862319 3.000000 0.206135 −5.154902 1.906064 0.049258
5 1.906064 3.000000 0.049258 −5.154902 1.916418 0.011544
6 1.916418 3.000000 0.011544 −5.154902 1.918839 0.002693
7 1.918839 3.000000 0.002693 −5.154902 1.919404 0.000628
8 1.919404 3.000000 0.000628 −5.154902 1.919535 0.000146
9 1.919535 3.000000 0.000146 −5.154902 1.919566 0.000034
10 1.919566 3.000000 0.000034 −5.154902 1.919573 0.000008
11 1.919573 3.000000 0.000008 −5.154902 1.919575 0.000002
12 1.919575 3.000000 0.000002 −5.154902 1.919575 0.000000
13 1.919575 3.000000 0.000000 −5.154902 1.919575 0.000000
14 1.919575 3.000000 0.000000 −5.154902 1.919575 0.000000

Because f(a)>0f(a)>0 stays at the same end, the left end creeps up to the root while bb stays fixed. The values of xx now agree to six decimal places, so x≈1.919575.x\approx 1.919575.

✓ Checked by computer We checked by computer: a bracketing root-finder gives x=1.91957524x=1.91957524, and ff changes sign only once on [0,3][0,3].

↑ Back to the question list

Solve, by Gauss elimination method, the system of equations 2x+2y+4z=18x+3y+2z=133x+y+3z=14

2022 · Paper II · Q5b · 10 marks

Solution

Reduce the augmented matrix to upper triangular form: [224|18132|13313|14]\left[\begin{array}{rrrcr} 2 & 2 & 4 &\vert& 18 \\ 1 & 3 & 2 &\vert& 13 \\ 3 & 1 & 3 &\vert& 14 \end{array}\right] R2→R2−12R1,R3→R3−32R1R_2\to R_2-\tfrac12R_1,\ R_3\to R_3-\tfrac32R_1: [224|18020|40−2−3|−13]\left[\begin{array}{rrrcr} 2 & 2 & 4 &\vert& 18 \\ 0 & 2 & 0 &\vert& 4 \\ 0 & -2 & -3 &\vert& -13 \end{array}\right]

R3→R3+R2R_3\to R_3+R_2: [224|18020|400−3|−9]\left[\begin{array}{rrrcr} 2 & 2 & 4 &\vert& 18 \\ 0 & 2 & 0 &\vert& 4 \\ 0 & 0 & -3 &\vert& -9 \end{array}\right]

The triangular system is 2x+2y+4z=182y=4−3z=−9\begin{aligned}2x+2y+4z&=18\\ 2y&=4\\ -3z&=-9\end{aligned} Back-substitution: z=3z=3, then y=2y=2, then 2x=18−4−12=22x=18-4-12=2, so x=1x=1. x=1,y=2,z=3.x=1,\quad y=2,\quad z=3 .

✓ Checked by computer We checked by computer: the system has the unique solution x=1,y=2,z=3x=1,\ y=2,\ z=3.

↑ Back to the question list

Find a positive root of the equation 3x=1+cosx by a numerical technique using initial values 0,π2; and further improve the result using Newton-Raphson method correct to 8 significant figures.

2021 · Paper II · Q5b · 10 marks

Solution

Let f(x)=3x−1−cosxf(x)=3x-1-\cos x. Then f(0)=−2<0f(0)=-2<0 and f(π/2)=3π2−1≈3.7124>0f(\pi/2)=\tfrac{3\pi}{2}-1\approx3.7124>0; since f′(x)=3+sinx>0f'(x)=3+\sin x>0, there is exactly one root.

Starting from 0 and π/2\pi/2: regula–falsi.

Step aa bb f(a)f(a) f(b)f(b) xx f(x)f(x)
1 0.000000 1.570796 −2.000000 3.712389 0.549961 −0.202661
2 0.549961 1.570796 −0.202661 3.712389 0.602804 −0.015336
3 0.602804 1.570796 −0.015336 3.712389 0.606787 −0.001125

This gives x≈0.606787x\approx0.606787.

Improving with Newton–Raphson. xn+1=xn−3xn−1−cosxn3+sinxnx_{n+1}=x_n-\dfrac{3x_n-1-\cos x_n}{3+\sin x_n}:

nn xnx_n f(xn)f(x_n) f′(xn)f'(x_n) xn+1x_{n+1}
0 0.6067866727 −0.0011245756 3.5702307097 0.6071016595
1 0.6071016595 0.0000000407 3.5704894382 0.6071016481
2 0.6071016481 0.0000000000 3.5704894289 0.6071016481

The last two iterates agree, so to eight significant figures x=0.60710165.x=0.60710165 .

✓ Checked by computer We checked by computer: the root of 3x−1−cosx3x-1-\cos x is x=0.607101648103x=0.607101648103.

↑ Back to the question list

Solve the system of equations 3x1+9x2−2x3=114x1+2x2+13x3=244x1−2x2+x3=−8 correct up to 4 significant figures by using Gauss-Seidel method after verifying whether the method is applicable in your transformed form of the system.

2021 · Paper II · Q7b · 15 marks

Solution

As written, the system is not diagonally dominant (the first equation has |3|<|9|+|−2||3|<|9|+|{-2}|), so Gauss–Seidel is not guaranteed to converge. Reorder the equations so that the largest coefficient sits on the diagonal: 4x1−2x2+x3=−83x1+9x2−2x3=114x1+2x2+13x3=24\begin{aligned}4x_1-2x_2+x_3&=-8\\ 3x_1+9x_2-2x_3&=11\\ 4x_1+2x_2+13x_3&=24\end{aligned} Now |4|>|−2|+|1||4|>|-2|+|1|, |9|>|3|+|−2||9|>|3|+|-2| and |13|>|4|+|2||13|>|4|+|2|: the matrix is strictly diagonally dominant, so the method converges for any starting vector.

x1=14(−8+2x2−x3)x2=19(11−3x1+2x3)x3=113(24−4x1−2x2)\begin{aligned}x_1&=\tfrac14(-8+2x_2-x_3)\\ x_2&=\tfrac19(11-3x_1+2x_3)\\ x_3&=\tfrac1{13}(24-4x_1-2x_2)\end{aligned} Start from (0,0,0)(0,0,0):

Iteration x1x_1 x2x_2 x3x_3
1 −2.00000 1.88889 2.17094
2 −1.59829 2.23742 1.99372
3 −1.37972 2.12518 1.94373
4 −1.42334 2.12861 1.95663
5 −1.42485 2.13198 1.95657
6 −1.42315 2.13140 1.95614
7 −1.42333 2.13136 1.95620
8 −1.42337 2.13139 1.95621
9 −1.42336 2.13139 1.95620
10 −1.42336 2.13139 1.95620

To four significant figures x1≈−1.423,x2≈2.131,x3≈1.956.x_1\approx-1.423,\quad x_2\approx2.131,\quad x_3\approx1.956.

✓ Checked by computer We checked by computer: the exact solution is x1=−195137,x2=292137,x3=268137x_1=- \frac{195}{137},\ x_2=\frac{292}{137},\ x_3=\frac{268}{137}, i.e. −1.42336,2.13139,1.95620-1.42336,\ 2.13139,\ 1.95620.

↑ Back to the question list

Show that the equation : f(x)=cosπ(x+1)8+0.148x−0.9062=0 has one root in the interval (−1,0) and one in (0,1). Calculate the negative root correct to four decimal places using Newton-Raphson method.

2020 · Paper II · Q5b · 10 marks

Solution

f(x)=cosπ(x+1)8+0.148x−0.9062f(x)=\cos\dfrac{\pi(x+1)}{8}+0.148x-0.9062.

f(−1)=1−0.148−0.9062=−0.0542<0f(0)=0.92388−0.9062=0.01768>0f(1)=0.70711+0.148−0.9062=−0.05109<0\begin{aligned}f(-1)&=1-0.148-0.9062\\ &=-0.0542<0\\ f(0)&=0.92388-0.9062\\ &=0.01768>0\\ f(1)&=0.70711+0.148-0.9062\\ &=-0.05109<0\end{aligned} ff changes sign on (−1,0)(-1,0) and on (0,1)(0,1), so (being continuous) it has a root in each.

Negative root by Newton–Raphson. f′(x)=−π8sinπ(x+1)8+0.148f'(x)=-\dfrac{\pi}{8}\sin\dfrac{\pi(x+1)}{8}+0.148. Take x0=−0.5x_0=-0.5:

nn xnx_n f(xn)f(x_n) f′(xn)f'(x_n) xn+1x_{n+1}
0 −0.500000 0.000585 0.071388 −0.508199
1 −0.508199 −0.000005 0.072629 −0.508129
2 −0.508129 0.000000 0.072618 −0.508129

So the negative root is x≈−0.5081.x\approx-0.5081.

✓ Checked by computer We checked by computer: the two roots are x≈−0.508129x\approx-0.508129 and x≈0.489490x\approx0.489490.

↑ Back to the question list

For the solution of the system of equations : 4x+y+2z=43x+5y+z=7x+y+3z=3 set up the Gauss-Seidel iterative scheme and iterate three times starting with the initial vector X(0)=0. Also find the exact solutions and compare with the iterated solutions.

2020 · Paper II · Q6b · 15 marks

Solution

Iterative scheme. The matrix is diagonally dominant (4>1+24>1+2, 5>3+15>3+1, 3>1+13>1+1). Solving each equation for its diagonal unknown, x(k+1)=14(4−y(k)−2z(k))y(k+1)=15(7−3x(k+1)−z(k))z(k+1)=13(3−x(k+1)−y(k+1))\begin{aligned}x^{(k+1)}&=\tfrac14\left(4-y^{(k)}-2z^{(k)}\right)\\ y^{(k+1)}&=\tfrac15\left(7-3x^{(k+1)}-z^{(k)}\right)\\ z^{(k+1)}&=\tfrac13\left(3-x^{(k+1)}-y^{(k+1)}\right)\end{aligned} Three iterations from X(0)=(0,0,0)X^{(0)}=(0,0,0):

Iteration xx yy zz
1 1.0000 0.8000 0.4000
2 0.6000 0.9600 0.4800
3 0.5200 0.9920 0.4960

Exact solution. Elimination gives x=12,y=1,z=12.x=\tfrac12,\qquad y=1,\qquad z=\tfrac12 . Comparison. After three iterations the errors are about 0.02000.0200, 0.00800.0080 and 0.00400.0040: after three sweeps every component is within 0.020.02 of the exact value, and each further sweep cuts the error by a factor of about 5.

✓ Checked by computer We checked by computer: the exact solution is (12,1,12)(\frac{1}{2},\ 1,\ \frac{1}{2}) and the third Gauss–Seidel iterate is as tabulated.

↑ Back to the question list

Apply Newton-Raphson method, to find a real root of transcendental equation xlog10x=1.2, correct to three decimal places.

2019 · Paper II · Q5b · 10 marks

Solution

Let f(x)=xlog10x−1.2f(x)=x\log_{10}x-1.2. Since f(2)=−0.5979<0f(2)=-0.5979<0 and f(3)=0.2314>0f(3)=0.2314>0, there is a root between 2 and 3. f′(x)=log10x+log10e=log10x+0.434294.\begin{aligned}f'(x)&=\log_{10}x+\log_{10}e\\ &=\log_{10}x+0.434294.\end{aligned} Newton–Raphson: xn+1=xn−xnlog10xn−1.2log10xn+0.434294x_{n+1}=x_n-\dfrac{x_n\log_{10}x_n-1.2}{\log_{10}x_n+0.434294}, starting at x0=2.5x_0=2.5:

nn xnx_n f(xn)f(x_n) f′(xn)f'(x_n) xn+1x_{n+1}
0 2.500000 −0.205150 0.832234 2.746505
1 2.746505 0.005113 0.873075 2.740649
2 2.740649 0.000003 0.872148 2.740646

Correct to three decimal places, x≈2.741.x\approx 2.741.

✓ Checked by computer We checked by computer: the root is x=2.74064610x=2.74064610.

↑ Back to the question list

Apply Gauss-Seidel iteration method to solve the following system of equations : 2x+y−2z=17,3x+20y−z=−18,2x−3y+20z=25, correct to three decimal places.

2019 · Paper II · Q7b · 15 marks

Solution

We solve the system exactly as printed. (Many books carry this example with first equation 20x+y−2z=1720x+y-2z=17; that version has solution x=1,y=−1,z=1x=1,\ y=-1,\ z=1.)

Solve each equation for its diagonal unknown: x=12(17−y+2z)y=120(−18−3x+z)z=120(25−2x+3y)\begin{aligned}x&=\tfrac12(17-y+2z)\\ y&=\tfrac1{20}(-18-3x+z)\\ z&=\tfrac1{20}(25-2x+3y)\end{aligned} The first row is not diagonally dominant, but the second and third are strongly so, and the iteration still converges quickly (its iteration matrix has spectral radius about 0.0740.074). From (0,0,0)(0,0,0):

Iteration xx yy zz
1 8.5000 −2.1750 0.0738
2 9.6613 −2.3455 −0.0680
3 9.6048 −2.3441 −0.0621
4 9.6100 −2.3446 −0.0627
5 9.6096 −2.3446 −0.0626
6 9.6096 −2.3446 −0.0627

Correct to three decimal places, x≈9.610,y≈−2.345,z≈−0.063.x\approx9.610,\quad y\approx-2.345,\quad z\approx-0.063.

✓ Checked by computer We checked by computer: the exact solution of the printed system is x=3988415,y=−973415,z=−26415x=\frac{3988}{415},\ y=- \frac{973}{415},\ z=- \frac{26}{415}; the iteration matrix has spectral radius about 0.0740.074, so Gauss–Seidel converges.

↑ Back to the question list

Write down the basic algorithm for solving the equation : xex−1=0 by bisection method, correct to 4 decimal places.

2018 · Paper II · Q5e · 10 marks

Solution

f(x)=xex−1f(x)=xe^x-1 has f(0)=−1<0f(0)=-1<0 and f(1)=e−1>0f(1)=e-1>0, so a root lies in [0,1][0,1] (and only one, as f′(x)=(1+x)ex>0f'(x)=(1+x)e^x>0 there). Each bisection halves the bracket [a,b][a,b] while keeping the sign change inside it. The root is known to four decimal places once both ends of the bracket round to the same four-decimal number, so that is our stopping test (it needs at least 14 halvings, since 2−14<10−42^{-14}<10^{-4}).

ALGORITHM  Bisection for f(x) = x·e^x − 1 = 0
1. Define f(x) = x*exp(x) - 1
2. Read a, b            (here a = 0, b = 1)
3. If f(a)*f(b) > 0: print "no sign change", stop
4. Repeat
       c = (a + b)/2
       if f(c) = 0: go to 6
       if f(a)*f(c) < 0 then b = c
                         else a = c
   until round(a, 4) = round(b, 4)
5. c = (a + b)/2
6. Print c rounded to 4 decimals, stop

Trace of the first steps (a ← c when f(c)<0f(c)<0, b ← c when f(c)>0f(c)>0):

Step aa bb cc f(c)f(c)
1 0.00000 1.00000 0.50000 −0.17564
2 0.50000 1.00000 0.75000 0.58775
3 0.50000 0.75000 0.62500 0.16765
4 0.50000 0.62500 0.56250 −0.01278
5 0.56250 0.62500 0.59375 0.07514
6 0.56250 0.59375 0.57812 0.03062
7 0.56250 0.57812 0.57031 0.00878
8 0.56250 0.57031 0.56641 −0.00204

Continuing, after 17 halvings the bracket is [0.567139,0.567146][0.567139,\ 0.567146]; both ends round to 0.56710.5671, so the root is x≈0.5671x\approx0.5671.

✓ Checked by computer We ran this algorithm in Python: it stops after 17 halvings with a=0.567139a=0.567139, b=0.567146b=0.567146, giving x=0.5671x=0.5671; the exact root is 0.567143…0.567143\ldots.

↑ Back to the question list

Explain the main steps of the Gauss-Jordan method and apply this method to find the inverse of the matrix [266286268].

2017 · Paper II · Q5b · 10 marks

Solution

Main steps of the Gauss–Jordan method.

  1. Write the augmented matrix ([A|b][A\,|\,b] to solve Ax=bAx=b, or [A|I][A\,|\,I] to find A−1A^{-1}).
  2. Choose a pivot in the first column (interchanging rows if needed, preferably the entry of largest size), divide the pivot row by the pivot so that it becomes 1.
  3. Subtract suitable multiples of the pivot row from every other row, above as well as below, so that the rest of the pivot column becomes 0.
  4. Repeat with the next column. When the left block has become II, the right block is the solution (or A−1A^{-1}). No back-substitution is needed.

Inverse of the given matrix. [266|100286|010268|001]\left[\begin{array}{rrrcrrr} 2&6&6&\vert&1&0&0\\ 2&8&6&\vert&0&1&0\\ 2&6&8&\vert&0&0&1 \end{array}\right] R2→R2−R1,R3→R3−R1R_2\to R_2-R_1,\ R_3\to R_3-R_1: [266|100020|−110002|−101]\left[\begin{array}{rrrcrrr} 2 & 6 & 6 &\vert& 1 & 0 & 0 \\ 0 & 2 & 0 &\vert& -1 & 1 & 0 \\ 0 & 0 & 2 &\vert& -1 & 0 & 1 \end{array}\right]

R2→12R2,R3→12R3R_2\to\tfrac12R_2,\ R_3\to\tfrac12R_3: [266|100010|−12120001|−12012]\left[\begin{array}{rrrcrrr} 2 & 6 & 6 &\vert& 1 & 0 & 0 \\ 0 & 1 & 0 &\vert& -\tfrac{1}{2} & \tfrac{1}{2} & 0 \\ 0 & 0 & 1 &\vert& -\tfrac{1}{2} & 0 & \tfrac{1}{2} \end{array}\right]

R1→R1−6R2−6R3R_1\to R_1-6R_2-6R_3: [200|7−3−3010|−12120001|−12012]\left[\begin{array}{rrrcrrr} 2 & 0 & 0 &\vert& 7 & -3 & -3 \\ 0 & 1 & 0 &\vert& -\tfrac{1}{2} & \tfrac{1}{2} & 0 \\ 0 & 0 & 1 &\vert& -\tfrac{1}{2} & 0 & \tfrac{1}{2} \end{array}\right]

R1→12R1R_1\to\tfrac12R_1: [100|72−32−32010|−12120001|−12012]\left[\begin{array}{rrrcrrr} 1 & 0 & 0 &\vert& \tfrac{7}{2} & -\tfrac{3}{2} & -\tfrac{3}{2} \\ 0 & 1 & 0 &\vert& -\tfrac{1}{2} & \tfrac{1}{2} & 0 \\ 0 & 0 & 1 &\vert& -\tfrac{1}{2} & 0 & \tfrac{1}{2} \end{array}\right]

A−1=[72−32−32−12120−12012].A^{-1}=\left[\begin{matrix}\frac{7}{2} & – \frac{3}{2} & – \frac{3}{2}\\- \frac{1}{2} & \frac{1}{2} & 0\\- \frac{1}{2} & 0 & \frac{1}{2}\end{matrix}\right]. Check. Row 1 of AA times column 1 of A−1A^{-1}: 2⋅72+6(−12)+6(−12)=7−3−3=12\cdot\tfrac72+6(-\tfrac12)+6(-\tfrac12)=7-3-3=1; the other products work out the same way to II.

✓ Checked by computer We checked by computer: A−1=[72−32−32−12120−12012]A^{-1}=\left[\begin{matrix}\frac{7}{2} & – \frac{3}{2} & – \frac{3}{2}\\- \frac{1}{2} & \frac{1}{2} & 0\\- \frac{1}{2} & 0 & \frac{1}{2}\end{matrix}\right] and AA−1=IAA^{-1}=I.

↑ 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

Write an algorithm in the form of a flow chart for Newton-Raphson method. Describe the cases of failure of this method.

2017 · Paper II · Q8b · 15 marks

Solution

Flow chart. ε\varepsilon is the tolerance, NN the largest number of iterations allowed, δ\delta a small number used to guard against division by a near-zero derivative.

StartRead x₀, ε, Ni ← 1|f′(x₀)| < δ ?Yesf′ ≈ 0: methodfails. StopNox₁ ← x₀ − f(x₀)/f′(x₀)|x₁ − x₀| < ε ?YesPrint x₁StopNoi ≥ N ?YesNo convergencein N steps. StopNox₀ ← x₁, i ← i + 1
Flow chart of the Newton–Raphson method

Cases where Newton–Raphson fails (or behaves badly).

  1. Zero or very small derivative. If f′(xn)=0f'(x_n)=0 the step is undefined; if f′(xn)f'(x_n) is tiny, xn+1x_{n+1} is thrown far away (the tangent is nearly horizontal).
  2. Poor starting value. Far from the root the iterates may diverge or converge to a different root. For example f(x)=tan−1xf(x)=\tan^{-1}x with |x0|>1.3917|x_0|>1.3917 gives iterates that grow without bound.
  3. Cycling. The iterates can repeat. For f(x)=x3−2x+2f(x)=x^3-2x+2 with x0=0x_0=0 we get x1=1,x2=0,x3=1,…x_1=1,\ x_2=0,\ x_3=1,\dots
  4. Multiple roots. At a root of multiplicity m>1m>1 (e.g. f(x)=(x−1)2f(x)=(x-1)^2) the convergence is only linear, not quadratic; the modified formula xn+1=xn−mf(xn)/f′(xn)x_{n+1}=x_n-m\,f(x_n)/f'(x_n) restores quadratic convergence.
  5. Inflection point or wrong-way curvature near the root (e.g. f(x)=x1/3f(x)=x^{1/3}, where each step doubles the distance from the root: xn+1=−2xnx_{n+1}=-2x_n).
  6. No real root at all (e.g. x2+1=0x^2+1=0): the iterates wander without settling.

✓ Proof checked step by step We traced the flow chart by hand on f(x)=x2−2f(x)=x^2-2, x0=1x_0=1: it reaches 1.4142141.414214 in four passes and exits through the convergence test.

↑ Back to the question list

Find the solution of the system 10x1−2x2−x3−x4=3−2x1+10x2−x3−x4=15−x1−x2+10x3−2x4=27−x1−x2−2x3+10x4=−9 using Gauss-Seidel method (make four iterations).

2015 · Paper II · Q8b · 15 marks

Solution

Each diagonal entry (10) exceeds the sum of the others in its row (4), so Gauss–Seidel converges. x1=110(3+2x2+x3+x4)x2=110(15+2x1+x3+x4)x3=110(27+x1+x2+2x4)x4=110(−9+x1+x2+2x3)\begin{aligned}x_1&=\tfrac1{10}(3+2x_2+x_3+x_4)\\ x_2&=\tfrac1{10}(15+2x_1+x_3+x_4)\\ x_3&=\tfrac1{10}(27+x_1+x_2+2x_4)\\ x_4&=\tfrac1{10}(-9+x_1+x_2+2x_3)\end{aligned} Four iterations from (0,0,0,0)(0,0,0,0):

Iteration x1x_1 x2x_2 x3x_3 x4x_4
1 0.3000 1.5600 2.8860 −0.1368
2 0.8869 1.9523 2.9566 −0.0248
3 0.9836 1.9899 2.9924 −0.0042
4 0.9968 1.9982 2.9987 −0.0008

So, after four iterations, x1≈1.000x2≈2.000x3≈3.000x4≈0.000,\begin{aligned}&x_1\approx1.000\\ &x_2\approx2.000\\ &x_3\approx3.000\\ &x_4\approx0.000,\end{aligned} which is the exact solution (1,2,3,0)(1,2,3,0).

✓ Checked by computer We checked by computer: the exact solution is x1=1,x2=2,x3=3,x4=0x_1=1,\ x_2=2,\ x_3=3,\ x_4=0.

↑ Back to the question list

Apply Newton-Raphson method to determine a root of the equation cosx−xex=0 correct up to four decimal places.

2014 · Paper II · Q5b · 10 marks

Solution

Let f(x)=cosx−xexf(x)=\cos x-xe^x. f(0)=1>0f(0)=1>0, f(1)=cos1−e=−2.1780<0f(1)=\cos1-e=-2.1780<0, so there is a root in (0,1)(0,1). f′(x)=−sinx−(1+x)ex.f'(x)=-\sin x-(1+x)e^x . Newton–Raphson from x0=1x_0=1:

nn xnx_n f(xn)f(x_n) f′(xn)f'(x_n) xn+1x_{n+1}
0 1.000000 −2.177980 −6.278035 0.653079
1 0.653079 −0.460642 −3.783942 0.531343
2 0.531343 −0.041803 −3.111838 0.517910
3 0.517910 −0.000464 −3.042901 0.517757
4 0.517757 0.000000 −3.042124 0.517757

Correct to four decimal places, x≈0.5178.x\approx0.5178.

✓ Checked by computer We checked by computer: the root is x=0.51775736x=0.51775736.

↑ Back to the question list

Solve the system of equations 2x1−x2=7−x1+2x2−x3=1−x2+2x3=1 using Gauss-Seidel iteration method (Perform three iterations).

2014 · Paper II · Q6b · 15 marks

Solution

x1=12(7+x2)x2=12(1+x1+x3)x3=12(1+x2)\begin{aligned}x_1&=\tfrac12(7+x_2)\\ x_2&=\tfrac12(1+x_1+x_3)\\ x_3&=\tfrac12(1+x_2)\end{aligned} The matrix is symmetric positive definite (tridiagonal 2, −1), so Gauss–Seidel converges. Three iterations from (0,0,0)(0,0,0):

Iteration x1x_1 x2x_2 x3x_3
1 3.5000 2.2500 1.6250
2 4.6250 3.6250 2.3125
3 5.3125 4.3125 2.6562

After three iterations x1≈5.3125,x2≈4.3125,x3≈2.6562x_1\approx5.3125,\ x_2\approx4.3125,\ x_3\approx2.6562. (The iterates are heading for the exact solution x1=6,x2=5,x3=3x_1=6,\ x_2=5,\ x_3=3.)

✓ Checked by computer We checked by computer: the exact solution is x1=6,x2=5,x3=3x_1=6,\ x_2=5,\ x_3=3, and the third iterate is as tabulated.

↑ Back to the question list

Develop an algorithm for Newton — Raphson method to solve f(x)=0 starting with initial iterate x0, n be the number of iterations allowed, eps be the prescribed relative error and delta be the prescribed lower bound for f′(x).

2013 · Paper II · Q7a · 20 marks

Solution

The Newton–Raphson step is xi+1=xi−f(xi)f′(xi)x_{i+1}=x_i-\dfrac{f(x_i)}{f'(x_i)}. The algorithm must guard against two things: a derivative too close to zero (the step would blow up), and non-convergence (stop after nn steps). The stopping test uses the relative error |xi+1−xi|/|xi+1|<eps|x_{i+1}-x_i|/|x_{i+1}|<\text{eps}.

ALGORITHM  Newton–Raphson for f(x) = 0
Input : x0, n (max. iterations), eps (relative error), delta (lower bound for |f'|)
1. i = 1
2. fd = f'(x0)
3. If |fd| < delta then
       print "Derivative too small – method fails", stop
4. x1 = x0 - f(x0)/fd
5. If |x1 - x0| < eps*|x1| then
       print "Root =", x1, "after", i, "iterations", stop
6. If i >= n then
       print "No convergence in", n, "iterations; last value", x1, stop
7. x0 = x1;  i = i + 1;  go to step 2

Remarks.

  • Step 3 is the “delta” test: if |f′(x)|<|f'(x)|< delta the tangent is almost horizontal and the next iterate is unreliable.
  • In step 5 we write the test as |x1−x0|<eps|x1||x_1-x_0|<\text{eps}\,|x_1| to avoid dividing by x1x_1 when the root is 0.
  • Each pass needs one evaluation of ff and one of f′f'.

✓ Checked by computer We ran this algorithm in Python on f(x)=x3−2x−5f(x)=x^3-2x-5 with x0=2x_0=2, n=20n=20, eps =10−6=10^{-6}, delta =10−6=10^{-6}: it stops after 4 iterations at x=2.0945515x=2.0945515.

↑ Back to the question list

Use Newton-Raphson method to find the real root of the equation 3x=cosx+1 correct to four decimal places.

2012 · Paper II · Q5b · 12 marks

Solution

Let f(x)=3x−cosx−1f(x)=3x-\cos x-1, f′(x)=3+sinxf'(x)=3+\sin x. Since f(0)=−2<0f(0)=-2<0 and f(1)=2−cos1=1.4597>0f(1)=2-\cos1=1.4597>0, a root lies in (0,1)(0,1), and f′>0f'>0 shows it is the only real root. Take x0=0.6x_0=0.6 (where f(0.6)≈−0.0253f(0.6)\approx-0.0253):

nn xnx_n f(xn)f(x_n) f′(xn)f'(x_n) xn+1x_{n+1}
0 0.600000 −0.025336 3.564642 0.607107
1 0.607107 0.000021 3.570494 0.607102
2 0.607102 0.000000 3.570489 0.607102

Correct to four decimal places, x≈0.6071.x\approx0.6071 .

✓ Checked by computer We checked by computer: the root is x=0.60710165x=0.60710165.

↑ Back to the question list

Solve the following system of simultaneous equations, using Gauss-Seidel iterative method : 3x+20y−z=−1820x+y−2z=172x−3y+20z=25.

2012 · Paper II · Q6c · 20 marks

Solution

As given, the first equation has its largest coefficient on yy. Interchange the first two equations so that the system is diagonally dominant: 20x+y−2z=173x+20y−z=−182x−3y+20z=25\begin{aligned}20x+y-2z&=17\\ 3x+20y-z&=-18\\ 2x-3y+20z&=25\end{aligned} x=120(17−y+2z)y=120(−18−3x+z)z=120(25−2x+3y)\begin{aligned}x&=\tfrac1{20}(17-y+2z)\\ y&=\tfrac1{20}(-18-3x+z)\\ z&=\tfrac1{20}(25-2x+3y)\end{aligned} From (0,0,0)(0,0,0):

Iteration xx yy zz
1 0.8500 −1.0275 1.0109
2 1.0025 −0.9998 0.9998
3 1.0000 −1.0000 1.0000
4 1.0000 −1.0000 1.0000

So x=1,y=−1,z=1.x=1,\quad y=-1,\quad z=1 .

✓ Checked by computer We checked by computer: the exact solution is x=1,y=−1,z=1x=1,\ y=-1,\ z=1.

↑ Back to the question list

Find the positive root of the equation 10xe−x2−1=0 correct up to 6 decimal places by using Newton-Raphson method. Carry out computations only for three iterations.

2010 · Paper II · Q5c · 12 marks

Solution

Let f(x)=10xe−x2−1f(x)=10xe^{-x^2}-1, f′(x)=10e−x2(1−2x2)f'(x)=10e^{-x^2}(1-2x^2).

How many positive roots? g(x)=10xe−x2g(x)=10xe^{-x^2} rises from 0 to its maximum 10⋅12e−1/2≈4.2910\cdot\tfrac{1}{\sqrt2}e^{-1/2}\approx4.29 at x=1/2x=1/\sqrt2 and then decays to 0. So g(x)=1g(x)=1 has two positive roots: one near 0.10.1 and one between 1.6 and 1.7 (f(1.6)=0.2361f(1.6)=0.2361, f(1.7)=−0.0611f(1.7)=-0.0611). The question speaks of “the” positive root; we give both, three iterations each.

Smaller root, x0=0x_0=0:

nn xnx_n f(xn)f(x_n) f′(xn)f'(x_n) xn+1x_{n+1}
0 0.000000 −1.000000 10.000000 0.100000
1 0.100000 −0.009950 9.702488 0.101026
2 0.101026 −0.000003 9.696407 0.101026

Larger root, x0=1.7x_0=1.7:

nn xnx_n f(xn)f(x_n) f′(xn)f'(x_n) xn+1x_{n+1}
0 1.700000 −0.055204 −2.656543 1.679219
1 1.679219 0.001137 −2.766065 1.679630
2 1.679630 0.000000 −2.763893 1.679631

After three iterations: x≈0.101026x\approx0.101026 and x≈1.679631x\approx1.679631.

✓ Checked by computer We checked by computer: the positive roots are x=0.10102585x=0.10102585 and x=1.67963061x=1.67963061.

↑ Back to the question list

Given the system of equations 2x+3y=12x+4y+z=22y+6z+Aw=44z+Bw=C State the solvability and uniqueness conditions for the system. Give the solution when it exists.

2010 · Paper II · Q7a · 20 marks

Solution

Eliminate step by step.

Subtract the first equation from the second: y+z=1y+z=1, so z=1−yz=1-y.

Third equation: 2y+6(1−y)+Aw=42y+6(1-y)+Aw=4, i.e. −4y+Aw=−2-4y+Aw=-2.

Fourth equation: 4(1−y)+Bw=C4(1-y)+Bw=C, i.e. −4y+Bw=C−4-4y+Bw=C-4.

Subtracting these two, (A−B)w=2−C.(A-B)\,w=2-C . The determinant of the coefficient matrix is −8(A−B)– 8 \left(A – B\right).

Unique solution: A≠BA\ne B. Then w=2−CA−By=Aw+24=4A−AC−2B4(A−B),\begin{aligned}&w=\frac{2-C}{A-B}\\ &y=\frac{Aw+2}{4}=\frac{4A-AC-2B}{4(A-B)},\end{aligned} z=1−y=AC−2B4(A−B)x=1−3y2=3AC−8A+2B8(A−B).\begin{aligned}&z=1-y=\frac{AC-2B}{4(A-B)}\\ &x=\frac{1-3y}{2}=\frac{3AC-8A+2B}{8(A-B)}.\end{aligned}

A=BA=B and C=2C=2: the last two equations coincide, so the system is consistent with infinitely many solutions: ww is arbitrary, and y=2+Aw4y=\dfrac{2+Aw}{4}, z=1−yz=1-y, x=1−3y2x=\dfrac{1-3y}{2}.

A=BA=B and C≠2C\ne2: the equations (A−B)w=2−C(A-B)w=2-C read 0=2−C≠00=2-C\ne0, so the system is inconsistent – no solution.

✓ Checked by computer We checked by computer: the coefficient determinant is −8(A−B)– 8 \left(A – B\right) and the solution for A≠BA\ne B is as stated.

↑ Back to the question list

The equation x2+ax+b=0 has two real roots α and β. Show that the iterative method given by : xk+1=−(axk+b)/xk,k=0,1,2,…… is convergent near x=α, if |α|>|β|.

2009 · Paper II · Q5c(i) · 6 marks

Solution

The iteration is xk+1=g(xk)x_{k+1}=g(x_k) with g(x)=−ax+bx=−a−bx.g(x)=-\frac{ax+b}{x}=-a-\frac{b}{x}. α\alpha is a fixed point. Since α2+aα+b=0\alpha^2+a\alpha+b=0, dividing by α\alpha (α≠0\alpha\neq0 because |α|>|β|≥0|\alpha|>|\beta|\ge0) gives α=−a−b/α=g(α)\alpha=-a-b/\alpha=g(\alpha).

Derivative at the fixed point. g′(x)=bx2g'(x)=\dfrac{b}{x^2}. For the quadratic, b=αβb=\alpha\beta (product of roots), so g′(α)=αβα2=βα.g'(\alpha)=\frac{\alpha\beta}{\alpha^2}=\frac{\beta}{\alpha}. Convergence. If |α|>|β||\alpha|>|\beta| then |g′(α)|=|β/α|<1|g'(\alpha)|=|\beta/\alpha|<1. As g′g' is continuous near α\alpha, there is an interval I=[α−h,α+h]I=[\alpha-h,\alpha+h] on which |g′(x)|≤L<1|g'(x)|\le L<1. For xk∈Ix_k\in I, the mean value theorem gives |xk+1−α|=|g(xk)−g(α)|=|g′(ξk)||xk−α|≤L|xk−α|,\begin{aligned}|x_{k+1}-\alpha|&=|g(x_k)-g(\alpha)|\\ &=|g'(\xi_k)|\,|x_k-\alpha|\\ &\le L\,|x_k-\alpha|,\end{aligned} so xk+1∈Ix_{k+1}\in I too, and |xk−α|≤Lk|x0−α|→0|x_k-\alpha|\le L^k|x_0-\alpha|\to0. Hence the method converges to α\alpha for every starting value close enough to α\alpha, and the convergence is linear with rate |β/α||\beta/\alpha|.

(If instead |α|<|β||\alpha|<|\beta|, then |g′(α)|>1|g'(\alpha)|>1 and the iterates move away from α\alpha.)

✓ Proof checked step by step We checked each step against the fixed-point convergence theorem; numerically, x2−5x+6=0x^2-5x+6=0 (α=3,β=2\alpha=3,\ \beta=2) with x0=3.5x_0=3.5 converges to 3, as predicted.

↑ Back to the question list

Develop an algorithm for Regula-Falsi method to find a root of f(x)=0 starting with two initial iterates x0 and x1 to the root such that sign (f(x0))≠ sign (f(x1)). Take n as the maximum number of iterations allowed and eps be the prescribed error.

2009 · Paper II · Q7a · 30 marks

Solution

Idea. If f(x0)f(x_0) and f(x1)f(x_1) have opposite signs, the chord joining (x0,f(x0))(x_0,f(x_0)) and (x1,f(x1))(x_1,f(x_1)) cuts the xx-axis at x2=x0f(x1)−x1f(x0)f(x1)−f(x0).x_2=\frac{x_0f(x_1)-x_1f(x_0)}{f(x_1)-f(x_0)} . We keep whichever of [x0,x2][x_0,x_2], [x2,x1][x_2,x_1] still has a sign change, so the root always stays bracketed.

ALGORITHM  Regula-Falsi for f(x) = 0
Input : x0, x1 with sign(f(x0)) ≠ sign(f(x1)), n (max. iterations), eps
1. f0 = f(x0);  f1 = f(x1)
2. If f0*f1 > 0 then print "Root not bracketed", stop
3. i = 1;  xold = x0
4. x2 = (x0*f1 - x1*f0)/(f1 - f0)        (chord meets the x-axis)
5. f2 = f(x2)
6. If |x2 - xold| < eps  or  f2 = 0 then
       print "Root =", x2, "after", i, "iterations", stop
7. If f0*f2 < 0 then                     (root in [x0, x2])
       x1 = x2;  f1 = f2
   else                                  (root in [x2, x1])
       x0 = x2;  f0 = f2
8. If i >= n then
       print "No convergence in", n, "iterations; last value", x2, stop
9. xold = x2;  i = i + 1;  go to step 4
StartRead x₀, x₁, n, epsf₀ ← f(x₀), f₁ ← f(x₁)i ← 1, x_old ← x₀x₂ ← (x₀f₁ − x₁f₀)/(f₁ − f₀)f₂ ← f(x₂)|x₂ − x_old| < eps ?YesPrint x₂StopNof₀·f₂ < 0 ?Yesx₁ ← x₂f₁ ← f₂Nox₀ ← x₂, f₀ ← f₂i ≥ n ?YesNo convergenceStopNox_old ← x₂, i ← i + 1
Flow chart of the regula-falsi method

✓ Checked by computer We ran this algorithm in Python on f(x)=x3−2x−5f(x)=x^3-2x-5 with x0=2x_0=2, x1=3x_1=3, n=50n=50, eps =10−6=10^{-6}: it returns x=2.094551x=2.094551 after 13 iterations.

↑ Back to the question list

Find the smallest positive root of equation xex−cosx=0 using regula-falsi method. Do three iterations.

2008 · Paper II · Q5c · 12 marks

Solution

Let f(x)=xex−cosxf(x)=xe^x-\cos x. f(0)=−1<0f(0)=-1<0 and f(1)=e−cos1=2.1780>0f(1)=e-\cos1=2.1780>0. Since f′(x)=(1+x)ex+sinx>0f'(x)=(1+x)e^x+\sin x>0 for x≥0x\ge0, there is exactly one root in (0,1)(0,1) – the smallest positive root.

x=af(b)−bf(a)f(b)−f(a)x=\frac{a\,f(b)-b\,f(a)}{f(b)-f(a)}

Step aa bb f(a)f(a) f(b)f(b) xx f(x)f(x)
1 0.000000 1.000000 −1.000000 2.177980 0.314665 −0.519871
2 0.314665 1.000000 −0.519871 2.177980 0.446728 −0.203545
3 0.446728 1.000000 −0.203545 2.177980 0.494015 −0.070802

After three iterations x≈0.4940x\approx0.4940 (the root is 0.517760.51776; regula-falsi approaches it slowly here because the end b=1b=1 never moves).

✓ Checked by computer We checked by computer: the smallest positive root is x=0.517757x=0.517757; the three regula-falsi iterates are as tabulated.

↑ Back to the question list

Apply Gauss-Seidel method to calculate x, y, z from the system: −x−y+6z=426x−y−z=11.33−x+6y−z=32 with initial values (4.67,7.62,9.05). Carry out computations for two iterations.

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

Solution

Rearrange the equations so that the dominant coefficient 6 is on the diagonal: 6x−y−z=11.33−x+6y−z=32−x−y+6z=42\begin{aligned}6x-y-z&=11.33\\ -x+6y-z&=32\\ -x-y+6z&=42\end{aligned} x=16(11.33+y+z)y=16(32+x+z)z=16(42+x+y)\begin{aligned}x&=\tfrac16(11.33+y+z)\\ y&=\tfrac16(32+x+z)\\ z&=\tfrac16(42+x+y)\end{aligned} Start from (x,y,z)=(4.67,7.62,9.05)(x,y,z)=(4.67,\ 7.62,\ 9.05):

Iteration xx yy zz
1 4.6667 7.6194 9.0477
2 4.6662 7.6190 9.0475

After two iterations x≈4.6662,y≈7.6190,z≈9.0475.x\approx4.6662,\quad y\approx7.6190,\quad z\approx9.0475.

✓ Checked by computer We checked by computer: the exact solution is x≈4.6661,y≈7.6189,z≈9.0475x\approx4.6661,\ y\approx7.6189,\ z\approx9.0475.

↑ Back to the question list

Draw a flow chart for solving equation F(x)=0 correct to five decimal places by Newton-Raphson method.

2008 · Paper II · Q7b · 30 marks

Solution

Newton–Raphson: xn+1=xn−F(xn)F′(xn)x_{n+1}=x_n-\dfrac{F(x_n)}{F'(x_n)}. For five-decimal accuracy we stop when two successive iterates differ by less than ε=0.5×10−5\varepsilon=0.5\times10^{-5}; NN caps the number of passes, and the test F′=0F'=0 prevents division by zero.

StartRead x₀, N(ε = 0.000005)i ← 1F ← F(x₀), D ← F′(x₀)D = 0 ?YesPrint "F′ = 0"StopNox₁ ← x₀ − F/D|x₁ − x₀| < ε ?YesPrint x₁ to5 decimals. StopNoi ≥ N ?YesNo convergenceStopNox₀ ← x₁, i ← i + 1
Newton–Raphson, stopping when successive iterates differ by less than 0.000005

✓ Proof checked step by step We traced the chart on F(x)=x2−3F(x)=x^2-3, x0=2x_0=2: it stops after 4 passes with 1.732051.73205, which is 3\sqrt3 to five decimals.

↑ Back to the question list

More on Numerical Analysis and Computer Programming

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