From 2922d7290750ed0ff08f4fc6ddee4794cb696742 Mon Sep 17 00:00:00 2001 From: Christian Kolset Date: Fri, 5 Sep 2025 12:27:55 -0600 Subject: Finished up Bisection content --- tutorials/module_3/2_roots_optimization.md | 83 ++++++++++++---- tutorials/module_3/roots_assignment2_data.csv | 136 ++++++++++++++++++++++++++ 2 files changed, 201 insertions(+), 18 deletions(-) create mode 100644 tutorials/module_3/roots_assignment2_data.csv diff --git a/tutorials/module_3/2_roots_optimization.md b/tutorials/module_3/2_roots_optimization.md index 9734d40..83684d5 100644 --- a/tutorials/module_3/2_roots_optimization.md +++ b/tutorials/module_3/2_roots_optimization.md @@ -1,11 +1,12 @@ # Root Finding Methods -Root Finding Methods or non-linear equation solvers. +By now you've learned the quadratic formula to find the roots of a second degree polynomial. +$$ +x=\frac{-b \pm \sqrt{b^2-4ac}}{2a} +$$ +This works nicely if we're given the function $f(x)$. However, how would you solve for $x$ if you were given experimental data? In this section we will cover bracketing and open methods to find roots of a function. - -In this section we will cover four different methods to find a root of a function. Let us take a step back and think algorithmically. To find a root numerically, we can implement a search algorithm. - -Let's consider a phone book - a database of names and numbers sorted alphabetically by last name. Our goal is to find the phone number of James Watt (our root). We could make an algorithm that starts at the the first page, checks to see if the current name equals our target (Watt), if it doesn't, check the next entry. This is method is called *incremental search*. As you may see, this can take very long if the database is very large. +Let us take a step back and think *algorithmically*. To find a root numerically, we can implement a search algorithm. Let's consider a small phone book - a database of names and numbers sorted alphabetically by last name. Our goal is to find the phone number of James Watt (our root). We could make an algorithm that starts at the the first page, checks to see if the current name equals our target (Watt), if it doesn't, check the next entry. This is method is called *incremental search*. As you may see, this can take very long if the database is large. > [!NOTE] Example Phonebook Database Entries > **A** – Archimedes @@ -34,46 +35,62 @@ Let's consider a phone book - a database of names and numbers sorted alphabetica > **Y** – Yukawa > **Z** – Zuse -Another approach may be to index the book and jump straight to the 'W' names however this requires two steps. Let us introduce *Bisection*. +Another approach may be to index the book and jump straight to the 'W' names however this requires two steps. + +When + +# Bracketing Method ## Incremental Search Incremental search ## Bisection -This method start by sectioning the database into two halves. We can do this with a phone book by simply opening it in the middle of the book. In our data set, we have find the middle entry to be 'M - Maxwell'. Since all names are sorted alphabetically we can conclude that we will find our target in the second half, essentially eliminating the first half. Doing this a second time gives us our new midpoint 'S – Schrödinger' and a third time get us to our target 'W - Watt'. In only 3 iterations we have reached out target goal. This is a huge improvement from the Incremental search (22 iterations) versus our new 3 iterations. +This method start by sectioning the database into two halves. We can do this with a phone book by simply opening it in the middle of the book. In our data set, we have find the middle entry to be 'M - Maxwell'. Based on the premises that all names are sorted alphabetically we can conclude that we will find our target in the second half, essentially eliminating the first half. Doing this a second time gives us our new midpoint 'S – Schrödinger' and a third time get us to our target 'W - Watt'. In only 3 iterations we have reached out target goal. This is a huge improvement from the Incremental search (22 iterations) versus our new 3 iterations. + +This exact same concept can be applied to finding roots of functions. Instead of searching for strings we are searching for floats. For computers this is a lot easier to do. Take a moment to think about how you would write psuedo-code to program this. + +> The **Intermediate Value Theorem** says that if f(x) is a continuous function between a and b, and sign(f(a))≠sign(f(b)), then there must be a c, such that a