∫ A solution for ODE with an arbitrary term


Kernel:

  • A derivation of a solution to ODE with an arbitary non-homogeneous term.

In this blog, I derive a solution to the following ODE:

$$ \begin{align*} \frac{df}{dt} = q(t) - \lambda f \end{align*} $$
where \(q(t)\) is an arbitrary function of \(t\) and \(\lambda\) is a constant.

This function captures the dynamics of a system where the rate of change of a variable \(f\) is determined by the difference between an arbitrary function \(q(t)\) and the current value of \(f\) scaled by a constant \(\lambda\). We can think of \(q(t)\) as the input added to the system that always decay.

To solve this ODE, we first multiply both sides by \(e^{\lambda t}\) and rearrange the terms:

$$ \begin{align*} e^{\lambda t} \frac{df}{dt} &= e^{\lambda t} q(t) - e^{\lambda t} \lambda f \\ \frac{d}{dt} \left( e^{\lambda t} f \right) &= e^{\lambda t} q(t) \\ e^{\lambda t} f(t) &= \int e^{\lambda t'} q(t') dt' + C \\ f(t) &= \int e^{- \lambda \left(t - t' \right)} q(t') dt' + C e^{-\lambda t} \quad \blacksquare \end{align*} $$

One can verify that the solution is correct by programming the ODE and plotting the solution. Here the result is perfectly fitted to the solution of the ODE.

It's also worth noting that the solution is insentivity to the initial condition when \(t\) is large due to the exponential term \(e^{-\lambda t}\). Here I plot the solution with a different initial condition and the result converges to the same solution.

Very interesting.