Skip to main content

Chapter 1

Numerical Method

TU BSc CSIT past exam questions

Past questions and answers

70 questions set from this chapter, 1 of them more than once; 1 is most repeated (set, or a close variant set, in 3 or more exams). Most repeated first.

  • Most repeated · 3 of 8 exams
  • 2079 · 5 marks

Solve the Poisson’s equation ∇^2f=3x^2y over the square domain 0 ≤ x ≤ 3, 0 ≤ y ≤ 3 with f=0 on the boundary and h=1.

Similar questions: Solve the Poison’s equation over the square (2075) · Solve the Poisson’s equation ∇²f = xy (2080)

Answer

Poisson's equation by finite differences. With a square grid of step hh, the five-point formula for ∇2f=g(x,y)\nabla^2f=g(x,y) is

fi+1,j+fi−1,j+fi,j+1+fi,j−1−4fi,j=h2g(xi,yj)f_{i+1,j}+f_{i-1,j}+f_{i,j+1}+f_{i,j-1}-4f_{i,j}=h^2g(x_i,y_j)

Here h=1h=1 on 0≤x,y≤30\le x,y\le3, so the interior points are (1,1),(2,1),(1,2),(2,2)(1,1),(2,1),(1,2),(2,2) and g=3x2yg=3x^2y gives

g(1,1)=3,g(2,1)=12,g(1,2)=6,g(2,2)=24.g(1,1)=3,\quad g(2,1)=12,\quad g(1,2)=6,\quad g(2,2)=24.

Boundary values are all zero. Writing f1,1=a,  f2,1=b,  f1,2=c,  f2,2=df_{1,1}=a,\;f_{2,1}=b,\;f_{1,2}=c,\;f_{2,2}=d:

−4a+b+c=3-4a+b+c=3 a−4b+d=12a-4b+d=12 a−4c+d=6a-4c+d=6 b+c−4d=24b+c-4d=24

Subtracting equation 3 from equation 2: −4b+4c=6⇒c=b+1.5-4b+4c=6\Rightarrow c=b+1.5.

Let s=b+cs=b+c. Adding equations 2 and 3 gives 2a+2d−4s=182a+2d-4s=18, so a+d=9+2sa+d=9+2s. Adding equations 1 and 4 gives −4(a+d)+2s=27-4(a+d)+2s=27. Substituting:

−4(9+2s)+2s=27⇒−6s=63⇒s=−10.5-4(9+2s)+2s=27\Rightarrow-6s=63\Rightarrow s=-10.5

Then 2b+1.5=−10.52b+1.5=-10.5, so b=−6b=-6, c=−4.5c=-4.5, and a+d=9−21=−12a+d=9-21=-12. From equation 1: −4a−6−4.5=3⇒a=−3.375-4a-6-4.5=3\Rightarrow a=-3.375, hence d=−8.625d=-8.625.

f(1,1)=−3.375,f(2,1)=−6,f(1,2)=−4.5,f(2,2)=−8.625f(1,1)=-3.375,\quad f(2,1)=-6,\quad f(1,2)=-4.5,\quad f(2,2)=-8.625

Check eq. 4: −6−4.5+34.5=24-6-4.5+34.5=24. Correct.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • Asked 2 times
  • 2079 · 5 marks
  • 2080 · 5 marks

Write down the program for solving ordinary differential equation using Heun’s method.

Answer

Heun's method. For y′=f(x,y)y'=f(x,y), y(x0)=y0y(x_0)=y_0, with step hh:

yi+1p=yi+hf(xi,yi),yi+1=yi+h2[f(xi,yi)+f(xi+1,yi+1p)]y^{p}_{i+1}=y_i+hf(x_i,y_i),\qquad y_{i+1}=y_i+\frac h2\left[f(x_i,y_i)+f(x_{i+1},y^{p}_{i+1})\right]

Algorithm.

  1. Read x0x_0, y0y_0, step size hh and the final value xnx_n.
  2. Compute the number of steps n=(xn−x0)/hn=(x_n-x_0)/h.
  3. Repeat nn times: k1=f(x,y)k_1=f(x,y); yp=y+hk1y_p=y+hk_1; k2=f(x+h,yp)k_2=f(x+h,y_p); y=y+h2(k1+k2)y=y+\frac h2(k_1+k_2); x=x+hx=x+h; print x,yx,y.

Program (C). The example equation is y′=x+yy'=x+y; change f for another problem.

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

double f(double x, double y) {
    return x + y;          /* dy/dx = f(x, y) */
}

int main(void) {
    double x0, y0, xn, h, x, y, k1, k2, yp;
    int i, n;

    printf("Enter x0, y0: ");
    scanf("%lf %lf", &x0, &y0);
    printf("Enter final x and step size h: ");
    scanf("%lf %lf", &xn, &h);

    n = (int)floor((xn - x0) / h + 0.5);
    x = x0;
    y = y0;
    printf("%10s %12s\n", "x", "y");
    printf("%10.4f %12.6f\n", x, y);
    for (i = 0; i < n; i++) {
        k1 = f(x, y);
        yp = y + h * k1;               /* predictor (Euler) */
        k2 = f(x + h, yp);
        y = y + h / 2.0 * (k1 + k2);   /* corrector (trapezoidal) */
        x = x + h;
        printf("%10.4f %12.6f\n", x, y);
    }
    return 0;
}

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2075 · 8 marks

Evaluate the following integration using Romberg integration. ∫01sinxxdx\int_{0}^{1} \frac{sinx}{x} dx

Similar questions: Evaluate the following integration using Romberg integration (2078)

Answer

Romberg integration improves trapezoidal estimates by Richardson extrapolation: Rk,1=T(hk),hk=b−a2k−1,Rk,j=Rk,j−1+Rk,j−1−Rk−1,j−14 j−1−1R_{k,1}=T(h_k),\quad h_k=\frac{b-a}{2^{k-1}},\qquad R_{k,j}=R_{k,j-1}+\frac{R_{k,j-1}-R_{k-1,j-1}}{4^{\,j-1}-1}

Here f(x)=sin⁡xxf(x)=\dfrac{\sin x}{x} with f(0)=1f(0)=1 (limit), a=0, b=1a=0,\ b=1.

Function values: f(0)=1f(0)=1, f(1)=sin⁡1=0.841471f(1)=\sin 1=0.841471, f(0.5)=0.4794260.5=0.958851f(0.5)=\dfrac{0.479426}{0.5}=0.958851, f(0.25)=0.2474040.25=0.989616f(0.25)=\dfrac{0.247404}{0.25}=0.989616, f(0.75)=0.6816390.75=0.908852f(0.75)=\dfrac{0.681639}{0.75}=0.908852.

Trapezoidal estimates

  • h=1h=1: R1,1=12(1+0.841471)=0.920735R_{1,1}=\dfrac12(1+0.841471)=0.920735
  • h=0.5h=0.5: R2,1=12R1,1+0.5 f(0.5)=0.460368+0.479426=0.939793R_{2,1}=\dfrac12R_{1,1}+0.5\,f(0.5)=0.460368+0.479426=0.939793
  • h=0.25h=0.25: R3,1=12R2,1+0.25 [f(0.25)+f(0.75)]=0.469897+0.25(1.898468)=0.944514R_{3,1}=\dfrac12R_{2,1}+0.25\,[f(0.25)+f(0.75)]=0.469897+0.25(1.898468)=0.944514
  • h=0.125h=0.125: R4,1=0.945691R_{4,1}=0.945691 (adding the four new midpoints f(0.125),f(0.375),f(0.625),f(0.875)f(0.125),f(0.375),f(0.625),f(0.875))

Romberg table

hhRk,1R_{k,1} (trapezoidal)Rk,2R_{k,2}Rk,3R_{k,3}Rk,4R_{k,4}
10.920735
0.50.9397930.946146
0.250.9445140.9460870.946083
0.1250.9456910.9460830.9460830.946083

Sample extrapolations: R2,2=0.939793+0.939793−0.9207353=0.946146R_{2,2}=0.939793+\frac{0.939793-0.920735}{3}=0.946146 R3,2=0.944514+0.944514−0.9397933=0.946087R_{3,2}=0.944514+\frac{0.944514-0.939793}{3}=0.946087 R3,3=0.946087+0.946087−0.94614615=0.946083R_{3,3}=0.946087+\frac{0.946087-0.946146}{15}=0.946083

Successive entries agree to six decimals, so ∫01sin⁡xx dx≈0.946083\int_0^1\frac{\sin x}{x}\,dx\approx 0.946083

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2075 · 8 marks

Solve the following set of equations using Gauss Seidel method. x + 2y + 3z = 4 6x – 4y + 5z = 10 5x + 2y + 2z = 25

Similar questions: Solve the following set of equations using (2079)

Answer

Condition for convergence. Gauss-Seidel converges when the coefficient matrix is diagonally dominant (sufficient condition). In the order given, the system is not diagonally dominant, and the iteration diverges. No re-ordering makes the matrix strictly diagonally dominant, but the order below makes the iteration converge (spectral radius ≈0.85<1\approx0.85<1): 5x+2y+2z=25,x+2y+3z=4,6x−4y+5z=105x+2y+2z=25,\qquad x+2y+3z=4,\qquad 6x-4y+5z=10

Iteration formulas (latest values are used immediately): x(k+1)=25−2y(k)−2z(k)5,y(k+1)=4−x(k+1)−3z(k)2,z(k+1)=10−6x(k+1)+4y(k+1)5x^{(k+1)}=\frac{25-2y^{(k)}-2z^{(k)}}{5},\qquad y^{(k+1)}=\frac{4-x^{(k+1)}-3z^{(k)}}{2},\qquad z^{(k+1)}=\frac{10-6x^{(k+1)}+4y^{(k+1)}}{5}

Start with x=y=z=0x=y=z=0.

Iterxxyyzz
15.0000-0.5000-4.4000
26.96005.1200-2.2560
33.85443.45680.1402
43.56120.0092-2.2661
55.90282.4478-3.1251
65.27094.0522-1.0833
104.53312.7784-1.2170
204.85232.5477-1.7846
304.81132.3958-1.8569
404.79082.3729-1.8507
604.78832.3748-1.8461

Example, iteration 1: x=255=5x=\dfrac{25}{5}=5; y=4−5−02=−0.5y=\dfrac{4-5-0}{2}=-0.5; z=10−30−25=−4.4z=\dfrac{10-30-2}{5}=-4.4.

The iterates oscillate and settle slowly (the convergence is slow because the system is only weakly dominant). They approach x≈4.79,y≈2.38,z≈−1.85x\approx4.79,\quad y\approx2.38,\quad z\approx-1.85

Check by direct elimination. Eliminating gives the exact solution x=4.7885, y=2.375, z=−1.8462x=4.7885,\ y=2.375,\ z=-1.8462. Substitution in the original equations: 4.7885+4.75−5.5385=4.004.7885+4.75-5.5385=4.00, 28.731−9.5−9.231=10.0028.731-9.5-9.231=10.00, 23.942+4.75−3.692=25.0023.942+4.75-3.692=25.00. All three equations are satisfied.

So x≈4.79, y≈2.38, z≈−1.85x\approx4.79,\ y\approx2.38,\ z\approx-1.85.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2075 · 8 marks

Solve the Poison’s equation over the square domain 0 ≤ x ≤ 1.5, 0 ≤ y ≤ 1.5 with f = 0 on the boundary and h = 0.5.

Similar questions: Solve the Poisson’s equation ∇^2f=3x^2y over the (2079)

Answer

Setting up. Poisson's equation is ∇2u=∂2u∂x2+∂2u∂y2=g(x,y)\nabla^2u=\dfrac{\partial^2u}{\partial x^2}+\dfrac{\partial^2u}{\partial y^2}=g(x,y). Using the five-point central difference formula on a square grid of side hh: ui+1,j+ui−1,j+ui,j+1+ui,j−1−4ui,j=h2g(xi,yj)u_{i+1,j}+u_{i-1,j}+u_{i,j+1}+u_{i,j-1}-4u_{i,j}=h^2g(x_i,y_j)

With 0≤x,y≤1.50\le x,y\le1.5 and h=0.5h=0.5, the grid points are x,y∈{0, 0.5, 1.0, 1.5}x,y\in\{0,\,0.5,\,1.0,\,1.5\}, a 4×44\times4 grid. The boundary nodes (12 points) all have the prescribed value 00. The interior nodes are (0.5,0.5), (1,0.5), (0.5,1), (1,1)(0.5,0.5),\ (1,0.5),\ (0.5,1),\ (1,1), which we call u1,u2,u3,u4u_1,u_2,u_3,u_4:

u3  u4
u1  u2

Equations. The source term is g=f=0g=f=0 (as given in the question), so the equation is ∇2u=0\nabla^2u=0 (Laplace form). For each interior node:

  • u1u_1: 0+u2+u3+0−4u1=00+u_2+u_3+0-4u_1=0
  • u2u_2: u1+0+0+u4−4u2=0u_1+0+0+u_4-4u_2=0
  • u3u_3: 0+u4+u1+0−4u3=00+u_4+u_1+0-4u_3=0
  • u4u_4: u3+0+u2+0−4u4=0u_3+0+u_2+0-4u_4=0

By symmetry u1=u2=u3=u4=uu_1=u_2=u_3=u_4=u, so 2u−4u=0⇒u=02u-4u=0\Rightarrow u=0.

Check by elimination: adding all four equations gives −2(u1+u2+u3+u4)=0-2(u_1+u_2+u_3+u_4)=0, so the sum is 00, and then each equation 4ui=uj+uk4u_i=u_j+u_k with the symmetric structure gives ui=0u_i=0.

u1=u2=u3=u4=0u_1=u_2=u_3=u_4=0

Remark. If a non-zero source gg were supplied, then by symmetry each interior node would satisfy −2u=h2g-2u=h^2g, i.e. u=−h2g/2=−0.125 gu=-h^2g/2=-0.125\,g for a constant gg. With g=0g=0 and zero boundary values, the solution is identically zero.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2077 · 8 marks

Construct Newton’s forward difference table for the given data points and approximate the value of f(x) at x = 15.
x1020304050
F(x)0.1730.3420.50.6430.766

Similar questions: Construct Newton’s backward difference table for given (2080)

Answer

Forward difference table (h=10h=10)

xxf(x)f(x)Δf\Delta fΔ2f\Delta^2fΔ3f\Delta^3fΔ4f\Delta^4f
100.1730.169-0.011-0.004-0.001
200.3420.158-0.015-0.005
300.5000.143-0.020
400.6430.123
500.766

Newton's forward interpolation formula f(x)=f0+p Δf0+p(p−1)2!Δ2f0+p(p−1)(p−2)3!Δ3f0+p(p−1)(p−2)(p−3)4!Δ4f0,p=x−x0hf(x)=f_0+p\,\Delta f_0+\frac{p(p-1)}{2!}\Delta^2f_0+\frac{p(p-1)(p-2)}{3!}\Delta^3f_0+\frac{p(p-1)(p-2)(p-3)}{4!}\Delta^4f_0,\qquad p=\frac{x-x_0}{h}

For x=15x=15: p=15−1010=0.5p=\dfrac{15-10}{10}=0.5.

Terms:

  • f0=0.173f_0=0.173
  • p Δf0=0.5(0.169)=0.0845p\,\Delta f_0=0.5(0.169)=0.0845
  • 0.5(−0.5)2(−0.011)=(−0.125)(−0.011)=0.001375\dfrac{0.5(-0.5)}{2}(-0.011)=(-0.125)(-0.011)=0.001375
  • 0.5(−0.5)(−1.5)6(−0.004)=(0.0625)(−0.004)=−0.00025\dfrac{0.5(-0.5)(-1.5)}{6}(-0.004)=(0.0625)(-0.004)=-0.00025
  • 0.5(−0.5)(−1.5)(−2.5)24(−0.001)=(−0.0390625)(−0.001)=0.000039\dfrac{0.5(-0.5)(-1.5)(-2.5)}{24}(-0.001)=(-0.0390625)(-0.001)=0.000039

f(15)=0.173+0.0845+0.001375−0.00025+0.000039=0.258664f(15)=0.173+0.0845+0.001375-0.00025+0.000039=0.258664 f(15)≈0.2587\boxed{f(15)\approx0.2587}

(The data are sin⁡x∘\sin x^\circ; the true value of sin⁡15∘\sin15^\circ is 0.25880.2588.)

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2078 · 5 marks

Evaluate the following integration using Romberg integration. ∫01sin2xxdx\int_{0}^{1} \frac{sin^2 x}{x} dx

Similar questions: Evaluate the following integration using Romberg integration (2075)

Answer

Romberg integration. Romberg integration improves trapezoidal estimates by Richardson extrapolation. With TkT_k the trapezoidal value using 2k2^{k} strips:

Rk,2=4Tk+1−Tk3,Rk,3=16Rk+1,2−Rk,215,Rk,4=64Rk+1,3−Rk,363R_{k,2}=\frac{4T_{k+1}-T_k}{3},\quad R_{k,3}=\frac{16R_{k+1,2}-R_{k,2}}{15},\quad R_{k,4}=\frac{64R_{k+1,3}-R_{k,3}}{63}

Problem. f(x)=sin⁡2xxf(x)=\dfrac{\sin^2x}{x}, f(0)=0f(0)=0 (limit), f(1)=sin⁡21=0.708073f(1)=\sin^21=0.708073.

  • h=1h=1 (1 strip): T1=12(0+0.708073)=0.354037T_1=\tfrac12(0+0.708073)=0.354037
  • h=0.5h=0.5: f(0.5)=0.459698f(0.5)=0.459698, so T2=12T1+0.5(0.459698)=0.406867T_2=\tfrac12T_1+0.5(0.459698)=0.406867
  • h=0.25h=0.25: f(0.25)=0.244835f(0.25)=0.244835, f(0.75)=0.619509f(0.75)=0.619509, so T3=12T2+0.25(0.864344)=0.419519T_3=\tfrac12T_2+0.25(0.864344)=0.419519
  • h=0.125h=0.125: f(0.125)=0.124350f(0.125)=0.124350, f(0.375)=0.357748f(0.375)=0.357748, f(0.625)=0.547742f(0.625)=0.547742, f(0.875)=0.673283f(0.875)=0.673283 (sum 1.7031241.703124), so T4=12T3+0.125(1.703124)=0.422650T_4=\tfrac12T_3+0.125(1.703124)=0.422650

Romberg table:

TT (trapezoid)1st extrapolation2nd extrapolation3rd extrapolation
0.354037
0.4068670.424477
0.4195190.4237370.423688
0.4226500.4236940.4236910.423691

For example 4(0.406867)−0.3540373=0.424477\dfrac{4(0.406867)-0.354037}{3}=0.424477 and 16(0.423737)−0.42447715=0.423688\dfrac{16(0.423737)-0.424477}{15}=0.423688.

∫01sin⁡2xx dx≈0.42369\int_0^1\frac{\sin^2x}{x}\,dx\approx0.42369

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2078 · 5 marks

Solve the following set of linear equations using the Gauss-Jordan method. x_2 + 2x_3 + 3x_4 = 9 7x_1 + 6x_2 + 5x_3 + 4x_4 = 33 8x_1 + 9x_2 + x_4 = 27 2x_1 + 5x_2 + 4x_3 + 3x_4 = 23

Similar questions: Solve the following system of linear equations (2081)

Answer

Gauss-Jordan method. The augmented matrix is reduced to the identity (reduced row echelon form) by row operations, so the solution can be read directly from the last column.

Augmented matrix (equations written with all four unknowns):

[01239765433890127254323]\left[\begin{array}{cccc|c}0&1&2&3&9\\7&6&5&4&33\\8&9&0&1&27\\2&5&4&3&23\end{array}\right]

The first pivot is zero, so interchange R1↔R3R_1\leftrightarrow R_3 and normalise (R1←R1/8R_1\leftarrow R_1/8), then eliminate column 1:

[1980182780−15852587580123901144114654]\left[\begin{array}{cccc|c}1&\frac98&0&\frac18&\frac{27}8\\0&-\frac{15}8&5&\frac{25}8&\frac{75}8\\0&1&2&3&9\\0&\frac{11}4&4&\frac{11}4&\frac{65}4\end{array}\right]

Normalise R2R_2 by its pivot −158-\tfrac{15}{8} and clear column 2 in all other rows:

[1032901−83−53−500143143140034322330]\left[\begin{array}{cccc|c}1&0&3&2&9\\0&1&-\frac83&-\frac53&-5\\0&0&\frac{14}3&\frac{14}3&14\\0&0&\frac{34}3&\frac{22}3&30\end{array}\right]

Third stage (normalise R3R_3: R3←314R3R_3\leftarrow\frac3{14}R_3 gives (0,0,1,1,3)(0,0,1,1,3), then clear column 3):

[100−100101300113000−4−4]\left[\begin{array}{cccc|c}1&0&0&-1&0\\0&1&0&1&3\\0&0&1&1&3\\0&0&0&-4&-4\end{array}\right]

Fourth stage (R4←R4/(−4)R_4\leftarrow R_4/(-4), then clear column 4):

[10001010020010200011]\left[\begin{array}{cccc|c}1&0&0&0&1\\0&1&0&0&2\\0&0&1&0&2\\0&0&0&1&1\end{array}\right]

x1=1,x2=2,x3=2,x4=1x_1=1,\quad x_2=2,\quad x_3=2,\quad x_4=1

Check in equation 2: 7+12+10+4=337+12+10+4=33. Correct.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2079 · 5 marks

Solve the following set of equations using Gauss Siedal method. x + 2y + 3z = 4 6x + 4y + 5z = 16 5x + 2y + 3z = 12

Similar questions: Solve the following set of equations using (2075)

Answer

Gauss-Seidel method. Each unknown is solved from its own equation, always using the newest available values:

x(k+1)=…a11,y(k+1) uses x(k+1),z(k+1) uses x(k+1),y(k+1)x^{(k+1)}=\frac{\ldots}{a_{11}},\quad y^{(k+1)}\text{ uses }x^{(k+1)},\quad z^{(k+1)}\text{ uses }x^{(k+1)},y^{(k+1)}

The method converges if the system is diagonally dominant (or if the iteration matrix has spectral radius below 1). The given equations are not diagonally dominant in any order, but taking them in the order

5x+2y+3z=12,6x+4y+5z=16,x+2y+3z=45x+2y+3z=12,\qquad 6x+4y+5z=16,\qquad x+2y+3z=4

gives a convergent iteration (spectral radius 5/6<15/6<1):

x=12−2y−3z5,y=16−6x−5z4,z=4−x−2y3x=\frac{12-2y-3z}{5},\qquad y=\frac{16-6x-5z}{4},\qquad z=\frac{4-x-2y}{3}

Start with x=y=z=0x=y=z=0:

Iterationxxyyzz
12.40000.40000.2667
22.08000.54670.2756
32.01600.63160.2403
42.00320.69480.2024
52.00060.74610.1691
102.00000.89800.0680
202.00000.98350.0110
302.00000.99730.0018

The values tend to x=2,  y=1,  z=0x=2,\;y=1,\;z=0 (convergence in y,zy,z is slow). Verification: 2+2+0=42+2+0=4, 12+4+0=1612+4+0=16, 10+2+0=1210+2+0=12.

x=2,y=1,z=0x=2,\quad y=1,\quad z=0

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2080 · 5 marks

Construct Newton’s backward difference table for given data points and approximate the value of f(x) at x=45.
x1020304050
f(x)0.9850.9340.8660.7660.643

Similar questions: Construct Newton’s forward difference table for the (2077)

Answer

Backward difference table (h=10h=10, ∇fi=fi−fi−1\nabla f_i=f_i-f_{i-1})

