title: Computing the lowest monthly payment using bisection search in python
body: <p>I'm trying to compute the minimum monthly payment to pay off a loan using the following:</p>
  
  <pre><code>balance = 999999
  annualInterestRate = .18
  monthlyInterestRate = annualInterestRate/12
  
  balanceCOPY = balance
  
  #Bisection search parameters
  
  lo = balance/12
  hi = (balance*(1+monthlyInterestRate**12))/12
  epsilon = .01
  
  guess = (lo + hi)/2
  
  while True:
     for month in range(1,13):
        balance = balance - guess
        balance = balance + (monthlyInterestRate*balance)
  
     if balance &gt; 0 and balance &gt; epsilon:
        lo = guess
        balance = balanceCOPY
     elif balance &lt; 0 and balance &lt; -epsilon:
        hi = guess
        balance = balanceCOPY
     else:
        print('Lowest payment: ',str(round(guess,2)))
        break
  
     guess = (lo + hi)/2
  </code></pre>
  
  <p>However, I seem to be stuck in some sort of infinite loop where my <code>guess</code> variable is not being updated. How can I break out of the infinite loop and have my <code>guess</code> variable updated?</p>
  
  <p>The problem was in my math. I meant to say</p>
  
  <pre><code>hi = (balance*(1+monthlyInterestRate)**12)/12
  </code></pre>
  
  <p>Thank you for all the help everyone!</p>