1

I need to calculate APR for loans. Constant repayment loans were covered clearly here Calculating annual percentage rate (need some help with inherited code)

My problem is where the repayment amount is not constant. The monthly repayments can differ and therefore Newton-Raphson does not seem applicable.

The formula is still 0 = loan amount - sum[Rp/(1+x)^p] where Rp is the repayment amount for repayment p. There are n repayments. Is there a way to solve this or is there a good way to make a good second guess to x based on the results of previous guesses?

Community
  • 1
  • 1
george
  • 11
  • 1

1 Answers1

1

It sounds like you're given the Rp values and want to calculate x. You can just use Newton-Raphson as before - the question you linked to showed you how to do that.

For this one, you just need to change your F(x) and F'(x) functions.

F(x) = loan amount - sum[Rp/(1+x)^p] You'll have to write code with a little loop in it to do the sum.

F'(x) = + sum[-p*Rp/(1+x)^(p+1)] A little loop there and you're set.

Michael
  • 1,022
  • 6
  • 7