Try to solve $x^3-x-1=0$ by factorising. It does not factorise, and there is no simple formula you can use. Or try to find $\int_0^1e^{-x^2}\,dx$ exactly: no one can, with the functions in this course. Engineers and computers meet problems like these every day. A numerical method gives an answer that is as accurate as you need, step by step. Every numerical answer should come with a check.
A root that algebra cannot reach
Method
What it does
Rule
Sign change
locates a root
$f$ continuous and $f(a)$, $f(b)$ of opposite signs
If $f$ is continuous 连续 on $[a,b]$, and $f(a)$ and $f(b)$ have opposite signs, then the graph must cross the axis between them. So there is a root in $(a,b)$.
When a sign change works and when it misleads
Worked example.$f(x)=x^3-x-1$. Then $f(1)=-1<0$ and $f(2)=5>0$. $f$ is a polynomial, so it is continuous. So there is a root between 1 and 2.
When a sign change misleads.
A change but no root.$f(x)=\frac1x$ has $f(-1)=-1$ and $f(1)=1$. But the graph jumps at $x=0$ (an asymptote). $f$ is not continuous there, so the rule does not apply.
A root but no change.$f(x)=(x-1)^2$ has $f(0)=f(2)=1$. The repeated root at $x=1$ only touches the axis.
Two roots in one interval. Two sign changes cancel, so $f(a)$ and $f(b)$ can have the same sign even though two roots lie between them.
Bisection
Bisection 二分法 halves the interval each time. Find the midpoint, test its sign, and keep the half whose ends have opposite signs.
Interval
Midpoint $m$
$f(m)$
Keep
$[1,2]$
$1.5$
$0.875$
$[1,1.5]$
$[1,1.5]$
$1.25$
$-0.297$
$[1.25,1.5]$
$[1.25,1.5]$
$1.375$
$0.225$
$[1.25,1.375]$
$[1.25,1.375]$
$1.3125$
$-0.0515$
$[1.3125,1.375]$
Each step halves the uncertainty. It is slow but it never fails, as long as $f$ is continuous.
Bisection keeps the half with a sign change; two trapezia give 3, above the true 8/3, for this convex curve
Proving a root to a given accuracy
To show that a root is $1.3247$ to 4 decimal places, test the two rounding boundaries, $1.32465$ and $1.32475$.
On a graph, the iteration moves between the curve $y=g(x)$ and the line $y=x$. When the steps go one way, it is a staircase diagram 阶梯图. When they spiral round the root, it is a cobweb diagram 蛛网图 (this happens when $g'(x)<0$).
Convergence. The same equation can also be written $x=x^3-1$. From $x_0=1.5$ this gives $2.375$, $12.40$, $1904$: it diverges. If $|g'(\alpha)|<1$ at a fixed point $\alpha$ and $g'$ is continuous near $\alpha$, the iteration converges 收敛 for starting values sufficiently close to $\alpha$.
Rearrangement
$\lvert g'(1.3247)\rvert$
From $x_0=1.5$
$g(x)=\sqrt[3]{x+1}$
$0.19<1$
converges to $1.3247$
$g(x)=x^3-1$
$5.26>1$
$2.375$, $12.40$, $1904$: diverges
A limit $L$ must satisfy $L=g(L)$. Check it in the original equation.
Iteration climbs a staircase into the root where the curve meets y = x; each Newton–Raphson tangent lands on the axis at the next, better estimate
The Newton–Raphson method
Start at $x_0$. Draw the tangent to $y=f(x)$ there. Where it meets the $x$-axis is the next estimate:
One Newton–Raphson step
$$x_{n+1}=x_n-\frac{f(x_n)}{f'(x_n)}.$$
Worked example: $\sqrt2$.$f(x)=x^2-2$, $f'(x)=2x$, $x_0=2$:
The two end heights count once, and every middle height counts twice.
Worked example. Estimate $\int_0^2x^2\,dx$ with 2 strips. $h=1$ and the heights are $0,1,4$:
$$\tfrac12\left[0+2(1)+4\right]=3.$$
The exact value is $\frac83=2.667$, so this is an overestimate.
More strips, a smaller error.
Strips
$h$
Estimate
Error
2
1
$3$
$0.333$
4
0.5
$0.25[0+2(0.25+1+2.25)+4]=2.75$
$0.083$
8
0.25
$2.6875$
$0.021$
Each time $h$ halves, the error falls by about a factor of 4.
Over or under? It depends on how the curve bends, not on whether it rises or falls.
Convex, $f''>0$
Concave, $f''<0$
the chords lie above the curve
the chords lie below the curve
the trapezium rule overestimates: $x^2$ on $[0,2]$
the trapezium rule underestimates: $\sqrt x$ on $[1,4]$
For $\sqrt x$ on $[1,4]$ with 3 strips: $\frac12\left[1+2(1.4142+1.7321)+2\right]=4.646$, below the exact $\frac{14}3=4.667$.
Rectangles as bounds. For an increasing function, rectangles using the left-hand heights give a lower bound, and right-hand heights give an upper bound. The true area lies between them.
Practice
Show that $x^3+2x-5=0$ has a root between 1 and 2.
Does $\tan x$ have a root in $(1,2)$? Explain.
Write down an interval that proves a root is $2.718$ to 3 d.p.
Use $x_{n+1}=\sqrt{2x_n+3}$ with $x_0=2$ to find $x_1$, $x_2$ and $x_3$. Which equation does the limit solve?
Apply one step of Newton–Raphson to $f(x)=x^3-5$ from $x_0=2$.
Use the trapezium rule with 4 strips to estimate $\int_0^1\frac1{1+x}\,dx$. Is it an over- or underestimate?
Answers.
$f(1)=-2<0$, $f(2)=7>0$; $f$ is continuous, so there is a root in $(1,2)$.
No: the zeros of $\tan x$ are integer multiples of $\pi$, none of which lies in $(1,2)$. The sign-change test does not apply across the asymptote at $x=\frac\pi2$.
$(2.7175,2.7185)$.
$2.6458$, $2.8795$, $2.9596$ (converging to 3); the limit solves $x^2-2x-3=0$.
$x_1=2-\frac{3}{12}=1.75$.
$h=0.25$: $0.125\left[1+2(0.8+0.6667+0.5714)+0.5\right]=0.697$; $\frac1{1+x}$ is convex, so it is an overestimate of $\ln2=0.693$.
Key points
A sign change locates a root only if $f$ is continuous.
To prove a root to $k$ decimal places, test the two rounding boundaries.
Iteration $x_{n+1}=g(x_n)$ converges locally if $|g'(\alpha)|<1$ at the fixed point $\alpha$, $g'$ is continuous near $\alpha$, and the starting value is sufficiently close.
Newton–Raphson is fast but fails where $f'(x_n)=0$ or from a bad start.
Trapezium rule: ends once, middles twice, times $\frac h2$; it overestimates for convex curves.