TExcelTAD
Home › Fourier Analysis & Signals › Sine-Cosine Form and Symmetry

Sine-Cosine Form and Symmetry

For real signals the complex Fourier series can be rewritten with real sines and cosines, the form in most engineering tables, or as amplitudes and phases, the form a spectrum analyzer shows. This lesson converts between the three forms and uses symmetry to predict which coefficients vanish before computing anything.

Three equivalent forms

For a real TT-periodic ff with ω0=2π/T\omega_0 = 2\pi/T:

f(t)=∑k=−∞∞ckeikω0t=a02+∑k=1∞(akcos⁡(kω0t)+bksin⁡(kω0t))=c0+∑k=1∞Akcos⁡(kω0t+φk)\begin{aligned} f(t) &= \sum_{k=-\infty}^{\infty} c_k e^{i k \omega_0 t} \\ &= \frac{a_0}{2} + \sum_{k=1}^{\infty} \big( a_k \cos(k\omega_0 t) + b_k \sin(k\omega_0 t) \big) \\ &= c_0 + \sum_{k=1}^{\infty} A_k \cos(k\omega_0 t + \varphi_k) \end{aligned}

with ak=2Re⁡cka_k = 2\operatorname{Re} c_k, bk=−2Im⁡ckb_k = -2\operatorname{Im} c_k, Ak=2∣ck∣A_k = 2\lvert c_k \rvert and φk=arg⁡ck\varphi_k = \arg c_k. The factor 2 appears because ckc_k and c−k=ck‾c_{-k} = \overline{c_k} together make one real sinusoid.

python · try it yourself
import numpy as np

N = 1024
t = np.arange(N) / N
f = 1.5 + 2 * np.cos(2 * np.pi * t) - 3 * np.sin(2 * np.pi * 3 * t) + np.cos(2 * np.pi * 5 * t + 0.7)

c = np.fft.fft(f) / N
for k in (0, 1, 3, 5):
    a, b = round(2 * c[k].real, 4) + 0.0, round(-2 * c[k].imag, 4) + 0.0
    A, phi = 2 * abs(c[k]), round(float(np.angle(c[k])), 4) + 0.0
    if k == 0:
        print(f"k=0: c0 = {c[0].real:.4f}")
    else:
        print(f"k={k}: a={a:+.4f} b={b:+.4f}   A={A:.4f} phase={phi:+.4f}")
k=0: c0 = 1.5000
k=1: a=+2.0000 b=+0.0000   A=2.0000 phase=+0.0000
k=3: a=+0.0000 b=-3.0000   A=3.0000 phase=+1.5708
k=5: a=+0.7648 b=-0.6442   A=1.0000 phase=+0.7000

The program recovers each term: 2cos⁡2\cos at k=1k = 1, −3sin⁡-3\sin at k=3k = 3 (amplitude 3, phase π/2\pi/2), and the cosine with phase 0.7 at k=5k = 5.

Symmetry shortcuts

  • Even ff (f(−t)=f(t)f(-t) = f(t)): all bk=0b_k = 0, a pure cosine series; the ckc_k are real.
  • Odd ff: all ak=0a_k = 0, a pure sine series; the ckc_k are purely imaginary.
  • Half-wave antisymmetric f(t+T/2)=−f(t)f(t + T/2) = -f(t): only odd harmonics.
python · try it yourself
import numpy as np

N = 1024
t = np.arange(N) / N
tc = np.where(t < 0.5, t, t - 1)            # t centered on [-1/2, 1/2)
shapes = {
    "even (|t|)":          np.abs(tc),
    "odd (t)":             tc,
    "half-wave antisym.":  np.sign(np.sin(2 * np.pi * t + 0.3)) * np.abs(np.sin(2 * np.pi * t)) ** 0.5,
}
for name, f in shapes.items():
    c = np.fft.fft(f)[:7] / N
    print(f"{name:20s} max|Re c_k| (k>0) = {np.max(np.abs(c.real[1:])):.3f}  max|Im c_k| = {np.max(np.abs(c.imag)):.3f}"
          f"  |c_2|,|c_4| = {abs(c[2]):.1e}, {abs(c[4]):.1e}")
