Message Boards Message Boards

0
|
1275 Views
|
2 Replies
|
2 Total Likes
View groups...
Share
Share this post:

Help with harmonic addition theorem

Posted 11 months ago

Hello,

It is well known that the linear combination, or harmonic addition, of sine and cosine waves is equivalent to a single sine (or cosine) wave with a phase shift and scaled amplitude.

I did some online search and found: http://mathworld.wolfram.com/notebooks/Trigonometry/HarmonicAdditionTheorem.nb

Basically the two identities I want to implement as functions are:

a cos(q)+b sin(q)==Sqrt[a^2+b^2] sgn(a) cos(tan^-1(-(b/a))+q)

a cos(q)+b sin(q)==-Sqrt[a^2+b^2] sgn(a) sin(tan^-1(-(b/a))+q-[Pi]/2)

I used mathematica to verify them (see attached notebook).

I need two functions (one for each identity) that would convert the sum of sine and cos wave to either a single sine or cos wave with a phase shift and scaled amplitude.

I am a Mathematica newbie and any help with the syntax would be much appreciated.

Thanks,

Attachments:
POSTED BY: ok ok
2 Replies

This is more complicated, but it should work in more cases:

convertToCos[a_.*Cos[q_] + b_.*Sin[q_]] := 
  Sign[a] Sqrt[a^2 + b^2] Cos[q + ArcTan[-b/a]];
convertToCos[b_.*Sin[q_]] := -b Cos[q + Pi/2];
convertToCos[a_.*Cos[q_]] := a Cos[q];

For example

convertToCos[2 Cos[theta] + Sin[theta]]

gives

Sqrt[5] Cos[theta - ArcTan[1/2]]
POSTED BY: Gianluca Gorni
Posted 11 months ago

Does this example help?

HarmonicAddition[a_*Cos[q_]+b_*Sin[q_]]:=Sqrt[a^2+b^2]*Sign[a]*Cos[ArcTan[-b/a]+q]

and then

HarmonicAddition[2 Cos[theta]+3 Sin[theta]]

returns

Sqrt[13]*Cos[theta - ArcTan[3/2]]

Please test that in all the ways that you might use that and see if it does what you need.

POSTED BY: Bill Nelson
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract