How to prove that if the integral of a nonnegative function is zero, then the function is zero This is required to prove that the expression $d(f,g)=\int|f-g|dt$ is a metric. We need to show that if $\int |f-g|dt=0$ then $f=g$. It seems obvious but how to prove it? This relation is not given in Paul's Online Math Notes for example.
f,g continuous on [a,b]
 A: If $u \ge 0$ is continuous then $$0 \le \int_a^x u(t) \, dt \le \int_a^b u(t) \, dt = 0$$ for all $x \in [a,b]$.
Write $F(x) = \displaystyle \int_a^x u(t) \, dt.$ It follows that $F$ is identically zero, and by the fundamental theorem of calculus $F'(x) = u(x)$ for all $x \in (a,b)$. Thus $u(x) = 0$ for all $x \in (a,b)$ and since  $u$ is continuous, $u(a) = u(b) = 0$ too.
A: Let's forget continuity for a minute.
Let $u$ be a measurable function that's also non-negative almost everywhere on $I=[a, b]$, such that $$\int_a^bu=0$$
Then for $\epsilon>0$,  let $$S_\epsilon=\{x\in[a,b] \textrm{  such that  } u(x)\geq\epsilon\}$$
Then by definition of $S_\epsilon$, $$\int_a^bu\geq\int_{S_\epsilon}u\geq\epsilon\mu(S_\epsilon)$$
where $\mu(S_\epsilon)$ is the Lebesgue measure of $S_\epsilon$.
That inequality $$\int_a^bu\geq\epsilon\mu(S_\epsilon)$$ is known as the Chebyshev inequality.
Because $u$ has a $0$ integral on $[a,b]$, it follows that $S_\epsilon$ is of measure $0$. So $u<\epsilon$ almost everywhere on $[a, b]$, and that, for all $\epsilon >0$. It's now easy to conclude that $u=0$ almost everywhere (for instance take the sequence $\epsilon_n=\frac 1 n$).
Now if you assume that $u$ is also continuous, that means that $u=0$ everywhere on $[a, b]$.
Finally, in the world of probabilities, this is how you prove that if a random variable has zero variance, the that variable is not that random: It is constant, almost surely.
