A escalar equation is an expression of the form $$f(x)=0$$ where $f:\Omega\subset\mathbb{R}\to\mathbb{R}$ is a function.
Any number $\alpha$ such that $f(\alpha)=0$ is a solution, zero or root of $f$.
For instance, $x=-1$, $x=1$ y $x=2$ are the zeros of the equation
$$x^3-2x^2-x+2=0 \qquad (f(x)=x^3-2x^2-x+2)$$because
Graphically, the zeros are the $x$ values ​​for which the $f$ curve intersects the $OX$ axis.
A zero of $f$, $\alpha$, has multiplicity $m$ if
If $m=1,$ we have a single zero.
For example: $$f(x)=2(x+1)^3(x-1)^2(x-0.5)=-1 + x + 4 x^2 - 2 x^3 - 5 x^4 + x^5 + 2 x^6$$
Zero bracketing consists of finding an interval $[a, b]$ that contains one and only one root of $f.$
We will take into account the Bolzano's Theorem:
Suppose that $f:[a,b]\to\mathbb{R}$ is continuous, with $f(a)f(b)\lt 0$, that is, with a different sign at the interval borders. Then there is at least one root of $f$ in $[a,b]$.
If Bolzano's theorem is fulfilled and also the function is:
The function has a single zero in $[a,b]$
For example, if $f(x)=x^2-1$ we can bracket their zeros in the intervals $[-2,0]$ and $[0,2]$.
For $[-2,0]$:
And for $[0,2]$:
Numerical methods are not only alternative methods to analytical ones. In some cases, they are the only possible ones. For example, the equation
$$\cos x = x$$has only one solution, but there is no way to solve it analytically.
Numerical methods to find zeros of functions are iterative methods, that is, we define a sequence $$x_0,x_1,\ldots,x_k,\ldots \rightarrow \alpha$$
such that
$$\lim_{k\to\infty}f(x_k)=0.$$The order of convergence of the method is related to the speed of convergence of the sequence with respect to $k$.
Suppose the sequence $x_k$ converges to $\alpha\in\mathbb{R}$. We say that $x_k$ converges to $\alpha$ with order $p$ if
$$\lim_{k\to\infty}\frac{e_k}{e_{k-1}^{\,p}}=\lambda\neq0$$being $e_k=|x_k-\alpha|$ the absolute error in iteration $k.$ That is
$$e_k\approx \lambda\, e_{k-1}^{\,p}$$In the special cases
A numerical method is said to be of order $p$ if it produces a sequence which converges to the solution with order $p$.
For instance, let's suppose that our method convergence order is linear with $\lambda=\dfrac{1}{2}$ and $e_k=0.1.$ We have
$$e_{k+1}\approx \frac{e_k}{2}=0.05 \quad e_{k+2}\approx \frac{e_{k+1}}{2}=0.025 \quad e_{k+3}\approx \frac{e_{k+2}}{2}=0.0125 \quad \ldots $$That is, at each iteration, the error halves.
Let's suppose that our method convergence order is quadratic with $\lambda=1$ and $e_k=0.1$. We have
$$e_{k+1}\approx e_k^{\,2} =0.01 \quad e_{k+2}\approx e_{k+1}^{\,2} =0.0001 \quad e_{k+3}\approx e_{k+2}^{\,2}=0.00000001 \quad \ldots $$That is, at each step, the error decreases by an order of magnitude, first to $0.01,$ then to $0.0001,$ etc. We can see that the error decreases much faster than in the linear case.
If we have a continuous function $f:[a,b]\to\mathbb{R}$ such that $f(a)f(b)\lt 0$. Bolzano's theorem guarantees the existence of a zero of $f$ in $(a,b)$.
- Let $a_1=a$, $b_1=b$.
- For $k=1,2,\ldots,\mathrm{MaxNumIter}$
- Compute the midpoint $x_k=\dfrac{a_k+b_k}{2}$
- If stopping criteria is satisfied then $x_k$ is the approximation: stop.
- Else,
- if $f(a_k)f(x_k)<0$ then:
$ a_{k+1}=a_{k},$ $ b_{k+1}=x_k,$
- if $f(x_k)f(b_k)<0$ then:
$ a_{k+1}=x_{k},$ $ b_{k+1}=b_k.$
- else:
stop.
Suppose that the initial interval $ [a_0, b_0] $ satisfies the conditions of Bolzano's theorem and, without loss of generality, that the interval contains a single zero. Then all other intervals obtained by the bisection algorithm contain a single zero.
We will take as an approximate solution the last $x_k$ obtained, which will be the extreme of the following interval. A boundary of the error is the length of the interval: the worst case is that the zero is very close to the other end of the interval and then the error would be a little less than the length of the interval.
Thus, after iterating, the interval is $[a_1, b_1]$ and its length is half the length of $[a_0, b_0]$. That is, the error boundary when we have done an iteration is
$$ c_1 = \frac{b_0-a_0}{2} $$If we iterate again, the length of the interval is halved and the error boundary is
$$ c_2 = \frac{1}{2}\times\frac{b_0-a_0}{2}=\frac{b_0-a_0}{2^2} $$For iteration 3
$$ c_3 = \frac{1}{2}\times\frac{b_0-a_0}{2^2}=\frac{b_0-a_0}{2^3} $$and for iteration $k$
$$ c_k = \frac{b_0-a_0}{2^k} $$So given the number of iterations, we can give an error boundary. And vice versa, given a tolerance, we can give the number of iterations that guarantee an error less than the tolerance.
In practice, the bisection method is used to initialize faster methods.
Consider the equation
$$\frac{x}{2}e^{-\frac{x}{2}}+\frac{1}{2}=0$$We define the function $f(x)=\dfrac{x}{2}e^{-\frac{x}{2}}+\dfrac{1}{2}$.
We see that the three sufficient conditions to exist a single root in the interval are met:
Let us also prove it analytically:
The conditions to apply the Bisection method are Bolzano's conditions, that is, conditions 1 and 2 of the previous section.
As we demonstrated, these two conditions are met and therefore, we can apply the Bisection method.
We iterate taking into account that given $a$ and $b$ the midpoint is
$$m = \frac{a+b}{2}$$and that the error boundary is given by
$$c = b-a$$of the next iteration.
Iteration 1
The interval is $[-1,1]$ and its midpoint is
$$m = \frac{a+b}{2}=\frac{(-1)+1}{2}=0$$As $f(-1)=-0.32$ and $f(0)=0.50$ the sign of the function is different at the next interval boundaries that is $[-1,0]$ and the error boundary is the length of this interval, 1.
Iteration 2
The interval is $[-1,0]$ and its midpoint is
$$m = \frac{a+b}{2}=\frac{(-1)+0}{2}=-0.5$$As $f(-1)=-0.32$ and $f(-0.5)=0.18$ the sign of the function is different at the next interval boundaries that is $[-1,-0.5]$ and the error boundary is the length of this interval, 0.5.
Iteration 3
The interval is $[-1,-0.5]$ and its midpoint is
$$m = \frac{a+b}{2}=\frac{(-1)+(-0.5)}{2}=-0.75$$As $f(-0.75)=-0.05$ and $f(-0.5)=0.18$ tienen signo distinto el siguiente intervalo es $[-0.75,-0.5]$ and the error boundary is the length of this interval, 0.25.
Iteration 4
The interval is $[-0.75,-0.5]$ and its midpoint is
$$m = \frac{a+b}{2}=\frac{(-1)+(-0.5)}{2}=-0.625$$and the error boundary is half the length of the previous interval, that is, 0.125.
We already calculated the error bound along with the iterations but, taking into account that the number of iterations is $k = 4$, we could also have used the formula
$$c_k=\frac{b_0-a_0}{2^k}=\frac{1-(-1)}{2^4}=\frac{2}{2^4}=\frac{1}{2^3}=\frac{1}{8} = 0.125$$Let's check that the error is less than the error boundary. Since the exact solution is $\alpha= -0.703$, the absolute error is
$$e_4 = |x_4-\alpha|=|-0.625-(-0.703)|=0.078$$which is less than the error boundary, as expected.
We want that
$$ e_{a}=\left|\alpha-x_{n}\right|\lt 10^{-6}. $$Since the error (unknown) is less than the error bound (known)
$$ e_{a}=\left|\alpha-x_n\right|\lt\dfrac{b_{0}-a_{0}}{2^n}. $$a sufficient condition for the error to be less than $10^{-6}$ is that the error bound is less than $10^{-6}$
$$ \dfrac{b_{0}-a_{0}}{2^n}\lt 10^{-6}. $$We will work with this inequality and apply the following properties
Taking into account property 1 and multiplying both members of the inequality first by $2^n$ and then $10^6$ we have
$$ \frac{1-(-1)}{2^{n}} \lt 10^{-6} \Longleftrightarrow 2 \lt 2^n 10^{-6} \Longleftrightarrow 2\times 10^6\lt 2^{n} $$Since $f(x)=\log(x)$ is a strictly increasing function, applying property 2 we have
$$ \log\left(2\times 10^6\right)\lt\log\left(2^{n}\right) $$and taking into account property 3
$$ \log\left(2\times 10^6\right)\lt n\log2. $$As $\log2 \gt 0$, applying property 1 with $c=1/\log2$
$$ \frac{\log\left(2\times 10^6\right)}{\log2}\lt n $$$\log$ represents here any logarithm in base greater than 1. We will use, for example, natural logarithms
$$20.9\lt n$$And if we do $\fbox{$n=21$}$ iterations, we can guarantee that the error is less than $10^{-6}.$