Skip to main content

Chapter 3

Numerical Methods

TU BIT past exam questions

Past questions and answers

60 questions set from this chapter. Most repeated first.

  • 2078 · 5 marks

Solve by Gauss elimination with pivoting: 2x+2y+z=62x+2y+z=6, 4x+2y+3z=44x+2y+3z=4, x−y+1=0x-y+1=0.

Similar questions: Solve by Gauss elimination with partial (2083)

Answer

Equations: 2x+2y+z=62x+2y+z=6, 4x+2y+3z=44x+2y+3z=4, x−y=−1x-y=-1.

Augmented matrix:

[221642341−10−1]\left[\begin{array}{ccc|c}2&2&1&6\\4&2&3&4\\1&-1&0&-1\end{array}\right]

Pivot 1. The largest entry in column 1 is 44, so swap R1↔R2R_1\leftrightarrow R_2:

[423422161−10−1]\left[\begin{array}{ccc|c}4&2&3&4\\2&2&1&6\\1&-1&0&-1\end{array}\right]

R2→R2−0.5R1R_2\to R_2-0.5R_1 and R3→R3−0.25R1R_3\to R_3-0.25R_1:

[423401−0.540−1.5−0.75−2]\left[\begin{array}{ccc|c}4&2&3&4\\0&1&-0.5&4\\0&-1.5&-0.75&-2\end{array}\right]

Pivot 2. The larger entry in column 2 is −1.5-1.5, so swap R2↔R3R_2\leftrightarrow R_3:

[42340−1.5−0.75−201−0.54]\left[\begin{array}{ccc|c}4&2&3&4\\0&-1.5&-0.75&-2\\0&1&-0.5&4\end{array}\right]

R3→R3+23R2R_3\to R_3+\tfrac23R_2:

[42340−1.5−0.75−200−183]\left[\begin{array}{ccc|c}4&2&3&4\\0&-1.5&-0.75&-2\\0&0&-1&\tfrac83\end{array}\right]

Back substitution

  • z=−83z=-\dfrac83
  • −1.5y−0.75(−83)=−2⇒−1.5y=−4⇒y=83-1.5y-0.75\left(-\dfrac83\right)=-2\Rightarrow -1.5y=-4\Rightarrow y=\dfrac83
  • 4x+2(83)+3(−83)=4⇒4x=203⇒x=534x+2\left(\dfrac83\right)+3\left(-\dfrac83\right)=4\Rightarrow 4x=\dfrac{20}{3}\Rightarrow x=\dfrac53

x=53≈1.667,  y=83≈2.667,  z=−83≈−2.667x=\dfrac53\approx1.667,\; y=\dfrac83\approx2.667,\; z=-\dfrac83\approx-2.667

Check in the third equation: 53−83=−1\frac53-\frac83=-1, which is correct.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2078 · 5 marks

Solve Poisson's equation abla2f=2x2y2 abla^2 f = 2x^2y^2 over 0≤x≤30\le x\le 3, 0≤y≤30\le y\le 3, with f=0f=0 on the boundary and h=1h=1.

Similar questions: Solve Poisson's equation $\frac{\partial^2 f}{\partial x^2}+\frac{\partial^2 (2080)

Answer

Use the five-point formula with h=1h=1:

fi+1,j+fi−1,j+fi,j+1+fi,j−1−4fi,j=h2⋅2x2y2f_{i+1,j}+f_{i-1,j}+f_{i,j+1}+f_{i,j-1}-4f_{i,j}=h^2\cdot2x^2y^2

The interior points are (1,1),(2,1),(1,2),(2,2)(1,1),(2,1),(1,2),(2,2) and all boundary values are 00. Let f1,1=pf_{1,1}=p, f2,1=f1,2=af_{2,1}=f_{1,2}=a and f2,2=qf_{2,2}=q (the problem is symmetric in xx and yy).

  • At (1,1)(1,1): 2a−4p=2(1)2(1)2=22a-4p=2(1)^2(1)^2=2
  • At (2,1)(2,1): p+q−4a=2(2)2(1)2=8p+q-4a=2(2)^2(1)^2=8
  • At (2,2)(2,2): 2a−4q=2(2)2(2)2=322a-4q=2(2)^2(2)^2=32

From the first, p=a−12p=\dfrac{a-1}{2}. From the third, q=a−162q=\dfrac{a-16}{2}. Substituting into the second:

2a−172−4a=8  ⇒  −3a=16.5  ⇒  a=−5.5\frac{2a-17}{2}-4a=8\;\Rightarrow\;-3a=16.5\;\Rightarrow\;a=-5.5

Then p=−3.25p=-3.25 and q=−10.75q=-10.75.

f(1,1)=−3.25,  f(2,1)=f(1,2)=−5.5,  f(2,2)=−10.75f(1,1)=-3.25,\; f(2,1)=f(1,2)=-5.5,\; f(2,2)=-10.75.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2080 · 5 marks

Solve Poisson's equation ∂2f∂x2+∂2f∂y2=2x2y2\frac{\partial^2 f}{\partial x^2}+\frac{\partial^2 f}{\partial y^2}=2x^2y^2 over the square domain 0≤x≤30\le x\le 3, 0≤y≤30\le y\le 3, with f=0f=0 on the boundary and h=1h=1.

Similar questions: Solve Poisson's equation $ abla^2 f (2078)

Answer

Use the five-point finite-difference formula with h=1h=1:

fi+1,j+fi−1,j+fi,j+1+fi,j−1−4fi,j=h2⋅2xi2yj2f_{i+1,j}+f_{i-1,j}+f_{i,j+1}+f_{i,j-1}-4f_{i,j}=h^2\cdot2x_i^2y_j^2

The interior points are (1,1),(2,1),(1,2),(2,2)(1,1),(2,1),(1,2),(2,2), with f=0f=0 on the boundary. By symmetry in xx and yy, write f1,1=pf_{1,1}=p, f2,1=f1,2=af_{2,1}=f_{1,2}=a, f2,2=qf_{2,2}=q.

  • Point (1,1)(1,1): 2a−4p=22a-4p=2
  • Point (2,1)(2,1): p+q−4a=8p+q-4a=8
  • Point (2,2)(2,2): 2a−4q=322a-4q=32

From the first and third equations, p=a−12p=\dfrac{a-1}{2} and q=a−162q=\dfrac{a-16}{2}. Substituting into the second:

2a−172−4a=8  ⇒  −3a=16.5  ⇒  a=−5.5\frac{2a-17}{2}-4a=8\;\Rightarrow\;-3a=16.5\;\Rightarrow\;a=-5.5

So p=−3.25p=-3.25 and q=−10.75q=-10.75.

f(1,1)=−3.25,  f(2,1)=f(1,2)=−5.5,  f(2,2)=−10.75f(1,1)=-3.25,\; f(2,1)=f(1,2)=-5.5,\; f(2,2)=-10.75.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2083 · 5 marks

Solve by Gauss elimination with partial pivoting: 2x+3y+z=92x+3y+z=9, x+4y+5z=15x+4y+5z=15, 3x+y+2z=103x+y+2z=10.

Similar questions: Solve by Gauss elimination with pivoting: (2078)

Answer

Augmented matrix:

[23191451531210]\left[\begin{array}{ccc|c} 2 & 3 & 1 & 9 \\ 1 & 4 & 5 & 15 \\ 3 & 1 & 2 & 10 \end{array}\right]

Pivot 1. The largest entry in column 1 is 3 (row 3). Swap R1↔R3R_1 \leftrightarrow R_3:

[31210145152319]\left[\begin{array}{ccc|c} 3 & 1 & 2 & 10 \\ 1 & 4 & 5 & 15 \\ 2 & 3 & 1 & 9 \end{array}\right]

Eliminate with R2←R2−13R1R_2 \leftarrow R_2 - \tfrac13 R_1 and R3←R3−23R1R_3 \leftarrow R_3 - \tfrac23 R_1:

[31210011/313/335/307/3−1/37/3]\left[\begin{array}{ccc|c} 3 & 1 & 2 & 10 \\ 0 & 11/3 & 13/3 & 35/3 \\ 0 & 7/3 & -1/3 & 7/3 \end{array}\right]

Pivot 2. Between 11/311/3 and 7/37/3, the larger is 11/311/3 (already in row 2), so no swap is needed. Apply R3←R3−711R2R_3 \leftarrow R_3 - \tfrac{7}{11}R_2:

[31210011/313/335/300−34/11−56/11]\left[\begin{array}{ccc|c} 3 & 1 & 2 & 10 \\ 0 & 11/3 & 13/3 & 35/3 \\ 0 & 0 & -34/11 & -56/11 \end{array}\right]

Back substitution.

z=56/1134/11=2817≈1.6471z = \frac{56/11}{34/11} = \frac{28}{17} \approx 1.6471

113y=353−133⋅2817  ⇒  11y=35−36417=23117  ⇒  y=2117≈1.2353\frac{11}{3}y = \frac{35}{3} - \frac{13}{3}\cdot\frac{28}{17} \;\Rightarrow\; 11y = 35 - \frac{364}{17} = \frac{231}{17} \;\Rightarrow\; y = \frac{21}{17} \approx 1.2353

3x=10−y−2z=10−2117−5617=9317  ⇒  x=3117≈1.82353x = 10 - y - 2z = 10 - \frac{21}{17} - \frac{56}{17} = \frac{93}{17} \;\Rightarrow\; x = \frac{31}{17} \approx 1.8235

Solution: x≈1.8235,  y≈1.2353,  z≈1.6471x \approx 1.8235,\; y \approx 1.2353,\; z \approx 1.6471.

Check in equation 1: 2(1.8235)+3(1.2353)+1.6471=3.647+3.706+1.647=9.0002(1.8235) + 3(1.2353) + 1.6471 = 3.647 + 3.706 + 1.647 = 9.000.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2078 · 10 marks

Derive the formula for Simpson's 3/8 rule for integration. Use the Secant method to estimate a root of x2−4x−10=0x^2-4x-10=0 with x1=4x_1=4, x2=2x_2=2.

Answer

Derivation of Simpson's 3/8 rule. Fit a cubic through four equally spaced points x0,x1=x0+h,x2,x3x_0, x_1=x_0+h, x_2, x_3 with values y0,…,y3y_0,\dots,y_3. Put x=x0+phx=x_0+ph, so dx=h dpdx=h\,dp and pp runs from 00 to 33. Newton's forward formula gives

y(p)=y0+p Δy0+p(p−1)2Δ2y0+p(p−1)(p−2)6Δ3y0y(p)=y_0+p\,\Delta y_0+\frac{p(p-1)}{2}\Delta^2y_0+\frac{p(p-1)(p-2)}{6}\Delta^3y_0

Integrating term by term over p=0p=0 to 33:

∫03dp=3,∫03p dp=92,∫03p(p−1)2dp=94,∫03p(p−1)(p−2)6dp=38\int_0^3 dp=3,\quad \int_0^3 p\,dp=\frac92,\quad \int_0^3\frac{p(p-1)}{2}dp=\frac94,\quad \int_0^3\frac{p(p-1)(p-2)}{6}dp=\frac38

I=h[3y0+92Δy0+94Δ2y0+38Δ3y0]I=h\left[3y_0+\frac92\Delta y_0+\frac94\Delta^2y_0+\frac38\Delta^3y_0\right]

Substitute Δy0=y1−y0\Delta y_0=y_1-y_0, Δ2y0=y2−2y1+y0\Delta^2y_0=y_2-2y_1+y_0, Δ3y0=y3−3y2+3y1−y0\Delta^3y_0=y_3-3y_2+3y_1-y_0 and collect terms:

I=∫x0x3f(x) dx≈3h8[y0+3y1+3y2+y3]I=\int_{x_0}^{x_3}f(x)\,dx\approx\frac{3h}{8}\left[y_0+3y_1+3y_2+y_3\right]

Secant method for f(x)=x2−4x−10f(x)=x^2-4x-10. The iteration is

xn+1=xn−f(xn)(xn−xn−1)f(xn)−f(xn−1)x_{n+1}=x_n-\frac{f(x_n)(x_n-x_{n-1})}{f(x_n)-f(x_{n-1})}

With x1=4x_1=4 and x2=2x_2=2: f(4)=−10f(4)=-10 and f(2)=−14f(2)=-14.

Stepxn−1x_{n-1}xnx_nxn+1x_{n+1}f(xn+1)f(x_{n+1})
1429.000035.0000
229.00004.0000-10.0000
39.00004.00005.1111-4.3210
44.00005.11115.95651.6541
55.11115.95655.7225-0.1431
65.95655.72255.7411-0.0040
75.72255.74115.74170.00001

The root is x≈5.7417x\approx 5.7417, which agrees with the exact value 2+14=5.74172+\sqrt{14}=5.7417.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2078 · 10 marks

What is a boundary value problem? Using the shooting method, solve y′′=6x2y''=6x^2 with y(0)=1y(0)=1 and y(1)=2y(1)=2 on (0,1)(0,1). Find y(0.5)y(0.5) taking h=0.5h=0.5.

Answer

Boundary value problem. A differential equation of order two or higher in which the conditions are given at more than one point, usually at the two ends of the interval (for example y(a)=αy(a)=\alpha and y(b)=βy(b)=\beta), is a boundary value problem. In an initial value problem, all conditions are given at a single point.

Shooting method. Replace the BVP by an IVP. Guess the missing slope y′(0)=sy'(0)=s, integrate to x=bx=b, and compare y(b)y(b) with the required value. Adjust ss by linear interpolation (secant) until y(b)y(b) matches the boundary value.

Here y′′=6x2y''=6x^2, y(0)=1y(0)=1, y(1)=2y(1)=2. Write z=y′z=y', so y′=zy'=z and z′=6x2z'=6x^2. Integrating the second equation gives z=2x3+sz=2x^3+s and then

