Fundamental Theorem of Calculus and Chain Rule for differentiating integral with multiple functions (exponential-weighted moving average in ODE form)

42 Views Asked by At

I am trying to derive the ODE version of the continuous exponentially-weighted moving average on Integral form given as such:

$m(t) = \frac{1}{w} \int_{-\infty}^{t} x(\tau)e^{-(t-\tau)/w} \,d\tau$

I assume I will need to combine the chain rule as well as the fundamental theory of calculus in order to turn this into:

$\frac{dm}{dt} = \frac{1}{w}x(t) - \frac{1}{w}m(t)$

However, I am not too sure how to do this. For example, my steps so far are:

  1. $\frac{d}{dt} m(t) = \frac{d}{dt} \frac{1}{w} \int_{-\infty}^{t} x(\tau)e^{-(t-\tau)/w} \,d\tau$
  2. $\frac{dm}{dt} = \frac{1}{w} \int_{-\infty}^{t} \frac{d}{dt}(x(\tau)e^{-(t-\tau)/w}) \,d\tau$
  3. $\frac{dm}{dt} = \frac{1}{w} \int_{-\infty}^{t} \frac{dx(\tau)}{dt}e^{-(t-\tau)/w} + x(\tau) \frac{de^{-(t-\tau)/w}}{dt} \,d\tau$
  4. $\frac{dm}{dt} = \frac{1}{w} \int_{-\infty}^{t} \frac{dx(\tau)}{dt}e^{-(t-\tau)/w}\,d\tau + \frac{1}{w} \int_{-\infty}^{t}x(\tau) \frac{de^{-(t-\tau)/w}}{dt} \,d\tau$
  5. $\frac{dm}{dt} = \frac{1}{w} \int_{-\infty}^{t} \frac{dx(\tau)}{dt}e^{-(t-\tau)/w}\,d\tau + \frac{1}{w} \int_{-\infty}^{t}x(\tau) (-\frac{1}{w}) e^{-(t-\tau)/w} \,d\tau$
  6. $\frac{dm}{dt} = \frac{1}{w} \int_{-\infty}^{t} \frac{dx(\tau)}{dt}e^{-(t-\tau)/w}\,d\tau + \frac{1}{w}(-\frac{1}{w}\int_{-\infty}^{t} x(\tau)e^{-(t-\tau)/w} \,d\tau) $
  7. $\frac{dm}{dt} = \frac{1}{w} \int_{-\infty}^{t} \frac{dx(\tau)}{dt}e^{-(t-\tau)/w}\,d\tau - \frac{1}{w}m(t) $
  8. ...

However after 7. I am stuck trying to figure out why (and more importantly how):

$\frac{1}{w} \int_{-\infty}^{t} \frac{dx(\tau)}{dt}e^{-(t-\tau)/w}\,d\tau = \frac{1}{w}x(t)$

I know that: $ \frac{d}{dt} \int_{-\infty}^{t} f(\tau) \,d\tau = \frac{d}{dt}F(t) - \frac{d}{dt}F(-\infty)$ However, I am not sure how this would apply here when we have $\frac{dx(\tau)}{dt}$ inside the integral since in this first integral term $e^{-(t-\tau)/w}$ is not differentiated because it already has been (chain rule).

Thank you in advance!

EDIT:

After looking into Leibniz Integral Rule, if I write it as such I get.

$\frac{d}{dt} \frac{1}{w} \int_{-\infty}^{t} x(\tau)e^{-(t-\tau)/w} \,d\tau$ -> set $x(\tau)e^{-(t-\tau)/w} = f(t,\tau)$ ->

$\frac{d}{dt} \frac{1}{w} \int_{-\infty}^{t} f(t,\tau) \,d\tau$ and solve as following using Leibnitz:

  1. $ \frac{d}{dt} \frac{1}{w} \int_{-\infty}^{t} f(t,\tau) \,d\tau = \frac{1}{w}f(t,t) + \frac{1}{w}\int_{-\infty}^{t} \frac{\partial}{\partial t}f(t,\tau) \,d\tau $
  2. $= \frac{1}{w}x(t)e^{-(t-t)/w} + \frac{1}{w}\int_{-\infty}^{t} \frac{\partial}{\partial t} x(\tau) e^{-(t-\tau)/w} \,d\tau$
  3. $= \frac{1}{w}x(t) + \frac{1}{w}\int_{-\infty}^{t} x(\tau) (-\frac{1}{w})e^{-(t-\tau)/w} $
  4. $= \frac{1}{w}x(t) - \frac{1}{w} m(t) $

Is this the correct way? Can we use the $\frac{\partial}{\partial t}$ straight on $e^{-(t-\tau)/w}$ and just treat $x(\tau)$ as constant when differentiation as done between steps 2 and 3?