Vector Sum and Gibbs phenomena

Thread Starter

WarrenR

Joined Mar 19, 2018
5
It seems to me, and I'm looking for where I might have flawed thinking, that 2 sine waves, separated by 120
degrees [this has to do with 3 phase power] and summed [like when converting from 'Y' to 'Delta'] produce a
sine wave with sqrt(3) times the amplitude of either of it's contituent parts, but when doing the same for pulses
the resultant is twice as large as either constituent part. It seems the harmonics traveling with the pulse [as
in Gibbbs phenomena] add 15% to the amplitude of the resultant over what it would be with just sine waves.

Am I understanding this correctly? To check this I made an 'R' file I've attached below. I ran out of a line
to put the program on before I got to add in all the harmonics I was interested in, but the results seem to
follow unless I'm doing something wrong.

% 'R' program start
par(mfrow = c(2, 3))
curve(sin(x), from = 0, to = 7, n = 1001)
curve(sin(x-(2*pi/3)), from = 0, to = 7, n = 1001)
curve(sin(x) - sin(x-(2*pi/3)), from = 0, to = 7, n = 1001)
curve(1.1547*(sin(x)+sin(3*x)/3), from = 0, to = 7, n = 1001)
curve(1.1547*(sin(x-(2*pi/3))+sin(3*(x-(2*pi/3)))/3), from = 0, to = 7, n = 1001)
curve(1.1547*(sin(x)+sin(3*x)/3-(sin(x-(2*pi/3))+sin(3*(x-(2*pi/3)))/3)), from = 0, to = 7, n = 1001)
par(mfrow = c(1, 1))
% 'R' program end

Thanks much for checking my work

WarrenR
 

MrAl

Joined Jun 17, 2014
13,703
It seems to me, and I'm looking for where I might have flawed thinking, that 2 sine waves, separated by 120
degrees [this has to do with 3 phase power] and summed [like when converting from 'Y' to 'Delta'] produce a
sine wave with sqrt(3) times the amplitude of either of it's contituent parts, but when doing the same for pulses
the resultant is twice as large as either constituent part. It seems the harmonics traveling with the pulse [as
in Gibbbs phenomena] add 15% to the amplitude of the resultant over what it would be with just sine waves.

Am I understanding this correctly? To check this I made an 'R' file I've attached below. I ran out of a line
to put the program on before I got to add in all the harmonics I was interested in, but the results seem to
follow unless I'm doing something wrong.

% 'R' program start
par(mfrow = c(2, 3))
curve(sin(x), from = 0, to = 7, n = 1001)
curve(sin(x-(2*pi/3)), from = 0, to = 7, n = 1001)
curve(sin(x) - sin(x-(2*pi/3)), from = 0, to = 7, n = 1001)
curve(1.1547*(sin(x)+sin(3*x)/3), from = 0, to = 7, n = 1001)
curve(1.1547*(sin(x-(2*pi/3))+sin(3*(x-(2*pi/3)))/3), from = 0, to = 7, n = 1001)
curve(1.1547*(sin(x)+sin(3*x)/3-(sin(x-(2*pi/3))+sin(3*(x-(2*pi/3)))/3)), from = 0, to = 7, n = 1001)
par(mfrow = c(1, 1))
% 'R' program end

Thanks much for checking my work

WarrenR

Hello,

A quick look tells me that you are only approximating up to the 3rd harmonic. That is like trying to replace a 27 step winding staircase with just 2 steps. Gibbs will show up no matter what you do, but the width decreases as you go up in harmonics. Try going up to the 27th and see what you get, or even the 11th, and track the resutls as you increase and see how much better it gets.
There's a calculation formula for Gibbs but i'd have to look it up.
 

Thread Starter

WarrenR

Joined Mar 19, 2018
5
Hello,

A quick look tells me that you are only approximating up to the 3rd harmonic. That is like trying to replace a 27 step winding staircase with just 2 steps. Gibbs will show up no matter what you do, but the width decreases as you go up in harmonics. Try going up to the 27th and see what you get, or even the 11th, and track the resutls as you increase and see how much better it gets.
There's a calculation formula for Gibbs but i'd have to look it up.
MrAI -

