# Trying to understand how to get this basic Fourier Series

I'm sorry if this kind of question isn't allowed, but I'm starting to learn Fourier series and I'm still not entirely sure what's going on... in this specific case, I'm trying to find the Continuous Time FS representation of this signal:

From what I gather, the period of this signal is $$T=6$$, and in order to find the Fourier coefficients, I only need to consider the integral from $$-2$$ to $$2$$, which I think I can divide into $$3$$ integrals:

• $$\int_{1}^{2}(-t+2)e^{-jk\omega t}dt$$
• $$\int_{-1}^{1}(1)e^{-jk\omega t}dt$$
• $$\int_{-2}^{-1}(t+2)e^{-jk\omega t}dt$$

If the exponent term weren't there, then the first and last terms would cancel out because of symmetry, but since the exponent terms ARE there, then they don't cancel out. Then when I try doing the integrals, I end up with a 10-term monster, where it looks awful even if I replace $$^{-jkwt}$$ with a stand-in variable, which leads me to believe I'm doing something wrong.

Is it incorrect to split up the integral like that? What am I meant to do here?

This is indeed a gnarly integral to do by hand, so it may be easier to leverage some properties of the Fourier Transform applied to simpler signals.

Your signal is a trapezoid and it can be created by the convolution of two rectangles, i.e.

$$x(t) = g \cdot \text{rect}(t/1) * \text{rect}(t/3)$$

So if you know the Fourier Coefficients of a rectangle and the convolution property of the Fourier Transform you can splice this together.

• I think it might be instead $$x(t) = g \cdot \text{rect}(t/1) * \text{rect}(t/3)$$ The widths gotta add to 4. Mar 4, 2023 at 0:55
• Thanks. Fixed . Mar 4, 2023 at 7:09

You're on the right track, just keep a cool head and solve those integrals. You can make use of the function's symmetry by noting that for even and real-valued $$f(t)$$, the Fourier coefficients can be written as

\begin{align}c_k&=\frac{1}{T}\int_{-T/2}^{T/2}f(t)e^{-j2\pi kt/T}dt\\&=\frac{2}{T}\int_0^{T/2}f(t)\cos(2\pi kt/T)dt\end{align}

So you end up with just two intervals and with two types of integrals, namely

$$I_1=\int\cos(2\pi kt/T)dt$$

and

$$I_2=\int t\cos(2\pi kt/T)dt$$

The first one is trivial and the second one can be solved using integration by parts. I'm confident that you can take it from here.

Another alternative, apart from representing the given function by the convolution of two rectangles as suggested in Hilmar's answer, is to differentiate the function. This approach was suggested in Olli's answer, but we can take this approach even a bit further. The first derivative of $$f(t)$$ is given in Olli's answer. If we differentiate a second time, we obtain

$$f''(t)=\delta(t+2)-\delta(t+1)-\delta(t-1)+\delta(t-2)$$

Computing the Fourier coefficients of this function is very simple:

\begin{align}d_k&=\frac{1}{T}\int_{-T/2}^{T/2}f''(t)e^{-j2\pi kt/T}dt\\&=\frac16\int_{-3}^3\big[\delta(t+2)-\delta(t+1)-\delta(t-1)+\delta(t-2)\big]e^{-j\pi kt/3}dt\\&=\frac16\left[e^{j2\pi k/3}-e^{j\pi k/3}-e^{-j\pi k/3}+e^{-j2\pi k/3}\right]\\&=\frac13\left[\cos\left(\frac{2\pi k}{3}\right)-\cos\left(\frac{\pi k}{3}\right)\right]\end{align}

These Fourier coefficients are related to the Fourier coefficients $$c_k$$ of the original function by

$$d_k=\left(\frac{j2\pi k}{T}\right)^2c_k=-\frac{\pi^2k^2}{9}c_k$$

Consequently, for $$k\neq 0$$ the Fourier coefficients $$c_k$$ of $$f(t)$$ are given by

\begin{align}c_k&=\frac{3}{\pi^2k^2}\left[\cos\left(\frac{\pi k}{3}\right)-\cos\left(\frac{2\pi k}{3}\right)\right],\quad k\neq 0\end{align}

The coefficient $$c_0$$ cannot be obtained from the coefficients $$d_k$$ because differentiation eliminates the DC value of $$f(t)$$. That coefficient needs to be obtained directly from $$f(t)$$:

$$c_0=\frac{1}{T}\int_{-T/2}^{T/2}f(t)dt=\frac12$$

