Fourier Things

2024-10-18

Background#

This is a post about Fourier series, but only in the convolution part.

So, the background of this post is that I watched a video about Fourier series. Here is the video that I'm talking about.

In the video, he's talking about getting a "score" of the phase-shifting process. This score is actually a convolution. The highest score, as well as the point where it produces the highest score, respectively represents relative amplitude and phase of the cosine function used for convolution. This score function is actually another trigonometric function. I'm representing it with $K * \cos(fx + c)$ where $K$, $f$, and $c$ represent amplitude, frequency, and phase of the score function, respectively.

What interests me is that we can obtain $K$ and $c$ by getting the definite integral of $f$ multiplied by sine and cosine functions with a frequency of $f$. I can't prove why this is true (my brain is not "braining" lately). After trying to prove it myself and finding the relevant problems online, I gave up and consulted with ChatGPT.

Consulting with ChatGPT#

Here's the interaction that I had with ChatGPT.

Me:

Suppose that I have a signal $f$ of $x$ ($f(x)$) defined from $-\pi$ to $\pi$. I'm going to convolve it with a cosine function. So the resulting convolution is $$h(t) = \int_{-\pi}^{\pi} f(x) * cos(t - x) dx$$ $h$ is another trigonometric function. I can represent $h(t)$ as $h(t) = K * cos(x + c)$. Now I can multiply $f$ with sine and cosine function and integrate them. Let the result be $A$ and $B$ correspondingly. So $$A = \int_{-\pi}^{\pi} f(x) * sin(x) dx$$ $$B = \int_{-\pi}^{\pi} f(x) * cos(x) dx$$ The interesting part is $K = \sqrt{A^2 + B^2}$ and $c = \text{atan2}(-A, B)$.

How do I prove that $K$ and $c$ can be obtained by integrating multiplication of $f$ with sine and cosine function?

ChatGPT 4o mini:

To prove that $K$ and $c$ can be obtained by integrating the multiplication of $f$ with sine and cosine functions, let's break down the steps involved in the convolution and how it relates to $A$ and $B$.

  1. Convolution Definition: The convolution of $f(x)$ with $\cos(t - x)$ is given by: $$h(t) = \int_{-\pi}^{\pi} f(x) \cos(t - x) , dx$$

    Using the trigonometric identity $\cos(t - x) = \cos(t)\cos(x) + \sin(t)\sin(x)$, we can rewrite this as: $$h(t) = \cos(t) \int_{-\pi}^{\pi} f(x) \cos(x) , dx + \sin(t) \int_{-\pi}^{\pi} f(x) \sin(x) , dx$$

    This allows us to express $h(t)$ in terms of the integrals $A$ and $B$: $$A = \int_{-\pi}^{\pi} f(x) \sin(x) , dx, \quad B = \int_{-\pi}^{\pi} f(x) \cos(x) , dx$$

    Thus, we can rewrite $h(t)$ as: $$h(t) = B \cos(t) + A \sin(t)$$

  2. Representing $h(t)$: We want to express $h(t)$ in the form: $$h(t) = K \cos(t + c)$$ Using the angle addition formula for cosine, we expand this: $$K \cos(t + c) = K (\cos(t) \cos(c) - \sin(t) \sin(c))$$ This gives us: $$h(t) = K \cos(c) \cos(t) - K \sin(c) \sin(t)$$

  3. Matching Coefficients: By comparing coefficients from the two expressions for $h(t)$:

    • The coefficient of $\cos(t)$ gives us: $$B = K \cos(c)$$
    • The coefficient of $\sin(t)$ gives us: $$A = -K \sin(c)$$
  4. Finding $K$ and $c$: To find $K$ and $c$, we can use these relationships:

    • Squaring both equations: $$K^2 \cos^2(c) = B^2, \quad K^2 \sin^2(c) = A^2$$

    • Adding these equations: $$K^2 (\cos^2(c) + \sin^2(c)) = A^2 + B^2 \Rightarrow K^2 = A^2 + B^2$$

    • Thus, we find: $$K = \sqrt{A^2 + B^2}$$

    • For $c$, we use the relationships: $$\tan(c) = -\frac{A}{B} \Rightarrow c = \tan^{-1}\left(-\frac{A}{B}\right) = \text{atan2}(-A, B)$$

In conclusion, $K = \sqrt{A^2 + B^2}$ and $c = \text{atan2}(-A, B)$ can indeed be derived from the integrals $A$ and $B$, confirming the relationships you stated.

It turns out to be very simple. I just had to use a trigonometric identity to transform the convolution into another form. ChatGPT sure is one of the most useful tools that has ever existed.

Bonus#

Here's a Desmos graph that I used for my experiment.