# trigonometric linear combination

How to simplify the expression a*sin(x)+b*cos(x), so it becomes something like c*sin(x + d) ?

trigonometric linear combination

How to simplify the expression a*sin(x)+b*cos(x), so it becomes something like c*sin(x + d) ?

0

No 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 ?

Please start posting anonymously - your entry will be published after you log in or create a new account.

Asked: ** 2019-08-30 05:55:26 +0200 **

Seen: **62 times**

Last updated: **Aug 31 '19**

Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.

Homework ?