# Total variation

In mathematics, the total variation identifies several slightly different concepts, related to the (local or global) structure of the codomain of a function or a measure. For a real-valued continuous function f, defined on an interval [a, b] ⊂ R, its total variation on the interval of definition is a measure of the one-dimensional arclength of the curve with parametric equation x ↦ f(x), for x ∈ [a, b]. Functions whose total variation is finite are called functions of bounded variation.

## Historical note

The concept of total variation for functions of one real variable was first introduced by Camille Jordan in the paper (Jordan 1881). He used the new concept in order to prove a convergence theorem for Fourier series of discontinuous periodic functions whose variation is bounded. The extension of the concept to functions of more than one variable however is not simple for various reasons.

## Definitions
### Total variation for functions of one real variable

Definition 1.1. The total variation of a real-valued (or more generally complex-valued) function $f$, defined on an interval $[a,b]\subset \mathbb {R}$ is the quantity
    $V_{a}^{b}(f)=\sup _{\mathcal {P}}\sum _{i=0}^{n_{P}-1}|f(x_{i+1})-f(x_{i})|,$
where the supremum runs over the set of all partitions ${\mathcal {P}}=\left\{P=\{x_{0},\dots ,x_{n_{P}}\}\mid P{\text{ is a partition of }}[a,b]\right\}$ of the given interval. Which means that $a=x_{0}<x_{1}<...<x_{n_{P}}=b$.

### Total variation for functions of n > 1 real variables

Definition 1.2. Let Ω be an open subset of R$^n$. Given a function f belonging to L$^1$(Ω), the total variation of f in Ω is defined as
    $V(f,\Omega ):=\sup \left\{\int _{\Omega }f(x)\operatorname {div} \phi (x)\,\mathrm {d} x\colon \phi \in C_{c}^{1}(\Omega ,\mathbb {R} ^{n}),\ \Vert \phi \Vert _{L^{\infty }(\Omega )}\leq 1\right\},$
where
* $C_{c}^{1}(\Omega ,\mathbb {R} ^{n})$ is the set of continuously differentiable vector functions of compact support contained in $\Omega$,
* $\Vert \;\Vert _{L^{\infty }(\Omega )}$ is the essential supremum norm, and
* $\operatorname {div}$ is the divergence operator.
This definition does not require that the domain $\Omega \subseteq \mathbb {R} ^{n}$ of the given function be a bounded set.

### Total variation in measure theory
#### Classical total variation definition

Following Saks (1937, p. 10), consider a signed measure $\mu$ on a measurable space $(X,\Sigma )$: then it is possible to define two set functions ${\overline {\mathrm {W} }}(\mu ,\cdot )$ and ${\underline {\mathrm {W} }}(\mu ,\cdot )$, respectively called upper variation and lower variation, as follows
    ${\overline {\mathrm {W} }}(\mu ,E)=\sup \left\{\mu (A)\mid A\in \Sigma {\text{ and }}A\subset E\right\}\qquad \forall E\in \Sigma$
    ${\underline {\mathrm {W} }}(\mu ,E)=\inf \left\{\mu (A)\mid A\in \Sigma {\text{ and }}A\subset E\right\}\qquad \forall E\in \Sigma$
clearly
    ${\overline {\mathrm {W} }}(\mu ,E)\geq 0\geq {\underline {\mathrm {W} }}(\mu ,E)\qquad \forall E\in \Sigma$
Definition 1.3. The variation (also called absolute variation) of the signed measure $\mu$ is the set function
    $|\mu |(E)={\overline {\mathrm {W} }}(\mu ,E)+\left|{\underline {\mathrm {W} }}(\mu ,E)\right|\qquad \forall E\in \Sigma$
and its total variation is defined as the value of this measure on the whole space of definition, i.e.
    $\|\mu \|=|\mu |(X)$

#### Modern definition of total variation norm

Saks (1937, p. 11) uses upper and lower variations to prove the Hahn–Jordan decomposition: according to his version of this theorem, the upper and lower variation are respectively a non-negative and a non-positive measure. Using a more modern notation, define
    $\mu ^{+}(\cdot )={\overline {\mathrm {W} }}(\mu ,\cdot )\,,$
    $\mu ^{-}(\cdot )=-{\underline {\mathrm {W} }}(\mu ,\cdot )\,,$
Then $\mu ^{+}$ and $\mu ^{-}$ are two non-negative measures such that
    $\mu =\mu ^{+}-\mu ^{-}$
    $|\mu |=\mu ^{+}+\mu ^{-}$
The last measure is sometimes called, by abuse of notation, total variation measure.

#### Total variation norm of complex measures

If the measure $\mu$ is complex-valued i.e. is a complex measure, its upper and lower variation cannot be defined and the Hahn–Jordan decomposition theorem can only be applied to its real and imaginary parts. However, it is possible to follow Rudin (1966, pp. 137–139) and define the total variation of the complex-valued measure $\mu$ as follows
Definition 1.4. The variation of the complex-valued measure $\mu$ is the set function
    $|\mu |(E)=\sup _{\pi }\sum _{A\in \pi }|\mu (A)|\qquad \forall E\in \Sigma$
