Integrating a step function using antiderivatives Let $$ f(x) = 
  \begin{cases}\begin{align}
    1\quad&\text{ if }\; 0\leq x \leq 1 \\
    2 \quad&\text{ if }\; 1<x \leq 2 \\
  \end{align}\end{cases}$$
Then $\int^2_0 f(x)dx=3$ and an anti derivative of f(x) is $$F(x)=\begin{cases}\begin{align}
    x\quad&\text{ if }\; 0\leq x \leq 1 \\
    2x \quad&\text{ if }\; 1<x \leq 2 \\
  \end{align}\end{cases}$$
But, $F(2)-F(0)=4-0=4 \neq 3.$ Why has this happened?
Find an anti-derivative $G(x)$ of $f(x)$ such that $G(2)-G(0)=3$, the correct answer.
My attempt:
$F(2)-F(0)=4 \neq 3$ because we need to break it up into two parts like this: $\int^2_1 2x dx + \int^1_0 x dx = x^2|^2_0 + \frac{1}{2} x^2|^1_0 =4-1+\frac{1}{2}-0=3.5$ but this is not right either. :(
For the "Find an anti-derivative $G(x)$..."I'm completely lost but perhaps if we solve the first part then I'll understand what it's asking for there.
Any help would be appreciated.
 A: $F$ is not the antiderivative of $f$ on the whole interval $[0,2]$, because its derivative doesn't exist at $1$. So the hypothesis of the $2$nd fundamental theorem of integral calculus is not satisfied.
A: Your $F$ is not really an antiderivative, because we don't have $F'(x)=f(x)$ everywhere -- in fact $F'(1)$ doesn't exist at all!
Even worse, $F$ is not even an indefinite integral, because it has a jump discontinuity at $1$.
If you add an appropriate constant to one of the two cases in the definition of $F$, you can get rid of the jump discontinuity, and then it will actually be an indefinite integral (but still not an antiderivative) -- if we define "indefinite integral" to mean a function that allows us to compute definite integrals by the $\int_a^b f(x)\,dx = F(b)-F(a)$ rule. (On the other hand, it seems to be more common to define "indefinite integral" simply as a synonym for "antiderivative", and then getting rid of the jump doesn't produce one, of course).
In fact $f$ can't have any antiderivative because derivatives always satisfy the intermediate value property (by Darboux's theorem), but $f$ doesn't do that.
A: Using the antiderivative to compute an integral is the (second) Fundamental Theorem of Calculus. Said theorem requires the function $f$ which you want to integrate to be continuous on the whole interval (where you want to integrate). Your $f$ is not continuous in $[0,2]$ and hence the theorem doesn't work. In fact, $f$ cannot have an antiderivative at point $x=1$ because $f$ has a simple discontinuity at point $x=1$.
We can find a function $G$ such that $G'=f$ in [0,1] (considering left hand derivatives at $x=1$) and $G'=f$ in [1,2] considering right hand derivatives at $x=1$, and such that $G$ computes the area below $f$ in the interval $[0,x]$
When considering the second half $[1,2]$, you must not forget the area below $f$ in $[0,1]$. With this in mind put:
$$G(x)=\begin{cases}x \quad \quad \ \  \text{if} \ x\in [0,1] \\ 1+2(x-1) \ \ \text{if} \ x\in [1,2]\end{cases}$$
Where the $x-1$ comes from considering the rectangle whose base is the segment $[1,x]$ for $x>1$
Then $G(2)-G(0)=1+2(2-1)-0=3=\int_{0}^{2}f(x)dx$, as desired. 
