CONMP · Question paper

CET-2 · 8 Oct 2025

Computer Oriented Numerical Methods with Python (S2320C1) · Continuous Evaluation Test 2 · 8 October 2025 · 30 marks · 12:30 – 2:00 pm ITM (SLS) Baroda University · B.Tech all branches, odd semester 2025-26 · Semester 3. Non-programmable calculator allowed. Questions transcribed from the original paper. Solutions are written by CampusLoop and every number was checked by computer; check the method against your class notes.

Q1 (A). Select the correct option [3]

1. If dy/dx = xy + y² with y(0) = 1, then using the R-K method the value of k₁ with step size 0.1 is: (a) 0.1 · (b) 0.01 · (c) 0.0001 · (d) 0.0001 Answer: (a) 0.1. k₁ = h f(x₀, y₀) = 0.1 × (0·1 + 1²) = 0.1.

2. The Gauss-Seidel method converges faster than Gauss-Jacobi because: (a) it updates all values at once · (b) it does not require an initial guess · (c) it uses the latest available values · (d) all mentioned Answer: (c).

3. Lin-Bairstow's method is used to find: (a) real roots · (b) negative roots · (c) positive roots · (d) complex roots Answer: (d) complex roots (it extracts quadratic factors x² + px + q, which give complex-conjugate pairs as well as real roots).

Q1 (B). Do as directed [3]

1. Trapezoidal rule for six intervals. With h = (b − a)/6 and yᵢ = f(a + ih): ∫ₐᵇ f(x) dx ≈ (h/2) [ (y₀ + y₆) + 2(y₁ + y₂ + y₃ + y₄ + y₅) ]

2. Using Descartes' rule of signs, the number of complex roots of x⁷ − 3x⁴ + 2x³ − 1 = 0.

  • f(x) signs: + − + − → 3 sign changes → 3 or 1 positive roots.
  • f(−x) = −x⁷ − 3x⁴ − 2x³ − 1: signs − − − − → 0 changes → no negative roots. x = 0 is not a root.
  • Degree 7, so complex roots = 7 − (3 or 1) − 0 = at least 4 (4 or 6).

3. Sufficient condition for convergence of the Gauss-Seidel and Gauss-Jacobi methods. The coefficient matrix must be diagonally dominant: in each row, |aᵢᵢ| ≥ Σⱼ≠ᵢ |aᵢⱼ|, with strict inequality for at least one row. Rearrange the equations to achieve this before iterating.

Q2. Attempt any three [9]

Q2(a) Euler's method: y at x = 0.1 from dy/dx = x + y + xy, y(0) = 1, in five steps.

Five steps means h = 0.1/5 = 0.02, and yₙ₊₁ = yₙ + h f(xₙ, yₙ):

nxₙyₙf(xₙ, yₙ) = xₙ + yₙ + xₙyₙyₙ₊₁
00.001.0000001.0000001.020000
10.021.0200001.0604001.041208
20.041.0412081.1228561.063665
30.061.0636651.1874851.087415
40.081.0874151.2544081.112503

y(0.1) ≈ 1.1125.

Q2(b) Evaluate ∫₀.₅¹·³ ln x dx by Simpson's appropriate rule with h = 0.2.

n = (1.3 − 0.5)/0.2 = 4 intervals (even), so use Simpson's 1/3 rule.

x0.50.70.91.11.3
y = ln x−0.693147−0.356675−0.1053610.0953100.262364

I = (h/3)[(y₀ + y₄) + 4(y₁ + y₃) + 2y₂] = (0.2/3)[(−0.693147 + 0.262364) + 4(−0.356675 + 0.095310) + 2(−0.105361)] = (0.2/3)[−0.430783 − 1.045460 − 0.210722] = −0.11246 (exact: −0.11235).

Q2(c) Given dy/dx = y − x, y(0) = 2, find y(0.3) using the R-K second order formula with h = 0.1.

k₁ = h f(xₙ, yₙ), k₂ = h f(xₙ + h, yₙ + k₁), yₙ₊₁ = yₙ + (k₁ + k₂)/2.

xₙyₙk₁k₂yₙ₊₁
0.02.0000000.2000000.2100002.205000
0.12.2050000.2105000.2215502.421025
0.22.4210250.2221030.2343132.649233

y(0.3) ≈ 2.6492 (exact eˣ + x + 1 = 2.6499).

Q2(d) Estimate ∫₀.₅¹·³ e^(x²) dx by Simpson's appropriate rule with five ordinates.

Five ordinates → 4 intervals, h = 0.2, Simpson's 1/3 rule.

x0.50.70.91.11.3
y = e^(x²)1.2840251.6323162.2479083.3534855.419481

I = (0.2/3)[(1.284025 + 5.419481) + 4(1.632316 + 3.353485) + 2(2.247908)] = (0.2/3)[6.703506 + 19.943204 + 4.495816] = 2.0762.

Q2(e) Budan's theorem: number of roots of x³ − 3x² − 4x + 13 = 0 in [−3,−2], [−2,−1], [−1,0], [0,1], [1,2], [2,3].

