# Stuck with this differential equation question, not getting the correct answer.

Suppose that, in order to buy a house, you obtain a mortgage. If the lender advertises an annual interest rate $r$, your debt $D$ will increase exponentially according to the simple O.D.E. $$\frac{dD}{dt}=rD.$$

If you pay your debt at a rate of $P$ (continuous annual rate), the evolution of your debt will then (under assumptions of continual compounding and payment) obey the linear differential equation

$$\frac{dD}{dt}=rD−P.$$

Using this model, answer the following question:

If initial amount of the mortgage is for $400,000$, the annual interest rate is $5\%$ , and you pay at a rate of $40,000$ every year, how many years will it take you to pay off the debt?

• Welcome to MSE! Can you show your work so we can see where your approach is failing?
– Moo
Dec 11 '17 at 19:05
• Okay, so I started solving this question as follows dD/dt - rD = -P then I solved for the integrating factor which came out to be exp(-rt) then putting it back and using it d(Dexp(-rt)) = -P Integral(exp(-rt))dt after integrating I got Dexp(-rt) = (P/r)*exp(-rt) + C now I'm getting stuck while caclulating the constant. at t=0 we get C= D-P/r So what do I do now? Assume D as the original 400000 or use it as it is, if I'm using as it is I'm getting nowhere Dec 11 '17 at 19:13
• At $t=0$, you're 400,000 in debt, so use $D=400 000$ as your initial condition. Dec 11 '17 at 19:44

The equation is separable.

$$dt=\frac{dD}{rD-P}.$$

Then by integration,

$$t=\frac1r\log\left|\frac{rD_t-P}{rD_0-P}\right|$$ and it suffices to set $D_t=0$.

• This is correct. Thank you soo much. Really Ive been stuck on this for hours now. Dec 11 '17 at 19:53

The first differential equation: $$\frac{\mathrm{d}D}{\mathrm{d}t}=rD$$ $$\frac{\mathrm{d}D}{\mathrm{d}t}-rD=0$$ Let's define $\mu(t):=\exp\left(\int -r \mathrm{d}t\right)=\exp(-rt)$, and multiply both sides with it: $$\exp(-rt)\frac{\mathrm{d}D}{\mathrm{d}t}-\exp(-rt)rD=0$$ By the product rule: $(f\cdot g)'=f' \cdot g+f\cdot g'$, we can see that the LHS can be written as: $$\frac{\mathrm{d}}{\mathrm{d}t}\bigg(D \exp(-rt) \bigg)=0$$ Now we can integrate both sides with respect to $t$ to get: $$D \exp(-rt)=C$$ $$D(t)=C\exp(rt)$$ The second one: $$\frac{\mathrm{d}D}{\mathrm{d}t}=rD-P$$ $$\frac{\mathrm{d}D}{\mathrm{d}t}-rD=-P$$ Define the $\mu(t)$ the same way as before, and multiple both sides with it. Now the LHS will be again the derivate ot $D \mu(t)$: $$\frac{\mathrm{d}}{\mathrm{d}t}\bigg(D \exp(-rt) \bigg)=-P\exp(-rt)$$ Integrate both sides with respect to $t$: $$D \exp(-rt)=\frac{-P}{-r}\exp(-rt)+C$$ $$D(t)=\frac{P}{r}+C\exp(rt)$$ We know that $P=40000$, $r=\frac{5}{100}$, and the $D$ at $t=0$ is $400000$. So we can calculate the $C$: $$400000=\frac{40000}{0.05}+C\exp(0 \cdot 0.05)$$ $$400000=800000+C$$ $$C=-400000$$ So the particular solution for your case: $$D(t)=-400000e^{0.05t}+800000$$ We want to calculate the time required for $D$ to be $0$: $$0=-400000e^{0.05t}+800000$$ $$400000e^{0.05t}=800000$$ $$e^{0.05t}=2$$ $$0.05t=\log(2)$$ $$t=20 \log(2)$$ So it will take 14 years.

• This is absolutly correct and I got to this step. But the problem starts here as I cannot calculate the time in which he can repay the loan, can you help me with that? Dec 11 '17 at 19:17
• @SulaimanQizilbash Could you make the text "understandable" for me? I cannot really understand it. Dec 11 '17 at 19:18
• @SulaimanQizilbash I mean what's $P$ and $r$, and what's $D$ at a given time, and what would you like to calculate ($D$ at a given $t$ time, or $t$ from a given $D$ value). Dec 11 '17 at 19:22
• Oh that, I want to calculate the time when the mortgage gets paid off, So I think its getting a t from a given D value? Dec 11 '17 at 19:26
• Like this is where I'm getting confused. To calculate the time I will need to calculate the C in any case. But how to calculate the C? what do I assume D as? Do I even assume it? while P and r are constants but I'm not really understanding the question myself here. Like how is the D working in this question Dec 11 '17 at 19:30