# How to rewrite $a\sin x+b\cos x$ just using $\sin x$ or $\cos x$? [duplicate]

For $$\sin (x)+\sqrt{3} \cos (x)$$, we can rewrite it as $$2 \sin \left(x+\frac{\pi }{3}\right)$$.

Is there a formula to represent $$a\sin(x)+b\cos(x)$$ just by using sine or cosine function just as the aforementioned example?

• This graphical explanation easily generalizes to the situation where lenghts $a$ and $b$ are not $1$. – hmakholm left over Monica Jun 4 '19 at 21:04
• I would guess is $/sqrt(a^2 + b^2)sen(x + atan (b/a))$. I cant remember very well but I suppose maybe you can prove it using $e^{ix} = cos x + i sen x$ and taking real and imaginary parts and somethings like this – HFKy Jun 4 '19 at 21:04

$$a \sin(x) + b\cos(x) = r \sin(x + \theta)$$ where $$r = \sqrt{a^2 + b^2}$$, $$a/r = \cos(\theta)$$ and $$b/r = \sin(\theta)$$. Thus if $$a > 0$$, $$\theta = \arcsin(b/r)$$ while if $$a < 0$$, $$\theta = \pi - \arcsin(b/r)$$ will do.