Amplitude of first harmonic of a square wave, $2/\pi$ or $4/\pi$? I am getting really confused about the value of the first harmonic of a $50\%$ duty cycle $-1$ to $1$ square wave.
By doing the math I found $\frac{2}{\pi}$, in my lesson and Wikipedia it's $\frac{4}{\pi}$.
But now I checked with MATLAB and it's also $\frac{2}{\pi} \approx 0.6$
t = -100:0.1:99.9; % -&gt; length = 2000
x = square(t, 50);
plot(abs(fft(x)/2000));



As you can see, on the spectrum the first harmonic is at $\frac{2}{\pi}$
And this is how I found $\frac{2}{\pi}$
\begin{align}
x(t) &amp;= \text{rect}\left(\frac{t}{T/2}\right) \ast \delta_T(t) - \text{rect}\left(\frac{t}{T/2}\right) \ast \delta_T\left(t - \frac{T}{2}\right)\\
 &amp;= \text{rect}\left(\frac{t}{T/2}\right) \ast \left( \delta_T(t) - \delta_T\left(t - \frac{T}{2}\right)\right)\\
\implies X(f) &amp;= \frac{T}{2}\mathrm{sinc}\left(\pi f \frac{T}{2}\right)\cdot F \cdot \delta_F(f)\cdot\left(1 - \exp\left(-2\pi j f\frac{T}{2}\right)\right)\\
 &amp;= \frac{1}{2}\mathrm{sinc}\left(\pi f \frac{T}{2}\right)\cdot\delta_F(f)\cdot\left(1 - \exp\left(-2\pi j f\frac{T}{2}\right)\right)\\
\implies X(F) &amp;= X\left(\frac 1T\right) = \frac{2}{\pi}
\end{align}
Clarification and definitions I am using:
$$\text{FFT}\left\{\mathrm{rect}\left(\frac tT\right)\right\} = T\mathrm{sinc}\left(\pi f T\right)$$
$\delta_T$ is the dirac comb of period $T$.
It's just a question of the definition of the Fourier series coefficients. There is the complex Fourier series

$$x(t)=\sum_{n=-\infty}^{\infty}c_ne^{j2\pi nt/T}\tag{1}$$

where $c_n$ are the complex Fourier series coefficients, and $T$ is the period of the periodic function $x(t)$. For real-valued $x(t)$ you can also use the real-valued Fourier series

$$x(t)=a_0+\sum_{n=1}^{\infty}\left[a_n\cos(2\pi nt/T)+b_n\sin(2\pi nt/T)\right]\tag{2}$$

with

$$a_0=c_0,\quad a_n=2\text{Re}\{c_n\},\quad b_n=-2\text{Im}\{c_n\}\tag{3}$$

For a $T$-periodic square wave with duty cycle of $50\%$ and amplitude $1$ you get

$$c_n=\begin{cases}\frac{2}{jn\pi},\quad n\text{ odd}\\0,\quad n\text{ even}\end{cases}\tag{4}$$

From $(3)$ you get

$$a_n=0,\quad b_n=\begin{cases}\frac{4}{n\pi},\quad n\text{ odd}\\0,\quad n\text{ even}\end{cases}\tag{5}$$

So if you only use positive frequencies in your series respresentation, as in $(2)$, your get a factor of $4/\pi$ for the first harmonic, whereas if you use positive as well as negative frequencies, as in $(1)$, you get a factor of $2/j\pi$ for $n=1$ and for $n=-1$.

Your representation as a Fourier transform corresponds to $(1)$, where for each frequency component you get a Dirac impulse in the frequency domain. Since that Dirac comb has components at positive as well as at negative frequencies, the amplitudes equal $2/n\pi$:

$$X(f)=\sum_{n=-\infty}^{\infty}c_n\delta\left(f-\frac{n}{T}\right)\tag{6}$$