# Integral of absolute value = absolute value of the integral

Let $(a,b) \in \mathbb{R}^2$ and $f \in C^0([a, b] , \mathbb{C})$
Find the condition on $f$ so that $$|\int_a^b f|=\int_a^b|f|$$

My try :
The function $f: t \mapsto r(t)\exp(i\theta)$ where $r$ is a positive real value function and $\theta \in \mathbb{R}$ satisfies the equation and I think it's the best shot we can get, but I'm not 100% sure.
Besides, I've no idea where to start.
Any help is appreciated.

You are almost right: $r$ need not be positive, it suffices that $r$ is nonnegative. It is straightforwart to show that for such a function bot sides evaluate to $\int_a^br(t)\,\mathrm dt$.
Now assume that $f$ is not of this form. Show that for arbitrary $\theta$, $$\int_a^b\Re (e^{-i\theta}f(t))\,\mathrm dt<\int_a^b|f(t)|\,\mathrm dt$$ because there is always some open interval where $f$ strictly deviates from being a nonegative multiple of $e^{i\theta}$ and hence where $\Re (e^{-i\theta}f(t))<|f(t)|$.