---
title: Problem set 10
heading: "Problem set 10: numerical solutions and stiffness"
eyebrow: A8 · Problem set 10
type: problems
---

::: hook
These problems use lessons 45 and 46: stepping methods, their accuracy and order, and the stability limits that make stiff circuits hard. On the test equation $\dot y = -ay$, every method multiplies by a fixed factor per step, which makes its behavior easy to compute exactly.
:::

::: pool
pick: 12

::: check
kind: parts
given: a = 1 | 2; h = 0.1 | 0.05; N = 10 | 20

## Forward Euler steps $\dot y = -\given{a}y$ from $y = 1$ with $h$ = {h}.

::: part
answer: (1 - a*h)^N
tolerance: 0.5%

### What is $y$ after {N} steps?

::: misses
- [exp(-a*h*N)] That's the exact value.
- [any] Each step multiplies by $1 - ah$.
:::
:::

::: part
answer: exp(-a*h*N) - (1 - a*h)^N
tolerance: 1%

### What is the error?

::: misses
- [any] Exact minus computed.
:::
:::
:::

::: check
kind: parts
given: tau = 1 | 10 | 47

## A circuit's fastest time constant is {tau} µs.

::: part
answer: 2*tau
unit: µs
tolerance: 0.5%

### What is the largest stable forward Euler step?

::: misses
- [tau] Stable while $|1 - h/\tau| \le 1$, so up to $2\tau$.
- [any] Need $|1 + \lambda h| \le 1$ with $\lambda = -1/\tau$.
:::
:::
:::

::: check
kind: parts
given: a = 10 | 100; h = 0.1 | 0.5; N = 3 | 5

## Backward Euler steps $\dot y = -\given{a}y$ from 1 with $h$ = {h}.

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

### What factor does each step multiply by?

::: misses
- [1 - a*h] That's forward Euler.
- [any] $y_{n+1} = y_n - ahy_{n+1}$.
:::
:::

::: part
answer: (1/(1 + a*h))^N
tolerance: 0.5%

### What is $y$ after {N} steps?

::: misses
- [any] The factor to the power {N}.
:::
:::
:::

::: check
kind: parts
given: x = 0.5 | 4 | 20

## The trapezoidal rule steps $\dot y = -ay$ with $ah$ = {x}.

::: part
answer: (1 - x/2)/(1 + x/2)
tolerance: 0.5%

### What factor does each step multiply by?

::: misses
- [1/(1 + x)] That's backward Euler.
- [any] $\frac{1 - ah/2}{1 + ah/2}$.
:::
:::
:::

::: check
kind: parts
given: h = 0.1 | 0.5 | 1

## One RK4 step of size {h} on $\dot y = -y$ from 1.

::: part
answer: 1 - h + h^2/2 - h^3/6 + h^4/24
tolerance: 0.001%

### What does it give?

::: misses
- [any] RK4 reproduces $e^{-h}$ through the $h^4$ term.
:::
:::

::: part
answer: abs(exp(-h) - (1 - h + h^2/2 - h^3/6 + h^4/24))
tolerance: 2%

### How far is it from $e^{-h}$?

::: misses
- [any] About the first omitted term, $h^5/120$.
:::
:::
:::

::: check
kind: parts
given: r = 2 | 4 | 16

## Halving the step divides a method's error at a fixed time by {r}.

::: part
answer: log(r)/log(2)
tolerance: 0.5%

### What is the method's order?

::: misses
- [r] The error goes as $h^p$, so the ratio is $2^p$: take its base-2 logarithm.
- [any] $p = \log_2 r$.
:::
:::
:::

::: check
kind: parts
given: tf = 1 | 10; T = 1 | 5

## A circuit has a fast time constant of {tf} µs and must be simulated for {T} s.

::: part
answer: T*1e6/(2*tf)
tolerance: 0.5%

### At least how many forward Euler steps does that take?

::: misses
- [T*1e6/tf] The stability limit is $2\tau$, not $\tau$.
- [any] Total time divided by the largest stable step.
:::
:::
:::

::: check
kind: parts
given: x = 0.1 | 0.05; N = 100 | 1000

## Forward Euler steps the oscillator $\ddot y = -\omega^2y$ with $\omega h$ = {x}.

