Sensitivity equations with discontinuities I'm working on solving pharmacometric problems using ordinary differential equations of low dimensionality. For example, a common simple model looks like this:
$$\dot{A} = -KA$$
where $A$ is the amount of a drug in blood plasma, and $K$ is the elimination rate, in units of 1/time.
It is desired to know how $A$ varies with changes in $K$. Define $G = \partial A/\partial K$. Then we can write a "sensitivity equation":
$$\dot{G} = -KG - A$$
This is all well known, but what is not well known is how to handle discontinuities at particular time points, such as doses $A = A + D$, or simply setting $A$ to zero $A = 0$. What do we do with $G$ at those time points?
I've tentatively concluded that adding something to $A$ does not affect $G$, but multiplying $A$ by some factor, like $0$, should also be applied to $G$.
I would appreciate any insight I may be lacking on this.
For what it's worth, here is some documentation on CVODES, by Serban and Hindmarsh:


 A: In general this problem seems to be complicated, but in this simple case you can be rather explicit. Consider the problem:
$$\frac{\partial x}{\partial t}=kx+f(t),x(k,t=0)=x_0.$$
The solution to this problem is 
$$x(k,t)=e^{kt} \left ( x_0 + \int_0^t e^{-ks} f(s) ds \right ).$$
Thus the derivative with respect to $k$ is
$$\frac{\partial x}{\partial k}(k,t)=t e^{kt} \left ( x_0 + \int_0^t e^{-ks} f(s) ds \right ) - e^{kt} \left ( \int_0^t s e^{-ks} f(s) ds \right ).$$
Differentiating that with respect to $t$ gives
$$\frac{\partial^2 x}{\partial t \partial k} = e^{kt} \left ( kt + 1 \right ) \left ( x_0 + \int_0^t e^{-ks} f(s) ds \right ) - k e^{kt} \int_0^t s e^{-ks} f(s) ds - t f(t)$$
If $f$ is just zero then this reduces to your equation, but otherwise the situation is quite a bit more complicated even in this relatively simple situation, as you can see. 
That said, you can implement your case of interest by considering $f(t)=\sum_{i=1}^n a_i \delta(t-t_i)$; these correspond to dosages of size $a_i$ at times $t_i$.
By the way, if you are careful about the order of multiplication, everything I did above translates to higher dimensions. It also translates to general inhomogeneous linear equations, provided that you can construct the necessary Green's function for them.
A: I wonder if you might want to look into the huge amount of literature on Michaelis–Menten kintetics, which can be used to describe when A is large enough that the path for elimination of drug is saturated. There, dC/dt = Vmax.C/(C + km), where C is the concentration of drug, Vmax and Km are constants. When C is small in relation to km, then dC/dt ~ (Vmax/km).C, which is like your first equation. However, this is more related to how A affects K, in the terminology of your first equation.    
