TITLE: Minimizing certain integral
QUESTION [1 upvotes]: Define $$F(a)=\int_0^{\pi/2}|\sin x-a\cos x|dx.$$
Find $a$ such that $F(a)$ is minimum.
My attempt is to use differentiation under integral sign. Namely, we have $$F(a)=\int_0^{\arctan a}(a\cos x-\sin x)dx+ \int_{\arctan a}^{\pi/2}(\sin x-a\cos x)dx,$$
and hence we can find the derivative as usual. Butthe calculation becomes hopelessly messy and I'm wondering is there any clearer solution. Thank you so much.

REPLY [1 votes]: What's wrong with just computing the integral?  Let $\theta = \tan^{-1} a$.
$$\begin{align*} F(a) &= \Bigl[ a \sin x + \cos x \Bigr]_{x=0}^\theta + \Bigl[ -\cos x - a \sin x \Bigr]_{x=\theta}^{\pi/2} \\ &= a \sin \theta + \cos \theta - 1 - a + \cos \theta + a \sin \theta \\ &= 2(a \sin \theta + \cos \theta) - (a+1) \\ &= 2 \sqrt{a^2+1} - (a+1), \quad \color{red}{a > 0}. \end{align*}$$  Then differentiation yields $$F'(a) = \frac{2a}{\sqrt{a^2+1}} - 1,$$ for which there is a critical point at $a = 1/\sqrt{3}$.  We then need to verify that this indeed corresponds to a minimum.
{"set_name": "stack_exchange", "score": 1, "question_id": 1170031}