Trigonometric Identity involving sin()+cos()

  • B
  • Thread starter erobz
  • Start date
  • #1
erobz
Gold Member
1,523
673
I'm trying to use the following trigonometric identity:

$$ a \cos ( \omega t ) + b \sin ( \omega t ) = \sqrt{a^2+b^2} \cos ( \omega t - \phi )$$ Where ##\phi = \tan^{-1} \left( \frac{b}{a} \right)## for the following equation:

$$ x(t) = -\frac{g}{ \omega^2} \cos ( \omega t) + \frac{v_o}{ \omega } \sin ( \omega t ) + \frac{g}{ \omega^2} $$

When I apply the identity I get:

##a = -\frac{g}{ \omega^2}##
##b = \frac{v_o}{ \omega }##
##\phi = \tan^{-1} \left( \frac{-v_o \omega}{g} \right)##

$$ X(t) = \sqrt{\left( \frac{g}{ \omega^2} \right)^2+\left( \frac{v_o}{ \omega } \right)^2} \cos \left( \omega t - \tan^{-1} \left( \frac{-v_o \omega}{g} \right) \right) + \frac{g}{ \omega^2} $$

However, on a plot they are not matching up...What am I doing wrong?

Mass-Spring Oscillator.JPG
 

Answers and Replies

  • #2
robphy
Science Advisor
Homework Helper
Insights Author
Gold Member
6,647
2,011
I suspect it may be related to the fact that
##\phi = \tan^{-1} \left( \frac{b}{a} \right)## can't distinguish ##\frac{b}{a}## from ##\frac{-b}{-a}##.
Try https://en.wikipedia.org/wiki/Atan2
or add ##\pi## to the result of ##\tan^{-1}## if the x-component is negative.
 
  • Like
Likes erobz and topsquark
  • #3
FactChecker
Science Advisor
Homework Helper
Gold Member
7,592
3,314
You can see from your original equation that CORRECTION the right-hand side is the same no matter what the signs of ##a## and ##b## are, whereas the left-hand side is different when a sign of ##a## or ##b## changes. Your plot of the right-hand side is correct for a positive ##a##, but your example has a negative ##a=-g/\omega^2##.
CORRECTION: I overlooked that ##\phi## of the right-hand side depends on the signs of ##a## and ##b##.
 
Last edited:
  • Like
Likes erobz, PeroK and topsquark
  • #4
PeroK
Science Advisor
Homework Helper
Insights Author
Gold Member
2022 Award
23,784
15,399
I'm trying to use the following trigonometric identity:

$$ a \cos ( \omega t ) + b \sin ( \omega t ) = \sqrt{a^2+b^2} \cos ( \omega t - \phi )$$ Where ##\phi = \tan^{-1} \left( \frac{b}{a} \right)## for the following equation:
This is not quite right. According to Wikipedia, it should be:
$$ a \cos ( \omega t ) + b \sin ( \omega t ) = sgn(a) \sqrt{a^2+b^2} \cos ( \omega t - \phi )$$ Where ##\phi = \tan^{-1} \left( \frac{b}{a} \right)##.

https://en.wikipedia.org/wiki/List_of_trigonometric_identities#Linear_combinations
 
  • Like
Likes topsquark and erobz
  • #6
erobz
Gold Member
1,523
673
I read the identity from my Mechanical Measurements Text:

Perhaps they are assuming something about ##A,B##, but I don't see it anywhere.

IMG_1739.jpg
 
  • #7
PeroK
Science Advisor
Homework Helper
Insights Author
Gold Member
2022 Award
23,784
15,399
I read the identity from my Mechanical Measurements Text:

Perhaps they are assuming something about ##A,B##, but I don't see it anywhere.

View attachment 315809
If ##A## is taken to be the amplitude (##y(0) = A##), then tacitly ##A > 0##.
 
  • #8
