---
title: Final exam
heading: "Final exam: numerical methods"
eyebrow: A13 · Final exam
type: problems
---

::: hook
Twelve problems from the whole course: floating point and error, conditioning and stability, root finding, interpolation, differentiation and quadrature, direct and iterative linear solvers, eigenvalues, nonlinear systems, fitting and optimization, ODE integration with step control and stiffness, the FFT, Monte Carlo and sparse matrices. Give yourself three hours, work without the lessons open, and write out your reasoning before checking each answer. "Another set" deals a different exam.
:::

::: pool
pick: 12

::: check
kind: parts
given: p = 11 | 24; x = 9 | 600

## Formats.

::: part
answer: 2^p
tolerance: 0.01%

### Above what integer does a {p}-bit format first skip integers?

::: misses
- [any] $2^p$.
:::
:::

::: part
answer: 2^(floor(ln(x)/ln(2)) - 52)/x
tolerance: 0.5%

### What's the relative spacing of doubles at {x}?

::: misses
- [any] The spacing $2^{\lfloor\log_2x\rfloor - 52}$, divided by x.
:::
:::
:::

::: check
kind: parts
given: b = 10000000 | 400000000; c = 2 | 6; x = 1.05 | 20

## Cancellation and conditioning.

::: part
answer: 2*c/(b + sqrt(b^2 - 4*c))
tolerance: 0.5%

### The small root of $x^2 - \given{b}x + \given{c}$?

::: misses
- [any] $\frac{2c}{b + \sqrt{b^2 - 4c}}$.
:::
:::

::: part
answer: 1/abs(ln(x))
tolerance: 0.5%

### κ of $\ln x$ at {x}?

::: misses
- [any] $1/\lvert\ln x\rvert$.
:::
:::
:::

::: check
kind: parts
given: c = 2 | 6; a = 1 | 2; q = 2 | 3; let e0 = 10^(-a); let e1 = 10^(-a*q); let e2 = 10^(-a*q^2)

## Iterations.

::: part
answer: 1/((c + sqrt(c^2 + 4))/2)^2
tolerance: 0.5%

### Error factor of $x \leftarrow \given{c} + 1/x$?

::: misses
- [any] $1/x^{*2}$.
:::
:::

::: part
answer: ln(e2/e1)/ln(e1/e0)
tolerance: 1%

### Order of a method with errors {e0}, {e1}, {e2}?

::: misses
- [any] $\frac{\ln(e_2/e_1)}{\ln(e_1/e_0)}$.
:::
:::
:::

::: check
kind: parts
given: c = 3 | 7; x0 = 1 | 2

## Solve $x^3 = \given{c}$.

::: part
answer: x0 - (x0^3 - c)/(3*x0^2)
tolerance: 0.01%

### One Newton step from {x0}?

::: misses
- [any] $x_0 - \frac{x_0^3 - c}{3x_0^2}$.
:::
:::

::: part
answer: 2 - (8 - c)/7
tolerance: 0.01%

### One secant step from 1 and 2?

::: misses
- [any] $x_2 = 2 - f(2)\frac{2 - 1}{f(2) - f(1)}$.
:::
:::
:::

::: check
kind: parts
given: a = 1 | 3; b = 4 | 6; c = 2 | 8

## The points (0, {a}), (1, {b}), (2, {c}).

::: part
answer: -0.125*a + 0.75*b + 0.375*c
tolerance: 0.1%

### Interpolating quadratic at 1.5?

::: misses
- [any] Lagrange weights −0.125, 0.75, 0.375.
:::
:::

::: part
answer: 1.5*(a - 2*b + c)
tolerance: 0.1%

### $M_1$ of the natural spline?

::: misses
- [any] $4M_1 = 6(a - 2b + c)$.
:::
:::
:::

::: check
kind: parts
given: x = 1 | 3; h = 0.2 | 0.4; s = 1 | 3

## Derivatives of $x^3$, and noise.

::: part
answer: 3*x^2 + h^2
tolerance: 0.01%

### Central difference at {x} with h = {h}?

::: misses
- [any] $3x^2 + h^2$.
:::
:::

::: part
answer: sqrt(2)*s/h
unit: V/s
tolerance: 0.5%

### Differencing samples with {s} mV noise, {h} ms apart: noise in the derivative?

::: misses
- [any] $\sqrt2\,\sigma/h$.
:::
:::
:::

::: check
kind: parts
given: n = 3 | 6; L = 2 | 3; N = 20 | 80; M = 4 | 9

## Quadrature.

::: part
answer: 1/3 + 1/(6*n^2)
tolerance: 0.01%

### Trapezoid with {n} intervals for $\int_0^1x^2\,dx$?

::: misses
- [any] $\frac13 + \frac{1}{6n^2}$.
:::
:::

::: part
answer: L^5*M/(180*N^4)
tolerance: 0.5%

### Simpson's error bound on length {L}, {N} intervals, $\lvert f^{(4)}\rvert \le$ {M}?

::: misses
- [any] $\frac{(b - a)h^4}{180}M$.
:::
:::
:::

::: check
kind: parts
given: k = 6 | 10; c = 0.5 | 2

## Gauss rules.

::: part
answer: 2*(1/3)^(k/2)
tolerance: 0.1%

### 2-point Gauss for $\int_{-1}^1x^{\given{k}}\,dx$?

::: misses
- [any] $2(1/3)^{k/2}$.
:::
:::

::: part
answer: 5/9*(exp(-c*sqrt(0.6)) + exp(c*sqrt(0.6))) + 8/9
tolerance: 0.001%

