I need a formula for determining a debt repayment plan, in which I know: the number of payments, the amount for the payment and the principal amount, and I need to find out which one will represent the interest rate. I redistribute the existing code, and the current method uses the following (compound = 12; interest rate starts with .1):
while (counter < 100) { intermediatePayment = (interestRate*(principal/compounded))/(1 - (1/Math.Pow(interestRate/compounded + 1,(compounded*numberOfYears)))); interestIncrement = Math.Abs(interestRate - previousRate)/2; previousRate = interestRate; if(intermediatePayment == payment) break; if (intermediatePayment > payment) interestRate -= interestIncrement; else interestRate += interestIncrement; counter++; }
Now I understand what this formula does, but I can never come to it myself. What is actually the equation that is supposed to be used to determine the monthly payment if interest rates, principal amounts and the number of payments are known. It uses brute force and a cycle (not more than 100 times) until the settlement payment becomes equal to the desired payment. It usually comes to an answer after 40-50 cycles and can be optimized by reducing significant numbers.
It seems to me that if we just decided for interestRate, there would be no cycles. Try as I could, I canβt get the equation to solve for me, so my main question.
Now, if you understand the problem well and know the financial formulas and exacerbate interest, you can provide me with an even better solution that would be awesome. I myself did a lot of research and found tools, but not a crude equation, or more often than not I find different formulas to identify questions of interest, but I'm not aware of how to reconfigure them for my needs.
Basically, I spent too much time on this, and my boss thinks, because the cycle is working, I need to leave it or ask for help. Fair enough, so do I. :)
Here's a more traditional formula layout if it helps anyone: http://i.imgur.com/BCdsV.png
And for test data: if
- P = 45500
- c = 12
- y = 3
- t = 1400
then
thanks for the help