xxf(x)f(x)∇f\nabla f∇2f\nabla^2 f∇3f\nabla^3 f∇4f\nabla^4 f
100.985
200.934−0.051-0.051
300.866−0.068-0.068−0.017-0.017
400.766−0.100-0.100−0.032-0.032−0.015-0.015
500.643−0.123-0.123−0.023-0.0230.0090.0090.0240.024

Newton's backward formula

f(x)=fn+p∇fn+p(p+1)2!∇2fn+p(p+1)(p+2)3!∇3fn+p(p+1)(p+2)(p+3)4!∇4fn,p=x−xnhf(x)=f_n+p\nabla f_n+\frac{p(p+1)}{2!}\nabla^2f_n+\frac{p(p+1)(p+2)}{3!}\nabla^3f_n+\frac{p(p+1)(p+2)(p+3)}{4!}\nabla^4f_n,\qquad p=\frac{x-x_n}{h}

Here xn=50x_n=50, so p=45−5010=−0.5p=\dfrac{45-50}{10}=-0.5.

  • p∇fn=(−0.5)(−0.123)=0.0615p\nabla f_n=(-0.5)(-0.123)=0.0615
  • p(p+1)2∇2fn=(−0.5)(0.5)2(−0.023)=(−0.125)(−0.023)=0.002875\dfrac{p(p+1)}{2}\nabla^2f_n=\dfrac{(-0.5)(0.5)}{2}(-0.023)=(-0.125)(-0.023)=0.002875
  • p(p+1)(p+2)6∇3fn=(−0.5)(0.5)(1.5)6(0.009)=(−0.0625)(0.009)=−0.0005625\dfrac{p(p+1)(p+2)}{6}\nabla^3f_n=\dfrac{(-0.5)(0.5)(1.5)}{6}(0.009)=(-0.0625)(0.009)=-0.0005625
  • p(p+1)(p+2)(p+3)24∇4fn=(−0.5)(0.5)(1.5)(2.5)24(0.024)=(−0.0390625)(0.024)=−0.0009375\dfrac{p(p+1)(p+2)(p+3)}{24}\nabla^4f_n=\dfrac{(-0.5)(0.5)(1.5)(2.5)}{24}(0.024)=(-0.0390625)(0.024)=-0.0009375

f(45)=0.643+0.0615+0.002875−0.0005625−0.0009375=0.705875≈0.7059f(45)=0.643+0.0615+0.002875-0.0005625-0.0009375=0.705875\approx0.7059

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2080 · 5 marks

Solve the Poisson’s equation ∇²f = xy and f=2 on boundary by assuming square domain 0 ≤ x ≤ 3 and 0 ≤ y ≤ 3 and h=1.

Similar questions: Solve the Poisson’s equation ∇^2f=3x^2y over the (2079)

Answer

Finite-difference form. With equal step hh in both directions, the five-point formula for ∇2f=g(x,y)\nabla^2f=g(x,y) is

fi+1,j+fi−1,j+fi,j+1+fi,j−1−4fi,j=h2g(xi,yj),g=xy, h=1f_{i+1,j}+f_{i-1,j}+f_{i,j+1}+f_{i,j-1}-4f_{i,j}=h^2g(x_i,y_j),\qquad g=xy,\ h=1

The grid has x,y∈{0,1,2,3}x,y\in\{0,1,2,3\}. The interior points are (1,1),(2,1),(1,2),(2,2)(1,1),(2,1),(1,2),(2,2); all boundary values are 22. Let f1=f(1,1)f_1=f(1,1), f2=f(2,1)f_2=f(2,1), f3=f(1,2)f_3=f(1,2), f4=f(2,2)f_4=f(2,2).

  • At (1,1)(1,1), g=1g=1: f2+f3+2+2−4f1=1⇒−4f1+f2+f3=−3f_2+f_3+2+2-4f_1=1\Rightarrow-4f_1+f_2+f_3=-3
  • At (2,1)(2,1), g=2g=2: f1+f4+2+2−4f2=2⇒f1−4f2+f4=−2f_1+f_4+2+2-4f_2=2\Rightarrow f_1-4f_2+f_4=-2
  • At (1,2)(1,2), g=2g=2: f1+f4+2+2−4f3=2⇒f1−4f3+f4=−2f_1+f_4+2+2-4f_3=2\Rightarrow f_1-4f_3+f_4=-2
  • At (2,2)(2,2), g=4g=4: f2+f3+2+2−4f4=4⇒f2+f3−4f4=0f_2+f_3+2+2-4f_4=4\Rightarrow f_2+f_3-4f_4=0

By symmetry f2=f3f_2=f_3:

−4f1+2f2=−3,f1−4f2+f4=−2,2f2−4f4=0⇒f4=12f2-4f_1+2f_2=-3,\qquad f_1-4f_2+f_4=-2,\qquad 2f_2-4f_4=0\Rightarrow f_4=\tfrac12f_2

Second equation: f1−4f2+0.5f2=−2⇒f1=3.5f2−2f_1-4f_2+0.5f_2=-2\Rightarrow f_1=3.5f_2-2. Substituting in the first: −14f2+8+2f2=−3⇒f2=1112-14f_2+8+2f_2=-3\Rightarrow f_2=\tfrac{11}{12}. Then f1=7724−2=2924f_1=\tfrac{77}{24}-2=\tfrac{29}{24}, f4=1124f_4=\tfrac{11}{24}.

f(1,1)=1.2083,f(2,1)=f(1,2)=0.9167,f(2,2)=0.4583f(1,1)=1.2083,\quad f(2,1)=f(1,2)=0.9167,\quad f(2,2)=0.4583

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2081 · 5 marks

Solve the following system of linear equations using Gauss-Jordan elimination method. x+2y-3z=4 2x+4y-6z=8 x-2y+5z=4

Similar questions: Solve the following set of linear equations (2078)

Answer

Augmented matrix:

[12−3424−681−254]\left[\begin{array}{ccc|c}1&2&-3&4\\2&4&-6&8\\1&-2&5&4\end{array}\right]

R2→R2−2R1R_2\to R_2-2R_1, R3→R3−R1R_3\to R_3-R_1:

[12−3400000−480]\left[\begin{array}{ccc|c}1&2&-3&4\\0&0&0&0\\0&-4&8&0\end{array}\right]

Interchange R2↔R3R_2\leftrightarrow R_3 (to bring a non-zero pivot up), then R2→R2/(−4)R_2\to R_2/(-4):

[12−3401−200000]\left[\begin{array}{ccc|c}1&2&-3&4\\0&1&-2&0\\0&0&0&0\end{array}\right]

R1→R1−2R2R_1\to R_1-2R_2:

[101401−200000]\left[\begin{array}{ccc|c}1&0&1&4\\0&1&-2&0\\0&0&0&0\end{array}\right]

The last row is 0=00=0, so there are only two independent equations for three unknowns: the second equation of the system is twice the first. The system is consistent with infinitely many solutions. Taking z=tz=t as a free parameter:

x=4−t,y=2t,z=t(t∈R)x=4-t,\qquad y=2t,\qquad z=t\qquad(t\in\mathbb R)

Check with t=1t=1: (3,2,1)(3,2,1) gives 3+4−3=43+4-3=4, 6+8−6=86+8-6=8, 3−4+5=43-4+5=4. All three equations hold.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2075 · 2 marks

What is non-linear equation? Derive the required expression to calculate the root of non-linear equation using secant method. Using this expression find a root of following equation. x2+cos(x)–e−x–2=0x^{2} + cos(x) – e^{-x} – 2 = 0

Answer

Non-linear equation. An equation f(x)=0f(x)=0 in which ff is not a linear function of the unknown (it contains terms such as x2x^2, sin⁡x\sin x, exe^{x}, log⁡x\log x) is called a non-linear equation. Such equations usually cannot be solved in closed form, so a root is found by an iterative numerical method.

Derivation of the secant method. Let xn−1x_{n-1} and xnx_n be two approximations of the root. Draw the secant line through (xn−1,f(xn−1))(x_{n-1}, f(x_{n-1})) and (xn,f(xn))(x_n, f(x_n)) and take the point where it cuts the xx-axis as the next approximation xn+1x_{n+1}.

The slope of the secant is m=f(xn)−f(xn−1)xn−xn−1m=\frac{f(x_n)-f(x_{n-1})}{x_n-x_{n-1}}

The line through (xn,f(xn))(x_n, f(x_n)) with this slope is y−f(xn)=m(x−xn)y-f(x_n)=m(x-x_n). Putting y=0y=0, x=xn+1x=x_{n+1}: xn+1=xn−f(xn)mx_{n+1}=x_n-\frac{f(x_n)}{m} xn+1=xn−f(xn) (xn−xn−1)f(xn)−f(xn−1)\boxed{x_{n+1}=x_n-\frac{f(x_n)\,(x_n-x_{n-1})}{f(x_n)-f(x_{n-1})}}

This is Newton's formula with f′(xn)f'(x_n) replaced by the finite-difference slope, so no derivative is needed. The order of convergence is about 1.6181.618.

Solving f(x)=x2+cos⁡x−e−x−2=0f(x)=x^2+\cos x-e^{-x}-2=0 (angles in radians).

f(1)=1+0.5403−0.3679−2=−0.8276f(1)=1+0.5403-0.3679-2=-0.8276, f(2)=4−0.4161−0.1353−2=1.4485f(2)=4-0.4161-0.1353-2=1.4485, so a root lies in (1,2)(1,2). Take x0=1x_0=1, x1=2x_1=2.

nxn−1x_{n-1}xnx_nf(xn−1)f(x_{n-1})f(xn)f(x_n)xn+1x_{n+1}
112-0.827581.448521.36360
221.363601.44852-0.190631.43761
31.363601.43761-0.19063-0.037991.45603
41.437611.45603-0.037990.001371.45539
51.456031.455390.00137-0.000011.45539

Example of one step: x2=2−1.44852 (2−1)1.44852−(−0.82758)=2−0.63640=1.36360x_2=2-\dfrac{1.44852\,(2-1)}{1.44852-(-0.82758)}=2-0.63640=1.36360.

The successive values agree to five decimals, so the root is x≈1.4554x\approx 1.4554

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2075 · 2 marks

What is matrix factorization? Factorize the given matrix A into LU using Doolittle algorithm and also solve Ax = b for given b using L and U matrices. A = [24−4015−5−3231314−22]\begin{bmatrix}2 & 4 & -4 & 0\\ 1 & 5 & -5 & -3\\ 2 & 3 & 1 & 3\\ 1 & 4 & -2 & 2\end{bmatrix} and b = [121888]\begin{bmatrix}12\\ 18\\ 8\\ 8\end{bmatrix}

Answer

Matrix factorization. Matrix factorization (decomposition) writes a matrix AA as a product of simpler matrices. In LU factorization, A=LUA=LU where LL is lower triangular and UU is upper triangular. Then Ax=bAx=b is solved in two easy triangular steps: Ly=bLy=b (forward substitution) and Ux=yUx=y (back substitution).

Doolittle algorithm. LL has a unit diagonal (lii=1l_{ii}=1). For i=1,…,ni=1,\dots,n: uij=aij−∑k=1i−1likukj,j=i,…,nu_{ij}=a_{ij}-\sum_{k=1}^{i-1}l_{ik}u_{kj},\quad j=i,\dots,n lji=1uii(aji−∑k=1i−1ljkuki),j=i+1,…,nl_{ji}=\frac{1}{u_{ii}}\left(a_{ji}-\sum_{k=1}^{i-1}l_{jk}u_{ki}\right),\quad j=i+1,\dots,n

Factorization of A.

Row 1 of UU: u11=2, u12=4, u13=−4, u14=0u_{11}=2,\ u_{12}=4,\ u_{13}=-4,\ u_{14}=0.

Column 1 of LL: l21=1/2=0.5, l31=2/2=1, l41=1/2=0.5l_{21}=1/2=0.5,\ l_{31}=2/2=1,\ l_{41}=1/2=0.5.

Row 2 of UU: u22=5−0.5(4)=3u_{22}=5-0.5(4)=3, u23=−5−0.5(−4)=−3u_{23}=-5-0.5(-4)=-3, u24=−3−0.5(0)=−3u_{24}=-3-0.5(0)=-3.

Column 2 of LL: l32=3−1(4)3=−13l_{32}=\dfrac{3-1(4)}{3}=-\dfrac13, l42=4−0.5(4)3=23l_{42}=\dfrac{4-0.5(4)}{3}=\dfrac23.

Row 3 of UU: u33=1−1(−4)−(−13)(−3)=1+4−1=4u_{33}=1-1(-4)-(-\tfrac13)(-3)=1+4-1=4, u34=3−1(0)−(−13)(−3)=3−1=2u_{34}=3-1(0)-(-\tfrac13)(-3)=3-1=2.

Column 3 of LL: l43=−2−0.5(−4)−23(−3)4=−2+2+24=12l_{43}=\dfrac{-2-0.5(-4)-\tfrac23(-3)}{4}=\dfrac{-2+2+2}{4}=\dfrac12.

Row 4 of UU: u44=2−0.5(0)−23(−3)−12(2)=2+2−1=3u_{44}=2-0.5(0)-\tfrac23(-3)-\tfrac12(2)=2+2-1=3.

L=[10000.51001−13100.523121],U=[24−4003−3−300420003]L=\begin{bmatrix}1&0&0&0\\0.5&1&0&0\\1&-\frac13&1&0\\0.5&\frac23&\frac12&1\end{bmatrix},\qquad U=\begin{bmatrix}2&4&-4&0\\0&3&-3&-3\\0&0&4&2\\0&0&0&3\end{bmatrix}

Solving Ax = b.

Forward substitution Ly=bLy=b:

  • y1=12y_1=12
  • y2=18−0.5(12)=12y_2=18-0.5(12)=12
  • y3=8−1(12)+13(12)=8−12+4=0y_3=8-1(12)+\tfrac13(12)=8-12+4=0
  • y4=8−0.5(12)−23(12)−12(0)=8−6−8=−6y_4=8-0.5(12)-\tfrac23(12)-\tfrac12(0)=8-6-8=-6

Back substitution Ux=yUx=y:

  • 3x4=−6⇒x4=−23x_4=-6\Rightarrow x_4=-2
  • 4x3+2x4=0⇒x3=14x_3+2x_4=0\Rightarrow x_3=1
  • 3x2−3x3−3x4=12⇒3x2=12+3−6=9⇒x2=33x_2-3x_3-3x_4=12\Rightarrow 3x_2=12+3-6=9\Rightarrow x_2=3
  • 2x1+4x2−4x3=12⇒2x1=12−12+4=4⇒x1=22x_1+4x_2-4x_3=12\Rightarrow 2x_1=12-12+4=4\Rightarrow x_1=2

x=(2, 3, 1, −2)Tx=(2,\ 3,\ 1,\ -2)^T

Check in the first equation: 2(2)+4(3)−4(1)+0=122(2)+4(3)-4(1)+0=12. In the last: 2+12−2−4=82+12-2-4=8. Both are correct.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2075 · 2 marks

What is initial value problem and boundary value problem? Write an algorithm and program to solve the boundary value problem using shooting method.

Answer

