Skip to content
The Lumenary

Each worksheet prints cleanly on A4 or Letter. Answer keys are on a separate page.

The Lumenary · Early undergraduate

Numerical methods

Name: ______________________

Date: ______________________

You will learn to

  • Explain binary floating-point representation, machine epsilon and the unit roundoff, and prove that subtracting nearly equal numbers amplifies relative error (catastrophic cancellation)
  • Implement bisection and Newton's method, prove that bisection always converges for a continuous function with a sign change and that Newton's method converges quadratically near a simple root, and give examples where Newton fails
  • Define the order of convergence of an iterative method and estimate it from computed errors
  • Derive the error of polynomial interpolation and of difference quotients, and balance truncation error against rounding error
  • Implement the composite trapezoidal and Simpson rules and prove their error bounds O(h2)O(h^2) and O(h4)O(h^4) for smooth integrands
  1. 1.

    Bisection is started on [1,2][1, 2] to find 2\sqrt 2 as a root of x2−2x^2 - 2. After nn halvings we report the midpoint of the current interval. What is the smallest nn for which Theorem 3 guarantees an error of at most 10−610^{-6}?

  2. 2.

    Newton's method for x2−2x^2 - 2 is xn+1=12(xn+2xn)x_{n+1} = \frac12\left(x_n + \frac{2}{x_n}\right). Starting from x0=1x_0 = 1, compute exactly x1=32x_1 = \frac32, x2=1712x_2 = \frac{17}{12} and x3=pqx_3 = \frac{p}{q} in lowest terms. Enter the numerator pp.

  3. 3.

    For large xx (say x=1012x = 10^{12}), which formula computes x+1−x\sqrt{x + 1} - \sqrt{x} most accurately in floating point?

    • A.1x+1+x\dfrac{1}{\sqrt{x + 1} + \sqrt{x}}
    • B.x+1−x\sqrt{x + 1} - \sqrt{x}, as written
    • C.(x+1)−x\sqrt{(x + 1) - x}
    • D.x (1+1/x−1)\sqrt{x}\,\big(\sqrt{1 + 1/x} - 1\big)
  4. 4.

    Newton's method for f(x)=x3f(x) = \sqrt[3]{x} (the real cube root) gives xn+1=−2xnx_{n+1} = -2x_n and diverges from every x0≠0x_0 \ne 0, although f(0)=0f(0) = 0. Which hypothesis of Theorem 4 fails?

    • A.ff is not differentiable at the root 00 (its derivative blows up there), so it is not C2C^2 near the root.
    • B.The root is not simple: f′(0)=0f'(0) = 0.
    • C.The starting point is too far from the root.
    • D.ff is not continuous at 00.
  5. 5.

    Apply Simpson's rule with n=2n = 2 strips (h=2h = 2) to ∫04x3 dx\int_0^4 x^3\,dx. What value does it give?

  6. 6.

    Which statements are true? (Choose all that apply.)

    • A.The trapezoidal rule integrates every polynomial of degree ≤1\le 1 exactly.
    • B.Simpson's rule integrates x4x^4 exactly.
    • C.For a smooth integrand, halving hh divides the trapezoidal error by about 44.
    • D.Simpson's rule has error O(h4)O(h^4) for ∫01x dx\int_0^1 \sqrt x\,dx.
    • E.Simpson's rule with step h/2h/2 equals 4Th/2−Th3\frac{4T_{h/2} - T_h}{3}.
  7. 7.

    In binary64 arithmetic, approximately which step hh minimises the total error of the forward difference f(x+h)−f(x)h\frac{f(x + h) - f(x)}{h} for a typical smooth function with ff, f′′f'' of moderate size?

    • A.h≈10−8h \approx 10^{-8}
    • B.h≈10−16h \approx 10^{-16}, the unit roundoff
    • C.As small as possible: the error tends to 00 as h→0h \to 0.
    • D.h≈10−2h \approx 10^{-2}
  8. 8.

    With IsBinary64 x meaning "xx is a positive binary64 number", which Lean statement says that 2−522^{-52} is the gap between 11 and the next larger binary64 number?

    • A.IsBinary64 (1 + 2 ^ (-52 : ℤ)) ∧ ∀ x, IsBinary64 x → ¬ (1 < x ∧ x < 1 + 2 ^ (-52 : ℤ))
    • B.∀ x, IsBinary64 x → 1 + 2 ^ (-52 : ℤ) ≤ x
    • C.∃ x, IsBinary64 x ∧ 1 < x ∧ x < 1 + 2 ^ (-52 : ℤ)
    • D.∀ x, ¬ (1 < x ∧ x < 1 + 2 ^ (-52 : ℤ))
  9. 9.

    Write newton(f, df, x0, tol=1e-12, max_iter=50) that runs Newton's method and returns (x, n): the first iterate with abs(f(x)) <= tol and the number of steps taken. If a derivative is exactly 0, or max_iter steps pass without success, return (None, n).

    Computational — Practice

Code: Apache-2.0 · Content: CC BY-SA 4.0