CSC212 · TU past paper
Numerical Method 2079 question paper
The complete TU 2079 exam paper for Numerical Method (CSC212), all 12 questions with solved model answers written to the mark scheme.
Tap a question to open its answer.
- Q1.10 marksNumericalSecant method and ConvergenceHideAnswer
How secant method can approximate the root of a non-linear equation? Explain with necessary derivation. Estimate a real root of following equation using secant method. Assume error precision of 0.01. $x^3 + 2x - \cos(x) = 4$ [10]
- Q2.10 marksNumericalCubic spline interpolationHideAnswer
Spline Interpolation vs Lagrange Interpolation
Key Differences:
-
Degree of polynomial: Lagrange interpolation uses a single polynomial of degree $n-1$ for $n$ points, while spline interpolation uses piecewise polynomials (typically cubic) of lower degree on each subinterval.
-
Smoothness: Spline interpolation ensures continuity of the function and its derivatives at knots, providing smoother curves. Lagrange interpolation may exhibit oscillations (Runge's phenomenon).
-
Computational efficiency: Spline interpolation is more efficient for large datasets and avoids high-degree polynomial issues.
-
Local vs global: Spline interpolation is local (changes in one interval don't affect others), while Lagrange interpolation is global.
Cubic Spline Interpolation
Given data:
$$\begin{array}{c|cccc} x & -1 & 1 & 2 & 3 \ \hline f(x) & -10 & -2 & 14 & 86 \end{array}$$
Step 1: Set up intervals and spacing
- Interval 1: $[-1, 1]$, $h_1 = 2$
- Interval 2: $[1, 2]$, $h_2 = 1$
- Interval 3: $[2, 3]$, $h_3 = 1$
Step 2: Calculate second differences
$$\Delta f_1 = \frac{-2-(-10)}{2} = 4, \quad \Delta f_2 = \frac{14-(-2)}{1} = 16, \quad \Delta f_3 = \frac{86-14}{1} = 72$$
Step 3: Set up system for second derivatives (assuming natural spline: $M_0 = M_3 = 0$)
$$h_1 M_0 + 2(h_1+h_2)M_1 + h_2 M_2 = 6(\Delta f_2 - \Delta f_1)$$ $$2(2) + 2(3)M_1 + 1 \cdot M_2 = 6(16-4) = 72$$ $$6M_1 + M_2 = 72 \quad \text{...(1)}$$
$$h_2 M_1 + 2(h_2+h_3)M_2 + h_3 M_3 = 6(\Delta f_3 - \Delta f_2)$$ $$M_1 + 4M_2 = 6(72-16) = 336 \quad \text{...(2)}$$
Solving: From (1): $M_2 = 72 - 6M_1$
Substituting into (2): $M_1 + 4(72-6M_1) = 336$ $$M_1 + 288 - 24M_1 = 336$$ $$M_1 = -\frac{48}{23}, \quad M_2 = \frac{1656}{23}$$
Step 4: Estimate $f(0)$ and $f(4)$
For $f(0)$ (in interval $[-1, 1]$): Using cubic spline formula with $x = 0$, $t = \frac{0-(-1)}{2} = 0.5$:
$$f(0) = -10(1-t)^3 + (-2)t^3 + \frac{M_0}{6}(1-t)^3 \cdot 2^3 + \frac{M_1}{6}t^3 \cdot 2^3$$
$$f(0) = -10(0.125) - 2(0.125) + \frac{1}{6} \cdot (-\frac{48}{23}) \cdot 0.125 \cdot 8$$
$$\boxed{f(0) \approx -6}$$
For $f(4)$: Since $x = 4$ is outside the data range $[-1, 3]$, extrapolation using the last spline segment $[2, 3]$ gives:
$$\boxed{f(4) \approx 158}$$
[10]
-
- Q3.10 markspivotingHideAnswer
What is pivoting? Why is it necessary? Write an algorithm and program to solve the set of n linear equations using Gaussian elimination method.[10]
- Q4.5 marksNumericalHalf-Interval method and ConvergenceHideAnswer
Calculate a real root of the following function using bisection method correct upto 3 significant figures. $x^2 - e^x = 3$ [5]
- Q5.5 marksFixed point iteration and its convergenceHideAnswer
What is fixed point iteration method? How can it converge to the root of a non-linear equation? Also explain the diverging cases with suitable examples. [5]
- Q6.5 marksHeun's methodHideAnswer
Write down the program for solving ordinary differential equation using Heun's method. [5]
- Q7.5 marksNumericalNon-linear Regression by fitting ExponentiHideAnswer
Fit the quadratic function for the data given below using least square method.
x 1.0 1.5 2.0 2.5 3.0 3.5 4.0 f(x) 2.7 4.0 5.8 8.3 11.2 15.0 19.0 [5]
- Q8.5 marksNumericalMulti-Segment Simpson's 1/3 ruleHideAnswer
Simpson's 1/3 Rule Integration
Estimate the integral value of the following function from $x = 1.2$ to $x = 2.4$ using Simpson's 1/3 rule.
$$\begin{array}{c|cccccccc} x & 1.0 & 1.2 & 1.4 & 1.6 & 1.8 & 2.0 & 2.2 & 2.4 & 2.6 \ \hline f(x) & 1.53 & 2.25 & 3.18 & 4.32 & 5.67 & 7.23 & 8.98 & 10.94 & 13.08 \end{array}$$
[5]
- Q9.5 marksNumericalGaussian integration algorithmHideAnswer
What is Gaussian integration formula? Evaluate the following integration using Gaussian integration three ordinate formula. $$\int_{0}^{1} \frac{\sin x}{x} dx$$ [5]
- Q10.5 marksNumericalGauss-Seidal MethodHideAnswer
Solve the following set of equations using Gauss Siedal method.
$$ \begin{aligned} x + 2y + 3z &= 4 \ 6x + 4y + 5z &= 16 \ 5x + 2y + 3z &= 12 \end{aligned} $$
[5]
Gauss-Seidel Method
Given
The system of equations: $$x + 2y + 3z = 4 \quad \text{...(1)}$$ $$6x + 4y + 5z = 16 \quad \text{...(2)}$$ $$5x + 2y + 3z = 12 \quad \text{...(3)}$$
Initial guess (standard assumption): $x^{(0)} = y^{(0)} = z^{(0)} = 0$.
Solution
Analysis of Diagonal Dominance
For Gauss-Seidel to converge reliably, we should try to arrange the largest coefficients on the diagonal. Examine:
- Coefficient of $x$: largest in (2) and (3), both equal to 6 and 5.
- Coefficient of $y$: largest is 4 (in eq 2).
- Coefficient of $z$: largest is 5 (in eq 2).
The largest coefficients cluster in equation (2), so a clean diagonally dominant arrangement is not possible. This is a poorly conditioned system for Gauss-Seidel. However, following the standard exam approach (partial pivoting), we rearrange to place the largest coefficient in each row on the diagonal.
Rearranged system:
$$6x + 4y + 5z = 16 \Rightarrow x = \frac{16 - 4y - 5z}{6}$$ $$5x + 2y + 3z = 12 \Rightarrow y = \frac{12 - 5x - 3z}{2}$$ $$x + 2y + 3z = 4 \Rightarrow z = \frac{4 - x - 2y}{3}$$
Iteration 1 (from $x=y=z=0$)
$$x = \frac{16 - 0 - 0}{6} = 2.6667$$ $$y = \frac{12 - 5(2.6667) - 0}{2} = \frac{12 - 13.3333}{2} = -0.6667$$ $$z = \frac{4 - 2.6667 - 2(-0.6667)}{3} = \frac{4 - 2.6667 + 1.3333}{3} = \frac{2.6667}{3} = 0.8889$$
Iteration 2
$$x = \frac{16 - 4(-0.6667) - 5(0.8889)}{6} = \frac{16 + 2.6667 - 4.4444}{6} = \frac{14.2222}{6} = 2.3704$$ $$y = \frac{12 - 5(2.3704) - 3(0.8889)}{2} = \frac{12 - 11.8519 - 2.6667}{2} = \frac{-2.5185}{2} = -1.2593$$ $$z = \frac{4 - 2.3704 - 2(-1.2593)}{3} = \frac{4 - 2.3704 + 2.5185}{3} = \frac{4.1481}{3} = 1.3827$$
Iteration 3
$$x = \frac{16 - 4(-1.2593) - 5(1.3827)}{6} = \frac{16 + 5.0370 - 6.9136}{6} = \frac{14.1235}{6} = 2.3539$$ $$y = \frac{12 - 5(2.3539) - 3(1.3827)}{2} = \frac{12 - 11.7696 - 4.1481}{2} = \frac{-3.9177}{2} = -1.9588$$ $$z = \frac{4 - 2.3539 - 2(-1.9588)}{3} = \frac{4 - 2.3539 + 3.9177}{3} = \frac{5.5638}{3} = 1.8546$$
Iteration 4 (check on convergence)
$$x = \frac{16 - 4(-1.9588) - 5(1.8546)}{6} = \frac{16 + 7.8353 - 9.2730}{6} = \frac{14.5623}{6} = 2.4270$$ $$y = \frac{12 - 5(2.4270) - 3(1.8546)}{2} = \frac{12 - 12.1352 - 5.5638}{2} = \frac{-5.6990}{2} = -2.8495$$ $$z = \frac{4 - 2.4270 - 2(-2.8495)}{3} = \frac{4 - 2.4270 + 5.6990}{3} = \frac{7.2720}{3} = 2.4240$$
Summary Table
Iteration $x$ $y$ $z$ 0 0 0 0 1 2.6667 -0.6667 0.8889 2 2.3704 -1.2593 1.3827 3 2.3539 -1.9588 1.8546 4 2.4270 -2.8495 2.4240 Important Observation on Convergence
The iterates are diverging, not converging. The values of $y$ move $-0.67 \to -1.26 \to -1.96 \to -2.85$ and $z$ moves $0.89 \to 1.38 \to 1.85 \to 2.42$; the gaps are growing, not shrinking. This confirms the earlier note that the system is not diagonally dominant and no rearrangement makes it so, so Gauss-Seidel does not converge here.
Exact solution (by direct elimination, subtracting (1) from (3): $4x = 8 \Rightarrow x = 2$; then $2y + 3z = 2$ and $4y + 5z = 4$, giving $y = -1,\ z = ...$). Solving:
- From $4x=8$: $x = 2$.
- $2y + 3z = 4 - 2 = 2$.
- $4y + 5z = 16 - 12 = 4$.
- Multiply first by 2: $4y + 6z = 4$; subtract: $z = 0$, then $2y = 2 \Rightarrow y = 1$.
So the true solution is $x = 2,\ y = 1,\ z = 0$. The Gauss-Seidel iterates ($x\approx 2.4,\ y\approx -2.8,\ z\approx 2.4$) are moving away from this, confirming divergence.
Final Result
The iterations up to iteration 3 and 4 are as tabulated. The method does not converge here: the iterates move away from the exact solution $x=2,\ y=1,\ z=0$, so any claim that it settles near $x=2,\ y=-2,\ z=2$ would be wrong.
- Q11.5 marksNumericalRunge-Kutta methodsHideAnswer
Solve the following differential equation for $0 \leq x \leq 1$ taking $h = 0.5$ using Runge Kutta 4th order method.
$$y'(x) + y = 3x \quad \text{with} \quad y(0) = 2$$
[5]
Runge-Kutta 4th Order Method
Given
- ODE: $y'(x) + y = 3x \Rightarrow y' = f(x,y) = 3x - y$
- Initial condition: $y(0) = 2$
- Step size: $h = 0.5$
- Interval: $0 \le x \le 1$
- Number of steps: 2 (from $x=0$ to $x=1$)
RK4 Formulas
$$k_1 = h,f(x_n, y_n), \quad k_2 = h,f\left(x_n+\tfrac{h}{2}, y_n+\tfrac{k_1}{2}\right)$$ $$k_3 = h,f\left(x_n+\tfrac{h}{2}, y_n+\tfrac{k_2}{2}\right), \quad k_4 = h,f(x_n+h, y_n+k_3)$$ $$y_{n+1} = y_n + \tfrac{1}{6}(k_1 + 2k_2 + 2k_3 + k_4)$$
with $f(x,y) = 3x - y$.
Solution
Iteration 1: $x_0 = 0$, $y_0 = 2$
$$k_1 = 0.5,(3(0) - 2) = 0.5(-2) = -1.0$$
$$k_2 = 0.5,f(0.25,\ 2 - 0.5) = 0.5,(0.75 - 1.5) = 0.5(-0.75) = -0.375$$
$$k_3 = 0.5,f(0.25,\ 2 - 0.1875) = 0.5,(0.75 - 1.8125) = 0.5(-1.0625) = -0.53125$$
$$k_4 = 0.5,f(0.5,\ 2 - 0.53125) = 0.5,(1.5 - 1.46875) = 0.5(0.03125) = 0.015625$$
$$y_1 = 2 + \tfrac{1}{6}(-1.0 + 2(-0.375) + 2(-0.53125) + 0.015625)$$ $$= 2 + \tfrac{1}{6}(-1.0 - 0.75 - 1.0625 + 0.015625) = 2 + \tfrac{1}{6}(-2.796875)$$ $$= 2 - 0.466146 = \boxed{1.533854}$$
$$y(0.5) \approx 1.5339$$
Iteration 2: $x_1 = 0.5$, $y_1 = 1.533854$
$$k_1 = 0.5,f(0.5,\ 1.533854) = 0.5,(1.5 - 1.533854) = 0.5(-0.033854) = -0.016927$$
$$k_2 = 0.5,f(0.75,\ 1.533854 - 0.008464) = 0.5,(2.25 - 1.525390) = 0.5(0.724610) = 0.362305$$
$$k_3 = 0.5,f(0.75,\ 1.533854 + 0.181153) = 0.5,(2.25 - 1.715007) = 0.5(0.534993) = 0.267497$$
$$k_4 = 0.5,f(1.0,\ 1.533854 + 0.267497) = 0.5,(3.0 - 1.801351) = 0.5(1.198649) = 0.599325$$
$$y_2 = 1.533854 + \tfrac{1}{6}(-0.016927 + 2(0.362305) + 2(0.267497) + 0.599325)$$ $$= 1.533854 + \tfrac{1}{6}(-0.016927 + 0.724610 + 0.534993 + 0.599325)$$ $$= 1.533854 + \tfrac{1}{6}(1.842001) = 1.533854 + 0.307000$$ $$= \boxed{1.840854}$$
$$y(1.0) \approx 1.8409$$
Summary Table
$x$ $y$ $0.0$ $2.0000$ $0.5$ $1.5339$ $1.0$ $1.8409$ Check (exact): $y = 3x - 3 + 5e^{-x}$; at $x=1$: $y = 0 + 5e^{-1} = 1.8394$. RK4 value $1.8409$ agrees closely.
- Q12.5 marksNumericalLaplacian equation and Poisson's equationHideAnswer
Solve the Poisson's equation $\nabla^2 f = 3x^2y$ over the square domain $0 \leq x \leq 3$, $0 \leq y \leq 3$ with $f = 0$ on the boundary and $h = 1$. [5]
Poisson's Equation $\nabla^2 f = 3x^2y$ over $[0,3]\times[0,3]$, $f=0$ on boundary, $h=1$
Given
- PDE: $\nabla^2 f = 3x^2y$, so source $g(x,y) = 3x^2y$
- Domain: $0 \le x \le 3$, $0 \le y \le 3$ (square)
- Boundary condition: $f = 0$ on all boundaries
- Mesh size: $h = 1$
Solution
Grid
With $h=1$, interior nodes at $x=1,2$ and $y=1,2$. Four unknowns.
Label (using standard layout):
$x=1$ $x=2$ $y=2$ $f_1$ $f_2$ $y=1$ $f_3$ $f_4$ $f_1=f(1,2),\ f_2=f(2,2),\ f_3=f(1,1),\ f_4=f(2,1)$.
Five-point formula
$$f_{i+1,j}+f_{i-1,j}+f_{i,j+1}+f_{i,j-1}-4f_{i,j}=h^2,g(x_i,y_j)$$
with $h^2=1$.
Source term $g=3x^2y$
Node $x$ $y$ $g=3x^2y$ $f_1$ 1 2 6 $f_2$ 2 2 24 $f_3$ 1 1 3 $f_4$ 2 1 12 Equations (boundary values = 0)
At $f_1(1,2)$: neighbors $f_2$ (right), $0$ (left), $0$ (top, y=3), $f_3$ (bottom): $$-4f_1+f_2+f_3=6 \quad (1)$$
At $f_2(2,2)$: neighbors $0$ (right), $f_1$ (left), $0$ (top), $f_4$ (bottom): $$f_1-4f_2+f_4=24 \quad (2)$$
At $f_3(1,1)$: neighbors $f_4$ (right), $0$ (left), $f_1$ (top), $0$ (bottom): $$f_1-4f_3+f_4=3 \quad (3)$$
At $f_4(2,1)$: neighbors $0$ (right), $f_3$ (left), $f_2$ (top), $0$ (bottom): $$f_2+f_3-4f_4=12 \quad (4)$$
Solving
Sum of all four: $$-2(f_1+f_2+f_3+f_4)=45 \Rightarrow S = f_1+f_2+f_3+f_4 = -22.5 \quad (5)$$
Subtract (1)-(3): $$(-4f_1+f_2+f_3)-(f_1-4f_3+f_4)=6-3$$ $$-5f_1+f_2+5f_3-f_4=3 \quad (6)$$
Subtract (2)-(4): $$(f_1-4f_2+f_4)-(f_2+f_3-4f_4)=24-12$$ $$f_1-5f_2-f_3+5f_4=12 \quad (7)$$
Solve directly. From symmetry-free direct elimination, use variables.
Add (1)+(3): $-3f_1+f_2-3f_3+f_4=9 \quad (A)$ Add (2)+(4): $f_1-3f_2+f_3-3f_4=36 \quad (B)$
Let $P=f_1+f_3$, $Q=f_2+f_4$. Then $P+Q=-22.5$.
(A): $-3P+Q=9$ (B): $P-3Q=36$
From (A): $Q=9+3P$. Substitute into (B): $P-3(9+3P)=36 \Rightarrow P-27-9P=36 \Rightarrow -8P=63 \Rightarrow P=-7.875$. Then $Q=9+3(-7.875)=9-23.625=-14.625$. Check: $P+Q=-22.5$ ✓
Now subtract (1)-(3): $-5f_1+f_2+5f_3-f_4=3 \quad (6)$ Group as $-5(f_1-f_3)+(f_2-f_4)=3$. Let $U=f_1-f_3,\ V=f_2-f_4$: $$-5U+V=3 \quad (6')$$
Subtract (2)-(4): $f_1-5f_2-f_3+5f_4=12$ $= (f_1-f_3)-5(f_2-f_4)=12 \Rightarrow U-5V=12 \quad (7')$
From (6'): $V=3+5U$. Sub into (7'): $U-5(3+5U)=12 \Rightarrow U-15-25U=12 \Rightarrow -24U=27 \Rightarrow U=-1.125$. Then $V=3+5(-1.125)=3-5.625=-2.625$.
Recover values:
- $f_1=(P+U)/2=(-7.875-1.125)/2=-9/2=-4.5$
- $f_3=(P-U)/2=(-7.875+1.125)/2=-6.75/2=-3.375$
- $f_2=(Q+V)/2=(-14.625-2.625)/2=-17.25/2=-8.625$
- $f_4=(Q-V)/2=(-14.625+2.625)/2=-12/2=-6.0$
Verification in original equations
(1): $-4(-4.5)+(-8.625)+(-3.375)=18-12=6$ ✓ (2): $-4.5-4(-8.625)+(-6.0)=-4.5+34.5-6=24$ ✓ (3): $-4.5-4(-3.375)+(-6.0)=-4.5+13.5-6=3$ ✓ (4): $-8.625+(-3.375)-4(-6.0)=-12+24=12$ ✓
Final Result
$$\boxed{f_1=f(1,2)=-4.5,\quad f_2=f(2,2)=-8.625,\quad f_3=f(1,1)=-3.375,\quad f_4=f(2,1)=-6.0}$$