Bisection Method Presentation
Cheatsheet Content
### Complete Presentation Guide: Bisection Method This comprehensive guide is designed for a 5-person team presentation on the Bisection Method, ensuring perfect timing and thorough coverage. Each person has a dedicated 5-minute slot. #### 5 Minutes Each - Perfect Timing! ⏱️ ### 🎤 Person 1: Introduction & Theory (5 minutes) #### 📝 Speaking Script (Word-by-Word) **[0:00-0:30] Self Introduction** "Good morning/afternoon everyone. I'm [Your Name], and I'll be starting our presentation on the Bisection Method, a fundamental numerical technique for finding roots of equations." **[0:30-1:30] What is a Root?** "First, let's establish a clear understanding of what we mean by a 'root' of a function. #### Definition of a Root [Draw on board, or point to Slide 2] If we have a function $f(x)$, a root, also known as a zero, is any value of $x$ for which $f(x) = 0$. [Point to graph on Slide 2] Graphically, this corresponds to the point or points where the curve of the function intersects or touches the x-axis. It's where the function's output is zero. For instance, consider our target function for today: $f(x) = x^3 - 2x - 5$. Our goal is to find the specific $x$-value where this expression evaluates to zero." **[1:30-2:30] Why Numerical Methods?** "Now, why do we need numerical methods like the Bisection Method? #### The Necessity of Numerical Methods [Write on board, or point to Slide 3] If we attempt to solve $x^3 - 2x - 5 = 0$ algebraically, we quickly find it's a non-trivial task. Exact solutions for cubic equations involve complex formulas, often making them impractical for real-world applications. However, in fields like engineering, physics, and computer science, we frequently require practical, approximate solutions with a desired level of accuracy. This is precisely where numerical methods become indispensable, providing efficient ways to converge on such solutions." **[2:30-3:30] Bisection Method Introduction** "The Bisection Method is elegant in its simplicity, rooted in a powerful mathematical concept: The Intermediate Value Theorem. #### Intermediate Value Theorem (IVT) [Draw diagram, or point to conceptual diagram on Slide 4] The IVT states that if a continuous function $f(x)$ takes on values of opposite signs at two points, say $a$ and $b$, meaning: * $f(a)$ is negative (below the x-axis) * $f(b)$ is positive (above the x-axis) (or vice-versa) Then, there **must** be at least one root, i.e., a point where $f(x) = 0$, between $a$ and $b$. It's conceptually similar to finding a 'treasure' (the root) hidden within an interval by continuously narrowing down its possible location." **[3:30-4:30] Our Specific Problem - Initial Interval** "Let's apply this principle to our function, $f(x) = x^3 - 2x - 5$, to identify an initial interval containing a root: #### Determining the Initial Interval [Calculate on board, or point to Slide 5] * Let's evaluate $f(x)$ at $x = 2$: $f(2) = (2)^3 - 2(2) - 5 = 8 - 4 - 5 = -1$ (which is negative). * Now, let's evaluate $f(x)$ at $x = 3$: $f(3) = (3)^3 - 2(3) - 5 = 27 - 6 - 5 = +16$ (which is positive). Since $f(2)$ is negative and $f(3)$ is positive, and $f(x)$ is a polynomial (hence continuous), the Intermediate Value Theorem guarantees that there **must** be a root between $x=2$ and $x=3$. Therefore, our initial search interval for the root is $[2, 3]$." **[4:30-5:00] Conclusion & Handover** "To summarize my segment, we've covered: 1. The fundamental definition of a root. 2. The crucial role of numerical methods in practical problem-solving. 3. The underlying principle of the Bisection Method, based on the Intermediate Value Theorem. 4. And, for our specific problem, we've identified an initial interval of $[2, 3]$ that definitively contains a root. Now, my colleague [Next Person] will delve into the precise mathematical steps of how the Bisection Method iteratively refines this interval to pinpoint the root. Thank you!" #### 🎨 Visual Aids for Person 1 ##### Slide 1: Title ``` ---------------------------------- BISECTION METHOD Finding Root of f(x) = x³ - 2x - 5 Group [Your Group Number] ---------------------------------- ``` ##### Slide 2: What is a Root? ``` ---------------------------------- ### What is a Root? • **Definition:** A value of $x$ where $f(x) = 0$. • **Graphically:** Where the function's curve intersects the x-axis. **Example:** For $f(x) = x^2 - 4$, the roots are $x = 2$ and $x = -2$. ---------------------------------- ``` **(Self-drawn on board: A simple x-y axis with a curve crossing the x-axis at two points. Label the points as roots.)** ##### Slide 3: Why Numerical Methods? ``` ---------------------------------- ### Why Numerical Methods? **Algebraic Solution for $x^3 - 2x - 5 = 0$:** ❌ Extremely difficult, involves complex formulas (e.g., Cardano's method). **Numerical Method (e.g., Bisection):** ✅ Provides an approximate solution with desired accuracy. ✅ Practical and efficient for real-world engineering problems. ---------------------------------- ``` ##### Slide 4: Bisection Method Introduction (IVT) ``` ---------------------------------- ### Bisection Method: The Core Idea **Based on the Intermediate Value Theorem (IVT):** If $f(x)$ is continuous on $[a, b]$ and $f(a)$ and $f(b)$ have opposite signs... ...then there **MUST** be at least one root between $a$ and $b$. ---------------------------------- ``` **(Self-drawn on board: A simple x-y axis. Mark 'a' and 'b' on x-axis. Draw a continuous curve where f(a) is negative and f(b) is positive. Show the curve crossing the x-axis between 'a' and 'b'.)** ##### Slide 5: Our Initial Interval ($f(x) = x^3 - 2x - 5$) ``` ---------------------------------- ### Our Initial Interval for $f(x) = x^3 - 2x - 5$ **Evaluate function at trial points:** • At $x = 2$: $f(2) = (2)^3 - 2(2) - 5 = 8 - 4 - 5 = -1$ (Negative) • At $x = 3$: $f(3) = (3)^3 - 2(3) - 5 = 27 - 6 - 5 = +16$ (Positive) **Conclusion:** Since $f(2)$ is negative and $f(3)$ is positive, by IVT, a root **MUST** exist within the interval $[2, 3]$. ---------------------------------- ``` **(Self-drawn on board: Write out the calculations for f(2) and f(3) clearly.)** ### 🎤 Person 2: Mathematical Foundation (5 minutes) #### 📝 Speaking Script (Word-by-Word) **[0:00-0:30] Opening** "Thank you [Previous Person]. I'm [Your Name], and I will now detail the precise mathematical steps that form the core of the Bisection Method, building upon the theoretical foundation just laid out." **[0:30-1:30] The Core Condition** "The entire iterative process of the Bisection Method hinges on one critical condition to ensure we are always bracketing a root: #### Root Bracketing Condition [Write big on board, or point to Slide 1] $$f(a) \times f(b) #### Midpoint Calculation [Write formula on board, or point to Slide 2] The midpoint, denoted as $c$, is found using a simple average: $$c = \frac{a + b}{2}$$ For our problem, with an initial interval of $[2, 3]$: $c = \frac{2 + 3}{2} = \frac{5}{2} = 2.5$ Now, we evaluate our function at this midpoint: $f(2.5) = (2.5)^3 - 2(2.5) - 5$ $= 15.625 - 5 - 5 = 5.625$ (which is positive)." **[2:30-3:30] Decision Making Logic** "This is where the method intelligently narrows down the search. We use the sign of $f(c)$ to determine which half of the interval still contains the root. #### Interval Refinement Logic [Draw number line/diagram on board, or point to Slide 3] Let's consider our current situation: * Original interval: $[2, 3]$ * $f(2) = -1$ (negative) * $f(3) = +16$ (positive) * Midpoint $c = 2.5$, with $f(2.5) = +5.625$ (positive) Now, we compare the signs: 1. Compare $f(a)$ and $f(c)$: $f(2) = -1$ (negative) and $f(2.5) = +5.625$ (positive). Since they have opposite signs, the root **must** lie in the interval $[a, c]$, which is $[2, 2.5]$. 2. Alternatively, compare $f(c)$ and $f(b)$: $f(2.5) = +5.625$ (positive) and $f(3) = +16$ (positive). Since they have the same sign, there is no guaranteed root in $[c, b]$. Thus, our **NEW** and smaller interval becomes $[2, 2.5]$. We effectively discard the right half of the previous interval. [Point to flowchart on Slide 3] The general logic is: * If $f(a) \times f(c) #### Convergence Rate * Initial interval: $[2, 3]$, length = 1 * After 1 step: $[2, 2.5]$, length = 0.5 * After 2 steps: $[2, 2.25]$, length = 0.25 * After $n$ steps: The interval length will be $(b-a)_{initial} / 2^n$. This predictable reduction in interval size implies a **linear rate of convergence**, making the method robust and reliable, albeit sometimes slower than other methods." **[4:00-4:45] Minimum Iterations Formula** "How many iterations, or steps, do we need to achieve a desired level of accuracy, also known as tolerance, denoted by $\epsilon$? #### Minimum Iterations for Desired Accuracy [Write formula on board, or point to Slide 4] The minimum number of iterations, $n$, can be calculated using the formula: $$n \geq \log_2\left(\frac{b-a}{\epsilon}\right)$$ Where: * $(b-a)$ is the length of the initial interval (which is $3-2=1$ for our problem). * $\epsilon$ is the desired error or tolerance. Let's assume we want an error of $0.001$. Plugging in our values: $n \geq \log_2\left(\frac{1}{0.001}\right) = \log_2(1000)$ Using a calculator, $\log_2(1000) \approx 9.9657$. Since the number of iterations must be an integer, we round up to ensure the condition is met: Therefore, we need a minimum of **10 iterations** to guarantee our desired accuracy of $0.001$." **[4:45-5:00] Handover** "So, in summary, we've established the mathematical backbone of the Bisection Method: 1. The crucial sign condition $f(a) \times f(b) **Example:** • $f(2) = -1$ • $f(3) = +16$ • $(-1) \times (+16) = -16 **Example for $[2, 3]$:** $c = \frac{2 + 3}{2} = 2.5$ **Evaluate $f(c)$:** $f(2.5) = (2.5)^3 - 2(2.5) - 5 = 5.625$ (Positive) ---------------------------------- ``` **(Self-drawn on board: Draw a number line with 'a', 'b', and 'c' marked. Write the formula clearly and perform the example calculation for $c$ and $f(c)$.)** ##### Slide 3: Decision Tree for Interval Refinement ``` ---------------------------------- ### Decision Tree for Interval Refinement **Logic:** 1. If $f(a) \times f(c) ### 🎤 Person 3: Algorithm & Flowchart (5 minutes) #### 📝 Speaking Script (Word-by-Word) **[0:00-0:30] Opening** "Thank you [Previous Person]. I'm [Your Name], and I will now translate the mathematical concepts into a concrete, step-by-step algorithm for the Bisection Method. This algorithm is essentially a precise recipe that we can then easily convert into computer code." **[0:30-1:30] Algorithm - Part 1 (Input & Validation)** "Let's walk through the complete algorithm, starting with the necessary inputs and crucial validation: #### Algorithm: Input and Validation [Point to Slide 1, Step 1] **STEP 1: INPUT PARAMETERS** * Get the lower bound, $a$, from the user (e.g., $a = 2$). * Get the upper bound, $b$, from the user (e.g., $b = 3$). * Get the desired tolerance/error, $\epsilon$, from the user (e.g., $\epsilon = 0.001$). [Point to Slide 1, Step 2] **STEP 2: INTERVAL VALIDATION** * Calculate $f(a)$ and $f(b)$. * **Crucially, check if $f(a) \times f(b) #### Algorithm: Iterative Refinement [Point to Slide 1, Step 3] **STEP 3: CALCULATE MINIMUM ITERATIONS** * Calculate the minimum number of iterations, $n$, required to achieve the desired tolerance using the formula: $n = \text{ceiling}(\log_2((b-a)/\epsilon))$. * For our problem: $n = \text{ceiling}(\log_2((3-2)/0.001)) = \text{ceiling}(\log_2(1000)) = \text{ceiling}(9.9657) = 10$. * It's good practice to display this number to the user. [Point to Slide 1, Step 4] **STEP 4: MAIN ITERATION LOOP** * Begin a loop that runs for $i = 1$ up to $n$ (or until convergence is met earlier): * **4.1: Calculate Midpoint:** $c = (a + b) / 2$. * **4.2: Evaluate Function at Midpoint:** Calculate $f(c)$. * **4.3: Display Progress:** Print the current iteration number, $a$, $b$, $c$, and $f(c)$ to track the method's progress. * **4.4: Check Stopping Conditions:** * If $|f(c)| = 0$ (meaning we found the exact root) OR * If $|b-a| #### Flowchart of the Bisection Method [Show large flowchart on Slide 2] "This flowchart visually maps out the entire algorithm. Let me trace the first iteration of our example through it: * **START** * **INPUT $a=2, b=3, \epsilon=0.001$** * **CHECK $f(a) \times f(b) #### Dry Run: First 3 Iterations [Point to Slide 3, Dry Run Table] **Iteration 1:** * $a = 2, b = 3$ * $c = (2 + 3) / 2 = 2.5$ * $f(c) = f(2.5) = 5.625$ * Check condition: $f(a) \times f(c) = (-1) \times (5.625) = -5.625 ---------------------------------- ``` **(Self-drawn on board: Draw a large, clear flowchart. Use standard flowchart symbols: ovals for start/end, parallelograms for input/output, rectangles for processes, diamonds for decisions. * **Start** (oval) * **Input a, b, epsilon** (parallelogram) * **Is f(a)*f(b) **Error, Stop** (parallelogram, oval) * Yes -> **Calculate n_min** (rectangle) * **Loop: i = 1 to n_min** (connector to loop, then rectangle for loop initialization) * **c = (a+b)/2** (rectangle) * **Calculate f(c)** (rectangle) * **Print i, a, b, c, f(c)** (parallelogram) * **Is |f(c)|==0 OR |b-a| **Break Loop** (connector out of loop) * No -> **Is f(a)*f(c) **b = c** (rectangle) * No -> **a = c** (rectangle) * **Increment i** (rectangle, then loop back) * **Print c (Root)** (parallelogram) * **Stop** (oval) Ensure arrows clearly indicate flow direction.)** ##### Slide 3: Dry Run Table (First 4 Iterations) ``` ---------------------------------- ### Dry Run Table: First 4 Iterations | Iter (i) | $a$ | $b$ | $c$ | $f(c)$ | New Interval | |----------|----------|----------|----------|------------|--------------| | 1 | 2.000000 | 3.000000 | 2.500000 | 5.625000 | $[2, 2.5]$ | | 2 | 2.000000 | 2.500000 | 2.250000 | 1.890625 | $[2, 2.25]$ | | 3 | 2.000000 | 2.250000 | 2.125000 | 0.353516 | $[2, 2.125]$ | | 4 | 2.000000 | 2.125000 | 2.062500 | -0.351318 | $[2.0625, 2.125]$ | ---------------------------------- ``` **(Self-drawn on board: Draw a clear table and fill in the first 3-4 iterations as shown, highlighting the changing interval.)** ### 🎤 Person 4: Code Explanation (5 minutes) #### 📝 Speaking Script (Word-by-Word) **[0:00-0:30] Opening** "Thank you [Previous Person]. I'm [Your Name], and I will now demonstrate how we translate our robust algorithm into executable Python code. We'll examine the code structure, explain key sections line by line, and then perform a live execution to see the Bisection Method in action." **[0:30-1:30] Code Structure Overview** "Here is the complete Python code implementing the Bisection Method, including functionalities for both static and animated visualizations. #### Code Structure Overview [Display Code Block 1 on screen/slide] ```python import math # For log and ceiling functions import numpy as np # For numerical operations and array creation import matplotlib.pyplot as plt # For plotting graphs from matplotlib.widgets import Button # For interactive animation buttons # 1. Function Definition def f(x): return x**3 - 2*x - 5 # 2. Bisection Method Core Logic def bisection_method(a, b, e): # Implementation of the algorithm's steps ... # 3. Static Plotting Function def plot_static(a, b, midpoints, root): # Generates a single plot showing all iterations ... # 4. Animation Class class BisectionAnimated: # Handles interactive step-by-step visualization ... # 5. Main Program Execution Block if __name__ == "__main__": # Handles user input, calls bisection_method, and then visualization ... ``` "We've structured the code into distinct functions and a class for clarity, modularity, and reusability, adhering to good programming practices. This makes it easier to understand, debug, and extend." **[1:30-2:30] Function Definition & Input/Validation Section** "Let's zoom into the initial segments of the code, focusing on the function definition and the critical input and validation steps. #### Function Definition, Input & Validation Code [Display Code Block 2 on screen/slide] ```python # Import necessary libraries import math import numpy as np import matplotlib.pyplot as plt from matplotlib.widgets import Button # The function whose root we are finding # This is f(x) = x^3 - 2x - 5 def f(x): return x**3 - 2*x - 5 # --- Main Program Execution Block --- if __name__ == "__main__": print("="*60) print("BISECTION METHOD - Find root of f(x) = x³ - 2x - 5") print("="*60) # Get user input for interval and tolerance try: a = float(input("\nEnter lower limit (a): ")) # Convert input to float b = float(input("Enter upper limit (b): ")) # Upper bound of the interval e = float(input("Enter tolerance (error): ")) # Desired accuracy except ValueError: print("❌ Error: Please enter valid numerical values for limits and tolerance!") exit() # Terminate if input is not valid numbers # Crucial Validation check: f(a) and f(b) must have opposite signs if f(a) * f(b) >= 0: print("❌ Error: Invalid interval! f(a) and f(b) must have opposite signs to guarantee a root.") print(f"f({a}) = {f(a):.4f}, f({b}) = {f(b):.4f}") exit() # Stop program if the interval is invalid # Calculate and display the minimum required iterations n_min = math.ceil(math.log((b - a) / e, 2)) # Using math.log(x, 2) for log base 2 print(f"\n📊 Minimum iterations required for ε={e}: {n_min}") # ... (rest of the main program) ``` "Here, `import math` allows us to use `math.ceil` for rounding up and `math.log` for base-2 logarithms in our iteration formula. The `f(x)` function directly implements our polynomial. The `if __name__ == "__main__":` block is standard Python practice for executable scripts. We use `float(input(...))` to get numerical values from the user and include robust error handling with a `try-except` block for `ValueError`. Most importantly, the `if f(a) * f(b) >= 0:` statement directly implements our crucial validation step, terminating the program if the initial interval does not bracket a root." **[2:30-3:30] Bisection Loop Explanation** "Now, let's examine the heart of the Bisection Method: the iterative loop that refines our interval. This is encapsulated within our `bisection_method` function. #### Bisection Loop Code [Display Code Block 3 on screen/slide] ```python # ========== BISECTION METHOD ========== def bisection_method(a, b, e): """ Perform bisection method to find a root of f(x). Args: a (float): Lower limit of the interval. b (float): Upper limit of the interval. e (float): Desired tolerance (error). Returns: tuple: (approximate_root, list_of_midpoints) """ # (Validation check is moved to main block for early exit) # Calculate minimum iterations (already checked in main for display) n_min = math.ceil(math.log((b - a) / e, 2)) midpoints = [] # List to store all calculated midpoints for plotting later # Print a formatted header for the iteration table print("\n" + "="*60) print("Iter\t a\t\t b\t\t c\t\t f(c)") print("="*60) # Main iteration loop: runs for n_min specified iterations for i in range(1, n_min + 1): c = (a + b) / 2 # Step 4.1: Calculate midpoint fc = f(c) # Step 4.2: Evaluate f(c) midpoints.append(c) # Store midpoint for visualization # Step 4.3: Display iteration details, formatted to 6 decimal places print(f"{i}\t{a:.6f}\t{b:.6f}\t{c:.6f}\t{fc:.6f}") # Step 4.4: Check stopping conditions # If f(c) is exactly zero or interval width is less than tolerance if fc == 0 or abs(b - a) #### Static Plot Function Code [Display Code Block 4 on screen/slide] ```python # ========== STATIC PLOT ========== def plot_static(a, b, midpoints, root): """ Creates a static plot showing the function, the root, and all calculated midpoints. """ # Generate x-values for a smooth curve from a slightly wider range x = np.linspace(a - 1, b + 1, 200) y = f(x) # Calculate corresponding y-values for the function plt.figure(figsize=(12, 7)) # Set up the plot figure size # Plot the function curve plt.plot(x, y, 'b-', linewidth=2.5, label='f(x) = x³ - 2x - 5') # Plot the x-axis (where f(x)=0) plt.axhline(y=0, color='black', linestyle='-', linewidth=1) # Plot initial interval boundaries as dashed lines plt.axvline(x=a, color='gray', linestyle=':', alpha=0.5, label='Initial Interval') plt.axvline(x=b, color='gray', linestyle=':', alpha=0.5) # Plot each midpoint as a scatter point with an iteration number for i, m in enumerate(midpoints): plt.scatter(m, f(m), color='red', s=100, zorder=5, edgecolors='darkred', linewidth=2) plt.text(m, f(m), f' {i+1}', fontsize=12, fontweight='bold', verticalalignment='bottom') # Plot the final approximated root with a dashed green line and a star marker plt.axvline(x=root, color='green', linestyle='--', linewidth=2.5, label=f'Final Root = {root:.6f}') plt.scatter(root, f(root), color='green', s=200, zorder=10, marker='*', edgecolors='darkgreen', linewidth=2) # Add grid, legend, title, and labels for better readability plt.grid(True, alpha=0.3) plt.legend(fontsize=11) plt.title('Bisection Method - Convergence of Midpoints', fontsize=16, fontweight='bold') plt.xlabel('x', fontsize=12) plt.ylabel('f(x)', fontsize=12) # Add a text box with summary information info_text = f'Initial interval: [{a:.1f}, {b:.1f}]\nIterations: {len(midpoints)}\nRoot: {root:.6f}' plt.text(0.02, 0.98, info_text, transform=plt.gca().transAxes, fontsize=10, verticalalignment='top', bbox=dict(boxstyle='round', facecolor='wheat', alpha=0.5)) plt.tight_layout() # Adjust plot to prevent labels from overlapping plt.show() # Display the plot ``` "This function uses `matplotlib` to create a visual representation. `np.linspace` generates a range of x-values for a smooth curve. We plot the function, the x-axis, and special markers for each calculated midpoint, labeled with their iteration number. The final root is highlighted with a distinct line and a star marker. This plot effectively shows how the midpoints progressively converge towards the root." **[4:15-4:45] Animation Class** "For an even more dynamic understanding, we've implemented an animation class. #### Animation Class Code [Display Code Block 5 on screen/slide] ```python # ========== ANIMATION CLASS ========== class BisectionAnimated: """ Class to handle animation of midpoints, showing convergence step-by-step. """ def __init__(self, a, b, midpoints, root): self.midpoints = midpoints self.root = root self.current_index = 0 # Tracks which midpoint to display next # Setup the plot figure self.fig, self.ax = plt.subplots(figsize=(12, 7)) plt.subplots_adjust(bottom=0.2) # Make space for buttons # Plot static elements of the graph (function, x-axis, final root) x = np.linspace(a - 1, b + 1, 200) y = f(x) self.ax.plot(x, y, 'b-', linewidth=2.5, label='f(x)') self.ax.axhline(y=0, color='black', linewidth=1) self.ax.axvline(x=root, color='green', linestyle='--', linewidth=2, label=f'Root = {root:.6f}') # Initialize scatter plot for midpoints (initially empty) self.scat = self.ax.scatter([], [], color='red', s=100, edgecolors='darkred', linewidth=2, zorder=5) # List to hold text annotations for each midpoint self.texts = [] # Formatting for the plot self.ax.grid(True, alpha=0.3) self.ax.legend(fontsize=11) self.ax.set_title('Bisection Method - Animation', fontsize=16, fontweight='bold') self.ax.set_xlabel('x', fontsize=12) self.ax.set_ylabel('f(x)', fontsize=12) # Create 'Show Next Midpoint' button ax_button = plt.axes([0.4, 0.05, 0.2, 0.075]) # Position of button self.button = Button(ax_button, '▶ Show Next Midpoint') self.button.on_clicked(self.show_next) # Link button click to show_next method # Create 'Reset Animation' button ax_reset = plt.axes([0.65, 0.05, 0.2, 0.075]) self.reset_button = Button(ax_reset, '↺ Reset Animation') self.reset_button.on_clicked(self.reset) # Link button click to reset method plt.show() # Display the interactive plot def show_next(self, event): """Method called when 'Show Next Midpoint' button is clicked.""" if self.current_index #### Code Execution Demonstration [Run the code live, or show a video/screenshot of the output] "Upon execution, the console output details each iteration, showing `a`, `b`, `c`, and `f(c)`. [Point to console output] * We observe the 10 required iterations. * The approximate root is displayed as `2.094551`. * The function value at this root, `f(root)`, is approximately `-1.953125e-04`, which is very close to zero, validating our result. [Show the static plot first] "A static plot will appear, clearly marking all 10 midpoints converging towards the root. [Then, show the animated plot and demonstrate clicking the button] "Following this, the interactive animation plot appears. With each click of the 'Show Next Midpoint' button, a new midpoint appears, visually tracing the path of convergence. Now, [Next Person] will provide a detailed analysis of these results, discuss the convergence, and further elaborate on the visualizations. Thank you!" #### 🎨 Visual Aids for Person 4 ##### Code Block 1: Code Structure Overview ```python """ BISECTION METHOD - COMPLETE IMPLEMENTATION Function: f(x) = x³ - 2x - 5 Features: Static plot + Animate button """ import math # For log and ceiling functions import numpy as np # For numerical operations and array creation import matplotlib.pyplot as plt # For plotting graphs from matplotlib.widgets import Button # For interactive animation buttons # 1. Function Definition def f(x): return x**3 - 2*x - 5 # 2. Bisection Method Core Logic def bisection_method(a, b, e): # Implementation of the algorithm's steps ... # 3. Static Plotting Function def plot_static(a, b, midpoints, root): # Generates a single plot showing all iterations ... # 4. Animation Class class BisectionAnimated: # Handles interactive step-by-step visualization ... # 5. Main Program Execution Block if __name__ == "__main__": # Handles user input, calls bisection_method, and then visualization ... ``` ##### Code Block 2: Function Definition & Input/Validation Section ```python # Import necessary libraries import math import numpy as np import matplotlib.pyplot as plt from matplotlib.widgets import Button # The function whose root we are finding # This is f(x) = x^3 - 2x - 5 def f(x): return x**3 - 2*x - 5 # --- Main Program Execution Block --- if __name__ == "__main__": print("="*60) print("BISECTION METHOD - Find root of f(x) = x³ - 2x - 5") print("="*60) # Get user input for interval and tolerance try: a = float(input("\nEnter lower limit (a): ")) # Convert input to float b = float(input("Enter upper limit (b): ")) # Upper bound of the interval e = float(input("Enter tolerance (error): ")) # Desired accuracy except ValueError: print("❌ Error: Please enter valid numerical values for limits and tolerance!") exit() # Terminate if input is not valid numbers # Crucial Validation check: f(a) and f(b) must have opposite signs if f(a) * f(b) >= 0: print("❌ Error: Invalid interval! f(a) and f(b) must have opposite signs to guarantee a root.") print(f"f({a}) = {f(a):.4f}, f({b}) = {f(b):.4f}") exit() # Stop program if the interval is invalid # Calculate and display the minimum required iterations n_min = math.ceil(math.log((b - a) / e, 2)) # Using math.log(x, 2) for log base 2 print(f"\n📊 Minimum iterations required for ε={e}: {n_min}") # ... (rest of the main program) ``` ##### Code Block 3: Bisection Loop Explanation ```python # ========== BISECTION METHOD ========== def bisection_method(a, b, e): """ Perform bisection method to find a root of f(x). Args: a (float): Lower limit of the interval. b (float): Upper limit of the interval. e (float): Desired tolerance (error). Returns: tuple: (approximate_root, list_of_midpoints) """ # (Validation check is moved to main block for early exit) # Calculate minimum iterations (already checked in main for display) n_min = math.ceil(math.log((b - a) / e, 2)) midpoints = [] # List to store all calculated midpoints for plotting later # Print a formatted header for the iteration table print("\n" + "="*60) print("Iter\t a\t\t b\t\t c\t\t f(c)") print("="*60) # Main iteration loop: runs for n_min specified iterations for i in range(1, n_min + 1): c = (a + b) / 2 # Step 4.1: Calculate midpoint fc = f(c) # Step 4.2: Evaluate f(c) midpoints.append(c) # Store midpoint for visualization # Step 4.3: Display iteration details, formatted to 6 decimal places print(f"{i}\t{a:.6f}\t{b:.6f}\t{c:.6f}\t{fc:.6f}") # Step 4.4: Check stopping conditions # If f(c) is exactly zero or interval width is less than tolerance if fc == 0 or abs(b - a) ### 🎤 Person 5: Results, Graph & Animation (5 minutes) #### 📝 Speaking Script (Word-by-Word) **[0:00-0:30] Opening** "Thank you [Previous Person]. I'm [Your Name], and I will now present and thoroughly analyze the results obtained from our Python implementation. We'll delve into the iteration table, examine the convergence characteristics, and demonstrate the powerful visualization features, including the interactive animation." **[0:30-1:30] Complete Iteration Table** "Let's review the complete iteration table generated by our program for $f(x) = x^3 - 2x - 5$, with an initial interval $[2, 3]$ and tolerance $\epsilon=0.001$. As predicted by our formula, exactly 10 iterations were performed. #### Complete Iteration Table [Display Slide 1: Complete Results, or the actual console output] ``` ==================================================================== Iter a b c f(c) ==================================================================== 1 2.000000 3.000000 2.500000 5.625000 2 2.000000 2.500000 2.250000 1.890625 3 2.000000 2.250000 2.125000 0.353516 4 2.000000 2.125000 2.062500 -0.351318 5 2.062500 2.125000 2.093750 -0.008942 6 2.093750 2.125000 2.109375 0.166832 7 2.093750 2.109375 2.101562 0.078562 8 2.093750 2.101562 2.097656 0.034714 9 2.093750 2.097656 2.095703 0.012861 10 2.093750 2.095703 2.094727 0.001953 ==================================================================== ``` **Key Observations from the Table:** * **Interval Halving:** Notice how the difference between `a` and `b` systematically halves with each iteration. For example, from $[2,3]$ (length 1) to $[2, 2.5]$ (length 0.5), and so on. * **$f(c)$ Approaching Zero:** The value of $f(c)$ progressively decreases in magnitude, eventually getting very close to zero. It starts at $5.625$ and ends at $0.001953$. * **Sign Alternation:** The sign of $f(c)$ alternates (positive, positive, positive, negative, negative, positive...), indicating that the root is continuously being bracketed within the shrinking interval." **[1:30-2:30] Convergence Analysis** "Let's formally analyze the convergence of the Bisection Method. #### Convergence Analysis [Point to Slide 2: Convergence Analysis] The error in the Bisection Method is defined as half the length of the current interval. * Initial interval length: $b-a = 3-2 = 1$. * Maximum initial error: $\frac{1}{2} = 0.5$. Consider the maximum possible error after $k$ iterations: $$E_k = \frac{(b-a)_{initial}}{2^{k+1}}$$ Our desired tolerance ($\epsilon$) was $0.001$. This means we want the interval length to be less than $2\epsilon = 0.002$. After 10 iterations, the interval length is $(3-2)/2^{10} = 1/1024 \approx 0.000976$. The maximum error is then $0.000976 / 2 \approx 0.000488$. This value, $0.000488$, is significantly less than our target tolerance of $0.001$, confirming that our 10 iterations were sufficient to meet the accuracy requirement. The Bisection Method exhibits **linear convergence**, meaning the error is reduced by a constant factor (1/2) in each step." **[2:30-3:15] Final Root Verification** "Our algorithm yielded an approximate root of $x \approx 2.094727$. Let's verify this by plugging it back into our function. #### Final Root Verification [Point to Slide 1: Final Results] Our computed root after 10 iterations is: $x = 2.0947265625$ (from the last $c$ value). Let's plug this into $f(x) = x^3 - 2x - 5$: $f(2.0947265625) = (2.0947265625)^3 - 2(2.0947265625) - 5$ $= 9.191295 - 4.189453 - 5$ $= 0.001842$ While not exactly zero, $0.001842$ is very close to zero, and importantly, it is less than our specified tolerance of $0.001$. In fact, if we had let the algorithm run for more iterations, it would converge even closer. The actual root is approximately $2.09455148154233$. Our result is accurate to several decimal places, well within the required bounds." **[3:15-4:00] Static Plot Explanation** "Now, let's turn our attention to the visual output. #### Static Plot Demonstration [Display Static Plot on screen/projector] "This static plot provides a comprehensive overview of the Bisection Method's process. [Point to each element on the plot] 1. **Blue Curve:** This represents our function, $f(x) = x^3 - 2x - 5$. 2. **Black Line:** This is the x-axis, where $f(x) = 0$, indicating the location of the root. 3. **Red Dots with Numbers:** These are all 10 midpoints ($c_1, c_2, \dots, c_{10}$) calculated during the iterations. Each dot is labeled with its iteration number. 4. **Green Dashed Line and Star:** This clearly marks the final approximate root found by the algorithm, $x \approx 2.0947$. Observe how the red dots, representing the successive midpoints, progressively cluster closer and closer to the green dashed line. The first few midpoints show larger jumps, while later ones become almost indistinguishable as they 'hone in' on the true root. This visually confirms the method's convergence." **[4:00-4:45] Animation Demonstration** "For an even deeper understanding of the iterative nature, let's explore the animation feature. #### Animation Demonstration [Switch to the BisectionAnimated plot and interactively demonstrate] "Here, we have an interactive plot. The function and the final root are already shown. Now, watch what happens as I click the '▶ Show Next Midpoint' button: * **Click 1:** The first midpoint, $c_1 = 2.5$, appears. * **Click 2:** The second midpoint, $c_2 = 2.25$, appears. * **Click 3:** The third midpoint, $c_3 = 2.125$, appears. * **Click 4:** The fourth midpoint, $c_4 = 2.0625$, appears. * ...and so on... Each click reveals the next step in the bisection process, showing how the interval is repeatedly narrowed. [Click the '↺ Reset Animation' button] "We can also reset the animation at any time and replay the entire convergence process. This dynamic visualization is incredibly valuable for understanding the **process** of convergence, not just the final result, making it an excellent educational tool." **[4:45-5:00] Conclusion** "To recap our findings from this comprehensive analysis: #### Conclusion Summary [Display Slide 4: Conclusion Summary] * ✅ **Root Found:** We successfully approximated the root of $f(x) = x^3 - 2x - 5$ to be $x \approx 2.0947$. * ✅ **Accuracy Achieved:** Our result met and even exceeded the required tolerance of $\epsilon=0.001$. * ✅ **Iterations Needed:** Exactly 10 iterations were performed as calculated. * ✅ **Verification:** The function value at our found root, $f(2.0947) \approx 0.0018$, is practically zero. The Bisection Method has proven to be a reliable and straightforward numerical technique for finding roots of continuous functions within a given interval, with its convergence clearly demonstrated through both numerical tables and interactive visualizations. Thank you all for your attention! Our group is now ready to answer any questions you may have." #### 🎨 Visual Aids for Person 5 ##### Slide 1: Complete Results ``` ---------------------------------- ### BISECTION METHOD - COMPLETE RESULTS **Function:** $f(x) = x^3 - 2x - 5$ **Initial Interval:** $[2, 3]$ **Tolerance ($\epsilon$):** $0.001$ **Final Approximate Root:** $x \approx 2.0947265625$ **Function Value at Root:** $f(2.0947265625) \approx 0.001842$ (Very close to 0!) **Total Iterations:** 10 **Verification:** $f(2.0947265625) = (2.0947265625)^3 - 2(2.0947265625) - 5$ $= 9.191295 - 4.189453 - 5$ $= 0.001842 \approx 0$ ✓ ---------------------------------- ``` **(Self-drawn on board: Write the final root and the verification calculation clearly.)** ##### Slide 2: Convergence Analysis ``` ---------------------------------- ### Convergence Analysis **Method:** Linear Convergence (Error halves each iteration) **Maximum Error after $k$ iterations:** $E_k = \frac{(b-a)_{initial}}{2^{k+1}}$ **Our Case:** • Initial interval length $(b-a)_{initial} = 1$ • After $k=9$ iterations (before the last update of $c_{10}$): Interval length = $1 / 2^9 = 1/512 \approx 0.001953$ Max Error $E_9 = 0.001953 / 2 \approx 0.000976$ **Conclusion:** $0.000976 **Key Visuals:** • **Blue Curve:** $f(x) = x^3 - 2x - 5$ • **Black Line:** X-axis ($f(x)=0$) • **Red Dots (1-10):** Successive midpoints ($c_i$) • **Green Dashed Line/Star:** Final approximate root **Observation:** Midpoints clearly 'hone in' on the root as iterations progress. ---------------------------------- ``` **(Will be displayed live by Person 4's code. This slide is a placeholder/backup screenshot. Person 5 will point to elements on the live plot.)** ##### Slide 4: Animation Demonstration (Example - will be generated live) ``` ---------------------------------- ### Visual Interpretation: Animation Demonstration **Interactive Features:** • **▶ Show Next Midpoint:** Reveals one midpoint at a time. • **↺ Reset Animation:** Clears points to replay the process. **Benefit:** Dynamically illustrates the iterative refinement and convergence process. ---------------------------------- ``` **(Will be displayed live by Person 4's code. This slide is a placeholder/backup screenshot. Person 5 will interact with the live animation.)** ##### Slide 5: Conclusion Summary ``` ---------------------------------- ### Conclusion Summary **The Bisection Method for $f(x) = x^3 - 2x - 5$:** ✅ **Root Found:** $x \approx 2.0947$ ✅ **Accuracy:** Achieved $\epsilon ### ❓ Q&A Preparation - Anticipated Questions #### Questions & Perfect Answers: **Q1: "What if $f(a)$ and $f(b)$ have the SAME sign?"** **Answer:** "If $f(a)$ and $f(b)$ have the same sign, the Intermediate Value Theorem cannot guarantee a root within that interval. The function might not cross the x-axis at all, or it might cross an even number of times. Our algorithm includes a validation step to detect this and terminate. In such cases, we would need to choose a different initial interval or employ other numerical methods, such as the Newton-Raphson method, which doesn't rely on bracketing." **Q2: "Why 10 iterations? Can we do fewer?"** **Answer:** "We calculated the minimum number of iterations, $n=10$, using the formula $n \geq \log_2((b-a)/\epsilon)$. This formula provides a **guarantee** that our desired tolerance will be met. In our actual execution, we observed that by iteration 5, the interval length was already less than $2\epsilon$, meaning the root was found with sufficient accuracy earlier. So, while 10 iterations are guaranteed, the loop can (and often does) break earlier if the stopping conditions are met. The `n_min` calculation sets an upper bound for the number of iterations required." **Q3: "What's the difference between your static plot and animation?"** **Answer:** "The static plot displays **all** the calculated midpoints simultaneously on a single graph. It's excellent for seeing the overall convergence pattern and the final result at a glance. In contrast, the animation allows us to visualize the process **step-by-step**. By clicking the 'Show Next Midpoint' button, we can see each iteration's midpoint appear sequentially, providing a dynamic understanding of how the interval shrinks and the root is approached. Think of the static plot as a complete photograph, and the animation as a video of the process unfolding." **Q4: "What happens if the function has multiple roots?"** **Answer:** "That's an excellent question. The Bisection Method, when applied to a given interval, will converge to **one** root if $f(a)$ and $f(b)$ have opposite signs. If a function has multiple roots, we would need to identify separate initial intervals, each containing only one root, and apply the Bisection Method to each interval individually. For our specific cubic function, $f(x) = x^3 - 2x - 5$, it has only one real root, which our method successfully found." **Q5: "How accurate is your answer?"** **Answer:** "Our final approximate root, $x \approx 2.0947265625$, yielded $f(x) \approx 0.001842$. While this is not exactly zero, it is well within our specified tolerance of $0.001$. In fact, the true root is approximately $2.09455148154233$. Comparing our result to the true value, the absolute error is roughly $|2.0947265625 - 2.09455148154233| \approx 0.000175$. This demonstrates that the method provides a highly accurate approximation, far exceeding the initial $\epsilon$ requirement due to the nature of interval halving." **Q6: "Can the method fail or encounter issues?"** **Answer:** "Yes, the Bisection Method has a few conditions for its successful application: 1. **Invalid Initial Interval:** As we discussed, if $f(a)$ and $f(b)$ do not have opposite signs, the method cannot proceed as it's not guaranteed a root exists. Our code explicitly checks for this. 2. **Discontinuous Function:** The method relies on the Intermediate Value Theorem, which requires the function to be continuous within the interval. If the function has a discontinuity or a vertical asymptote within $[a, b]$, the method might fail or give a misleading result. 3. **Root at Endpoint:** If an exact root lies precisely at $a$ or $b$, the method would potentially still converge, but the $f(c)=0$ stopping condition might be met very early. 4. **Slow Convergence for Steep Functions:** While guaranteed to converge, the Bisection Method can be slow for functions that are very steep near the root, as it doesn't utilize the derivative (slope) information like other methods (e.g., Newton-Raphson)." ### 📊 Marking Scheme - How to Get 10/10 | Criteria | What to Show | Marks | |--------------------------------|-----------------------------------------------|-------| | **Theory** (Person 1) | Explain root, IVT, need for numerical methods, initial interval. | 2 | | **Mathematics** (Person 2) | Formulas ($f(a)f(b) ### 🏆 Final Tips for Success #### DO's: ✅ **Speak Clearly and Confidently:** Project your voice, make eye contact, and articulate your points with conviction. ✅ **Point to Visuals:** Actively use your slides, board drawings, and live code. Point to specific elements as you discuss them. ✅ **Engage the Audience:** Use rhetorical questions, invite participation, and maintain a friendly demeanor. ✅ **Practice Transitions:** Ensure smooth handovers between speakers to maintain flow and timing. ✅ **Run Code Pre-Presentation:** Test all code thoroughly beforehand to prevent live demo issues. ✅ **Have Backup Screenshots:** Prepare screenshots of code and plots in case of technical difficulties during the live demo. ✅ **Time Your Section:** Practice with a timer to ensure you stay within your 5-minute limit. ✅ **Understand Your Content Deeply:** Be prepared to elaborate or simplify any point based on questions. #### DON'Ts: ❌ **Read Directly from Script:** Use the script as a guide, but speak naturally and make it sound conversational. ❌ **Rush Through Slides:** Give the audience time to absorb each visual and concept. ❌ **Ignore the Audience:** Maintain eye contact and respond to non-verbal cues. ❌ **Let One Person Dominate:** Ensure equitable participation and speaking time among group members. ❌ **Forget to Introduce Each Speaker:** Acknowledge the previous speaker and smoothly introduce the next. ❌ **Apologize for Minor Glitches:** If a small issue occurs, address it quickly and move on without dwelling. ❌ **Over-Complicate Explanations:** Keep explanations concise and clear, especially for foundational concepts. ### 🎯 Group Coordination Sheet ``` GROUP [Your Number] - SECTION [Your Section] Person 1 (Introduction & Theory): [Name] Person 2 (Mathematical Foundation): [Name] Person 3 (Algorithm & Flowchart): [Name] Person 4 (Code Explanation): [Name] Person 5 (Results, Graph & Animation): [Name] Practice Schedule: - Practice 1: [Date/Time] - Practice 2: [Date/Time] - Final Run: [Date/Time] Contact: [Group WhatsApp/Telegram/Email Thread] Notes: - Ensure all members are familiar with the entire presentation, not just their part. - Prepare for potential questions beyond the anticipated list. - Confirm projector/screen compatibility for code and plots. - Assign a timekeeper for practice sessions to ensure strict adherence to 5-minute slots. ```