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.
 A: $$\cos{\frac{x}{2}} +\sin(3x) + \sqrt{3}\left(\sin\frac{x}{2} + \cos(3x)\right)$$
$$=\cos{\frac{x}{2}} + \sqrt{3}\sin\frac{x}{2} +\sin(3x)  + \sqrt{3}\cos(3x)$$
$$=2\left(\frac{1}{2}\cos\frac{x}{2} + \frac{\sqrt{3}}{2}\sin\frac{x}{2} +\frac{1}{2}\sin(3x)  + \frac{\sqrt{3}}{2}\cos(3x)\right)$$
Note that $\frac{1}{2}=\sin\frac{\pi}{6}$ and $\frac{\sqrt{3}}{2}=\cos\frac{\pi}{6}$ so:
$$=2\left(\sin\frac{\pi}{6}\cos\frac{x}{2} + \cos\frac{\pi}{6}\sin\frac{x}{2} +\sin\frac{\pi}{6}\sin(3x)  + \cos\frac{\pi}{6}\cos(3x)\right)$$
Then using Addition Theorem:
$$=2\left(\sin\left(\frac{x}{2}+\frac{\pi}{6}\right)+\cos\left(3x-\frac{\pi}{6}\right)\right)$$
$$=2\left(\sin\left(\frac{x}{2}+\frac{\pi}{6}\right)+\sin\left(3x+\frac{\pi}{3}\right)\right)$$
Then using Sums to Products:
$$=4\left(\sin\left(\frac{\frac{x}{2}+\frac{\pi}{6}+3x+\frac{\pi}{3}}{2}\right)\cos\left(\frac{\frac{x}{2}+\frac{\pi}{6}-3x-\frac{\pi}{3}}{2}\right)\right)$$
$$=4\sin\left(\frac{7x+\pi}{4}\right)\cos\left(\frac{-15x-\pi}{12}\right)$$
A: 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.
