An interesting question occurred to me as I was reading some Physics: Is it true in general that $$\left|\int_a^b f(x) \, dx\right| = \int_a^b |f(x)| \, dx\, ?$$ If not, what properties must $f(x)$ satisfy for the above equality to be true?
I'm not a mathematician, but my hunch is that the equality holds only for $f$ such that $f(x) > 0$ for every $x \in [a,b].$ This seems to work out with some simple examples I've tried, but I haven't been able to prove it rigorously so far. I suspect the Cauchy-Schwartz inequality might come in handy, but I do not know how to use it here, unless perhaps if I interpret the definite integral as a Riemann Sum.