---
title: Problem set 2
heading: "Problem set 2: Newton, convergence and polynomial roots"
eyebrow: A13 · Problem set 2
type: problems
---

::: hook
These problems use lessons 6 to 9: Newton's and the secant method, order of convergence, roots of polynomials, and the lab's floating-point and root-finding code. Several ask you to run a step or two of an iteration by hand; keep at least six significant digits in between.
:::

::: pool
pick: 12

::: check
kind: parts
given: a = 2 | 5 | 10; x0 = 1 | 3

## Newton's method for $\sqrt{\given{a}}$ uses $x \leftarrow \frac12\left(x + \frac ax\right)$, starting at {x0}.

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

### What is $x_1$?

::: misses
- [any] Average $x_0$ and $a/x_0$.
:::
:::

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

### What is $x_2$?

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

::: check
kind: parts
given: a = 3 | 7; x0 = 0.2 | 0.1

## Find $1/\given{a}$ without division using $x \leftarrow x(2 - \given{a}x)$ from {x0}.

::: part
answer: x0*(2 - a*x0)
tolerance: 0.1%

### What is $x_1$?

::: misses
- [any] $x_0(2 - ax_0)$.
:::
:::

::: part
answer: (1 - a*x0)^2
tolerance: 0.5%

### The relative error $1 - ax$ squares each step. What is it after the first step?

::: misses
- [1 - a*x0] That's the starting error; it squares.
- [any] $(1 - ax_0)^2$.
:::
:::
:::

::: check
kind: parts
given: c = 0.5 | 1 | 1.5 | 2 | 3 | 4

## Solve $\cos x = x/\given{c}$ with one secant step from $x_0 = 0$ and $x_1 = 1$, on $f(x) = \cos x - x/c$.

::: part
answer: 1 - (cos(1) - 1/c)*(1 - 0)/((cos(1) - 1/c) - 1)
tolerance: 0.1%

### What is $x_2$?

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

::: check
kind: parts
given: m = 3 | 4 | 5

## Newton's method approaches a root of multiplicity {m}.

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

### By what factor does each step shrink the error?

::: misses
- [1/m] The factor is $1 - \frac1m$.
- [any] For $(x - r)^m$, Newton's step leaves $\left(1 - \frac1m\right)(x - r)$.
:::
:::

::: part
answer: ceil(ln(1e-6)/ln((m - 1)/m))
tolerance: 0

### How many steps reduce the error by $10^6$?

::: misses
- [any] Solve $\left(1 - \frac1m\right)^n \le 10^{-6}$.
:::
:::
:::

::: check
kind: parts
given: e0 = 0.1 | 0.05; e1 = 0.01 | 0.005; e2 = 0.0001 | 0.00005

## A method's successive errors are {e0}, {e1} and {e2}.

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

### What is its estimated order?

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

::: check
kind: parts
given: w = 0.5 | 1.5 | 2 | 2.5 | 3 | 4

## Newton costs one f and one f′ per step; the secant method costs one f. A derivative costs {w} times as much as f.

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

### What is Newton's efficiency index, order to the power 1/(cost per step)?

::: misses
- [2^(1/2)] Count the derivative's cost as {w} function evaluations.
- [any] $2^{1/(1 + w)}$.
:::
:::

::: part
answer: (1 + sqrt(5))/2
tolerance: 0.5%

### And the secant method's?

::: misses
- [any] Its order, the golden ratio, at one evaluation per step.
:::
:::
:::

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

## $p(x) = \given{a}x^3 + \given{b}x^2 + \given{c}x + \given{d}$, evaluated by Horner's rule at x = {x}.

::: part
answer: ((a*x + b)*x + c)*x + d
tolerance: 0.1%

### What is p(x)?

::: misses
- [any] $((ax + b)x + c)x + d$.
:::
:::

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

### Where does one Newton step from {x} land?

::: misses
- [any] $x - p/p'$ with $p' = 3ax^2 + 2bx + c$.
:::
:::
:::

