How would I go about showing that the function $ f(x) = \left\{ \begin{array}{lr} &1 & : x \in [n,n+1) & :n\quad \text{even}\\ &-1 & : x \in [n,n+1) & :n\quad \text{ odd} \end{array} \right. $ defined on $E=\mathbb{R}$ is Lebesgue integrable or not?
My first idea is to use the definition of the Lebesgue integral of a simple function since I have that $f$ only assumes $1$ and $-1$.
Let $f$ be a simple function with the canonical representation $f=\sum\limits^n_{k=1}c_k\chi_{E_k}.$
The Lebesgue integral of $f$ on $E$ is $\int_E f=\sum\limits^n_{k=1}c_km(E_k).$
But I ran into trouble in defining the $E_k$'s. I know that they should be measurable and disjoint as well as their union must be equal to $E=\mathbb{R}$. I have this intuition that if I take say $[0,1),[1,2),[2,3),[3,4),...$ all of these intervals are measurable and disjoint and their union is $\mathbb{R}$. I have that $f$ will assume the value $1$ on $E_1$ where $E_1$ is the union of all intervals $[n,n+1)$ where $n$ is even. On the other hand $f$ will take the value $-1$ on $E_2$ where $E_2$ is the union of all intervals $[n,n+1)$ where $n$ is odd. I'm not sure how to represent $E_1$ and $E_2$. Here is a try. If I let $n=2k$ when $n$ is even and $n=2k+1$ when $n$ is odd I will have:
$$E_1=\bigcup\limits_{k=0}^\infty [2k,2k+1)$$ $$E_2=\bigcup\limits_{k=0}^\infty [2k+1,2k+2)$$
But the representations above only covers the positive numbers. How do I write the intervals $...[-3,-2),[-2,-1),[-1,0)$?
The measure of any interval $[2k,2k+1)$ or $[2k+1),2k+2)$ is $1$. Since there are infinitely many $k$ I will have $m(E_1)=\infty$ and $m(E_2)=\infty$ also. So I would have like an $\infty-\infty$? But my intuition tells me that for every interval $[2k,2k+1)$ there is an interval $[2k+1),2k+2)$ so things should evenly cancel out and I will be left with zero. Which is finite so $f$ is integrable.
Here is another idea. What if I consider $f^+=max(f,0)$ and $f^-=-min(f,0)$?
A measurable function $f$ is said to be integrable over $E$ if $f^+$ and $f^-$ are both integrable over $E$. In this case we define $\int_E f = \int_E f^+ -\int_E f^-$.
Then if I can show that $f^+$ and $f^-$ are both integrable then so is $f$. Now if $f=1$, $f^+=1$ and $f^-=0$ and if $f=-1$, $f^+=0$ and $f^-=1$. So I have that $f^+$ and $f^-$ assumes the value $0$ or $1$ only. Intuitively I think that $\int_E f^+=\infty$ which makes it not integrable and thus $f$ is not integrable also.
Which approach is correct? Any ideas?
Any help or suggestion will be greatly appreciated. Thank you!