where the supremum is taken over all partitions $\pi$ of a measurable set $E$ into a countable number of disjoint measurable subsets.
This definition coincides with the above definition $|\mu |=\mu ^{+}+\mu ^{-}$ for the case of real-valued signed measures.

#### Total variation norm of vector-valued measures

The variation so defined is a positive measure (see Rudin (1966, p. 139)) and coincides with the one defined by 1.3 when $\mu$ is a signed measure: its total variation is defined as above. This definition works also if $\mu$ is a vector measure: the variation is then defined by the following formula
    $|\mu |(E)=\sup _{\pi }\sum _{A\in \pi }\|\mu (A)\|\qquad \forall E\in \Sigma$
where the supremum is as above. This definition is slightly more general than the one given by Rudin (1966, p. 138) since it requires only to consider finite partitions of the space $X$: this implies that it can be used also to define the total variation on finite-additive measures.

#### Total variation of probability measures

The total variation of any probability measure is exactly one, therefore it is not interesting as a means of investigating the properties of such measures. However, when μ and ν are probability measures, the total variation distance of probability measures can be defined as $\|\mu -\nu \|$ where the norm is the total variation norm of signed measures. Using the property that $(\mu -\nu )(X)=0$, we eventually arrive at the equivalent definition
    $\|\mu -\nu \|=|\mu -\nu |(X)=2\sup \left\{\,\left|\mu (A)-\nu (A)\right|:A\in \Sigma \,\right\}$
and its values are non-trivial. The factor $2$ above is usually dropped (as is the convention in the article total variation distance of probability measures). Informally, this is the largest possible difference between the probabilities that the two probability distributions can assign to the same event. For a categorical distribution it is possible to write the total variation distance as follows
    $\delta (\mu ,\nu )=\sum _{x}\left|\mu (x)-\nu (x)\right|\;.$
It may also be normalized to values in $[0,1]$ by halving the previous definition as follows
    $\delta (\mu ,\nu )={\frac {1}{2}}\sum _{x}\left|\mu (x)-\nu (x)\right|$

## Basic properties
### Total variation of differentiable functions

The total variation of a $C^{1}({\overline {\Omega }})$ function $f$ can be expressed as an integral involving the given function instead of as the supremum of the functionals of definitions 1.1 and 1.2.

#### The form of the total variation of a differentiable function of one variable

Theorem 1. The total variation of a differentiable function $f$, defined on an interval $[a,b]\subset \mathbb {R}$, has the following expression if $f'$ is Riemann integrable
    $V_{a}^{b}(f)=\int _{a}^{b}|f'(x)|\mathrm {d} x$
If $f$ is differentiable and monotonic, then the above simplifies to
    $V_{a}^{b}(f)=|f(a)-f(b)|$
For any differentiable function $f$, we can decompose the domain interval $[a,b]$, into subintervals $[a,a_{1}],[a_{1},a_{2}],\dots ,[a_{N},b]$ (with $a<a_{1}<a_{2}<\cdots <a_{N}<b$) in which $f$ is locally monotonic, then the total variation of $f$ over $[a,b]$ can be written as the sum of local variations on those subintervals:
    ${\begin{aligned}V_{a}^{b}(f)&=V_{a}^{a_{1}}(f)+V_{a_{1}}^{a_{2}}(f)+\,\cdots \,+V_{a_{N}}^{b}(f)\\[0.3em]&=|f(a)-f(a_{1})|+|f(a_{1})-f(a_{2})|+\,\cdots \,+|f(a_{N})-f(b)|\end{aligned}}$

#### The form of the total variation of a differentiable function of several variables

Theorem 2. Given a $C^{1}({\overline {\Omega }})$ function $f$ defined on a bounded open set $\Omega \subseteq \mathbb {R} ^{n}$, with $\partial \Omega$ of class $C^{1}$, the total variation of $f$ has the following expression
    $V(f,\Omega )=\int _{\Omega }\left|\nabla f(x)\right|\mathrm {d} x$ .

##### Proof

The first step in the proof is to first prove an equality which follows from the Gauss–Ostrogradsky theorem.

##### Lemma

Under the conditions of the theorem, the following equality holds:
    $\int _{\Omega }f\operatorname {div} \varphi =-\int _{\Omega }\nabla f\cdot \varphi$

###### Proof of the lemma

From the Gauss–Ostrogradsky theorem:
    $\int _{\Omega }\operatorname {div} \mathbf {R} =\int _{\partial \Omega }\mathbf {R} \cdot \mathbf {n}$
by substituting $\mathbf {R} :=f\mathbf {\varphi }$, we have:
    $\int _{\Omega }\operatorname {div} \left(f\mathbf {\varphi } \right)=\int _{\partial \Omega }\left(f\mathbf {\varphi } \right)\cdot \mathbf {n}$