::: check
kind: parts
given: e = 0.001 | 0.002 | 0.005 | 0.01 | 0.02 | 0.05

## The constant term of $(x - 1)(x - 2)(x - 4)$ is changed by {e}.

::: part
answer: -e/6
tolerance: 1%

### About how far does the root at 4 move?

::: misses
- [e/6] Check the sign: $\delta r \approx -\delta/p'(r)$.
- [any] $p'(4) = (4 - 1)(4 - 2) = 6$.
:::
:::

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

### And the root at 2?

::: misses
- [-e/2] $p'(2) = (2 - 1)(2 - 4) = -2$.
- [any] $-\delta/p'(2)$.
:::
:::
:::

::: check
kind: parts
given: r1 = 1 | -2; r2 = 3 | 0.5; r3 = -4 | 5

## A monic cubic has roots {r1}, {r2} and {r3}, and its companion matrix has first row $(-c_2, -c_1, -c_0)$.

::: part
answer: r1 + r2 + r3
tolerance: 0.5%

### What is $-c_2$, the trace?

::: misses
- [any] The sum of the roots.
:::
:::

::: part
answer: r1*r2*r3
tolerance: 0.5%

### What is the companion matrix's determinant?

::: misses
- [-(r1*r2*r3)] The determinant is the product of the eigenvalues, the roots.
- [any] The product of the roots.
:::
:::
:::

::: check
kind: parts
given: b = -6 | 2; c = 11 | -5; r = 1 | 3

## Divide $x^3 + \given{b}x^2 + \given{c}x + d$ by $x - \given{r}$ with Horner's rule.

::: part
answer: b + r
tolerance: 0.5%

### What is the quotient's coefficient of x?

::: misses
- [b - r] Horner adds r times the previous value: $b + r \cdot 1$.
- [any] $q_1 = b + r$.
:::
:::

::: part
answer: c + r*(b + r)
tolerance: 0.5%

### And its constant term?

::: misses
- [any] $q_0 = c + rq_1$.
:::
:::
:::

::: check
kind: parts
given: b = 100000 | 1000000000; c = 1 | 4

## Solve $x^2 - \given{b}x + \given{c} = 0$ without cancellation.

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

### What is the small root?

::: misses
- [any] Divide c by the large root.
:::
:::
:::

::: check
kind: parts
given: x = 3 | 1000 | 0.3

## Doubles have 53 significant bits.

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

### What is the spacing above x = {x}?

::: misses
- [x*2^(-52)] Spacing is set by the power of two at or below x.
- [any] $2^{e - 52}$ with $2^e \le x < 2^{e+1}$.
:::
:::
:::

::: check
kind: parts
given: n = 1000 | 10000 | 100000 | 1000000 | 10000000 | 100000000

## You add {n} positive numbers of similar size in double precision.

::: part
answer: n*1.1e-16
tolerance: 1%

### What relative error bounds the naive sum, at worst?

::: misses
- [sqrt(n)*1.1e-16] That's the typical size, for errors that cancel randomly.
- [any] About $nu$ with $u = 1.1 \times 10^{-16}$.
:::
:::

::: part
answer: sqrt(n)*1.1e-16
tolerance: 1%

### What size is typical, if the roundings behave like random signs?

::: misses
- [any] About $\sqrt n\,u$.
:::
:::
:::

::: check
kind: parts
given: C = 0.5 | 2; e0 = 0.01 | 0.001

## Near a root, Newton's error obeys $e_{n+1} = \given{C}e_n^2$, starting at {e0}.

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

### What is $e_1$?

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

::: part
answer: C*(C*e0^2)^2
tolerance: 0.5%

### What is $e_2$?

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

::: check
kind: parts
given: W = 1 | 10; t = 0.000001 | 0.000000001

## A safeguarded solver falls back to bisection on a bracket {W} wide.

::: part
answer: ceil(log(W/t)/log(2))
tolerance: 0

### At worst, how many steps bring the bracket below {t}?

::: misses
- [any] Each bisection halves the bracket: solve $W/2^n \le t$.
:::
:::
:::
:::
