Why the plot result of summing 2 same frequency SinOsc with phase reversed is not just zeros?


Please check case 2 code and graph below.

I wonder why the values are not just zeros.

Would it be a Plotter’s plot resolution related phenomenon?


// case 1 - I think this would be right result
x = Signal.sineFill(s.sampleRate, [1]); //cyan
y = Signal.sineFill(s.sampleRate, [1], [pi]); //magenta
z = x + y; // black

var data = [x,y,z];
var plotter = Plotter("plotter", Rect(0, 0, 1024, 400));
plotter.plotMode = \points;
	\plotColor, [Color.cyan, Color.magenta, Color.black]

// case 2 - The values are almost zero.. But why not just zero?
	var env = Env([0, 0.1, 0], [1.0, 0.1]);
	SinOsc.ar(1, 0) + SinOsc.ar(1, pi)

The range of the second graph is -0.0000002 to 0.0000002.

These are not large numbers.

The only time you will ever get pure mathematical precision from floating point numbers is when all numbers are rational and the denominators are only powers of two. Otherwise, rounding error should be expected.

Also, pi cannot possibly be exact as it’s an irrational number (infinite digits), and floating point precision is finite. sin(pi) is not exactly 0 in floating point – and your pi-offset sinewave is thereby not an exact negative of the 0-phase wave.




There was an obvious reason that makes such a result.

Thank you for your kind explanation :+1: :+1:

This sounds like 4’33 for computer, somehow.


@Dindoleon haha - that put a smile on my face:)

1 Like

very fun to abuse! kind of like digital lowercase music…

(//floating point errors
{ var pink;
	pink = PinkNoise.ar().range(0.08, 0.12)!2;
	0.5*LeakDC.ar(Median.ar(2, Limiter.ar(99999999*(SawDPW.ar(pink, 0) + SawDPW.ar(pink, pi)), 0.9)))}.play;
{ var pink;
	pink = PinkNoise.ar().range(0.0999/3, 0.1001/3)!2;
	0.5*LeakDC.ar(Median.ar(5, Limiter.ar(99999999*(SawDPW.ar(pink, 0) + SawDPW.ar(pink, pi)), 0.9)))}.play;
{var pink;
	pink = PinkNoise.ar().range(0.00999, 0.01001)!2;
	Limiter.ar(999999*LeakDC.ar(SawDPW.ar(pink, 0+(pi/2)) + SawDPW.ar(pink, pi+(pi/2))), 0.1)))}.play;
{0.5*Median.ar(30, Limiter.ar(99999999*LeakDC.ar((SinOsc.ar(0.005, 0) + SinOsc.ar(0.005, pi)), 0.05)))!2}.play;
{0.5*SVF.ar((Median.ar(10, Limiter.ar(999999*LeakDC.ar(LFPulse.ar(0.5, 0) + LFPulse.ar(0.5, pi)), 0.6))), 800)!2}.play;

It won’t let me edit, but I initially misunderstood what’s actually going on in my reply. Only the sine voice should cancel, and that truly is floating point errors as far as I can tell. The others are results of running oscillators really slow and removing the dc offset, so only artifacts remain