bisection method: Simulating a retirement fund

MRAB python at mrabarnett.plus.com
Fri Sep 3 13:12:49 EDT 2010


On 03/09/2010 09:06, Baba wrote:
> On Sep 2, 11:10 pm, MRAB<pyt... at mrabarnett.plus.com>  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.
>
> Hi MRAB
>
> 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.
>
It doesn't in that particular case, but it might in some other cases.



More information about the Python-list mailing list