Initial value problem (IVP). A differential equation whose auxiliary conditions are all given at the same point. Example: y′′=f(x,y,y′)y''=f(x,y,y') with y(a)=α, y′(a)=βy(a)=\alpha,\ y'(a)=\beta. It can be marched forward directly (Euler, Runge-Kutta).

Boundary value problem (BVP). A differential equation whose conditions are given at two different points. Example: y′′=f(x,y,y′)y''=f(x,y,y') with y(a)=α, y(b)=βy(a)=\alpha,\ y(b)=\beta. Since y′(a)y'(a) is unknown, direct marching is not possible.

Shooting method. The BVP is converted into an IVP by guessing the missing initial slope s=y′(a)s=y'(a). The IVP is solved (here by RK4) up to x=bx=b, and the computed end value y(b;s)y(b;s) is compared with the required β\beta. The mismatch ϕ(s)=y(b;s)−β\phi(s)=y(b;s)-\beta is a non-linear equation in ss, solved with the secant method: sk+1=sk−ϕ(sk)(sk−sk−1)ϕ(sk)−ϕ(sk−1)s_{k+1}=s_k-\frac{\phi(s_k)(s_k-s_{k-1})}{\phi(s_k)-\phi(s_{k-1})} For a linear ODE, ϕ\phi is linear in ss, so one secant step gives the exact slope.

Algorithm

  1. Read a,b,α,βa,b,\alpha,\beta, step hh, tolerance ε\varepsilon.
  2. Choose two guesses s0,s1s_0,s_1 for y′(a)y'(a).
  3. For each guess, write the ODE as the system y′=z, z′=f(x,y,z)y'=z,\ z'=f(x,y,z) with y(a)=α, z(a)=sy(a)=\alpha,\ z(a)=s and integrate from aa to bb by RK4.
  4. Compute ϕ(s0)=y(b;s0)−β\phi(s_0)=y(b;s_0)-\beta and ϕ(s1)=y(b;s1)−β\phi(s_1)=y(b;s_1)-\beta.
  5. Compute the new slope s2s_2 by the secant formula; integrate again to get ϕ(s2)\phi(s_2).
  6. If ∣ϕ(s2)∣<ε|\phi(s_2)|<\varepsilon, stop and output the solution; otherwise set s0=s1, s1=s2s_0=s_1,\ s_1=s_2 and repeat step 5.

Program (C): solves y′′=−yy''=-y, y(0)=0y(0)=0, y(1)=1y(1)=1 (exact solution y=sin⁡x/sin⁡1y=\sin x/\sin 1).

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

/* system: y' = z, z' = g(x,y,z) */
double g(double x, double y, double z) { return -y; }

/* integrate from a to b with n steps; return y(b); print table if pr */
double shoot(double a, double b, double alpha, double s, int n, int pr) {
    double h = (b - a) / n, x = a, y = alpha, z = s;
    double k1, k2, k3, k4, l1, l2, l3, l4;
    int i;
    for (i = 0; i < n; i++) {
        k1 = h * z;               l1 = h * g(x, y, z);
        k2 = h * (z + l1 / 2);    l2 = h * g(x + h / 2, y + k1 / 2, z + l1 / 2);
        k3 = h * (z + l2 / 2);    l3 = h * g(x + h / 2, y + k2 / 2, z + l2 / 2);
        k4 = h * (z + l3);        l4 = h * g(x + h, y + k3, z + l3);
        y += (k1 + 2 * k2 + 2 * k3 + k4) / 6;
        z += (l1 + 2 * l2 + 2 * l3 + l4) / 6;
        x += h;
        if (pr) printf("x = %.3f   y = %.6f\n", x, y);
    }
    return y;
}

int main() {
    double a = 0, b = 1, alpha = 0, beta = 1, eps = 1e-8;
    double s0 = 0.5, s1 = 1.5, f0, f1, s2;
    int n = 10, it;

    f0 = shoot(a, b, alpha, s0, n, 0) - beta;
    for (it = 0; it < 50; it++) {
        f1 = shoot(a, b, alpha, s1, n, 0) - beta;
        if (fabs(f1) < eps) break;
        s2 = s1 - f1 * (s1 - s0) / (f1 - f0);
        s0 = s1; f0 = f1; s1 = s2;
    }
    printf("Required slope y'(a) = %.6f\n", s1);
    shoot(a, b, alpha, s1, n, 1);
    return 0;
}

The program finds the slope y′(0)=1/sin⁡1≈1.1884y'(0)=1/\sin 1\approx1.1884 and prints the solution at each grid point, ending with y(1)=1y(1)=1.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2075 · 8 marks

Calculate a real negative root of following equation using Newton’s method for polynomial. x4+2x3+3x2+4x=5x^4 + 2x^3 + 3x^2 + 4x = 5

Answer

Let p(x)=x4+2x3+3x2+4x−5p(x)=x^4+2x^3+3x^2+4x-5. For a polynomial, Newton's method xn+1=xn−p(xn)/p′(xn)x_{n+1}=x_n-p(x_n)/p'(x_n) is carried out with synthetic division (Horner's scheme): dividing p(x)p(x) by (x−xn)(x-x_n) gives the remainder b4=p(xn)b_4=p(x_n); dividing the quotient again by (x−xn)(x-x_n) gives the remainder c3=p′(xn)c_3=p'(x_n).

Locating the root. p(−2)=16−16+12−8−5=−1p(-2)=16-16+12-8-5=-1 and p(−3)=81−54+27−12−5=37p(-3)=81-54+27-12-5=37. The sign change shows a negative root between −3-3 and −2-2, close to −2-2. Take x0=−2x_0=-2.

Iteration 1, x0=−2x_0=-2:

First synthetic division (coefficients 1, 2, 3, 4, −51,\ 2,\ 3,\ 4,\ -5):

  • b0=1b_0=1
  • b1=2+(1)(−2)=0b_1=2+(1)(-2)=0
  • b2=3+(0)(−2)=3b_2=3+(0)(-2)=3
  • b3=4+(3)(−2)=−2b_3=4+(3)(-2)=-2
  • b4=−5+(−2)(−2)=−1=p(x0)b_4=-5+(-2)(-2)=-1=p(x_0)

Second division on 1, 0, 3, −21,\ 0,\ 3,\ -2:

  • c0=1c_0=1
  • c1=0+(1)(−2)=−2c_1=0+(1)(-2)=-2
  • c2=3+(−2)(−2)=7c_2=3+(-2)(-2)=7
  • c3=−2+(7)(−2)=−16=p′(x0)c_3=-2+(7)(-2)=-16=p'(x_0)

x1=−2−−1−16=−2.0625x_1=-2-\frac{-1}{-16}=-2.0625

Iteration 2, x1=−2.0625x_1=-2.0625: b=1, −0.0625, 3.1289, −2.4534, 0.06007b=1,\ -0.0625,\ 3.1289,\ -2.4534,\ 0.06007 so p=0.06007p=0.06007; c=1, −2.125, 7.5117, −17.9462c=1,\ -2.125,\ 7.5117,\ -17.9462 so p′=−17.9462p'=-17.9462. x2=−2.0625−0.06007−17.9462=−2.05915x_2=-2.0625-\frac{0.06007}{-17.9462}=-2.05915

Iteration 3, x2=−2.05915x_2=-2.05915: p=0.000181p=0.000181, p′=−17.8384p'=-17.8384. x3=−2.05915−0.000181−17.8384=−2.05914x_3=-2.05915-\frac{0.000181}{-17.8384}=-2.05914

nxnx_np(xn)p(x_n)p′(xn)p'(x_n)xn+1x_{n+1}
0-2-1-16-2.0625
1-2.06250.06007-17.9462-2.05915
2-2.059150.000181-17.8384-2.05914

The values have converged to five decimals, so the real negative root is x≈−2.0591x\approx-2.0591

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2075 · 8 marks

What is least squares approximation of fitting a function? How does it differ with polynomial interpolation? Explain with suitable example.

Answer

Least squares approximation. Given nn data points (xi,yi)(x_i,y_i) that usually contain measurement errors, we seek a simple function ϕ(x)\phi(x) of a chosen form (line, parabola, exponential, etc.) that fits the trend of the data. The parameters are chosen to minimise the sum of squared residuals S=∑i=1n(yi−ϕ(xi))2S=\sum_{i=1}^{n}\big(y_i-\phi(x_i)\big)^2

For the straight line y=a+bxy=a+bx, setting ∂S/∂a=0\partial S/\partial a=0 and ∂S/∂b=0\partial S/\partial b=0 gives the normal equations ∑y=na+b∑x,∑xy=a∑x+b∑x2\sum y=na+b\sum x,\qquad \sum xy=a\sum x+b\sum x^2 For a polynomial of degree mm there are m+1m+1 normal equations ∑xky=∑j=0maj∑xk+j\sum x^k y=\sum_{j=0}^{m} a_j\sum x^{k+j}.

Difference from polynomial interpolation.

Least squares fittingPolynomial interpolation
Curve need not pass through the points; it follows the overall trendCurve passes exactly through every given point
Low-degree function, independent of the number of pointsDegree is n−1n-1 for nn points
Suitable for noisy experimental dataSuitable for exact (tabulated) data
Minimises the sum of squared errorsError at the nodes is zero
Stable; smoothHigh degree gives wild oscillations between nodes

Example. Data: (1,2), (2,3), (3,5), (4,4)(1,2),\ (2,3),\ (3,5),\ (4,4).

n=4, ∑x=10, ∑y=14, ∑x2=30, ∑xy=2+6+15+16=39n=4,\ \sum x=10,\ \sum y=14,\ \sum x^2=30,\ \sum xy=2+6+15+16=39.

b=n∑xy−∑x∑yn∑x2−(∑x)2=4(39)−10(14)4(30)−100=1620=0.8b=\frac{n\sum xy-\sum x\sum y}{n\sum x^2-(\sum x)^2}=\frac{4(39)-10(14)}{4(30)-100}=\frac{16}{20}=0.8 a=∑y−b∑xn=14−84=1.5a=\frac{\sum y-b\sum x}{n}=\frac{14-8}{4}=1.5

The least squares line is y=1.5+0.8xy=1.5+0.8x. Its values at x=1,2,3,4x=1,2,3,4 are 2.3, 3.1, 3.9, 4.72.3,\ 3.1,\ 3.9,\ 4.7, with residuals −0.3, −0.1, 1.1, −0.7-0.3,\ -0.1,\ 1.1,\ -0.7 and S=0.09+0.01+1.21+0.49=1.8S=0.09+0.01+1.21+0.49=1.8. The line does not pass through any point exactly, but it is the best straight line in the least squares sense.

Interpolation through the same four points needs a cubic polynomial; it passes through all points with zero error at the nodes, but it is a more complicated curve and follows the scatter (including the error) of the data rather than the trend.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2075 · 8 marks

Find the lowest degree polynomial, which passes through the following points:
X-2-11234
F(x)-1902-3-45
Using this polynomial estimate f(x) at x = 0

Answer

The points are not equally spaced, so Newton's divided difference form is used.

xxff1st2nd3rd4th5th
-2-19
19
-10-6
11
12-20
-510
2-320
-11
3-45
9
45

Sample calculations:

  • f[−2,−1]=0+191=19f[-2,-1]=\dfrac{0+19}{1}=19, f[−1,1]=2−02=1f[-1,1]=\dfrac{2-0}{2}=1, f[1,2]=−5f[1,2]=-5, f[2,3]=−1f[2,3]=-1, f[3,4]=9f[3,4]=9
  • f[−2,−1,1]=1−193=−6f[-2,-1,1]=\dfrac{1-19}{3}=-6, f[−1,1,2]=−5−13=−2f[-1,1,2]=\dfrac{-5-1}{3}=-2, f[1,2,3]=−1+52=2f[1,2,3]=\dfrac{-1+5}{2}=2, f[2,3,4]=9+12=5f[2,3,4]=\dfrac{9+1}{2}=5
  • f[−2,−1,1,2]=−2+64=1f[-2,-1,1,2]=\dfrac{-2+6}{4}=1, f[−1,1,2,3]=2+24=1f[-1,1,2,3]=\dfrac{2+2}{4}=1, f[1,2,3,4]=5−23=1f[1,2,3,4]=\dfrac{5-2}{3}=1

The third divided differences are all equal to 11, so the fourth and fifth differences are zero. The data therefore belong to a polynomial of degree 33, which is the lowest degree polynomial through the points.

f(x)=−19+19(x+2)−6(x+2)(x+1)+1 (x+2)(x+1)(x−1)f(x)=-19+19(x+2)-6(x+2)(x+1)+1\,(x+2)(x+1)(x-1)

Expanding:

  • 19(x+2)=19x+3819(x+2)=19x+38
  • −6(x+2)(x+1)=−6x2−18x−12-6(x+2)(x+1)=-6x^2-18x-12
  • (x+2)(x+1)(x−1)=x3+2x2−x−2(x+2)(x+1)(x-1)=x^3+2x^2-x-2

Sum: x3+(−6+2)x2+(19−18−1)x+(−19+38−12−2)x^3+(-6+2)x^2+(19-18-1)x+(-19+38-12-2) f(x)=x3−4x2+5\boxed{f(x)=x^3-4x^2+5}

Check: f(−2)=−8−16+5=−19f(-2)=-8-16+5=-19, f(2)=8−16+5=−3f(2)=8-16+5=-3, f(4)=64−64+5=5f(4)=64-64+5=5. All agree.

Estimate at x = 0: f(0)=5f(0)=5

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2075 · 8 marks

The fit function of type y = a + bx for the following points using the least square method.
X-11.222.73.64
F(x)12027334145

Answer

For y=a+bxy=a+bx the normal equations are ∑y=na+b∑x,∑xy=a∑x+b∑x2\sum y=na+b\sum x,\qquad \sum xy=a\sum x+b\sum x^2

xxyyx2x^2xyxy
-111-1
1.2201.4424
227454
2.7337.2989.1
3.64112.96147.6
44516180
12.516742.69493.7

with n=6n=6.

The normal equations become 6a+12.5b=1676a+12.5b=167 12.5a+42.69b=493.712.5a+42.69b=493.7

Using the formulas: b=n∑xy−∑x∑yn∑x2−(∑x)2=6(493.7)−12.5(167)6(42.69)−156.25=2962.2−2087.5256.14−156.25=874.799.89=8.7566b=\frac{n\sum xy-\sum x\sum y}{n\sum x^2-(\sum x)^2}=\frac{6(493.7)-12.5(167)}{6(42.69)-156.25}=\frac{2962.2-2087.5}{256.14-156.25}=\frac{874.7}{99.89}=8.7566 a=167−8.7566(12.5)6=167−109.4586=9.5903a=\frac{167-8.7566(12.5)}{6}=\frac{167-109.458}{6}=9.5903

The fitted line is y≈9.590+8.757 x\boxed{y\approx 9.590+8.757\,x}

Check: first equation 6(9.5903)+12.5(8.7566)=57.54+109.46=167.06(9.5903)+12.5(8.7566)=57.54+109.46=167.0. Second: 12.5(9.5903)+42.69(8.7566)=119.88+373.82=493.712.5(9.5903)+42.69(8.7566)=119.88+373.82=493.7. Both are satisfied.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2075 · 8 marks

Calculate the integral value of the function given below from x = 1.8 to x = 3.4 using Simpson’s 1/3 rule.
X1.82.02.22.42.62.83.03.4
F(x)0.0030.7781.6322.5663.5794.6727.0978.429

Answer

Simpson's 1/3 rule needs an even number of equal sub-intervals. The table has equal spacing h=0.2h=0.2 from x=1.8x=1.8 to x=3.0x=3.0 (6 intervals, 7 points), but the last interval, from 3.03.0 to 3.43.4, has width 0.40.4. Hence Simpson's 1/3 rule is applied on [1.8, 3.0][1.8,\,3.0] and the remaining strip [3.0, 3.4][3.0,\,3.4] is handled separately with the trapezoidal rule.

Part 1: [1.8, 3.0], h = 0.2 I1=h3[f0+4(f1+f3+f5)+2(f2+f4)+f6]I_1=\frac h3\Big[f_0+4(f_1+f_3+f_5)+2(f_2+f_4)+f_6\Big]

  • f0=0.003f_0=0.003, f6=7.097f_6=7.097
  • Odd terms: f1+f3+f5=0.778+2.566+4.672=8.016f_1+f_3+f_5=0.778+2.566+4.672=8.016, so 4(8.016)=32.0644(8.016)=32.064
  • Even terms: f2+f4=1.632+3.579=5.211f_2+f_4=1.632+3.579=5.211, so 2(5.211)=10.4222(5.211)=10.422

I1=0.23 [0.003+32.064+10.422+7.097]=0.23(49.586)=3.3057I_1=\frac{0.2}{3}\,[0.003+32.064+10.422+7.097]=\frac{0.2}{3}(49.586)=3.3057

Part 2: [3.0, 3.4], width 0.4 (only the two end values are available) I2=0.42(7.097+8.429)=0.2(15.526)=3.1052I_2=\frac{0.4}{2}(7.097+8.429)=0.2(15.526)=3.1052

Total I=I1+I2=3.3057+3.1052≈6.411I=I_1+I_2=3.3057+3.1052\approx 6.411

So ∫1.83.4f(x) dx≈6.41\displaystyle\int_{1.8}^{3.4}f(x)\,dx\approx 6.41.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2075 · 8 marks

From the following differential equation estimate y(1) using RK 4^th order method. dydx+2x2y=4withy(0)=1\frac{dy}{dx} + 2x^2y = 4 \enspace with \enspace y(0) = 1 [Take h = 0.5]

Answer

Write the equation as y′=f(x,y)=4−2x2yy'=f(x,y)=4-2x^2y, y(0)=1y(0)=1, h=0.5h=0.5. Two steps are needed to reach x=1x=1.

RK4 formulas: k1=f(xn,yn), k2=f ⁣(xn+h2, yn+h2k1), k3=f ⁣(xn+h2, yn+h2k2), k4=f(xn+h, yn+hk3)k_1=f(x_n,y_n),\ k_2=f\!\left(x_n+\tfrac h2,\,y_n+\tfrac h2k_1\right),\ k_3=f\!\left(x_n+\tfrac h2,\,y_n+\tfrac h2k_2\right),\ k_4=f(x_n+h,\,y_n+hk_3) yn+1=yn+h6 (k1+2k2+2k3+k4)y_{n+1}=y_n+\frac h6\,(k_1+2k_2+2k_3+k_4)

Step 1: x0=0, y0=1x_0=0,\ y_0=1

  • k1=4−0=4k_1=4-0=4
  • k2=f(0.25, 1+0.25⋅4=2)=4−2(0.0625)(2)=3.75k_2=f(0.25,\,1+0.25\cdot4=2)=4-2(0.0625)(2)=3.75
  • k3=f(0.25, 1+0.25⋅3.75=1.9375)=4−0.125(1.9375)=3.757813k_3=f(0.25,\,1+0.25\cdot3.75=1.9375)=4-0.125(1.9375)=3.757813
  • k4=f(0.5, 1+0.5⋅3.757813=2.878906)=4−0.5(2.878906)=2.560547k_4=f(0.5,\,1+0.5\cdot3.757813=2.878906)=4-0.5(2.878906)=2.560547

y1=1+0.56 [4+7.5+7.515625+2.560547]=1+0.083333(21.576172)=2.798014y_1=1+\frac{0.5}{6}\,[4+7.5+7.515625+2.560547]=1+0.083333(21.576172)=2.798014

Step 2: x1=0.5, y1=2.798014x_1=0.5,\ y_1=2.798014

  • k1=4−2(0.25)(2.798014)=2.600993k_1=4-2(0.25)(2.798014)=2.600993
  • k2=f(0.75, 2.798014+0.25⋅2.600993=3.448262)=4−1.125(3.448262)=0.120705k_2=f(0.75,\,2.798014+0.25\cdot2.600993=3.448262)=4-1.125(3.448262)=0.120705
  • k3=f(0.75, 2.798014+0.25⋅0.120705=2.828190)=4−1.125(2.828190)=0.818286k_3=f(0.75,\,2.798014+0.25\cdot0.120705=2.828190)=4-1.125(2.828190)=0.818286
  • k4=f(1, 2.798014+0.5⋅0.818286=3.207157)=4−2(3.207157)=−2.414314k_4=f(1,\,2.798014+0.5\cdot0.818286=3.207157)=4-2(3.207157)=-2.414314

y2=2.798014+0.56 [2.600993+0.241410+1.636572−2.414314]=2.798014+0.083333(2.064661)=2.970069y_2=2.798014+\frac{0.5}{6}\,[2.600993+0.241410+1.636572-2.414314]=2.798014+0.083333(2.064661)=2.970069

y(1)≈2.9701\boxed{y(1)\approx 2.9701}

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2077 · 2 marks

Derive the formula for Newton Raphson Method. Solve the equation x2+4x–9=0x^2 + 4x – 9 = 0 using Newton Raphson method. Assume error precision is 0.01. Discuss drawbacks of the Newton Raphson method.

Answer

Derivation. Let xnx_n be an approximation of a root of f(x)=0f(x)=0. Expand ff about xnx_n by Taylor's series: f(xn+δ)=f(xn)+δf′(xn)+δ22!f′′(xn)+⋯f(x_n+\delta)=f(x_n)+\delta f'(x_n)+\frac{\delta^2}{2!}f''(x_n)+\cdots If xn+δx_n+\delta is the root, then f(xn+δ)=0f(x_n+\delta)=0. Neglecting terms of order δ2\delta^2 and higher: f(xn)+δf′(xn)≈0 ⇒ δ=−f(xn)f′(xn)f(x_n)+\delta f'(x_n)\approx0\ \Rightarrow\ \delta=-\frac{f(x_n)}{f'(x_n)} xn+1=xn−f(xn)f′(xn),f′(xn)≠0\boxed{x_{n+1}=x_n-\frac{f(x_n)}{f'(x_n)},\quad f'(x_n)\ne0}

Geometrically, xn+1x_{n+1} is where the tangent to y=f(x)y=f(x) at (xn,f(xn))(x_n,f(x_n)) cuts the xx-axis. Convergence is quadratic near a simple root.

Solving f(x)=x2+4x−9=0f(x)=x^2+4x-9=0, f′(x)=2x+4f'(x)=2x+4.

f(1)=−4f(1)=-4, f(2)=3f(2)=3, so a root lies in (1,2)(1,2). Take x0=2x_0=2.

nxnx_nf(xn)f(x_n)f′(xn)f'(x_n)xn+1x_{n+1}∣xn+1−xn∣\lvert x_{n+1}-x_n\rvert
02381.62500.3750
11.62500.14067.25001.60560.0194
21.60560.0003767.21121.605550.00005

At the third iteration the change is 0.00005<0.010.00005<0.01, so the iteration stops: x≈1.6056x\approx1.6056 (The exact root is −2+13=1.60555-2+\sqrt{13}=1.60555.)

Drawbacks of Newton-Raphson method

  1. It needs the derivative f′(x)f'(x) at each step, which may be difficult or costly to compute.
  2. If f′(xn)=0f'(x_n)=0 or is very small (near a stationary point), the next step is undefined or flies far away.
  3. It needs a good initial guess; a poor guess can diverge or jump to a different root, and the method can cycle or oscillate (for example on x3−2x+2x^3-2x+2 from x0=0x_0=0).
  4. Convergence is only linear at a multiple root.
  5. It does not guarantee convergence (unlike bisection) and gives no bracketing of the root.
  6. Each iteration evaluates two functions (ff and f′f').

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2077 · 2 marks

How interpolation differs from regression? Write down algorithm and program for Lagrange interpolation.

Answer

Interpolation vs regression

InterpolationRegression (curve fitting)
The curve passes exactly through all given data pointsThe curve passes near the points; it need not touch any of them
Used when data are exact (tables of function values)Used when data contain errors or noise (experiments)
Degree of polynomial is tied to the number of points (n−1n-1 for nn points)Form of the function is chosen independently (line, exponential, etc.)
Aim: estimate values between known pointsAim: find the trend/relation between variables
Error at the nodes is zeroMinimises the sum of squared errors (least squares)

Lagrange interpolation. For n+1n+1 points (x0,y0),…,(xn,yn)(x_0,y_0),\dots,(x_n,y_n): P(x)=∑i=0nyi Li(x),Li(x)=∏j=0j≠inx−xjxi−xjP(x)=\sum_{i=0}^{n}y_i\,L_i(x),\qquad L_i(x)=\prod_{\substack{j=0\\ j\ne i}}^{n}\frac{x-x_j}{x_i-x_j} Each Li(xk)=1L_i(x_k)=1 if k=ik=i and 00 otherwise, so P(xi)=yiP(x_i)=y_i.

Algorithm

  1. Read nn, the data points xi,yix_i,y_i (i=0..n−1i=0..n-1) and the value xx at which ff is wanted.
  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, j≠ij\ne i: term=term×x−xjxi−xjterm=term\times\dfrac{x-x_j}{x_i-x_j}; then sum=sum+termsum=sum+term.
  4. Print sumsum as f(x)f(x).

Program (C)

#include <stdio.h>

int main() {
    int n, i, j;
    float x[20], y[20], xp, term, sum = 0;

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

    for (i = 0; i < n; i++) {
        term = y[i];
        for (j = 0; j < n; j++)
            if (j != i)
                term = term * (xp - x[j]) / (x[i] - x[j]);
        sum = sum + term;
    }
    printf("f(%.3f) = %.4f\n", xp, sum);
    return 0;
}

Example: for the points (0,1),(1,3),(2,7)(0,1),(1,3),(2,7) and x=1.5x=1.5, the program gives f(1.5)=4.75f(1.5)=4.75, which is the value of x2+x+1x^2+x+1 at 1.51.5.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2077 · 2 marks

Why partial pivoting is used with Naive Gauss Elimination method? Solve the following system of equations using Gauss Elimination method with partial pivoting? How Gauss Jordan method differs from Gauss elimination method? 2x + 2y – z = 6 4x + 2y + 3z = 4 x + y + z = 0

Answer

Why partial pivoting is used. In naive Gauss elimination the pivot element akka_{kk} is used as the divisor to form the multipliers mik=aik/akkm_{ik}=a_{ik}/a_{kk}. If the pivot is zero the method breaks down, and if it is very small compared with other elements in the column, the multipliers become huge and round-off errors are magnified, giving inaccurate results. In partial pivoting, before eliminating column kk, the row having the largest absolute value in that column (from row kk downward) is swapped into the pivot position. This keeps all multipliers ≤1\le1, avoids division by zero and improves numerical stability.

Solution. Augmented matrix: [22−1642341110]\left[\begin{array}{ccc|c}2&2&-1&6\\4&2&3&4\\1&1&1&0\end{array}\right]

Column 1: the largest element is 44 (row 2). Swap R1↔R2R_1\leftrightarrow R_2: [423422−161110]\left[\begin{array}{ccc|c}4&2&3&4\\2&2&-1&6\\1&1&1&0\end{array}\right]

R2→R2−24R1R_2\to R_2-\tfrac24R_1 and R3→R3−14R1R_3\to R_3-\tfrac14R_1: [423401−2.5400.50.25−1]\left[\begin{array}{ccc|c}4&2&3&4\\0&1&-2.5&4\\0&0.5&0.25&-1\end{array}\right]

Column 2: compare ∣1∣|1| and ∣0.5∣|0.5|; the pivot 11 is already largest, so no swap. R3→R3−0.5R2R_3\to R_3-0.5R_2: [423401−2.54001.5−3]\left[\begin{array}{ccc|c}4&2&3&4\\0&1&-2.5&4\\0&0&1.5&-3\end{array}\right]

Back substitution:

  • 1.5z=−3⇒z=−21.5z=-3\Rightarrow z=-2
  • y−2.5z=4⇒y=4+2.5(−2)=−1y-2.5z=4\Rightarrow y=4+2.5(-2)=-1
  • 4x+2y+3z=4⇒4x=4+2+6=12⇒x=34x+2y+3z=4\Rightarrow 4x=4+2+6=12\Rightarrow x=3

x=3,y=−1,z=−2x=3,\quad y=-1,\quad z=-2

Check in the first equation: 2(3)+2(−1)−(−2)=62(3)+2(-1)-(-2)=6. In the third: 3−1−2=03-1-2=0.

Gauss-Jordan vs Gauss elimination

Gauss eliminationGauss-Jordan
Reduces the matrix to upper triangular formReduces the matrix to diagonal (identity) form
Eliminates entries only below the pivotEliminates entries above and below the pivot
Solution found by back substitutionSolution read directly; no back substitution
About n3/3n^3/3 operationsAbout n3/2n^3/2 operations (more work)
Preferred for solving a single systemConvenient for matrix inversion

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2077 · 8 marks

Define the terms true error and relative error? Use Horner’ method to evaluate polynomial 2x3–3x2+5x–22x^3 – 3x^2 + 5x – 2 at x = 3 and write down its algorithm.

Answer

True error. If xtx_t is the exact (true) value and xax_a the approximate value, the true error is Et=xt−xaE_t=x_t-x_a

Relative error. The true error expressed as a fraction of the true value: Er=xt−xaxt(relative percentage error=xt−xaxt×100%)E_r=\frac{x_t-x_a}{x_t}\qquad\left(\text{relative percentage error}=\frac{x_t-x_a}{x_t}\times100\%\right)

For example, if xt=3.1416x_t=3.1416 and xa=3.14x_a=3.14, then Et=0.0016E_t=0.0016 and Er=0.0016/3.1416=5.09×10−4E_r=0.0016/3.1416=5.09\times10^{-4}.

Horner's method. A polynomial p(x)=anxn+⋯+a1x+a0p(x)=a_nx^n+\dots+a_1x+a_0 is written in nested form so that it needs only nn multiplications and nn additions: p(x)=(⋯((anx+an−1)x+an−2)x+⋯+a1)x+a0p(x)=(\cdots((a_nx+a_{n-1})x+a_{n-2})x+\cdots+a_1)x+a_0

Evaluation of p(x)=2x3−3x2+5x−2p(x)=2x^3-3x^2+5x-2 at x=3x=3. Nested form: p(x)=((2x−3)x+5)x−2p(x)=((2x-3)x+5)x-2.

Synthetic table (coefficients 2, −3, 5, −22,\,-3,\,5,\,-2):

2-35-2
x=3x=36942
231440
  • b3=2b_3=2
  • b2=−3+3(2)=3b_2=-3+3(2)=3
  • b1=5+3(3)=14b_1=5+3(3)=14
  • b0=−2+3(14)=40b_0=-2+3(14)=40

p(3)=40p(3)=40

Check by direct substitution: 2(27)−3(9)+5(3)−2=54−27+15−2=402(27)-3(9)+5(3)-2=54-27+15-2=40.

Algorithm

  1. Read the degree nn, the coefficients an,an−1,…,a0a_n,a_{n-1},\dots,a_0 and the point xx.
  2. Set b=anb=a_n.
  3. For i=n−1i=n-1 down to 00: b=b×x+aib=b\times x+a_i.
  4. Print bb as p(x)p(x).

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2077 · 8 marks

Fit the curve y=aebxy = ae^{bx} through the following data points.
x1234
y1.652.704.507.35

Answer

Take natural logarithms to linearise y=aebxy=ae^{bx}: 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 is a straight line. Its normal equations are ∑Y=nA+b∑x,∑xY=A∑x+b∑x2\sum Y=nA+b\sum x,\qquad \sum xY=A\sum x+b\sum x^2

xxyyY=ln⁡yY=\ln yx2x^2xYxY
11.650.5007810.50078
22.700.9932541.98650
34.501.5040894.51223
47.351.99470167.97880
104.992813014.97831

with n=4n=4.

4A+10b=4.99281,10A+30b=14.978314A+10b=4.99281,\qquad 10A+30b=14.97831

b=n∑xY−∑x∑Yn∑x2−(∑x)2=4(14.97831)−10(4.99281)4(30)−100=59.91324−49.928120=0.49926b=\frac{n\sum xY-\sum x\sum Y}{n\sum x^2-(\sum x)^2}=\frac{4(14.97831)-10(4.99281)}{4(30)-100}=\frac{59.91324-49.9281}{20}=0.49926 A=4.99281−10(0.49926)4=0.000214≈0.00005A=\frac{4.99281-10(0.49926)}{4}=\frac{0.00021}{4}\approx0.00005 a=eA=e0.00005≈1.0001a=e^{A}=e^{0.00005}\approx1.0001

Hence y≈1.0001 e0.4993x ≈ e0.5x\boxed{y\approx1.0001\,e^{0.4993x}\ \approx\ e^{0.5x}}

Check: at x=3x=3, e0.4993×3=e1.4978=4.47e^{0.4993\times3}=e^{1.4978}=4.47 (data 4.50); at x=4x=4, e1.9970=7.37e^{1.9970}=7.37 (data 7.35).

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2077 · 8 marks

Discuss the Doolittle LU decomposition method for matrix factorization.

Answer

Idea. LU decomposition factors a square matrix AA (when no row interchange is needed) as A=LUA=LU where LL is lower triangular and UU is upper triangular. In the Doolittle method the diagonal of LL is made 11: L=[100l2110l31l321],U=[u11u12u130u22u2300u33]L=\begin{bmatrix}1&0&0\\l_{21}&1&0\\l_{31}&l_{32}&1\end{bmatrix},\qquad U=\begin{bmatrix}u_{11}&u_{12}&u_{13}\\0&u_{22}&u_{23}\\0&0&u_{33}\end{bmatrix}

Formulas. Multiplying LULU and equating with AA gives, for i=1,…,ni=1,\dots,n: uij=aij−∑k=1i−1likukj,j=i,i+1,…,nu_{ij}=a_{ij}-\sum_{k=1}^{i-1}l_{ik}u_{kj},\qquad j=i,i+1,\dots,n lji=1uii(aji−∑k=1i−1ljkuki),j=i+1,…,nl_{ji}=\frac{1}{u_{ii}}\left(a_{ji}-\sum_{k=1}^{i-1}l_{jk}u_{ki}\right),\qquad j=i+1,\dots,n That is, alternately a row of UU and then a column of LL are computed. The requirement is uii≠0u_{ii}\ne0 (all leading principal minors non-zero); otherwise pivoting is needed.

Solving Ax=bAx=b. Since LUx=bLUx=b, put Ux=yUx=y.

  1. Forward substitution: Ly=bLy=b, yi=bi−∑k<ilikyky_i=b_i-\sum_{k<i}l_{ik}y_k.
  2. Back substitution: Ux=yUx=y, xi=1uii(yi−∑k>iuikxk)x_i=\dfrac{1}{u_{ii}}\Big(y_i-\sum_{k>i}u_{ik}x_k\Big).

Example. A=[211433879]A=\begin{bmatrix}2&1&1\\4&3&3\\8&7&9\end{bmatrix}

  • Row 1 of UU: 2, 1, 12,\ 1,\ 1
  • Column 1 of LL: l21=4/2=2, l31=8/2=4l_{21}=4/2=2,\ l_{31}=8/2=4
  • Row 2 of UU: u22=3−2(1)=1, u23=3−2(1)=1u_{22}=3-2(1)=1,\ u_{23}=3-2(1)=1
  • l32=7−4(1)1=3l_{32}=\dfrac{7-4(1)}{1}=3
  • u33=9−4(1)−3(1)=2u_{33}=9-4(1)-3(1)=2

L=[100210431],U=[211011002]L=\begin{bmatrix}1&0&0\\2&1&0\\4&3&1\end{bmatrix},\qquad U=\begin{bmatrix}2&1&1\\0&1&1\\0&0&2\end{bmatrix} Check: third row of LULU is 4(2,1,1)+3(0,1,1)+(0,0,2)=(8,7,9)4(2,1,1)+3(0,1,1)+(0,0,2)=(8,7,9).

Advantages

  • Once AA is factored, many right-hand sides bb can be solved cheaply (O(n2)O(n^2) each).
  • Determinant: det⁡A=u11u22⋯unn\det A=u_{11}u_{22}\cdots u_{nn}.
  • Factoring costs about n3/3n^3/3 multiplications, the same as Gauss elimination, and the multipliers are stored in LL.

Compared with Crout: Crout puts the unit diagonal in UU instead of LL.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2077 · 8 marks

Write down algorithm and program for the differentiating continuous function using three point formula.

Answer

Three-point formulas. Differentiate the quadratic through three equally spaced points (spacing hh).

  • Forward (at x0x_0, using x0,x1,x2x_0,x_1,x_2): f′(x0)≈−3f(x0)+4f(x0+h)−f(x0+2h)2h\displaystyle f'(x_0)\approx\frac{-3f(x_0)+4f(x_0+h)-f(x_0+2h)}{2h}
  • Central (at x0x_0, using x0−h, x0, x0+hx_0-h,\,x_0,\,x_0+h): f′(x0)≈f(x0+h)−f(x0−h)2h\displaystyle f'(x_0)\approx\frac{f(x_0+h)-f(x_0-h)}{2h}
  • Backward (at x0x_0, using x0−2h, x0−h, x0x_0-2h,\,x_0-h,\,x_0): f′(x0)≈3f(x0)−4f(x0−h)+f(x0−2h)2h\displaystyle f'(x_0)\approx\frac{3f(x_0)-4f(x_0-h)+f(x_0-2h)}{2h}

Each has error of order h2h^2.

Algorithm

  1. Define the function f(x)f(x).
  2. Read the point x0x_0 and step size hh.
  3. Compute f(x0−2h), f(x0−h), f(x0), f(x0+h), f(x0+2h)f(x_0-2h),\,f(x_0-h),\,f(x_0),\,f(x_0+h),\,f(x_0+2h).
  4. Compute the forward, central and backward estimates from the above formulas.
  5. Print the results.

Program (C): differentiates f(x)=sin⁡xf(x)=\sin x (exact derivative cos⁡x\cos x) at a given point.

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

double f(double x) { return sin(x); }

int main() {
    double x0, h, fwd, cen, bwd;

    printf("Enter the point x0 and step size h: ");
    scanf("%lf %lf", &x0, &h);

    fwd = (-3 * f(x0) + 4 * f(x0 + h) - f(x0 + 2 * h)) / (2 * h);
    cen = (f(x0 + h) - f(x0 - h)) / (2 * h);
    bwd = (3 * f(x0) - 4 * f(x0 - h) + f(x0 - 2 * h)) / (2 * h);

    printf("Forward  three-point: f'(%.3f) = %.6f\n", x0, fwd);
    printf("Central  three-point: f'(%.3f) = %.6f\n", x0, cen);
    printf("Backward three-point: f'(%.3f) = %.6f\n", x0, bwd);
    printf("Exact value         : %.6f\n", cos(x0));
    return 0;
}

For x0=1x_0=1, h=0.1h=0.1 the central formula gives 0.53940.5394 against the exact cos⁡1=0.5403\cos1=0.5403.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2077 · 8 marks

How Simpson’s 1/3 rule differs from Trapezoidal rule? Drive the formula for Simson’s 1/3 rule.

Answer

Difference between the two rules

Trapezoidal ruleSimpson's 1/3 rule
Replaces ff on each sub-interval by a straight line (degree 1)Replaces ff on each pair of sub-intervals by a parabola (degree 2)
Works with any number of intervalsNeeds an even number of intervals
Formula: h2[f0+2(f1+⋯+fn−1)+fn]\frac h2[f_0+2(f_1+\dots+f_{n-1})+f_n]Formula: h3[f0+4(f1+f3+… )+2(f2+f4+… )+fn]\frac h3[f_0+4(f_1+f_3+\dots)+2(f_2+f_4+\dots)+f_n]
Error −(b−a)12h2f′′(ξ)-\frac{(b-a)}{12}h^2f''(\xi), order h2h^2Error −(b−a)180h4f(4)(ξ)-\frac{(b-a)}{180}h^4f^{(4)}(\xi), order h4h^4
Exact for linear functionsExact for polynomials up to degree 3
Less accurateMore accurate for the same hh

Derivation of Simpson's 1/3 rule. Take three equally spaced points x0, x1=x0+h, x2=x0+2hx_0,\ x_1=x_0+h,\ x_2=x_0+2h with values f0,f1,f2f_0,f_1,f_2. Fit the Newton forward polynomial through them, with p=(x−x0)/hp=(x-x_0)/h, dx=h dpdx=h\,dp: f(x)≈f0+p Δf0+p(p−1)2Δ2f0f(x)\approx f_0+p\,\Delta f_0+\frac{p(p-1)}{2}\Delta^2f_0

Integrate from x0x_0 to x2x_2, i.e. p=0p=0 to 22: ∫x0x2f(x) dx=h∫02[f0+p Δf0+p2−p2Δ2f0]dp\int_{x_0}^{x_2}f(x)\,dx=h\int_0^2\left[f_0+p\,\Delta f_0+\frac{p^2-p}{2}\Delta^2f_0\right]dp

Evaluate each integral:

  • ∫02dp=2\int_0^2dp=2
  • ∫02p dp=2\int_0^2p\,dp=2
  • ∫02p2−p2dp=12[83−2]=13\int_0^2\frac{p^2-p}{2}dp=\frac12\left[\frac{8}{3}-2\right]=\frac13

=h[2f0+2Δf0+13Δ2f0]=h\left[2f_0+2\Delta f_0+\frac13\Delta^2f_0\right]

Substitute Δf0=f1−f0\Delta f_0=f_1-f_0 and Δ2f0=f2−2f1+f0\Delta^2f_0=f_2-2f_1+f_0: =h[2f0+2f1−2f0+13f2−23f1+13f0]=h[13f0+43f1+13f2]=h\left[2f_0+2f_1-2f_0+\frac13f_2-\frac23f_1+\frac13f_0\right]=h\left[\frac13f_0+\frac43f_1+\frac13f_2\right] ∫x0x2f(x) dx≈h3 [f0+4f1+f2]\int_{x_0}^{x_2}f(x)\,dx\approx\frac h3\,[f_0+4f_1+f_2]

Composite rule. For an even number nn of sub-intervals, apply this to each pair [x0,x2],[x2,x4],…[x_0,x_2],[x_2,x_4],\dots and add. Interior odd points occur once with weight 4, interior even points twice (end of one pair and start of the next): ∫abf(x) dx≈h3[f0+4(f1+f3+⋯+fn−1)+2(f2+f4+⋯+fn−2)+fn],h=b−an\boxed{\int_a^bf(x)\,dx\approx\frac h3\Big[f_0+4(f_1+f_3+\dots+f_{n-1})+2(f_2+f_4+\dots+f_{n-2})+f_n\Big]},\quad h=\frac{b-a}{n}

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2077 · 8 marks

Appropriate the solution of y’ = 2x + y , y(0) = 1 using Euler’s method with step size 0.1. Approximate the value of y(0.4).

Answer

Euler's method: yn+1=yn+h f(xn,yn)y_{n+1}=y_n+h\,f(x_n,y_n), with f(x,y)=2x+yf(x,y)=2x+y, x0=0x_0=0, y0=1y_0=1, h=0.1h=0.1.

nxnx_nyny_nf(xn,yn)=2xn+ynf(x_n,y_n)=2x_n+y_nyn+1=yn+0.1fy_{n+1}=y_n+0.1f
00.01.00001.00001.1000
10.11.10001.30001.2300
20.21.23001.63001.3930
30.31.39301.99301.5923

Hence y(0.1)=1.1,y(0.2)=1.23,y(0.3)=1.393,y(0.4)≈1.5923y(0.1)=1.1,\quad y(0.2)=1.23,\quad y(0.3)=1.393,\quad \boxed{y(0.4)\approx1.5923}

(For comparison, the exact solution of this linear equation is y=3ex−2x−2y=3e^x-2x-2, giving y(0.4)=1.6755y(0.4)=1.6755; the difference is the Euler truncation error.)

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2077 · 8 marks

A plate of dimension 18cm x 18cm is subjected to temperatures as follows: left side at 1000c100^{0}c, right side at 2000c200^{0}c. Upper part at 500c50^{0}c, and lower at 1500c150^{0}c. If square grid length of 6cm x 6cm is assumed, what will be the temperature at the interior nodes?

Answer

Steady-state temperature TT in the plate satisfies Laplace's equation ∇2T=0\nabla^2T=0. With a square grid, the five-point formula gives, at an interior node, the average of its four neighbours: Ti,j=Ti+1,j+Ti−1,j+Ti,j+1+Ti,j−14T_{i,j}=\frac{T_{i+1,j}+T_{i-1,j}+T_{i,j+1}+T_{i,j-1}}{4}

Grid. The plate is 18×1818\times18 cm with grid spacing 66 cm, so there are 4×44\times4 nodes and 2×2=42\times2=4 interior nodes: T1T_1 (top left), T2T_2 (top right), T3T_3 (bottom left), T4T_4 (bottom right).

Boundary temperatures: top 50∘50^\circC, bottom 150∘150^\circC, left 100∘100^\circC, right 200∘200^\circC.

Equations

  • T1=50+100+T2+T34⇒4T1−T2−T3=150T_1=\dfrac{50+100+T_2+T_3}{4}\Rightarrow4T_1-T_2-T_3=150
  • T2=50+200+T1+T44⇒−T1+4T2−T4=250T_2=\dfrac{50+200+T_1+T_4}{4}\Rightarrow-T_1+4T_2-T_4=250
  • T3=100+150+T1+T44⇒−T1+4T3−T4=250T_3=\dfrac{100+150+T_1+T_4}{4}\Rightarrow-T_1+4T_3-T_4=250
  • T4=200+150+T2+T34⇒−T2−T3+4T4=350T_4=\dfrac{200+150+T_2+T_3}{4}\Rightarrow-T_2-T_3+4T_4=350

Solution. Subtract equation 3 from equation 2: 4T2−4T3=0⇒T2=T3=T4T_2-4T_3=0\Rightarrow T_2=T_3=T.

Equation 1: 4T1−2T=1504T_1-2T=150. Equation 4: −2T+4T4=350-2T+4T_4=350. Equation 2: −T1+4T−T4=250-T_1+4T-T_4=250.

From the first two, T1=150+2T4T_1=\dfrac{150+2T}{4} and T4=350+2T4T_4=\dfrac{350+2T}{4}. Substituting in equation 2: −150+2T4+4T−350+2T4=250 ⇒ −125−T+4T=250 ⇒ 3T=375⇒T=125-\frac{150+2T}{4}+4T-\frac{350+2T}{4}=250\ \Rightarrow\ -125-T+4T=250\ \Rightarrow\ 3T=375\Rightarrow T=125

Then T1=150+2504=100T_1=\dfrac{150+250}{4}=100, T4=350+2504=150T_4=\dfrac{350+250}{4}=150.

T1=100∘C,T2=125∘C,T3=125∘C,T4=150∘C\boxed{T_1=100^\circ\text{C},\quad T_2=125^\circ\text{C},\quad T_3=125^\circ\text{C},\quad T_4=150^\circ\text{C}}

Check: T1=(50+100+125+125)/4=100T_1=(50+100+125+125)/4=100 and T4=(200+150+125+125)/4=150T_4=(200+150+125+125)/4=150.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2077 · 8 marks

How boundary value problems differs from initial value problems? Discuss shooting method for solving boundary value problem.

Answer

Difference between BVP and IVP

Initial value problem (IVP)Boundary value problem (BVP)
All conditions are given at one point, e.g. y(a)=α, y′(a)=βy(a)=\alpha,\ y'(a)=\betaConditions are given at two (or more) points, e.g. y(a)=α, y(b)=βy(a)=\alpha,\ y(b)=\beta
Solution is obtained by marching step by step from the initial pointCannot be marched directly because the starting slope is unknown
Solved directly by Euler, Runge-Kutta, etc.Solved by shooting method, finite difference method
Usually has a unique solutionMay have no solution, one or many
Typical for time-dependent problemsTypical for space-dependent problems (beam deflection, heat flow)

Shooting method. Consider the second order BVP y′′=f(x,y,y′),y(a)=α, y(b)=βy''=f(x,y,y'),\qquad y(a)=\alpha,\ y(b)=\beta The idea is to convert it into an IVP by guessing the missing initial slope y′(a)=sy'(a)=s and "shooting" the solution toward x=bx=b, like aiming a gun.

  1. Write the ODE as a first order system: y′=zy'=z, z′=f(x,y,z)z'=f(x,y,z) with y(a)=αy(a)=\alpha, z(a)=sz(a)=s.
  2. Guess s1s_1 and integrate (RK4 or Euler) from aa to bb to get y(b;s1)y(b;s_1).
  3. Define the error function ϕ(s)=y(b;s)−β\phi(s)=y(b;s)-\beta. We need ϕ(s)=0\phi(s)=0.
  4. If ϕ(s1)≠0\phi(s_1)\ne0, take another guess s2s_2 and compute ϕ(s2)\phi(s_2).
  5. Improve the guess with the secant method: sk+1=sk−ϕ(sk)sk−sk−1ϕ(sk)−ϕ(sk−1)s_{k+1}=s_k-\phi(s_k)\frac{s_k-s_{k-1}}{\phi(s_k)-\phi(s_{k-1})}
  6. Repeat until ∣ϕ(sk)∣<ε|\phi(s_k)|<\varepsilon. The last integration is the required solution.

Remarks

  • For a linear ODE, ϕ(s)\phi(s) is a linear function of ss, so by linear interpolation of two shots, s=s1+(β−y1)(s2−s1)y2−y1s=s_1+\dfrac{(\beta-y_1)(s_2-s_1)}{y_2-y_1} gives the exact slope (the solution is y=θy(1)+(1−θ)y(2)y=\theta y_{(1)}+(1-\theta)y_{(2)}).
  • For a non-linear ODE, several iterations (a root-finding procedure such as secant or bisection) are needed.
  • Advantage: uses ready IVP solvers and is simple to code. Disadvantage: may be unstable and sensitive to the guess when the solution grows rapidly.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2078 · 10 marks

How can Horner’s rule be used to evaluate the f(x) and f(x) of a polynomial at a given point? Explain. Write an algorithm and program to calculate a real root of a polynomial using Horner’s rule.

Answer

Horner's rule for f(x)f(x). For p(x)=anxn+an−1xn−1+⋯+a1x+a0p(x)=a_nx^n+a_{n-1}x^{n-1}+\dots+a_1x+a_0 write it in nested form p(x)=(⋯((anx+an−1)x+an−2)x+⋯ )x+a0p(x)=(\cdots((a_nx+a_{n-1})x+a_{n-2})x+\cdots)x+a_0 Set bn=anb_n=a_n and, for i=n−1,…,0i=n-1,\dots,0, bi=ai+bi+1 x0b_i=a_i+b_{i+1}\,x_0 Then b0=p(x0)b_0=p(x_0). This is synthetic division of p(x)p(x) by (x−x0)(x-x_0): the bib_i (i≥1i\ge1) are the coefficients of the quotient q(x)q(x) and b0b_0 is the remainder, so p(x)=(x−x0) q(x)+b0p(x)=(x-x_0)\,q(x)+b_0 It requires only nn multiplications and nn additions.

Horner's rule for f′(x)f'(x). Differentiate the identity above: p′(x)=q(x)+(x−x0)q′(x) ⇒ p′(x0)=q(x0)p'(x)=q(x)+(x-x_0)q'(x)\ \Rightarrow\ p'(x_0)=q(x_0) So p′(x0)p'(x_0) is obtained by applying the same procedure again to the quotient coefficients: put cn=bnc_n=b_n, and for i=n−1,…,1i=n-1,\dots,1, ci=bi+ci+1 x0c_i=b_i+c_{i+1}\,x_0 Then c1=p′(x0)c_1=p'(x_0).

Example: p(x)=x3−2x−5p(x)=x^3-2x-5 at x0=2x_0=2. Coefficients 1,0,−2,−51,0,-2,-5: b=1, 2, 2, −1b=1,\ 2,\ 2,\ -1, so p(2)=−1p(2)=-1. Second pass on 1,2,21,2,2: c=1, 4, 10c=1,\ 4,\ 10, so p′(2)=10p'(2)=10. (Check: p′(x)=3x2−2=10p'(x)=3x^2-2=10.)

Root of a polynomial. Combining both evaluations in Newton's method gives xk+1=xk−p(xk)p′(xk)x_{k+1}=x_k-\frac{p(x_k)}{p'(x_k)} repeated until ∣xk+1−xk∣<ε|x_{k+1}-x_k|<\varepsilon.

Algorithm

  1. Read the degree nn, coefficients an,…,a0a_n,\dots,a_0, initial guess x0x_0, tolerance ε\varepsilon, maximum iterations.
  2. Repeat:
    1. b=anb=a_n, c=anc=a_n.
    2. For i=n−1i=n-1 down to 11: b=ai+b xb=a_i+b\,x; c=b+c xc=b+c\,x.
    3. b=a0+b xb=a_0+b\,x (now b=p(x)b=p(x), and c=p′(x)c=p'(x)).
    4. If c=0c=0, stop (derivative zero).
    5. xnew=x−b/cx_{new}=x-b/c.
    6. If ∣xnew−x∣<ε|x_{new}-x|<\varepsilon, print xnewx_{new} and stop; else x=xnewx=x_{new}.
  3. If the iteration limit is reached, print "no convergence".

Program (C)

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

int main() {
    int n, i, iter;
    double a[20], x, xn, b, c, eps;

    printf("Enter the degree of the polynomial: ");
    scanf("%d", &n);
    printf("Enter coefficients a[n] ... a[0] (highest power first):\n");
    for (i = n; i >= 0; i--)
        scanf("%lf", &a[i]);
    printf("Enter initial guess and tolerance: ");
    scanf("%lf %lf", &x, &eps);

    for (iter = 1; iter <= 100; iter++) {
        b = a[n];
        c = a[n];
        for (i = n - 1; i >= 1; i--) {
            b = a[i] + b * x;     /* quotient coefficient / value */
            c = b + c * x;        /* derivative */
        }
        b = a[0] + b * x;         /* b = p(x), c = p'(x) */
        if (fabs(c) < 1e-12) {
            printf("Derivative is zero. Try another guess.\n");
            return 1;
        }
        xn = x - b / c;
        printf("Iteration %d: x = %.8f  p(x) = %.8f\n", iter, xn, b);
        if (fabs(xn - x) < eps) {
            printf("Root = %.6f\n", xn);
            return 0;
        }
        x = xn;
    }
    printf("Did not converge in 100 iterations.\n");
    return 1;
}

Test: for x3−2x−5=0x^3-2x-5=0 with x0=2x_0=2 the program converges to the root 2.0945512.094551 in a few iterations.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2078 · 10 marks

Write matrix factorization? How can be used to solve a system of linear equations? Factorize the given matrix A and solve the system of equations Ax = b for given b using L and U matrices. A = [123281132236]\begin{bmatrix}1 & 2 & 3\\ 2 & 8 & 11\\ 3 & 22 & 36\end{bmatrix} and b = [41228]\begin{bmatrix}4\\ 12 \\28\end{bmatrix}

Answer

Matrix factorization (LU decomposition). A square matrix AA is factorized as a product of a lower triangular matrix LL (with unit diagonal) and an upper triangular matrix UU:

A=LUA = LU

UU is the result of Gaussian elimination on AA, and the entries of LL below the diagonal are the multipliers used during elimination.

Solving Ax=bAx=b using LL and UU. Substituting A=LUA=LU gives LUx=bLUx=b. Put Ux=yUx=y. Then:

  1. Solve Ly=bLy=b by forward substitution.
  2. Solve Ux=yUx=y by back substitution.

The expensive factorization is done only once, so the same LL, UU can be reused for many right-hand sides bb (cost of each extra solve is only O(n2)O(n^2)).

Factorization of AA.

A=[123281132236]A=\begin{bmatrix}1&2&3\\2&8&11\\3&22&36\end{bmatrix}

Multipliers: l21=2/1=2l_{21}=2/1=2, l31=3/1=3l_{31}=3/1=3.

R2←R2−2R1=(0,4,5)R_2\leftarrow R_2-2R_1=(0,4,5), R3←R3−3R1=(0,16,27)R_3\leftarrow R_3-3R_1=(0,16,27).

Multiplier: l32=16/4=4l_{32}=16/4=4. R3←R3−4R2=(0,0,27−20)=(0,0,7)R_3\leftarrow R_3-4R_2=(0,0,27-20)=(0,0,7).

L=[100210341],U=[123045007]L=\begin{bmatrix}1&0&0\\2&1&0\\3&4&1\end{bmatrix},\qquad U=\begin{bmatrix}1&2&3\\0&4&5\\0&0&7\end{bmatrix}

Check: row 3 of LULU = (3,  6+16,  9+20+7)=(3,22,36)(3,\;6+16,\;9+20+7)=(3,22,36). Correct.

Forward substitution Ly=bLy=b, b=(4,12,28)Tb=(4,12,28)^T:

y1=4y_1=4 2y1+y2=12⇒y2=42y_1+y_2=12\Rightarrow y_2=4 3y1+4y2+y3=28⇒y3=28−12−16=03y_1+4y_2+y_3=28\Rightarrow y_3=28-12-16=0

Back substitution Ux=yUx=y:

7x3=0⇒x3=07x_3=0\Rightarrow x_3=0 4x2+5x3=4⇒x2=14x_2+5x_3=4\Rightarrow x_2=1 x1+2x2+3x3=4⇒x1=2x_1+2x_2+3x_3=4\Rightarrow x_1=2

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

Check in equation 3: 3(2)+22(1)+36(0)=283(2)+22(1)+36(0)=28. Correct.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2078 · 10 marks

What is a higher-order differential equation? How can you solve the higher-order differential equation? Explain. Solve the following differential equation for 1 ≤ x ≥ 2, taking h = 0.25 d2ydx2+3dydx+5y=0\frac{d^2y}{dx^2} + 3\frac{dy}{dx} + 5y = 0, width y(1) = 1 and y^‘(1) = 2

Answer

Higher-order differential equation. An ordinary differential equation containing a derivative of order two or more, e.g. d2ydx2+3dydx+5y=0\dfrac{d^2y}{dx^2}+3\dfrac{dy}{dx}+5y=0, is a higher-order ODE. It needs as many initial conditions as its order.

Numerical solution. A numerical method (Euler, Heun, Runge-Kutta) works on first-order equations, so the nn-th order equation is reduced to a system of nn first-order equations by introducing new variables for the lower derivatives:

  1. Let y1=y,  y2=y′y_1=y,\; y_2=y'.
  2. Write y1′=y2,  y2′=y_1'=y_2,\; y_2'= (the equation solved for the highest derivative).
  3. Apply the one-step method to the vector (y1,y2)(y_1,y_2) simultaneously, using the initial values.

Problem. Take 1≤x≤21\le x\le2, h=0.25h=0.25. Let y′=zy'=z. Then

y′=z,z′=−3z−5y,y(1)=1,  z(1)=2.y'=z,\qquad z'=-3z-5y,\qquad y(1)=1,\; z(1)=2.

Using Heun's (improved Euler) method:

yp=yi+hk1,  zp=zi+hl1,yi+1=yi+h2(k1+k2),  zi+1=zi+h2(l1+l2)y_{p}=y_i+hk_1,\; z_p=z_i+hl_1,\qquad y_{i+1}=y_i+\tfrac h2(k_1+k_2),\; z_{i+1}=z_i+\tfrac h2(l_1+l_2)

with k1=zi,  l1=−3zi−5yik_1=z_i,\; l_1=-3z_i-5y_i and k2=zp,  l2=−3zp−5ypk_2=z_p,\; l_2=-3z_p-5y_p.

Step 1 (x=1x=1): k1=2,  l1=−6−5=−11k_1=2,\; l_1=-6-5=-11. yp=1.5,  zp=2−2.75=−0.75y_p=1.5,\; z_p=2-2.75=-0.75. k2=−0.75,  l2=2.25−7.5=−5.25k_2=-0.75,\; l_2=2.25-7.5=-5.25.

y(1.25)=1+0.125(2−0.75)=1.15625y(1.25)=1+0.125(2-0.75)=1.15625, z(1.25)=2+0.125(−11−5.25)=−0.03125z(1.25)=2+0.125(-11-5.25)=-0.03125.

Step 2 (x=1.25x=1.25): k1=−0.03125,  l1=0.09375−5.78125=−5.6875k_1=-0.03125,\; l_1=0.09375-5.78125=-5.6875. yp=1.14844,  zp=−1.45313y_p=1.14844,\; z_p=-1.45313. k2=−1.45313,  l2=4.35938−5.74219=−1.38281k_2=-1.45313,\; l_2=4.35938-5.74219=-1.38281.

y(1.5)=0.97070y(1.5)=0.97070, z(1.5)=−0.91504z(1.5)=-0.91504.

Step 3 (x=1.5x=1.5): k1=−0.91504,  l1=2.74512−4.85352=−2.10840k_1=-0.91504,\; l_1=2.74512-4.85352=-2.10840. yp=0.74194,  zp=−1.44214y_p=0.74194,\; z_p=-1.44214. k2=−1.44214,  l2=4.32642−3.70972=0.61670k_2=-1.44214,\; l_2=4.32642-3.70972=0.61670.

y(1.75)=0.67606y(1.75)=0.67606, z(1.75)=−1.10150z(1.75)=-1.10150.

Step 4 (x=1.75x=1.75): k1=−1.10150,  l1=3.30450−3.38028=−0.07578k_1=-1.10150,\; l_1=3.30450-3.38028=-0.07578. yp=0.40068,  zp=−1.12045y_p=0.40068,\; z_p=-1.12045. k2=−1.12045,  l2=3.36134−2.00340=1.35793k_2=-1.12045,\; l_2=3.36134-2.00340=1.35793.

y(2)=0.39831y(2)=0.39831, z(2)=−0.94123z(2)=-0.94123.

xx1.001.251.501.752.00
yy11.15630.97070.67610.3983
y′y'2-0.0313-0.9150-1.1015-0.9412

So y(2)≈0.398y(2)\approx0.398.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2078 · 5 marks

How the half-interval method can be estimate a root of a non-linear equation? Find a real root of the following equation using the half-interval method to correct up to two decimal places. x^2 – e^-x – x = 1

Answer

Half-interval (bisection) method. If f(x)f(x) is continuous on [a,b][a,b] and f(a)f(b)<0f(a)f(b)<0, a root lies in (a,b)(a,b). Take the midpoint c=a+b2c=\dfrac{a+b}{2}. If f(a)f(c)<0f(a)f(c)<0 the root is in [a,c][a,c] (set b=cb=c); otherwise it is in [c,b][c,b] (set a=ca=c). Repeating halves the interval each time until ∣b−a∣|b-a| (or ∣f(c)∣|f(c)|) is smaller than the required tolerance.

Problem. f(x)=x2−e−x−x−1=0f(x)=x^2-e^{-x}-x-1=0.

f(1)=1−0.3679−1−1=−1.3679<0f(1)=1-0.3679-1-1=-1.3679<0, f(2)=4−0.1353−2−1=0.8647>0f(2)=4-0.1353-2-1=0.8647>0, so a root lies in [1,2][1,2].

nnaabbc=a+b2c=\frac{a+b}2f(c)f(c)
1121.5-0.4731
21.521.750.1387
31.51.751.625-0.1813
41.6251.751.6875-0.0248
51.68751.751.718750.0561
61.68751.718751.7031250.0154
71.68751.7031251.6953-0.0048
81.69531.7031251.69920.0053

The root now lies in (1.6953, 1.6992)(1.6953,\,1.6992), so both ends round to 1.701.70 and the successive midpoints agree to two decimal places.

x≈1.70x\approx1.70

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2078 · 5 marks

Calculate the real root of the given equation using fixed point iteration correct up to 3 significant figures. 2x^3 – 2x = 5

Answer

Equation: 2x3−2x=52x^3-2x=5, i.e. f(x)=2x3−2x−5=0f(x)=2x^3-2x-5=0.

f(1)=−5<0f(1)=-5<0 and f(2)=7>0f(2)=7>0; f(1.5)=−1.25<0f(1.5)=-1.25<0, f(1.6)=−0.008<0f(1.6)=-0.008<0, f(1.7)=1.43>0f(1.7)=1.43>0. The root lies near 1.61.6.

Rearrangement. 2x3=2x+5⇒x=x+2.53=g(x)2x^3=2x+5\Rightarrow x=\sqrt[3]{x+2.5}=g(x).

Convergence needs ∣g′(x)∣<1|g'(x)|<1 near the root: g′(x)=13(x+2.5)−2/3≈0.2<1g'(x)=\dfrac{1}{3}(x+2.5)^{-2/3}\approx0.2<1 at x≈1.6x\approx1.6, so the iteration xn+1=g(xn)x_{n+1}=g(x_n) converges.

Start with x0=1.5x_0=1.5:

nnxnx_nxn+1=xn+2.53x_{n+1}=\sqrt[3]{x_n+2.5}
01.50001.5874
11.58741.5989
21.59891.6004
31.60041.6006
41.60061.6006

The values agree to four decimals, so

x≈1.60(3 significant figures; more precisely 1.6006).x\approx1.60\quad(\text{3 significant figures; more precisely }1.6006).

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2078 · 5 marks

What is Newton’s interpolation? Obtain the divided difference table from the following data set and estimate the f(x) at x = 2 and x = 5.
x3.22.71.04.85.6
f(x)22.017.814.238.351.7

Answer

Newton's interpolation. Newton's divided-difference interpolation fits a polynomial through n+1n+1 points (which may be unequally spaced) in the form

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

where divided differences are f[xi,xi+1]=f(xi+1)−f(xi)xi+1−xif[x_i,x_{i+1}]=\dfrac{f(x_{i+1})-f(x_i)}{x_{i+1}-x_i} and so on recursively. A new point only adds one new term.

Divided difference table (points in the order given):

xxff1st2nd3rd4th
3.222.0
8.4000
2.717.82.8556
2.1176-0.5275
1.014.22.01160.2558
6.34210.0865
4.838.32.2626
16.7500
5.651.7

Sample entries: 17.8−222.7−3.2=8.4\dfrac{17.8-22}{2.7-3.2}=8.4; 2.1176−8.41.0−3.2=2.8556\dfrac{2.1176-8.4}{1.0-3.2}=2.8556; 2.0116−2.85564.8−3.2=−0.5275\dfrac{2.0116-2.8556}{4.8-3.2}=-0.5275; 0.0865+0.52755.6−3.2=0.2558\dfrac{0.0865+0.5275}{5.6-3.2}=0.2558.

Polynomial:

f(x)=22+8.4(x−3.2)+2.8556(x−3.2)(x−2.7)−0.5275(x−3.2)(x−2.7)(x−1)+0.2558(x−3.2)(x−2.7)(x−1)(x−4.8)f(x)=22+8.4(x-3.2)+2.8556(x-3.2)(x-2.7)-0.5275(x-3.2)(x-2.7)(x-1)+0.2558(x-3.2)(x-2.7)(x-1)(x-4.8)

At x=2x=2: (x−3.2)=−1.2(x-3.2)=-1.2, (x−2.7)=−0.7(x-2.7)=-0.7, (x−1)=1(x-1)=1, (x−4.8)=−2.8(x-4.8)=-2.8.

f(2)=22−10.08+2.8556(0.84)−0.5275(0.84)+0.2558(0.84)(−2.8)=22−10.08+2.3987−0.4431−0.6016≈13.27f(2)=22-10.08+2.8556(0.84)-0.5275(0.84)+0.2558(0.84)(-2.8)=22-10.08+2.3987-0.4431-0.6016\approx13.27

At x=5x=5: (x−3.2)=1.8(x-3.2)=1.8, (x−2.7)=2.3(x-2.7)=2.3, (x−1)=4(x-1)=4, (x−4.8)=0.2(x-4.8)=0.2.

f(5)=22+15.12+2.8556(4.14)−0.5275(16.56)+0.2558(3.312)=22+15.12+11.8222−8.7354+0.8472≈41.05f(5)=22+15.12+2.8556(4.14)-0.5275(16.56)+0.2558(3.312)=22+15.12+11.8222-8.7354+0.8472\approx41.05

f(2)≈13.27,f(5)≈41.05f(2)\approx13.27,\qquad f(5)\approx41.05

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2078 · 5 marks

What is linear regression? Fit the linear function to the following data
x1.01.21.41.61.82.02.22.4
f(x)2.02.63.96.09.31520.630.4

Answer

Linear regression. Linear regression fits a straight line f(x)=a+bxf(x)=a+bx to data by the method of least squares, i.e. choosing a,ba,b that minimise S=∑(yi−a−bxi)2S=\sum(y_i-a-bx_i)^2. Setting ∂S/∂a=∂S/∂b=0\partial S/\partial a=\partial S/\partial b=0 gives the normal equations

na+b∑x=∑y,a∑x+b∑x2=∑xy.na+b\sum x=\sum y,\qquad a\sum x+b\sum x^2=\sum xy.

Computation (n=8n=8):

xxyyx2x^2xyxy
1.02.01.002.00
1.22.61.443.12
1.43.91.965.46
1.66.02.569.60
1.89.33.2416.74
2.015.04.0030.00
2.220.64.8445.32
2.430.45.7672.96
13.689.824.80185.20

Normal equations:

8a+13.6b=89.8,13.6a+24.8b=185.28a+13.6b=89.8,\qquad 13.6a+24.8b=185.2

Determinant =8(24.8)−13.62=198.4−184.96=13.44=8(24.8)-13.6^2=198.4-184.96=13.44.

b=8(185.2)−13.6(89.8)13.44=260.3213.44=19.369b=\frac{8(185.2)-13.6(89.8)}{13.44}=\frac{260.32}{13.44}=19.369

a=89.8−13.6(19.369)8=−21.702a=\frac{89.8-13.6(19.369)}{8}=-21.702

f(x)≈−21.70+19.37 xf(x)\approx-21.70+19.37\,x

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2078 · 5 marks

What are the problems with polynomial interpolation for a large number of data set? How such problems are addressed? Explain with an example.

Answer

Problems with polynomial interpolation for a large data set.

  1. High degree. n+1n+1 points need a polynomial of degree nn. A high-degree polynomial is costly to build and evaluate and the coefficients are very sensitive to rounding errors (ill-conditioned Vandermonde system).
  2. Oscillation (Runge's phenomenon). Between the data points, especially near the ends of the interval, a high-degree polynomial swings wildly, so the interpolated values can be far from the true function even though it passes exactly through every point. For equally spaced nodes the error does not shrink as nn grows; it can get larger.
  3. Global dependence. Changing or adding one data point changes the whole polynomial.
  4. Noisy data are reproduced exactly, including the noise.

Remedy: piecewise (spline) interpolation. Instead of one polynomial for all the points, a separate low-degree polynomial (usually cubic) is fitted on each subinterval [xi,xi+1][x_i,x_{i+1}]. The pieces are joined so that the function, its first derivative and its second derivative are continuous at the interior nodes (cubic spline). Since each piece is low degree, there is no wild oscillation, and a change in one point affects mainly the neighbouring intervals. Other remedies are least-squares curve fitting with a low-degree polynomial, and using Chebyshev-spaced nodes.

Example. Take f(x)=11+25x2f(x)=\dfrac{1}{1+25x^2} on [−1,1][-1,1] with 11 equally spaced points. The degree-10 interpolating polynomial gives about 1.91.9 near x=0.95x=0.95 against the true value f(0.95)=0.042f(0.95)=0.042, and it oscillates strongly near both ends. A cubic spline through the same 11 points follows the curve closely everywhere.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2078 · 5 marks

Solve the following differential equation for 1 ≤ x ≤ 2, taking h = 0.25 using Heun’s method. y^‘(x) + x^2y = 3x, with y(1) = 1

Answer

Heun's method (predictor-corrector, 2nd order) for y′=f(x,y)y'=f(x,y):

yi+1p=yi+hf(xi,yi),yi+1=yi+h2[f(xi,yi)+f(xi+1,yi+1p)]y^{p}_{i+1}=y_i+hf(x_i,y_i),\qquad y_{i+1}=y_i+\frac h2\left[f(x_i,y_i)+f(x_{i+1},y^{p}_{i+1})\right]

Here y′=3x−x2yy'=3x-x^2y, h=0.25h=0.25, x0=1x_0=1, y0=1y_0=1.

Step 1: f(1,1)=3−1=2f(1,1)=3-1=2. yp=1+0.25(2)=1.5y^p=1+0.25(2)=1.5. f(1.25,1.5)=3.75−1.5625(1.5)=1.40625f(1.25,1.5)=3.75-1.5625(1.5)=1.40625.

y(1.25)=1+0.125(2+1.40625)=1.42578y(1.25)=1+0.125(2+1.40625)=1.42578

Step 2: f(1.25,1.42578)=3.75−2.22778=1.52222f(1.25,1.42578)=3.75-2.22778=1.52222. yp=1.42578+0.38056=1.80634y^p=1.42578+0.38056=1.80634. f(1.5,1.80634)=4.5−4.06426=0.43575f(1.5,1.80634)=4.5-4.06426=0.43575.

y(1.5)=1.42578+0.125(1.52222+0.43575)=1.67053y(1.5)=1.42578+0.125(1.52222+0.43575)=1.67053

Step 3: f(1.5,1.67053)=4.5−3.75869=0.74132f(1.5,1.67053)=4.5-3.75869=0.74132. yp=1.67053+0.18533=1.85586y^p=1.67053+0.18533=1.85586. f(1.75,1.85586)=5.25−5.68360=−0.43356f(1.75,1.85586)=5.25-5.68360=-0.43356.

y(1.75)=1.67053+0.125(0.74132−0.43356)=1.70900y(1.75)=1.67053+0.125(0.74132-0.43356)=1.70900

Step 4: f(1.75,1.70900)=5.25−5.23381=0.01620f(1.75,1.70900)=5.25-5.23381=0.01620. yp=1.70900+0.00405=1.71305y^p=1.70900+0.00405=1.71305. f(2,1.71305)=6−6.85218=−0.85218f(2,1.71305)=6-6.85218=-0.85218.

y(2)=1.70900+0.125(0.01620−0.85218)=1.60450y(2)=1.70900+0.125(0.01620-0.85218)=1.60450

xx1.001.251.501.752.00
yy11.42581.67051.70901.6045

y(2)≈1.6045y(2)\approx1.6045.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2078 · 5 marks

Consider a metallic plate of size 90cm by 90cm. The two adjacent sides of the plate are maintained at a temperature of 100^0C and the remaining two adjacent sides are held at 200^0C. Calculate the steady-state temperature at interior points assuming a grid size of 30 cm by 30 cm.

Answer

Setup. The steady-state temperature u(x,y)u(x,y) satisfies Laplace's equation ∇2u=0\nabla^2u=0. With a square grid of step hh, each interior point is the average of its four neighbours:

ui,j=14(ui+1,j+ui−1,j+ui,j+1+ui,j−1)u_{i,j}=\frac14\left(u_{i+1,j}+u_{i-1,j}+u_{i,j+1}+u_{i,j-1}\right)

The plate is 90×9090\times90 cm and h=30h=30 cm, so there are 3×33\times3 divisions and 2×2=42\times2=4 interior points. Let the top and left sides be at 100∘100^\circC and the right and bottom sides at 200∘200^\circC. Label the interior points

u1u2u3u4\begin{matrix}u_1&u_2\\u_3&u_4\end{matrix}

(top row u1,u2u_1,u_2; bottom row u3,u4u_3,u_4).

Equations.

4u1=100+100+u2+u3⇒4u1−u2−u3=2004u_1=100+100+u_2+u_3\Rightarrow 4u_1-u_2-u_3=200 4u2=100+200+u1+u4⇒−u1+4u2−u4=3004u_2=100+200+u_1+u_4\Rightarrow -u_1+4u_2-u_4=300 4u3=100+200+u1+u4⇒−u1+4u3−u4=3004u_3=100+200+u_1+u_4\Rightarrow -u_1+4u_3-u_4=300 4u4=200+200+u2+u3⇒−u2−u3+4u4=4004u_4=200+200+u_2+u_3\Rightarrow -u_2-u_3+4u_4=400

Solution. Equations 2 and 3 are symmetric, so u2=u3u_2=u_3. Then

4u1−2u2=200,−2u2+4u4=400.4u_1-2u_2=200,\qquad -2u_2+4u_4=400.

Also −u1+4u2−u4=300-u_1+4u_2-u_4=300. From the first, u1=50+0.5u2u_1=50+0.5u_2; from the second, u4=100+0.5u2u_4=100+0.5u_2. Substituting:

−(50+0.5u2)+4u2−(100+0.5u2)=300⇒3u2=450⇒u2=150.-(50+0.5u_2)+4u_2-(100+0.5u_2)=300\Rightarrow3u_2=450\Rightarrow u_2=150.

Hence u1=125u_1=125, u4=175u_4=175, u3=150u_3=150.

u1=125∘C,u2=150∘C,u3=150∘C,u4=175∘Cu_1=125^\circ\text{C},\quad u_2=150^\circ\text{C},\quad u_3=150^\circ\text{C},\quad u_4=175^\circ\text{C}

Check: 4(125)=500=200+150+1504(125)=500=200+150+150; 4(175)=700=400+150+1504(175)=700=400+150+150. Correct.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2079 · 10 marks

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 precisionn of 0.01. x^3 + 2x – cos(x) = 4

Answer

Secant method. For f(x)=0f(x)=0, Newton's method needs f′(x)f'(x). The secant method replaces f′(xn)f'(x_n) by the slope of the chord through the two latest points (xn−1,f(xn−1))(x_{n-1},f(x_{n-1})) and (xn,f(xn))(x_n,f(x_n)):

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

Derivation. The straight line through the two points is

y−f(xn)=f(xn)−f(xn−1)xn−xn−1(x−xn).y-f(x_n)=\frac{f(x_n)-f(x_{n-1})}{x_n-x_{n-1}}(x-x_n).

The next approximation xn+1x_{n+1} is where this line crosses the xx-axis (y=0y=0):

xn+1=xn−f(xn) (xn−xn−1)f(xn)−f(xn−1)=xn−1f(xn)−xnf(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})}=\frac{x_{n-1}f(x_n)-x_nf(x_{n-1})}{f(x_n)-f(x_{n-1})}

It needs two starting values but no derivative and no bracketing. The order of convergence is about 1.6181.618.

Problem. f(x)=x3+2x−cos⁡x−4f(x)=x^3+2x-\cos x-4.

f(1)=1+2−0.5403−4=−1.5403f(1)=1+2-0.5403-4=-1.5403, f(2)=8+4+0.4161−4=8.4161f(2)=8+4+0.4161-4=8.4161. Take x0=1,  x1=2x_0=1,\;x_1=2.

nnxn−1x_{n-1}xnx_nf(xn−1)f(x_{n-1})f(xn)f(x_n)xn+1x_{n+1}∣xn+1−xn∣\lvert x_{n+1}-x_n\rvert
112-1.54038.41611.154700.8453
221.154708.4161-0.55521.207010.0523
31.154701.20701-0.5552-0.18331.232800.0258
41.207011.23280-0.18330.00761.231770.0010

Since ∣x5−x4∣=0.0010<0.01\lvert x_5-x_4\rvert=0.0010<0.01, we stop.

x≈1.232x\approx1.232

(Check: f(1.2318)≈0f(1.2318)\approx0.)

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2079 · 10 marks

How spline interpolation differs with the Langrage’s interpolation? Estimate the value of f(0) and f(4) using cubic spline interpolation from the following data.
x-1123
f(x)-10-21486

Answer

Spline vs Lagrange interpolation. Lagrange interpolation passes a single polynomial of degree nn through all n+1n+1 points. For many points it has high degree and can oscillate badly between points (Runge's phenomenon), and it changes completely if one point is altered. Spline interpolation fits a separate low-degree polynomial (cubic) on each interval and joins them so that SS, S′S' and S′′S'' are continuous at interior nodes. It is smooth, stable and local.

Cubic spline. On [xi,xi+1][x_i,x_{i+1}], with Mi=S′′(xi)M_i=S''(x_i) and hi=xi+1−xih_i=x_{i+1}-x_i:

Si(x)=Mi(xi+1−x)3+Mi+1(x−xi)36hi+(yihi−Mihi6)(xi+1−x)+(yi+1hi−Mi+1hi6)(x−xi)S_i(x)=\frac{M_i(x_{i+1}-x)^3+M_{i+1}(x-x_i)^3}{6h_i}+\left(\frac{y_i}{h_i}-\frac{M_ih_i}{6}\right)(x_{i+1}-x)+\left(\frac{y_{i+1}}{h_i}-\frac{M_{i+1}h_i}{6}\right)(x-x_i)

Continuity of S′S' gives, for interior nodes,

hi−1Mi−1+2(hi−1+hi)Mi+hiMi+1=6[yi+1−yihi−yi−yi−1hi−1]h_{i-1}M_{i-1}+2(h_{i-1}+h_i)M_i+h_iM_{i+1}=6\left[\frac{y_{i+1}-y_i}{h_i}-\frac{y_i-y_{i-1}}{h_{i-1}}\right]

Data. x=−1,1,2,3x=-1,1,2,3; y=−10,−2,14,86y=-10,-2,14,86; h0=2,  h1=1,  h2=1h_0=2,\;h_1=1,\;h_2=1. Use natural end conditions M0=M3=0M_0=M_3=0.

Slopes: −2+102=4\dfrac{-2+10}{2}=4, 14+21=16\dfrac{14+2}{1}=16, 86−141=72\dfrac{86-14}{1}=72.

At x1x_1: 2M0+2(3)M1+1⋅M2=6(16−4)⇒6M1+M2=722M_0+2(3)M_1+1\cdot M_2=6(16-4)\Rightarrow6M_1+M_2=72

At x2x_2: M1+2(2)M2+M3=6(72−16)⇒M1+4M2=336M_1+2(2)M_2+M_3=6(72-16)\Rightarrow M_1+4M_2=336

Solving: from the first M2=72−6M1M_2=72-6M_1; then M1+288−24M1=336⇒M1=−4823=−2.0870M_1+288-24M_1=336\Rightarrow M_1=-\dfrac{48}{23}=-2.0870, M2=84.5217M_2=84.5217.

f(0)f(0) lies in [−1,1][-1,1] (i=0i=0, h=2h=2, M0=0M_0=0, M1=−2.0870M_1=-2.0870):

S0(0)=M1(0+1)312+(−102)(1)+(−22+2.0870⋅26)(1)=−0.1739−5+(−1+0.6957)=−5.478S_0(0)=\frac{M_1(0+1)^3}{12}+\left(\frac{-10}{2}\right)(1)+\left(\frac{-2}{2}+\frac{2.0870\cdot2}{6}\right)(1)=-0.1739-5+(-1+0.6957)=-5.478

f(4)f(4) lies outside the data, so the last cubic (interval [2,3][2,3], h=1h=1, M2=84.5217M_2=84.5217, M3=0M_3=0) is extended (extrapolation):

S2(x)=84.5217 (3−x)36+(14−84.52176)(3−x)+86(x−2)S_2(x)=\frac{84.5217\,(3-x)^3}{6}+\left(14-\frac{84.5217}{6}\right)(3-x)+86(x-2)

At x=4x=4: 84.5217(−1)36=−14.087\dfrac{84.5217(-1)^3}{6}=-14.087; (14−14.087)(3−4)=+0.087(14-14.087)(3-4)=+0.087; 86(2)=17286(2)=172.

S2(4)=−14.087+0.087+172=158.0S_2(4)=-14.087+0.087+172=158.0

f(0)≈−5.48,f(4)≈158.0 (extrapolated, so less reliable)f(0)\approx-5.48,\qquad f(4)\approx158.0\ (\text{extrapolated, so less reliable})

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2079 · 10 marks

What is pivoting? Why is it necessary? Write an algorithm and program to solve the set of n linear equations using Gaussian elimination method.

Answer

Pivoting. In Gaussian elimination the element akka_{kk} used to eliminate column kk is the pivot. Pivoting means choosing a good pivot by interchanging rows (partial pivoting: pick the row with the largest ∣aik∣|a_{ik}| for i≥ki\ge k; complete pivoting also interchanges columns).

Why it is necessary.

  1. If a pivot is zero, the multipliers aik/akka_{ik}/a_{kk} cannot be computed (division by zero) even though the system may have a unique solution, e.g. 0⋅x1+x2=1,  x1+x2=20\cdot x_1+x_2=1,\;x_1+x_2=2.
  2. If a pivot is very small compared with other elements, the multipliers are huge and round-off errors are magnified, giving wrong answers.

Partial pivoting keeps all multipliers ≤1\le1 in magnitude and so improves accuracy and stability.

Algorithm (Gaussian elimination with partial pivoting).

  1. Read nn and the augmented matrix a[i][j]a[i][j], i=0..n−1i=0..n-1, j=0..nj=0..n.
  2. For k=0k=0 to n−2n-2:
    1. Find row p≥kp\ge k with the largest ∣a[p][k]∣|a[p][k]|. If it is zero, the matrix is singular; stop.
    2. If p≠kp\ne k interchange rows pp and kk.
    3. For i=k+1i=k+1 to n−1n-1: m=a[i][k]/a[k][k]m=a[i][k]/a[k][k]; for j=kj=k to nn: a[i][j]=a[i][j]−m⋅a[k][j]a[i][j]=a[i][j]-m\cdot a[k][j].
  3. Back substitution: x[n−1]=a[n−1][n]/a[n−1][n−1]x[n-1]=a[n-1][n]/a[n-1][n-1]; for i=n−2i=n-2 down to 00: x[i]=(a[i][n]−∑j=i+1n−1a[i][j]x[j])/a[i][i]x[i]=\left(a[i][n]-\sum_{j=i+1}^{n-1}a[i][j]x[j]\right)/a[i][i].
  4. Print xx.

Program (C).

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

int main(void) {
    int n, i, j, k, p;
    double a[20][21], x[20], m, t, s;

    printf("Enter number of equations: ");
    scanf("%d", &n);
    printf("Enter augmented matrix (%d x %d):\n", n, n + 1);
    for (i = 0; i < n; i++)
        for (j = 0; j <= n; j++)
            scanf("%lf", &a[i][j]);

    /* forward elimination with partial pivoting */
    for (k = 0; k < n - 1; k++) {
        p = k;
        for (i = k + 1; i < n; i++)
            if (fabs(a[i][k]) > fabs(a[p][k]))
                p = i;
        if (fabs(a[p][k]) < 1e-12) {
            printf("Matrix is singular; no unique solution.\n");
            return 1;
        }
        if (p != k)
            for (j = 0; j <= n; j++) {
                t = a[k][j]; a[k][j] = a[p][j]; a[p][j] = t;
            }
        for (i = k + 1; i < n; i++) {
            m = a[i][k] / a[k][k];
            for (j = k; j <= n; j++)
                a[i][j] -= m * a[k][j];
        }
    }
    if (fabs(a[n - 1][n - 1]) < 1e-12) {
        printf("Matrix is singular; no unique solution.\n");
        return 1;
    }

    /* back substitution */
    for (i = n - 1; i >= 0; i--) {
        s = a[i][n];
        for (j = i + 1; j < n; j++)
            s -= a[i][j] * x[j];
        x[i] = s / a[i][i];
    }

    printf("Solution:\n");
    for (i = 0; i < n; i++)
        printf("x%d = %.4f\n", i + 1, x[i]);
    return 0;
}

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2079 · 5 marks

Calculate a real root of the following function using bisection method correct upto 3 significant figures. x^2 – e^-x = 3

Answer

f(x)=x2−e−x−3=0f(x)=x^2-e^{-x}-3=0.

f(1)=1−0.3679−3=−2.3679<0f(1)=1-0.3679-3=-2.3679<0 and f(2)=4−0.1353−3=0.8647>0f(2)=4-0.1353-3=0.8647>0, so a root lies in [1,2][1,2].

nnaabbc=a+b2c=\frac{a+b}2f(c)f(c)
1121.5-0.9731
21.521.75-0.1113
31.7521.8750.3623
41.751.8751.81250.1219
51.751.81251.781250.0044
61.751.781251.765625-0.0536
71.7656251.781251.7734-0.0247
81.77341.781251.7773-0.0101
91.77731.781251.7793-0.0029
101.77931.781251.78030.0008

The root lies in (1.7793, 1.7803)(1.7793,\,1.7803); both ends and the midpoints round to 1.781.78 (3 significant figures).

x≈1.78x\approx1.78

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2079 · 5 marks

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.

Answer

Fixed point iteration. To solve f(x)=0f(x)=0, rewrite it in the form x=g(x)x=g(x) and iterate from a starting guess x0x_0:

xn+1=g(xn),n=0,1,2,…x_{n+1}=g(x_n),\quad n=0,1,2,\ldots

A root of ff is a fixed point of gg (where the curve y=g(x)y=g(x) meets the line y=xy=x). Iteration stops when ∣xn+1−xn∣|x_{n+1}-x_n| is smaller than the tolerance.

Convergence condition. Let α=g(α)\alpha=g(\alpha) and en=xn−αe_n=x_n-\alpha. By the mean value theorem en+1=g′(ξ)ene_{n+1}=g'(\xi)e_n. If gg and g′g' are continuous on an interval II around α\alpha containing x0x_0, and

∣g′(x)∣≤k<1 for all x∈I,|g'(x)|\le k<1\ \text{for all }x\in I,

then the error is multiplied by at most kk at every step, so xn→αx_n\to\alpha (linear convergence; the smaller ∣g′(α)∣|g'(\alpha)|, the faster). In the cobweb diagram, 0<g′<10<g'<1 gives a monotone staircase and −1<g′<0-1<g'<0 gives a spiral into the root.

Diverging cases. If ∣g′(x)∣>1|g'(x)|>1 near the root, the error grows and the iteration moves away from the root.

Example 1. x2−2x−3=0x^2-2x-3=0 has root x=3x=3. Taking x=g(x)=x2−32x=g(x)=\dfrac{x^2-3}{2}: g′(x)=xg'(x)=x, so ∣g′(3)∣=3>1|g'(3)|=3>1. Starting at x0=4x_0=4: x1=6.5,  x2=19.6,  x3=190.6…x_1=6.5,\;x_2=19.6,\;x_3=190.6\ldots, which diverges. Rearranged as x=2x+3x=\sqrt{2x+3}, g′(3)=19=13<1g'(3)=\dfrac{1}{\sqrt{9}}=\dfrac13<1, and x0=4→3.317→3.103→3.034→3.011…→3x_0=4\to3.317\to3.103\to3.034\to3.011\ldots\to3 converges.

Example 2. The equation 3x=13x=1 (root x=1/3x=1/3) written as x=g(x)=1−2xx=g(x)=1-2x has g′(x)=−2g'(x)=-2, so ∣g′∣>1|g'|>1. The iterates oscillate with growing amplitude: x0=0.4→0.2→0.6→−0.2→1.4→⋯x_0=0.4\to0.2\to0.6\to-0.2\to1.4\to\cdots

So the same equation can converge or diverge depending on the choice of g(x)g(x); one must check ∣g′(x)∣<1|g'(x)|<1 near the root.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2079 · 5 marks

Fit the quadratic function for the data given below using least square method.
x1.01.52.02.53.03.54.0
f(x)2.745.88.311.21519

Answer

Fit f(x)=a+bx+cx2f(x)=a+bx+cx^2 by least squares. The normal equations (n=7n=7) are

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

xxyyx2x^2x3x^3x4x^4xyxyx2yx^2y
1.02.71.001.0001.00002.702.700
1.54.02.253.3755.06256.009.000
2.05.84.008.00016.000011.6023.200
2.58.36.2515.62539.062520.7551.875
3.011.29.0027.00081.000033.60100.800
3.515.012.2542.875150.062552.50183.750
4.019.016.0064.000256.000076.00304.000
17.566.050.75161.875548.1875203.15675.325

7a+17.5b+50.75c=667a+17.5b+50.75c=66 17.5a+50.75b+161.875c=203.1517.5a+50.75b+161.875c=203.15 50.75a+161.875b+548.1875c=675.32550.75a+161.875b+548.1875c=675.325

Solving (eliminate aa): multiply eq. 1 by 2.52.5 and subtract from eq. 2, and by 7.257.25 and subtract from eq. 3:

7b+35c=38.157b+35c=38.15 35b+180.25c=196.82535b+180.25c=196.825

(for example 50.75−2.5⋅17.5=750.75-2.5\cdot17.5=7, 161.875−2.5⋅50.75=35161.875-2.5\cdot50.75=35, 203.15−2.5⋅66=38.15203.15-2.5\cdot66=38.15). From the first, b=5.45−5cb=5.45-5c. Substituting: 35(5.45−5c)+180.25c=196.825⇒5.25c=6.07535(5.45-5c)+180.25c=196.825\Rightarrow5.25c=6.075, c=1.1571c=1.1571; then b=−0.3357b=-0.3357 and a=(66−17.5b−50.75c)/7=1.8786a=(66-17.5b-50.75c)/7=1.8786.

f(x)≈1.879−0.336 x+1.157 x2f(x)\approx1.879-0.336\,x+1.157\,x^2

Check at x=2x=2: 1.879−0.671+4.629=5.8371.879-0.671+4.629=5.837 (data 5.85.8).

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2079 · 5 marks

Estimate the integral value of following function from x =1.2 to 2.4 using Simpson’s 1/3 rule.
x1.01.21.41.61.82.02.22.42.6
f(x)1.532.253.184.325.677.238.9810.9413.08

Answer

Simpson's 1/3 rule. For an even number of strips nn of width hh:

∫x0xnf dx≈h3[y0+yn+4(y1+y3+⋯ )+2(y2+y4+⋯ )]\int_{x_0}^{x_n}f\,dx\approx\frac h3\left[y_0+y_n+4(y_1+y_3+\cdots)+2(y_2+y_4+\cdots)\right]

The range x=1.2x=1.2 to 2.42.4 with h=0.2h=0.2 has 6 strips (even), 7 ordinates:

ii0123456
xx1.21.41.61.82.02.22.4
yy2.253.184.325.677.238.9810.94
  • Ends: y0+y6=2.25+10.94=13.19y_0+y_6=2.25+10.94=13.19
  • Odd ordinates: y1+y3+y5=3.18+5.67+8.98=17.83y_1+y_3+y_5=3.18+5.67+8.98=17.83, times 4 =71.32=71.32
  • Even ordinates: y2+y4=4.32+7.23=11.55y_2+y_4=4.32+7.23=11.55, times 2 =23.10=23.10

I≈0.23(13.19+71.32+23.10)=0.23(107.61)=7.174I\approx\frac{0.2}{3}(13.19+71.32+23.10)=\frac{0.2}{3}(107.61)=7.174

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2079 · 5 marks

What is Gaussian integration formula? Evaluate the following integration using Gaussian integration three ordinate formula _0∫^1 Sinx/x dx

Answer

Gaussian integration formula. Gauss quadrature chooses both the nodes and the weights so that the formula is exact for polynomials up to degree 2n−12n-1 with nn ordinates:

∫−11f(t) dt≈∑i=1nwif(ti)\int_{-1}^{1}f(t)\,dt\approx\sum_{i=1}^{n}w_if(t_i)

(for a general interval [a,b][a,b] use x=b−a2t+b+a2x=\tfrac{b-a}{2}t+\tfrac{b+a}{2}). For three ordinates, t=0,±3/5t=0,\pm\sqrt{3/5} with weights w=89,59,59w=\tfrac89,\tfrac59,\tfrac59.

Problem. I=∫01sin⁡xxdxI=\displaystyle\int_0^1\frac{\sin x}{x}dx. Put x=t+12x=\dfrac{t+1}{2}, dx=12dtdx=\dfrac12dt:

I=12∫−11sin⁡t+12t+12 dt≈12[59f(x1)+89f(x2)+59f(x3)]I=\frac12\int_{-1}^{1}\frac{\sin\frac{t+1}2}{\frac{t+1}2}\,dt\approx\frac12\left[\tfrac59f(x_1)+\tfrac89f(x_2)+\tfrac59f(x_3)\right]

Nodes: x1=1−0.7745972=0.112702x_1=\dfrac{1-0.774597}{2}=0.112702, x2=0.5x_2=0.5, x3=0.887298x_3=0.887298.

  • f(x1)=sin⁡0.1127020.112702=0.997884f(x_1)=\dfrac{\sin0.112702}{0.112702}=0.997884
  • f(x2)=sin⁡0.50.5=0.958851f(x_2)=\dfrac{\sin0.5}{0.5}=0.958851
  • f(x3)=sin⁡0.8872980.887298=0.873853f(x_3)=\dfrac{\sin0.887298}{0.887298}=0.873853

I≈12[0.555556(0.997884+0.873853)+0.888889(0.958851)]=12[1.039854+0.852312]I\approx\frac12\left[0.555556(0.997884+0.873853)+0.888889(0.958851)\right]=\frac12\left[1.039854+0.852312\right]

I≈0.94608I\approx0.94608

(The exact value is 0.9460830.946083.)

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2079 · 5 marks

Solve the following differential equation for 0 ≤ x ≤ 1 taking h=0.5 using Runge Kutta 4th order method. y'(x) + y = 3x with y(0)=2

Answer

RK4 formulas for y′=f(x,y)y'=f(x,y):

k1=f(xi,yi),  k2=f ⁣(xi+h2,yi+h2k1),  k3=f ⁣(xi+h2,yi+h2k2),  k4=f(xi+h,yi+hk3)k_1=f(x_i,y_i),\; k_2=f\!\left(x_i+\tfrac h2,y_i+\tfrac h2k_1\right),\; k_3=f\!\left(x_i+\tfrac h2,y_i+\tfrac h2k_2\right),\; k_4=f(x_i+h,y_i+hk_3)

yi+1=yi+h6(k1+2k2+2k3+k4)y_{i+1}=y_i+\frac h6(k_1+2k_2+2k_3+k_4)

Here y′=3x−yy'=3x-y, h=0.5h=0.5, y(0)=2y(0)=2.

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

k1=0−2=−2k_1=0-2=-2 k2=f(0.25, 2+0.25(−2))=f(0.25,1.5)=0.75−1.5=−0.75k_2=f(0.25,\,2+0.25(-2))=f(0.25,1.5)=0.75-1.5=-0.75 k3=f(0.25, 2+0.25(−0.75))=f(0.25,1.8125)=0.75−1.8125=−1.0625k_3=f(0.25,\,2+0.25(-0.75))=f(0.25,1.8125)=0.75-1.8125=-1.0625 k4=f(0.5, 2+0.5(−1.0625))=f(0.5,1.46875)=1.5−1.46875=0.03125k_4=f(0.5,\,2+0.5(-1.0625))=f(0.5,1.46875)=1.5-1.46875=0.03125

y(0.5)=2+0.56(−2−1.5−2.125+0.03125)=2+0.083333(−5.59375)=1.53385y(0.5)=2+\frac{0.5}{6}\left(-2-1.5-2.125+0.03125\right)=2+0.083333(-5.59375)=1.53385

Step 2 (x=0.5,  y=1.53385x=0.5,\;y=1.53385):

k1=1.5−1.53385=−0.03385k_1=1.5-1.53385=-0.03385 k2=f(0.75, 1.53385−0.00846)=2.25−1.52539=0.72461k_2=f(0.75,\,1.53385-0.00846)=2.25-1.52539=0.72461 k3=f(0.75, 1.53385+0.18115)=2.25−1.71500=0.53500k_3=f(0.75,\,1.53385+0.18115)=2.25-1.71500=0.53500 k4=f(1, 1.53385+0.26750)=3−1.80135=1.19865k_4=f(1,\,1.53385+0.26750)=3-1.80135=1.19865

y(1)=1.53385+0.56(−0.03385+1.44922+1.07000+1.19865)=1.53385+0.083333(3.68402)=1.84085y(1)=1.53385+\frac{0.5}{6}\left(-0.03385+1.44922+1.07000+1.19865\right)=1.53385+0.083333(3.68402)=1.84085

xx00.51.0
yy21.53391.8409

(Exact solution y=3x−3+5e−xy=3x-3+5e^{-x} gives y(1)=1.8394y(1)=1.8394.)

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2080 · 10 marks

How secant methods differs from Newton Rhapson method? Derive the formula for Secant Method. Solve the equation Cosx + 2Sinx – x² = 0 using Secant method. Assume error precision as 0.01. Discuss the drawbacks of the Newton Rhapson method.

Answer

Secant vs Newton-Raphson.

Newton-RaphsonSecant
xn+1=xn−f(xn)f′(xn)x_{n+1}=x_n-\dfrac{f(x_n)}{f'(x_n)}xn+1=xn−f(xn)(xn−xn−1)f(xn)−f(xn−1)x_{n+1}=x_n-\dfrac{f(x_n)(x_n-x_{n-1})}{f(x_n)-f(x_{n-1})}
Needs the derivative f′(x)f'(x)No derivative needed; slope is approximated by a chord
One starting valueTwo starting values
Order of convergence 2Order about 1.618
Two function-type evaluations per step (ff and f′f')One new evaluation of ff per step

Derivation of the secant formula. Replace f′(xn)f'(x_n) in Newton's formula by the difference quotient f(xn)−f(xn−1)xn−xn−1\dfrac{f(x_n)-f(x_{n-1})}{x_n-x_{n-1}}. Equivalently, the line through (xn−1,f(xn−1))(x_{n-1},f(x_{n-1})) and (xn,f(xn))(x_n,f(x_n)) is

y−f(xn)=f(xn)−f(xn−1)xn−xn−1(x−xn).y-f(x_n)=\frac{f(x_n)-f(x_{n-1})}{x_n-x_{n-1}}(x-x_n).

Setting y=0y=0 gives the new approximation:

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})}

Problem. f(x)=cos⁡x+2sin⁡x−x2f(x)=\cos x+2\sin x-x^2. f(1)=0.5403+1.6829−1=1.2232f(1)=0.5403+1.6829-1=1.2232 and f(2)=−0.4161+1.8186−4=−2.5976f(2)=-0.4161+1.8186-4=-2.5976, so a root lies between 1 and 2. Take x0=1x_0=1, x1=2x_1=2.

nnxn−1x_{n-1}xnx_nf(xn−1)f(x_{n-1})f(xn)f(x_n)xn+1x_{n+1}∣xn+1−xn∣\lvert x_{n+1}-x_n\rvert
1121.2232-2.59761.320150.680
221.32015-2.59760.44271.419150.099
31.320151.419150.44270.11411.453530.034
41.419151.453530.1141-0.00951.450890.0026

The change 0.0026<0.010.0026<0.01, so we stop:

x≈1.451x\approx1.451

Drawbacks of Newton-Raphson.

  1. It needs f′(x)f'(x), which may be difficult or costly to find.
  2. If f′(xn)=0f'(x_n)=0 or is very small (near a stationary point), the step is undefined or huge.
  3. It can diverge or jump to a different root if the initial guess is not close enough to the root; it may also cycle or oscillate (e.g. x3−2x+2=0x^3-2x+2=0 from x0=0x_0=0).
  4. Convergence is only linear at multiple roots.
  5. It is sensitive to the starting value and requires ff to be differentiable.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2080 · 10 marks

Define the terms interpolation and extrapolation. Write down the algorithm and program for Newton’s divided difference interpolation.

Answer

Interpolation is estimating the value of a function at a point lying inside the range of the given data points x0,…,xnx_0,\ldots,x_n (i.e. x0≤x≤xnx_0\le x\le x_n), using a function (usually a polynomial) that passes through the data.

Extrapolation is estimating the value at a point outside that range (x<x0x<x_0 or x>xnx>x_n). It is less reliable because the fitted curve is not constrained there.

Newton's divided difference interpolation.

f(x)=f[x0]+f[x0,x1](x−x0)+f[x0,x1,x2](x−x0)(x−x1)+⋯+f[x0,…,xn]∏i=0n−1(x−xi)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+f[x_0,\ldots,x_n]\prod_{i=0}^{n-1}(x-x_i)

with f[xi,xi+1]=f(xi+1)−f(xi)xi+1−xif[x_i,x_{i+1}]=\dfrac{f(x_{i+1})-f(x_i)}{x_{i+1}-x_i} and f[xi,…,xi+k]=f[xi+1,…,xi+k]−f[xi,…,xi+k−1]xi+k−xif[x_i,\ldots,x_{i+k}]=\dfrac{f[x_{i+1},\ldots,x_{i+k}]-f[x_i,\ldots,x_{i+k-1}]}{x_{i+k}-x_i}.

Algorithm.

  1. Read nn (number of points), the arrays x[i]x[i], y[i]y[i] and the value xpxp at which to interpolate.
  2. Store d[i][0]=y[i]d[i][0]=y[i].
  3. For j=1j=1 to n−1n-1 and for i=0i=0 to n−1−jn-1-j: d[i][j]=d[i+1][j−1]−d[i][j−1]x[i+j]−x[i]d[i][j]=\dfrac{d[i+1][j-1]-d[i][j-1]}{x[i+j]-x[i]}.
  4. Set sum=d[0][0]sum=d[0][0] and prod=1prod=1.
  5. For j=1j=1 to n−1n-1: prod=prod×(xp−x[j−1])prod=prod\times(xp-x[j-1]); sum=sum+d[0][j]×prodsum=sum+d[0][j]\times prod.
  6. Print sumsum as f(xp)f(xp).

Program (C).

#include <stdio.h>

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

    printf("Enter number of data points: ");
    scanf("%d", &n);
    printf("Enter x and f(x) values:\n");
    for (i = 0; i < n; i++) {
        scanf("%lf %lf", &x[i], &d[i][0]);
    }
    printf("Enter the 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's form */
    sum = d[0][0];
    prod = 1.0;
    for (j = 1; j < n; j++) {
        prod *= (xp - x[j - 1]);
        sum += d[0][j] * prod;
    }

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

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2080 · 10 marks

How Gauss Jordan method differs from Gauss Elimination method? Solve the following system of equations using Gauss Jordan method. How can we use Gauss Jordan method to find the inverse of a matrix? Discuss. 2x – y + 4z = 15 2x + 3y – 2z = 4 3x + 2y – 4z = -4

Answer

Difference between Gauss Elimination and Gauss-Jordan.

Gauss EliminationGauss-Jordan
Reduces the augmented matrix to an upper triangular form (zeros only below the diagonal).Reduces it to a diagonal (identity) form (zeros above and below each pivot).
Solution is obtained by back substitution.Solution is read directly; no back substitution is needed.
Fewer operations, about n3/3n^3/3 multiplications.More operations, about n3/2n^3/2.
Pivot rows are normalised only if required.Every pivot row is divided by its pivot to make the pivot 1.

Solution of the system by Gauss-Jordan

[2−141523−2432−4−4]\left[\begin{array}{ccc|c}2&-1&4&15\\2&3&-2&4\\3&2&-4&-4\end{array}\right]

Step 1: R1→R1/2R_1\to R_1/2, then R2→R2−2R1R_2\to R_2-2R_1, R3→R3−3R1R_3\to R_3-3R_1:

[1−12215204−6−11072−10−532]\left[\begin{array}{ccc|c}1&-\tfrac12&2&\tfrac{15}{2}\\0&4&-6&-11\\0&\tfrac72&-10&-\tfrac{53}{2}\end{array}\right]

Step 2: R2→R2/4R_2\to R_2/4, then R1→R1+12R2R_1\to R_1+\tfrac12R_2, R3→R3−72R2R_3\to R_3-\tfrac72R_2:

[105449801−32−11400−194−1358]\left[\begin{array}{ccc|c}1&0&\tfrac54&\tfrac{49}{8}\\0&1&-\tfrac32&-\tfrac{11}{4}\\0&0&-\tfrac{19}{4}&-\tfrac{135}{8}\end{array}\right]

Step 3: R3→R3/(−194)R_3\to R_3/(-\tfrac{19}{4}), then R1→R1−54R3R_1\to R_1-\tfrac54R_3, R2→R2+32R3R_2\to R_2+\tfrac32R_3:

[1003219010491900113538]\left[\begin{array}{ccc|c}1&0&0&\tfrac{32}{19}\\0&1&0&\tfrac{49}{19}\\0&0&1&\tfrac{135}{38}\end{array}\right]

x=3219≈1.684,y=4919≈2.579,z=13538≈3.553x=\tfrac{32}{19}\approx1.684,\qquad y=\tfrac{49}{19}\approx2.579,\qquad z=\tfrac{135}{38}\approx3.553

Check in equation 1: 2(1.6842)−2.5789+4(3.5526)=3.3684−2.5789+14.2105=15.02(1.6842)-2.5789+4(3.5526)=3.3684-2.5789+14.2105=15.0.

Finding the inverse using Gauss-Jordan

To find A−1A^{-1} of an n×nn\times n non-singular matrix, form the augmented matrix [A ∣ I][A\,|\,I] and apply row operations (the same Gauss-Jordan steps, including row swaps for partial pivoting) until the left half becomes II. Because every row operation is equivalent to multiplying by an elementary matrix EkE_k,

Em⋯E2E1A=I ⇒ Em⋯E1=A−1,[A ∣ I]⟶[I ∣ A−1]E_m\cdots E_2E_1A=I\ \Rightarrow\ E_m\cdots E_1=A^{-1},\qquad [A\,|\,I]\longrightarrow[I\,|\,A^{-1}]

so the right half now holds A−1A^{-1}. If a zero pivot cannot be removed by a row swap, AA is singular and has no inverse.

Procedure:

  1. Write [A ∣ I][A\,|\,I].
  2. For each column j=1,…,nj=1,\dots,n: choose the pivot (largest ∣aij∣|a_{ij}|, swap if needed), divide the pivot row by the pivot, and eliminate column jj from all other rows.
  3. Read A−1A^{-1} from the right half.

For the system above, A−1A^{-1} obtained this way gives x=A−1b\mathbf x=A^{-1}\mathbf b, the same solution as found directly.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2080 · 5 marks

Define the terms approximate errot and relative approximate error? Discuss the working of Half Interval method for finding the roots of non-linear equation.

Answer

Approximate error. If xnewx_{new} and xoldx_{old} are the present and previous approximations of a root in an iterative method (the true value being unknown), the approximate error is

Ea=xnew−xoldE_a=x_{new}-x_{old}

and the relative approximate error is

εa=∣xnew−xoldxnew∣(or ×100%)\varepsilon_a=\left|\frac{x_{new}-x_{old}}{x_{new}}\right|\quad\text{(or }\times100\%\text{)}

Iteration stops when εa<εtol\varepsilon_a<\varepsilon_{tol}. (For comparison, the true error is Et=xtrue−xapproxE_t=x_{true}-x_{approx}, usable only when xtruex_{true} is known.)

Half Interval (Bisection) method. It finds a root of f(x)=0f(x)=0 for a continuous ff on [a,b][a,b] where f(a)f(b)<0f(a)f(b)<0; by the intermediate value theorem a root lies in (a,b)(a,b).

Working:

  1. Choose a,ba,b with f(a)f(b)<0f(a)f(b)<0 and a tolerance ε\varepsilon.
  2. Compute the midpoint c=a+b2c=\dfrac{a+b}{2}.
  3. Test:
    • if f(c)=0f(c)=0, 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;
    • else the root lies in [c,b][c,b], so set a=ca=c.
  4. Repeat steps 2-3 until ∣b−a∣<ε|b-a|<\varepsilon (or εa<ε\varepsilon_a<\varepsilon). The final cc is the root.

Each step halves the interval, so after nn steps the width is (b−a)/2n(b-a)/2^n. The number of iterations needed for accuracy ε\varepsilon is

n≥ln⁡((b−a)/ε)ln⁡2n\ge\frac{\ln\big((b-a)/\varepsilon\big)}{\ln2}

The method always converges (linearly) but is slow, and it cannot find roots where ff touches zero without changing sign.

Example: f(x)=x2−2f(x)=x^2-2 on [1,2][1,2]: c=1.5c=1.5, f(1.5)=0.25>0f(1.5)=0.25>0, root in [1,1.5][1,1.5]; c=1.25c=1.25, f=−0.4375<0f=-0.4375<0, root in [1.25,1.5][1.25,1.5]; c=1.375c=1.375, and so on, converging to 1.41421.4142.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2080 · 5 marks

Fit the quadratic curve through the following data points and estimate the value of f(x) at x=2.
x13456
y27875

Answer

Quadratic least-squares 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
1211122
37927812163
48166425632128
572512562535175
6536216129630180
1929874332259120548

5a+19b+87c=295a+19b+87c=29 19a+87b+433c=12019a+87b+433c=120 87a+433b+2259c=54887a+433b+2259c=548

Solving the three equations simultaneously (elimination or Cramer's rule, with determinant D=2716D=2716):

a≈−2.6289,b≈5.2629,c≈−0.6649a\approx-2.6289,\qquad b\approx5.2629,\qquad c\approx-0.6649

y=−2.6289+5.2629x−0.6649x2y=-2.6289+5.2629x-0.6649x^2

At x=2x=2:

y(2)=−2.6289+10.5258−2.6598=5.2371≈5.24y(2)=-2.6289+10.5258-2.6598=5.2371\approx5.24

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2080 · 5 marks

How can we calculate derivatives of discrete (tabulated) functions? Write down its algorithm.

Answer

Derivatives of tabulated functions. When f(x)f(x) is known only at points x0,x1,…,xnx_0,x_1,\dots,x_n, we fit an interpolating polynomial through the data and differentiate that polynomial, since f′(x)≈Pn′(x)f'(x)\approx P_n'(x).

  • For equally spaced points (hh constant) use Newton's formulas. With p=(x−x0)/hp=(x-x_0)/h and forward differences, f′(x)=1h[Δf0+2p−12Δ2f0+3p2−6p+26Δ3f0+⋯ ]f'(x)=\frac1h\left[\Delta f_0+\frac{2p-1}{2}\Delta^2f_0+\frac{3p^2-6p+2}{6}\Delta^3f_0+\cdots\right] f′′(x)=1h2[Δ2f0+(p−1)Δ3f0+⋯ ]f''(x)=\frac1{h^2}\left[\Delta^2f_0+(p-1)\Delta^3f_0+\cdots\right] At x=x0x=x_0 (p=0p=0): f′(x0)=1h[Δf0−12Δ2f0+13Δ3f0−⋯ ]f'(x_0)=\frac1h\left[\Delta f_0-\frac12\Delta^2f_0+\frac13\Delta^3f_0-\cdots\right]. Near the end of the table use the backward-difference version, and in the middle use central differences: f′(xi)≈fi+1−fi−12h,f′′(xi)≈fi+1−2fi+fi−1h2f'(x_i)\approx\frac{f_{i+1}-f_{i-1}}{2h},\qquad f''(x_i)\approx\frac{f_{i+1}-2f_i+f_{i-1}}{h^2}
  • For unequally spaced points use Lagrange's or Newton's divided-difference polynomial and differentiate it.

Algorithm (Newton forward formula, equal spacing)

  1. Read nn and the data xi,fix_i,f_i (i=0..ni=0..n); read the point xx where the derivative is wanted.
  2. Compute h=x1−x0h=x_1-x_0 and p=(x−x0)/hp=(x-x_0)/h.
  3. Build the difference table: Δkfi=Δk−1fi+1−Δk−1fi\Delta^kf_i=\Delta^{k-1}f_{i+1}-\Delta^{k-1}f_i for k=1..nk=1..n.
  4. Compute f′(x)=1h[Δf0+2p−12Δ2f0+3p2−6p+26Δ3f0+⋯ ]f'(x)=\frac1h\left[\Delta f_0+\frac{2p-1}{2}\Delta^2f_0+\frac{3p^2-6p+2}{6}\Delta^3f_0+\cdots\right] using as many terms as the table allows.
  5. Print f′(x)f'(x) (and similarly f′′(x)f''(x) if required) and stop.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2080 · 5 marks

Find the following integral using composite trapezoidal rule for using 2 segments (k=2) and 4 segments (k=4). _2∫^4 (x³+2) dx

Answer

Composite trapezoidal rule

∫abf(x) dx≈h2[f0+2(f1+⋯+fk−1)+fk],h=b−ak\int_a^bf(x)\,dx\approx\frac h2\Big[f_0+2(f_1+\dots+f_{k-1})+f_k\Big],\qquad h=\frac{b-a}{k}

with f(x)=x3+2f(x)=x^3+2, a=2a=2, b=4b=4.

k = 2: h=1h=1, nodes x=2,3,4x=2,3,4: f=10, 29, 66f=10,\ 29,\ 66.

I2=12[10+2(29)+66]=1342=67I_2=\frac12\big[10+2(29)+66\big]=\frac{134}{2}=67

k = 4: h=0.5h=0.5, nodes x=2, 2.5, 3, 3.5, 4x=2,\ 2.5,\ 3,\ 3.5,\ 4:

xx22.533.54
f(x)f(x)1017.6252944.87566

I4=0.52[10+2(17.625+29+44.875)+66]=0.25 [10+183+66]=0.25(259)=64.75I_4=\frac{0.5}{2}\big[10+2(17.625+29+44.875)+66\big]=0.25\,[10+183+66]=0.25(259)=64.75

The exact value is [x44+2x]24=(64+8)−(4+4)=64\big[\tfrac{x^4}4+2x\big]_2^4=(64+8)-(4+4)=64, so the errors are 33 (k=2) and 0.750.75 (k=4); the error falls by about a factor of 4 when hh is halved.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2080 · 5 marks

Approximate the solution of y’=3x², y(1)=1 using Taylor’s series method using first four terms. Approximate the value of y(2).

Answer

Taylor series about x0=1x_0=1:

y(x)=y0+(x−x0)y0′+(x−x0)22!y0′′+(x−x0)33!y0′′′+⋯y(x)=y_0+(x-x_0)y_0'+\frac{(x-x_0)^2}{2!}y_0''+\frac{(x-x_0)^3}{3!}y_0'''+\cdots

Derivatives from y′=3x2y'=3x^2, at x0=1x_0=1, y0=1y_0=1:

  • y′=3x2⇒y0′=3y'=3x^2\Rightarrow y_0'=3
  • y′′=6x⇒y0′′=6y''=6x\Rightarrow y_0''=6
  • y′′′=6⇒y0′′′=6y'''=6\Rightarrow y_0'''=6

First four terms:

y(x)=1+3(x−1)+62(x−1)2+66(x−1)3=1+3(x−1)+3(x−1)2+(x−1)3y(x)=1+3(x-1)+\frac{6}{2}(x-1)^2+\frac{6}{6}(x-1)^3=1+3(x-1)+3(x-1)^2+(x-1)^3

At x=2x=2 (x−1=1x-1=1):

y(2)=1+3+3+1=8y(2)=1+3+3+1=8

(The next derivative y(4)=0y^{(4)}=0, so the series terminates and this is exact: y=x3y=x^3, y(2)=8y(2)=8.)

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2081 · 10 marks

What are inherent errors? Derive the Newton Raphson method for solving non-linear equation and using this method solve
x2–5x+6=0x^2 – 5x + 6 = 0 . Calculate upto 3 decimal places.

Answer

Inherent errors. These are errors already present in the data or problem before any computation begins: they arise from imprecise measurements, approximate physical constants, or a mathematical model that simplifies reality (also called data or input errors). They cannot be removed by improving the numerical method, only by more accurate input data. Example: using g=9.8g=9.8 instead of 9.806659.80665, or a length measured as 12.312.3 cm.

Derivation of Newton-Raphson method. Let f(x)=0f(x)=0 have a root near xnx_n, and let the true root be xn+hx_n+h with hh small. Expanding by Taylor's series:

f(xn+h)=f(xn)+hf′(xn)+h22!f′′(xn)+⋯=0f(x_n+h)=f(x_n)+hf'(x_n)+\frac{h^2}{2!}f''(x_n)+\cdots=0

Neglecting h2h^2 and higher terms:

h≈−f(xn)f′(xn)h\approx-\frac{f(x_n)}{f'(x_n)}

so the improved estimate is

xn+1=xn−f(xn)f′(xn),f′(xn)≠0x_{n+1}=x_n-\frac{f(x_n)}{f'(x_n)},\qquad f'(x_n)\ne0

Geometrically, xn+1x_{n+1} is where the tangent to y=f(x)y=f(x) at (xn,f(xn))(x_n,f(x_n)) cuts the xx-axis. Convergence is quadratic near a simple root.

Solution of x2−5x+6=0x^2-5x+6=0

f(x)=x2−5x+6f(x)=x^2-5x+6, f′(x)=2x−5f'(x)=2x-5, so

xn+1=xn−xn2−5xn+62xn−5x_{n+1}=x_n-\frac{x_n^2-5x_n+6}{2x_n-5}

Take x0=0x_0=0 (note f(0)=6>0f(0)=6>0, and f(2)=0f(2)=0 lies to the right).

nnxnx_nf(xn)f(x_n)f′(xn)f'(x_n)xn+1x_{n+1}
00.0006.000−5.000-5.0001.200
11.2001.440−2.600-2.6001.754
21.7540.307−1.492-1.4921.959
31.9590.043−1.082-1.0821.998
41.9980.002−1.004-1.0042.000
52.0000.000−1.000-1.0002.000

Two successive values agree to three decimals, so one root is x=2.000x=2.000.

The other root is found by starting on the other side, e.g. x0=4x_0=4: x1=4−23=3.333x_1=4-\frac{2}{3}=3.333, x2=3.067x_2=3.067, x3=3.004x_3=3.004, x4=3.000x_4=3.000. Hence the roots are x=2x=2 and x=3x=3, which agree with the factorisation (x−2)(x−3)=0(x-2)(x-3)=0.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2081 · 10 marks

What are the limitations of direct methods for solving a system of linear equations? How Gauss Seidel method differs from Jacobi iteration? Solve the following system of linear equation using Jacobi iteration method. 2x-7y-10z=-17 5x+y+3z=14 x+10y+9z=7

Answer

Limitations of direct methods (Gauss elimination, Gauss-Jordan, LU):

  • Cost grows as O(n3)O(n^3) operations, which is very large for big systems.
  • Round-off errors accumulate through the many elimination steps; without pivoting a small or zero pivot can ruin the result, and ill-conditioned systems amplify the error.
  • For large sparse systems (as arise from PDEs) elimination causes fill-in: zeros become non-zeros, so memory and time are wasted.
  • The coefficient matrix is modified and the method cannot make use of a good initial guess; there is no way to improve a solution cheaply.

Gauss-Seidel versus Jacobi.

JacobiGauss-Seidel
Every new component is computed only from values of the previous iteration: xi(k+1)=1aii(bi−∑j≠iaijxj(k))x^{(k+1)}_i=\frac1{a_{ii}}\big(b_i-\sum_{j\ne i}a_{ij}x_j^{(k)}\big)Uses the latest available values, including components already updated in the current iteration: xi(k+1)=1aii(bi−∑j<iaijxj(k+1)−∑j>iaijxj(k))x_i^{(k+1)}=\frac1{a_{ii}}\big(b_i-\sum_{j<i}a_{ij}x_j^{(k+1)}-\sum_{j>i}a_{ij}x_j^{(k)}\big)
Slower convergence (simultaneous displacement)Usually about twice as fast (successive displacement)
Needs two copies of the vector; easily parallelisedNeeds one copy, sequential

Both need a diagonally dominant matrix (or similar) to guarantee convergence.

Solution by Jacobi iteration. The given order is not diagonally dominant, so the equations are rearranged:

5x+y+3z=14,x+10y+9z=7,2x−7y−10z=−175x+y+3z=14,\qquad x+10y+9z=7,\qquad 2x-7y-10z=-17

(Row 1: 5>1+35>1+3; row 2: 10≥1+910\ge1+9; row 3: 10>2+710>2+7.) Then

x=14−y−3z5,y=7−x−9z10,z=17+2x−7y10  (from −10z=−17−2x+7y)x=\frac{14-y-3z}{5},\qquad y=\frac{7-x-9z}{10},\qquad z=\frac{17+2x-7y}{10}\ \ \text{(from }-10z=-17-2x+7y)

Start from (x,y,z)=(0,0,0)(x,y,z)=(0,0,0), using only previous-iteration values:

Iterationxxyyzz
12.8000.7001.700
21.640−1.110-1.1101.770
31.960−1.057-1.0572.805
41.328−2.021-2.0212.832
51.505−1.982-1.9823.380
81.086−2.737-2.7373.679
121.023−2.930-2.9303.912
151.020−2.960-2.9603.977

The iterates approach (slowly, because the dominance is weak) the exact solution

x=1,y=−3,z=4x=1,\qquad y=-3,\qquad z=4

which satisfies all three equations: 2(1)−7(−3)−10(4)=2+21−40=−172(1)-7(-3)-10(4)=2+21-40=-17, 5+(−3)+12=145+(-3)+12=14, 1−30+36=71-30+36=7.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2081 · 10 marks

Write an algorithm and program to implement Lagrange interpolation method.

Answer

Lagrange interpolation. For n+1n+1 points (xi,yi)(x_i,y_i) the interpolating polynomial is

P(x)=∑i=0nyiLi(x),Li(x)=∏j=0j≠inx−xjxi−xjP(x)=\sum_{i=0}^{n}y_iL_i(x),\qquad L_i(x)=\prod_{\substack{j=0\\j\ne i}}^{n}\frac{x-x_j}{x_i-x_j}

Each Li(xk)=1L_i(x_k)=1 if k=ik=i and 00 otherwise, so P(xk)=ykP(x_k)=y_k. The nodes need not be equally spaced, but must be distinct.

Algorithm

  1. Start.
  2. Read the number of data points nn and the values xi,yix_i,y_i for i=0..n−1i=0..n-1.
  3. Read the value xpxp at which ff is to be interpolated.
  4. Set sum=0sum=0.
  5. For i=0i=0 to n−1n-1:
    1. set term=yiterm=y_i;
    2. for j=0j=0 to n−1n-1, if j≠ij\ne i: term=term×(xp−xj)/(xi−xj)term=term\times(xp-x_j)/(x_i-x_j);
    3. sum=sum+termsum=sum+term.
  6. Print sumsum as f(xp)f(xp).
  7. Stop.

Program (C)

#include <stdio.h>

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

    printf("Enter number of data points: ");
    scanf("%d", &n);

    printf("Enter the values of x and y:\n");
    for (i = 0; i < n; i++)
        scanf("%f %f", &x[i], &y[i]);

    printf("Enter the value of x for interpolation: ");
    scanf("%f", &xp);

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

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

Sample: for points (1,1),(2,4),(3,9)(1,1),(2,4),(3,9) and xp=2.5xp=2.5 the program prints 6.25006.2500, as expected from y=x2y=x^2.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2081 · 5 marks

Consider the following data points estimate the f(0.6) using Newton’s interpolation formula.
x0.10.20.30.40.5
f(x)2.683.043.383.693.97

Answer

Since x=0.6x=0.6 lies just beyond the last tabulated point xn=0.5x_n=0.5, Newton's backward difference formula is the appropriate one (it is used here as an extrapolation).

Backward difference table (h=0.1h=0.1):

xxf(x)f(x)∇f\nabla f∇2f\nabla^2f∇3f\nabla^3f∇4f\nabla^4f
0.12.68
0.23.040.36
0.33.380.34−0.02-0.02
0.43.690.31−0.03-0.03−0.01-0.01
0.53.970.28−0.03-0.030.000.01

f(x)=fn+p∇fn+p(p+1)2!∇2fn+p(p+1)(p+2)3!∇3fn+p(p+1)(p+2)(p+3)4!∇4fnf(x)=f_n+p\nabla f_n+\frac{p(p+1)}{2!}\nabla^2f_n+\frac{p(p+1)(p+2)}{3!}\nabla^3f_n+\frac{p(p+1)(p+2)(p+3)}{4!}\nabla^4f_n

p=0.6−0.50.1=1p=\frac{0.6-0.5}{0.1}=1

  • p∇fn=0.28p\nabla f_n=0.28
  • 1⋅22(−0.03)=−0.03\dfrac{1\cdot2}{2}(-0.03)=-0.03
  • 1⋅2⋅36(0.00)=0\dfrac{1\cdot2\cdot3}{6}(0.00)=0
  • 1⋅2⋅3⋅424(0.01)=0.01\dfrac{1\cdot2\cdot3\cdot4}{24}(0.01)=0.01

f(0.6)=3.97+0.28−0.03+0+0.01=4.23f(0.6)=3.97+0.28-0.03+0+0.01=4.23

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2081 · 5 marks

What is regression analysis? Fit a second order polynomial for the following data values.
x246810
y1.42.02.42.62.8

Answer

Regression analysis. It is a statistical/numerical technique for finding a mathematical relationship between a dependent variable yy and one or more independent variables xx from observed data that contain error. A curve (line, polynomial, etc.) is chosen so that it passes close to, rather than exactly through, the points; the commonest criterion is the least-squares one, which minimises S=∑(yi−f(xi))2S=\sum(y_i-f(x_i))^2. The fitted curve is then used to predict yy for other xx.

Second-order polynomial y=a+bx+cx2y=a+bx+cx^2. Normal equations:

∑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
21.448162.85.6
42.016642568.032.0
62.436216129614.486.4
82.664512409620.8166.4
102.810010001000028.0280.0
3011.222018001566474.0570.4

5a+30b+220c=11.25a+30b+220c=11.2 30a+220b+1800c=7430a+220b+1800c=74 220a+1800b+15664c=570.4220a+1800b+15664c=570.4

Eliminating aa: (2nd −6×-6\times1st) gives 40b+480c=6.840b+480c=6.8; (3rd −44×-44\times1st) gives 480b+5984c=77.6480b+5984c=77.6. From the first, b=0.17−12cb=0.17-12c; substituting: 81.6−5760c+5984c=77.6⇒224c=−4⇒c=−0.01785781.6-5760c+5984c=77.6\Rightarrow224c=-4\Rightarrow c=-0.017857. Then b=0.17+0.214286=0.384286b=0.17+0.214286=0.384286, and a=(11.2−30b−220c)/5=(11.2−11.5286+3.9286)/5=0.72a=(11.2-30b-220c)/5=(11.2-11.5286+3.9286)/5=0.72.

y=0.72+0.3843x−0.01786x2y=0.72+0.3843x-0.01786x^2

Check at x=6x=6: 0.72+2.3057−0.6429=2.383≈2.40.72+2.3057-0.6429=2.383\approx2.4.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2081 · 5 marks

What is numerical differentiation? The table below gives the values of distance travelled by a vehicle at various time interval, estimate the velocity and acceleration at x = 4.
Time(x)124810
Distance(y)0152127

Answer

Numerical differentiation. It is the process of estimating the derivatives of a function from a set of its tabulated values, without an analytical expression. The data are fitted by an interpolating polynomial Pn(x)P_n(x) and f′(x)≈Pn′(x)f'(x)\approx P_n'(x), f′′(x)≈Pn′′(x)f''(x)\approx P_n''(x). It is used when ff is known only at discrete points or is too complicated to differentiate.

Estimate at x=4x=4. The time points are unequally spaced, so Newton's divided-difference polynomial is used. Velocity is dy/dxdy/dx and acceleration is d2y/dx2d^2y/dx^2.

Divided differences (nodes 1,2,4,8,101,2,4,8,10):

xxyy1st2nd3rd4th
10
211
4521/3
82141/30
10273−1/6-1/6−1/16-1/16−1/144-1/144

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

Velocity. Differentiating term by term and putting x=4x=4:

  • first term: 11
  • second term: 13[(x−2)+(x−1)]=13(2+3)=53\tfrac13[(x-2)+(x-1)]=\tfrac13(2+3)=\tfrac53
  • third term: 00
  • fourth term: since (x−4)(x-4) is a factor, the derivative at x=4x=4 is −1144(x−1)(x−2)(x−8)=−1144(3)(2)(−4)=24144=16-\tfrac1{144}(x-1)(x-2)(x-8)=-\tfrac{1}{144}(3)(2)(-4)=\tfrac{24}{144}=\tfrac16

y′(4)=1+53+16=176≈2.833y'(4)=1+\tfrac53+\tfrac16=\tfrac{17}{6}\approx2.833

Acceleration.

  • second term: 13⋅2=23\tfrac13\cdot2=\tfrac23
  • fourth term: with g=(x−4)hg=(x-4)h, h=(x−1)(x−2)(x−8)h=(x-1)(x-2)(x-8), g′′(4)=2h′(4)g''(4)=2h'(4) and h′(4)=(2)(−4)+(3)(−4)+(3)(2)=−14h'(4)=(2)(-4)+(3)(-4)+(3)(2)=-14, so g′′(4)=−28g''(4)=-28 and the term is −1144(−28)=736-\tfrac{1}{144}(-28)=\tfrac{7}{36}

y′′(4)=23+736=3136≈0.861y''(4)=\tfrac23+\tfrac7{36}=\tfrac{31}{36}\approx0.861

So the velocity at x=4x=4 is about 2.832.83 and the acceleration about 0.860.86 (distance units per time and per time2^2).

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2081 · 5 marks

What is an application of numerical integration? Find the value of the integral
∫12exx dx\int_1^2 \frac{e^x}{x} \, dx using Simpson’s 38\frac{3}{8} rule with n=6n = 6.

Answer

Application of numerical integration. It is used when the integral ∫abf(x) dx\int_a^bf(x)\,dx cannot be found analytically (e.g. ∫ex/x dx\int e^{x}/x\,dx has no elementary form) or when ff is known only at tabulated points. Typical uses are the area under a curve from survey or experimental data, work done by a variable force, the distance travelled from velocity readings, and probability (area under a distribution curve).

Simpson's 3/8 rule (for nn a multiple of 3):

∫abf dx≈3h8[f0+fn+3(f1+f2+f4+f5+⋯ )+2(f3+f6+⋯ )]\int_a^bf\,dx\approx\frac{3h}{8}\Big[f_0+f_n+3(f_1+f_2+f_4+f_5+\cdots)+2(f_3+f_6+\cdots)\Big]

Here a=1, b=2, n=6a=1,\ b=2,\ n=6, so h=2−16=16=0.16667h=\dfrac{2-1}{6}=\dfrac16=0.16667.

iixix_if(xi)=exi/xif(x_i)=e^{x_i}/x_i
01.00002.71828
11.16672.75252
21.33332.84525
31.50002.98779
41.66673.17669
51.83333.41166
62.00003.69453
  • f0+f6=2.71828+3.69453=6.41281f_0+f_6=2.71828+3.69453=6.41281
  • 3(f1+f2+f4+f5)=3(2.75252+2.84525+3.17669+3.41166)=3(12.18612)=36.558363(f_1+f_2+f_4+f_5)=3(2.75252+2.84525+3.17669+3.41166)=3(12.18612)=36.55836
  • 2f3=5.975582f_3=5.97558

Sum =48.94675=48.94675.

I=3(1/6)8×48.94675=0.0625×48.94675=3.0592I=\frac{3(1/6)}{8}\times48.94675=0.0625\times48.94675=3.0592

So ∫12exxdx≈3.059\displaystyle\int_1^2\frac{e^x}{x}dx\approx3.059.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2081 · 5 marks

Given the data points below
X1.03.04.0
f(x)1.54.59.0
Find cubic spline which belongs to 1<=x<=3 and estimate f(2) using cubic splines.

Answer

Nodes: x0=1, x1=3, x2=4x_0=1,\ x_1=3,\ x_2=4 with f0=1.5, f1=4.5, f2=9.0f_0=1.5,\ f_1=4.5,\ f_2=9.0; h0=2, h1=1h_0=2,\ h_1=1. No end conditions are given, so the natural spline (M0=M2=0M_0=M_2=0, where Mi=S′′(xi)M_i=S''(x_i)) is used.

Equation for the interior moment.

h0M0+2(h0+h1)M1+h1M2=6[f2−f1h1−f1−f0h0]h_0M_0+2(h_0+h_1)M_1+h_1M_2=6\left[\frac{f_2-f_1}{h_1}-\frac{f_1-f_0}{h_0}\right]

0+2(3)M1+0=6[4.51−32]=6(4.5−1.5)=18⇒M1=30+2(3)M_1+0=6\left[\frac{4.5}{1}-\frac{3}{2}\right]=6(4.5-1.5)=18\Rightarrow M_1=3

Cubic on [1,3][1,3]:

S(x)=M0(x1−x)3+M1(x−x0)36h0+(f0h0−M0h06)(x1−x)+(f1h0−M1h06)(x−x0)S(x)=\frac{M_0(x_1-x)^3+M_1(x-x_0)^3}{6h_0}+\left(\frac{f_0}{h_0}-\frac{M_0h_0}{6}\right)(x_1-x)+\left(\frac{f_1}{h_0}-\frac{M_1h_0}{6}\right)(x-x_0)

S(x)=3(x−1)312+(1.52)(3−x)+(4.52−1)(x−1)S(x)=\frac{3(x-1)^3}{12}+\left(\frac{1.5}{2}\right)(3-x)+\left(\frac{4.5}{2}-1\right)(x-1)

S(x)=0.25(x−1)3+0.75(3−x)+1.25(x−1)=0.25(x−1)3+0.5x+1,1≤x≤3S(x)=0.25(x-1)^3+0.75(3-x)+1.25(x-1)=0.25(x-1)^3+0.5x+1,\qquad1\le x\le3

Check: S(1)=1.5S(1)=1.5 and S(3)=2+1.5+1=4.5S(3)=2+1.5+1=4.5.

Estimate at x=2x=2:

f(2)≈S(2)=0.25(1)3+1+1=2.25f(2)\approx S(2)=0.25(1)^3+1+1=2.25

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2081 · 5 marks

What is differential equation? Differentiate between ODE and PDE with example.

Answer

Differential equation. An equation that contains an unknown function and its derivatives with respect to one or more independent variables. Example: dydx=3x2\dfrac{dy}{dx}=3x^2. Its order is that of the highest derivative and its degree is the power of that derivative. A solution is a function that satisfies the equation (general solution has arbitrary constants; extra conditions fix them).

ODE versus PDE.

Ordinary differential equation (ODE)Partial differential equation (PDE)
Unknown function depends on a single independent variable.Unknown function depends on two or more independent variables.
Contains ordinary derivatives dy/dxdy/dx.Contains partial derivatives ∂u/∂x, ∂u/∂t\partial u/\partial x,\ \partial u/\partial t.
Conditions: initial value or boundary value at points.Conditions on boundaries (curves/surfaces) and initial profiles.
Methods: Euler, Taylor, Runge-Kutta, shooting.Methods: finite difference, finite element.

Examples:

  • ODE: d2ydx2+y=0\dfrac{d^2y}{dx^2}+y=0, or Newton's cooling law dTdt=−k(T−T0)\dfrac{dT}{dt}=-k(T-T_0).
  • PDE: Laplace equation ∂2u∂x2+∂2u∂y2=0\dfrac{\partial^2u}{\partial x^2}+\dfrac{\partial^2u}{\partial y^2}=0, heat equation ∂u∂t=α∂2u∂x2\dfrac{\partial u}{\partial t}=\alpha\dfrac{\partial^2u}{\partial x^2}, wave equation ∂2u∂t2=c2∂2u∂x2\dfrac{\partial^2u}{\partial t^2}=c^2\dfrac{\partial^2u}{\partial x^2}.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2081 · 5 marks

Solve dydx=xy,y(0)=1\frac{dy}{dx} = \frac{x}{y}, \quad y(0) = 1, at x=0.4x = 0.4 using Runge–Kutta’s 4th4^{\text{th}} order method.

Answer

dydx=f(x,y)=xy\dfrac{dy}{dx}=f(x,y)=\dfrac xy, x0=0x_0=0, y0=1y_0=1. The step size is not given, so take h=0.2h=0.2 (two steps to reach x=0.4x=0.4).

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) ynew=y+16(k1+2k2+2k3+k4)y_{new}=y+\tfrac16(k_1+2k_2+2k_3+k_4)

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

  • k1=0.2⋅01=0k_1=0.2\cdot\dfrac01=0
  • k2=0.2⋅0.11=0.02k_2=0.2\cdot\dfrac{0.1}{1}=0.02
  • k3=0.2⋅0.11.01=0.019802k_3=0.2\cdot\dfrac{0.1}{1.01}=0.019802
  • k4=0.2⋅0.21.019802=0.039223k_4=0.2\cdot\dfrac{0.2}{1.019802}=0.039223

y(0.2)=1+16(0+0.04+0.039604+0.039223)=1+0.019805=1.019805y(0.2)=1+\tfrac16(0+0.04+0.039604+0.039223)=1+0.019805=1.019805

Step 2 (x=0.2, y=1.019805x=0.2,\ y=1.019805):

  • k1=0.2⋅0.21.019805=0.039223k_1=0.2\cdot\dfrac{0.2}{1.019805}=0.039223
  • k2=0.2⋅0.31.039416=0.057725k_2=0.2\cdot\dfrac{0.3}{1.039416}=0.057725
  • k3=0.2⋅0.31.048668=0.057215k_3=0.2\cdot\dfrac{0.3}{1.048668}=0.057215
  • k4=0.2⋅0.41.077020=0.074279k_4=0.2\cdot\dfrac{0.4}{1.077020}=0.074279

y(0.4)=1.019805+16(0.039223+0.115450+0.114431+0.074279)=1.019805+0.057231=1.07703y(0.4)=1.019805+\tfrac16(0.039223+0.115450+0.114431+0.074279)=1.019805+0.057231=1.07703

y(0.4)≈1.0770y(0.4)\approx1.0770

Check: the exact solution is y2=x2+1y^2=x^2+1, giving y(0.4)=1.16=1.07703y(0.4)=\sqrt{1.16}=1.07703.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2081 · 5 marks

Solve the Poisson equation
∂2u∂x2+∂2u∂y2=−64xy,0≤x≤1,  0≤y≤1\frac{\partial^2 u}{\partial x^2} + \frac{\partial^2 u}{\partial y^2} = -64xy, \quad 0 \leq x \leq 1,\; 0 \leq y \leq 1 with boundary conditions:
u(0,y)=0,u(x,0)=0,u(1,y)=150,u(x,1)=150andh=13.u(0, y) = 0,\quad u(x, 0) = 0,\quad u(1, y) = 150,\quad u(x, 1) = 150 \quad \text{and} \quad h = \frac{1}{3}.

Answer

Setting up. With h=13h=\tfrac13 the grid is xi,yj∈{0,13,23,1}x_i,y_j\in\{0,\tfrac13,\tfrac23,1\} and the interior points are (13,13),(23,13),(13,23),(23,23)(\tfrac13,\tfrac13),(\tfrac23,\tfrac13),(\tfrac13,\tfrac23),(\tfrac23,\tfrac23). The five-point formula for ∇2u=g\nabla^2u=g is

ui+1,j+ui−1,j+ui,j+1+ui,j−1−4ui,j=h2g(xi,yj),g=−64xy, h2=19u_{i+1,j}+u_{i-1,j}+u_{i,j+1}+u_{i,j-1}-4u_{i,j}=h^2g(x_i,y_j),\qquad g=-64xy,\ h^2=\tfrac19

Let u1=u(13,13), u2=u(23,13), u3=u(13,23), u4=u(23,23)u_1=u(\tfrac13,\tfrac13),\ u_2=u(\tfrac23,\tfrac13),\ u_3=u(\tfrac13,\tfrac23),\ u_4=u(\tfrac23,\tfrac23). Boundary: u=0u=0 on x=0x=0 and y=0y=0; u=150u=150 on x=1x=1 and y=1y=1.

Right-hand sides h2g=−649xyh^2g=-\tfrac{64}{9}xy:

  • (13,13)(\tfrac13,\tfrac13): −6481=−0.7901-\tfrac{64}{81}=-0.7901
  • (23,13)(\tfrac23,\tfrac13) and (13,23)(\tfrac13,\tfrac23): −12881=−1.5802-\tfrac{128}{81}=-1.5802
  • (23,23)(\tfrac23,\tfrac23): −25681=−3.1605-\tfrac{256}{81}=-3.1605

Equations

  • u1u_1: u2+u3+0+0−4u1=−0.7901⇒−4u1+u2+u3=−0.7901u_2+u_3+0+0-4u_1=-0.7901\Rightarrow-4u_1+u_2+u_3=-0.7901
  • u2u_2: u1+u4+150+0−4u2=−1.5802⇒u1−4u2+u4=−151.5802u_1+u_4+150+0-4u_2=-1.5802\Rightarrow u_1-4u_2+u_4=-151.5802
  • u3u_3: u1+u4+0+150−4u3=−1.5802⇒u1−4u3+u4=−151.5802u_1+u_4+0+150-4u_3=-1.5802\Rightarrow u_1-4u_3+u_4=-151.5802
  • u4u_4: u2+u3+150+150−4u4=−3.1605⇒u2+u3−4u4=−303.1605u_2+u_3+150+150-4u_4=-3.1605\Rightarrow u_2+u_3-4u_4=-303.1605

By symmetry u2=u3u_2=u_3:

−4u1+2u2=−0.7901,u1−4u2+u4=−151.5802,2u2−4u4=−303.1605-4u_1+2u_2=-0.7901,\qquad u_1-4u_2+u_4=-151.5802,\qquad 2u_2-4u_4=-303.1605

From the first, u1=0.5u2+0.1975u_1=0.5u_2+0.1975. From the third, u4=0.5u2+75.7901u_4=0.5u_2+75.7901. Substituting into the second:

0.5u2+0.1975−4u2+0.5u2+75.7901=−151.5802⇒−3u2=−227.5678⇒u2=75.8560.5u_2+0.1975-4u_2+0.5u_2+75.7901=-151.5802\Rightarrow-3u_2=-227.5678\Rightarrow u_2=75.856

Then u1=38.126u_1=38.126 and u4=113.718u_4=113.718.

u(13,13)≈38.13,u(23,13)=u(13,23)≈75.86,u(23,23)≈113.72u(\tfrac13,\tfrac13)\approx38.13,\quad u(\tfrac23,\tfrac13)=u(\tfrac13,\tfrac23)\approx75.86,\quad u(\tfrac23,\tfrac23)\approx113.72

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

Questions from TU BSc CSIT 2075 Third Semester Numerical Method (TU IOST board exam, 2075), TU BSc CSIT 2077 Third Semester Numerical Method (TU IOST board exam, 2077), TU BSc CSIT 2078 Third Semester Numerical Method (TU IOST board exam, 2078), TU BSc CSIT 2079 Third Semester Numerical Method (TU IOST board exam, 2079), TU BSc CSIT 2080 Third Semester Numerical Method (TU IOST board exam, 2080), TU BSc CSIT 2081 Third Semester Numerical Method (TU IOST board exam, 2081), TU BSc CSIT 2075 Third Semester Computer Architecture (TU IOST board exam, 2075), TU BSc CSIT 2077 Third Semester Computer Architecture (TU IOST board exam, 2077), TU BSc CSIT 2078 Third Semester Computer Architecture (TU IOST board exam, 2078), TU BSc CSIT 2079 Third Semester Computer Architecture (TU IOST board exam, 2079), TU BSc CSIT 2080 Third Semester Computer Architecture (TU IOST board exam, 2080), TU BSc CSIT 2081 Third Semester Computer Architecture (TU IOST board exam, 2081), TU BSc CSIT 2075 Third Semester Computer Graphics (TU IOST board exam, 2075), TU BSc CSIT 2077 Third Semester Computer Graphics (TU IOST board exam, 2077), TU BSc CSIT 2078 Third Semester Computer Graphics (TU IOST board exam, 2078), TU BSc CSIT 2079 Third Semester Computer Graphics (TU IOST board exam, 2079), TU BSc CSIT 2080 Third Semester Computer Graphics (TU IOST board exam, 2080), TU BSc CSIT 2081 Third Semester Computer Graphics (TU IOST board exam, 2081), TU BSc CSIT 2082 Third Semester Computer Graphics (TU IOST board exam, 2082), TU BSc CSIT 2074 Third Semester Data Structures and Algorithms (TU IOST board exam, 2074), TU BSc CSIT 2075 Third Semester Data Structures and Algorithms (TU IOST board exam, 2075), TU BSc CSIT 2077 Third Semester Data Structures and Algorithms (TU IOST board exam, 2077), TU BSc CSIT 2078 Third Semester Data Structures and Algorithms (TU IOST board exam, 2078), TU BSc CSIT 2079 Third Semester Data Structures and Algorithms (TU IOST board exam, 2079), TU BSc CSIT 2080 Third Semester Data Structures and Algorithms (TU IOST board exam, 2080), TU BSc CSIT 2081 Third Semester Data Structures and Algorithms (TU IOST board exam, 2081), TU BSc CSIT 2075 Third Semester Statistics II (TU IOST board exam, 2075), TU BSc CSIT 2077 Third Semester Statistics II (TU IOST board exam, 2077), TU BSc CSIT 2078 Third Semester Statistics II (TU IOST board exam, 2078), TU BSc CSIT 2079 Third Semester Statistics II (TU IOST board exam, 2079), TU BSc CSIT 2080 Third Semester Statistics II (TU IOST board exam, 2080), TU BSc CSIT 2081 Third Semester Statistics II (TU IOST board exam, 2081) and TU BSc CSIT 2082 Third Semester Statistics II (TU IOST board exam, 2082). Answers are written for this site; check them against your class notes.