The given problem: use bisectional search to find the minimum monthly payment to pay off debt after 12 payments (slight.
Assume that the interest is compounded monthly according to the balance at the end of the month (after the payment for that month is made).
Assume that the interest is compounded monthly according to the balance at the end of the month (after the payment for that month is made).
annualInterestRate=.1 # i used these numbers soley as placeholders to test the program balance=100 # i used these numbers soley as placeholders to test the program monthlyInterestrate=annualInterestRate/12 balance_initial=balance lowerbound=(1/12)*balance # the upperbound and lowerbound were defined in the given problem for us. upperbound=balance*(1+monthlyInterestrate)**(12)/12 monthlyPayment=(upperbound+lowerbound)/2 while balance!=0: for i in range(12): balance=balance-monthlyPayment + (balance-monthlyPayment)*monthlyInterestrate if balance>0: monthlyPayment=(upperbound+monthlyPayment)/2 if balance<0: monthlyPayment=(lowerbound+monthlyPayment)/2 balance=balance_initial print('Lowest Payment: ' + str(round(monthlyPayment, 2)))Is there something wrong with my bisectional search? I've been looking at it for some time and I don't see how this could give me an infinite look; if the monthlyPyament is too large it is lowered, and if it is too small it is raised until the minimum balance is found.