Convolution seemingly not commutative

convolution

I think I don't quite get how convolution works.

It should be defined as:
$$
f \star g(y) = \int_{-\infty}^{\infty} f(x)g(y-x)\, dx
$$

Now, my two functions are:

f(x) = 1 if x in [-1, 1] else 0
g(x) = 1 - x^2 if x in [-1, 1] else 0

According to the slides, f*g = g*f, but that is inconsistent with the definition, since g*f wouldn't even "contain" y (function f doesn't care about its argument), while the opposite does.

It seems to me that in this case f*g(y) = -2y^2 + 4/3, but g*f wouldn't even contain y in its answer.

How is that?

Best Answer

Noting that $f(x)g(y-x) = 0$ whenever $x < -1$ or $x > 1,$

\begin{align} f \star g(y) &= \int_{-\infty}^\infty f(x)g(y-x)\, dx \\ &= \int_{-1}^1 f(x)g(y-x)\, dx \\ &= \int_{-1}^1 g(y-x)\, dx \\ &= -\int_{y+1}^{y-1} g(t)\, dt && t = y - x \\ &= \int_{y-1}^{y+1} g(t)\, dt. \end{align}

But also $g(x)f(y-x) = 0$ whenever $y-x < -1$ or $y-x > 1$, that is to say, whenever $x > y+1$ or $x < y-1,$ so

\begin{align} g \star f(y) &= \int_{-\infty}^\infty g(x)f(y-x)\, dx \\ &= \int_{y-1}^{y+1} g(x)f(y-x)\, dx \\ &= \int_{y-1}^{y+1} g(x)\, dx . \end{align}

The final value of the integral either way is not as simple as $-2y^2 + \frac43.$ If $y \leq -2$ or $y \geq 2$ the integral is zero. If $y = 0$ then

\begin{align} g \star f(y) &= \int_{-\infty}^\infty g(x)f(-x)\, dx \\ &= \int_{-1}^{1} g(x)\, dx \\ &= \int_{-1}^{1} (1 - x^2)\, dx \\ &= 2 - \left. \frac{x^3}{3}\right\rvert_{x=-1}^{x=1} \\ &= \frac 43. \end{align}

But if $0 < y < 2$ then $f(y - x) = 0$ whenever $x < y - 1,$ and $g(x) = 0$ whenever $x > 1,$ so

\begin{align} g \star f(y) &= \int_{-\infty}^\infty g(x)f(y-x)\, dx \\ g \star f(y) &= \int_{y-1}^{1} g(x) \, dx \\ g \star f(y) &= \int_{y-1}^{1} (1 - x^2)\, dx \\ &= (2 - y) - \left. \frac{x^3}{3}\right\rvert_{x=y-1}^{x=1} \\ &= \frac{y^3}{3} - y^2 + \frac 43. \end{align}

And if $-2 < y < 0$ then $f(y - x) = 0$ whenever $x > y + 1,$ and $g(x) = 0$ whenever $x < -1,$ and the result is

\begin{align} g \star f(y) &= -\frac{y^3}{3} - y^2 + \frac 43. \end{align}

So $g\star f(y)$ depends very much on $y$.

Moreover, your calculation of $f\star g(y)$ is incorrect. You need to account for the fact that $g(x)=1 - x^2$ on all of $[y-1,y+1]$ only when $y = 0.$ For $y > 0,$ $g(x)=1 - x^2$ on $[y-1,1]$ and $g(x) = 0$ otherwise. Indeed, you should end up integrating the exact same integrals as for $g\star f.$