---
title: Problem set 3
heading: "Problem set 3: roots, interpolation and derivatives"
eyebrow: A13 · Problem set 3
type: problems
---

::: hook
These problems use lessons 6 to 15: Newton's and the secant method, order of convergence and safeguarding, polynomial interpolation, splines, and numerical and automatic differentiation.
:::

::: pool
pick: 12

::: check
kind: parts
given: a = 3 | 7 | 11; x0 = 2 | 3

## Newton's method for $\sqrt{\given{a}}$ from $x_0$ = {x0}.

::: part
answer: (x0 + a/x0)/2
tolerance: 0.01%

### What's $x_1$?

::: misses
- [any] $\frac12(x_0 + a/x_0)$.
:::
:::

::: part
answer: ((x0 + a/x0)/2 + a/((x0 + a/x0)/2))/2
tolerance: 0.01%

### What's $x_2$?

::: misses
- [any] Apply the same step to $x_1$.
:::
:::
:::

::: check
kind: parts
given: c = 2 | 10; 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}: what's $x_1$?

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

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

### Instead, one secant step from $x_0 = 1$ and $x_1 = 2$: what's $x_2$?

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

::: check
kind: parts
given: m = 2 | 3; C = 0.5 | 1.5; e = 0.01 | 0.001

## Rates of convergence.

::: part
answer: (m - 1)/m
tolerance: 0.5%

### Newton approaches a root of multiplicity {m}. By what factor does each step shrink the error?

::: misses
- [any] $(m - 1)/m$.
:::
:::

::: part
answer: C*e^2
tolerance: 0.5%

### At a simple root with $C = \given{C}$ and $e_n$ = {e}, what's $e_{n+1}$?

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

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

## A run's errors are {e0}, {e1}, {e2}.

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

### What's the order?

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

::: part
answer: e2^q
tolerance: 2%

### Assuming the same pattern, what's the next error?

::: misses
- [any] $e_3 = e_2^{\,p}$ here.
:::
:::
:::

::: check
kind: parts
given: p = 1.618 | 3; w = 1 | 2

## Efficiency.

::: part
answer: p^(1/w)
tolerance: 0.5%

### A method of order {p} costs {w} evaluations per step. What's its efficiency index?

::: misses
- [any] $p^{1/w}$.
:::
:::

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

### What's Newton's, with f and f′ each costing one evaluation?

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

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

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

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

### What's the interpolating quadratic at 1.5?

::: misses
- [any] Lagrange basis at 1.5: −0.125, 0.75, 0.375.
:::
:::

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

### What's the divided difference $f[x_0, x_1, x_2]$?

::: misses
- [any] $\frac{f[x_1, x_2] - f[x_0, x_1]}{x_2 - x_0}$.
:::
:::
:::

::: check
kind: parts
given: n = 6 | 10; i = 0 | 2; N = 128 | 512

## Nodes and tables.

::: part
answer: cos((2*i + 1)*pi/(2*(n + 1)))
tolerance: 0.1%

### What's Chebyshev node $x_{\given{i}}$ for n = {n}?

::: misses
- [any] $\cos\frac{(2i + 1)\pi}{2(n + 1)}$.
:::
:::

::: part
answer: (2*pi/N)^2/8
tolerance: 0.5%

### What's the worst linear-interpolation error of a {N}-entry sine table?

::: misses
- [any] $(2\pi/N)^2/8$.
:::
:::
:::

::: check
kind: parts
given: a = 0 | 2; b = 3 | 5; c = 1 | 4

## The natural spline through (0, {a}), (1, {b}), (2, {c}).

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

### What's $M_1 = S''(1)$?

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

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

### What's S(0.5)?

::: misses
- [any] $M_1\frac{x^3}{6} + y_0(1 - x) + \left(y_1 - \frac{M_1}{6}\right)x$ at 0.5.
:::
:::
:::

::: check
kind: parts
given: n = 9 | 41; k = 2 | 4

## Spline bookkeeping.

::: part
answer: 4*(n - 1)
tolerance: 0

### How many coefficients does a cubic spline through {n} points have?

::: misses
- [any] $4(n - 1)$.
:::
:::

