Multiple Drug Doses - Day 3

This project is based on a project by Brian Winkle. https://www.simiode.org/resources/2981/supportingdocs

Some helpful functions

dirac delta function

To represent a bolus we want a function that "turns on" at just ONE value of $t$ and is "off" for all other values of $t$.

Here's one way to build such a function:

$$ f(t)= \begin{cases} \dfrac{1}{\epsilon} & 0 \leq t \leq \epsilon \\\\ 0 & t > \epsilon \\ \end{cases} $$

and let $\epsilon \rightarrow 0$!!

The function that results is called the Dirac delta function, $\delta(t)$.

In [1]:
dirac

You can think of it this way: 5𝛿(𝑡−3) is 5 when 𝑡=3 and zero everywhere else. (This isn't really correct, but it helps to think of it this way.)

image.png

$$y=\sum_{k=0}^5 \delta(t-k)$$

heaviside function

To represent continuous drip administration of the drug, but for no more than 1/2 hour each hour we want a function that turns on for awhile and then turns off for awhile, etc.

First, define: $$h(t)=\begin{cases} 0 & t<0 \\\\ 1 & t \geq 0 \\ \end{cases} $$

In [16]:
syms t
g(t)=heaviside(t);
fplot(g(t),[-3,3], "LineWidth",3)

on and off

If we want a function to turn on for awhile and then off we can combine heaviside functions. For example if we want the function to turn on at $t=2$, we use $h(t-2)$. Notice, $h(t-2)=1$ for $t$-values bigger than 2. So say we want the function to turn off at $t=5$, we just need to subtract 1 starting at $t=5$. So, we'll subtract $h(t-5)$. The function $g(t)=h(t-2)-h(t-5)$ will turn on at $t=2$ and off at $t=5$.

In [28]:
g(t)=heaviside(t-2)-heaviside(t-5);
fplot(g,[-5,8], "LineWidth",3)

and on and off and on and off and....

It's easy to combine several heaviside functions to get a function and repeatedly goes on and off. Start with a simple one on, one off, of length one and height one:

$s(t)=h(t)-h(t-1)$

In [4]:
syms t h(t)
step(t)=heaviside(t)-heaviside(t-1)
fplot(step(t), [-1,3], "LineWidth",3)
 
step(t) =
 
heaviside(t) - heaviside(t - 1)
 

Now, say we want the function to go on at $t=0$, $t=2$, $t=4$, etc. and have a magnitude of 3 instead of 1.

$$f(t)=3s(t)+3s(t-2)+3s(t-4)+ \cdots$$
In [15]:
syms t f(t)
f(t)=3*step(t)+3*step(t-2)+3*step(t-4)
fplot(f, [-3,7], "LineWidth",3)
syms g(t) k
g(t)=symsum(step(t-2*k),k,0,10)
fplot(g, [-3,25], "LineWidth", 3)
 
f(t) =
 
3*heaviside(t - 2) - 3*heaviside(t - 1) - 3*heaviside(t - 3) + 3*heaviside(t - 4) - 3*heaviside(t - 5) + 3*heaviside(t)
 
 
g(t) =
 
heaviside(t - 2) - heaviside(t - 1) - heaviside(t - 3) + heaviside(t - 4) - heaviside(t - 5) + heaviside(t - 6) - heaviside(t - 7) + heaviside(t - 8) - heaviside(t - 9) + heaviside(t - 10) - heaviside(t - 11) + heaviside(t - 12) - heaviside(t - 13) + heaviside(t - 14) - heaviside(t - 15) + heaviside(t - 16) - heaviside(t - 17) + heaviside(t - 18) - heaviside(t - 19) + heaviside(t - 20) - heaviside(t - 21) + heaviside(t)
 

These are just these "affine" transformations you learned in Precalculus: horizontal shifts, vertical shifts, horizontal compression/expansions, vertical compression/expansion.

Homework

Please do all of this homework on a separate sheet of paper. Do not use a printout of these slides.

Exercise 1

Give algebraic representations (formulas) for the graphs you sketched in Exercise 1 on the first day of class. Show both the graphs from last week as well as their formulas. These will almost certainly be written in terms of $\delta(t)$, $h(t)$, and $s(t)$.

Homework

Exercise 2

Give formulas for the functions in terms of $\delta(t)$, $h(t)$, or $s(t)$ for the graphs in the pdf: Plotone

Exercise 3 Sketch plots of each of the following:

  1. $\displaystyle f(t)=\sum_{k=0}^4 \delta(t-k)$
  2. $\displaystyle g(t)=\sum_{k=0}^6 \delta\left(t-\frac{k}{2}\right)$
  3. $\displaystyle h(t)=\sum_{k=0}^6 s \left(2(t-k)\right)$
  4. $\displaystyle p(t)=\sum_{k=0}^3 s \left(t-3k\right)$
In [ ]: