# how to calculate $\int (|1+x|-|1-x|) dx$ and $\int$ max {${1-x^2,0}$}?

I'm used to integrate normal functions, but here I got quiet confused because these integrals :

• $\int (|1+x|-|1-x|) dx$
• $\int$ max {${1-x^2,0}$}

Include absolute value, and and option to choose between two values, in what direction I must think here? do I have to separate the first integral into cases? and see whats the integral inside the absolute value is negative or positive? and in second one I just do integral on both sides normally? any kind of help would be appreciated.

• Yes, separate into cases. In the second you also need to separate into cases ($-1\leq x\leq1$, $x>1$, and $x<-1$) and not interchange integral and $\max$ if that is what you meant. – OR. Apr 3 '15 at 13:10
• @MlazhinkaShungGronzalezLeWy do you mean that I should set the limits of integration to be in these intervals ? – Firas Ali Abdel Ghani Apr 3 '15 at 13:33
• More or less. Look, from the fundamental theorem of calculus, the derivative of $F(x)=\int_{a}^{x}f(t)dt$ is $f(x)$ when $f(t)$ is continuous. Therefore $F(x)$ is one antiderivative of $f(t)$. So, pick some $a$, say $a=0$ and compute that definite integral. You will have to divide it in cases depending on where $x$ is and break the integrals into pieces to compute them. – OR. Apr 3 '15 at 13:40

For the first function:

if $x\leq -1$ then $|1+x|-|1-x|=-2$

if $x\geq 1$ then $|1+x|-|1-x|=2$

if $-1 \leq x \leq 1$ then $|1+x|-|1-x|=2x$

For the second function:

if $-1\leq x \leq 1$ then $\max \{1-x^2,0\}=1-x^2$

if $x\leq -1$ or $x \geq 1$ then $\max \{1-x^2,0\}=0$.

Using these relationships you may simply proceed with integration.

$\int(|1+x|-|1-x|)~dx$

$=\int((1+x)\text{sgn}(1+x)-(1-x)\text{sgn}(1-x))~dx$

$=\dfrac{(1+x)^2\text{sgn}(1+x)+(1-x)^2\text{sgn}(1-x)}{2}+C$

$=\dfrac{(1+x)|1+x|+(1-x)|1-x|}{2}+C$

$\int\max\{1-x^2,0\}~dx$

$=\begin{cases}-\dfrac{2}{3}&\text{when}~x\leq-1\\x-\dfrac{x^3}{3}&\text{when}~-1\leq x\leq1\\\dfrac{2}{3}&\text{when}~x\geq1\end{cases}+C$