I agree it should be taken to a higher degree than I've taken it, but I only had so much space
per line of 'R' text before the line just ENDS. After that, nothing can be entered so I have to
truncate how far it can reasonably be taken. It's something like ASM in that sometimes you
just have to approximate. Your answer was that I should use more of the terms in the Fourier
series, but I've only got limited resources and was hoping someone out there had access
to a version of 'R' that would get those terms and you asked me to use more terms. If I had
access to something that would allow me to do that, I would. Do you have access to that
something?

Alternatively I can just build a digital simulator and put pulses at the 120 degree angles in
there and O'scope the result. I would have done that, but the device I built is at my sister's
place in a state that's about 1500 miles from where I am right now so I can't just O'scope
it immediately like I'd like to do and was hoping a theoretical answer would do.

If you've got the means to simulated it to a large number of terms, please do so and tell
me what result you get, else I'll just have to wait for the gizmo I built to arrive in the mail.

Thanks anyway,
 

MrAl

Joined Jun 17, 2014
13,703
Hello again,

I guess you are using a function called "curve", so why not just add more turns? What is stopping you from doing that?

You can use a circuit simulator, then use sine sources, one for each harmonic, and add them.
LT Spice is free.
 

mlv

Joined Nov 6, 2017
17
Apologies, but I don't know/use R, so I instead wrote a simple Octave (Matlab) script to illustrate the points here

To set the stage, Figure 1 shows two sinusoids offset by 1/3 cycle and their delta. The peak is sqrt(3).

If I understand your question correctly, the delta between two square waves offset by 1/3 of a cycle would simply give a peak that is 2 simply due to the difference between them when one is +1 and the other is -1. This is without any Gibbs considerations. See Figure 2.

In Figure 3, I show the plot of a synthesized square wave using up to the Mth harmonic (127 in this case). Gibbs phenomenon results in an overshoot of ~2*0.0895. As M gets large, the synthesized square wave approaches ideal in an L2 sense but still has an overshoot whose energy vanishes as the overshoot pulse width tends to zero as M goes to infinity. In reality, an analog signal will be bandlimited and the observation of it is bandlimited (probes, scope trace, sampling, etc), so we expect to always see such an overshoot.

Finally, if we have two such synthesized square waves with Gibbs overshoots that are offset by 1/3 period and differenced, we expect to see a peak value of 2+2*0.0895. See Figure 4.

I'll attach the figures and paste the matlab/octave code below. The output of the script is:
>> delta_and_harmonics
fig1max = 1.7321
fig2max = 2
fig3max = 1.1790
fig4max = 2.1762

Cheers,
M.

---------------------------octave code-----------------------------
% set time range to give 4 cycles with resolution of 1/1000
x = 0:0.001:8*pi;

figure(1);hold off
% For figure 1, we plot a sinusoid at 0 and 120 degrees offset and the
% difference. Here, the max value should be sqrt(3)
plot(x/2/pi,sin(x),'b--')
hold on
plot(x/2/pi,sin(x+2*pi/3),'r--')
plot(x/2/pi,sin(x+2*pi/3)-sin(x),'k')
fig1max = max(sin(x+2*pi/3)-sin(x))

figure(2);hold off
% For figure 2, we plot a square wave and a delayed square wave (again 120 deg)
% The max value in this case should be 2
plot(x/2/pi,sign(sin(x)),'b--')
hold on
plot(x/2/pi,sign(sin(x+2*pi/3)),'r--')
plot(x/2/pi,sign(sin(x+2*pi/3)) - sign(sin(x)),'k')
fig2max = max(sign(sin(x+2*pi/3)) - sign(sin(x)))

