<s>[INST] $\int_{0}^{\pi}|\sqrt2\sin x+2\cos x|dx$ $\int_{0}^{\pi}|\sqrt2\sin x+2\cos x|dx$
MyAttempt
$\int_{0}^{\pi}|\sqrt2\sin x+2\cos x|=\int_{0}^{\pi/2}\sqrt2\sin x+2\cos x dx+\int_{\pi/2}^{\pi}|\sqrt2\sin x+2\cos x| dx$
I could solve first integral but in second one,i could not judge the mod will take plus sign or minus sign or how to break it in further intervals?
 [/INST] $\displaystyle A \sin \ x + B \cos \ x = \sqrt{A^2 + B^2}\sin( x + \phi )$, where $\displaystyle \cos \phi =  \frac{A}{\sqrt{A^2 + B^2}}$.
In our case $\displaystyle \cos\phi=\frac{1}{\sqrt{3}} \Rightarrow \phi\in\left(0;\frac{\pi}{2}\right)$.
Thus: $\displaystyle \begin{aligned}\int\limits_0^\pi\left|\sqrt{2}\sin x+2\cos x\right|dx&=\sqrt{6}\int\limits_0^\pi\left|\sin(x+\phi)\right|dx=\sqrt{6}\int\limits_0^{\pi-\phi}\sin(x+\phi)dx+\sqrt{6}\int\limits_{\pi-\phi}^\pi(-\sin(x+\phi))dx=\\&=\left.-\sqrt{6}\cos(x+\phi)\right|_0^{\pi-\phi}+\left.\sqrt{6}\cos(x+\phi)\right|_{\pi-\phi}^\pi=-\sqrt{6}\left(\cos\pi-\cos\phi\right)+\sqrt{6}\left(\cos(\pi+\phi)-\cos\pi\right )=\\&=\sqrt{6}+\sqrt{2}-\sqrt{2}+\sqrt{6}=2\sqrt{6}\end{aligned}$
</s>