Approximating the Box Function as a sum of sinusoids using the Inverse Fourier Transform

137 Views Asked by At

I use this formula for the Fourier Transform, preferring the angular frequency $\omega$ over the ordinary frequency $f$:

$$ f(x) = \frac{1}{2\pi} \int_{-\infty}^{\infty} F(\omega) e^{i\omega x} d\omega \\ F(\omega) = \int_{-\infty}^{\infty} f(x) * e^{-i\omega x} dx $$

Given a non-periodic box function, let's call it $g(x)$:

$$ g(x) = \begin{cases} A & \text{if } -\frac{1}{2} \lt x \lt \frac{1}{2} \\ 0 & \text{otherwise} \\ \end{cases} $$

(Where $A \in R_{+}$ is a constant)

I've calculated the $G(\omega)$ for $g(x)$:

$$ G(\omega) = \int_{-\frac{1}{2}}^{\frac{1}{2}} A * e^{-i\omega x} dx = A * \frac{e^{-i\omega x}}{-i\omega}\Bigr|_{-\frac{1}{2}}^{\frac{1}{2}} = A * \frac{e^{\frac{i\omega}{2}} - e^{\frac{-i\omega}{2}}}{i\omega} \\ $$

That simplifies to:

$$ G(\omega) = A * \frac{2}{\omega} * sin(\frac{\omega}{2}) = A * \frac{sin(\frac{\omega}{2})}{\frac{\omega}{2}} $$

