# sine wave question

robert bristow-johnson pbjrbj at viconet.com
Tue Apr 21 23:30:34 EDT 1998

```>Matt Green wrote:
>>I'm trying to add two sets of spectral data together.  Is there a simple
>>way of computing the spectral effects of combining a sine wave at a
>>particular frequency/phase/amplitude with another sine wave, same
>>frequency but different amplitude/phase.

...
>
>I think this should work:
>
>Given two sinusoids A1*cos(w*t + ph1) and A2*cos(w*t + ph2)
>
>their sum can be written    A12*cos(w*t + ph12)
>
>where A12 = sqrt( A1^2 + A2^2 + 2*A1*A2*cos(ph1-ph2) )
>
>and p12 = atan((A1*sin(ph1) + A2*sin(ph2))/(A1*cos(ph1) + A2*cos(ph2)))

i think you might run into the quadrant problem here as you do for the
complex arg() operator (which means p12 will be off by PI if the
denominator of the atan() function is negative).  so maybe it should be
stated as

p12 = arg{(A1*cos(ph1) + A2*cos(ph2)) + j*(A1*sin(ph1) + A2*sin(ph2))}

where arg{ R + j*I } = atan2(I/R) or sgn(I)*arccos(R/(R^2 + I^2)) .

r b-j
pbjrbj at viconet.com   a.k.a.   robert at audioheads.com
a.k.a.   robert at wavemechanics.com

"Don't give in to the Dark Side.  Boycott intel and microsoft."

```