Converting a sum of trig functions into a product Given,
$$\cos{\frac{x}{2}} +\sin{(3x)} + \sqrt{3}\left(\sin\frac{x}{2} + \cos{(3x)}\right)$$
How can we write this as a product? 
Some things I have tried: 


*

*Grouping like arguments with each other. Wolfram Alpha gives $$\cos{\frac{x}{2}} + \sqrt{3}\sin{\frac{x}{2}} = 2\sin{\left(\frac{x}{2} + \frac{\pi}{6}\right)}$$but I don't know how to derive that myself or do a similar thing with the $3x$.

*Write $3x$ as $6\frac{x}{2}$ and then using the triple and double angle formulas, but that is much too tedious and there has to be a more efficient way.

*Rewriting $\sqrt{3}$ as $2\sin{\frac{\pi}{3}}$ and then expanding and trying to use the product-to-sum formulas, and then finally grouping like terms and then using the sum-to-product formulas, but that didn't work either.


I feel like I'm overthinking this, so any help or insights would be useful.

First of all
$$
A\cos\alpha+B\sin\alpha=\sqrt{A^2+B^2}\left(\frac{A}{\sqrt{A^2+B^2}}\cos\alpha+\frac{B}{\sqrt{A^2+B^2}}\sin\alpha\right)\\
=\sqrt{A^2+B^2}(\sin\beta\cos\alpha+\cos\beta\sin\alpha)=\sqrt{A^2+B^2}\sin(\beta+\alpha)
$$
you only have to find $\beta$ such that
$$
\left\{
\begin{align}
\sin\beta&=\frac{A}{\sqrt{A^2+B^2}}\\
\cos\beta&=\frac{B}{\sqrt{A^2+B^2}}
\end{align}
\right.
$$
Next, use Sum to product identities.
