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? 
 A: $$\cos x+\sqrt 3\sin x=2\left( \frac 12\cos x+\frac {\sqrt 3}2\sin x \right)$$
$$=2\left( \sin\frac{\pi}6\cos x+\cos\frac{\pi}6\sin x \right)$$
$$=2\sin\left( x+\frac{\pi}6 \right)=a^2$$
Can you finish from here?
A: Since \begin{align}\cos x+\sqrt 3\sin x &=2\left( \frac 12\cos x+\frac {\sqrt 3}2\sin x \right) \\
& =2 \sin\left(x + \frac{\pi}{6}\right) = a^2\end{align}
Since $\sin x$ oscillates between $-1$ and $1$, we need $\displaystyle -1 \leq \frac{a^2}{2} \leq 1$. The maximum value of $a$ is easily seen to be $a = \sqrt{2}$ since $\displaystyle \frac{a^2}{2}\leq 1 \implies a^2 \leq 2$.

An alternative way (but much less elegant, imo) is to differentiate and set the derivative equal to zero, as shown below: 
$$\dfrac{\mathrm{d}}{\mathrm{d}x}\left(\cos x + \sqrt{3} \sin x\right) = \sqrt{3}\cos x - \sin x.$$
The derivative first vanishes at $x = \frac{\pi}{3}$ and has the general solution of $x = n\pi - \frac{2\pi}{3}$. When $x = \frac{\pi}{3}$, you need only check that this is a maximum point (hint: look at the second derivative) then substitute it into the original equation to deduce that $a^2 = 2$. 
A: 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
$.