y(x)=x42+sx+1y(x)=\frac{x^4}{2}+sx+1

This is exact, so it agrees with Euler/RK stepping on this problem.

  • Trial 1, s=0s=0: y(1)=0.5+0+1=1.5y(1)=0.5+0+1=1.5.
  • Trial 2, s=1s=1: y(1)=0.5+1+1=2.5y(1)=0.5+1+1=2.5.

The target is y(1)=2y(1)=2. Because y(1)y(1) is linear in ss,

s=0+2−1.52.5−1.5(1−0)=0.5s=0+\frac{2-1.5}{2.5-1.5}(1-0)=0.5

Then with h=0.5h=0.5:

y(0.5)=0.542+0.5(0.5)+1=0.03125+0.25+1=1.28125y(0.5)=\frac{0.5^4}{2}+0.5(0.5)+1=0.03125+0.25+1=1.28125

Answer: y(0.5)≈1.28125y(0.5)\approx 1.28125.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2078 · 10 marks

Write an algorithm and a program to compute interpolation using Lagrange's method.

Answer

Algorithm (Lagrange interpolation)

  1. Read nn, the data points (xi,yi)(x_i,y_i) for i=0,…,n−1i=0,\dots,n-1, and the point xpx_p at which to interpolate.
  2. Set sum=0sum=0.
  3. For i=0i=0 to n−1n-1:
    • set term=yiterm=y_i;
    • for j=0j=0 to n−1n-1 with j≠ij\ne i, set term=term×xp−xjxi−xjterm=term\times\dfrac{x_p-x_j}{x_i-x_j};
    • set sum=sum+termsum=sum+term.
  4. Print sumsum as f(xp)f(x_p).
  5. Stop.

The formula used is

f(xp)=∑i=0n−1yi∏j=0j≠in−1xp−xjxi−xjf(x_p)=\sum_{i=0}^{n-1}y_i\prod_{\substack{j=0\\ j\ne i}}^{n-1}\frac{x_p-x_j}{x_i-x_j}

C program

#include <stdio.h>

int main(void) {
    int n, i, j;
    double x[20], y[20], xp, sum = 0.0, term;

    printf("Enter number of data points: ");
    scanf("%d", &n);
    printf("Enter x and y values:\n");
    for (i = 0; i < n; i++)
        scanf("%lf %lf", &x[i], &y[i]);

    printf("Enter the value of x to interpolate: ");
    scanf("%lf", &xp);

    for (i = 0; i < n; i++) {
        term = y[i];
        for (j = 0; j < n; j++) {
            if (j != i)
                term *= (xp - x[j]) / (x[i] - x[j]);
        }
        sum += term;
    }

    printf("f(%.4f) = %.6f\n", xp, sum);
    return 0;
}

The x values must be distinct, otherwise the program divides by zero.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2078 · 5 marks

Show that the Newton-Raphson method converges quadratically.

Answer

Newton-Raphson iteration. For f(x)=0f(x)=0,

