TITLE: How can I prove $\underbrace{\int \ldots \int}_{n} |x| dx = \frac{x^n |x|}{n+1}+C$?
QUESTION [6 upvotes]: So I was bored and decided to figure out the indefinite integral of the absolute value function, $|x|$. Using integration by parts ($u=|x|, dv=dx$, $dx = \text{sgn}(x)=\frac{|x|}{x}$), it can be shown that $\displaystyle\int |x| dx = \frac{x |x|}{2}+C$.
Now I decided to take the integral again, finding that $\displaystyle\int\left(\int |x| dx \right) dx=\frac{x^2 |x|}{3}+C$. Continuing, I found the pattern in the title, that the $n$th indefinite integral of $|x|$ is $\displaystyle\frac{x^n |x|}{n+1}+C$. Is there a way to prove this general result?

REPLY [7 votes]: Make the observation that $|x| = \theta(x) x - \theta(-x) x$ for all real $x$, where $\theta$ is the Heaviside function (evaluating to $1$ if the argument is positive and $0$ otherwise). It is known that
\begin{eqnarray}
\int \theta(x) \ x \ dx = \theta(x) \frac{x^{2}}{2} + C \quad \text{and} \quad \int \theta(-x) \ x \ dx = \theta(-x) \frac{x^{2}}{2} + C^{\prime},
\end{eqnarray}
where $C$ and $C^{\prime}$ are constants of integration. The identity for $n = 1$ follows by subtraction and the representation of $|x|$ above. With $n$ integrations, we have
\begin{eqnarray}
\int \cdots \int |x| \ dx = \theta(x) \int \cdots \int x \ dx  - \theta(-x) \int \cdots \int x \ dx = \frac{|x| x^{n}}{(n+1)!} + P_{n},
\end{eqnarray}
where $P_{n}$ is a polynomial in $x$, as claimed.