Is this formula correct (monthly payments for a loan over time charging compounded interest while decreasing principal)?

I'm trying to derive a formula that I can use to optimize payments for my student loans. I'm not sure if Economics.SE is the best place for this because it is pretty math based, but the problem I have mostly involves concept and I'm not sure if Math.SE would be appropriate for this question.

Here are the five formulas I've used to derive my equation:

$$(1) \hspace{1cm} A=P(1+\frac{r}n)^{nt}$$

$$(2) \hspace{1cm} A_{0}=P_{0}(1+\frac{r}n)^{nt_{0}}$$

$$(3) \hspace{1cm} A=12mt$$

$$(4) \hspace{1cm} A_{0}=12m_{0}t_{0}$$

$$(5) \hspace{1cm} m=m_{0}+\frac{P_{0}-P}{12t}$$

For these formulas, $$A$$=principal plus interest, $$P$$=principal, $$t$$=time in years to pay the loan completely, $$r$$=fixed interest rate, $$n$$=number of times per year interest is compounded, and $$m$$=monthly payment. $$A$$, $$P$$, $$m$$ and $$t$$ are the final values after lowering the principal by the same amount $$(m-m_{0})$$ every month while simultaneously making monthly payments $$(m_{0})$$ Every "sub-zero" value represents the initial amount before curtailing the principal.

Using substitution, I was able to derive this formula:

$$(6) \hspace{1cm} m=\frac{P_{0}}{12}\bigg{(}\frac{(1+\frac{r}{n})^{nt_{0}}}{t_{0}}+\frac{1}{t}\bigg{)}\frac{(1+\frac{r}{n})^{nt}} {(1+\frac{r}{n})^{nt}+1}$$

I feel confident that there are no arithmetic mistakes deriving the formula, but I'm not sure that the logic for the concept of each formula makes sense. The idea is that if I plug in $$P_{0}, t_{0}, r$$ and $$n$$, I should be able to find $$m$$ by plugging in $$t$$ or vice versa. Since lowering the principal creates another P value, you need two formulas, (1) and (2). In order to determine the amount of money paid per month, I need formulas (3) and (4). With these first four formulas, you can only relate formulas (1) with (3) and (2) with (4); formula (5) is therefore needed to relate them with each other. It makes sense to me since $$m$$ should be the sum of the amount I need to lower the Principal from $$P_{0}$$ to a smaller value $$P$$ and find how much money I need to pay $$m$$ per month (which includes the amount of money you would need per month to fully pay the loan off in $$t_{0}$$ years, which is $$m_{0}$$, as well as an additional amount to curtail the principal amount to pay it off in a shorter amount of time, $$t$$ years).

I'm also trying to visualize this with a GeoGebra file, where I use sliders to indicate $$P_{0}$$, $$t_{0}$$, $$r$$ and $$n$$. The horizontal axis is $$t$$ and the vertical axis is $$m(t)$$ (don't know how to attach).

I have experience with math, but not economics so I'm not sure if there is a method that I'm not aware of to determine this or if I'm overthinking the problem. I mainly want confirmation that the original formulas are correct and that formula (6) will give me the value that I want. What I don't trust is the fact that interest would be added every day, but the payments should be made every month and I don't feel convinced that the formula takes that into account. If something isn't right, how do I correct it? I've tried my best to explain, but if it's still unclear please ask. I want to make absolutely certain it will work before I try it and I'm having trouble checking through brute force.

Edit:

For example, say you take out a 3000 dollar loan with a fixed interest rate of 5% that is compounded daily and originally planned to pay it off in 10 years. So, $$P_{0}=3000$$, $$r=0.05$$, $$n=365$$ and $$t_{0}=10$$. By formula (1), this implies if you follow through with paying off the loan in 10 years, you will pay $$A_{0}=4946$$ dollars. Therefore, formula (3) implies I would need to pay $$m_{0}=41.22$$ dollars per month.

But let's say that after budgeting, I could afford to spend 60 dollars every month $$(m=60)$$. Then, I'd make the monthly payment of 41.22 dollars and pay the difference to decrease the principal. I want to know how long it would take to pay off the loan in that time. Looking at formula (6), it's clearly not easy to determine, which is why I made a graph ($$t=5.3$$ if the formula is right).

I guess "optimize" might not be the best word to describe this because I'm not doing it in the mathematical sense of finding relative extrema. I meant it in the colloquial sense to realistically ease financial burden. So after I budget my expenses, if I can afford to spend extra money, I can anticipate how long I can pay off the loan.

The question is just whether or not formula (6) is right based on my logic. My concern is that one of the first 5 formulas doesn't accurately represent the concept and formula (6) would then be derived incorrectly from trickle-down error.

• Economics is heavily mathematical so that is definitely not a problem here, but I am not really sure what you are trying to accomplish. You say you want to optimize your student loan payments but what exactly you mean by that? What you ultimately pay A is monotonously increasing function of P and t (which are your choice variables) so I am afraid that without imposing some constraint on the optimization problem the optimum would be corner solution where P=0 and t=0. The same would hold even if you just care about installments. What exactly is here you objective?
– 1muflon1
Apr 12 at 22:41