I'm really struggling with Prob Set #1, Prob # 3. Can anyone recommend a resource to help better understand the Bisection method?
Did you watch the video of the lecture #3?
Yes, I've watched the lectures up to #4 each 2-3 times. It's Problem #3 of Problem Set #1 that's really stumping me. I've tried it at least 3 times without success. I can't seem to figure out how to get the payment variable to change based on the difference of plus or minus from variable newBalance after the for loop. I'm no doubt missing something.
Could you show here the source code you have made for this problem?
balance = float(raw_input('Outstanding Balance: > ')) apr = float(raw_input('Annual Interest Rate (as decimal) : > ')) mir = apr / 12 negative = 0 low = balance / 12 high = (balance * (1 + mir)**12.0) / 12.0 mmp = (high + low) / 2.0 newBalance = balance #verify low and high producing legal values #print low #print high while newBalance != 0.0: for i in range(1,13): newBalance = newBalance - mmp print 'newBalance =', newBalance if newBalance > 0.0: high = mmp elif newBalance == 0.0: negative = month break else: low = mmp mmp = (high + low) /2.0 newBalance = balance
the negative variable is just what i used to track the month where balance goes negative in the final print statements.
Oh, now I remember "this" problem. I did not resolve it, because all the tests i ran with my code were failed . But I saw the example solution. I know that the suggested upper bound is wrong. The real upper bound is: (balance*(1+(interest/12.0))*12.0)/12.0 Also, I saw that you are using the: "mir" variable on upper bound, but I think is wrong, perhaps, you should use the "apr" variable.
I hope that helps a bit :/
So do you not think it is a big deal to 100% understand this solution before moving along? I get the idea, but I'm just having a hard time associating it with the particular problem. Where are you at in the course sequence as of now?
I think that the specification of this problem is a bit messy. Anyway, if you can understand the example solution included in this problem set, go ahead. In the course sequence, I need to complete the last quiz.
Join our real-time social learning platform and learn together with your friends!