# General and specific ODE

Tried solving this but not sure it's correct. Does anyone have a chance to check it? Any ideas on optimizing my 'process' would also be appreciated.

For

$\frac{dK}{dt}=\lambda(P-K)$ where $K(0) = 0.2P$

General solution

$dK = \lambda(P-K) \space dt \\ \frac{1}{(P-K)} \space dK = \lambda \space dt \\ \int \frac{1}{(P-K)} \space dK = \int \lambda \space dt\\ -ln(P-K) = \lambda t + C\\ -e^{ln(P-K)} = e^{\lambda t + C}\\ -P - K = e^{\lambda t + C}\\ -K = P + e^{\lambda t + C}\\ -(-K) = -(P + e^{\lambda t + C})$

$K(t) = -P - e^{\lambda t + C} = -P - e^{\lambda t} e^C$

Particular solution

$0.2P = -P - e^{\lambda (0) + C}=-P - e^{\lambda (0)} e^C = -P - e^C\\ -e^C = P + 0.2P\\ ln(e^C) = -ln(1.2P)\\ C = -ln(1.2P)$

$K(t) = -P - e^{\lambda t} (-1.2P)$

# Potential fix

General solution

$-ln|(P-K)| = \lambda t + C\\ e^{ln|(P-K)^{-1}|} = e^{\lambda t + C}\\ |\frac{1}{(P-K)}| = e^{\lambda t + C}\\ \frac{1}{(P-K)} = Ce^{\lambda t}\\ 1 = PCe^{\lambda t}-KCe^{\lambda t}\\ PCe^{\lambda t} - 1 = KCe^{\lambda t}\\$

$K(t) = \frac{PCe^{\lambda t}-1}{Ce^{\lambda t}}\\$

Particular solution

$0.2P = \frac{PCe^{\lambda (0)}-1}{Ce^{\lambda (0)}}\\ 0.2P = \frac{PC-1}{C}\\ 0.2PC = PC - 1\\ -0.8PC = - 1\\ C=\frac{1}{0.8P}$

$K(t) = \frac{P(\frac{1}{0.8P})e^{\lambda t}-1}{(\frac{1}{0.8P})e^{\lambda t}}$

Checking

$K(0) = \frac{P(\frac{1}{0.8P})e^{\lambda (0)}-1}{(\frac{1}{0.8P})e^{\lambda (0)}} = \frac{\frac{P}{0.8P}-1}{\frac{1}{0.8P}}=(\frac{1}{0.8}-1)0.8P=0.25\cdot0.8P=0.2P$

-
$-\log a=\log a^{-1}$ –  Artem Nov 14 '12 at 1:33
You can check your solution by computing $dK/dt$ –  tentaclenorm Nov 14 '12 at 1:47
Thanks for the pointers. I have added a potential 'fix', but still a bit unsure of myself. :) –  eee3 Nov 14 '12 at 13:23

When you went from $$-\log(P-K)=\lambda t+C$$ to $$-e^{\log(P-K)}=e^{\lambda t+C}$$ you fell into a trap --- the left side should be $e^{-\log(P-K)}$, which is a very different thing. You made another blunder on the next step, but you were already lost by then.