Using the trigonometric identity $$\cos(a-b)-\cos(a+b)=2\sin(a)\sin(b)$$, the coefficients $$c_k$$ ($$k\neq 0$$) can also be written as

$$c_k=\frac{6}{\pi^2k^2}\sin\left(\frac{\pi k}{2}\right)\sin\left(\frac{\pi k}{6}\right),\quad k\neq 0$$

which shows the fact that the coefficients $$c_k$$ can be written as the multiplication of the Fourier coefficients of two rectangles (see Hilmar's answer). The other representation shown above as a difference of cosines shows that the function $$f(t)$$ can also be written as the difference of two triangles.

The figure below shows two approximations of $$f(t)$$ by truncating the Fourier series computed above. The blue curve was obtained by summing $$10$$ cosine terms, whereas for the orange curve $$100$$ cosine terms were used.

In sum, these are the options you have:

• solve the integrals making use of the function's symmetry, as explained above; it's not that hard.
• write the function as the convolution of two rectangles and use the well-known Fourier series of a rectangular pulse.
• write the function as the difference of two triangles and use the (relatively) well-known Fourier series of a triangular wave.
• differentiate the function twice to end up with Dirac impulses; then use the differentiation/integration property of Fourier series to obtain the Fourier coefficients of the original function.

One more trick you could use. For the period you have (here written with an increasing order of $$t$$):

$$x(t) = \cases{ 0 &\text{if t \le -2,}\\ t+2 &\text{if -2 \le t \le -1,}\\ 1 &\text{if -1 \le t \le 1,}\\ -t+2 &\text{if 1 \le t \le 2,}\\ 0 &\text{if 2 \le t}}\tag{1}$$

By differentiating:

$$x'(t) = \cases{ 0 &\text{if t < -2,}\\ 1 &\text{if -2 < t < -1,}\\ 0 &\text{if -1 < t < 1,}\\ -1 &\text{if 1 < t < 2,}\\ 0 &\text{if 2 < t}}\tag{2}$$

This is a sum of boxcar functions that each have a Fourier transform $$\mathcal{F}$$ that is related to the sinc function by the Fourier transform pairs of shifting: $$\mathcal{F}\big(f(t - t_0)\big)(\omega) = e^{-t_0 i\omega}\mathcal{F}\big(f(t)\big)$$ and argument scaling: $$\mathcal{F}\big(f(at)\big)(\omega) = \frac{1}{|a|}\mathcal{F}\big(f(t)\big)(\frac{\omega}{a})$$. You could write $$\mathcal{F}\big(x'(t)\big)(\omega)$$ and use the Fourier transform pair of integration: $$\mathcal{F}\big(\int{}{}f(t)\big)(\omega) = \frac{\mathcal{F}(f)}{i\omega} + c\delta(\omega)$$, where $$c$$ is a constant and $$\delta$$ is the Dirac delta function. If we want to arrive at the Fourier transform of a function $$g(t)$$ that we differentiated to obtain $$f(t)$$, then we must equate $$g(t) = \frac{\mathcal{F}(f)}{i\omega} + c\delta(\omega)$$, where $$c$$ represents the mean of $$g(t)$$. The coefficient $$c$$ must be zero if $$g(t)$$ is any derivative of $$x(t)$$ (except $$x(t)$$ itself as the 0th derivative), because the derivative of a compactly supported function must be compactly supported (because the derivative must be zero outside the support of the function) and zero-mean (or else the function would not come back to zero at the end of the support).

You can refer to Matt L.'s answer on how to relate to calculation of Fourier series coefficients an extension of this approach with two differentiation steps.

In this answer (Eqs. 2 and 3) there are ready-made formulas for the Fourier series of a piece-wise linear function given a list of corner points, however with a hard-coded period $$T = 2\pi$$.

• Differentiating one more time yields 4 Dirac impulses, which would make things even easier. But maybe you were planning on adding this anyway ... Mar 7, 2023 at 11:51
• @MattL. I did first do exactly that, and it was pretty, but then going from $x''(t)$ to $x'(t)$ and to $x(t)$ came the problem of finding the values for $c$, and that seemed messier with two integration steps. But maybe there is a clean way... Mar 7, 2023 at 13:40
• I think it should be straightforward when dealing directly with Fourier coefficients: if $d_k$ are the Fourier coefficients of the twice differentiated function and $c_k$ are the Fourier coefficients of the original function, we have $d_k=(j2\pi k/T)^2c_k$. I.e., for $k\neq 0$ we can easily obtain $c_k$ from $d_k$. The coefficient $c_0$ must be obtained directly from the original function. Mar 7, 2023 at 15:22