title: How to calculate the APR on an ARM in javascript
body: <p>I am trying to calculate the APR for an ARM  (in javascript) and have gotten stuck and am hopping somebody out there might be able to steer me in the right direction. Here is what I have tried so far:</p>
  
  <p>I get the average interest rate paid over the life of the loan.  For example: if the loan has a 4% rate for the first 24 payments and then the rate is raised to 6% for the last 336 payments. </p>
  
  <pre><code>AverageOverallRate = ( (4/12 * 24 ) +  ( 6/12 * 336 ) / 360 ) * 12 
  </code></pre>
  
  <p>This will give me an Average Interest Rate of of 5.866%</p>
  
  <p>I then try and take this “Average Interest Rate” and find the effective APR (taking into account compounding) using this formula. </p>
  
  <pre><code>Math.pow( 1 + ( averageOverallRate / 12 ), 12) – 1
  </code></pre>
  
  <p>Or I try to figure the effective APR (taking into account origination fees) by first solving for the payment that would result from borrowing the Principal + Origination Fees at the AverageOverallRate. Then once I know what that payment would have been I use a guess check method to evaluate what the rate would be for that same payment amount but for the original principal amount (without fees). (I am using the method explained here <a href="http://www.efunda.com/formulae/finance/apr_calculator.cfm" rel="nofollow">http://www.efunda.com/formulae/finance/apr_calculator.cfm</a> )</p>
  
  <p>I have both the above formulas working for fixed rate loans so I believe I am implementing them correctly(that is my calculations correspond to the many online calculators).  However, whey I try to calculate with the average interest rate for an ARM my calculations do not equal what the other online ARM APR calculators show (like this one: <a href="http://www.bankrate.com/calculators/mortgages/annual-percentage-rate-apr-calculator.aspx" rel="nofollow">http://www.bankrate.com/calculators/mortgages/annual-percentage-rate-apr-calculator.aspx</a> ).  </p>
  
  <p>How are you supposed to calculate the ARP for an APR?  Are you able to do it with simply average out the interest rate over the life of the loan or is this the wrong approach. </p>