Sum of Positive and Negative Parts

Theorem
Let $X$ be a set, and let $f: X \to \overline{\R}$ be an extended real-valued function.

Let $f^+, f^-: X \to \overline{\R}$ be the positive and negative parts of $f$, respectively.

Then $\left\vert{f}\right\vert = f^+ + f^-$, where $\left\vert{f}\right\vert$ is the absolute value of $f$.

Proof
Let $x \in X$.

Suppose that $f \left({x}\right) \ge 0$, where $\ge$ signifies the extended real ordering.

Then $\left\vert{f \left({x}\right)}\right\vert = f \left({x}\right)$, and:


 * $f^+ \left({x}\right) = \max \, \left\{{f \left({x}\right), 0}\right\} = f \left({x}\right)$
 * $f^- \left({x}\right) = - \min \, \left\{{f \left({x}\right), 0}\right\} = 0$

Hence $f^+ \left({x}\right) + f^- \left({x}\right) = f \left({x}\right) = \left\vert{f \left({x}\right)}\right\vert$.

Next, suppose that $f \left({x}\right) < 0$, again in the extended real ordering.

Then $\left\vert{f \left({x}\right)}\right\vert = - f \left({x}\right)$, and:


 * $f^+ \left({x}\right) = \max \, \left\{{f \left({x}\right), 0}\right\} = 0$
 * $f^- \left({x}\right) = - \min \, \left\{{f \left({x}\right), 0}\right\} = - f \left({x}\right)$

Hence $f^+ \left({x}\right) + f^- \left({x}\right) = - f \left({x}\right) = \left\vert{f \left({x}\right)}\right\vert$.

Thus, for all $x \in X$:


 * $f^+ \left({x}\right) + f^- \left({x}\right) = \left\vert{f \left({x}\right)}\right\vert$

that is, $f^+ + f^- = \left\vert{f}\right\vert$.