I have a problem I need help in solving.

Suppose that $f\in L^1(\mu)$. I would like to show that $\left|\int_X f~d\mu\right| = \int_X |f|~d\mu$ if and only if $\exists$ a constant $\beta$ such that $|f|=\beta f$ a.e. on $X$.

My Attempt(for the forward direction)

$\left|\int_X f~d\mu\right| =\beta\int_X f~d\mu$ for some constant $\beta$. So $$\int_X |f|~d\mu = \beta \int_X f~d\mu \implies \int_X \left(|f|-\beta f\right)~d\mu =0$$ But since $|f|-\beta f \geq 0$, $|f| =\beta f$ a.e.

For the backward direction, this is what I have so far:

Suppose $|f|=\beta f$ a.e. I know that $\left|\int_X f~d\mu\right| \leq \int_X |f|~d\mu$. So, I must show the reverse inequality and I need some help with it.

Also is what I did for the forward direction ok?

Thanks very much.