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ₙ):
| n | xₙ | yₙ | f(xₙ, yₙ) = xₙ + yₙ + xₙyₙ | yₙ₊₁ |
|---|---|---|---|---|
| 0 | 0.00 | 1.000000 | 1.000000 | 1.020000 |
| 1 | 0.02 | 1.020000 | 1.060400 | 1.041208 |
| 2 | 0.04 | 1.041208 | 1.122856 | 1.063665 |
| 3 | 0.06 | 1.063665 | 1.187485 | 1.087415 |
| 4 | 0.08 | 1.087415 | 1.254408 | 1.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.
| x | 0.5 | 0.7 | 0.9 | 1.1 | 1.3 |
|---|---|---|---|---|---|
| y = ln x | −0.693147 | −0.356675 | −0.105361 | 0.095310 | 0.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.0 | 2.000000 | 0.200000 | 0.210000 | 2.205000 |
| 0.1 | 2.205000 | 0.210500 | 0.221550 | 2.421025 |
| 0.2 | 2.421025 | 0.222103 | 0.234313 | 2.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.
| x | 0.5 | 0.7 | 0.9 | 1.1 | 1.3 |
|---|---|---|---|---|---|
| y = e^(x²) | 1.284025 | 1.632316 | 2.247908 | 3.353485 | 5.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‴).
| x | f | f′ | f″ | f‴ | V(x) |
|---|---|---|---|---|---|
| −3 | −29 | 41 | −24 | 6 | 3 |
| −2 | 1 | 20 | −18 | 6 | 2 |
| −1 | 13 | 5 | −12 | 6 | 2 |
| 0 | 13 | −4 | −6 | 6 | 2 |
| 1 | 7 | −7 | 0 | 6 | 2 |
| 2 | 1 | −4 | 6 | 6 | 2 |
| 3 | 1 | 5 | 12 | 6 | 0 |
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.
| k | x₁ | x₂ | x₃ |
|---|---|---|---|
| 0 | 0 | 0 | 0 |
| 1 | 1.1446 | 1.8459 | 1.8207 |
| 2 | 0.9877 | 1.4119 | 1.9566 |
| 3 | 1.0518 | 1.3693 | 1.9617 |
| 4 | 1.0577 | 1.3672 | 1.9617 |
| 5 | 1.0579 | 1.3672 | 1.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.
| x | y | k₁ | k₂ | k₃ | k₄ | new y |
|---|---|---|---|---|---|---|
| 0.0 | 0.000000 | 0.200000 | 0.202000 | 0.202040 | 0.208164 | 0.202707 |
| 0.2 | 0.202707 | 0.208218 | 0.218827 | 0.219484 | 0.235649 | 0.422789 |
| 0.4 | 0.422789 | 0.235750 | 0.258464 | 0.260945 | 0.293499 | 0.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.
| k | x | y | z |
|---|---|---|---|
| 0 | 0 | 0 | 0 |
| 1 | 1.1190 | 2.8080 | 3.5610 |
| 2 | 1.1943 | 2.3400 | 3.3921 |
| 3 | 1.2242 | 2.3494 | 3.4464 |
| 4 | 1.2287 | 2.3409 | 3.4485 |
| 5 | 1.2298 | 2.3403 | 3.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.)