Let's review our progress so far.

We want to solve $$\frac{dq}{dt}=f(t)-kq.$$

We found the value of $k$ and algebraic representations for $f(t)$.

We're ready for the main tool in the scenario:

Laplace transform

The Laplace transform transforms calculus problems (differential equations) into algebra problems. The algebra problem is easy, if sometimes messy. If we can undo the transform, take the inverse Laplace transform, we'll have the solution to the differential equation. It's the last step that is the hardest (sometimes impossible).

We'll use the following notation:

$\mathscr{L}(f(t))=F(s)$

The independent variable in the differential equation is $t$, we say the differential equaiton is in the time domain. The Laplace transform has a different independent variable: $s$. The transformed equation is said to be in the frequency domain.

To help with the notation we'll use lower case letters ($q$, $f$) for functions in the time domain, and upper case letters ($Q$, $F$) for functions in the frequency domain.

$$\begin{array}{ccc} \frac{dy}{dt}=f(y,t)&\xrightarrow{\mathscr{L}}& \mathscr{L}\left(\frac{dy}{dt}=f(y,t)\right) \\ & & \biggr\downarrow \text{algebra} \\ \text{solution: }y(t)=\mathscr{L}^{-1}(Y(s)) & \xleftarrow{\mathscr{L}^{-1}} & Y(s) \\ \end{array}$$

Ok, so what is the Laplace transform?

$$\mathscr{L}(f(t))=\int_0^\infty f(t)e^{-st} \ dt.$$

This might seems like a bad deal: trading a simple looking differential equation for an awful looking, improper integral.

Don't worry!

Let's do an example with the drug administration given by $f(t)=h(t)-h(t-1/2)$. (Just one, 1/2-hour, administration.)

\begin{align*} \frac{dq}{dt}&=f(t)-kq=h(t)-h(t-1/2)-kq\\ \mathscr{L}\left(\frac{dq}{dt}\right)&=\mathscr{L}\left(h(t)-h\left(t-\frac{1}{2}\right)-kq\right)\\ \mathscr{L}\left(\frac{dq}{dt}\right)&=\mathscr{L}\left(h(t)\right)-\mathscr{L}\left(h(t-\frac{1}{2})\right)-k\mathscr{L}\left(q\right)\\ \end{align*}

First important property of the Laplace transform: it's linear. So, it's easy to deal with addition, subtraction, and multiplication by constants. BUT: NOT multiplication of functions. Just like derivatives and integrals.

$$\begin{array}{lllcl} \mathscr{L}\left(\dfrac{dq}{dt}\right)=\displaystyle \int_0^\infty \frac{dq}{dt}e^{-st}\ dt && u=e^{-st}& &v=q \\ && du=-se^{-st}\ dt & & dv=\frac{dq}{dt}\ dt \\ && & & \\ =qe^{-st}\Bigr\rvert_0^\infty-\displaystyle \int_0^\infty -qse^{-st}\ dt &&&&\\ =-q(0)+s \int_0^\infty qe^{-st}\ dt &&&&\\ =-q(0)+s Q(s) &&&&\\ \end{array}$$
\begin{align*} f(t)&=h(t)\\ \mathscr{L}(h(t))&=\int_0^\infty h(t)e^{-st}\ dt\\ &=\int_0^\infty 1\cdot e^{-st}\ dt\\ &=-\frac{1}{s}e^{-st} \Bigr\rvert_{\ 0}^{\ \infty} \\ &=\frac{1}{s} \end{align*}
In [3]:
syms t s
syms h(t)
h(t)=heaviside(t);
laplace(h,t,s)
 
ans =
 
1/s
 
\begin{align*} \mathscr{L}(h(t-\tau))&=\int_0^\infty h(t-\tau)e^{-st} \ dt\ \hspace{3cm} u=t-\tau,\ \ du=dt\\ &=\int_{-\tau}^\infty h(u)e^{-s(u+\tau)}\ du\\ &=\int_{-\tau}^\infty h(u)e^{-su} \cdot e^{-s\tau}\ du\\ &= e^{-s\tau}\int_{-\tau}^\infty h(u)e^{-su} \ du \hspace{3cm} h(u)=0 \mathrm{\ for\ } u<0\\ &= e^{-s\tau}\int_{0}^\infty h(u)e^{-su} \ du \\ &= e^{-s\tau}\mathscr{L}(h)=e^{-s\tau}\cdot \frac{1}{s}\\ \end{align*}
In [26]:
syms g(t)
g(t)=h(t-3)
laplace(g,t,s)
 
g(t) =
 
heaviside(t - 3)
 
 
ans =
 
exp(-3*s)/s
 