even (|t|)           max|Re c_k| (k>0) = 0.101  max|Im c_k| = 0.000  |c_2|,|c_4| = 0.0e+00, 0.0e+00
odd (t)              max|Re c_k| (k>0) = 0.000  max|Im c_k| = 0.159  |c_2|,|c_4| = 8.0e-02, 4.0e-02
half-wave antisym.   max|Re c_k| (k>0) = 0.067  max|Im c_k| = 0.544  |c_2|,|c_4| = 1.1e-11, 1.1e-11

The even function has (numerically) no imaginary parts, the odd one has no real parts beyond tiny sampling effects, and the half-wave antisymmetric one has no even harmonics.

In software

  • Audio spectrum displays show AkA_k in decibels; phase is usually hidden because the ear is mostly insensitive to it.
  • Power engineers report harmonic distortion of the 50/60 Hz mains as the ratio of A22+A32+⋯\sqrt{A_2^2 + A_3^2 + \cdots} to A1A_1 (THD).

Exercises

Exercise 1: Convert

A real signal has c2=1−ic_2 = 1 - i. Write the corresponding real term.

Answer

2cos⁡(2ω0t)+2sin⁡(2ω0t)2\cos(2\omega_0 t) + 2\sin(2\omega_0 t), that is 22cos⁡(2ω0t−π/4)2\sqrt{2}\cos(2\omega_0 t - \pi/4).

Solution

a2=2⋅1=2a_2 = 2 \cdot 1 = 2, b2=−2⋅(−1)=2b_2 = -2 \cdot (-1) = 2. In amplitude-phase form A2=2∣1−i∣=22A_2 = 2\lvert 1 - i \rvert = 2\sqrt{2} and φ2=arg⁡(1−i)=−π/4\varphi_2 = \arg(1 - i) = -\pi/4.

Exercise 2: Predict the zeros

Which coefficients vanish for the triangle wave f(t)=∣t∣f(t) = \lvert t \rvert on [−1/2,1/2)[-1/2, 1/2)?

Answer

All bkb_k, and all aka_k with even k≥2k \ge 2.

Solution

∣t∣\lvert t \rvert is even, so the bkb_k vanish. Subtracting its mean 1/41/4 leaves a half-wave antisymmetric function, so the even harmonics vanish as well. The remaining ak=−2/(π2k2)a_k = -2/(\pi^2 k^2) for odd kk.

Exercise 3: Check the triangle coefficients (code)

Verify ak=−2/(π2k2)a_k = -2/(\pi^2 k^2) for k=1,3,5k = 1, 3, 5.

Answer

a1≈−0.2026a_1 \approx -0.2026, a3≈−0.0225a_3 \approx -0.0225, a5≈−0.0081a_5 \approx -0.0081.

Solution
python · try it yourself
import numpy as np
N = 100000
t = np.arange(N) / N
tc = np.where(t < 0.5, t, t - 1)
f = np.abs(tc)
c = np.fft.fft(f) / N
for k in (1, 3, 5):
    print(k, round(2 * c[k].real, 4), round(-2 / (np.pi ** 2 * k ** 2), 4))
1 -0.2026 -0.2026
3 -0.0225 -0.0225
5 -0.0081 -0.0081

Test yourself

For a real signal, the amplitude of harmonic kk in the cosine-with-phase form is…

  1. ∣ck∣\lvert c_k \rvert
  2. 2∣ck∣2\lvert c_k \rvert
  3. ck2c_k^2
  4. Re⁡ck\operatorname{Re} c_k

An even real function has a Fourier series with…

  1. only sines
  2. only cosines (and a constant)
  3. only odd harmonics
  4. no constant term

If f(t+T/2)=−f(t)f(t + T/2) = -f(t), which harmonics are present?

  1. only even
  2. only odd
  3. all
  4. none