ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Sat, 31 Aug 2019 13:04:17 +0200trigonometric linear combinationhttps://ask.sagemath.org/question/47665/trigonometric-linear-combination/How to simplify the expression a*sin(x)+b*cos(x), so it becomes something like c*sin(x + d) ?Fri, 30 Aug 2019 05:55:26 +0200https://ask.sagemath.org/question/47665/trigonometric-linear-combination/Comment by Emmanuel Charpentier for <p>How to simplify the expression a<em>sin(x)+b</em>cos(x), so it becomes something like c*sin(x + d) ?</p>
https://ask.sagemath.org/question/47665/trigonometric-linear-combination/?comment=47670#post-id-47670Homework ?Fri, 30 Aug 2019 16:11:07 +0200https://ask.sagemath.org/question/47665/trigonometric-linear-combination/?comment=47670#post-id-47670Answer by Emmanuel Charpentier for <p>How to simplify the expression a<em>sin(x)+b</em>cos(x), so it becomes something like c*sin(x + d) ?</p>
https://ask.sagemath.org/question/47665/trigonometric-linear-combination/?answer=47686#post-id-47686No answer. Okay, I,ll *assume* this is not homework (if it is, you'll loose the benefit of finding this by yourself ; on your head be it)...):
The "naive" solution" coesn't work:
sage: var("a, b, c, d")
(a, b, c, d)
sage: E1=a*sin(x)+b*cos(x)==c*sin(x+d); E1
b*cos(x) + a*sin(x) == c*sin(d + x)
sage: solve(E1,[c,d])
[[c == (b*cos(x) + a*sin(x))/sin(r1 + x), d == r1]]
This "solution" depends on x. since we are looking for a *general* solution this can't be accepted. In fact, our equation, which we can rewrite as :
sage: E1.trig_expand()
b*cos(x) + a*sin(x) == (cos(x)*sin(d) + cos(d)*sin(x))*c
must hold for *any* x. In particular,
- it must hold for $\cos(x)=0$:
This is interesting:
sage: E1.trig_expand().subs(cos(x)==0)
a*sin(x) == c*cos(d)*sin(x)
Since $\cos(x)=0\Rightarrow \sin(x)\in \left(-1,1\right)$, this gives us a"special case" equation:
sage: E2=E1.trig_expand().subs(cos(x)==0)/sin(x); E2
a == c*cos(d)
- It must hold for $\sin(x)=0$.
By a similar reasoning, we get another "special case" equation:
sage: E3=E1.trig_expand().subs(sin(x)==0)/cos(x); E3
b == c*sin(d)
E2 and E3 together gives us a solution for d:
sage: S1=(E3/E2).trig_reduce().solve(d); S1
[d == arctan(b/a)]
This solution can be substituted in our (expanded) original equation which can now be solved for c:
sage: S2=E1.trig_expand().subs(S1).solve(c);S2
[c == a*sqrt(b^2/a^2 + 1)]
And we can check that our original equation holds:
sage: E1.subs(S1).subs(S2).trig_simplify()
b*cos(x) + a*sin(x) == b*cos(x) + a*sin(x)
We end up with a tautology. Good...
Left as an exercise for the reader: We have *a* solution; is this *the* solution ?
Sat, 31 Aug 2019 13:04:17 +0200https://ask.sagemath.org/question/47665/trigonometric-linear-combination/?answer=47686#post-id-47686