So I have found the formula:
monthly_payment = (monthly_interest * principal) / (1- ((1+ monthly_interest)**(-1*months)))
** being to the power of.
Can someone tell me where I should go to find out about this equation? Is it a polynomial? Should I start there or do I need to understand more basic maths? If anyone can recommend a good resource that would be great.
Also, I can't seem to re arrange it to solve months.
I am going to presume that the discussion about percents is over.
The relevant interest rate is the rate
per compounding period. In your case, the payment period is months and so is 1/12 of the annual rate, but the formula works for any length of compounding period.
\(\displaystyle i = \text { interest rate for compounding period (not year).}\)
Now before proceeding to the meat of the derivation, let's deal with difference of powers.
\(\displaystyle \displaystyle x \ge 0 \le y \text { and integer } n > 1 \implies x^n - y^n = (x - y) * \left ( \sum_{j=1}^n x^{(n-j)} * y^{(j-1)} \right ).\)
The proof of that theorem is most easily done by weak induction, but it is probably easy to find proofs about difference of powers via google.
\(\displaystyle \displaystyle \therefore x \ne y \implies \left ( \sum_{j=1}^n x^{(n-j)} * y^{(j-1)} \right ) = \dfrac{x^n - y^n}{x - y}.\)
\(\displaystyle \displaystyle \therefore x \ne 1 = y \implies \dfrac{x^n - 1^n}{x - 1} = \left ( \sum_{j=1}^n x^{(n-j)} * 1^{(j-1)} \right ) \implies \)
\(\displaystyle \displaystyle \left ( \sum_{j=1}^n x^{(n-j)} \right ) = \dfrac{x^n - 1}{x - 1}.\)
That lets us substitute a particular form of fraction for a particular form of sum.
\(\displaystyle i > 0 \implies 1 + i > 1 \implies 1 + i \ne 1 \implies \)
\(\displaystyle \displaystyle \left ( \sum_{j=1}^n (1 + i)^{(n-j)} \right ) = \dfrac{(1 + i)^n - 1}{(1 + i) - 1} = \dfrac{(1 + i)^n - 1}{i}.\)
\(\displaystyle \therefore \dfrac{1}{\displaystyle \left ( \sum_{j=1}^n (1 + i)^{(n-j)} \right )} = i * \dfrac{1}{(1 + i)^n - 1} \implies\)
\(\displaystyle \dfrac{(1 + i)^n}{\displaystyle \left ( \sum_{j=1}^n (1 + i)^{(n-j)} \right )} = i * \dfrac{(1 + i)^n}{(1 + i)^n - 1} =\)
\(\displaystyle i * \dfrac{(1 + i)^n}{(1 + i)^n - 1} * \dfrac{(1 + i)^{-n}}{(1 + i)^{-n}} = i * \dfrac{1}{1 - (1 + i)^{-n}}.\)
\(\displaystyle \text {In short, } \dfrac{(1 + i)^n}{\displaystyle \left ( \sum_{j=1}^n (1 + i)^{(n-j)} \right )} = \dfrac{i}{1 - (1 + i)^{-n}}.\)
What, you may wonder, is the point of all this algebra? Let's get back to the basic problem.
We have already defined i.
\(\displaystyle n = \text { number of payments.}\)
\(\displaystyle a = \text { amount of each payment.}\)
\(\displaystyle p_0 = \text { original principal.}\)
\(\displaystyle p_j = \text { principal due remaining after }j \text { payments, where } 1 \le j \le n.\)
The logic works on the basis of two obvious propositions:
\(\displaystyle p_n = 0 \text { and }p_j = p_{j-1} + ip_{j-1} - a = (1 + i)p_{j-1} - a.\)
Now let's do a bit of experimentation.
\(\displaystyle n = 1 \implies 0 = p_1 = (1 + i)p_0 - a \implies a = (1 + i) * p_0.\)
That is simple common sense. But notice that we can re-state it as follows:
\(\displaystyle n = 1 \implies a = (1 + i) * p_0 = p_0 * \dfrac{i(1 + i)^1}{i} * \dfrac{(1 + i)^{-1}}{(1 + i)^{-1}} \implies\)
\(\displaystyle a = p_0 * \dfrac{i}{i * (1 + i)^{-n}} = p_0 * \dfrac{i}{\dfrac{i}{1 + i}} = p_0 * \dfrac{i}{\dfrac{1 + i - 1}{1 + i}} \implies\)
\(\displaystyle a = p_0 * \dfrac{i}{1 - \dfrac{1}{1 + i}} = p_0 * \dfrac{i}{1 - (1 + i)^{-1}}.\)
Your formula works if n = 1. Let's try n = 2.
\(\displaystyle n = 2 \implies 0 = p_2 = (1 + i)p_1 - a \implies a = p_1 * (1 + i).\)
\(\displaystyle \text {But } p_1 = (1 + i)p_0 - a \implies a =(1 + i)\{(1 + i)p_0 - a) \implies\)
\(\displaystyle a(1 + i) + a = p_0(1 + i)^2 \implies \displaystyle a * \left ( \sum_{j=1}^2 (1 + i)^{(n-j)} \right ) = p_0(1 + i)^2 \implies\)
\(\displaystyle a = p_0 * \dfrac{(1 + i)^2}{ \displaystyle \left ( \sum_{j=1}^2 (1 + i)^{(n-j)} \right )} = p_0 * \dfrac{i}{1 - (1 + i)^{-2}}.\)
Again your formula works. Let's try n = 3.
\(\displaystyle n = 3 \implies 0 = p_3 = (1 + i)p_2 - a \implies a = p_2 * (1 + i).\)
\(\displaystyle \text {But } p_2 = (1 + i)p_1 - a \implies a =(1 + i)\{(1 + i)p_1 - a) \implies\)
\(\displaystyle a(1 + i) + a = (1 + i)^2p_1.\)
\(\displaystyle \text {But } p_1 = (1 + i)p_0 - a \implies a(1 + i) + a = (1 + i)^2 \{(1 + i)p_0 - a\} \implies\)
\(\displaystyle a(1 + i)^2 + a(1 + i) + a = p_0(1 + i)^3 \implies\)
\(\displaystyle \displaystyle a * \left ( \sum_{j=1}^3 (1 + i)^{(n-j)} \right ) = p_0(1 + i)^3 \implies\)
\(\displaystyle a = p_0 * \dfrac{(1 + i)^3}{ \displaystyle \left ( \sum_{j=1}^3 (1 + i)^{(n-j)} \right )} = p_0 * \dfrac{i}{1 - (1 + i)^{-3}}.\)
In general, \(\displaystyle a = p_0 * \dfrac{i}{1 - (1 + i)^{-n}}.\)
To solve for n, you must know p
0, i, and a and a > ip
0.
\(\displaystyle a = p_0 * \dfrac{i}{1 - (1 + i)^{-n}} \implies 1 - (1 + i)^{-n} = \dfrac{ip_0}{a}\implies\)
\(\displaystyle (1 + i)^{-n} = 1 - \dfrac{ip_0}{a} = \dfrac{a - ip_0}{a} \implies -\ n * log(1 + i) = log(a - ip_0) - log(a) \implies \)
\(\displaystyle n * log(1 + i) = log(a) - log(a - ip_0) \implies n = \dfrac{log(a) - log(a - ip_0)}{log(1 + i)}.\)