<s>[INST] Trigonometry equation maximum Given the equation: $\cos x + \sqrt3 \sin x = a^2$  find the maximum value for $a$ for which the equation has solutions and for this case solve the equation, $a \in \mathbb{R}$.
I'm guessing I need to find the maximum for the function and for this I have to differentiate it and solve it when it's derivative is $0$? At a first glance I'd say the maximum for $a$ is $\sqrt2$ when $x=\frac{\pi}{3}$, but how do I go around proving this? 
 [/INST] More generally,
and with no originality:
If
$f(x)
=a \sin x + b \cos x
$,
let
$c = \sqrt{a^2+b^2}$.
Then
$f(x)
=c(\frac{a}{c} \sin x + \frac{b}{c} \cos x)
=c(A \sin x + B \cos x)
$.
Since
$A^2+B^2 = 1$,
there is an angle 
$\theta$
such that
$\cos \theta = A$
and
$\sin \theta = B$.
Therefore
$f(x)
=c(\cos \theta \sin x + \sin \theta \cos x)
=c \sin(x+ \theta)
$.
Therefore,
$|f(x)|
\le c
$
and this value is attained
for $x = -\theta$.
In this case,
$a = 1$
and $b = \sqrt{3}$,
so the max is
$\sqrt{1+3}
= 2
$.
</s>