figure(3);hold off
% For figure 3, we demonstrate Fourier Series and Gibbs. The FS coefficients
% for a square wave are (4/pi)*(1/p) for p odd, 0 for p even. The overshoot
% due to Gibbs phenomenon approaches 1+2*0.0895 assuming sufficiently fine
% resolution in x
M = 127; % add odd harmonics up to the Mth harmonic
p = 1:2:M;
Y = ((1 ./p)'*ones(size(x))).*sin(p'*x);
y = 4/pi*sum(Y);
plot(x/2/pi,y)
fig3max = max(y)

figure(4);hold off
% For figure 4, we plot the "square" waves from FS synthesis at 0 and 120
% degree offsets and the delta. The max value here should be (1+0.0895)*2
Y_120deg = ((1 ./p)'*ones(size(x))).*sin(p'*(x+2*pi/3));
y_120deg = 4/pi*sum(Y_120deg);
plot(x/2/pi,y,'b--')
hold on
plot(x/2/pi,y_120deg,'r--')
plot(x/2/pi,y_120deg-y,'k');
fig4max = max(y_120deg-y)
 

Attachments

Thread Starter

WarrenR

Joined Mar 19, 2018
5
Apologies, but I don't know/use R, so I instead wrote a simple Octave (Matlab) script to illustrate the points here

To set the stage, Figure 1 shows two sinusoids offset by 1/3 cycle and their delta. The peak is sqrt(3).

If I understand your question correctly, the delta between two square waves offset by 1/3 of a cycle would simply give a peak that is 2 simply due to the difference between them when one is +1 and the other is -1. This is without any Gibbs considerations. See Figure 2.

In Figure 3, I show the plot of a synthesized square wave using up to the Mth harmonic (127 in this case). Gibbs phenomenon results in an overshoot of ~2*0.0895. As M gets large, the synthesized square wave approaches ideal in an L2 sense but still has an overshoot whose energy vanishes as the overshoot pulse width tends to zero as M goes to infinity. In reality, an analog signal will be bandlimited and the observation of it is bandlimited (probes, scope trace, sampling, etc), so we expect to always see such an overshoot.

Finally, if we have two such synthesized square waves with Gibbs overshoots that are offset by 1/3 period and differenced, we expect to see a peak value of 2+2*0.0895. See Figure 4.

I'll attach the figures and paste the matlab/octave code below. The output of the script is:
>> delta_and_harmonics
fig1max = 1.7321
fig2max = 2
fig3max = 1.1790
fig4max = 2.1762

Cheers,
M.

---------------------------octave code-----------------------------
% set time range to give 4 cycles with resolution of 1/1000
x = 0:0.001:8*pi;

figure(1);hold off
% For figure 1, we plot a sinusoid at 0 and 120 degrees offset and the
% difference. Here, the max value should be sqrt(3)
plot(x/2/pi,sin(x),'b--')
hold on
plot(x/2/pi,sin(x+2*pi/3),'r--')
plot(x/2/pi,sin(x+2*pi/3)-sin(x),'k')
fig1max = max(sin(x+2*pi/3)-sin(x))

figure(2);hold off
% For figure 2, we plot a square wave and a delayed square wave (again 120 deg)
% The max value in this case should be 2
plot(x/2/pi,sign(sin(x)),'b--')
hold on
plot(x/2/pi,sign(sin(x+2*pi/3)),'r--')
plot(x/2/pi,sign(sin(x+2*pi/3)) - sign(sin(x)),'k')
fig2max = max(sign(sin(x+2*pi/3)) - sign(sin(x)))

figure(3);hold off
% For figure 3, we demonstrate Fourier Series and Gibbs. The FS coefficients
% for a square wave are (4/pi)*(1/p) for p odd, 0 for p even. The overshoot
% due to Gibbs phenomenon approaches 1+2*0.0895 assuming sufficiently fine
% resolution in x
M = 127; % add odd harmonics up to the Mth harmonic
p = 1:2:M;
Y = ((1 ./p)'*ones(size(x))).*sin(p'*x);
y = 4/pi*sum(Y);
plot(x/2/pi,y)
fig3max = max(y)

