# Notes on Differential Equations (3) —— $\frac{dy}{dt}=ay+q(t)$

The general form for any input (or source term) with first order differential equations can be written as below, and it starts at $y(0)$.

$$\frac{dy}{dt}=ay+q(t)$$

One way to interpret this equation is to think it as a bank account, where $a$ is the interest rate and $q(t)$ is the new deposits.

$$\frac{dy}{dt}=\underbrace{ay}_\textrm{interest added}+\underbrace{q(t)}_\textrm{new deposits}$$

The general formula of the solution is

$$y(t)=\underbrace{y(0)e^{at}}_\textrm{null solution}+\underbrace{\int_{s=0}^{s=t}e^{a(t-s)}q(s)ds}_\textrm{particular solution}$$

where $s$ is the running clock, and $t$ is the time we look at it. Why the integral term has $(t-s)$ inside? Because the deposits $q(s)$ is made at time point $s$, and you only get interests after you made the deposits.

Let's have some examples of $q(t)$,

\begin{align*}q(t)&=C\\ &=e^{st}\\ &=\cos\omega t\\ &=\textrm{step function}\\ &=\textrm{delta function} \end{align*}

The step function is always 0 until a time point $t$, it becomes a constant and then stay at that constant forever. The delta function is always 0, except for a single time point, it has a value. Thus delta function is all in one instant, an impulse.

We can verify the particular part of the general solution is correct by the following steps,

\begin{align*}y_p(t)&=\int_{s=0}^{s=t}e^{a(t-s)}q(s)ds\\ &=e^{at}\int_{s=0}^{s=t}e^{-as}q(s)ds\\ \frac{dy}{dt}&=\frac{d\left(e^{at}\right)\left(\int_{s=0}^{s=t}e^{-as}q(s)ds\right)}{dt}\\ &=ae^{at}\int_{s=0}^{s=t}e^{-as}q(s)ds+e^{at}e^{-at}q(t)\\ &=\underbrace{ae^{at}\int_{s=0}^{s=t}e^{-as}q(s)ds}_{ay}+q(t) \end{align*}