bisection method: Simulating a retirement fund

Baba raoulbia at
Fri Sep 3 10:06:14 CEST 2010

On Sep 2, 11:10 pm, MRAB <pyt... at> wrote:
> Why are you saving 'fund' in SavingsRecord if you're returning just the
> last and discarding others? Basically you're returning the final value
> of fund.


ok i agree that this is not be ideal. I should shorten this to ONLY
return SavingsRecord[-1]

> When performing this type of 'search' make sure that the interval (high
> - low) reduces at every step. > (integer division) and if the 'if' condition happens to be false
> then the value of 'low' won't change for the next iteration, leading to an infinite loop.

If you look at the output you will see that the interval DOES seem to
reduce at each interval as expenses and fundsize reduce gradually. The
computation does not lead to an infinite loop.


More information about the Python-list mailing list