where $\mathbf {\varphi }$ is zero on the border of $\Omega$ by definition:
    $\int _{\Omega }\operatorname {div} \left(f\mathbf {\varphi } \right)=0$
    $\int _{\Omega }\partial _{x_{i}}\left(f\mathbf {\varphi } _{i}\right)=0$
    $\int _{\Omega }\mathbf {\varphi } _{i}\partial _{x_{i}}f+f\partial _{x_{i}}\mathbf {\varphi } _{i}=0$
    $\int _{\Omega }f\partial _{x_{i}}\mathbf {\varphi } _{i}=-\int _{\Omega }\mathbf {\varphi } _{i}\partial _{x_{i}}f$
    $\int _{\Omega }f\operatorname {div} \mathbf {\varphi } =-\int _{\Omega }\mathbf {\varphi } \cdot \nabla f$

##### Proof of the equality

Under the conditions of the theorem, from the lemma we have:
    $\int _{\Omega }f\operatorname {div} \mathbf {\varphi } =-\int _{\Omega }\mathbf {\varphi } \cdot \nabla f\leq \left|\int _{\Omega }\mathbf {\varphi } \cdot \nabla f\right|\leq \int _{\Omega }\left|\mathbf {\varphi } \right|\cdot \left|\nabla f\right|\leq \int _{\Omega }\left|\nabla f\right|$
in the last part $\mathbf {\varphi }$ could be omitted, because by definition its essential supremum is at most one.
On the other hand, we consider $\theta _{N}:=-\mathbb {I} _{\left[-N,N\right]}\mathbb {I} _{\{\nabla f\neq 0\}}{\frac {\nabla f}{\left|\nabla f\right|}}$ and $\theta _{N}^{*}$ which is the up to $\varepsilon$ approximation of $\theta _{N}$ in $C_{c}^{1}$ with the same integral. We can do this since $C_{c}^{1}$ is dense in $L^{1}$. Now again substituting into the lemma:
    ${\begin{aligned}&\lim _{N\to \infty }\int _{\Omega }f\operatorname {div} \theta _{N}^{*}\\[4pt]&=\lim _{N\to \infty }\int _{\{\nabla f\neq 0\}}\mathbb {I} _{\left[-N,N\right]}\nabla f\cdot {\frac {\nabla f}{\left|\nabla f\right|}}\\[4pt]&=\lim _{N\to \infty }\int _{\left[-N,N\right]\cap {\{\nabla f\neq 0\}}}\nabla f\cdot {\frac {\nabla f}{\left|\nabla f\right|}}\\[4pt]&=\int _{\Omega }\left|\nabla f\right|\end{aligned}}$
This means we have a convergent sequence of ∫$_Ω$fdiv⁡φ{\textstyle \int _{\Omega }f\operatorname {div} \mathbf {\varphi } } that tends to ∫$_Ω$|∇f|{\textstyle \int _{\Omega }\left|\nabla f\right|} as well as we know that ∫$_Ω$fdiv⁡φ≤∫$_Ω$|∇f|{\textstyle \int _{\Omega }f\operatorname {div} \mathbf {\varphi } \leq \int _{\Omega }\left|\nabla f\right|}. Q.E.D.
It can be seen from the proof that the supremum is attained when
    $\varphi \to {\frac {-\nabla f}{\left|\nabla f\right|}}.$
The function $f$ is said to be of bounded variation precisely if its total variation is finite.

### Total variation of a measure

The total variation is a norm defined on the space of measures of bounded variation. The space of measures on a σ-algebra of sets is a Banach space, called the ca space, relative to this norm. It is contained in the larger Banach space, called the ba space, consisting of finitely additive (as opposed to countably additive) measures, also with the same norm. The distance function associated to the norm gives rise to the total variation distance between two measures μ and ν.
For finite measures on R, the link between the total variation of a measure μ and the total variation of a function, as described above, goes as follows. Given μ, define a function $\varphi \colon \mathbb {R} \to \mathbb {R}$ by
    $\varphi (t)=\mu ((-\infty ,t])~.$
Then, the total variation of the signed measure μ is equal to the total variation, in the above sense, of the function $\varphi$. In general, the total variation of a signed measure can be defined using Jordan's decomposition theorem by
    $\|\mu \|_{TV}=\mu _{+}(X)+\mu _{-}(X)~,$
for any signed measure μ on a measurable space $(X,\Sigma )$.

## Applications

Total variation can be seen as a non-negative real-valued functional defined on the space of real-valued functions (for the case of functions of one variable) or on the space of integrable functions (for the case of functions of several variables). As a functional, total variation finds applications in several branches of mathematics and engineering, like optimal control, numerical analysis, and calculus of variations, where the solution to a certain problem has to minimize its value. As an example, use of the total variation functional is common in the following two kind of problems
* Numerical analysis of differential equations: it is the science of finding approximate solutions to differential equations. Applications of total variation to these problems are detailed in the article "total variation diminishing"
* Image denoising: in image processing, denoising is a collection of methods used to reduce the noise in an image reconstructed from data obtained by electronic means, for example data transmission or sensing. "Total variation denoising" is the name for the application of total variation to image noise reduction; further details can be found in the papers of (Rudin, Osher & Fatemi 1992) and (Caselles, Chambolle & Novaga 2007). A sensible extension of this model to colour images, called Colour TV, can be found in (Blomgren & Chan 1998).