Calculating the $L^1$-norm of a piecewise linear and continuous function

analysisapproximationintegrationreal-analysisspline

Let $0 = x_0 < x_1 < \dots x_n =1 $ (e.g. the $x_i$'s are equidistantly distributed) and $c_0, c_1, \dots, c_n \in \mathbb R$. Let $f : [0,1] \to \mathbb R$ be the unique continuous, piecewise linear function such that $f(x_i)=c_i$ for all $i$. I want to calculate the $L^1$ norm of $f$, i.e. the value
$$
I = \int_0^1|f(t)| \, dt.
$$

Is there an easy and direct formula for $I$ in terms of the $x_i$'s and $c_i$'s?

Thanks in advance

Best Answer

You can split up the integral by using $\int_a^c f(x)dx = \int_a^b f(x)dx + \int_b^c f(x)dx$:

$$\int_0^1|f(t)| \, dt = \sum_{i=0}^{n-1} \int_{x_i}^{x_{i+1}} |f(t)| \, dt.$$

The part $\int_{x_i}^{x_{i+1}} |f(t)| \, dt$ is simple if both $c_i$ and $c_{i+1}$ have the same sign, because then this integral is just the average height multiplied with the width: $\int_{x_i}^{x_{i+1}} |f(t)| \, dt=0.5|c_i+c_{i+1}|(x_{i+1}-x_i)$.

If $c_i$ and $c_{i+1}$ have opposing signs, then $\int_{x_i}^{x_{i+1}} |f(t)| \, dt$ is the area of two triangles. The first triangle has width $(x_{i+1}-x_i)|c_i|/(|c_i|+|c_{i+1}|)$ and height $|c_i|$, the other triangle has width $(x_{i+1}-x_i)|c_{i+1}|/(|c_i|+|c_{i+1}|)$ and height $|c_{i+1}|$, resulting in: $$\int_{x_i}^{x_{i+1}} |f(t)| \, dt = 0.5(x_{i+1}-x_i)\frac{|c_i|^2+|c_{i+1}|^2}{(|c_i|+|c_{i+1}|)}.$$ The factor $(|c_i|^2 + |c_{i+1}|^2) / (|c_i| + |c_{i+1}|)$ simplifies to: \begin{align} ((c_i - c_{i+1})^2 + 2c_i c_{i+1}) / |c_i - c_{i+1}| &= |c_i - c_{i+1}|+2c_i c_{i+1} / |c_i - c_{i+1}| \\ &= |c_i| + |c_{i+1}|+2c_i c_{i+1} / |c_i - c_{i+1}| \end{align} The first two terms appear in the 'same sign' formula (as $|c_i + c_{i+1}|$) and the last term is negative. The formulas can therefore be combined into: $$\int_0^1|f(t)| \, dt = \sum_{i=0}^{n-1} 0.5(x_{i+1}-x_i) \left(|c_i| + |c_{i+1}| + \min\left\{0, 2c_i c_{i+1} / |c_i - c_{i+1}|\right\}\right).$$

Related Question