# Phase difference calculation

I have the frequency of two waves $$A$$ and $$B$$ and I want to calculate the phase difference of $$A$$ relative to $$B$$ in degrees. I also have the phase difference in terms of time $$t$$ i.e. the time difference between the starting point of the two waves. Then, my phase difference formula is going to be:

$$\text{phase difference} = t f \cdot (360^{\circ})$$

My question is should $$f$$ be the frequency of $$A$$ or $$B \$$? I want the phase difference of $$A$$ $$\bf{relative}$$ to $$B$$.

• Usually you have phase differences only for waves of the same frequency. for waves with different frequencies it makes no sense since at any place it changes over time, and at any time it changes over space. Sep 21, 2022 at 17:33
• Do you have a wave equation for A and B? If so, it would be very helpful if you would post them. Sep 21, 2022 at 19:37
• @trula thanks for clarifying.
– Meow
Sep 21, 2022 at 20:20
• @David, no this was more of a general question that popped in my head when I was dealing with measurements from my oscilloscope and I realized I hadn't calculated the phases from the machine before printing them out.
– Meow
Sep 21, 2022 at 20:20

As a matter of calculation, if you have a sampled pair of waveforms, you can use a discreet FFT to generate sine (sometimes referred to as 'imaginary') and cosine ('real') frequency components. The phase difference of each frequency component is $$atan{(IM(A(f)/RE(A(f))} - atan{(IM(B(f)/RE(B(f))}$$ and the best-fit value for the phase difference of the signals is the weighted average result with weight $${||A(f)|| \times ||B(f)||} \over {|| A(f)|| + ||B(f)||}$$

where the double verticals indicate squared absolute value.

If either OR both of the samples has a zero amplitude, phase difference is indeterminate; low ampltude indicates that the frequency of interest is not present in the (off-frequency) sample being considered. Weighting reflects those principles...

All the usual caveats apply, the discrete Fourier transform requires sampling many periods, and window application, as appropriate.

The "phase" is just the name we give to the argument of the sinusoidal wave function.

For example if one wave is described by: $$f(x,t) = A_1\sin(k_1 x - \omega_1 t + \delta_1)\tag 1$$ the "phase" of this wave is: $$\eta_1 = k_1 x - \omega_1 t + \delta_1$$

For example if another wave is described by: $$g(x,t) = A_2\sin(k_2 x - \omega_2 t + \delta_2) \tag 2$$ the "phase" of this wave is: $$\eta_2 = k_2 x - \omega_2 t + \delta_2$$

The "phase difference" at the same point in space and time between the two above-mentioned waves of this example is: $$\Delta\eta_{1,2} = (k_2 - k_1)x + (\omega_2 - \omega_1)t + (\delta_2 - \delta_1)$$

The phase difference doesn't have to refer to different wave forms. It could instead refer to a single wave form, but at different points in space, or for different path lengths travelled by the wave.

For example, if the wave $$f(x,t)$$ of Eq. (1) is split (e.g., with a prism) and one component of the wave travels along a path of length $$L$$ and another component of the wave travels along a path of length $$\ell$$ and then the waves recombine, we are interested in the phase difference: $$\Delta \eta = k_1(L - \ell)$$