Signed area under a graph (source code)

= Signed area under a graph
{title2=$\int_a^b f(x)\,dx$}

= Net signed area
{synonym}

For $a<b$ and a <real-valued function> $f$ with a finite <Riemann integral> or <Lebesgue integral> on $[a,b]$, the <signed area under a graph> is its <definite integral>: geometric <area> above the horizontal axis contributes positively, and geometric <area> below it contributes negatively. If these two nonnegative <areas> are $A_+$ and $A_-$, then
$$
\int_a^b f(x)\,dx=A_+-A_-,\qquad
\int_a^b |f(x)|\,dx=A_++A_-.
$$
The second expression is the <total geometric area under a graph>. Taking the <absolute value> of the first expression does not usually give the second: cancellation has already removed information about how much <area> lies on each side.<Calculus Volume 1 by Gilbert Strang and others/5.2 The Definite Integral>{ref}

For an exact example, take the <polynomial function> $f(x)=x^2-1$ on $[-2,2]$. Its <polynomial roots> are $-1$ and $1$: it is negative between them and positive on the two outer <intervals>. An <antiderivative> is $F(x)=x^3/3-x$, so the <fundamental theorem of calculus> gives
$$
\int_{-2}^{-1}(x^2-1)\,dx=\frac43,\qquad
\int_{-1}^{1}(x^2-1)\,dx=-\frac43,\qquad
\int_{1}^{2}(x^2-1)\,dx=\frac43.
$$
Thus $A_+=8/3$ and $A_-=4/3$. The <signed area under a graph> is $4/3$, whereas the <total geometric area under a graph> is $4$. To compute the latter with <antiderivatives>, split at each sign-changing <polynomial root> and reverse the sign of the negative contribution.

\Image[/signed-polynomial-area-and-absolute-area.png]
{title=The polynomial x squared minus one has signed integral 4/3 and total geometric area 4 on the interval from minus two to two}
{id=signed-polynomial-area-and-absolute-area}

Cancellation is useful information when the <integrand> represents a signed contribution. For the <polynomial function> $f(x)=x$ on $[-1,1]$, the two triangular <areas> give $\int_{-1}^1x\,dx=0$, although $\int_{-1}^1|x|\,dx=1$. Zero <net signed area> therefore means balanced positive and negative contributions, rather than an empty region.

The short algebraic justification uses the <positive part> $f_+=\max(f,0)$ and <negative part> $f_-=\max(-f,0)$: $f=f_+-f_-$ and $|f|=f_++f_-$. Their <integrals> give $A_+$ and $A_-$, and <linearity of integration> gives the difference and sum formulas. For <Lebesgue integration>, require both contributions to be finite to avoid the undefined subtraction $\infty-\infty$.<18.102 Introduction to Functional Analysis, Spring 2021 (lecture notes) by Andrew Lin/Lecture 12: Lebesgue Integrable Functions, the Lebesgue Integral and the Dominated Convergence Theorem>[Definitions 120–121 and Proposition 122]{ref}