Now we are ready to solve this problem. Here are the general steps we'll follow:
Let $q$ be the amount of drug in the blood stream. This is always changing, so we are interested in $\frac{dq}{dt}$ . The derivative, $\frac{dq}{dt}$, is affected by two things:
That's it! We've represented (modeled) the scenario with mathematics.
The "solution" to a differential equation is a function. In this case, we'd like to know what $q(t)$ is. Sometimes we'll be able to find an algebraic representation for $q(t)$. Sometimes we'll be able to find a numerical solution . Sometimes general behavior will be the form of our solution, eg. "What happens to $q(t)$ as $t \rightarrow \infty$?"
In this scenario we're going to find an algebraic solution, i.e. a formula. Let's think about what we'll need to do:
If we suppose for a minute that $f(t)=0$, then the differential equation simplifies to $\frac{dq}{dt}=-kq.$
You may have seen this kind of differential equation in Calc II. It's separable because we can "separate" the $q$ part from the $t$ part and then (more or less) integrate:
If $t=0$ we have $q(t)=C\cdot e^{0}=C$. So $C$ is the intial quantity, let's call this value $q_0$. We have $q(t)=q_0e^{-kt}.$
clear all
syms t k q(t) q_0
de=diff(q,t)==-k*q
soln(t)=dsolve(de, q(0)==q_0)
Now, remember:
The drug is absorbed into the tissues where it does its work at the rate of 50% of the amount present in the bloodstream per hour.
So, $q(1)=\frac{1}{2}\cdot q_0$ and we can find $k$: \begin{align*} q(1)&=\frac{1}{2}\cdot q_0\\ q_0\cdot e^{-k\cdot 1}&=\frac{1}{2}\cdot q_0\\ e^{-k}&=\frac{1}{2}\\ k&=-\ln\left(\frac{1}{2}\right)\\ \end{align*}
(Matlab uses "log" for "ln", "log10" for "log", and "log2" for "log base 2")
eqtn=soln(1)==(1/2)*q_0
solve(eqtn,k)
Let's solve $$x \frac{dy}{dx} +y^2+y=0$$ with the initial condition $$y(1)=-2.$$
solution on the board
clear all
syms x y(x)
de=x*diff(y(x),x)+y^2+y==0
dsolve(de)
soln(x)=dsolve(de, y(1)==-2)
fplot(soln)
box off
ax = gca;
ax.XAxisLocation = 'origin';
ax.YAxisLocation = 'origin';
ylim([-30,30])
(Trench, 2.2 #4, #20)
clear all
syms x y(x)
de=diff(y(x),x)*log(y)+x^2*y(x)==0
dsolve(de)
clear all
syms x y(x)
de=diff(y(x),x)==2*y(x)-y(x)^2
dsolve(de, y(0)==1)
%pretty(dsolve(de))
When we see new techniques for solving differential equations, I'll include references to open source textbooks where you can read more about the techniques. I will also assign homework problems from these textbooks. You can find links to the textbooks on Canvas.
The references will look like this:
Trench, section 2.2, page 52: 1, 4, 6 (for these three you don't need to solve for $y$, leave it as an implicit solution), 11, 15 (just solve part)
Nagy, section 1.3, page 32: 1.3.1, 1.3.2, 1.3.3, 1.3.4
Trench, section 2.2, page 52: 6, (try 6 and then see cells below) 12 (try the command simplify on #12)
Concerning Trench #6:
You always have to read Matlab results critically. If you solve #6 as below: (execute it)
clear all
syms x y(x)
de=x^2*y(x)*diff(y(x),x)==(y(x)^2-1)^(3/2)
dsolve(de)
...then something seems wrong with the solutions Matlab provides. Why?
For this example you can give Matlab a little help to find the missing solutions. Do the following:
I've given you a partially completed input box for the process described above. Fill in the missing parts.
clear all
syms x y C %% Notice the variable is y and not y(x)
g(y)= %Fill in this spot
f(x)= %Fill in this spot
lhs(y)= %Fill in this spot....NOTICE it's lhs(y), not just lhs, this is important!
rhs(x)= %Fill in this spot
rhs(x)=rhs(x)+C
solve(%Fill in the equation here% ,y)