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 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}.$
