---
title: Problem set 9
heading: "Problem set 9: fitting, optimization and ODEs"
eyebrow: A13 · Problem set 9
type: problems
---

::: hook
These problems use lessons 37 to 43: least squares and curve fitting, optimization, Runge–Kutta methods, adaptive step control, and stiffness with implicit methods.
:::

::: pool
pick: 12

::: check
kind: parts
given: k = 2 | 4 | 6

## Least squares with $\kappa(A) = 10^{\given{k}}$.

::: part
answer: 15.95 - k
tolerance: 1%

### About how many digits does QR keep?

::: misses
- [any] $15.95 - \log_{10}\kappa$.
:::
:::

::: part
answer: 15.95 - 2*k
tolerance: 1%

### And the normal equations?

::: misses
- [any] They square κ.
:::
:::
:::

::: check
kind: parts
given: a = 1 | 3; b = 2 | 5; c = 9 | 10

## The least-squares line through (0, {a}), (1, {b}), (2, {c}).

::: part
answer: (c - a)/2
tolerance: 0.1%

### What's its slope?

::: misses
- [any] $\frac{\sum(x - \bar x)(y - \bar y)}{\sum(x - \bar x)^2}$.
:::
:::

::: part
answer: (a + b + c)/3 - (c - a)/2
tolerance: 0.1%

### What's its intercept?

::: misses
- [any] $\bar y - \text{slope}\cdot\bar x$.
:::
:::
:::

::: check
kind: parts
given: s = 0.2 | 1; n = 8 | 15; S = 0.4 | 2

## Fit statistics.

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

### A line through {n} points at x = 0, 1, ... with noise σ = {s}: slope standard error?

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

::: part
answer: S/(n - 2)
tolerance: 0.5%

### That fit leaves SSR = {S}. What's the estimated σ²?

::: misses
- [any] SSR/(m − n) with 2 parameters.
:::
:::
:::

::: check
kind: parts
given: A = 3 | 6; tau = 1.5 | 4; t = 2 | 5

## The model $Ae^{-t/\tau}$ with A = {A}, τ = {tau}, at t = {t}.

::: part
answer: exp(-t/tau)
tolerance: 0.1%

### What's $\partial f/\partial A$?

::: misses
- [any] $e^{-t/\tau}$.
:::
:::

::: part
answer: A*t/tau^2*exp(-t/tau)
tolerance: 0.1%

### What's $\partial f/\partial\tau$?

::: misses
- [any] $\frac{At}{\tau^2}e^{-t/\tau}$.
:::
:::
:::

::: check
kind: parts
given: L = 3 | 10; d = 0.001 | 0.0000001; l = 20 | 400

## Searching and stepping.

::: part
answer: ceil(ln(d/L)/ln(0.6180339887))
tolerance: 0

### Golden-section evaluations to shrink a width-{L} bracket below {d}?

::: misses
- [any] Smallest n with $L(0.618)^n \le \delta$.
:::
:::

::: part
answer: 2/l
tolerance: 0.5%

### Gradient descent's stability limit when $\lambda_{max}$ = {l}?

::: misses
- [any] $2/\lambda_{max}$.
:::
:::
:::

::: check
kind: parts
given: a = 1 | 4; b = 50 | 500

## A quadratic with Hessian eigenvalues from {a} to {b}.

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

### What's the best fixed gradient-descent step?

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

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

### What factor per step does it achieve?

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

::: check
kind: parts
given: c = 4 | 10; x0 = 1 | 2

## Minimize $x^4 - \given{c}x$.

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

### One Newton step from {x0}?

::: misses
- [any] $x - f'/f''$.
:::
:::

::: part
answer: (c/4)^(1/3)
tolerance: 0.01%

### Where's the minimum?

::: misses
- [any] $4x^3 = c$.
:::
:::
:::

::: check
kind: parts
given: k = 4 | 10; h = 0.02 | 0.05; p = 2 | 4

## ODE steps.

::: part
answer: 1 - k*h
tolerance: 0.01%

### One Euler step on $\dot y = -\given{k}y$ from y = 1 with h = {h}?

::: misses
- [any] $1 - kh$.
:::
:::

::: part
answer: 3^p
tolerance: 0.5%

### An order-{p} method's step is divided by 3. By what factor does its global error shrink?

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

::: check
kind: parts
given: w = 0.05 | 0.1 | 0.2 | 0.25 | 0.3 | 0.5

## An undamped oscillator with $h\omega$ = {w}.

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

### Euler's amplitude growth per period?

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

::: part
answer: sqrt(1 + w^2)
tolerance: 0.01%

### Euler's growth per step?

::: misses
- [any] $\lvert 1 + jh\omega\rvert$.
:::
:::
:::

::: check
kind: parts
given: h = 4 | 20; e = 0.0000003 | 0.000006; t = 0.000001; at = 0.000001 | 0.0001; rt = 0.001 | 0.00001; y = 2 | 50

## Step control.

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

### Order-4 error {e} on a {h} µs step, tolerance {t}: next step?

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

::: part
answer: at + rt*y
tolerance: 0.5%

### With atol = {at}, rtol = {rt}, what's the tolerance at y = {y}?

::: misses
- [any] $\text{atol} + \text{rtol}\lvert y\rvert$.
:::
:::
:::

::: check
kind: parts
given: h = 20 | 100; t = 1 | 3

## Stiff mode with τ = {t} µs and step {h} µs.

::: part
answer: 1/(1 + h/t)
tolerance: 0.5%

### Backward Euler's factor per step?

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

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

### Trapezoidal rule's factor?

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

::: check
kind: parts
given: f = 0.00000001 | 0.000001; T = 0.001 | 0.1; C = 2.2 | 47; h = 1 | 10

## Explicit limits and companion models.

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

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

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

::: part
answer: C/h
unit: S
tolerance: 0.5%

### Backward-Euler companion conductance of {C} µF with a {h} µs step?

::: misses
- [any] $C/h$.
:::
:::
:::

::: check
kind: parts
given: k = 10 | 50 | 100 | 500 | 1000 | 2000

## AB2 integrates a mode decaying at {k} s⁻¹.

::: part
answer: 1/k
unit: s
tolerance: 0.5%

### Above what step does it go unstable?

::: misses
- [2/k] That's forward Euler's limit.
- [any] $h\lambda > -1$.
:::
:::
:::

::: check
kind: parts
given: C = 10 | 100; h = 1 | 5

## BDF2 steps a {C} nF capacitor with h = {h} ns.

::: part
answer: 3*C/(2*h)
unit: S
tolerance: 0.5%

### What is its companion conductance?

::: misses
- [C/h] That's backward Euler.
- [any] $\frac{3C}{2h}$.
:::
:::
:::

::: check
kind: parts
given: k = 2 | 3; B = 2 | 4

## Shooting on $y'' = \given{k}^2y$ with $y(0) = 0$ and $y(1) = \given{B}$.

::: part
answer: B*k/sinh(k)
tolerance: 0.5%

### What starting slope is needed?

::: misses
- [B/sinh(k)] The slope of $\sinh kx$ at 0 is k.
- [any] $\frac{Bk}{\sinh k}$.
:::
:::
:::
:::
