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.md33
1 files changed, 28 insertions, 5 deletions
diff --git a/tutorials/module_3/2_roots_optimization.md b/tutorials/module_3/2_roots_optimization.md
index cc9dbb5..2c94f92 100644
--- a/tutorials/module_3/2_roots_optimization.md
+++ b/tutorials/module_3/2_roots_optimization.md
@@ -60,7 +60,7 @@ Let's consider a continuous function $f(x)$ with an unknown root $x_r$ . Using t
Once we bisect the interval and found we set the new predicted root to be in the middle. We can then compare the two sections and see if there is a sign change between the bounds. Once the section with the sign change has been identified, we can repeat this process until we near the root.
![[bisection.png|500]]
-As you the figure shows, the predicted root $x_r$ get's closer to the actual root each iteration. In theory this is an infinite process that ca3n keep on going. In practice, computer precision may cause error in the result. A work-around to these problems is setting a tolerance for the accuracy. As engineers it is our duty to determine what the allowable deviation is.
+As you the figure shows, the predicted root $x_r$ get's closer to the actual root each iteration. In theory this is an infinite process that can keep on going. In practice, computer precision may cause error in the result. A work-around to these problems is setting a tolerance for the accuracy. As engineers it is our duty to determine what the allowable deviation is.
So let's take a look at how we can write this in python.
```python
@@ -128,16 +128,39 @@ plt.legend()
plt.show()
```
# Open Methods
-## Modified Secant
-We can do better.
-
+So far we looked at methods that require us to bracket a root before finding it. However, let's think outside of the box and ask ourselves if we can find a root with only 1 guess. Can we improve the our guess by if we have some knowledge of the function itself?
## Newton-Raphson
+Possibly the most used root finding method implemented in algorithms is the Newton-Raphson method. Unlike the bracketing methods, we use one guess and the slope of the function to find our next guess. We can represent this graphically below.
+![Newton-Raphson illustration|350](https://pythonnumericalmethods.studentorg.berkeley.edu/_images/19.04.01-Newton-step.png)
-![Newton-Raphson illustration|350](https://pythonnumericalmethods.studentorg.berkeley.edu/_images/19.04.01-Newton-step.png)
+<img
+ style="display: block;
+ margin-left: auto;
+ margin-right: auto;
+ width: 60%;"
+ src="https://pythonnumericalmethods.studentorg.berkeley.edu/_images/19.04.01-Newton-step.png"
+ alt="Newton-Raphson illustration">
+If we start with a single
+
+## Modified Secant
+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}
+$$
+$$
+x_{x+1} = x_i - \frac{f(x_i)}{f'(x_i)}
+$$
+$$
+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}{f(x_i+\delta x)-f(x_i)}
+$$
# Pipe Friction Example