Why do we need the absolute value signs when integrating the square of a function?

Why do we need the absolute value signs in the definition of square-integrable function? As seen below:

$$ \int_{-\infty}^{\infty} \lvert f(x) \rvert^2 \, dx < \infty $$


Solution 1:

Because complex-valued functions are used. The square of a complex number need not be non-negative.

Solution 2:

Besides the complex-valued case, I suspect it also has to do with the existence of other $L^p$ spaces; Wikipedia gives the general definition as

$$ \|f\|_p = \left(\int_S |f|^p \,d\mu\right)^{1/p} $$

Since the absolute value symbols are redundant only for even integral $p$, omitting them disrupts the uniformity of the notation without buying a whole lot.