Numerical Methods
- Tags
- math
Refers to several methods to determine whether a curve has a root in the interval
To do this you must show that there's a change in sign between
Warn: without continuity a change of sign no longer guarantees the presence of a
root.
Consider a hyperbola
The Need for Numerical Methods
These approaches show their value when you realise that not all equations have
solvable roots.
Recall that for the several types of equations, there are formula for the
root (see
Function | Terms in the Root Formula |
---|---|
Quadratic | |
Cubic | |
Quartic |
Methods
Each of the methods described below try to narrow down from a wide range or
start-position to an
They all have the possibility to diverge and not find a root, but under some conditions their guaranteed to converge to a root.
Interval Bisection
Is an approach for narrowing down to the root. It's essentially a binary search.
Given that
r = a, b
while True:
m = (a + b) / 2
fm = f(m)
if fm > 0:
a = m
elif fm < 0:
b = m
else: # fm == 0
root = m
break
Essentially we continually cut off half the search space, moving closer to the root as we move long, until we've found the root to a desired accuracy.
Linear Interpolation
Is a variant that uses the linear distance between the current range to jump to the approximate location of the root. This works by using the ratio of the two triangles formed through intersecting the root.
\begin{figure}[ht]
\centering
\begin{tikzpicture}[scale=2]
% Definitions
\def\xa{1cm} \def\a{3cm} \def\xb{4cm}
\def\yb{1cm} \def\ya{-2cm}
% Axis and Line
\draw[very thick,->] (0,0) -- (5,0) node[right] {$x$};
\draw (\xa,0) -- ++(0, 4pt) node[above] {$x_1$}
(\a,0) -- ++(0, 4pt) node[above] {$\alpha$}
(\xb,0) -- ++(0, -4pt) node[below] {$x_2$};
\draw[thick] (\xa,\ya) -- (\xb,\yb);
\fill (\xa, \ya) circle (2pt) node[left] {$y_1$}
(\xb, \yb) circle (2pt) node[right] {$y_2$};
% Witdh Indicators
\draw[dotted] (\xb, \yb) -- (\xb,0) (\a, 0) -- (\a, \ya);
\draw[dotted,<->] ({\xa + 2pt}, \ya) -- (\a,\ya) node[below,midway] {$x_2 - \alpha$};
\draw[dotted,<->] (\a,-3pt) -- (\xb, -3pt) node[below,midway] {$\alpha - x_1$};
\end{tikzpicture}
\caption{A demonstration of the ratio between the triangles formed by the
x-intercept of a straight-line.}
\label{fig:larp-demo}
\end{figure}
In
{\Delta{y}} \) is the same for both triangles.
If we equate them we can get an equation for Now for example if we had
Newton-Raphson Method
This approach is a sort of gradient-descent to reach the root of an equation. It works by:
- Having an existing
-value, , - Finding the tangent of the curve at that point, and then
- Setting
to the x-intercept of the tangent.
\begin{figure}[ht]
\centering
\incfig{20210618042247}
\caption{Visualisation of the Newton Raphson method, starting with \( x_n \) we
find the root \( x_{n+3} \) in 3 steps.}
\label{fig:newton-raphson}
\end{figure}
We define the tangent of a 2D curve at a point
Furthermore because each subsequent point in the sequence of the newton-rhapson
method is an X intercept,
eq:newton-raphson defines the algorithm of the newton-raphson method. For
each iteration we take the current
This method is only guaranteed to converge to a root if