Showing that a function is Lebesgue integrable (or not) 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!
 A: Your idea of covering $\mathbb{R}$ with intervals of the form $[n,n+1)$ is spot-on. You're right that your attempt at doing so leaves out the negative numbers, but that is easily fixed. Just let the indices in your big unions range over $\mathbb{Z}$ instead of $\mathbb{N}$, like this \begin{eqnarray}
  E_1 &=& \bigcup_{k\in\mathbb{Z}} [2k, 2k+1) \text{,}\\
  E_2 &=& \bigcup_{k\in\mathbb{Z}} [2k+1, 2k+2) \text{.}
\end{eqnarray}
Your function $f$, as you correctly observed, is then simply $$
  f(x) = \chi_{E_1}(x) - \chi_{E_2}(x) \text{.}
$$
Now, the definition of the lesbegue integral splits a function into it's positive and negative parts, i.e. splits $f$ into $f^+$ and $f^-$ such that \begin{eqnarray}
  f^+(x) &\geq& 0 &\quad \text{for all $x$,} \\
  f^-(x) &\geq& 0 &\quad \text{for all $x$,} \\
  f^+(x) = 0 \,\text{or}\, f^-(x) &=& 0 &\quad \text{for all $x$,}\\
  f(x)   &=&    f^+(x) - f^-(x) &\quad \text{for all $x$.}
\end{eqnarray}
and it defines the integral of $f$ as $$
  \int f = \int f^+ - \int f^-
$$
You are correct that in your case, that gives $\infty - \infty$. And that simply means that your function is not lebesgue integrable over $\mathbb{R}$!. Lebesgue integrals do not allow infinite positive areas to cancel out infinite negative areas! In fact, this is one of the properties that make it possible for lebesgue integrals to obey much stronger convergence theorems than riemann integrals, because such a cancellation would intrinsically depend on the order of summation.
For example, say your function was instead defined to be $$
  f(x) = \begin{cases} -1 &\text{if $x < 0$} \\ 1 &\text{if $x \geq 0$.} \end{cases}
$$
That function simply re-arranges the positive and negative areas differently, yet orders of summation that would yield a finite result for your original $f$ would not yield a finite result here.
A: For your notation concern, you can write it like this:
$$E_1 = \bigcup_{k \in \mathbb{Z}} [2k, 2k+1) = \bigcup_{k=-\infty}^\infty [2k, 2k+1).$$
Concerning the Lebesgue integrability, I think the argument that you give holds.
