$f$ is not Lebesgue integrable but $|f|$ is. Why?

I read some wikipedia pages, http://en.wikipedia.org/wiki/Absolute_convergence and have a question. I know how to construct a Vitali set (non-measurable), I understand relations and equivalence classes, but here is the problem.

The page says that $f = \chi_S - 1/2$ is not Lebesgue integrable but that $|f|$ is (constant). Here I assume that $$\chi_S := \left\{ \begin{array}{ll} 1, & x \in S\\ 0, & x \in S^c \end{array} \right.,$$ where $S$ is the nonmeasurable set of $\mathbb{R}$, the Vitali set.

I understand that $f = f^+ - f^-$ and $|f| = f^+ + f^-$, where $f^+ := \max(f,0)$ and $f^- := - \min(f,0)$.

So why is a nonmeasurable set suddenly measurable when the absolute value is taken?

I tried this:

$\int_{\mathbb{R}}\,|f|\,d\mu = \int_{\mathbb{R}}\,\bigg( \big(\chi_S-1/2\big)^+ + (\chi_S-1/2)^-\bigg)\,d\mu = \int_{\mathbb{R}}\,\big(\chi_S-1/2)^+\,d\mu + \int_{\mathbb{R}}\;\big(\chi_S - 1/2)^-\,d\mu$ $\leq \int_{\mathbb{R}}\;\chi_S{}^+\;d\mu+\int_{\mathbb{R}}\;(-1/2)^-\;d\mu+\int_{\mathbb{R}}\;\chi_S{}^-\;d\mu+\int_{\mathbb{R}}\;(-1/2)^-d\mu = \int_{\mathbb{R}}\;\chi_S{}^+d\mu+\int_{\mathbb{R}}\;\chi_S{}^-d\mu$,

a finite number apparently, while,

$\int_{\mathbb{R}}\,f\,d\mu = \int_{\mathbb{R}}\,\bigg( \big(\chi_S-1/2\big)^+ - (\chi_S-1/2)^-\bigg)\,d\mu = \int_{\mathbb{R}}\,\big(\chi_S-1/2)^+\,d\mu - \int_{\mathbb{R}}\,\big(\chi_S - 1/2)^-\,d\mu$ $\leq \cdots = \int_{\mathbb{R}}\;\chi_S{}^+d\mu-\int_{\mathbb{R}}\;\chi_S{}^-d\mu$

must be infinite? (The first equality holds only if both upper functions are Lebesgue integrable.) Or does this latter one fail just because it is undefined on $S$?

Thanks much!

P.S. This is a homework question suggesting to find a function $f$ that is not Lebesgue integrable, but whose $|f|$ is Lebesgue integrable. The question hinted at using $f = \chi_A - \chi_B$ on some subsets of $\mathbb{R}$. I tried tons of combinations (too many to type):

$\chi_A := 1$ if $x \in \mathbb{Q}$ and $-1$ if $x \in \mathbb{Q}^c$, with the opposite for $\chi_B$. I also tried intersecting $A$ and $B$ with $[0,1]$ so as to avoid an infinite measure that may have violated the Lebesgue integrability of $|f|$, too.

-
The function equals 1/2 on the non-measurable set and -1/2 off it. It isn't integrable, since it's not measurable; but the absolute value is constantly 1/2, thus integrable. – David Mitra Nov 13 '11 at 21:33
Just for finishing, it isn't measurable because the pre-image of $-1/2$ is not in a measurable set. – nate Nov 14 '11 at 23:21

So why is a nonmeasurable set suddenly measurable when the absolute value is taken?

It is not measureable. The point is that the set $\{ x | |f(x)| = C\}$ is the union of two sets:

$$\{ x | |f(x)| = C\}= \{x | f(x)=C \} \cup \{x | f(x)=-C \} \,.$$

Now the union of two non-measurable sets can be measurable, and this is what lies behind this problem...

-

I think that the formula $\int |f| d\mu = \int f^+ d\mu+\int f^- d\mu$ is valid only if both $f^+$ and $f^-$ are integrable. In the general case if $|f|$ is constant then it is integrable no matter if $f$ is. The trick is that you don't need to think of $|f|$ as an absolute value of some function, you can think about $|f|$ as a function itself.

-
Good point. I'll change that just for the record. Thanks. – nate Nov 13 '11 at 22:43

The true issue is whether the set $S_c(f)$={x|f(x)>c}, for all reals c itself is measurable, not whether S itself is, tho of course, the two are related. Now, if f is not measurable, then there is some c for which $S_c(f)$ itself is not measurable (you can check for which specific c this happens, since f takes only finitely-many values). Now, |f| takes on different values than f, so that the sets $S_c(f)$ and $S_c(|f|)$ are different. Check to see that the problem set has dissapeared when considering |f|.

-
Maybe to summarize (or, as one of my students once wrote, two sammurais), f is measurable if all $S_c$'s are. So, find a function f such that there is a negative c so that the only $S_c(f):={x:x>c}$ that is not measurable is a negative c. Then this obstacle to measurability of f will disappear with the absolute value composition. – C.O.Jones Nov 13 '11 at 22:04