Until now, everything is clear (unless I've made a mistake).

Now, I want to use the Fourier Transform to approximate my initial function $g(x)$ as a $\sum$ of sinusoids.

Using the inverse Fourier Transform $g(x)$ can be written as:

$$ g(x)=\frac{1}{2\pi} \int_{-\infty}^{\infty} G(\omega) * \underbrace{e^{i\omega x}}_{\text{sinusoid}} d\omega $$

So my relationship becomes:

$$ g(x)=\frac{1}{2\pi} \int_{-\infty}^{\infty} \frac{2*A}{\omega} * sin(\frac{\omega}{2}) * e^{i\omega x} d\omega $$

How do I identity and extract the most relevant 10 terms (sinusoids) from the Inverse Fourier Transform so I can express $g(x) \approx \sum_{n=1}^{10} \text{?sinusoid?}$.

If I plug in some values for $\omega$ and plot the results, there is nothing like the initial box function. So, I suspect I might be doing something incorrect (from a mathematical standpoint).

This makes me ask a secondary question: Is my assumption correct that the Inverse Fourier Transform can still be approximated as sum of sinusoids? If yes, how can I read of the imaginary part, as my initial function was on R.

2

There are 2 best solutions below

0
On BEST ANSWER

Since the function

$$g_A(x)=\left\{\begin{array}{cc} A & -\frac{1}{2}<x<\frac{1}{2} \\ 0 & \text{Otherwise} \\ \end{array}\right.\tag{1}$$

is an even function of $x$ it can be approximated by the cosine Fourier series

$$g_A(x) \approx a_0+\underset{K\to\infty}{\text{lim}}\left(\sum\limits _{n=1}^K a_n \cos \left(\frac{2 \pi n x}{P}\right)\right)\tag{2}$$

on the interval $-\frac{P}{2}<x<\frac{P}{2}$ where

$$a_0=\frac{1}{P} \int\limits_{-\frac{P}{2}}^{\frac{P}{2}} g(x) \, dx=\frac{A}{P}\tag{3}$$

and for $n\ne0$

$$a_n=\frac{2}{P} \int\limits_{-\frac{P}{2}}^{\frac{P}{2}} g(x)\, \cos\left(\frac{2 \pi n x}{P}\right) \, dx=\frac{2 A}{\pi}\, \frac{\sin\left(\frac{\pi n}{P}\right)}{n}\tag{4}$$

so in a sense one has

$$g_A(x) \approx \underset{P\to\infty}{\text{lim}}\left(\frac{A}{P}+\frac{2 A}{\pi}\, \underset{K\to\infty}{\text{lim}}\left(\sum\limits_{n=1}^K \frac{\sin\left(\frac{\pi n}{P}\right)}{n}\, \cos\left(\frac{2 \pi n x}{P}\right)\right)\right)\tag{5}.$$


The exponential Fourier series for $g_A(x)$ on the interval $-\frac{P}{2}<x<\frac{P}{2}$ is

$$g_A(x) \approx \underset{K\to\infty}{\text{lim}}\left(\sum\limits_{n=-K}^K c_n\, e^{\frac{2 i \pi n x}{P}}\right)\tag{6}$$

where

$$c_n=\frac{1}{P} \int\limits_{-\frac{P}{2}}^{\frac{P}{2}} g_A(x)\, e^{-\frac{i 2 \pi n x}{P}} \, dx=\frac{A}{\pi}\,\frac{\sin\left(\frac{\pi n}{P}\right)}{n}\tag{7}$$

and

$$c_0=a_0=\frac{1}{P} \int\limits_{-\frac{P}{2}}^{\frac{P}{2}} g(x) \, dx=\frac{A}{P}=\underset{n\to 0}{\text{lim}}\left(\frac{A}{\pi}\, \frac{\sin\left(\frac{\pi n}{P}\right)}{n}\right)\tag{8}$$

so in a sense one has

$$g_A(x) \approx \underset{P\to\infty}{\text{lim}}\left(\frac{A}{\pi}\, \underset{K\to\infty}{\text{lim}}\left(\sum\limits_{n=-K}^K \frac{\sin\left(\frac{\pi n}{P}\right)}{n}\, e^{\frac{2 i \pi n x}{P}}\right)\right)\tag{9}.$$


Formula (9) above can also be evaluated as

$$g_A(x) \approx \underset{P\to\infty}{\text{lim}}\left(\frac{A}{P}+\frac{A}{\pi}\underset{K\to\infty}{\text{lim}}\left(\sum\limits_{n=1}^K \left(\frac{\sin\left(-\frac{\pi n}{P}\right)}{-n}\, e^{-\frac{2 i \pi n x}{P}}+\frac{\sin\left(\frac{\pi n}{P}\right)}{n}\, e^{\frac{2 i \pi n x}{P}}\right)\right)\right)\tag{10}$$

and since

$$\frac{A}{\pi} \left(\frac{\sin\left(-\frac{\pi n}{P}\right)}{-n}\, e^{-\frac{2 i \pi n x}{P}}+\frac{\sin\left(\frac{\pi n}{P}\right)}{n}\, e^{\frac{2 i \pi n x}{P}}\right)=\frac{2 A}{\pi}\, \frac{\sin\left(\frac{\pi n}{P}\right)}{n}\, \cos\left(\frac{2 \pi n x}{P}\right)\tag{11}$$

the exponential Fourier series defined in formula (9) above is equivalent to the cosine Fourier series defined in formula (5) above.


The function $g_A(x)$ can also be approximated as

$$g_A(x) \approx \frac{A}{\pi}\, \underset{f\to\infty}{\text{lim}} \left(\text{Si}\left(2 f \pi \left(x+\frac{1}{2}\right)\right)-\text{Si}\left(2 f \pi \left(x-\frac{1}{2}\right)\right)\right)\tag{12}$$

where $\text{Si}(z)$ is the sine integral function.


0
On

You can recover $f$ using the inverse fourier transform from $\hat{f}$ if $\hat{f} \in L^{1}(\mathbb{R})$. Here is the related theorem: If $f \in L^{1}(\mathbb{R})$ and $\hat{f} \in L^{1}(\mathbb{R})$, then $$f(t)=\frac{1}{2\pi}\int_{-\infty}^{\infty} \hat{f}(w)e^{iwt}dw.$$

In your case, the box function $g(x)$ is clearly in $L^{1}(\mathbb{R})$ but $G(w)$ is not in $L^{1}(\mathbb{R})$. You cannot take this approach to approximate the box function with sinusoidal functions.

The equality in the theorem above works for each $t$ (pointwise). Note that there is a similar equality for $L^2(\mathbb{R})$ functions but the equality is not meant for each $t$, rather it is in $L^{2}$ norm. So $L^1$, $L^2$ issues and the equalities are given in which context is important. I took this theorem from the book "A Wavelet tour of Signal Processing." Also you can find it in harmonic analysis book or real analysis books. In your case the best option will be to use Fourier series. You can approximate a periodic function by a series of sinusoidal functions (Fourier Series). You can view the box function as one part of square wave function. Check https://mathworld.wolfram.com/FourierSeriesSquareWave.html and the complementary answer in Fourier Series of a Constant Function. As noted there, there will be problems at the endpoints in this approach (so it is not perfect), but it seems it is the best approach so far to your question.