Hello,
First of all, I wanted to thank the contributors to this site. I learned a lot from the lectures and I’m a very satisfied user of you module quantecon.py!
I would change a small detail to the solution of ex 1 of the lecture about SciPy. The function bisect() you propose does not return anything (except the output from print). Here is a simple way to fix it (the 3 lines containing “result” have been changed/added):
def bisect(f, a, b, tol=10e-5):
"""
Implements the bisection root finding algorithm, assuming that f is a
real-valued function on [a, b] satisfying f(a) < 0 < f(b).
"""
lower, upper = a, b
if upper - lower < tol:
return 0.5 * (upper + lower)
else:
middle = 0.5 * (upper + lower)
if f(middle) > 0: # Implies root is between lower and middle
result = bisect(f, lower, middle)
else: # Implies root is between middle and upper
result = bisect(f, middle, upper)
return result
Again, thanks for your great work!