::: part
answer: k^4
tolerance: 0.5%

### Its error is $O(h^4)$. By what factor does it shrink with {k} times as many intervals?

::: misses
- [any] $k^4$.
:::
:::
:::

::: check
kind: parts
given: x = 1 | 2; h = 0.1 | 0.2

## Differences of $x^3$ at x = {x} with h = {h}.

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

### What does the forward difference give?

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

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

### What does the central difference give?

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

::: check
kind: parts
given: p = 11 | 16 | 24 | 53 | 64 | 113

## Best steps in a {p}-bit format.

::: part
answer: sqrt(2^(1 - p))
tolerance: 1%

### For a forward difference, $h \approx \sqrt\varepsilon$: what's h?

::: misses
- [any] $\sqrt{2^{1-p}}$.
:::
:::

::: part
answer: (2^(1 - p))^(1/3)
tolerance: 1%

### For a central difference, $h \approx \varepsilon^{1/3}$: what's h?

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

::: check
kind: parts
given: s = 1 | 4; h = 5 | 20; x = 0.5 | 1.5

## Noise and extrapolation.

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

### Samples with {s} mV of noise, {h} µs apart, are differenced. How noisy is the derivative?

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

::: part
answer: (exp(x)*sinh(0.05)/0.05 - exp(x)*sinh(0.1)/0.1)/3
tolerance: 0.5%

### For $e^x$ at x = {x}, what's Richardson's correction $\frac{D(0.05) - D(0.1)}{3}$ for central differences?

::: misses
- [any] Compute both central differences to 8 digits, subtract, divide by 3.
:::
:::
:::

::: check
kind: parts
given: n = 3 | 5 | 7; t = 30 | 60

## Chebyshev polynomials satisfy $T_n(\cos\theta) = \cos n\theta$.

::: part
answer: cos(n*t*pi/180)
tolerance: 0.5%

### What is $T_{\given{n}}(\cos\given{t}°)$?

::: misses
- [any] $\cos(n\theta)$.
:::
:::
:::

::: check
kind: parts
given: d1 = 2.72 | 0.54; c = 0.003 | 0.001

## Central differences give {d1} with step h and a value {c} smaller with step h/2.

::: part
answer: d1 - 4*c/3
tolerance: 0.01%

### What is the Richardson-extrapolated derivative?

::: misses
- [d1 - c/2] The error goes as $h^2$, so weight $\frac{4D(h/2) - D(h)}{3}$.
- [any] $\frac{4D(h/2) - D(h)}{3}$.
:::
:::
:::

::: check
kind: parts
given: h = 0.1 | 0.5; M = 1 | 4

## Linear interpolation on a table with spacing {h}, for a function with $\lvert f''\rvert \le$ {M}.

::: part
answer: h^2*M/8
tolerance: 0.5%

### What is the worst-case error?

::: misses
- [h^2*M/2] The node polynomial $(x - x_0)(x - x_1)$ peaks at $\frac{h^2}{4}$, so the bound is $\frac{h^2M}{8}$.
- [any] $\frac{h^2}{8}\max\lvert f''\rvert$.
:::
:::
:::

::: check
kind: parts
given: x = 0.5 | 1 | 2

## Evaluate $f(x) = \dfrac{x}{1 + x^2}$ on the dual number $\given{x} + \varepsilon$.

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

### What is the real part?

::: misses
- [any] The real part is just $f(x)$.
:::
:::

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

### What is the $\varepsilon$ part?

::: misses
- [1/(1 + x^2)] That ignores the denominator's derivative. Use the dual quotient rule: $\frac{bc - ad}{c^2}$.
- [(1 + x^2)/(1 + x^2)^2] Subtract $a d$ = $x \cdot 2x$ in the numerator.
- [any] Not yet. With $a + b\varepsilon = x + \varepsilon$ and $c + d\varepsilon = 1 + x^2 + 2x\varepsilon$, the $\varepsilon$ part is $(bc - ad)/c^2$.
:::
:::

::: right
Right. The $\varepsilon$ part is $f'(x)$, exact, from the same arithmetic the program does anyway.
:::
:::
:::