\begin{align*} %\frac{dq}{dt}&=f(t)-kq=h(t)-h(t-1/2)-kq\\ %\mathscr{L}\left(\frac{dq}{dt}\right)&=\mathscr{L}\left(h(t)-h\left(t-\frac{1}{2}\right)-kq\right)\\ \mathscr{L}\left(\frac{dq}{dt}\right)&=\mathscr{L}\left(h(t)\right)-\mathscr{L}\left(h(t)-\frac{1}{2}\right)-k\mathscr{L}\left(q\right)\\ -q(0)+s Q(s)&=\frac{1}{s}-e^{-s/2}\cdot \frac{1}{s}-kQ(s)\\ &\text{suppose } q(0)=2, \text{ remember we know the value of } k\\ &\text{solve for } Q(s):\\ s Q(s)+kQ(s)&=\frac{1}{s}-e^{-s/2}\cdot \frac{1}{s}+2\\ Q(s)&=\frac{1}{(s)(s+k)}-e^{-s/2}\cdot \frac{1}{(s)(s+k)}+\frac{2}{(s+k)}\\ \end{align*}
In [29]:
syms t q(t) f(t) s Q Qs k
%k=log(1/2)
f(t)=heaviside(t)-heaviside(t-(1/2))
de=diff(q,t)==f(t)-k*q
transform=laplace(de, t, s)
transform=subs(transform, laplace(q(t),t,s), Q)
Qs=solve(transform, Q)
Qs=subs(Qs, q(0), 2)
pretty(Qs)
 
f(t) =
 
heaviside(t) - heaviside(t - 1/2)
 
 
de(t) =
 
diff(q(t), t) == heaviside(t) - heaviside(t - 1/2) - k*q(t)
 
 
transform =
 
s*laplace(q(t), t, s) - q(0) == 1/s - exp(-s/2)/s - k*laplace(q(t), t, s)
 
 
transform =
 
Q*s - q(0) == 1/s - exp(-s/2)/s - Q*k
 
 
Qs =
 
(q(0) - exp(-s/2)/s + 1/s)/(k + s)
 
 
Qs =
 
(1/s - exp(-s/2)/s + 2)/(k + s)
 
       /   s \
    exp| - - |
1      \   2 /
- - ---------- + 2
s        s
------------------
       k + s

$$\begin{array}{ccc} \frac{dy}{dt}=f(y,t)&\xrightarrow{\mathscr{L}}& \mathscr{L}\left(\frac{dy}{dt}=f(y,t)\right) \\ & & \biggr\downarrow \text{algebra} \\ \text{solution: }y(t)=\mathscr{L}^{-1}(Y(s)) & \xleftarrow{\mathscr{L}^{-1}} & Y(s) \\ \end{array}$$
\begin{align*} \mathscr{L}(h(t))&=\frac{1}{s}\\ \mathscr{L}(h(t-\tau))&=e^{-s\tau}\frac{1}{s}\\ \end{align*}

and similarly:

\begin{align*} \mathscr{L}(e^{at})&=\frac{1}{s-a}\\ \mathscr{L}(h(t-\tau))&=\frac{e^{-s \tau}}{s}\\ \mathscr{L}(f(t-\tau)h(t-\tau))&=e^{-s \tau}\cdot \mathscr{L}(f(t))\\ \end{align*}

See Trench pages 463 and 464 for a table of Laplace transforms.

Examples of finding Laplace transforms from tables:

  1. $\displaystyle \mathscr{L}(e^{2t}-3e^t)=\frac{1}{s-2}-3\frac{1}{s-1}$

  2. $\displaystyle \mathscr{L}(\cos(3t))=\frac{s}{s^2+4}$

another example: Trench 8.1.5b)

Let: $$ f(t) = \begin{cases} t & 0 \leq t \leq 1 \\ 1 & t \geq 1 \\ \end{cases} $$

Write: \begin{align*} f(t)&=t(h(t)-h(t-1))+h(t-1)\\ &=th(t)-th(t-1)+h(t-1)\\ \end{align*}

So, find:

\begin{align*} \mathscr{L}(f(t))&=\mathscr{L}(th(t))-\mathscr{L}(th(t-1))+\mathscr{L}(h(t-1))\\ &=\mathscr{L}(th(t))-\mathscr{L}((t-1+1)h(t-1))+\mathscr{L}(h(t-1))\\ &=\mathscr{L}(th(t))-\mathscr{L}((t-1)h(t-1))-\mathscr{L}((1)h(t-1))+\mathscr{L}(h(t-1))\\ &=\frac{1}{s^2}-\frac{e^{-s}}{s^2} \end{align*}
In [10]:
syms t
f(t)=t*(heaviside(t)-heaviside(t-1))+h(t-1)
fplot(f(t), "LineWidth",3)
xlim([-1 5])
F=laplace(f(t), t, s)
 
f(t) =
 
heaviside(t - 1) - t*(heaviside(t - 1) - heaviside(t))
 
 
F =
 
1/s^2 - exp(-s)/s^2
 

Homework

By hand: Trench section 8.1: 1b)c)e), 5b)d) Trench section 8.3: 7, 17 BUT just find the Laplace transform and STOP Trench section 8.5: BUT just find the Laplace transform and STOP Trench section 8.7: 6 BUT just find the Laplace transform and STOP

With Matlab: 2c)g)h), 5a)

In [ ]: