• WANTED: Happy members who like to discuss audio and other topics related to our interest. Desire to learn and share knowledge of science required as is 20 years of participation in forums (not all true). There are daily reviews of audio hardware and expert members to help answer your questions. Click here to have your audio equipment measured for free!

Analytical Analysis - Polarity vs Phase

OP
R

René - Acculution.com

Active Member
Technical Expert
Joined
May 1, 2021
Messages
201
Likes
699
This is an cases of estimation bias.
If you search for Creationism vs. Evolution. you will also get the impression there is a controversy.


Don't think you can educate them or that they want to be educated.
If they would have the knowledge/educate to understand your explanation they would not argue.
True, true, you are right. It is quite the connundrum though... It is extremely trivial, and yet it seems very difficult for people to drop the notion that a PHASOR phase equates to a time delay, which is does not.

- A polarity switch equates to a sign inversion.
- When all we have to characterize a signal or system completely are magnitude and phase phasors per frequency, the sign change has to go into the phase somehow, as the magnitude is unaffected by the sign.
- Whether looking at truncated sines, triangular, or whatever other signals, all of the Fourier components that make up these signals will have their phasor phase shifted by 180 degree when going through a system that flips polarity, and the output signal will be the "upside-down" version of the original signal.
- There is no delay associated with this flat phase characteristics (why would there be?)
- You cannot time delay your way to a polarity (so why try).
 
Last edited:
OP
R

René - Acculution.com

Active Member
Technical Expert
Joined
May 1, 2021
Messages
201
Likes
699
TLDR: This is like saying unplugging the wires is a 90 degree phase shift at all frequencies.

This explanation was bothering me, even though it is mathematically correct, but it took me a while to figure out why. As @mansr has pointed out in this thread and others, F{x(A * t)} = A x F{x(t)}. If the constant A is -1 then this represents a polarity inversion and shows it is equivalent to a 180 degree phase shift at all frequencies. But what exactly is this "phase shift across all frequencies", ie. what does this do for phases other than the special case of 180 degrees? This can be seen by simply multiplying x(t) by the complex number of magnitude 1 and phase we wish to shift by; then, as speakers can only play real signals, taking the real component of the result.

So, let us look at Re(A * x(t)) for values of A with magnitude 1 and various phases. Since x(t) is real, Re(A * x(t)) = Re(A) * x(t), so it's just Re(A) applied as a gain factor, and Re(A) is of course just cos(P) where P is the phase angle of A.
30 degrees: Re(A) = 0.866
45 degrees: Re(A) = 0.707
90 degrees: Re(A) = 0
120 degrees: Re(A) = -0.5
180 degrees: Re(A) = -1

So this "phase shift at all frequencies" we're talking about is just a gain factor of cos(phase), which at 180 degrees happens to be -1. But did you see what happens at 90 degrees? It's 0, ie. unplugged from the source. So saying a polarity inversion is like a 180 degree phase shift at all frequencies, while mathematically correct, is akin to describing disconnecting the source as a "90 degree phase shift at all frequencies".
You just need to look at it in a complex sense. A real system (which a system that flips the polarity/sign inverts) will output a real signal for a real input. One that shift 90 degrees will not. All of this falls directly out the analysis that I have laid out. But I can see that people do not understand the mathematics/signal processing, so I am wondering what it will take to get the message across. I can expand the sheet so that it also looks at other flat phases (90 degree, 80 degrees, whatever) but I think people will get more confused.
 
OP
R

René - Acculution.com

Active Member
Technical Expert
Joined
May 1, 2021
Messages
201
Likes
699
The OP is saying, correctly but in a roundabout way, that a polarity inversion is equivalent to 180° phase shift of each frequency component in the signal. In the complex frequency representation (as obtained by the Fourier transform), this is simply multiplication by -1. From the linear property of the Fourier transform, it trivially follows that this is equivalent to a polarity inversion of the time based representation. There is nothing remotely controversial here.

The above notwithstanding, I still prefer the term polarity inversion when this is the intended meaning. In common usage, the term phase shift is often associated with a time delay, and this can result in minor confusion, as evidenced by your post.
Exactly.
 
OP
R

René - Acculution.com

Active Member
Technical Expert
Joined
May 1, 2021
Messages
201
Likes
699
(bold mine)
That's the important point -- from DC to light or at least within the whole bandwidth of the system under observation.
Another one is it has to be exactly 180 degrees.