::: part
answer: sqrt(1 + x^2)
tolerance: 0.001%

### By what factor does the amplitude grow each step?

::: misses
- [1 + x^2] The magnitude of $1 + j\omega h$ is a square root.
- [any] $|1 \pm j\omega h|$.
:::
:::

::: part
answer: (1 + x^2)^(N/2)
tolerance: 0.5%

### By what factor after {N} steps?

::: misses
- [any] The per-step factor to the power {N}.
:::
:::
:::

::: check
kind: parts
given: e1 = 0.36 | 0.42; e2 = 0.365 | 0.43

## Euler gives {e1} with step $h$ and {e2} with step $h/2$ for the same quantity.

::: part
answer: 2*e2 - e1
tolerance: 0.5%

### What does Richardson extrapolation give?

::: misses
- [(e1 + e2)/2] For a first-order method the error halves with $h$, so extrapolate: $2E(h/2) - E(h)$.
- [any] $E(h/2) + (E(h/2) - E(h))$.
:::
:::
:::

::: check
kind: parts
given: h = 0.01 | 0.1 | 0.2

## One forward Euler step of size {h} on $\dot y = -y$ from 1.

::: part
answer: exp(-h) - (1 - h)
tolerance: 1%

### What is its local error?

::: misses
- [h^2] About $h^2/2$: half the second derivative times $h^2$.
- [any] Exact minus computed after one step.
:::
:::
:::

::: check
kind: parts
given: C1 = 1 | 2; C4 = 0.01 | 0.1; e = 0.000001 | 0.0001

## To reach error {e} at $t = 1$, Euler's error is about $\given{C1}h$ and RK4's about $\given{C4}h^4$.

::: part
answer: C1/e
tolerance: 1%

### How many Euler steps are needed?

::: misses
- [any] $h = e/C_1$, steps $= 1/h$.
:::
:::

::: part
answer: (C4/e)^0.25
tolerance: 1%

### How many RK4 steps?

::: misses
- [any] $h = (e/C_4)^{1/4}$.
:::
:::
:::

::: check
kind: parts
given: a = 10 | 50 | 100 | 500 | 1000 | 5000

## RK4 is stable on $\dot y = -\given{a}y$ for $ah$ up to about 2.785.

::: part
answer: 2.785/a
tolerance: 0.5%

### What is the largest stable step?

::: misses
- [2/a] That's forward Euler's limit; RK4 allows a little more.
- [any] $h = 2.785/a$.
:::
:::
:::

::: check
kind: parts
given: tau = 1 | 2; h = 0.5 | 2

## Backward Euler steps an RC circuit with $\tau$ = {tau} ms using $h$ = {h} ms.

::: part
answer: h/ln(1 + h/tau)
unit: ms
tolerance: 0.5%

### What time constant does the simulation actually show?

::: misses
- [tau] Backward Euler decays more slowly than the true circuit.
- [any] Each step multiplies by $\frac{1}{1 + h/\tau} = e^{-h/\tau_\text{eff}}$.
:::
:::
:::

::: check
kind: parts
given: x = 5 | 10 | 20 | 50 | 100 | 200

## The trapezoidal rule steps a fast mode with $ah$ = {x}.

::: part
answer: abs((1 - x/2)/(1 + x/2))
tolerance: 0.5%

### What is the size of its per-step factor?

::: misses
- [any] $\left|\frac{1 - ah/2}{1 + ah/2}\right|$, close to 1 for large $ah$.
:::
:::

::: part
answer: ceil(ln(0.01)/ln(abs((1 - x/2)/(1 + x/2))))
tolerance: 0

### How many steps until that mode's ringing falls below 1% of its start?

::: misses
- [any] The first $n$ with $|f|^n < 0.01$.
:::
:::
:::

::: check
kind: parts
given: h = 0.05 | 0.1 | 0.2 | 0.25 | 0.5 | 1

## Heun's method (RK2) steps $\dot y = -y$ from 1 with $h$ = {h}.

::: part
answer: 1 - h + h^2/2
tolerance: 0.001%

### What does one step give?

::: misses
- [1 - h] That's Euler; Heun's correction adds the $h^2/2$ term.
- [any] It matches $e^{-h}$ through $h^2$.
:::
:::
:::
:::
