Convolutions

In signal processing, the convolution is a very useful operation, and is defined as:

$(f * g)(t) = \int_{-\infty}^\infty f(\tau) g(t - \tau) d\tau$

If both $f$ and $g$ are functions multiplied by a unit step function, then we can rewrite the integral as:

$(fu * gu)(t) = u(t) \int_0^t f(\tau) g(t - \tau) d\tau$

We can author a Maple function to perform a convolution:

[> conv := (f, g, t)
     -> int( eval( f, t = %tau )*eval( g, t = t - %tau ), %tau = -infinity..infinity ):

Now, with the above simplification, if we are assuming that both arguments are multiplied by the unit step function, we now have the following:

[> conv0 := (f, g, t)
     -> u(t)*int( eval( f, t = %tau )*eval( g, t = t - %tau ), %tau = 0..t ):

Unfortunately, this, too, is too naive, for what if one of the functions is $\delta(t)$?. Once again, we must resort to using limits:

$(fu * gu)(t) = u(t) \int_{0^-}^{t^+} f(\tau) g(t - \tau) d\tau$

Thus, we have the more complex definition:

[> conv0 := (f, g, t)
    -> u(t)*limit( limit( int(
        eval( f, t = %tau )*eval( g, t = t - %tau ), %tau = %a..%b
    ), %a = 0, 'left' ), %b = t, 'right' ):

You can now use this as expected:

[> conv0( exp(-t), cos(t), t );

$u(t)\left( \frac{\cos(t)}{2} + \frac{\sin(t)}{2} - \frac{e^{-t}}{2} \right)$

[> conv0( exp(-t), delta(t), t );

$u(t)^2 e^{-t}$

[> conv0( delta(t), cos(t), t );

$u(t)^2 \cos(t)$

You may need to call simplify(..., 'size') on these results to make them neater, or you could integrate these into the functions. For appending to your .mapleprofile:

conv := (f, g, t) -> simplify( int(
    eval( f, t = %tau )*eval( g, t = t - %tau ), %tau = -infinity..infinity
), 'size' ):
conv0 := (f, g, t) -> u(t)*simplify( limit( limit( int(
    eval( f, t = %tau )*eval( g, t = t - %tau ), %tau = %a..%b
), %a = 0, 'left' ), %b = t, 'right' ), 'size' ):