figure(4);hold off
% For figure 4, we plot the "square" waves from FS synthesis at 0 and 120
% degree offsets and the delta. The max value here should be (1+0.0895)*2
Y_120deg = ((1 ./p)'*ones(size(x))).*sin(p'*(x+2*pi/3));
y_120deg = 4/pi*sum(Y_120deg);
plot(x/2/pi,y,'b--')
hold on
plot(x/2/pi,y_120deg,'r--')
plot(x/2/pi,y_120deg-y,'k');
fig4max = max(y_120deg-y)
 

Thread Starter

WarrenR

Joined Mar 19, 2018
5
Apologies, but I don't know/use R, so I instead wrote a simple Octave (Matlab) script to illustrate the points here

To set the stage, Figure 1 shows two sinusoids offset by 1/3 cycle and their delta. The peak is sqrt(3).

If I understand your question correctly, the delta between two square waves offset by 1/3 of a cycle would simply give a peak that is 2 simply due to the difference between them when one is +1 and the other is -1. This is without any Gibbs considerations. See Figure 2.

In Figure 3, I show the plot of a synthesized square wave using up to the Mth harmonic (127 in this case). Gibbs phenomenon results in an overshoot of ~2*0.0895. As M gets large, the synthesized square wave approaches ideal in an L2 sense but still has an overshoot whose energy vanishes as the overshoot pulse width tends to zero as M goes to infinity. In reality, an analog signal will be bandlimited and the observation of it is bandlimited (probes, scope trace, sampling, etc), so we expect to always see such an overshoot.

Finally, if we have two such synthesized square waves with Gibbs overshoots that are offset by 1/3 period and differenced, we expect to see a peak value of 2+2*0.0895. See Figure 4.

I'll attach the figures and paste the matlab/octave code below. The output of the script is:
>> delta_and_harmonics
fig1max = 1.7321
fig2max = 2
fig3max = 1.1790
fig4max = 2.1762

Cheers,
M.

---------------------------octave code-----------------------------
% set time range to give 4 cycles with resolution of 1/1000
x = 0:0.001:8*pi;

figure(1);hold off
% For figure 1, we plot a sinusoid at 0 and 120 degrees offset and the
% difference. Here, the max value should be sqrt(3)
plot(x/2/pi,sin(x),'b--')
hold on
plot(x/2/pi,sin(x+2*pi/3),'r--')
plot(x/2/pi,sin(x+2*pi/3)-sin(x),'k')
fig1max = max(sin(x+2*pi/3)-sin(x))

figure(2);hold off
% For figure 2, we plot a square wave and a delayed square wave (again 120 deg)
% The max value in this case should be 2
plot(x/2/pi,sign(sin(x)),'b--')
hold on
plot(x/2/pi,sign(sin(x+2*pi/3)),'r--')
plot(x/2/pi,sign(sin(x+2*pi/3)) - sign(sin(x)),'k')
fig2max = max(sign(sin(x+2*pi/3)) - sign(sin(x)))

figure(3);hold off
% For figure 3, we demonstrate Fourier Series and Gibbs. The FS coefficients
% for a square wave are (4/pi)*(1/p) for p odd, 0 for p even. The overshoot
% due to Gibbs phenomenon approaches 1+2*0.0895 assuming sufficiently fine
% resolution in x
M = 127; % add odd harmonics up to the Mth harmonic
p = 1:2:M;
Y = ((1 ./p)'*ones(size(x))).*sin(p'*x);
y = 4/pi*sum(Y);
plot(x/2/pi,y)
fig3max = max(y)

figure(4);hold off
% For figure 4, we plot the "square" waves from FS synthesis at 0 and 120
% degree offsets and the delta. The max value here should be (1+0.0895)*2
Y_120deg = ((1 ./p)'*ones(size(x))).*sin(p'*(x+2*pi/3));
y_120deg = 4/pi*sum(Y_120deg);
plot(x/2/pi,y,'b--')
hold on
plot(x/2/pi,y_120deg,'r--')
plot(x/2/pi,y_120deg-y,'k');
fig4max = max(y_120deg-y)
Apologies, but I don't know/use R, so I instead wrote a simple Octave (Matlab) script to illustrate the points here