Those are very specific constraints that are normally not acheivable in the real world, at least not with any phase-modifying allpass filter in analog systems.
Well, it is easily achievable by flipping the wires or when using for example and op-amp configuration such as multiple-feedback or whatever else that inverts the sign; whatever phase you had before will be flipped an additional 180 degrees.
 
OP
R

René - Acculution.com

Active Member
Technical Expert
Joined
May 1, 2021
Messages
201
Likes
699
View attachment 174877

This is the main issue with this discussion; a lot of misinformation where people confuse a 180 degree phase shift at all frequencies with having a time delay that equates to the FUNDAMENTAL being shifted 180 degrees. The above figure is misleading, as it fails to take into account that this sawtooth has infinitely many (on a discrete spectrum; Fourier SERIES as opposed to Fourier Transform) phasors that all need to be flipped 180 degrees. Once that is realised, you can put this to bed. A time delay as shown in the second plot indicates a LINEAR phase, not a flat phase. This is clearly laid out in the sheet that I made.
 
Last edited:
OP
R

René - Acculution.com

Active Member
Technical Expert
Joined
May 1, 2021
Messages
201
Likes
699
Here are first three components of a sawtooth wave, and with each component shifted 180 degrees. So you can see this is the same as inverted. I'm not sure if the OP is helpful in practical terms though. Usually when people talk about the importance of distinguishing between phase shift and polarity they are referring to using subwoofer settings and such.
View attachment 174891
There is no difference when it comes to subwoofer settings; if all the subwoofer has is a polarity switch, the phase will be 180 degrees switched at all frequencies. If it has a variable phase knob, it depends on the implementation; what one would hope for is that all relevant frequencies are shifted in phase by the amount that the know says, but in reality this might only hold at some frequencies, depending on whether is analog or digital implementation.
 

ebslo

Active Member
Forum Donor
Joined
Jan 27, 2021
Messages
267
Likes
351
You just need to look at it in a complex sense. A real system (which a system that flips the polarity/sign inverts) will output a real signal for a real input. One that shift 90 degrees will not. All of this falls directly out the analysis that I have laid out. But I can see that people do not understand the mathematics/signal processing, so I am wondering what it will take to get the message across. I can expand the sheet so that it also looks at other flat phases (90 degree, 80 degrees, whatever) but I think people will get more confused.
People will get confused because it's confusing. When we apply a "phasor phase" shift to a phasor we get a phase shift, but when we apply it to a real signal the result is not recognizable as a phase shift. It's because real signals have mirror-image frequency components in negative frequency. By Euler's identity, we can write for a real sinusoid:

x(t) = cos(w*t + p) = (e^(j*w*t + p) + e^(-j*w*t - p)) / 2

When we apply the "phasor phase" shift, ie. multiply (in frequency or time domain) by the complex number representing the phase shift, it shifts the negative frequency component's phase such that the real parts of the two components are no longer in phase. The result in no way looks like what people usually think of as a "phase shift".
 
OP
R

René - Acculution.com

Active Member
Technical Expert
Joined
May 1, 2021
Messages
201
Likes
699
Yes. The analysis is based on the phasor model. Note the first line of the wikipedia entry:

So it is based on a model of a sinusoid having no beginning and no end. No surprise that it doesn't hold when we consider real signals with a beginning and an end. That's not to say it's "wrong", just that it's applicability is limited by the model it is based on.
It holds no matter what. Whatever weird signal you can come up with, we can decompose it into fourier transform component phasors, and each of these will be 180 degrees shifted. The transient behavior as well as the steady-state behavior is shown in the attached sheet. Whatever you send in to the "180 degree shift" system will be inverted, both in its transient behavior and its steady state behavior.
 
OP
R

René - Acculution.com

Active Member
Technical Expert
Joined
May 1, 2021
Messages
201
Likes
699
People will get confused because it's confusing. When we apply a "phasor phase" shift to a phasor we get a phase shift, but when we apply it to a real signal the result is not recognizable as a phase shift. It's because real signals have mirror-image frequency components in negative frequency. By Euler's identity, we can write for a real sinusoid:

x(t) = cos(w*t + p) = (e^(j*w*t + p) + e^(-j*w*t - p)) / 2

When we apply the "phasor phase" shift, ie. multiply (in frequency or time domain) by the complex number representing the phase shift, it shifts the negative frequency component's phase such that the real parts of the two components are no longer in phase. The result in no way looks like what people usually think of as a "phase shift".
It is confusing when the concept of phasors is not understood, and yet people argue as if they can just skip this, and visualise things via wrong assumptions. And one added issue is that working with sines, instead of cosines, we have to carry around an extra 90 degrees which further muddies the waters...
 
OP
R

