MANE 3351
Lecture 8
Classroom Management
Agenda
- Part 2: Bisection Search lecture
- Test 1
Resources
Handouts
Assignments
- Homework 1 (assigned 9/16/2024, due 9/23/2024 (before 11:59 pm)
- Homework 2 (assigned 9/18/2024, due 9/25/2024 (before 11:59 pm - no late submissions)
- Lab 3 (assigned 9/18/2024, due 9/25/2024 (before 2:00pm))
- Read textbook pages 41-46
Schedule
| Lecture/Lab | Date | Topic |
|---|---|---|
| 8 | 9/23 | Roots of Equations, bisection method (not on Test 1) |
| 9 | 9/25 | Bisection Method Error Analysis, False Position (not on Test 1) |
| 10 | 9/30 | Test 1 (lectures 1-7) |
Roots of Equations
Introduction
- Value x such that f(x)=0
- Extremely useful operations
- Engineering Economic Examples
- Break-even analysis
- Payback period
- Rate of return
Quadratic Equation
Consider a second-order polynomial \(ax^2+bx+c=0\)
- The quadratic formula finds the value(s) of x
\[
\frac{-b\pm\sqrt{b^2-4ac}}{2a}
\]
Root Bracketing Techniques
- Many techniques for find roots start by bracketing the root
- Consider the cumulative distribution function (CDF) of a standard normal distribution
\[
\Phi(z)=\int_{-\infty}^z\frac{1}{\sqrt{2\pi}}\exp\left(-\frac{1}{2}u^2\right)\;du
\]
- Goal: Find first quartile that is the value of z such that \(\phi(z)=0.25\)
- Start up writing equation
- Trial and error
- Python can help
Statistical Functions in Python
Python Code for Statistical Functions
from scipy import stats
p=0.25
x=float(input("Enter the value of x: "))
fx=stats.norm.cdf(x)
print("for x={}, f({})={}".format(x,x,fx))
print("{}-th percentile={}".format(p,stats.norm.ppf(p)))
Bisection Method
- Identify an interval [a,b] such that either a or b overshoots the mark while the other undershoots it.
- Calculate the midpoint, m, of the identified interval
- If a and m both overshoot or both undershoot the mark, the desired value lies in [m,b]
- If b and m both overshoots or both undershoot the mark, the desired value lies in [a,m]
- Return to step 2 using the newly identified interval
Source: textbook, page 41
Simple Pseudocode

Source: textbook, page 43
Python code for Simple Pseudocode
#from scipy import stats
def f(x):
return stats.norm.cdf(x)-.25
# initialize code
a=-0.9
b=0.9
i=1
L=f(a)
m=(a+b)/2.0 # discuss divisor
M=f(m)
while True:
if L*M<0.0:
b=m
else:
a=m
L=M
m=(a+b)/2.0
M=f(m)
i=i+1
print("iteration {}, root is located at {}".format(i,m))
print("{} iterations processed".format(i))
print("the root is {} with f({})={}".format(m,m,M))
Pseudocode 2

Source: textbook, page 43
Python Code for Pseudocode 2
# Pseudo-code 2
from scipy import stats
import math
def f(x):
return stats.norm.cdf(x)-.25
# initialize code
a=-3.0
b=0.0
tol=0.0005
N=100
err=math.fabs(b-a)
L=f(a)
for i in range(0,N+1):
m=(a+b)/2.0
M=f(m)
err=err/2.0
if (M==0) or (err<tol):
print("stopping inside for loop at iteration {}".format(i))
break
if (L*M<0):
b=m
else:
a=m
L=M
print("the root is {} with f({})={}".format(m,m,M))
Software
- It should be apparent that having software to follow the lectures is very helpful