To set the stage, Figure 1 shows two sinusoids offset by 1/3 cycle and their delta. The peak is sqrt(3).

If I understand your question correctly, the delta between two square waves offset by 1/3 of a cycle would simply give a peak that is 2 simply due to the difference between them when one is +1 and the other is -1. This is without any Gibbs considerations. See Figure 2.

In Figure 3, I show the plot of a synthesized square wave using up to the Mth harmonic (127 in this case). Gibbs phenomenon results in an overshoot of ~2*0.0895. As M gets large, the synthesized square wave approaches ideal in an L2 sense but still has an overshoot whose energy vanishes as the overshoot pulse width tends to zero as M goes to infinity. In reality, an analog signal will be bandlimited and the observation of it is bandlimited (probes, scope trace, sampling, etc), so we expect to always see such an overshoot.

Finally, if we have two such synthesized square waves with Gibbs overshoots that are offset by 1/3 period and differenced, we expect to see a peak value of 2+2*0.0895. See Figure 4.

I'll attach the figures and paste the matlab/octave code below. The output of the script is:
>> delta_and_harmonics
fig1max = 1.7321
fig2max = 2
fig3max = 1.1790
fig4max = 2.1762

Cheers,
M.

---------------------------octave code-----------------------------
% set time range to give 4 cycles with resolution of 1/1000
x = 0:0.001:8*pi;

figure(1);hold off
% For figure 1, we plot a sinusoid at 0 and 120 degrees offset and the
% difference. Here, the max value should be sqrt(3)
plot(x/2/pi,sin(x),'b--')
hold on
plot(x/2/pi,sin(x+2*pi/3),'r--')
plot(x/2/pi,sin(x+2*pi/3)-sin(x),'k')
fig1max = max(sin(x+2*pi/3)-sin(x))

figure(2);hold off
% For figure 2, we plot a square wave and a delayed square wave (again 120 deg)
% The max value in this case should be 2
plot(x/2/pi,sign(sin(x)),'b--')
hold on
plot(x/2/pi,sign(sin(x+2*pi/3)),'r--')
plot(x/2/pi,sign(sin(x+2*pi/3)) - sign(sin(x)),'k')
fig2max = max(sign(sin(x+2*pi/3)) - sign(sin(x)))

figure(3);hold off
% For figure 3, we demonstrate Fourier Series and Gibbs. The FS coefficients
% for a square wave are (4/pi)*(1/p) for p odd, 0 for p even. The overshoot
% due to Gibbs phenomenon approaches 1+2*0.0895 assuming sufficiently fine
% resolution in x
M = 127; % add odd harmonics up to the Mth harmonic
p = 1:2:M;
Y = ((1 ./p)'*ones(size(x))).*sin(p'*x);
y = 4/pi*sum(Y);
plot(x/2/pi,y)
fig3max = max(y)

figure(4);hold off
% For figure 4, we plot the "square" waves from FS synthesis at 0 and 120
% degree offsets and the delta. The max value here should be (1+0.0895)*2
Y_120deg = ((1 ./p)'*ones(size(x))).*sin(p'*(x+2*pi/3));
y_120deg = 4/pi*sum(Y_120deg);
plot(x/2/pi,y,'b--')
hold on
plot(x/2/pi,y_120deg,'r--')
plot(x/2/pi,y_120deg-y,'k');
fig4max = max(y_120deg-y)
 

Thread Starter

WarrenR

Joined Mar 19, 2018
5
Ml AI -

Thanks for trying

Mr mlv -

Your reply is really more like what I was hoping for. I might even use your graphics for other things, but MAN ! that was tood
and REALLY along the line of what I was hoping for. Outside of just grabbing your JPGs I'll be looking into Octave and confirming
your code, but man I'm really happy with that response, THANK YOU !!

WarrenR
 
Top