Course Test · University: upper level

Numerical analysis: independent answers

Each answer here was worked out by hand, without RatMath, before the RatMath code was written. Where the arithmetic is long, the working says how it was checked.

  1. 1.Floating point
    What exact rational number does the double nearest to 0.1 equal? What is machine epsilon (the gap from 1 to the next double)?
    Answer
    0.1=0.000110011…20.1 = 0.000110011\ldots_2; rounded to 53 significant bits it is 3602879701896397255\dfrac{3602879701896397}{2^{55}}, slightly above 0.1. Machine epsilon is 2−52≈2.22×10−162^{-52} \approx 2.22\times10^{-16}.
  2. 2.Catastrophic cancellation
    Evaluate x+1−x\sqrt{x + 1} - \sqrt{x} at x=1016x = 10^{16} in double precision. What goes wrong, and what is the true value?
    Answer
    1016+110^{16} + 1 rounds to 101610^{16}, so the computed difference is 0, with every digit lost. Rewriting as 1x+1+x≈5×10−9\dfrac{1}{\sqrt{x+1} + \sqrt x} \approx 5\times10^{-9} gives the true value.
  3. 3.Bisection
    Bisection on x2−2x^2 - 2 over [1,2][1, 2]: how many steps until the guaranteed error (b−a)/2n+1(b - a)/2^{n+1} is below 10−610^{-6}?
    Answer
    2−(n+1)<10−62^{-(n+1)} < 10^{-6} needs n+1≥20n + 1 \ge 20 (220=10485762^{20} = 1048576): 19 halvings, i.e. 20 midpoints counting the first, with bound 2−20≈9.54×10−72^{-20} \approx 9.54\times10^{-7}.
  4. 4.Newton's method
    Apply Newton's method to x2−2x^2 - 2 from x0=1x_0 = 1. Give x1,x2,x3x_1, x_2, x_3.
    Answer
    xk+1=12(xk+2/xk)x_{k+1} = \tfrac12(x_k + 2/x_k): 32\tfrac32, 1712\tfrac{17}{12}, 577408≈1.4142157\tfrac{577}{408} \approx 1.4142157. The correct digits roughly double each step.
  5. 5.Secant method
    Apply the secant method to x2−2x^2 - 2 from x0=1x_0 = 1, x1=2x_1 = 2. Give x2x_2 and x3x_3.
    Answer
    x2=2−2⋅2−12−(−1)=43x_2 = 2 - 2\cdot\dfrac{2 - 1}{2 - (-1)} = \tfrac43; x3=43−(−29)4/3−2−2/9−2=75x_3 = \tfrac43 - \left(-\tfrac29\right)\dfrac{4/3 - 2}{-2/9 - 2} = \tfrac75.
  6. 6.Fixed-point iteration
    For xk+1=cos⁡xkx_{k+1} = \cos x_k, by what factor does the error shrink each step near the fixed point?
    Answer
    ∣g′(x∗)∣=sin⁡x∗≈sin⁡0.7390851≈0.6736|g'(x^*)| = \sin x^* \approx \sin 0.7390851 \approx 0.6736: linear convergence with that ratio.
  7. 7.Interpolation
    Find the polynomial through (0,1)(0, 1), (1,3)(1, 3), (2,7)(2, 7) and evaluate it at 3.
    Answer
    Divided differences: 1; 2, 4; 1. p=1+2x+x(x−1)=x2+x+1p = 1 + 2x + x(x - 1) = x^2 + x + 1, p(3)=13p(3) = 13.
  8. 8.Natural cubic spline
    Find the natural cubic spline through (0,0)(0, 0), (1,1)(1, 1), (2,0)(2, 0) and its value at x=12x = \tfrac12.
    Answer
    With M0=M2=0M_0 = M_2 = 0: 4M1=6(0−2+0)=−124M_1 = 6(0 - 2 + 0) = -12, M1=−3M_1 = -3. On [0,1][0, 1]: S=−12x3+32xS = -\tfrac12x^3 + \tfrac32x, so S(12)=34−116=1116S(\tfrac12) = \tfrac34 - \tfrac1{16} = \tfrac{11}{16}.
  9. 9.Chebyshev nodes
    Give the three Chebyshev nodes on [−1,1][-1, 1].
    Answer
    cos⁡(2i+1)π6\cos\dfrac{(2i + 1)\pi}{6}: 32,0,−32≈±0.8660254\tfrac{\sqrt3}2, 0, -\tfrac{\sqrt3}2 \approx \pm0.8660254.
  10. 10.Least squares
    Fit a least-squares line to (0,1)(0, 1), (1,3)(1, 3), (2,4)(2, 4), (3,4)(3, 4).
    Answer
    xˉ=1.5\bar x = 1.5, yˉ=3\bar y = 3, Sxy=5S_{xy} = 5, Sxx=5S_{xx} = 5: slope 1, intercept 3−1.5=1.53 - 1.5 = 1.5. y=x+32y = x + \tfrac32.
  11. 11.Richardson extrapolation
    Estimate f′(0)f'(0) for f=exf = e^x with central differences at h=0.1h = 0.1 and h=0.05h = 0.05, then one Richardson step.
    Answer
    D(0.1)=e0.1−e−0.10.2≈1.0016675D(0.1) = \dfrac{e^{0.1} - e^{-0.1}}{0.2} \approx 1.0016675, D(0.05)≈1.0004167D(0.05) \approx 1.0004167. 4D(0.05)−D(0.1)3≈0.99999979\dfrac{4D(0.05) - D(0.1)}{3} \approx 0.99999979, error about 2×10−72\times10^{-7} instead of 4×10−44\times10^{-4}.
  12. 12.Trapezoid rule
    Approximate ∫01x2 dx\int_0^1 x^2\,dx by the trapezoid rule with 4 panels.
    Answer
    18(0+2⋅1+4+916+1)=1132=0.34375\tfrac18\left(0 + 2\cdot\tfrac{1 + 4 + 9}{16} + 1\right) = \tfrac{11}{32} = 0.34375 (exact 13\tfrac13).
  13. 13.Simpson's rule
    Apply Simpson's rule with one panel (three points) to ∫01x4 dx\int_0^1 x^4\,dx.
    Answer
    16(0+4⋅116+1)=524≈0.2083\tfrac16\left(0 + 4\cdot\tfrac1{16} + 1\right) = \tfrac{5}{24} \approx 0.2083 (exact 15\tfrac15).
  14. 14.Gaussian quadrature
    Apply two-point Gauss–Legendre quadrature to ∫−11x4 dx\int_{-1}^1 x^4\,dx.
    Answer
    Nodes ±1/3\pm1/\sqrt3, weights 1: 2⋅19=292\cdot\tfrac19 = \tfrac29 (exact 25\tfrac25; the rule is exact only up to degree 3).
  15. 15.Euler's method
    Use Euler's method with h=0.1h = 0.1 on y′=yy' = y, y(0)=1y(0) = 1, up to t=0.5t = 0.5.
    Answer
    Each step multiplies by 1.1: 1.15=1.610511.1^5 = 1.61051 (exact e0.5≈1.64872e^{0.5} \approx 1.64872).
  16. 16.Runge–Kutta
    Take one classical RK4 step of size 0.1 on y′=yy' = y, y(0)=1y(0) = 1.
    Answer
    1+h+h22+h36+h424=1.10517083‾1 + h + \tfrac{h^2}2 + \tfrac{h^3}6 + \tfrac{h^4}{24} = 1.1051708\overline3 (exact e0.1=1.1051709181e^{0.1} = 1.1051709181).
  17. 17.Stability
    For y′=−10yy' = -10y, what is the largest step for which Euler's method does not grow?
    Answer
    Each step multiplies by 1−10h1 - 10h; ∣1−10h∣≤1|1 - 10h| \le 1 needs h≤0.2h \le 0.2. The stability interval for hλh\lambda is [−2,0][-2, 0].
  18. 18.LU factorisation
    Factor A=(2143)A = \begin{pmatrix}2&1\\4&3\end{pmatrix} as LULU (no pivoting).
    Answer
    ℓ21=2\ell_{21} = 2: L=(1021)L = \begin{pmatrix}1&0\\2&1\end{pmatrix}, U=(2101)U = \begin{pmatrix}2&1\\0&1\end{pmatrix}.
  19. 19.Condition number
    Find κ∞\kappa_\infty of (1111.0001)\begin{pmatrix}1&1\\1&1.0001\end{pmatrix}.
    Answer
    ∥A∥∞=2.0001\|A\|_\infty = 2.0001; A−1=104(1.0001−1−11)A^{-1} = 10^4\begin{pmatrix}1.0001&-1\\-1&1\end{pmatrix}, ∥A−1∥∞=20001\|A^{-1}\|_\infty = 20001. κ=2.0001⋅20001=40004.0001\kappa = 2.0001\cdot20001 = 40004.0001.
  20. 20.Iterative methods and eigenvalues
    (a) Two Jacobi steps for 4x+y=14x + y = 1, x+3y=2x + 3y = 2 from (0,0)(0, 0). (b) The dominant eigenvalue of (2113)\begin{pmatrix}2&1\\1&3\end{pmatrix} by the power method.
    Answer
    (a) (14,23)(\tfrac14, \tfrac23), then (1−2/34,2−1/43)=(112,712)\left(\tfrac{1 - 2/3}{4}, \tfrac{2 - 1/4}{3}\right) = (\tfrac1{12}, \tfrac7{12}); the solution is (111,711)(\tfrac1{11}, \tfrac7{11}). (b) λ=5+52≈3.618034\lambda = \tfrac{5 + \sqrt5}{2} \approx 3.618034.