PeroK
Science Advisor
Homework Helper
Insights Author
Gold Member
2022 Award
23,784
15,399
You can see from your original equation that CORRECTION the right-hand side is the same no matter what the signs of ##a## and ##b## are, whereas the left-hand side is different when a sign of ##a## or ##b## changes. Your plot of the right-hand side is correct for a positive ##a##, but your example has a negative ##a=-g/\omega^2##.
CORRECTION: I overlooked that ##\phi## of the right-hand side depends on the signs of ##a## and ##b##.
You were right if you looked at the case where ##t = 0##, as ##\cos## is positive on the range of ##\tan^{-1}##, which is ##(-\frac \pi 2, \frac \pi 2)##:
$$a = \sqrt{a^2 + b^2}\cos(-\phi) = \sqrt{a^2 + b^2}\cos(\phi)> 0$$
 
  • #9
erobz
Gold Member
1,523
673
If ##A## is taken to be the amplitude (##y(0) = A##), then tacitly ##A > 0##.
But wouldn't the amplitude be ##\sqrt{ A^2 + B^2}## ?
 
  • Like
Likes topsquark and PeroK
  • #10
PeroK
Science Advisor
Homework Helper
Insights Author
Gold Member
2022 Award
23,784
15,399
But wouldn't the amplitude be ##\sqrt{ A^2 + B^2}## ?
That's true. The important thing is to remember the mathematical pitfall you uncovered here. It's possible the book's author overlooked it.
 
  • Like
Likes topsquark and erobz
  • #11
PeroK
Science Advisor
Homework Helper
Insights Author
Gold Member
2022 Award
23,784
15,399
First, assume ##a > 0## and let ##\phi = \tan^{-1}\big (\frac b a \big )##. Note that ##-\frac \pi 2 < \phi < \frac \pi 2##. Hence: ##\cos \phi > 0## and ##\sin \phi## has the same sign as ##b##. We have:
$$\cos(x - \phi) = \cos x \cos \phi + \sin x \sin \phi$$Where
$$\cos \phi = \sqrt{\cos^2 \phi} = \frac 1 {\sqrt{\sec^2 \phi}} = \frac 1 {\sqrt{1 + \tan^2 \phi}} = \frac 1 {\sqrt{1 + \frac{b^2}{a^2}}} = \frac{a}{\sqrt{a^2 + b^2}}$$And:
$$\sin \phi = sgn(b) \sqrt{\sin^2 \phi} = sgn(b) \sqrt{1 - \cos^2 \phi} = sgn(b)\sqrt{1 - \frac{1}{\sec^2 \phi}}$$$$ = sgn(b)\sqrt{\frac{b^2}{a^2 + b^2}} = \frac{b}{\sqrt{a^2+b^2}}$$Hence, for ##a > 0## we have:
$$\cos(x - \phi) = \frac 1 {\sqrt{a^2 + b^2}}\big(a\cos x + b\sin x\big)$$And$$a\cos x + b\sin x = \sqrt{a^2 + b^2}\cos(x - \phi)$$Finally, if ##a < 0##, then:
$$a\cos x + b\sin x = -\big((-a)\cos x + (-b)\sin x \big ) = -\sqrt{a^2 + b^2}\cos(x - \phi)$$Where ##\phi = \tan^{-1}\big(\frac{-b}{-a} \big) = \tan^{-1}\big(\frac{b}{a} \big)##
 
  • Like
Likes erobz and topsquark
  • #12
DaveE
Science Advisor
Gold Member
2,840
2,488
It is really common for people to be sloppy when they say ##\phi = tan^{-1}(b/a)##. As others have said, there are sign issues depending on which quadrant you are in. When things seem wrong always look at a sketch in the complex plane first. This is why all (good) programming libraries have the atan2 function. Also, beware, you'll see this mistake again, from yourself or others.
 
  • Like
Likes FactChecker and erobz

Suggested for: Trigonometric Identity involving sin()+cos()

  • Last Post
Replies
4
Views
387
Replies
3
Views
857
  • Last Post
Replies
1
Views
530
  • Last Post
Replies
0
Views
400
Replies
3
Views
770
Replies
9
Views
837
  • Last Post
Replies
9
Views
1K
  • Last Post
Replies
2
Views
542
Replies
3
Views
965
Top