René - Acculution.com

Active Member
Technical Expert
Joined
May 1, 2021
Messages
201
Likes
699
Seems that people overall are on-board with this. Try now and search for this topic on other forums and witness the total confusion...
 

dc655321

Major Contributor
Joined
Mar 4, 2018
Messages
1,564
Likes
2,142
Maybe if you would have a nice animation showing non periodic signal getting disassembled to its sine components. phases shifted and then combined back to the original signal.

See attachment (yes, I know you know this stuff).
I can post link to portion of phase-altered track, if any interest.
 

Attachments

  • asr_polarity_stuff.pdf
    77.8 KB · Views: 58

ebslo

Active Member
Forum Donor
Joined
Jan 27, 2021
Messages
267
Likes
351
Seems that people overall are on-board with this. Try now and search for this topic on other forums and witness the total confusion...
Not on board, I think this is the wrong approach. Let's go back to basics, where phase shift is a time delay of a periodic signal of theta/(2*pi*f) seconds, ex.

x(t) = cos(2 * pi * f * t), or letting omega = 2*pi*f, x(t) = cos(omega * t)
x(t + theta/omega) = cos(omega * t + theta)

This signal extends from -inf < t < inf, but in all other aspects is a real signal, as could be produced by an electronic device and measured by an oscilloscope. It has a single positive frequency component f, and a phase theta which is equivalent to a time shift by identity.

If we take the Fourier transform of the original signal x(t) = cos(omega * t) and shift the phase of each frequency component by theta radians, then take the inverse Fourier transform, we should have our original signal with "all frequency components" phase shifted by theta, ie.

iF{ (cos(theta) + j*sin(theta)) * F{x(t)} }

Which, by linearity of the Fourier transform, is mathematically equivalent to:

(cos(theta) + j*sin(theta)) * x(t)

So let's postulate (wrongly, obviously, but let's run with it) that:

(cos(theta) + j*sin(theta)) * x(t) = x(t + theta/omega)
then (still obviously wrong):
(cos(theta) + j*sin(theta)) * cos(omega * t) = cos(omega * t + theta)

So what happens when theta = pi in the above horribly wrong "equation"? It magically yields a correct equation of:

-1 * cos(omega * t) = cos(omega * t + pi)

Which is true for all t. So integer multiples of 180 degrees really are a special case in the math you are using (at least when applied to real signals). FWIW, I think the issue lies in your application of Hermitian symmetry, which seems only valid for multiples of 180 degrees.

Though all your math is correct for the special case of a 180 degree phase shift, it seems wrong to frame a polarity inversion as some kind of phase shift when the math used to justify it is invalid for arbitrary phase shifts of real signals. I realize your main goal is to debunk the notion that polarity inversion is in any way like a time delay, I just don't think this is a good way to do it.
 

ebslo

Active Member
Forum Donor
Joined
Jan 27, 2021
Messages
267
Likes
351
The following plots were created by taking the fft of a discreet time sinusoidal signal, applying a phase shift in frequency domain, then converting back to time domain. The top plot starts with e^(j * omega * t), whereas the bottom plot starts with cos(omega * t). Note that the bottom plot is what would apply to an actual measured signal as no imaginary component would be present, and it sure doesn't look like phase shifts to me (except at 180 degrees).

Script is attached as text.
phase-shift.png
 

Attachments

  • phase-shift.py.txt
    761 bytes · Views: 28
OP
R

René - Acculution.com

Active Member
Technical Expert
Joined
May 1, 2021
Messages
201
Likes
699
Not on board, I think this is the wrong approach. Let's go back to basics, where phase shift is a time delay of a periodic signal of theta/(2*pi*f) seconds, ex.

x(t) = cos(2 * pi * f * t), or letting omega = 2*pi*f, x(t) = cos(omega * t)
x(t + theta/omega) = cos(omega * t + theta)

This signal extends from -inf < t < inf, but in all other aspects is a real signal, as could be produced by an electronic device and measured by an oscilloscope. It has a single positive frequency component f, and a phase theta which is equivalent to a time shift by identity.

If we take the Fourier transform of the original signal x(t) = cos(omega * t) and shift the phase of each frequency component by theta radians, then take the inverse Fourier transform, we should have our original signal with "all frequency components" phase shifted by theta, ie.

iF{ (cos(theta) + j*sin(theta)) * F{x(t)} }

Which, by linearity of the Fourier transform, is mathematically equivalent to:

(cos(theta) + j*sin(theta)) * x(t)

So let's postulate (wrongly, obviously, but let's run with it) that:

(cos(theta) + j*sin(theta)) * x(t) = x(t + theta/omega)
then (still obviously wrong):
(cos(theta) + j*sin(theta)) * cos(omega * t) = cos(omega * t + theta)

So what happens when theta = pi in the above horribly wrong "equation"? It magically yields a correct equation of:

-1 * cos(omega * t) = cos(omega * t + pi)

Which is true for all t. So integer multiples of 180 degrees really are a special case in the math you are using (at least when applied to real signals). FWIW, I think the issue lies in your application of Hermitian symmetry, which seems only valid for multiples of 180 degrees.

Though all your math is correct for the special case of a 180 degree phase shift, it seems wrong to frame a polarity inversion as some kind of phase shift when the math used to justify it is invalid for arbitrary phase shifts of real signals. I realize your main goal is to debunk the notion that polarity inversion is in any way like a time delay, I just don't think this is a good way to do it.
You say the signal is purely real, but only has a positive frequency. If it is purely real, it has two complex phasors to describe it; one positive and one negative. For a polarity flip, the phase of the phasor(s) at each frequency is changed 180 degrees, and then proper projection must be done onto the real and imaginary axis, to find the resulting signal. Sure, 180 degrees is a 'special case' in that a purely real signal is flipped to another purely real signal, and phase is a more than polarity. But with magnitude and phase being all we have to describe the system, the phase needs to cover the sign inversion. The sheet covers of all of this. I cannot take on any more students than what I already have currently.

And with that, I will not spend any more time on this topic. Next up is probably 'Beaming/radiation pattern', and everyone is also free to suggest other topics. Have a nice weekend! :)
 
Last edited:

ebslo

Active Member
Forum Donor
Joined
Jan 27, 2021
Messages
267
Likes
351
TLDR: I would say: Is polarity reversal time delay? No. Is polarity reversal phase shift? No. What is it then? It's sign inversion.

You say the signal is purely real, but only has a positive frequency. If it is purely real, it has two complex phasors to describe it; one positive and one negative. For a polarity flip, the phase of the phasor(s) at each frequency is changed 180 degrees, and then proper projection must be done onto the real and imaginary axis, to find the resulting signal. Sure, 180 degrees is a 'special case' in that a purely real signal is flipped to another purely real signal, and phase is a more than polarity. But with magnitude and phase being all we have to describe the system, the phase needs to cover the sign inversion. The sheet covers of all of this. I cannot take on any more students than what I already have currently.

And with that, I will not spend any more time on this topic. Next up is probably 'Beaming/radiation pattern', and everyone is also free to suggest other topics. Have a nice weekend! :)
"It has a single positive frequency component" was not supposed to mean "it has a single frequency component which is positive"; I tried to choose my words carefully, but I see how it could still be read that way. Anyway, no need for more on this as we agree on the facts.

However, the assertion that "magnitude and phase being all we have to describe the system" is only true if that's the model we choose. If we describe the system purely in the time domain, where the output is given by convolution of the input with the impulse response, then we can represent polarity reversal directly as sign inversion. Your presentation seems not "what polarity reversal is" but "how sign inversion is represented in the frequency domain".

Anyway, thanks for posting this as I have enjoyed the exercise and opportunity to brush-up on some stuff I've gotten rusty on.
 

ebslo

Active Member
Forum Donor
Joined
Jan 27, 2021
Messages
267
Likes
351
See attachment (yes, I know you know this stuff).
I can post link to portion of phase-altered track, if any interest.
Be careful generating d_90_t. The frequency domain phase shift used to generate dft_90 produces a non-Hermitian function, so it is not correct to apply it to dft which was generated by rfft() instead of fft(). When irfft() is used to get d_90_t, it incorrectly constructs a Hermitian function from its input prior to the transform.
 

dc655321

Major Contributor
Joined
Mar 4, 2018
Messages
1,564
Likes
2,142
Be careful generating d_90_t. The frequency domain phase shift used to generate dft_90 produces a non-Hermitian function, so it is not correct to apply it to dft which was generated by rfft() instead of fft(). When irfft() is used to get d_90_t, it incorrectly constructs a Hermitian function from its input prior to the transform.

Yes, thank you. I had been reflexively using rfft (assumes purely Real, Hermitian).
This is all starting to dredge up memories of time/phase shift and frequency shift/modulation properties of Fourier transforms.
Should probably stop before we have to get into quadrature sampling and how 2*bandwidth is not always necessary ;)
 

Attachments

  • asr_polarity_stuff (1).pdf
    86.7 KB · Views: 35
Top Bottom