# How to find $\int_0^{2\pi} |a\cos(x)+b\sin(x)|dx$, where $a^2+b^2=1$

I need help to solve this integral: $$\int_0^{2\pi} |a\cos(x)+b\sin(x)|dx$$ where $a^2+b^2=1$. I hope someone is able to help me.

-
What you're trying to do is to evaluate an integral, not to solve an integral. One solves problems; one solves equations; one evaluates expressions. – Michael Hardy Apr 9 '12 at 1:22
$\displaystyle{\large a,\ b \in {\mathbb R}\ ?}$. – Felix Marin Aug 7 '14 at 23:33

Hint: Let $\phi$ be a number such that $a=\sin\phi$ and $b=\cos\phi$. You want to integrate $|\sin(x+\phi)|$. Maybe make the natural change of variable, or let the geometry guide you to the answer.
Remark: The "trick" above has a number of uses. The idea works even if $a^2+b^2\ne 1$. For suppose that $a^2+b^2\ne 0$. Note that $$a\cos x+b\sin x=\sqrt{a^2+b^2}\left(\frac{a}{\sqrt{a^2+b^2}}\cos x+\frac{b}{\sqrt{a^2+b^2}}\sin x\right).$$ Let $\phi$ be a number such that $a/\sqrt{a^2+b^2}=\sin \phi$ and $b/\sqrt{a^2+b^2}=\cos\phi$.
Choose $\theta$ such that $\sin(\theta) = a$ and $\cos(\theta)=b$. Then you have $a\cos(x)+b\sin(x) = \sin(\theta)\cos(x)+\cos(\theta)\sin(x)$. A standard trig. identity shows that this can be written as $a\cos(x)+b\sin(x) = \sin(\theta+x)$. Since $x \mapsto \sin(\theta+x)$ is $2 \pi$ periodic, then the integral can be written as $\int_0^{2 \pi} |\sin(\theta+x)|dx = \int_0^{2 \pi} |\sin(x)|dx$ = $\int_0^{\pi} \sin(x)dx - \int_{\pi}^{2\pi} \sin(x)dx = 2 \int_0^{\pi} \sin(x)dx$. I trust you can take it from here.