xn+1=xn−f(xn)f′(xn)x_{n+1}=x_n-\frac{f(x_n)}{f'(x_n)}

Let α\alpha be a simple root, so f(α)=0f(\alpha)=0 and f′(α)≠0f'(\alpha)\ne0. Define the error en=xn−αe_n=x_n-\alpha.

Expand f(α)f(\alpha) about xnx_n by Taylor's theorem, with ξ\xi between xnx_n and α\alpha:

0=f(α)=f(xn)+(α−xn)f′(xn)+(α−xn)22f′′(ξ)0=f(\alpha)=f(x_n)+(\alpha-x_n)f'(x_n)+\frac{(\alpha-x_n)^2}{2}f''(\xi)

Divide by f′(xn)f'(x_n) and rearrange:

xn−f(xn)f′(xn)−α=f′′(ξ)2f′(xn)(xn−α)2x_n-\frac{f(x_n)}{f'(x_n)}-\alpha=\frac{f''(\xi)}{2f'(x_n)}(x_n-\alpha)^2

The left side is xn+1−α=en+1x_{n+1}-\alpha=e_{n+1}, so

en+1=f′′(ξ)2f′(xn) en2e_{n+1}=\frac{f''(\xi)}{2f'(x_n)}\,e_n^2

As xn→αx_n\to\alpha, we have ξ→α\xi\to\alpha and

∣en+1∣≈∣f′′(α)2f′(α)∣ ∣en∣2=C ∣en∣2|e_{n+1}|\approx\left|\frac{f''(\alpha)}{2f'(\alpha)}\right|\,|e_n|^2=C\,|e_n|^2

The new error is proportional to the square of the previous error, so the order of convergence is 22 (quadratic). The number of correct digits roughly doubles with every iteration once xnx_n is close to the root.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2078 · 5 marks

The temperature of a metal strip was recorded over time: t (min) = 1, 2, 3, 4; T (°C) = 70, 83, 100, 124. If T=bet/4+aT = be^{t/4} + a, estimate the temperature at t=6t = 6 min.

Answer

Let X=et/4X=e^{t/4}. Then T=bX+aT=bX+a is linear in XX, and least squares applies.

ttTTX=et/4X=e^{t/4}X2X^2XTXT
1701.284031.6487289.882
2831.648722.71828136.844
31002.117004.48169211.700
41242.718287.38906337.067
Sum3777.7680316.23775775.493

Normal equations:

4a+7.76803 b=377,7.76803 a+16.23775 b=775.4934a+7.76803\,b=377,\qquad 7.76803\,a+16.23775\,b=775.493

Solving gives b≈37.63b\approx37.63 and a≈21.17a\approx21.17, so

T=37.63 et/4+21.17T=37.63\,e^{t/4}+21.17

At t=6t=6, e1.5=4.4817e^{1.5}=4.4817:

T=37.63(4.4817)+21.17=168.64+21.17≈189.8T=37.63(4.4817)+21.17=168.64+21.17\approx189.8

Estimated temperature at t=6t=6 min is about 190 ∘190\,^\circC.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2078 · 5 marks

Given the data below, construct the divided difference table and use it to estimate f(1.5)f(1.5).
xx12345
f(x)=x3−1f(x)=x^3-1072663124

Answer

Divided difference table

xxff1st2nd3rd4th
10
7
276
191
32690
371
46312
61
5124

Each entry is difference of the two entries to its leftxi+k−xi\dfrac{\text{difference of the two entries to its left}}{x_{i+k}-x_i}. For example, 19−73−1=6\dfrac{19-7}{3-1}=6.

Newton's divided difference polynomial (the 4th difference is 00, as expected for a cubic):

f(x)=0+7(x−1)+6(x−1)(x−2)+1(x−1)(x−2)(x−3)f(x)=0+7(x-1)+6(x-1)(x-2)+1(x-1)(x-2)(x-3)

At x=1.5x=1.5:

f(1.5)=7(0.5)+6(0.5)(−0.5)+(0.5)(−0.5)(−1.5)=3.5−1.5+0.375=2.375f(1.5)=7(0.5)+6(0.5)(-0.5)+(0.5)(-0.5)(-1.5)=3.5-1.5+0.375=2.375

f(1.5)=2.375f(1.5)=2.375, which equals 1.53−11.5^3-1 exactly.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2078 · 5 marks

Find the eigenvalues and corresponding eigenvectors of A=[161120003]A=\begin{bmatrix}1&6&1\\1&2&0\\0&0&3\end{bmatrix}.

Answer

Characteristic equation ∣A−λI∣=0|A-\lambda I|=0. Expanding along the third row:

(3−λ)[(1−λ)(2−λ)−6]=(3−λ)(λ2−3λ−4)=(3−λ)(λ−4)(λ+1)=0(3-\lambda)\big[(1-\lambda)(2-\lambda)-6\big]=(3-\lambda)(\lambda^2-3\lambda-4)=(3-\lambda)(\lambda-4)(\lambda+1)=0

Eigenvalues: λ=4,  3,  −1\lambda=4,\;3,\;-1.

For λ=4\lambda=4: (A−4I)v=0(A-4I)v=0 gives −3x+6y+z=0-3x+6y+z=0, x−2y=0x-2y=0, −z=0-z=0. So z=0z=0, x=2yx=2y:

v1=[210]v_1=\begin{bmatrix}2\\1\\0\end{bmatrix}

For λ=3\lambda=3: −2x+6y+z=0-2x+6y+z=0, x−y=0x-y=0, 0=00=0. So x=yx=y and z=−4xz=-4x:

v2=[11−4]v_2=\begin{bmatrix}1\\1\\-4\end{bmatrix}

For λ=−1\lambda=-1: 2x+6y+z=02x+6y+z=0, x+3y=0x+3y=0, 4z=04z=0. So z=0z=0, x=−3yx=-3y:

v3=[3−10]v_3=\begin{bmatrix}3\\-1\\0\end{bmatrix}

Any non-zero scalar multiple of each vector is also an eigenvector.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2078 · 5 marks

The distance travelled by a car at various times is given below: t (sec) = 5, 6, 7, 8, 9; Distance (m) = 10.0, 14.5, 19.5, 25.5, 32.0. Estimate the velocity and acceleration at t=7t = 7 sec.

Answer

Step size h=1h=1 s. Use central differences at t=7t=7 with s(6)=14.5s(6)=14.5, s(7)=19.5s(7)=19.5, s(8)=25.5s(8)=25.5.

Velocity

v=dsdt≈s(8)−s(6)2h=25.5−14.52=5.5 m/sv=\frac{ds}{dt}\approx\frac{s(8)-s(6)}{2h}=\frac{25.5-14.5}{2}=5.5\ \text{m/s}

Acceleration

a=d2sdt2≈s(8)−2s(7)+s(6)h2=25.5−39.0+14.51=1.0 m/s2a=\frac{d^2s}{dt^2}\approx\frac{s(8)-2s(7)+s(6)}{h^2}=\frac{25.5-39.0+14.5}{1}=1.0\ \text{m/s}^2

At t=7t=7 s: velocity ≈5.5\approx5.5 m/s and acceleration ≈1.0\approx1.0 m/s2^2.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2078 · 5 marks

Using the trapezoidal rule with n=8n=8, evaluate I=∫24(x4+1) dxI=\int_{2}^{4}(x^4+1)\,dx.

Answer

I=∫24(x4+1)dxI=\int_2^4(x^4+1)dx with n=8n=8, so h=4−28=0.25h=\dfrac{4-2}{8}=0.25. The rule is

I≈h2[f0+f8+2(f1+⋯+f7)]I\approx\frac h2\Big[f_0+f_8+2(f_1+\dots+f_7)\Big]

iixix_if(xi)=xi4+1f(x_i)=x_i^4+1
02.0017.0000
12.2526.6289
22.5040.0625
32.7558.1914
43.0082.0000
53.25112.5664
63.50151.0625
73.75198.7539
84.00257.0000

Sum of interior values =669.2656=669.2656.

I≈0.125[17+257+2(669.2656)]=0.125(1612.5312)≈201.566I\approx0.125\big[17+257+2(669.2656)\big]=0.125(1612.5312)\approx201.566

I≈201.57I\approx201.57. The exact value is 200.4200.4, so the trapezoidal rule overestimates slightly because ff is convex.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2078 · 5 marks

Given y′=3x2+1y'=3x^2+1 with y(1)=2y(1)=2, estimate y(2)y(2) by Euler's method using h=0.2h=0.2.

Answer

y′=3x2+1y'=3x^2+1, y(1)=2y(1)=2, h=0.2h=0.2. Euler's formula: yn+1=yn+h f(xn,yn)y_{n+1}=y_n+h\,f(x_n,y_n).

nnxnx_nyny_nf=3xn2+1f=3x_n^2+1yn+1y_{n+1}
01.02.0004.002.800
11.22.8005.323.864
21.43.8646.885.240
31.65.2408.686.976
41.86.97610.729.120

y(2)≈9.12y(2)\approx9.12. The exact solution is y=x3+xy=x^3+x, giving y(2)=10y(2)=10, so Euler with this step size underestimates.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2079 · 10 marks

Define true error and relative error. Derive the bisection method for a nonlinear equation and apply it to 2x3−2x−5=02x^3-2x-5=0 with x0=1x_0=1 and x1=2x_1=2, up to 10 iterations.

Answer

True error: Et=true value−approximate valueE_t=\text{true value}-\text{approximate value}.

Relative (true) error: εt=Ettrue value\varepsilon_t=\dfrac{E_t}{\text{true value}}, often given as a percentage.

Bisection method (derivation). Suppose ff is continuous on [a,b][a,b] and f(a)f(b)<0f(a)f(b)<0. By the intermediate value theorem there is a root in (a,b)(a,b). Take the midpoint

c=a+b2c=\frac{a+b}{2}

  • If f(c)=0f(c)=0, then cc is the root.
  • If f(a)f(c)<0f(a)f(c)<0, the root lies in [a,c][a,c], so set b=cb=c.
  • Otherwise the root lies in [c,b][c,b], so set a=ca=c.

Repeat. The interval halves every step, so after nn steps its width is (b−a)/2n(b-a)/2^n.

Application: f(x)=2x3−2x−5f(x)=2x^3-2x-5 on [1,2][1,2]. Here f(1)=−5<0f(1)=-5<0 and f(2)=7>0f(2)=7>0.

nnaabbc=a+b2c=\frac{a+b}{2}f(c)f(c)
1121.5-1.2500
21.521.752.2188
31.51.751.6250.3320
41.51.6251.5625-0.4956
51.56251.6251.59375-0.0911
61.593751.6251.6093750.1181
71.593751.6093751.6015630.0129
81.593751.6015631.597656-0.0393
91.5976561.6015631.599609-0.0132
101.5996091.6015631.600586-0.0002

After 10 iterations the root is x≈1.6006x\approx1.6006 (accurate to about three decimal places).

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2079 · 10 marks

Describe applications of interpolation and distinguish interpolation from regression. Using Lagrange's interpolation, estimate f(10)f(10) from: x = 5, 6, 9, 11; y = 13, 14, 15, 16.

Answer

Applications of interpolation

  • Estimating values between tabulated data, for example from a table of sines, logarithms or steam tables.
  • Reconstructing missing readings from experiments or sensors.
  • Numerical differentiation and integration, which are built on interpolating polynomials.
  • Computer graphics and image resizing (curves, surfaces, resampling).

Interpolation versus regression

InterpolationRegression (curve fitting)
The curve passes exactly through every data point.The curve passes near the points and need not touch any.
Suited to accurate, precise data.Suited to noisy or experimental data.
Polynomial degree =n−1=n-1 for nn points.Degree chosen by the user, usually much lower than n−1n-1.
No error at the data points.Minimises the sum of squared errors (least squares).

Lagrange interpolation at x=10x=10 with x=5,6,9,11x=5,6,9,11 and y=13,14,15,16y=13,14,15,16:

L0=(10−6)(10−9)(10−11)(5−6)(5−9)(5−11)=−4−24=16L_0=\frac{(10-6)(10-9)(10-11)}{(5-6)(5-9)(5-11)}=\frac{-4}{-24}=\frac16

L1=(10−5)(10−9)(10−11)(6−5)(6−9)(6−11)=−515=−13L_1=\frac{(10-5)(10-9)(10-11)}{(6-5)(6-9)(6-11)}=\frac{-5}{15}=-\frac13

L2=(10−5)(10−6)(10−11)(9−5)(9−6)(9−11)=−20−24=56L_2=\frac{(10-5)(10-6)(10-11)}{(9-5)(9-6)(9-11)}=\frac{-20}{-24}=\frac56

L3=(10−5)(10−6)(10−9)(11−5)(11−6)(11−9)=2060=13L_3=\frac{(10-5)(10-6)(10-9)}{(11-5)(11-6)(11-9)}=\frac{20}{60}=\frac13

f(10)=13(16)+14(−13)+15(56)+16(13)=136−286+756+326=926f(10)=13\left(\tfrac16\right)+14\left(-\tfrac13\right)+15\left(\tfrac56\right)+16\left(\tfrac13\right)=\tfrac{13}{6}-\tfrac{28}{6}+\tfrac{75}{6}+\tfrac{32}{6}=\tfrac{92}{6}

f(10)≈15.33f(10)\approx15.33. The weights sum to 16−13+56+13=1\frac16-\frac13+\frac56+\frac13=1, as they must.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2079 · 10 marks

Explain numerical integration and give one application. Write an algorithm and a C program for the multi-segment trapezoidal rule.

Answer

Numerical integration means approximating a definite integral ∫abf(x) dx\int_a^b f(x)\,dx by a weighted sum of function values, ∑wif(xi)\sum w_if(x_i). It is needed when ff has no closed-form antiderivative or when ff is known only as a table of values.

Application: finding the distance travelled from tabulated speed readings, or the area of an irregular plot of land from measured offsets.

Multi-segment trapezoidal rule. Divide [a,b][a,b] into nn equal segments of width h=b−anh=\dfrac{b-a}{n}:

I≈h2[f(x0)+2∑i=1n−1f(xi)+f(xn)]I\approx\frac h2\Big[f(x_0)+2\sum_{i=1}^{n-1}f(x_i)+f(x_n)\Big]

Algorithm

  1. Read aa, bb and nn.
  2. Set h=(b−a)/nh=(b-a)/n and sum=f(a)+f(b)sum=f(a)+f(b).
  3. For i=1i=1 to n−1n-1: set x=a+ihx=a+ih and sum=sum+2f(x)sum=sum+2f(x).
  4. Set I=(h/2)×sumI=(h/2)\times sum.
  5. Print II and stop.

C program (the example integrand is f(x)=11+x2f(x)=\dfrac1{1+x^2})

#include <stdio.h>

double f(double x) {
    return 1.0 / (1.0 + x * x);
}

int main(void) {
    double a, b, h, sum, x, I;
    int n, i;

    printf("Enter lower limit a, upper limit b: ");
    scanf("%lf %lf", &a, &b);
    printf("Enter number of segments n: ");
    scanf("%d", &n);

    h = (b - a) / n;
    sum = f(a) + f(b);
    for (i = 1; i < n; i++) {
        x = a + i * h;
        sum += 2.0 * f(x);
    }
    I = (h / 2.0) * sum;

    printf("Integral = %.6f\n", I);
    return 0;
}

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2079 · 5 marks

Construct the divided difference table for the data below, then find the first and second derivatives at x=2x=2. x = 1, 2, 4, 8, 10; y = 0, 1, 5, 21, 27.

Answer

Data: x=1,2,4,8,10x=1,2,4,8,10 and y=0,1,5,21,27y=0,1,5,21,27.

Divided difference table

xxyy1st2nd3rd4th
10
1
211/3
20
451/3-1/144
4-1/16
821-1/6
3
1027

For example, f[2,4,8]=4−28−2=13f[2,4,8]=\dfrac{4-2}{8-2}=\dfrac13 and f[2,4,8,10]=−1/6−1/310−2=−116f[2,4,8,10]=\dfrac{-1/6-1/3}{10-2}=-\dfrac1{16}.

Interpolating polynomial

P(x)=(x−1)+13(x−1)(x−2)−1144(x−1)(x−2)(x−4)(x−8)P(x)=(x-1)+\tfrac13(x-1)(x-2)-\tfrac1{144}(x-1)(x-2)(x-4)(x-8)

First derivative at x=2x=2. Let g(x)=(x−1)(x−2)(x−4)(x−8)g(x)=(x-1)(x-2)(x-4)(x-8). Since (x−2)(x-2) is a factor, g′(2)=(2−1)(2−4)(2−8)=12g'(2)=(2-1)(2-4)(2-8)=12. Then

P′(2)=1+13(2⋅2−3)−12144=1+13−112=1712≈1.417P'(2)=1+\tfrac13(2\cdot2-3)-\tfrac{12}{144}=1+\tfrac13-\tfrac1{12}=\tfrac{17}{12}\approx1.417

Second derivative at x=2x=2. Write g=(x−2)hg=(x-2)h with h=(x−1)(x−4)(x−8)=x3−13x2+44x−32h=(x-1)(x-4)(x-8)=x^3-13x^2+44x-32. Then g′′(2)=2h′(2)=2(3⋅4−26⋅2+44)=2(4)=8g''(2)=2h'(2)=2(3\cdot4-26\cdot2+44)=2(4)=8, and

P′′(2)=23−8144=23−118=1118≈0.611P''(2)=\tfrac23-\tfrac8{144}=\tfrac23-\tfrac1{18}=\tfrac{11}{18}\approx0.611

f′(2)≈1.417f'(2)\approx1.417 and f′′(2)≈0.611f''(2)\approx0.611.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2079 · 5 marks

Explain the least squares method of curve fitting. Fit a second-order polynomial to: x = 1, 2, 3, 4, 5, 6, 7; y = 2, 6, 7, 8, 10, 12, 15.

Answer

Least squares method. Given data (xi,yi)(x_i,y_i), choose the curve's parameters so that the sum of squares of the vertical deviations S=∑[yi−f(xi)]2S=\sum[y_i-f(x_i)]^2 is minimum. Setting the partial derivative of SS with respect to each parameter to zero gives the normal equations. For y=a0+a1x+a2x2y=a_0+a_1x+a_2x^2:

∑y=na0+a1∑x+a2∑x2\sum y=na_0+a_1\sum x+a_2\sum x^2 ∑xy=a0∑x+a1∑x2+a2∑x3\sum xy=a_0\sum x+a_1\sum x^2+a_2\sum x^3 ∑x2y=a0∑x2+a1∑x3+a2∑x4\sum x^2y=a_0\sum x^2+a_1\sum x^3+a_2\sum x^4

Sums for the data (n=7n=7): ∑x=28\sum x=28, ∑x2=140\sum x^2=140, ∑x3=784\sum x^3=784, ∑x4=4676\sum x^4=4676, ∑y=60\sum y=60, ∑xy=294\sum xy=294, ∑x2y=1634\sum x^2y=1634.

7a0+28a1+140a2=607a_0+28a_1+140a_2=60 28a0+140a1+784a2=29428a_0+140a_1+784a_2=294 140a0+784a1+4676a2=1634140a_0+784a_1+4676a_2=1634

Solving gives a0=87=1.1429a_0=\dfrac87=1.1429, a1=7342=1.7381a_1=\dfrac{73}{42}=1.7381 and a2=142=0.0238a_2=\dfrac1{42}=0.0238.

y≈1.1429+1.7381x+0.0238x2y\approx1.1429+1.7381x+0.0238x^2

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2079 · 5 marks

Solve by the Gauss-Seidel method: 10x+y+z=1210x+y+z=12, 2x+10y+z=132x+10y+z=13, 2x+2y+10z=142x+2y+10z=14.

Answer

The system is diagonally dominant, so Gauss-Seidel converges. Rearrange:

x=12−y−z10,y=13−2x−z10,z=14−2x−2y10x=\frac{12-y-z}{10},\quad y=\frac{13-2x-z}{10},\quad z=\frac{14-2x-2y}{10}

Start with x=y=z=0x=y=z=0 and always use the newest values.

Iterationxxyyzz
11.20001.06000.9480
20.99921.00540.9991
30.99961.00021.0001
41.00001.00001.0000

Solution: x=1,  y=1,  z=1x=1,\; y=1,\; z=1.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2079 · 5 marks

Using Heun's method with h=0.2h=0.2, find yy at x=0.6x=0.6 for dydx=1−2xy\frac{dy}{dx}=1-2xy, given y=0y=0 at x=0x=0.

Answer

dydx=f(x,y)=1−2xy\dfrac{dy}{dx}=f(x,y)=1-2xy, y(0)=0y(0)=0, h=0.2h=0.2. Heun's method:

yn+1∗=yn+hf(xn,yn),yn+1=yn+h2[f(xn,yn)+f(xn+1,yn+1∗)]y^*_{n+1}=y_n+hf(x_n,y_n),\qquad y_{n+1}=y_n+\frac h2\big[f(x_n,y_n)+f(x_{n+1},y^*_{n+1})\big]

Step 1 (x0=0, y0=0x_0=0,\ y_0=0): f=1f=1, y∗=0.2y^*=0.2, f(0.2,0.2)=1−0.08=0.92f(0.2,0.2)=1-0.08=0.92,

y1=0+0.1(1+0.92)=0.1920y_1=0+0.1(1+0.92)=0.1920

Step 2 (x1=0.2, y1=0.192x_1=0.2,\ y_1=0.192): f=1−2(0.2)(0.192)=0.9232f=1-2(0.2)(0.192)=0.9232, y∗=0.192+0.2(0.9232)=0.37664y^*=0.192+0.2(0.9232)=0.37664, f(0.4,0.37664)=1−0.8(0.37664)=0.69869f(0.4,0.37664)=1-0.8(0.37664)=0.69869,

y2=0.192+0.1(0.9232+0.69869)=0.35419y_2=0.192+0.1(0.9232+0.69869)=0.35419

Step 3 (x2=0.4, y2=0.35419x_2=0.4,\ y_2=0.35419): f=1−0.8(0.35419)=0.71665f=1-0.8(0.35419)=0.71665, y∗=0.35419+0.2(0.71665)=0.49752y^*=0.35419+0.2(0.71665)=0.49752, f(0.6,0.49752)=1−1.2(0.49752)=0.40298f(0.6,0.49752)=1-1.2(0.49752)=0.40298,

y3=0.35419+0.1(0.71665+0.40298)=0.46615y_3=0.35419+0.1(0.71665+0.40298)=0.46615

y(0.6)≈0.466y(0.6)\approx0.466.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2079 · 5 marks

Explain why the composite Simpson's 3/8 rule is preferred over the simple Simpson's 3/8 rule. Then apply Simpson's 3/8 rule to: x = 0, 1, 2, 3, 4, 5, 6; y = 1, 0.5, 0.2, 0.1, 0.0588, 0.0385, 0.027.

Answer

Why the composite rule is preferred. The simple 3/8 rule uses a single cubic over only three sub-intervals, so over a wide interval the error is large (it depends on h5f(4)(ξ)h^5f^{(4)}(\xi) with a large hh). The composite rule applies the 3/8 rule repeatedly over successive groups of three sub-intervals and adds the results. This lets hh be small, so the error falls to O(h4)O(h^4) overall, and the rule handles any interval whose number of sub-intervals is a multiple of 33.

Composite Simpson's 3/8 rule (number of intervals nn a multiple of 3):

I≈3h8[y0+3(y1+y2+y4+y5)+2y3+y6]I\approx\frac{3h}{8}\Big[y_0+3(y_1+y_2+y_4+y_5)+2y_3+y_6\Big]

Application. Here h=1h=1 and n=6n=6 (two groups of three intervals).

I≈38[1+3(0.5+0.2+0.0588+0.0385)+2(0.1)+0.027]I\approx\frac{3}{8}\Big[1+3(0.5+0.2+0.0588+0.0385)+2(0.1)+0.027\Big]

=38[1+3(0.7973)+0.2+0.027]=38 (3.6189)≈1.357=\frac38\Big[1+3(0.7973)+0.2+0.027\Big]=\frac38\,(3.6189)\approx1.357

I≈1.357I\approx1.357.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2079 · 5 marks

Solve by Gaussian elimination: 2x+2y+z=122x+2y+z=12, 3x+2y+2z=83x+2y+2z=8, 5x+10y−8z=105x+10y-8z=10.

Answer

[221123228510−810]\left[\begin{array}{ccc|c}2&2&1&12\\3&2&2&8\\5&10&-8&10\end{array}\right]

Forward elimination

R2→R2−1.5R1R_2\to R_2-1.5R_1 and R3→R3−2.5R1R_3\to R_3-2.5R_1:

[221120−10.5−1005−10.5−20]\left[\begin{array}{ccc|c}2&2&1&12\\0&-1&0.5&-10\\0&5&-10.5&-20\end{array}\right]

R3→R3+5R2R_3\to R_3+5R_2:

[221120−10.5−1000−8−70]\left[\begin{array}{ccc|c}2&2&1&12\\0&-1&0.5&-10\\0&0&-8&-70\end{array}\right]

Back substitution

  • z=−70−8=8.75z=\dfrac{-70}{-8}=8.75
  • −y+0.5(8.75)=−10⇒y=14.375-y+0.5(8.75)=-10\Rightarrow y=14.375
  • 2x+2(14.375)+8.75=12⇒2x=−25.5⇒x=−12.752x+2(14.375)+8.75=12\Rightarrow 2x=-25.5\Rightarrow x=-12.75

x=−12.75,  y=14.375,  z=8.75x=-12.75,\; y=14.375,\; z=8.75.

Check in the second equation: 3(−12.75)+2(14.375)+2(8.75)=−38.25+28.75+17.5=83(-12.75)+2(14.375)+2(8.75)=-38.25+28.75+17.5=8.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2079 · 5 marks

Define eigenvalue and eigenvector. Explain how the shooting method solves a boundary value problem.

Answer

Eigenvalue and eigenvector. For a square matrix AA, a scalar λ\lambda is an eigenvalue if there is a non-zero vector vv with

Av=λvAv=\lambda v

The vector vv is the corresponding eigenvector. The eigenvalues are the roots of the characteristic equation ∣A−λI∣=0|A-\lambda I|=0, and each eigenvector is a non-zero solution of (A−λI)v=0(A-\lambda I)v=0.

Shooting method for a BVP. Consider y′′=f(x,y,y′)y''=f(x,y,y') with y(a)=αy(a)=\alpha and y(b)=βy(b)=\beta.

  1. Convert to a first-order system with z=y′z=y': y′=zy'=z, z′=f(x,y,z)z'=f(x,y,z).
  2. Guess the missing initial slope z(a)=s1z(a)=s_1 and solve the resulting IVP (Euler, Runge-Kutta) from aa to bb. Record y(b;s1)y(b;s_1).
  3. Compare y(b;s1)y(b;s_1) with β\beta. Take a second guess s2s_2 and find y(b;s2)y(b;s_2).
  4. Improve the guess by the secant (linear interpolation) formula s3=s2+(β−y(b;s2))(s2−s1)y(b;s2)−y(b;s1)s_3=s_2+\frac{(\beta-y(b;s_2))(s_2-s_1)}{y(b;s_2)-y(b;s_1)}
  5. Repeat until ∣y(b;s)−β∣|y(b;s)-\beta| is within tolerance. For a linear ODE, one interpolation gives the exact slope.
  6. The IVP solution with this final slope is the solution of the BVP.

The method is called shooting because adjusting ss is like adjusting the angle of a gun until the shot hits the target at x=bx=b.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2079 · 5 marks

A steel plate measures 24 cm x 24 cm. Two opposite sides are held at 100 °C and the other two at 0 °C. Using an 8 cm grid, find the steady-state temperatures at the interior points.

Answer

The plate is 24×2424\times24 cm and the grid spacing is 88 cm, so there are 3×33\times3 divisions and 2×2=42\times2=4 interior points. Let the top and bottom edges be at 100 ∘100\,^\circC and the left and right edges at 0 ∘0\,^\circC. Label the interior points u1,u2u_1,u_2 (top row) and u3,u4u_3,u_4 (bottom row).

Laplace's equation in difference form: each interior temperature is the average of its four neighbours.

u1=100+0+u2+u34,u2=100+0+u1+u44u_1=\frac{100+0+u_2+u_3}{4},\quad u_2=\frac{100+0+u_1+u_4}{4} u3=100+0+u1+u44,u4=100+0+u2+u34u_3=\frac{100+0+u_1+u_4}{4},\quad u_4=\frac{100+0+u_2+u_3}{4}

By symmetry all four are equal, u1=u2=u3=u4=uu_1=u_2=u_3=u_4=u, so

4u=100+0+u+u  ⇒  2u=100  ⇒  u=504u=100+0+u+u\;\Rightarrow\;2u=100\;\Rightarrow\;u=50

All four interior points are at 50 ∘50\,^\circC.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2079 · 5 marks

Write an algorithm for Horner's method. Use it to evaluate f(x)=x4+3x3+5x2+7x+9f(x)=x^4+3x^3+5x^2+7x+9 at x=2x=2.

Answer

Algorithm (Horner's method for f(x)=anxn+⋯+a1x+a0f(x)=a_nx^n+\dots+a_1x+a_0)

  1. Read nn, the coefficients an,…,a0a_n,\dots,a_0 and the value xx.
  2. Set b=anb=a_n.
  3. For i=n−1i=n-1 down to 00: set b=b⋅x+aib=b\cdot x+a_i.
  4. Print bb as f(x)f(x) and stop.

Horner's method rewrites the polynomial in nested form, which needs only nn multiplications and nn additions.

Evaluation of f(x)=x4+3x3+5x2+7x+9f(x)=x^4+3x^3+5x^2+7x+9 at x=2x=2

f(x)=((((1)x+3)x+5)x+7)x+9f(x)=((((1)x+3)x+5)x+7)x+9

StepCalculationResult
b4b_41
b3b_31⋅2+31\cdot2+35
b2b_25⋅2+55\cdot2+515
b1b_115⋅2+715\cdot2+737
b0b_037⋅2+937\cdot2+983

f(2)=83f(2)=83. Direct check: 16+24+20+14+9=8316+24+20+14+9=83.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2080 · 10 marks

Write an algorithm and a C program to obtain roots of a non-linear equation using the Newton-Raphson method.

Answer

Algorithm (Newton-Raphson)

  1. Define f(x)f(x) and f′(x)f'(x).
  2. Read the initial guess x0x_0, tolerance ε\varepsilon and the maximum number of iterations NN.
  3. For i=1i=1 to NN:
    • if f′(x0)=0f'(x_0)=0, print "derivative is zero" and stop;
    • compute x1=x0−f(x0)/f′(x0)x_1=x_0-f(x_0)/f'(x_0);
    • if ∣x1−x0∣<ε|x_1-x_0|<\varepsilon, print x1x_1 as the root and stop;
    • set x0=x1x_0=x_1.
  4. Print "does not converge in N iterations" and stop.

C program (example f(x)=x3−2x−5f(x)=x^3-2x-5)

#include <stdio.h>
#include <math.h>

double f(double x)  { return x * x * x - 2 * x - 5; }
double df(double x) { return 3 * x * x - 2; }

int main(void) {
    double x0, x1, eps;
    int i, maxit;

    printf("Enter initial guess, tolerance, max iterations: ");
    scanf("%lf %lf %d", &x0, &eps, &maxit);

    for (i = 1; i <= maxit; i++) {
        if (fabs(df(x0)) < 1e-12) {
            printf("Derivative is zero. Method fails.\n");
            return 1;
        }
        x1 = x0 - f(x0) / df(x0);
        printf("Iteration %d: x = %.6f\n", i, x1);
        if (fabs(x1 - x0) < eps) {
            printf("Root = %.6f after %d iterations\n", x1, i);
            return 0;
        }
        x0 = x1;
    }
    printf("Did not converge in %d iterations.\n", maxit);
    return 1;
}

For x0=2x_0=2 this converges to the root 2.0945512.094551.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2080 · 10 marks

Solve the following ODE using the shooting method: y′′+xy′−xy=2xy''+xy'-xy=2x, with y(0)=1y(0)=1 and y(2)=10y(2)=10.

Answer

Write y′=zy'=z and z′=2x−xz+xyz'=2x-xz+xy, with y(0)=1y(0)=1 and unknown z(0)=sz(0)=s. The ODE is linear, so y(2)y(2) is a linear function of ss.

Trial 1: s1=0s_1=0. Integrating from x=0x=0 to 22 (Runge-Kutta, step 0.50.5) gives y(2)≈4.014y(2)\approx4.014.

Trial 2: s2=1s_2=1. The same integration gives y(2)≈6.000y(2)\approx6.000.

The target is y(2)=10y(2)=10. By linear interpolation (secant on ss):

s=s1+10−4.0146.000−4.014(s2−s1)=5.9861.986≈3.014s=s_1+\frac{10-4.014}{6.000-4.014}(s_2-s_1)=\frac{5.986}{1.986}\approx3.014

Final solution. Integrating the IVP with y(0)=1y(0)=1, y′(0)=3.014y'(0)=3.014:

xx00.51.01.52.0
yy12.524.246.5510.00

So the BVP solution is the IVP solution with the slope y′(0)≈3.01y'(0)\approx3.01, and it satisfies y(2)=10y(2)=10. Values at interior points are y(1)≈4.24y(1)\approx4.24 and y(1.5)≈6.55y(1.5)\approx6.55.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2080 · 10 marks

Compare and contrast the Jacobi iterative and Gauss-Seidel methods. Solve the following equations using the Gauss-Seidel method: x+2y+3z=5x+2y+3z=5, 2x+8y+22z=62x+8y+22z=6, 3x+22y+82z=−103x+22y+82z=-10

Answer

Comparison

JacobiGauss-Seidel
Uses only values from the previous iteration for all unknowns.Uses the newest available values in the same iteration.
Updates can be done in parallel.Updates are sequential.
Converges more slowly, roughly twice as many iterations.Converges faster, usually about twice as fast.
Needs two arrays (old and new).Needs one array.
Both need diagonal dominance (or similar) to be sure of convergence.Same condition.

Gauss-Seidel solution. The equations are

x=5−2y−3z,y=6−2x−22z8,z=−10−3x−22y82x=5-2y-3z,\quad y=\frac{6-2x-22z}{8},\quad z=\frac{-10-3x-22y}{82}

This system is not diagonally dominant (for example, ∣1∣<∣2∣+∣3∣|1|<|2|+|3| in row 1), so convergence is slow. Starting from (0,0,0)(0,0,0):

Iterationxxyyzz
15.0000-0.5000-0.1707
26.5122-0.4085-0.2506
36.5689-0.2031-0.3078
46.32950.0140-0.3573
56.04380.2216-0.4025
65.76440.4158-0.4444
75.50160.5967-0.4833
85.25650.7650-0.5195

The iterates move steadily toward the exact solution. Elimination confirms it: R2−2R1R_2-2R_1 gives y+4z=−1y+4z=-1, and R3−3R1R_3-3R_1 gives 16y+73z=−2516y+73z=-25. Hence z=−1z=-1, y=3y=3, x=2x=2.

Solution: x=2,  y=3,  z=−1x=2,\; y=3,\; z=-1. Many more Gauss-Seidel iterations are needed to reach this; reordering the equations to improve dominance would speed it up.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2080 · 5 marks

Use the secant method to estimate the root of x2−5x+6=0x^2-5x+6=0, with initial estimates x1=4x_1=4 and x2=2x_2=2 (EPS = 0.05).

Answer

f(x)=x2−5x+6f(x)=x^2-5x+6, x1=4x_1=4, x2=2x_2=2. Here f(4)=16−20+6=2f(4)=16-20+6=2 and f(2)=4−10+6=0f(2)=4-10+6=0.

x3=x2−f(x2)(x2−x1)f(x2)−f(x1)=2−0⋅(2−4)0−2=2x_3=x_2-\frac{f(x_2)(x_2-x_1)}{f(x_2)-f(x_1)}=2-\frac{0\cdot(2-4)}{0-2}=2

f(x3)=f(2)=0f(x_3)=f(2)=0, so ∣f(x3)∣<EPS=0.05|f(x_3)|<\text{EPS}=0.05 and the iteration stops at once.

The root is x=2x=2. Indeed x2−5x+6=(x−2)(x−3)x^2-5x+6=(x-2)(x-3), so 22 is an exact root. The other root is 33.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2080 · 5 marks

Solve the double integral using Simpson's 1/3 rule: ∫22.6∫44.4dx dyxy\int_{2}^{2.6}\int_{4}^{4.4}\frac{dx\,dy}{xy}.

Answer

I=∫22.6∫44.4dx dyxyI=\int_{2}^{2.6}\int_{4}^{4.4}\dfrac{dx\,dy}{xy}, with x∈[4,4.4]x\in[4,4.4] and y∈[2,2.6]y\in[2,2.6]. Take two sub-intervals in each direction: h=4.4−42=0.2h=\dfrac{4.4-4}{2}=0.2 and k=2.6−22=0.3k=\dfrac{2.6-2}{2}=0.3.

The nodes are x=4,4.2,4.4x=4,4.2,4.4 and y=2,2.3,2.6y=2,2.3,2.6. Simpson's 1/3 weights in each direction are 13(1,4,1)\frac13(1,4,1), so

I≈hk9∑wiwjf(xi,yj),f=1xyI\approx\frac{hk}{9}\sum w_iw_jf(x_i,y_j),\quad f=\frac1{xy}

Because f=1x⋅1yf=\frac1x\cdot\frac1y is separable, the sum factorises.

x-direction:

0.23[14+44.2+14.4]=0.06667(1.42965)=0.09531\frac{0.2}{3}\left[\frac14+\frac4{4.2}+\frac1{4.4}\right]=0.06667(1.42965)=0.09531

y-direction:

0.33[12+42.3+12.6]=0.1(2.62375)=0.26237\frac{0.3}{3}\left[\frac12+\frac4{2.3}+\frac1{2.6}\right]=0.1(2.62375)=0.26237

I≈0.09531×0.26237≈0.02501I\approx0.09531\times0.26237\approx0.02501

I≈0.0250I\approx0.0250. The exact value is ln⁡(1.1)ln⁡(1.3)=0.025006\ln(1.1)\ln(1.3)=0.025006.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2080 · 5 marks

What are the sources of errors? Discuss the various types of errors encountered in numerical computation.

Answer

Sources of errors in numerical computation

  1. Inherent (input) errors in the data: measurement errors in experimental values, or errors from approximating physical constants.
  2. Errors introduced by the mathematical model, which simplifies the real problem.
  3. Errors arising from the numerical method (truncation) and from the finite-precision computer (round-off).
  4. Human or programming errors (blunders), such as wrong formulas or typing mistakes.

Types of errors

  • Round-off error: caused by the computer storing only a finite number of digits, for example 13=0.3333\frac13=0.3333 or π=3.1416\pi=3.1416. The error accumulates over many operations, and subtracting nearly equal numbers loses significant digits.
  • Truncation error: caused by cutting off an infinite process after finitely many terms, for example using sin⁡x≈x−x36\sin x\approx x-\frac{x^3}{6} or replacing a derivative by a finite difference.
  • Absolute error: ∣xtrue−xapprox∣|x_{true}-x_{approx}|.
  • Relative error: ∣xtrue−xapprox∣∣xtrue∣\dfrac{|x_{true}-x_{approx}|}{|x_{true}|}, and the percentage error is this multiplied by 100100.
  • Blunder (gross) error: mistakes due to carelessness; these are avoidable.
  • Inherent error: error already present in the input data.
  • Propagated error: error carried forward from earlier steps into later calculations.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2080 · 5 marks

Fit a second-order polynomial to the data below: X = 1, 2, 3, 4, 5; F(x) = 2, 6, 12, 20, 30.

Answer

Fit y=a0+a1x+a2x2y=a_0+a_1x+a_2x^2 for the data x=1,…,5x=1,\dots,5 and f=2,6,12,20,30f=2,6,12,20,30.

xxyyx2x^2x3x^3x4x^4xyxyx2yx^2y
1211122
2648161224
3129278136108
420166425680320
53025125625150750
Sum70552259792801204

Normal equations (n=5n=5):

5a0+15a1+55a2=705a_0+15a_1+55a_2=70 15a0+55a1+225a2=28015a_0+55a_1+225a_2=280 55a0+225a1+979a2=120455a_0+225a_1+979a_2=1204

Solving gives a0=0a_0=0, a1=1a_1=1 and a2=1a_2=1.

f(x)=x2+xf(x)=x^2+x

This fits every data point exactly.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2080 · 5 marks

Why is numerical integration required? Compute I=∫−11ex dxI=\int_{-1}^{1}e^x\,dx using the composite trapezoidal rule with n=4n=4.

Answer

Why numerical integration is required: many integrands have no elementary antiderivative (for example e−x2e^{-x^2}), and in practice the function is often known only as a table of measured values. Numerical methods give an approximate answer in both cases.

Composite trapezoidal rule, n=4n=4. h=1−(−1)4=0.5h=\dfrac{1-(-1)}{4}=0.5, with nodes −1,−0.5,0,0.5,1-1,-0.5,0,0.5,1.

xx-1-0.500.51
exe^x0.367880.606531.000001.648722.71828

I≈h2[f0+f4+2(f1+f2+f3)]=0.25[0.36788+2.71828+2(3.25525)]I\approx\frac h2\Big[f_0+f_4+2(f_1+f_2+f_3)\Big]=0.25\Big[0.36788+2.71828+2(3.25525)\Big]

=0.25(9.59666)≈2.3992=0.25(9.59666)\approx2.3992

I≈2.399I\approx2.399. The exact value is e−e−1=2.3504e-e^{-1}=2.3504, so the error is about 0.0490.049.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2080 · 5 marks

Evaluate dydx\frac{dy}{dx} at x=5x=5 using Newton's forward interpolation formula for the table below: X = 1, 3, 5, 7, 9; y = -1.20, 12.80, 119.60, 472.80, 1302.80.

Answer

Data: h=2h=2, x0=1x_0=1, so x=5x=5 corresponds to p=5−12=2p=\dfrac{5-1}{2}=2.

Forward difference table

xxyyΔy\Delta yΔ2y\Delta^2yΔ3y\Delta^3yΔ4y\Delta^4y
1-1.2014.092.8153.676.8
312.80106.8246.4230.4
5119.60353.2476.8
7472.80830.0
91302.80

Newton's forward formula for the derivative:

dydx=1h[Δy0+2p−12Δ2y0+3p2−6p+26Δ3y0+4p3−18p2+22p−624Δ4y0]\frac{dy}{dx}=\frac1h\left[\Delta y_0+\frac{2p-1}{2}\Delta^2y_0+\frac{3p^2-6p+2}{6}\Delta^3y_0+\frac{4p^3-18p^2+22p-6}{24}\Delta^4y_0\right]

At p=2p=2 the coefficients are 32\dfrac32, 13\dfrac13 and −112-\dfrac1{12}:

dydx=12[14+1.5(92.8)+13(153.6)−112(76.8)]=12[14+139.2+51.2−6.4]=1982\frac{dy}{dx}=\frac12\left[14+1.5(92.8)+\frac13(153.6)-\frac1{12}(76.8)\right]=\frac12\left[14+139.2+51.2-6.4\right]=\frac{198}{2}

dydx∣x=5≈99\dfrac{dy}{dx}\Big|_{x=5}\approx99.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2080 · 5 marks

Find the eigenvalues and eigenvectors of the matrix A=[3−111]A=\begin{bmatrix}3 & -1\\ 1 & 1\end{bmatrix}.

Answer

A=[3−111]A=\begin{bmatrix}3&-1\\1&1\end{bmatrix}. The characteristic equation is

∣A−λI∣=(3−λ)(1−λ)+1=λ2−4λ+4=(λ−2)2=0|A-\lambda I|=(3-\lambda)(1-\lambda)+1=\lambda^2-4\lambda+4=(\lambda-2)^2=0

Eigenvalue: λ=2\lambda=2 (repeated, with algebraic multiplicity 22).

Eigenvector: (A−2I)v=0(A-2I)v=0 gives

[1−11−1][xy]=0  ⇒  x=y\begin{bmatrix}1&-1\\1&-1\end{bmatrix}\begin{bmatrix}x\\y\end{bmatrix}=0\;\Rightarrow\;x=y

v=[11]v=\begin{bmatrix}1\\1\end{bmatrix}

Only one independent eigenvector exists for the repeated eigenvalue, so AA is not diagonalisable.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2080 · 5 marks

Solve dydx=3x+y2\frac{dy}{dx}=3x+\frac{y}{2} with y(0)=1y(0)=1 for x=0.2x=0.2 (h=0.1h=0.1) using Euler's method.

Answer

dydx=3x+y2\dfrac{dy}{dx}=3x+\dfrac y2, y(0)=1y(0)=1, h=0.1h=0.1. Euler's formula is yn+1=yn+h f(xn,yn)y_{n+1}=y_n+h\,f(x_n,y_n).

Step 1 (x0=0, y0=1x_0=0,\ y_0=1): f=0+0.5=0.5f=0+0.5=0.5,

y(0.1)=1+0.1(0.5)=1.05y(0.1)=1+0.1(0.5)=1.05

Step 2 (x1=0.1, y1=1.05x_1=0.1,\ y_1=1.05): f=0.3+0.525=0.825f=0.3+0.525=0.825,

y(0.2)=1.05+0.1(0.825)=1.1325y(0.2)=1.05+0.1(0.825)=1.1325

y(0.2)≈1.1325y(0.2)\approx1.1325.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2082 · 2+4+4 marks

Compare the bisection and secant methods. Derive the Newton-Raphson formula. Use Newton-Raphson to solve f(x)=x3+2x−2f(x) = x^3 + 2x - 2, correct to three decimal places.

Answer

Comparison of bisection and secant methods

BisectionSecant
Needs a bracketing interval with f(a)f(b)<0f(a)f(b)<0.Needs two starting points; no bracketing is required.
Always converges, but only linearly (slow).Converges faster (order about 1.6181.618) but may diverge.
Uses only the sign of ff.Uses the function values to interpolate.

Derivation of Newton-Raphson. Let xnx_n be an approximation to a root of f(x)=0f(x)=0. The tangent to y=f(x)y=f(x) at (xn,f(xn))(x_n,f(x_n)) is y−f(xn)=f′(xn)(x−xn)y-f(x_n)=f'(x_n)(x-x_n). The next approximation xn+1x_{n+1} is where this tangent meets the x-axis (y=0y=0):

−f(xn)=f′(xn)(xn+1−xn)  ⇒  xn+1=xn−f(xn)f′(xn)-f(x_n)=f'(x_n)(x_{n+1}-x_n)\;\Rightarrow\;x_{n+1}=x_n-\frac{f(x_n)}{f'(x_n)}

Solving f(x)=x3+2x−2f(x)=x^3+2x-2. f′(x)=3x2+2f'(x)=3x^2+2. Since f(0)=−2f(0)=-2 and f(1)=1f(1)=1, a root lies in (0,1)(0,1). Take x0=1x_0=1.

nnxnx_nf(xn)f(x_n)f′(xn)f'(x_n)xn+1x_{n+1}
01.000001.000005.00000.80000
10.800000.112003.92000.77143
20.771430.002083.78540.77092
30.770920.00000063.78310.77092

The iterates have settled to three decimal places, so the root is x≈0.771x\approx0.771.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2082 · 5+5 marks

Write an algorithm for interpolation using Newton's divided difference method. Write a program for the same method.

Answer

Algorithm (Newton's divided difference interpolation)

  1. Read nn, the points (xi,yi)(x_i,y_i) for i=0,…,n−1i=0,\dots,n-1, and the value xpx_p.
  2. Build the table: set d[i][0]=yid[i][0]=y_i. For j=1j=1 to n−1n-1 and i=0i=0 to n−1−jn-1-j, compute d[i][j]=d[i+1][j−1]−d[i][j−1]xi+j−xid[i][j]=\frac{d[i+1][j-1]-d[i][j-1]}{x_{i+j}-x_i}
  3. Set result=d[0][0]result=d[0][0] and prod=1prod=1.
  4. For j=1j=1 to n−1n-1: set prod=prod×(xp−xj−1)prod=prod\times(x_p-x_{j-1}) and result=result+d[0][j]×prodresult=result+d[0][j]\times prod.
  5. Print resultresult as f(xp)f(x_p) and stop.

The interpolating polynomial is

f(x)=f[x0]+f[x0,x1](x−x0)+f[x0,x1,x2](x−x0)(x−x1)+⋯f(x)=f[x_0]+f[x_0,x_1](x-x_0)+f[x_0,x_1,x_2](x-x_0)(x-x_1)+\cdots

C program

#include <stdio.h>

int main(void) {
    int n, i, j;
    double x[20], d[20][20], xp, prod, result;

    printf("Enter number of data points: ");
    scanf("%d", &n);
    printf("Enter x and y values:\n");
    for (i = 0; i < n; i++)
        scanf("%lf %lf", &x[i], &d[i][0]);

    printf("Enter value of x to interpolate: ");
    scanf("%lf", &xp);

    /* divided difference table */
    for (j = 1; j < n; j++)
        for (i = 0; i < n - j; i++)
            d[i][j] = (d[i + 1][j - 1] - d[i][j - 1]) / (x[i + j] - x[i]);

    /* Newton form */
    result = d[0][0];
    prod = 1.0;
    for (j = 1; j < n; j++) {
        prod *= (xp - x[j - 1]);
        result += d[0][j] * prod;
    }

    printf("f(%.4f) = %.6f\n", xp, result);
    return 0;
}

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2082 · 2+3+5 marks

List two applications of systems of linear equations. Differentiate between Gauss-Seidel and Jacobi iteration. Solve by Jacobi iteration: 4x+y+z=74x+y+z=7, x+5y−2z=3x+5y-2z=3, 3x+2y+6z=143x+2y+6z=14.

Answer

Two applications of linear systems: (1) analysis of electrical circuits using Kirchhoff's laws, and (2) structural analysis of trusses and frames, or balancing chemical equations and economic input-output models.

Gauss-Seidel versus Jacobi

JacobiGauss-Seidel
Computes every new value from the previous iteration's values only.Uses each newly computed value immediately in the same iteration.
Slower convergence.Usually converges about twice as fast.
Needs to store both old and new vectors.Needs a single vector.

Jacobi iteration. The system is diagonally dominant (4>24>2, 5>35>3, 6>56>5). Rewrite:

x=7−y−z4,y=3−x+2z5,z=14−3x−2y6x=\frac{7-y-z}{4},\quad y=\frac{3-x+2z}{5},\quad z=\frac{14-3x-2y}{6}

Start with (0,0,0)(0,0,0):

Iterationxxyyzz
11.75000.60002.3333
21.01671.18331.2583
31.13960.90001.4306
41.16740.94431.4635
51.14800.95191.4349
61.15330.94431.4420
71.15340.94611.4419
81.15300.94611.4412
91.15320.94591.4415
101.15320.94601.4414

Solution: x≈1.153,  y≈0.946,  z≈1.441x\approx1.153,\; y\approx0.946,\; z\approx1.441. The exact values are x=128111x=\frac{128}{111}, y=3537y=\frac{35}{37} and z=160111z=\frac{160}{111}.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2082 · 2+3 marks

Differentiate round-off error from truncation error, and explain their effect on numerical computation with an example.

Answer

Round-off error versus truncation error

Round-off errorTruncation error
Arises because a computer stores numbers with finite digits.Arises because an infinite process or exact formula is replaced by a finite approximation.
Depends on machine precision and word length.Depends on the method, such as the number of series terms or the step size.
Example: 13\frac13 stored as 0.33330.3333.Example: sin⁡x≈x−x36\sin x\approx x-\frac{x^3}{6} dropping later terms.

Effect on computation. Round-off errors accumulate over many operations and can wipe out significant digits when nearly equal numbers are subtracted. Truncation error can be reduced by taking more terms or a smaller step size hh, but a smaller hh means more operations, hence more round-off.

Example. Approximating a derivative by f′(x)≈f(x+h)−f(x)hf'(x)\approx\dfrac{f(x+h)-f(x)}{h} for f=exf=e^x at x=1x=1: the truncation error is about h2f′′(1)\frac h2f''(1), which falls as hh decreases. But for very small hh (about 10−1510^{-15}), f(x+h)f(x+h) and f(x)f(x) agree to nearly all stored digits, so the subtraction loses accuracy and the round-off error, of order ε/h\varepsilon/h, dominates. The total error is therefore smallest at an intermediate hh.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2082 · 2.5+2.5 marks

Derive the two-point forward difference formula and the two-point backward difference formula.

Answer

Both formulas come from the Taylor series of ff about xx, with step size hh.

Two-point forward difference. Expand f(x+h)f(x+h):

f(x+h)=f(x)+hf′(x)+h22!f′′(x)+…f(x+h) = f(x) + h f'(x) + \frac{h^2}{2!} f''(x) + \dots

Rearranging for f′(x)f'(x):

f′(x)=f(x+h)−f(x)h−h2f′′(ξ)f'(x) = \frac{f(x+h) - f(x)}{h} - \frac{h}{2} f''(\xi)

Neglecting the last term (truncation error of order hh):

f′(x)≈f(x+h)−f(x)h=fi+1−fihf'(x) \approx \frac{f(x+h) - f(x)}{h} = \frac{f_{i+1} - f_i}{h}

This uses the points xix_i and xi+1x_{i+1} and is first-order accurate, O(h)O(h).

Two-point backward difference. Expand f(x−h)f(x-h):

f(x−h)=f(x)−hf′(x)+h22!f′′(x)−…f(x-h) = f(x) - h f'(x) + \frac{h^2}{2!} f''(x) - \dots

Rearranging for f′(x)f'(x):

f′(x)=f(x)−f(x−h)h+h2f′′(ξ)f'(x) = \frac{f(x) - f(x-h)}{h} + \frac{h}{2} f''(\xi)

Hence

f′(x)≈f(x)−f(x−h)h=fi−fi−1hf'(x) \approx \frac{f(x) - f(x-h)}{h} = \frac{f_i - f_{i-1}}{h}

This also has error O(h)O(h). Averaging the two formulas gives the more accurate central difference f(x+h)−f(x−h)2h\dfrac{f(x+h)-f(x-h)}{2h}, with error O(h2)O(h^2).

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2082 · 5 marks

Fit y=aebxy = ae^{bx} to the points (1,15),(2,22),(3,33),(4,48),(5,70)(1,15), (2,22), (3,33), (4,48), (5,70) using least squares.

Answer

Take logarithms to linearise: ln⁡y=ln⁡a+bx\ln y = \ln a + bx. Put Y=ln⁡yY = \ln y, A=ln⁡aA = \ln a, so Y=A+bxY = A + bx.

xxyyY=ln⁡yY=\ln yx2x^2xYxY
1152.708112.7081
2223.091046.1821
3333.4965910.4895
4483.87121615.4848
5704.24852521.2425
Sum17.41535556.1069

Here n=5n=5, ∑x=15\sum x = 15. The normal equations are

∑Y=nA+b∑x  ⇒  17.4153=5A+15b\sum Y = nA + b\sum x \;\Rightarrow\; 17.4153 = 5A + 15b

∑xY=A∑x+b∑x2  ⇒  56.1069=15A+55b\sum xY = A\sum x + b\sum x^2 \;\Rightarrow\; 56.1069 = 15A + 55b

Solving for bb:

b=5(56.1069)−15(17.4153)5(55)−152=19.386650=0.3861b = \frac{5(56.1069) - 15(17.4153)}{5(55) - 15^2} = \frac{19.3866}{50} = 0.3861

A=17.4153−15(0.3861)5=2.3247,a=e2.3247=10.224A = \frac{17.4153 - 15(0.3861)}{5} = 2.3247, \qquad a = e^{2.3247} = 10.224

Fitted curve:

y≈10.224 e0.3861xy \approx 10.224\, e^{0.3861x}

Check: at x=3x=3, y=10.224×e1.1583=32.5y = 10.224 \times e^{1.1583} = 32.5, close to 33.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2082 · 5 marks

Solve by Cholesky decomposition: 4x+6y−8z=−84x+6y-8z=-8, 6x+13y−11z=−16x+13y-11z=-1, −8x−11y+29z=57-8x-11y+29z=57.

Answer

Write Ax=bA\mathbf{x} = \mathbf{b} with

A=[46−8613−11−8−1129],b=[−8−157]A = \begin{bmatrix} 4 & 6 & -8 \\ 6 & 13 & -11 \\ -8 & -11 & 29 \end{bmatrix}, \quad \mathbf{b} = \begin{bmatrix} -8 \\ -1 \\ 57 \end{bmatrix}

AA is symmetric (and positive definite), so A=LLTA = LL^T with LL lower triangular.

Step 1: Find LL.

  • l11=4=2l_{11} = \sqrt{4} = 2
  • l21=6/2=3l_{21} = 6/2 = 3, l31=−8/2=−4l_{31} = -8/2 = -4
  • l22=13−32=2l_{22} = \sqrt{13 - 3^2} = 2
  • l32=(−11−(−4)(3))/2=0.5l_{32} = (-11 - (-4)(3))/2 = 0.5
  • l33=29−16−0.25=12.75=3.5707l_{33} = \sqrt{29 - 16 - 0.25} = \sqrt{12.75} = 3.5707

L=[200320−40.53.5707]L = \begin{bmatrix} 2 & 0 & 0 \\ 3 & 2 & 0 \\ -4 & 0.5 & 3.5707 \end{bmatrix}

Step 2: Forward substitution, Ly=bL\mathbf{y} = \mathbf{b}.

  • 2y1=−8⇒y1=−42y_1 = -8 \Rightarrow y_1 = -4
  • 3y1+2y2=−1⇒y2=(−1+12)/2=5.53y_1 + 2y_2 = -1 \Rightarrow y_2 = (-1 + 12)/2 = 5.5
  • −4y1+0.5y2+3.5707y3=57⇒y3=(57−16−2.75)/3.5707=10.712-4y_1 + 0.5y_2 + 3.5707y_3 = 57 \Rightarrow y_3 = (57 - 16 - 2.75)/3.5707 = 10.712

Step 3: Back substitution, LTx=yL^T\mathbf{x} = \mathbf{y}.

  • 3.5707 z=10.712⇒z=33.5707\,z = 10.712 \Rightarrow z = 3
  • 2y+0.5z=5.5⇒y=(5.5−1.5)/2=22y + 0.5z = 5.5 \Rightarrow y = (5.5 - 1.5)/2 = 2
  • 2x+3y−4z=−4⇒x=(−4−6+12)/2=12x + 3y - 4z = -4 \Rightarrow x = (-4 - 6 + 12)/2 = 1

Solution: x=1,  y=2,  z=3x = 1,\; y = 2,\; z = 3.

Check in equation 1: 4+12−24=−84 + 12 - 24 = -8. Correct.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2082 · 5 marks

Using the data below, find f′(2.5)f'(2.5) and f′′(2.5)f''(2.5). x = 1.5, 2, 2.5, 3, 3.5, 4; f(x) = 2.375, 4.5, 7.625, 12, 17.875, 23.

Answer

The step size is h=0.5h = 0.5, and x=2.5x = 2.5 is an interior point, so use central differences.

First derivative:

f′(2.5)≈f(3)−f(2)2h=12−4.51=7.5f'(2.5) \approx \frac{f(3) - f(2)}{2h} = \frac{12 - 4.5}{1} = 7.5

Second derivative:

f′′(2.5)≈f(3)−2f(2.5)+f(2)h2=12−2(7.625)+4.50.25=1.250.25=5f''(2.5) \approx \frac{f(3) - 2f(2.5) + f(2)}{h^2} = \frac{12 - 2(7.625) + 4.5}{0.25} = \frac{1.25}{0.25} = 5

Result: f′(2.5)≈7.5f'(2.5) \approx 7.5 and f′′(2.5)≈5f''(2.5) \approx 5.

Using a more accurate five-point formula for the first derivative gives

f′(2.5)≈f(1.5)−8f(2)+8f(3)−f(3.5)12h=2.375−36+96−17.8756≈7.42f'(2.5) \approx \frac{f(1.5) - 8f(2) + 8f(3) - f(3.5)}{12h} = \frac{2.375 - 36 + 96 - 17.875}{6} \approx 7.42

which is consistent with the central value.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2082 · 5 marks

Evaluate ∫03(2x3+1) dx\int_{0}^{3} (2x^3 + 1)\,dx using Simpson's 1/3 rule with n=6n = 6.

Answer

Here a=0a=0, b=3b=3, n=6n=6, so h=(3−0)/6=0.5h = (3-0)/6 = 0.5.

iixix_if(xi)=2x3+1f(x_i) = 2x^3+1
001
10.51.25
21.03
31.57.75
42.017
52.532.25
63.055

Simpson's 1/3 rule:

I≈h3[f0+f6+4(f1+f3+f5)+2(f2+f4)]I \approx \frac{h}{3}\left[f_0 + f_6 + 4(f_1 + f_3 + f_5) + 2(f_2 + f_4)\right]

I≈0.53[1+55+4(1.25+7.75+32.25)+2(3+17)]I \approx \frac{0.5}{3}\left[1 + 55 + 4(1.25 + 7.75 + 32.25) + 2(3 + 17)\right]

=0.53[56+165+40]=0.53(261)=43.5= \frac{0.5}{3}\left[56 + 165 + 40\right] = \frac{0.5}{3}(261) = 43.5

Result: I≈43.5I \approx 43.5.

This equals the exact value [x42+x]03=40.5+3=43.5\left[\tfrac{x^4}{2} + x\right]_0^3 = 40.5 + 3 = 43.5, because Simpson's rule is exact for cubics.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2082 · 5 marks

Solve dydx=x2+y\frac{dy}{dx} = x^2 + y with y(0)=1y(0) = 1 at x=1.5x = 1.5 using the fourth-order Runge-Kutta method.

Answer

Here f(x,y)=x2+yf(x,y) = x^2 + y, x0=0x_0 = 0, y0=1y_0 = 1. To reach x=1.5x = 1.5 take h=0.5h = 0.5 and 3 steps.

RK4 formulas:

k1=hf(x,y),  k2=hf ⁣(x+h2,y+k12),  k3=hf ⁣(x+h2,y+k22),  k4=hf(x+h,y+k3)k_1 = hf(x,y),\; k_2 = hf\!\left(x+\tfrac h2, y+\tfrac{k_1}{2}\right),\; k_3 = hf\!\left(x+\tfrac h2, y+\tfrac{k_2}{2}\right),\; k_4 = hf(x+h, y+k_3)

yn+1=yn+16(k1+2k2+2k3+k4)y_{n+1} = y_n + \tfrac16(k_1 + 2k_2 + 2k_3 + k_4)

Step 1 (x=0, y=1x=0,\ y=1):

  • k1=0.5(0+1)=0.5k_1 = 0.5(0+1) = 0.5
  • k2=0.5(0.0625+1.25)=0.65625k_2 = 0.5(0.0625 + 1.25) = 0.65625
  • k3=0.5(0.0625+1.328125)=0.69531k_3 = 0.5(0.0625 + 1.328125) = 0.69531
  • k4=0.5(0.25+1.69531)=0.97266k_4 = 0.5(0.25 + 1.69531) = 0.97266
  • y(0.5)=1+16(0.5+1.3125+1.39063+0.97266)=1.69596y(0.5) = 1 + \tfrac16(0.5 + 1.3125 + 1.39063 + 0.97266) = 1.69596

Step 2 (x=0.5, y=1.69596x=0.5,\ y=1.69596):

  • k1=0.5(0.25+1.69596)=0.97298k_1 = 0.5(0.25 + 1.69596) = 0.97298
  • k2=0.5(0.5625+2.18245)=1.37248k_2 = 0.5(0.5625 + 2.18245) = 1.37248
  • k3=0.5(0.5625+2.38220)=1.47235k_3 = 0.5(0.5625 + 2.38220) = 1.47235
  • k4=0.5(1+3.16831)=2.08416k_4 = 0.5(1 + 3.16831) = 2.08416
  • y(1.0)=1.69596+16(0.97298+2.74496+2.94470+2.08416)=3.15376y(1.0) = 1.69596 + \tfrac16(0.97298 + 2.74496 + 2.94470 + 2.08416) = 3.15376

Step 3 (x=1, y=3.15376x=1,\ y=3.15376):

  • k1=0.5(1+3.15376)=2.07688k_1 = 0.5(1 + 3.15376) = 2.07688
  • k2=0.5(1.5625+4.19220)=2.87735k_2 = 0.5(1.5625 + 4.19220) = 2.87735
  • k3=0.5(1.5625+4.59244)=3.07747k_3 = 0.5(1.5625 + 4.59244) = 3.07747
  • k4=0.5(2.25+6.23123)=4.24062k_4 = 0.5(2.25 + 6.23123) = 4.24062
  • y(1.5)=3.15376+16(2.07688+5.75470+6.15494+4.24062)=6.19162y(1.5) = 3.15376 + \tfrac16(2.07688 + 5.75470 + 6.15494 + 4.24062) = 6.19162

Result: y(1.5)≈6.1916y(1.5) \approx 6.1916.

The exact solution y=3ex−x2−2x−2y = 3e^x - x^2 - 2x - 2 gives 6.19516.1951, so the RK4 value is accurate to about 3 decimals.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2082 · 2+3 marks

Explain a boundary value problem with an example, and describe how higher-order differential equations can be solved.

Answer

Boundary value problem (BVP). A differential equation whose auxiliary conditions are given at two or more different points (the boundaries) of the interval, instead of all at one starting point. A second-order ODE needs two such conditions.

Example:

y′′+y=0,y(0)=0,  y ⁣(π2)=1y'' + y = 0, \quad y(0) = 0,\; y\!\left(\tfrac{\pi}{2}\right) = 1

The values of yy are fixed at x=0x=0 and x=π/2x=\pi/2 (two points), so this is a BVP. Its solution is y=sin⁡xy = \sin x. By contrast, an initial value problem would give y(0)y(0) and y′(0)y'(0) at the same point.

Solving higher-order differential equations. A higher-order ODE is converted into a system of first-order ODEs, which can then be solved by Euler, Runge-Kutta, etc.

For y(n)=f(x,y,y′,…,y(n−1))y^{(n)} = f(x, y, y', \dots, y^{(n-1)}), let y1=y,  y2=y′,  …,  yn=y(n−1)y_1 = y,\; y_2 = y',\; \dots,\; y_n = y^{(n-1)}. Then

y1′=y2,y2′=y3,…,yn′=f(x,y1,…,yn)y_1' = y_2,\quad y_2' = y_3,\quad \dots,\quad y_n' = f(x, y_1, \dots, y_n)

For example, y′′=f(x,y,y′)y'' = f(x,y,y') becomes y′=zy' = z, z′=f(x,y,z)z' = f(x,y,z). Each equation is advanced step by step with the same method (e.g. RK4) applied to every variable.

For a BVP the missing initial value is not known, so two approaches are used:

  • Shooting method: guess the missing initial slope, solve as an IVP, compare the computed end value with the required boundary value, and adjust the guess (e.g. by secant or bisection) until the boundary condition is met.
  • Finite difference method: replace derivatives by central differences, e.g. y′′≈yi+1−2yi+yi−1h2y'' \approx \frac{y_{i+1} - 2y_i + y_{i-1}}{h^2}, giving a system of linear algebraic equations in the unknowns yiy_i that is solved by Gauss elimination or an iterative method.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2082 · 2.5+2.5 marks

Define eigenvalue and eigenvector, and distinguish between regression and interpolation.

Answer

Eigenvalue and eigenvector. For a square matrix AA, a non-zero vector x\mathbf{x} is an eigenvector and the scalar λ\lambda is the corresponding eigenvalue if

Ax=λxA\mathbf{x} = \lambda\mathbf{x}

That is, multiplying by AA only scales x\mathbf{x} and does not change its direction. The eigenvalues are the roots of the characteristic equation det⁡(A−λI)=0\det(A - \lambda I) = 0. The eigenvector for each λ\lambda is found by solving (A−λI)x=0(A - \lambda I)\mathbf{x} = \mathbf{0}.

Regression versus interpolation.

BasisRegression (curve fitting)Interpolation
CurvePasses near the points, not necessarily through themPasses exactly through every given point
DataSuited to noisy or experimental dataSuited to accurate, exact data
MethodLeast squares minimises ∑(yi−f(xi))2\sum(y_i - f(x_i))^2Lagrange, Newton, spline polynomials
FunctionLow-degree function with few parametersPolynomial of degree up to nn for n+1n+1 points
PurposeShows the overall trendEstimates values between known points

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2083 · 2+4+4 marks

Differentiate the Newton-Raphson and bisection methods. Derive the Newton-Raphson formula. Use bisection to solve x3−x−2=0x^3 - x - 2 = 0 in (1,2)(1, 2).

Answer

Newton-Raphson versus bisection.

BasisNewton-RaphsonBisection
Starting dataOne initial guess x0x_0Interval [a,b][a,b] with f(a)f(b)<0f(a)f(b)<0
DerivativeNeeds f′(x)f'(x)Not needed
ConvergenceQuadratic (fast)Linear (slow, error halves each step)
ReliabilityMay diverge if f′(x)≈0f'(x)\approx 0 or guess is poorAlways converges

Derivation of Newton-Raphson. Let x0x_0 be near the root. Expand f(x)f(x) by Taylor series about x0x_0 and keep the linear terms:

f(x)≈f(x0)+(x−x0)f′(x0)f(x) \approx f(x_0) + (x - x_0)f'(x_0)

At the root f(x)=0f(x) = 0, so

x=x0−f(x0)f′(x0)x = x_0 - \frac{f(x_0)}{f'(x_0)}

Repeating gives

xn+1=xn−f(xn)f′(xn)x_{n+1} = x_n - \frac{f(x_n)}{f'(x_n)}

Geometrically, xn+1x_{n+1} is where the tangent at (xn,f(xn))(x_n, f(x_n)) cuts the xx-axis.

Bisection for f(x)=x3−x−2f(x) = x^3 - x - 2 in (1,2)(1,2). f(1)=−2<0f(1) = -2 < 0 and f(2)=4>0f(2) = 4 > 0, so a root lies in (1,2)(1,2).

Iteraabbc=(a+b)/2c=(a+b)/2f(c)f(c)
1121.5−0.1250-0.1250
21.521.75+1.6094+1.6094
31.51.751.625+0.6660+0.6660
41.51.6251.5625+0.2522+0.2522
51.51.56251.53125+0.0594+0.0594
61.51.531251.51563−0.0341-0.0341
71.515631.531251.52344+0.0123+0.0123
81.515631.523441.51953−0.0111-0.0111

The interval is now (1.5195,1.5234)(1.5195, 1.5234), so the root is x≈1.521x \approx 1.521 (exact root 1.52141.5214).

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2083 · 5+5 marks

Write an algorithm for Newton's backward interpolation. Write a program for Newton's backward interpolation.

Answer

Algorithm: Newton's backward interpolation

Given nn equally spaced points (xi,yi)(x_i, y_i), i=0,…,n−1i = 0,\dots,n-1, and a value xx to interpolate near the end of the table.

  1. Read nn, the values xix_i, yiy_i, and the point xx.
  2. Compute h=x1−x0h = x_1 - x_0.
  3. Build the backward difference table: set d[i][0]=yid[i][0] = y_i, then for j=1,…,n−1j = 1,\dots,n-1 and i=n−1i = n-1 down to jj, compute d[i][j]=d[i][j−1]−d[i−1][j−1]d[i][j] = d[i][j-1] - d[i-1][j-1].
  4. Compute p=(x−xn−1)/hp = (x - x_{n-1})/h.
  5. Set sum=yn−1sum = y_{n-1} and term=1term = 1.
  6. For j=1j = 1 to n−1n-1: term=term⋅(p+j−1)/jterm = term\cdot(p + j - 1)/j; sum=sum+term⋅d[n−1][j]sum = sum + term\cdot d[n-1][j].
  7. Print sumsum as f(x)f(x).

This implements

y(x)=yn+p∇yn+p(p+1)2!∇2yn+p(p+1)(p+2)3!∇3yn+…y(x) = y_n + p\nabla y_n + \frac{p(p+1)}{2!}\nabla^2 y_n + \frac{p(p+1)(p+2)}{3!}\nabla^3 y_n + \dots

Program (C):

#include <stdio.h>

int main() {
    int n, i, j;
    double x[20], d[20][20], xv, h, p, sum, term;

    printf("Enter number of points: ");
    scanf("%d", &n);
    printf("Enter x and y values:\n");
    for (i = 0; i < n; i++)
        scanf("%lf %lf", &x[i], &d[i][0]);
    printf("Enter value of x to interpolate: ");
    scanf("%lf", &xv);

    /* backward difference table */
    for (j = 1; j < n; j++)
        for (i = n - 1; i >= j; i--)
            d[i][j] = d[i][j - 1] - d[i - 1][j - 1];

    h = x[1] - x[0];
    p = (xv - x[n - 1]) / h;

    sum = d[n - 1][0];
    term = 1.0;
    for (j = 1; j < n; j++) {
        term = term * (p + j - 1) / j;
        sum = sum + term * d[n - 1][j];
    }

    printf("f(%.4lf) = %.6lf\n", xv, sum);
    return 0;
}

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2083 · 3+2+5 marks

Explain the power method for finding eigenvalues. Differentiate Jacobi and Gauss-Seidel methods. Solve by Jacobi: 5x+y+z=75x+y+z=7, x+4y+z=6x+4y+z=6, x+y+3z=5x+y+3z=5.

Answer

Power method. It finds the dominant (largest in magnitude) eigenvalue and its eigenvector of a matrix AA.

  1. Choose a non-zero starting vector x0\mathbf{x}_0 (e.g. all ones).
  2. Compute yk=Axk\mathbf{y}_k = A\mathbf{x}_k.
  3. Let λk+1\lambda_{k+1} be the component of yk\mathbf{y}_k with largest magnitude, and normalise: xk+1=yk/λk+1\mathbf{x}_{k+1} = \mathbf{y}_k/\lambda_{k+1}.
  4. Repeat until ∣λk+1−λk∣<ε|\lambda_{k+1} - \lambda_k| < \varepsilon.

Then λk→λmax⁡\lambda_k \to \lambda_{\max} and xk→\mathbf{x}_k \to the corresponding eigenvector. It converges when one eigenvalue strictly dominates the others, at a rate set by ∣λ2/λ1∣|\lambda_2/\lambda_1|. The smallest eigenvalue can be found by applying the method to A−1A^{-1}.

Jacobi versus Gauss-Seidel.

BasisJacobiGauss-Seidel
Values usedOnly the previous iteration's valuesLatest updated values immediately
SpeedSlowerUsually about twice as fast
ParallelismEasy to paralleliseSequential
StorageNeeds old and new vectorsOne vector is enough

Both converge for a diagonally dominant system.

Jacobi solution. The system is diagonally dominant. Rewrite:

x=7−y−z5,y=6−x−z4,z=5−x−y3x = \frac{7 - y - z}{5}, \quad y = \frac{6 - x - z}{4}, \quad z = \frac{5 - x - y}{3}

Start with (0,0,0)(0,0,0):

Iterxxyyzz
11.40001.50001.6667
20.76670.73330.7000
31.11331.13331.1667
40.94000.93000.9178
51.03041.03561.0433

The values oscillate and converge towards the exact solution:

x≈1,y≈1,z≈1x \approx 1,\quad y \approx 1,\quad z \approx 1

Check: 5+1+1=75+1+1=7, 1+4+1=61+4+1=6, 1+1+3=51+1+3=5. All hold.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2083 · 1+4 marks

Differentiate absolute and relative error. Explain fixed point iteration.

Answer

Absolute versus relative error. If xx is the true value and xax_a the approximation:

  • Absolute error Ea=∣x−xa∣E_a = |x - x_a|. It is the raw size of the error, in the units of the quantity.
  • Relative error Er=∣x−xa∣∣x∣E_r = \dfrac{|x - x_a|}{|x|}, often given as a percentage. It is dimensionless and shows how large the error is compared with the quantity. For example, an error of 1 cm is large for a 10 cm object but negligible for a 1 km road.

Fixed point iteration. To solve f(x)=0f(x) = 0, rewrite it as x=g(x)x = g(x). A root of ff is then a fixed point of gg, meaning a point with g(α)=αg(\alpha) = \alpha.

Procedure:

  1. Choose an initial guess x0x_0.
  2. Iterate xn+1=g(xn)x_{n+1} = g(x_n).
  3. Stop when ∣xn+1−xn∣<ε|x_{n+1} - x_n| < \varepsilon.

Convergence condition: the iteration converges if ∣g′(x)∣<1|g'(x)| < 1 in an interval containing the root and the starting value. The smaller ∣g′∣|g'| is, the faster it converges, and the order is linear.

Example: x2−2x−3=0x^2 - 2x - 3 = 0 near x=3x = 3. Write x=2x+3x = \sqrt{2x+3}, so g(x)=2x+3g(x) = \sqrt{2x+3}. From x0=4x_0 = 4: x1=3.317x_1 = 3.317, x2=3.103x_2 = 3.103, x3=3.034x_3 = 3.034, tending to 3.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2083 · 5 marks

Fit a second-degree polynomial by least squares to (−1,2),(0,1),(1,2),(2,5),(3,10)(-1,2), (0,1), (1,2), (2,5), (3,10).

Answer

Fit y=a+bx+cx2y = a + bx + cx^2. The normal equations are

∑y=na+b∑x+c∑x2\sum y = na + b\sum x + c\sum x^2 ∑xy=a∑x+b∑x2+c∑x3\sum xy = a\sum x + b\sum x^2 + c\sum x^3 ∑x2y=a∑x2+b∑x3+c∑x4\sum x^2y = a\sum x^2 + b\sum x^3 + c\sum x^4

xxyyx2x^2x3x^3x4x^4xyxyx2yx^2y
−1-121−1-11−2-22
0100000
1211122
2548161020
310927813090
Sum2015359940114

Substituting (n=5n=5, ∑x=5\sum x = 5):

5a+5b+15c=20(1)5a + 5b + 15c = 20 \quad (1) 5a+15b+35c=40(2)5a + 15b + 35c = 40 \quad (2) 15a+35b+99c=114(3)15a + 35b + 99c = 114 \quad (3)

(2) −- (1): 10b+20c=20⇒b+2c=210b + 20c = 20 \Rightarrow b + 2c = 2.

(3) −- 3(1): 20b+54c=54⇒10b+27c=2720b + 54c = 54 \Rightarrow 10b + 27c = 27.

Substituting b=2−2cb = 2 - 2c: 20−20c+27c=27⇒c=120 - 20c + 27c = 27 \Rightarrow c = 1, so b=0b = 0. From (1): 5a+15=20⇒a=15a + 15 = 20 \Rightarrow a = 1.

Fitted polynomial:

y=1+x2y = 1 + x^2

This passes exactly through all five points.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2083 · 5 marks

From the table below, find f′(2)f'(2) and f′′(2)f''(2). x = 1, 1.5, 2, 2.5, 3; f(x) = 1, 3.375, 8, 15.625, 27.

Answer

The step is h=0.5h = 0.5 and x=2x = 2 is an interior point, so use central differences.

First derivative:

f′(2)≈f(2.5)−f(1.5)2h=15.625−3.3751=12.25f'(2) \approx \frac{f(2.5) - f(1.5)}{2h} = \frac{15.625 - 3.375}{1} = 12.25

Second derivative:

f′′(2)≈f(2.5)−2f(2)+f(1.5)h2=15.625−16+3.3750.25=30.25=12f''(2) \approx \frac{f(2.5) - 2f(2) + f(1.5)}{h^2} = \frac{15.625 - 16 + 3.375}{0.25} = \frac{3}{0.25} = 12

Result: f′(2)≈12.25f'(2) \approx 12.25 and f′′(2)≈12f''(2) \approx 12.

The table values are those of f(x)=x3f(x) = x^3, whose exact values are f′(2)=12f'(2) = 12 and f′′(2)=12f''(2) = 12. The small error in f′f' comes from the truncation term h26f′′′\tfrac{h^2}{6}f''' of the central formula.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2083 · 1+4 marks

What is numerical integration? Derive the Newton-Cotes quadrature formula.

Answer

Numerical integration is the approximate evaluation of a definite integral I=∫abf(x) dxI = \int_a^b f(x)\,dx by a weighted sum of function values at selected points, used when ff has no closed-form antiderivative or is known only as tabulated data.

Newton-Cotes quadrature formula. Divide [a,b][a,b] into nn equal parts of width h=(b−a)/nh = (b-a)/n, with xi=x0+ihx_i = x_0 + ih and yi=f(xi)y_i = f(x_i). Replace f(x)f(x) by Newton's forward interpolating polynomial, with x=x0+phx = x_0 + ph, so dx=h dpdx = h\,dp:

I=∫x0xnf(x) dx≈h∫0n[y0+pΔy0+p(p−1)2!Δ2y0+p(p−1)(p−2)3!Δ3y0+… ]dpI = \int_{x_0}^{x_n} f(x)\,dx \approx h\int_0^n \left[y_0 + p\Delta y_0 + \frac{p(p-1)}{2!}\Delta^2 y_0 + \frac{p(p-1)(p-2)}{3!}\Delta^3 y_0 + \dots\right] dp

Integrating term by term from 0 to nn:

I≈nh[y0+n2Δy0+n(2n−3)12Δ2y0+n(n−2)224Δ3y0+… ]I \approx nh\left[y_0 + \frac{n}{2}\Delta y_0 + \frac{n(2n-3)}{12}\Delta^2 y_0 + \frac{n(n-2)^2}{24}\Delta^3 y_0 + \dots\right]

This is the general Newton-Cotes formula. Special cases:

  • n=1n=1 gives the trapezoidal rule: I=h2(y0+y1)I = \dfrac h2 (y_0 + y_1).
  • n=2n=2 gives Simpson's 1/3 rule: I=h3(y0+4y1+y2)I = \dfrac h3(y_0 + 4y_1 + y_2).
  • n=3n=3 gives Simpson's 3/8 rule: I=3h8(y0+3y1+3y2+y3)I = \dfrac{3h}{8}(y_0 + 3y_1 + 3y_2 + y_3).

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2083 · 5 marks

Evaluate ∫12exx dx\int_{1}^{2} \frac{e^{x}}{x}\,dx using the trapezoidal rule with n=5n=5.

Answer

Here f(x)=ex/xf(x) = e^x/x, a=1a=1, b=2b=2, n=5n=5, so h=(2−1)/5=0.2h = (2-1)/5 = 0.2.

iixix_if(xi)f(x_i)
01.02.71828
11.22.76676
21.42.89657
31.63.09565
41.83.36092
52.03.69453

Trapezoidal rule:

I≈h2[f0+f5+2(f1+f2+f3+f4)]I \approx \frac h2\left[f_0 + f_5 + 2(f_1 + f_2 + f_3 + f_4)\right]

=0.1[2.71828+3.69453+2(2.76676+2.89657+3.09565+3.36092)]= 0.1\left[2.71828 + 3.69453 + 2(2.76676 + 2.89657 + 3.09565 + 3.36092)\right]

=0.1[6.41281+24.23980]=0.1(30.65261)=3.0653= 0.1\left[6.41281 + 24.23980\right] = 0.1(30.65261) = 3.0653

Result: I≈3.065I \approx 3.065.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2083 · 5 marks

For dydx=2x+3y\frac{dy}{dx} = 2x+3y with y(0)=1y(0)=1, find y(0.2)y(0.2) using Runge-Kutta.

Answer

Here f(x,y)=2x+3yf(x,y) = 2x + 3y, x0=0x_0 = 0, y0=1y_0 = 1, and h=0.2h = 0.2, so one step of the fourth-order Runge-Kutta method reaches x=0.2x = 0.2.

  • k1=hf(x0,y0)=0.2(0+3)=0.6k_1 = hf(x_0, y_0) = 0.2(0 + 3) = 0.6
  • k2=hf(0.1, 1.3)=0.2(0.2+3.9)=0.82k_2 = hf(0.1,\ 1.3) = 0.2(0.2 + 3.9) = 0.82
  • k3=hf(0.1, 1.41)=0.2(0.2+4.23)=0.886k_3 = hf(0.1,\ 1.41) = 0.2(0.2 + 4.23) = 0.886
  • k4=hf(0.2, 1.886)=0.2(0.4+5.658)=1.2116k_4 = hf(0.2,\ 1.886) = 0.2(0.4 + 5.658) = 1.2116

y(0.2)=y0+16(k1+2k2+2k3+k4)=1+16(0.6+1.64+1.772+1.2116)=1+0.8706y(0.2) = y_0 + \frac16(k_1 + 2k_2 + 2k_3 + k_4) = 1 + \frac16(0.6 + 1.64 + 1.772 + 1.2116) = 1 + 0.8706

Result: y(0.2)≈1.8706y(0.2) \approx 1.8706.

The exact solution is y=119e3x−2x3−29y = \tfrac{11}{9}e^{3x} - \tfrac{2x}{3} - \tfrac29, which gives 1.87141.8714 at x=0.2x=0.2, so the RK result is accurate.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2083 · 2+3 marks

Differentiate initial value and boundary value problems. Explain the solution of a system of ODEs.

Answer

Initial value problem versus boundary value problem.

BasisInitial value problem (IVP)Boundary value problem (BVP)
ConditionsAll given at one point, e.g. y(x0)y(x_0), y′(x0)y'(x_0)Given at two or more different points, e.g. y(a)y(a), y(b)y(b)
Exampley′′=−y, y(0)=0, y′(0)=1y'' = -y,\ y(0)=0,\ y'(0)=1y′′=−y, y(0)=0, y(π/2)=1y'' = -y,\ y(0)=0,\ y(\pi/2)=1
MethodsEuler, Runge-Kutta, predictor-corrector (marching)Shooting, finite difference
SolutionStep-by-step from the startOften needs a whole system solved at once

Solution of a system of ODEs. A system has the form

dy1dx=f1(x,y1,…,yn),  …,  dyndx=fn(x,y1,…,yn)\frac{dy_1}{dx} = f_1(x, y_1, \dots, y_n), \;\dots,\; \frac{dy_n}{dx} = f_n(x, y_1, \dots, y_n)

with initial values yi(x0)y_i(x_0). In vector form it is y′=f(x,y)\mathbf{y}' = \mathbf{f}(x, \mathbf{y}), and any single-variable method extends directly by applying it to every equation at each step.

For example, with RK4 for two equations y′=f(x,y,z)y' = f(x,y,z), z′=g(x,y,z)z' = g(x,y,z), compute k1,…,k4k_1,\dots,k_4 for yy and l1,…,l4l_1,\dots,l_4 for zz at the same stage values, then update

yn+1=yn+16(k1+2k2+2k3+k4),zn+1=zn+16(l1+2l2+2l3+l4)y_{n+1} = y_n + \tfrac16(k_1 + 2k_2 + 2k_3 + k_4), \qquad z_{n+1} = z_n + \tfrac16(l_1 + 2l_2 + 2l_3 + l_4)

Higher-order equations are first reduced to such first-order systems.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2083 · 5 marks

Explain the classification of partial differential equations by order and linearity.

Answer

A partial differential equation (PDE) involves an unknown function of two or more independent variables and its partial derivatives.

Classification by order. The order is the highest-order partial derivative present.

  • First order: ux+uy=0u_x + u_y = 0
  • Second order: uxx+uyy=0u_{xx} + u_{yy} = 0 (Laplace equation)

Classification by linearity.

  • Linear: the unknown function and its derivatives appear only to the first power and are not multiplied together, with coefficients depending only on the independent variables, e.g. ut=αuxxu_t = \alpha u_{xx} (heat equation).
  • Semi-linear: linear in the highest-order derivatives, with coefficients that depend only on the independent variables, but the lower-order terms may be nonlinear, e.g. uxx+uyy=u2u_{xx} + u_{yy} = u^2.
  • Quasi-linear: linear in the highest-order derivatives, but their coefficients may depend on uu and lower derivatives, e.g. u ux+ut=0u\,u_x + u_t = 0.
  • Non-linear: the highest-order derivatives appear non-linearly, e.g. (ux)2+(uy)2=1(u_x)^2 + (u_y)^2 = 1.

Second-order linear PDEs Auxx+Buxy+Cuyy+⋯=0Au_{xx} + Bu_{xy} + Cu_{yy} + \dots = 0 are further classified by the discriminant B2−4ACB^2 - 4AC:

DiscriminantTypeExample
B2−4AC<0B^2 - 4AC < 0EllipticLaplace: uxx+uyy=0u_{xx} + u_{yy} = 0
B2−4AC=0B^2 - 4AC = 0ParabolicHeat: ut=αuxxu_t = \alpha u_{xx}
B2−4AC>0B^2 - 4AC > 0HyperbolicWave: utt=c2uxxu_{tt} = c^2 u_{xx}

A PDE is also called homogeneous if every term contains uu or its derivatives, and non-homogeneous otherwise.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

Questions from TU BIT 2078 Third Semester Data Structures and Algorithms (TU IOST semester board exam, 2078 (BS), via StudyNp), TU BIT 2079 Third Semester Data Structures and Algorithms (TU IOST semester board exam, 2079 (BS), via StudyNp), TU BIT 2080 Third Semester Data Structures and Algorithms (TU IOST semester board exam, 2080 (BS), via StudyNp), TU BIT 2082 Third Semester Data Structures and Algorithms (TU IOST semester board exam, 2082 (BS), via StudyNp), TU BIT 2083 Third Semester Data Structures and Algorithms (TU IOST semester board exam, 2083 (BS), via StudyNp), TU BIT 2078 Third Semester Database Management System (TU IOST semester board exam, 2078 (BS), via StudyNp), TU BIT 2079 Third Semester Database Management System (TU IOST semester board exam, 2079 (BS), via StudyNp), TU BIT 2080 Third Semester Database Management System (TU IOST semester board exam, 2080 (BS), via StudyNp), TU BIT 2082 Third Semester Database Management System (TU IOST semester board exam, 2082 (BS), via StudyNp), TU BIT 2083 Third Semester Database Management System (TU IOST semester board exam, 2083 (BS), via StudyNp), TU BIT 2078 Third Semester Numerical Methods (TU IOST semester board exam, 2078 (BS), via StudyNp), TU BIT 2079 Third Semester Numerical Methods (TU IOST semester board exam, 2079 (BS), via StudyNp), TU BIT 2080 Third Semester Numerical Methods (TU IOST semester board exam, 2080 (BS), via StudyNp), TU BIT 2082 Third Semester Numerical Methods (TU IOST semester board exam, 2082 (BS), via StudyNp), TU BIT 2083 Third Semester Numerical Methods (TU IOST semester board exam, 2083 (BS), via StudyNp), TU BIT 2078 Third Semester Operating Systems (TU IOST semester board exam, 2078 (BS), via StudyNp), TU BIT 2079 Third Semester Operating Systems (TU IOST semester board exam, 2079 (BS), via StudyNp), TU BIT 2080 Third Semester Operating Systems (TU IOST semester board exam, 2080 (BS), via StudyNp), TU BIT 2082 Third Semester Operating Systems (TU IOST semester board exam, 2082 (BS), via StudyNp), TU BIT 2083 Third Semester Operating Systems (TU IOST semester board exam, 2083 (BS), via StudyNp), TU BIT 2078 Third Semester Principles of Management (TU IOST semester board exam, 2078 (BS), via StudyNp), TU BIT 2079 Third Semester Principles of Management (TU IOST semester board exam, 2079 (BS), via StudyNp), TU BIT 2080 Third Semester Principles of Management (TU IOST semester board exam, 2080 (BS), via StudyNp), TU BIT 2082 Third Semester Principles of Management (TU IOST semester board exam, 2082 (BS), via StudyNp) and TU BIT 2083 Third Semester Principles of Management (TU IOST semester board exam, 2083 (BS), via StudyNp). Answers are written for this site; check them against your class notes.