Numerical analysis is the process of approximating a solution when the solution cannot be found exactly.
## Bisection method
The bisection method is an example of numerical analysis. Start by specifying an interval that will contain the solution. Next bisect (calculate the middle of) the interval and determine if the solution is in the upper or lower half of the interval. Repeat bisecting the interval until the solution is approximated to the desired degree of accuracy.
The downside of the bisection method is that it may be difficult to find the original interval. It can also be slow, especially if the initial interval is large. The upside is it will always converge on the solution given the true solution is in the initial interval.
### Example
Let's find the value $\sqrt3$ numerically.
First, let's specify the function we need to solve
$\displaylines{x = \sqrt3 \\
x^2 = 3 \\
x^2 - 3 = 0 \\}$
So we'll say $f(x) = x^2 - 3$ and we want to find where $f(x) = 0$.
Let's start with the interval $(0, 2)$.
$\displaylines{f(0) = 0^2 - 3 = -3 \\
f(2) = 2^2 - 3 = 1}$
We can see that the interval must contain the solution because the upper bound is positive and the lower bound is negative. Next let's use the bisecting value for the interval, which is $1$.
$f(1) = 1^2 - 3 = -2$
Now we have a negative result, which means the solution must be in the interval $(1, 2)$. Let's continue with this logic until we get the desired degree of accuracy.
$\displaylines{f(1.5) = 1.5^2 - 3 = -0.75 \\
f(1.75) = 1.75^2 - 3 = 0.0625 \\
f(1.625) = 1.625^2 - 3 = -0.359375 \\
\dots \\
f(1.73046875) = -0.0054\dots}$
After 8 iterations, we'll find the approximation $1.730$ is fairly close to the true value of $\sqrt3 \approx 1.732$.
## Newton's method
Newton's method is an example of numerical analysis using the [[derivative]] of the function to find the solution. Starting from an initial guess, calculate the slope at the point to find the next guess. Continue until the desired degree of accuracy is attained.
The formula is
$x_{n+1} = x_n - \frac{f(x_n)}{f'(x_n)}$
While this is computationally faster than the bisection method, and only requires one point to start with, the downside is that it might not converge on the solution.
### Example
Let's find the value $\sqrt3$ numerically.
First, let's specify the function we need to solve
$\displaylines{x = \sqrt3 \\
x^2 = 3 \\
x^2 - 3 = 0 \\}$
So we'll say $f(x) = x^2 - 3$ and we want to find where $f(x) = 0$. Finding the derivative of the function we get $f('x) = 2x$.
Let's start with a guess of 1.5. Plugging into the equation we have
$x_{n+1} = 1.5 - \frac{1.5^3 - 3}{2*1.5} = 1.75$
We'll simply repeat this process until the desired degree of accuracy is achieved. Plugging in $1.75$ we get
$x_{n+1} = 1.75 - \frac{1.75^3 - 3}{2*1.75} = 1.732\dots$
which is already a very good approximation of $\sqrt3 \approx 1.732$.