### 3-point Gauss for $\int_{-1}^1e^{\given{c}x}\,dx$?

::: misses
- [any] $\frac59(e^{-c\sqrt{0.6}} + e^{c\sqrt{0.6}}) + \frac89$.
:::
:::
:::

::: check
kind: parts
given: n = 600 | 7000; k = 20 | 2000

## Direct solvers.

::: part
answer: 2*n^3/3 + 2*k*n^2
tolerance: 1%

### One LU of a dense {n} × {n} matrix and {k} solves: operations?

::: misses
- [any] $\frac23n^3 + 2kn^2$.
:::
:::

::: part
answer: 8*n^2/1e6
unit: MB
tolerance: 1%

### Its storage?

::: misses
- [any] 8 bytes per entry.
:::
:::
:::

::: check
kind: parts
given: N = 30 | 300; k = 100 | 1000000

## Iterative solvers.

::: part
answer: 2/(1 + sin(pi/N))
tolerance: 0.01%

### $\omega_{opt}$ for an {N} × {N} grid?

::: misses
- [any] $\frac{2}{1 + \sin(\pi/N)}$.
:::
:::

::: part
answer: (sqrt(k) - 1)/(sqrt(k) + 1)
tolerance: 0.01%

### CG's convergence factor for κ = {k}?

::: misses
- [any] $\frac{\sqrt\kappa - 1}{\sqrt\kappa + 1}$.
:::
:::
:::

::: check
kind: parts
given: l1 = 7 | -12; l2 = 3 | 6; a = 2 | 5; x = 2 | 4

## Eigenvalues.

::: part
answer: abs(l2/l1)
tolerance: 0.5%

### Power iteration's ratio for {l1} and {l2}?

::: misses
- [any] $\lvert\lambda_2/\lambda_1\rvert$.
:::
:::

::: part
answer: (a*x^2 + 2*x + a)/(x^2 + 1)
tolerance: 0.1%

### Rayleigh quotient of ({x}, 1) for ({a}, 1; 1, {a})?

::: misses
- [any] $\frac{v^TAv}{v^Tv}$.
:::
:::
:::

::: check
kind: parts
given: V = 0.58 | 0.66; x = 0.5 | 1; y = 1 | 2

## Nonlinear systems.

::: part
answer: 1e-14/0.02585*exp(V/0.02585)*1000
unit: mS
tolerance: 0.5%

### A diode's companion conductance at {V} V?

::: misses
- [any] $\frac{I_s}{nV_T}e^{V/nV_T}$.
:::
:::

::: part
answer: 2*x - 2*y*exp(x)
tolerance: 0.1%

### det J of $(x^2 + y^2 - 4,\; e^x + y - 1)$ at ({x}, {y})?

::: misses
- [any] $2x - 2ye^x$.
:::
:::
:::

::: check
kind: parts
given: s = 0.1 | 0.4; n = 10 | 30; a = 0.5 | 2; b = 40 | 400

## Fitting and optimization.

::: part
answer: s/sqrt(n*(n^2 - 1)/12)
tolerance: 0.5%

### Slope standard error for {n} points at x = 0, 1, ... with σ = {s}?

::: misses
- [any] $\sigma/\sqrt{n(n^2 - 1)/12}$.
:::
:::

::: part
answer: 2/(a + b)
tolerance: 0.5%

### Best fixed gradient-descent step for Hessian eigenvalues {a} to {b}?

::: misses
- [any] $\frac{2}{\lambda_{min} + \lambda_{max}}$.
:::
:::
:::

::: check
kind: parts
given: w = 0.05 | 0.2; h = 3 | 30; e = 0.0000002 | 0.000004; t = 0.000001

## ODE integration.

::: part
answer: (1 + w^2)^(pi/w)
tolerance: 0.5%

### Euler's amplitude growth per period on an oscillator with $h\omega$ = {w}?

::: misses
- [any] $(1 + h^2\omega^2)^{\pi/(h\omega)}$.
:::
:::

::: part
answer: h*0.9*(t/e)^(1/5)
unit: µs
tolerance: 0.5%

### Next RK45 step after err = {e} on {h} µs with tolerance {t}?

::: misses
- [any] $0.9h(\text{tol}/\text{err})^{1/5}$.
:::
:::
:::

::: check
kind: parts
given: f = 0.000000001 | 0.0000001; T = 0.01 | 0.5; h = 50 | 500; c = 2 | 8

## Stiffness.

::: part
answer: T/(2*f)
tolerance: 0.5%

### Fastest time constant {f} s: forward-Euler steps for {T} s?

::: misses
- [any] $T/(2\tau_{fast})$.
:::
:::

::: part
answer: (1 - h/(2*c))/(1 + h/(2*c))
tolerance: 0.5%

### Trapezoidal factor for τ = {c} µs at h = {h} µs?

::: misses
- [any] $\frac{1 - h/2\tau}{1 + h/2\tau}$.
:::
:::
:::

::: check
kind: parts
given: p = 12 | 18; s = 0.5 | 5; e = 0.01 | 0.001

## FFT and Monte Carlo.

::: part
answer: 2^p/2*p
tolerance: 0.5%

### Multiplications in a $2^{\given{p}}$-point FFT?

::: misses
- [any] $\frac N2\log_2N$.
:::
:::

::: part
answer: (s/e)^2
tolerance: 0.5%

### Monte Carlo samples for standard error {e} with s = {s}?

::: misses
- [any] $(s/\varepsilon)^2$.
:::
:::
:::
:::
