Linear combination of sine and cosine as phase shift
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 + ).
DerivationDefine
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.
EquationsFirst we consider the case
a sin(x) + b cos(x) = A sin(x + ).
Sine with phase shiftIf 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 shiftNow 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 posts- Convert between real and complex Fourier series
- Converting between error function and normal CDF [pdf]
- Converting trig identities to hyperbolic identities
- Technical notes