# How to uniquely identify phase difference between harmonics?

Let's say I have a multi-frequencies signal of 440Hz and 880Hz, slightly out of phase.

I can take a chunk of the signal and calculate phase difference of the two frequencies with FFT bins. However, since frequencies are different, the phase difference will differ depending upon where I took the chunks, despite they are taken from the same signal.

I wonder whether there is a way to uniquely identify phase difference between harmonics, with arbitrary chunks? (so that I can identify harmonic signals.)

• Phase relative to what? 1970 Midnight GMT? Some start time when you flipped a switch, or other event? Some fundamental periodicity or pitch interval zero crossing? Or ? – hotpaw2 Dec 14 '18 at 20:11
• My question is how to come up with a definition of "phase difference" representing uniquely the same signal from which arbitrary chunks are taken. I think @robert bristow-johnson has given a good answer. – Wei Lin Dec 23 '18 at 2:18

i am assuming this is a periodic (or quasi-periodic) function. also seems like the signal is a musical tone. periodic signals have a period, $$P$$, and the reciprocal of that period is the fundamental frequency; $$f_0 \triangleq \frac{1}{P}$$

or, as angular frequency; $$\omega_0 = 2 \pi f_0 = \frac{2 \pi}{P}$$ .

the periodic signal is $$x(t)$$ where

$$x(t+P) = x(t) \qquad \forall t \in \mathbb{R}$$

it can be represented as a Fourier series

\begin{align} x(t) \ &= \ a_0 \ + \ 2 \sum_{k=1}^{\infty} a_k \cos(k \omega_0 t) - b_k \sin(k \omega_0 t) \\ &= \ a_0 \ + \ 2 \sum_{k=1}^{\infty} a_k \frac{e^{j k \omega_0 t} + e^{-j k \omega_0 t}}{2} \ - \ b_k \frac{e^{j k \omega_0 t} - e^{-j k \omega_0 t}}{2j} \\ &= \ a_0 \ + \ \sum_{k=1}^{\infty} (a_k + jb_k) e^{j k \omega_0 t} \ + \ (a_k - jb_k) e^{-j k \omega_0 t} \\ &= \ \sum_{k=-\infty}^{\infty} c_k \ e^{j k \omega_0 t} \\ \end{align}

where

$$c_k = \begin{cases} a_{-k} - jb_{-k}, & \quad \text{for } k < 0 \\ a_0, & \quad\quad k = 0 \\ a_k + jb_k, & \quad\quad k > 0 \end{cases}$$

and, going in the other direction,

$$\begin{array}{lcl} a_0 & = & c_0 \\ a_k & = & \Re\{c_k \} \quad\quad \text{for } k>0\\ b_k & = & \Im\{c_k \} \quad\quad\quad k>0 \end{array}$$

note that for real $$a_k$$ and real $$b_k$$, then

$$c_{-k} = c_k^* = \text{"complex conjugate of } c_k \text{ "}$$

it's easier to get $$c_k$$ from $$x(t)$$ and then compute $$a_k$$ and $$b_k$$ from the $$c_k$$ which is:

$$c_k = \tfrac{1}{P} \int\limits_{t_0}^{t_0+P} x(t) \, e^{-j k \omega_0 t} \, \mathrm{d}t \qquad \text{for any } t_0 \in \mathbb{R}$$

you can uniquely define the phase of overtones (or harmonics apart from the fundamental) with reference to the fundamental if there is any energy at the fundamental. (it is not always the case that a periodic signal has non-zero energy in its own fundamental frequency.)

now it's also true that:

\begin{align} x(t) \ &= \ \sum_{k=-\infty}^{\infty} c_k \ e^{j k \omega_0 t} \\ &= \ a_0 \ + \ 2 \sum_{k=1}^{\infty} a_k \cos(k \omega_0 t) - b_k \sin(k \omega_0 t) \\ &= \ a_0 \ + \sum_{k=1}^{\infty} r_k \cos(k \omega_0 t + \phi_k) \\ \end{align}

where

\begin{align} r_k &= 2 \big| a_k + j\,b_k \big| \\ &= 2 \sqrt{a_k^2 + b_k^2} \\ \\ \phi_k &= \arg \{a_k + j\,b_k \} \\ &= \operatorname{atan2}(b_k, a_k) \\ \end{align}

now, the phases of all of the harmonics are relative to some time $$t=0$$, but that reference time can be defined in such a way that the phase of the fundamental is zero.

let

\begin{align} \tilde{x}(t) \ &\triangleq \ x(t - \tfrac{\phi_1}{\omega_0}) \\ &= \ a_0 \ + \sum_{k=1}^{\infty} r_k \cos \big(k \omega_0 (t - \tfrac{\phi_1}{\omega_0}) + \phi_k \big) \\ &= \ a_0 \ + \sum_{k=1}^{\infty} r_k \cos(k \omega_0 t + \phi_k - k\phi_1) \\ &= \ a_0 \ + \sum_{k=1}^{\infty} r_k \cos(k \omega_0 t + \tilde{\phi}_k) \\ \end{align}

where $$\tilde{\phi}_k \triangleq \phi_k - k\phi_1$$.

you can see that $$\tilde{\phi}_1 = 0$$, that we defined our origin of $$t$$ so that the phase of the fundamental (when $$k=1$$) is 0. then all of the other harmonics have their phases referenced to that "first harmonic" or fundamental. the only problem is that the amplitude of that fundamental must not be zero. $$r_1 \ne 0$$ so that the reference phase, $$\phi_1 = \arg \{a_1 + j\,b_1 \}$$, can be determined.