Determine the Distribution Function Another density function to Distribution function that has me stumped again.  This time, I might be going wrong on my intervals.  
$$
f(x)=
\begin{cases}
x+1, & -1<x\le0\\
1-x, & 0< x\le1\\
0, & otherwise\\
\end{cases}
$$
I know now that to get $F(x)$ I should integrate these two density functions. 
so $\int_{-1}^x x+1 dx$ which gives me $\frac{1}{2}x^2 + x + \frac{1}{2}$ which is fine, as that would be between the interval $-1<x\le0$ 
For the second interval (from $0<x\le1$), $\int_0^x 1-x dx$ which gives me $-\frac{1}{2}x^2 + x$ 
however the answer says it should be $-\frac{1}{2}x^2 + x + \frac{1}{2}$ can someone please help me out .. where is this extra 1/2 coming from?  Is my interval selection wrong or am I not integrating properly?
Thank you so much in advance for your help and your time. 
 A: In general, 
$$F(x)=\int_{-\infty}^x f(t)\,dt,$$
where $f$ is the density function.  If you prefer, you can write $\int_{-\infty}^x f(x)\,dx$. (The second notation can be confusing, since $x$ appears both as the dummy variable of integration and in the upper limit.)
Because our density function is given by different formulas in different places, we will have to be careful in evaluating the integral. 
(i) Suppose that $-\infty\lt x\le -1$. Then $F(x)=\int_{-\infty}^x (0)\,dt=0$.
(ii) Suppose that $-1\lt x\le 0$. Then $F(x)=\int_{-\infty}^{-1} (0)\,dt+\int_{-1}^x (t+1)\,dt=\frac{x^2}{2}+x+\frac{1}{2}$.
(iii) Suppose that $0\lt x\le 1$. Again, we integrate the density function from $-\infty$ to $x$. Let's not bother writing down the part from $-\infty$ to $-1$, there is nothing there. But there is stuff from $-1$ to $0$. So for $0\l x\le 1$, the  integral is $\int_{-1}^0 (1+t)\,dt +\int_0^x(1-t)\,dt$.
The part from $-1$ to $0$ gives $\frac{1}{2}$. The part from $0$ to $x$ gives $x-\frac{x^2}{2}$. Add.
(iv) Suppose that $x\gt 1$. The integral from $-\infty$ to $1$ is $1$, and the density is $0$ after that, so $F(x)=1$ for $x\gt 1$. 
Remark: To see what is going on, it is useful to draw the density function. The graph is $0$ up to $x=-1$, then climbs linearly until it hits the value $1$ at $x=0$, then falls to $0$ at $x=1$, and then stays at $0$.  The function $F(x)$ gives the area under the curve from $-\infty$ to $x$.
This may help to answer answer your question.  Suppose we want to find the area under the curve from $-\infty$ to $x$, where $0\lt x\le 1$. We certainly don't just integrate $1-t$ from $0$ to $x$. We have to add in the area to the left of $x=0$. This area is $\frac{1}{2}$.
