Article 6S5W6 Linear combination of sine and cosine as phase shift

Linear combination of sine and cosine as phase shift

by
John
from John D. Cook on (#6S5W6)

Here's a simple calculation that I've done often enough that I'd like to save the result for my future reference and for the benefit of anyone searching on this.

A linear combination of sines and cosines

a sin(x) + b cos(x)

can be written as a sine with a phase shift

A sin(x + ).

Going between {a, b} and {A, } is the calculation I'd like to save. For completeness I also include the case

A cos(x + ).

Derivation

Define

f(x) = a sin(x) + b cos(x)

and

g(x) = A sin(x + ).

Both functions satisfy the differential equation

y'' + y = 0

and so f = g if and only if f(0) = g(0) and f'(0) = g'(0).

Setting the values at 0 equal implies

b = A sin()

and setting the derivatives at 0 equal implies

a = A cos().

Taking the ratio of these two equations shows

b/a = tan()

and adding the squares of both equations shows

a^2 + b^2 = A^2.

Equations

First we consider the case

a sin(x) + b cos(x) = A sin(x + ).

Sine with phase shift

If a and b are given,

A = (a^2 + b^2)

and

= tan-1(b / a).

If A and are given,

a = A cos()

and

b = A sin()

from the previous section.

Cosine with phase shift

Now suppose we want

a sin(x) + b cos(x) = A cos(x + )

If a and b are given, then

A = (a^2 + b^2)

as before and

= - tan-1(a / b).

If A and are given then

a = - A sin()

and

b = A cos().

Related postsThe post Linear combination of sine and cosine as phase shift first appeared on John D. Cook.
External Content
Source RSS or Atom Feed
Feed Location http://feeds.feedburner.com/TheEndeavour?format=xml
Feed Title John D. Cook
Feed Link https://www.johndcook.com/blog
Reply 0 comments