ข้อสอบเก่ามิดเทอม Numerical methods 2566/1

August 28, 2023

  1. เขียนโค้ด Graphical Methods ประสิทธิภาพสูง หาค่า 127/13127/13

  2. Find result of a program (Bisection xm=xl+xr3x_m = \dfrac{x_l + x_r}{3} [0,10][0,10] f(x)=12xf(x)=1-2x)

    #include <iostream> #include <math.h> using namespace std; double fx(double x) { return 1 - (2 * x); } double err(double xold, double xnew) { return fabs((xnew - xnew) / xnew) * 100; } int main() { double xl = 0.0, xr = 100.0, xm, ea, e = 0.000001, fxr, fxm; int iter = 0; do { iter += 1; xm = (xl + xr) / 3; fxr = fx(xr); fxm = fx(xm); if(fxr * fxm > 0) { ea = err(xr, xm); xr = xm; } else if(fxr * fxm < 0) { ea = err(xl, xm); xl = xm; } cout << iter << " " << xm << " " << ea << endl; } while(ea < e) return 0; }
    1. What result gonna be after iter 3?
    2. Will this code converge?
  3. One-point iteration methods หา iteration ที่ 5

    Givenf(x)=ex/4(2x)1x1=1.00\begin{align*} & Given \\ & f(x)=e^{-x/4}(2-x)-1 \\ & x_1 = 1.00 \end{align*}
    xxvaluevalue
    x1x_11.001.00
    x2x_20.71597460.7159746
    x3x_30.80398690.8039869
  4. Guass elimination

    [a11a12a13b10a22a23b200a33b3]\begin{bmatrix} a_{11} & a_{12} & a_{13} & | & b_{1} \\ 0 & a'_{22} & a'_{23} & | & b'_{2} \\ 0 & 0 & a''_{33} & | & b''_{3} \\ \end{bmatrix}
    1. Find x1x_1 as variable equation
    2. Back Substiution find b2b'_2 given some equation
  5. Linear algebra equation

    9x1+7x219x3=4000     14x113bx26x3=1200     16x1+x24x3=2350     { \begin{align*} \begin{equation} -9x_1 + 7x_2 - 19x_3 = 4000 \space\space\space\space\space \end{equation} \\ \begin{equation} 14x_1 - 13bx_2 - 6x_3 = 1200 \space\space\space\space\space \end{equation} \\ \begin{equation} 16x_1 + x_2 - 4x_3 = 2350 \space\space\space\space\space \end{equation} \\ \end{align*} }
    1. Cramer's rules
    2. Matrix inversion
    3. LU Decomposition