f(x) = x³ − 3x² − 4x + 13, f′(x) = 3x² − 6x − 4, f″(x) = 6x − 6, f‴(x) = 6. V(x) = number of sign changes in (f, f′, f″, f‴).

xff′f″f‴V(x)
−3−2941−2463
−2120−1862
−1135−1262
013−4−662
17−7062
21−4662
3151260

Number of roots in (a, b) is V(a) − V(b) or less by an even number:

  • [−3, −2]: 3 − 2 = 1 real root.
  • [−2, −1], [−1, 0], [0, 1], [1, 2]: 0 → no roots.
  • [2, 3]: 2 − 0 = 2 or 0 roots. Check: f(2.5) = −0.125 < 0 while f(2) = f(3) = 1 > 0, so there are 2 real roots in (2, 3).

Q3. Attempt any three [15]

Q3(a) Two iterations of Lin-Bairstow: quadratic factor x² + px + q of x⁴ − 8x³ + 39x² − 62x + 50, p₀ = q₀ = 0.

Synthetic division by x² + px + q: bₖ = aₖ − p bₖ₋₁ − q bₖ₋₂, cₖ = bₖ − p cₖ₋₁ − q cₖ₋₂, then solve c₂ Δp + c₁ Δq = b₃ and (c₃ − b₃) Δp + c₂ Δq = b₄.

Iteration 1 (p = 0, q = 0): b = (1, −8, 39, −62, 50), c = (1, −8, 39, −62). 39Δp − 8Δq = −62 and 0·Δp + 39Δq = 50 → Δp = −1.3268, Δq = 1.2821 → p₁ = −1.3268, q₁ = 1.2821.

Iteration 2: b = (1, −6.6732, 28.8642, −15.1488, −7.1041), c = (1, −5.3465, 20.4886, 18.8891). Solving gives Δp = −0.5789, Δq = 0.6150 → p₂ = −1.9057, q₂ = 1.8970.

Quadratic factor after two iterations: x² − 1.9057x + 1.8970. (Iterating further converges to x² − 2x + 2; indeed x⁴ − 8x³ + 39x² − 62x + 50 = (x² − 2x + 2)(x² − 6x + 25), giving roots 1 ± i and 3 ± 4i.)

Q3(b) Gauss-Seidel: 7x₁ + 52x₂ + 13x₃ = 104, 83x₁ + 11x₂ − 4x₃ = 95, 3x₁ + 8x₂ + 29x₃ = 71 (three decimals).

Rearrange for diagonal dominance: x₁ = (95 − 11x₂ + 4x₃)/83, x₂ = (104 − 7x₁ − 13x₃)/52, x₃ = (71 − 3x₁ − 8x₂)/29.

kx₁x₂x₃
0000
11.14461.84591.8207
20.98771.41191.9566
31.05181.36931.9617
41.05771.36721.9617
51.05791.36721.9617

x₁ = 1.058, x₂ = 1.367, x₃ = 1.962.

Q3(c) R-K fourth order: y at x = 0.6 for dy/dx = 1 + y², y(0) = 0, h = 0.2.

k₁ = hf(x, y), k₂ = hf(x + h/2, y + k₁/2), k₃ = hf(x + h/2, y + k₂/2), k₄ = hf(x + h, y + k₃), Δy = (k₁ + 2k₂ + 2k₃ + k₄)/6.

xyk₁k₂k₃k₄new y
0.00.0000000.2000000.2020000.2020400.2081640.202707
0.20.2027070.2082180.2188270.2194840.2356490.422789
0.40.4227890.2357500.2584640.2609450.2934990.684133

y(0.6) ≈ 0.6841 (exact tan 0.6 = 0.684137).

Q3(d) Jacobi iteration: 10x + y − z = 11.19, x + 10y + z = 28.08, −x + y + 10z = 35.61 (two decimals).

x = (11.19 − y + z)/10, y = (28.08 − x − z)/10, z = (35.61 + x − y)/10, all using the previous iteration's values.

kxyz
0000
11.11902.80803.5610
21.19432.34003.3921
31.22422.34943.4464
41.22872.34093.4485
51.22982.34033.4498

x = 1.23, y = 2.34, z = 3.45.

Q3(e) Heun's predictor-corrector: y at x = 0.1 for dy/dx = x² + y, y(0) = 1.

The paper prints "step size 0.5", which overshoots x = 0.1; it is a misprint for h = 0.05 (as in the end-semester paper). With h = 0.05 (two steps):

Predictor yᵖ = yₙ + h f(xₙ, yₙ); corrector y = yₙ + (h/2)[f(xₙ, yₙ) + f(xₙ₊₁, yᵖ)], repeated until stable.

  • Step 1 (x = 0 → 0.05): predictor 1.050000; corrector 1.051313 → 1.051345 → 1.051346.
  • Step 2 (x = 0.05 → 0.1): predictor 1.104038; corrector 1.105543 → 1.105581 → 1.105582.

y(0.1) ≈ 1.1056. (With a single step h = 0.1 the answer is 1.1058.)