summaryrefslogtreecommitdiff
path: root/tutorials/module_3/2_roots_optimization.md
diff options
context:
space:
mode:
Diffstat (limited to 'tutorials/module_3/2_roots_optimization.md')
-rw-r--r--tutorials/module_3/2_roots_optimization.md20
1 files changed, 14 insertions, 6 deletions
diff --git a/tutorials/module_3/2_roots_optimization.md b/tutorials/module_3/2_roots_optimization.md
index a97e7d2..8083260 100644
--- a/tutorials/module_3/2_roots_optimization.md
+++ b/tutorials/module_3/2_roots_optimization.md
@@ -164,7 +164,7 @@ x_{1} = x_0 - \frac{f(x_0)}{f'(x_0)}
$$
Since $x_0$ is our current guess and $x_0$ is our next guess, we can write these symbolically as $x_i$ and $x_{i+1}$ respectively. This gives us the *Newton-Raphson formula*.
$$
-\boxed{x_{i+1} = x_i - \frac{f(x_i)}{f'(x_i)}}
+\boxed{x_{i+1} = x_i - \frac{f(x_i)}{f'(x_i)}} \tag{3.1}
$$
### Assignment 2
From experimental data we extrapolated a function f. Write a python function called *newtonraphson* which as the following input parameters
@@ -199,27 +199,35 @@ def newtonraphson(f, df, x0, tol):
## Modified Secant
-A possible issue with the Newton-Raphson method is that we are required to know the derivative of the function we are finding the root for. Sometimes this may be extremely difficult or impossible to find analytically. Thus we can use the modified secant method.
+A possible issue with the Newton-Raphson method is that we are required to know the derivative of the function we are finding the root for. Sometimes this may be extremely difficult or impossible to find analytically. Thus we can use the modified secant method. A numerical variant of the Newton-Raphson.
This method uses the finite derivative to guess where the root lies. We can then iterate this guessing process until we're within tolerance.
$$
f'(x_i) \simeq \frac{f(x_{i-1})-f(x_i)}{x_{i-1}x_i}
$$
+Then substituting this in equation (3.1) we get the equation for the secant method:
+
$$
-x_{x+1} = x_i - \frac{f(x_i)}{f'(x_i)}
+x_{i+1} = x_i - \frac{f(x_i) (x_{i-1}x_i)}{f(x_{i-1})-f(x_i)} \tag {3.2}
$$
+
+We can then *modify* the equation to instead of choosing two arbitrary numbers we use a small value $\delta$ in the independent variable to get a better reading.
$$
x_{x+1} = x_i - \frac{f(x_i)(x_{i-1}-x_i)}{f(x_i+\delta x)-f(x_i)}
$$
$$
-x_{x+1} = x_i - \frac{f(x_i)\delta x_i}{f(x_i+\delta x)-f(x_i)}
-$$
+\boxed{x_{x+1} = x_i - \frac{f(x_i)\delta x_i}{f(x_i+\delta x)-f(x_i)}} \tag{3.3}
+$$
+Note that if $\delta$ is too small the method can fail by round-off error due to the subractive cancellation in the denominator in eqn. 3.3. If $\delta$ is too large, the method becomes inefficient or even divergent.
## Issues with open methods
-Open methods may also have it's problems. Let's consider the following function: $f(x)=3.2*tan^{-1}(x-4.3)$ if we were to apply the Newton-Raphson to find the root of this function we can see that the results diverge. This happens when
+Open methods may also have it's problems. Let's consider the following function: $f(x)=3.2*tan^{-1}(x-4.3)$ if we were to apply the Newton-Raphson to find the root of this function we can see that the results diverge.
+
+{Divergence Demo}
+
# Pipe Friction Example