Numerical Computing, Past Papers, UOS Main Campus

Numerical Computing BSCS 6th Final Past Paper 2013 – UOS Main Campus

ProgramBSCS
Semester6th
ExamFinal Term
Year2013
AnswersSolved ✓

University of Sargodha main campus Numerical Computing final exam for BSCS 6 (Regular), held on 13 June 2013 (2 hours). Retyped from the original paper, with solved answers below.

Solved answers

Q1 – Lagrange interpolation, f(3)

f(x) = Σ yᵢ Lᵢ(x) with x₀ = 1, x₁ = 2, x₂ = 5.

L₀(3) = (3 − 2)(3 − 5)/((1 − 2)(1 − 5)) = (1)(−2)/((−1)(−4)) = −1/2
L₁(3) = (3 − 1)(3 − 5)/((2 − 1)(2 − 5)) = (2)(−2)/((1)(−3)) = 4/3
L₂(3) = (3 − 1)(3 − 2)/((5 − 1)(5 − 2)) = 2/12 = 1/6

f(3) = 1(−1/2) + 4(4/3) + 10(1/6) = −0.5 + 5.3333 + 1.6667 = 6.5.

Q2 – Simpson’s 1/3 rule, ∫₁² dx/x, h = 0.25

x11.251.51.752
f = 1/x10.80.6666670.5714290.5

I ≈ (h/3)[f₀ + 4(f₁ + f₃) + 2f₂ + f₄] = (0.25/3)[1 + 4(1.371429) + 2(0.666667) + 0.5] = (0.083333)(8.319048) = 0.693254. (Exact value ln 2 = 0.693147.)

Q3 – Modified Euler’s method, dy/dt = 1 − y, y(0) = 0, h = 0.1

Predictor y* = yₙ + h f(tₙ, yₙ); corrector yₙ₊₁ = yₙ + (h/2)[f(tₙ, yₙ) + f(tₙ₊₁, y*)].

t = 0.1: f = 1; y* = 0.1; f* = 0.9; y₁ = 0 + 0.05(1 + 0.9) = 0.095.
t = 0.2: f = 0.905; y* = 0.095 + 0.0905 = 0.1855; f* = 0.8145; y₂ = 0.095 + 0.05(0.905 + 0.8145) = 0.180975.

(Exact: 1 − e⁻ᵗ gives 0.09516 and 0.18127.)

Q4 – Newton–Raphson pseudo-code

INPUT f(x), f'(x), initial guess x0, tolerance tol, max iterations N
FOR i = 1 TO N
    IF f'(x0) = 0 THEN PRINT "derivative zero, method fails"; STOP
    x1 = x0 - f(x0) / f'(x0)
    IF |x1 - x0| < tol THEN PRINT "root =", x1; STOP
    x0 = x1
END FOR
PRINT "did not converge in N iterations"

Q5 – Estimate y′(1.3) (Newton’s forward difference formula, h = 0.2)

Forward differences at x = 1.3: Δy = −0.3049, Δ²y = −0.0217, Δ³y = 0.0072, Δ⁴y = 0.0004, Δ⁵y = −0.0004.

y′(x₀) = (1/h)[Δy − Δ²y/2 + Δ³y/3 − Δ⁴y/4 + Δ⁵y/5] = (1/0.2)[−0.3049 + 0.01085 + 0.0024 − 0.0001 − 0.00008] = (1/0.2)(−0.29183) = −1.4592.

Q6 – Second-order Runge–Kutta, dy/dx = (y + x)/(y − x), y(0) = 1, h = 0.2

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

Step 1 (x = 0 → 0.2): k₁ = 0.2(1/1) = 0.2; k₂ = 0.2 f(0.2, 1.2) = 0.2(1.4/1.0) = 0.28; y(0.2) = 1 + 0.24 = 1.24.

Step 2 (x = 0.2 → 0.4): k₁ = 0.2(1.44/1.04) = 0.276923; k₂ = 0.2 f(0.4, 1.516923) = 0.2(1.916923/1.116923) = 0.343251; y(0.4) = 1.24 + 0.310087 = 1.5501.

Q7 – Trapezoidal rule, ∫₀¹ dx/(1 + x²), h = 1/4

x00.250.50.751
f(x)10.9411760.80.640.5

I ≈ (h/2)[f₀ + 2(f₁ + f₂ + f₃) + f₄] = (0.125)[1 + 2(2.381176) + 0.5] = 0.125 × 6.262353 = 0.782794. (Exact value π/4 = 0.785398.)

All values were computed and checked in Python.

Save this paper for offline studyDownload the question paper, or save the paper together with all solved answers as a PDF.
↓ Download Paper (JPG)

About Saif R

An educator and technology enthusiast passionate about empowering students through quality education and digital learning. Dedicated to making academic resources and opportunities accessible to everyone.