Optimal allocation between loans I have a two part problem. The first asks whether I can optimally determine how I should split my weekly paycheck towards two loan payments to ensure the shortest total time to payoff my loans. The second, if possible, asks how to allocate funds if I also split funds into an investment account that grows at some rate. I have changed numbers from my real world use case.
Question 1
Given two loans, the first at \$2,000 compounded daily with an annual rate of 6% and the second at \$4,000 compounded daily with an annual rate of 7%, and I save \$10 a day. How can I optimally split my \$10 between the loans each day, to ensure I payoff the loans in the shortest time possible?
I have come up with three equations that I need to solve for.
$$f_\alpha(t) : \mathbb{N} \rightarrow \mathbb{R} $$
The domain is whole numbers representing each day and the co-domain is a range [0,1] that represents the percent of funds that are added to each loan daily. So if $f_\alpha(1) = 0.2$ then on the first day $t_1$, I would add \$2 to loan1 and \$8 to loan2. Then there are the recursive equations representing the daily loan amounts over time.
$$loan_1(t) = loan_1(t-1)*(1 + \frac {0.06}{365}) + 10*f_\alpha(t) \mid \ loan_1(0) = -2000 $$
$$loan_2(t) = loan_2(t-1)*(1 + \frac {0.07}{365}) + 10*(1-f_\alpha(t)) \mid \ loan_2(0) = -4000 $$
The loan amount on each day is the previous day's loan total multiplied by the fixed rate compounded daily plus the dollar amount added to each loan.
Is there a way for me to solve $f_\alpha(t)$ to minimize the time it takes to get $loan_1(t) + loan_2(t) = 0$? Because $f_\alpha(t)$ has a discrete input, that makes this problem non-differentiable. So I don't think I've defined the problem properly to do this with calculus but I'd be happy to change the problem statement so that $f_\alpha(t) : \mathbb{R} \rightarrow \mathbb{R}$ with your suggestion and a modification to $loan_1(t)$ and $loan_2(t)$ that isn't recursive.
Question 2
Bonus points for adding in a fourth function that represents gains in the stock market with an annual percent yield of 7%. The updated functions would look like this:
$$f_\alpha(t) : \mathbb{Z} \rightarrow \mathbb{R^3} $$
mapped from the the integer domain representing days, to a vector $v_\alpha = [v_1,v_2,v_3]$ where $v_1+v_2+v_3=1.0$ and each value is constricted to the range [0,1]. Each value in the vector represents the percent of funds that are added to each loan/investment daily. So $f_\alpha(1) = [0.1,0.3,0.6]$ would have me insert \$1 into loan1, \$3 into loan2, and \$6 into my investment account, namely the function invest3.
$$loan_1(t) = loan_1(t-1)*(1 + \frac {0.06}{365}) + 10*f_\alpha(t)[1] \mid \ loan_1(0) = -2000 $$
$$loan_2(t) = loan_2(t-1)*(1 + \frac {0.07}{365}) + 10*f_\alpha(t)[2] \mid \ loan_2(0) = -4000 $$
$$invest_3(t) = invest_3(t-1)*(1 + \frac {0.07}{365}) + 10*f_\alpha(t)[3] \mid \ invest_3(0) = 1000 $$
I'm also curious to find out if, for varying market gains, if these functions even converge. Is the problem even constrained enough? For example do I need to set a 5 year limit, and simply try to maximize wealth by paying off loans and investing over a 5 year period? I do not know, but I believe answering Question 1 will help in my quest.
Conclusion
I am a first time user so please point out any mistakes in my line of reasoning. Solving this answer will help me in the real world because the true loan amounts are much much larger. I'm an American student who paid on the order of $100,000 for tuition, so solving atleast Question 1 will help me tremendously!
 A: The simple answer is to look at what allocation helps your net worth tomorrow the most.  When looking at loans, pay the high interest one first.  Probably each loan has a minimum payment that if you don't pay it generates a fee that is effectively a higher interest rate.  In that case, make the minimum payment on the $6\%$ loan and put all the rest toward the $7\%$ loan until it is paid off.  You may hear of a "snowball" strategy, which says to pay the maximum on the smallest loan.  The justification is psychological, in that getting a loan paid off is rewarding and will help you stay on course.  The difference in interest is often small and if the encouragement is valuable to you it can be worthwhile.  That is a nonmathematical question.  If you are interested, I suggest making a spreadsheet that shows the balance each month based on how you make your payments.  With these numbers, I think you will find the difference is tiny, so encouragement may be worth the small cost, but that is up to you.
When you look at investments, until taxes intervene you are better off borrowing if the investment returns more than the interest cost of the loan.  If you borrow a dollar at $7\%$ to invest in something that returns $7\%$ after a year you have an investment worth $1.07$ and owe $1.07$ for a wash.  If you can deduct the interest but not pay taxes on the profit (unlikely), you are ahead.  If you pay taxes on the profit but cannot deduct the interest (more likely), you are behind.
