# Linear differential equation with driving

In class we are solving the linear differential equation with driving given by $$\frac{dx}{dt} = -\gamma x + f(t)$$ The professor first transformed to a new variable $$y$$, $$y(t) := x(t) e^{\gamma t}$$ and then calculate the differential equation for $$y$$: $$\frac{dy}{dt} = \frac{\partial y}{\partial x}\frac{dx}{dt} + \frac{\partial y}{\partial t} = e^{\gamma t} f(t)$$ Problem: I don't understand how he reached the last step, i.e., how it equals $$e^{\gamma t} f(t)$$.

Attempt: Here is what I get for the differentials: $$\frac{\partial y}{\partial x} = e^{\gamma t} \\ \frac{dx}{dt} = -\gamma x + f(t) \\ \frac{\partial y}{\partial t} = e^{\gamma t}\frac{dx}{dt} + x(t)\gamma e^{\gamma t}$$ Given these, I get $$\frac{\partial y}{\partial x}\frac{dx}{dt} + \frac{\partial y}{\partial t} = -\gamma x e^{\gamma t} + 2fe^{\gamma t}$$ which is incorrect. It's probably my differentials that are incorrect, but what am I doing wrong here?

Attempt: Here is what I get for the differentials: $$\frac{\partial y}{\partial x} = e^{\gamma t} \\ \frac{dx}{dt} = -\gamma x + f(t) \\ \color{red}{\frac{\partial y}{\partial t} = e^{\gamma t}\frac{dx}{dt} + x(t)\gamma e^{\gamma t}}$$

By calculating $$\frac{dy}{dt}$$ as $$\frac{dy}{dt} = \color{blue}{\frac{\partial y}{\partial x}\frac{dx}{dt} }+ \color{red}{\frac{\partial y}{\partial t}}$$ you have already taken the $$x$$, and $$t$$ through $$x$$, dependency into account (blue). That leaves:

$$\frac{\partial y}{\partial t} = x\gamma e^{\gamma t}$$ and so: $$\frac{dy}{dt} = e^{\gamma t} \bigl( -\gamma x + f(t) \bigr) + x\gamma e^{\gamma t} = e^{\gamma t}f(t)$$

Differentiate $$y(t) = x(t) e^{\gamma t}$$ with the product rule:

$$y'(t)=x'(t)e^{\gamma t}+x(t) \gamma e^{\gamma t}.$$

Since $$x'(t)=- \gamma x(t)+f(t)$$, we get

$$y'(t)=(- \gamma x(t)+f(t))e^{\gamma t}+x(t)\gamma e^{\gamma t}=f(t)e^{\gamma t}.$$

$$\frac{dx}{dt}+\gamma x=f(t)\Rightarrow e^{-t} \frac{d(e^t x)}{dt}=f(t) \Rightarrow \frac{d(e^t x)}{dt}=e^t f(t).$$ Finally, integrating we get $$e^t x=\int e^t f(t)+C \Rightarrow x=e^{-t} \int e^t x dt+C e^{-t}.$$