How to write equation for half-life of caffeine consumed over time? If you ingest 100mg of caffeine instantly (say, as a pill), then given the six hour half-life of caffeine in the body, you'd calculate the milligrams of caffeine left in your system with $100(\frac{1}{2})^{\frac{t}{6}}$ (where $t$ is the time since ingestion in hours).
What is the equation if you consume the 100mg at a constant rate over the course of an hour (savoring your coffee)?
 A: Here is how we could approach this. We split the time up into two cases: the first hour from when you begin drinking the coffee and then the rest of the time.
Let $N_1$ be the amount of coffee in your system at $t = 1$ hours (when you are done drinking it). Then the amount of coffee left in your system, $t$ hours after you started drinking the coffee will be exactly what you already have in your question except the starting amount will be $N_1$ and you will subtract $1$ from the time in the function to account for the hour passed. That is, the amount of coffee $N(t)$ for $t > 1$, is given by 
$$
N(t) = N_1\left(\frac{1}{2}\right)^{\frac{t-1}{6}} 
$$
So we just need to find $N_1$. Consider the situation where $t \in [0,1]$. We know the coffee is being absorbed at rate of $100$ mg per hour and, due to it's exponential decay, is being broken down at rate $-\lambda N(t)$ where $\lambda$ is the exponential decay constant. Thus we have solve the following differential equation:
$$
\frac{dN}{dt} = 100 - \lambda N(t) \\
$$
We can rearrange:
$$
\begin{align}
\frac{dN}{100 - \lambda N(t)} &= dt \\
\int{\frac{dN}{100 - \lambda N(t)}} &= \int{dt} \\
\frac{-1}{\lambda} \ \ln{({100 - \lambda N(t)})} &= t + C \\
\frac{-1}{\lambda} \ \ln{({100 - \lambda N(t)})} &= t + C \\
\end{align}
$$
which, after solving for the constant, gives us:
$$
N(t) = \frac{100 - 100e^{-\lambda t}}{\lambda}
$$
You can find $N_1 = N(1)$ by substituting the appropriate value for $\lambda$ into the above, giving $N_1 \approx 94.44$.
A: During the one hour drinking, in the interval $\tau, \tau+d\tau$ you are sipping $100\,d\tau$ of caffeine,
which in the following time $t- \tau$ will trace in
$$
100\left[ {0 \leqslant t - \tau } \right]d\tau \left( {\frac{1}
{2}} \right)^{\,\left( {t - \tau } \right)\,\;/6}  = 100\,\left[ {0 \leqslant t - \tau } \right]e^{\, - \,\frac{{\ln 2}}
{6}\;\left( {t - \tau } \right)\,} d\tau 
$$
where the square brackets indicate the Iverson bracket, that is the Unit step function.
So the sipings sum up to:
$$
f(t) = 100\int_{\tau  = 0}^{\,1} {\left[ {0 \leqslant t - \tau } \right]e^{\, - \,\frac{{\ln 2}}
{6}\;\left( {t - \tau } \right)\,} d\tau } 
$$
Now the integral can be developed easily as:
$$
\begin{gathered}
  \int_{\,\tau \, = \,0\;}^{\,1} {\left[ {0 \leqslant t - \tau } \right]e^{\, - \,\lambda \;\left( {t - \tau } \right)\,} d\tau }  =  \hfill \\
   = \left[ {0 \leqslant t < 1} \right]\int_{\,\tau \, = \,0\;}^{\,\,t} {e^{\, - \,\lambda \;\left( {t - \tau } \right)\,} d\tau }  + \left[ {1 \leqslant t} \right]\int_{\,\tau \, = \,0\;}^{\,1} {e^{\, - \,\lambda \;\left( {t - \tau } \right)\,} d\tau }  =  \hfill \\
   = \left[ {0 \leqslant t < 1} \right]\frac{1}
{\lambda }\left( {1 - e^{\, - \,\lambda \;t\,} } \right) + \left[ {1 \leqslant t} \right]\frac{1}
{\lambda }\left( {e^{\, - \,\lambda \;\left( {t - 1} \right)\,}  - e^{\, - \,\lambda \;t\,} } \right) =  \hfill \\
   = \left[ {0 \leqslant t < 1} \right]\frac{1}
{\lambda }\left( {1 - e^{\, - \,\lambda \;t\,} } \right) + \left[ {1 \leqslant t} \right]\frac{1}
{\lambda }\left( {e^{\,\,\lambda \;\,}  - 1} \right)e^{\, - \,\lambda \;t\,}  =  \hfill \\
   = \frac{1}
{\lambda }\left( {\left[ {0 \leqslant t < 1} \right]\left( {e^{\,\lambda \;t\,}  - 1} \right) + \left[ {1 \leqslant t} \right]\left( {e^{\,\,\lambda \;\,}  - 1} \right)} \right)e^{\, - \,\lambda \;t\,}  \hfill \\ 
\end{gathered} 
$$
with $\lambda  = \frac{{\ln 2}}{6}$, and giving the attached graph  
 
Thus, in the time following the drink, everything goes as if you had taken:


*

*$f(1) = \frac{1}{\lambda }\left( {1 - e^{\, - \,\lambda \,} } \right)
   = 94.4\,\%$ alltogether at the end of the drink, or

*$f_{\left[ {1 \leqslant t} \right]} (0) = \frac{1}{\lambda }\left(
   {e^{\,\,\lambda \;\,}  - 1} \right) = 106\,\% $ alltogether at the
beginning, or

*just $100\,\% $ at $t_{\, * }$, i.e. the solution to $1 = \frac{1}{\lambda }\left( {e^{\,\,\lambda \;\,}  - 1} \right)e^{\, - \,\lambda \;t_{\, * } \,} $  which in this case is quite near to the mid hour.

A: Hint: Instead of having the usual differential equation for decay, $\frac{dC(t)}{dt}=-kC(t),$ you have $$\frac{dC(t)}{dt}=k_1-k_2C(t)$$ for the first hour, where $k_i$ are constants to be determined by the boundary conditions. After the first hour, we're simply back to the first equation again (but remember to apply the correct boundary conditions!).
A: A solution based on the Laplace transform: you have $dy/dt=-ky+100(1-u(t-1)),y(0)=0$ where $u$ is the Heaviside step function and $k=\ln(2)/6$. Taking Laplace transforms gives $sY=-kY+\frac{100-100e^{-s}}{s}$, so that $Y=\frac{100-100e^{-s}}{s(s+k)}$. The inverse Laplace transform is then $y(t)=\frac{100}{k} \left ( 1-e^{-kt} + u(t-1) \left ( e^{k-kt} - 1 \right ) \right )$. This could also be written as $y(t)=\begin{cases}\frac{100}{k} \left ( 1-e^{-kt} \right ) & t \leq 1 \\ \frac{100}{k} e^{-kt} \left ( e^k-1 \right ) & t \geq 1 \end{cases}.$
