# Mean value theorem

In mathematics, the mean value theorem (or Lagrange's mean value theorem) states, roughly, that for a given planar arc between two endpoints, there is at least one point at which the tangent to the arc is parallel to the secant through its endpoints. It is one of the most important results in real analysis. This theorem is used to prove statements about a function on an interval starting from local hypotheses about derivatives at points of the interval.

## History

A special case of this theorem for inverse interpolation of the sine was first described by Parameshvara (1380–1460), from the Kerala School of Astronomy and Mathematics in India, in his commentaries on Govindasvāmi and Bhāskara II. A restricted form of the theorem was proved by Michel Rolle in 1691; the result was what is now known as Rolle's theorem, and was proved only for polynomials, without the techniques of calculus. The mean value theorem in its modern form was stated and proved by Augustin Louis Cauchy in 1823. Many variations of this theorem have been proved since then.

## Statement

Let $f:[a,b]\to \mathbb {R}$ be a continuous function on the closed interval $[a,b]$, and differentiable on the open interval $(a,b)$, where $a<b$. Then there exists some $c$ in $(a,b)$ such that:
    $f'(c)={\frac {f(b)-f(a)}{b-a}}.$
The mean value theorem is a generalization of Rolle's theorem, which assumes $f(a)=f(b)$, so that the right-hand side above is zero.
The mean value theorem is still valid in a slightly more general setting. One only needs to assume that $f:[a,b]\to \mathbb {R}$ is continuous on $[a,b]$, and that for every $x$ in $(a,b)$ the limit
    $\lim _{h\to 0}{\frac {f(x+h)-f(x)}{h}}$
exists as a finite number or equals $\infty$ or $-\infty$. If finite, that limit equals $f'(x)$. An example where this version of the theorem applies is given by the real-valued cube root function mapping $x\mapsto x^{1/3}$, whose derivative tends to infinity at the origin.

### Proof

The expression f(b)−f(a)/b−a {\textstyle {\frac {f(b)-f(a)}{b-a}}} gives the slope of the line joining the points $(a,f(a))$ and $(b,f(b))$, which is a chord of the graph of $f$, while $f'(x)$ gives the slope of the tangent to the curve at the point $(x,f(x))$. Thus the mean value theorem says that given any chord of a smooth curve, we can find a point on the curve lying between the end-points of the chord such that the tangent of the curve at that point is parallel to the chord. The following proof illustrates this idea.
Define $g(x)=f(x)-rx$, where $r$ is a constant. Since $f$ is continuous on $[a,b]$ and differentiable on $(a,b)$, the same is true for $g$. We now want to choose $r$ so that $g$ satisfies the conditions of Rolle's theorem. Namely
    ${\begin{aligned}g(a)=g(b)&\iff f(a)-ra=f(b)-rb\\&\iff r(b-a)=f(b)-f(a)\\&\iff r={\frac {f(b)-f(a)}{b-a}}.\end{aligned}}$
By Rolle's theorem, since $g$ is differentiable and $g(a)=g(b)$, there is some $c$ in $(a,b)$ for which $g'(c)=0$ , and it follows from the equality $g(x)=f(x)-rx$ that,
    ${\begin{aligned}&g'(x)=f'(x)-r\\&g'(c)=0\\&g'(c)=f'(c)-r=0\\&\Rightarrow f'(c)=r={\frac {f(b)-f(a)}{b-a}}\end{aligned}}$

## Implications

Theorem 1: Assume that $f$ is a continuous, real-valued function, defined on an arbitrary interval $I$ of the real line. If the derivative of $f$ at every interior point of the interval $I$ exists and is zero, then $f$ is constant in the interior.
Proof: Assume the derivative of $f$ at every interior point of the interval $I$ exists and is zero. Let $(a,b)$ be an arbitrary open interval in $I$. By the mean value theorem, there exists a point $c$ in $(a,b)$ such that
    $0=f'(c)={\frac {f(b)-f(a)}{b-a}}.$
This implies that $f(a)=f(b)$. Thus, $f$ is constant on the interior of $I$ and thus is constant on $I$ by continuity. (See below for a multivariable version of this result.)
Remarks:
* Only continuity of $f$, not differentiability, is needed at the endpoints of the interval $I$. No hypothesis of continuity needs to be stated if $I$ is an open interval, since the existence of a derivative at a point implies the continuity at this point. (See the section continuity and differentiability of the article derivative.)
* The differentiability of $f$ can be relaxed to one-sided differentiability, a proof is given in the article on semi-differentiability.
Theorem 2: If $f'(x)=g'(x)$ for all $x$ in an interval $(a,b)$ of the domain of these functions, then $f-g$ is constant, i.e. $f=g+c$ where $c$ is a constant on $(a,b)$.
Proof: Let $F(x)=f(x)-g(x)$, then $F'(x)=f'(x)-g'(x)=0$ on the interval $(a,b)$, so the above theorem 1 tells that $F(x)=f(x)-g(x)$ is a constant $c$ or $f=g+c$.
Theorem 3: If $F$ is an antiderivative of $f$ on an interval $I$, then the most general antiderivative of $f$ on $I$ is $F(x)+c$ where $c$ is a constant.
Proof: It directly follows from the theorem 2 above.

## Cauchy's mean value theorem

Cauchy's mean value theorem, also known as the extended mean value theorem, is a generalization of the mean value theorem. It states: if the functions $f$ and $g$ are both continuous on the closed interval $[a,b]$ and differentiable on the open interval $(a,b)$, then there exists some $c\in (a,b)$, such that
    $(f(b)-f(a))g'(c)=(g(b)-g(a))f'(c).$
Of course, if $g(a)\neq g(b)$ and $g'(c)\neq 0$, this is equivalent to:
    ${\frac {f'(c)}{g'(c)}}={\frac {f(b)-f(a)}{g(b)-g(a)}}.$
Geometrically, this means that there is some tangent to the graph of the curve
    ${\begin{cases}[a,b]\to \mathbb {R} ^{2}\\t\mapsto (f(t),g(t))\end{cases}}$
which is parallel to the line defined by the points $(f(a),g(a))$ and $(f(b),g(b))$. However, Cauchy's theorem does not claim the existence of such a tangent in all cases where $(f(a),g(a))$ and $(f(b),g(b))$ are distinct points, since it might be satisfied only for some value $c$ with $f'(c)=g'(c)=0$, in other words a value for which the mentioned curve is stationary; in such points no tangent to the curve is likely to be defined at all. An example of this situation is the curve given by
    $t\mapsto \left(t^{3},1-t^{2}\right),$
which on the interval $[-1,1]$ goes from the point $(-1,0)$ to $(1,0)$, yet never has a horizontal tangent; however it has a stationary point (in fact a cusp) at $t=0$.
Cauchy's mean value theorem can be used to prove L'Hôpital's rule. The mean value theorem is the special case of Cauchy's mean value theorem when $g(t)=t$.

### Proof

The proof of Cauchy's mean value theorem is based on the same idea as the proof of the mean value theorem.
Define $h(x)=(g(b)-g(a))f(x)-(f(b)-f(a))g(x)$, then we easily see $h(a)=h(b)=f(a)g(b)-f(b)g(a)$.
Since $f$ and $g$ are continuous on $[a,b]$ and differentiable on $(a,b)$, the same is true for $h$. All in all, $h$ satisfies the conditions of Rolle's theorem. Consequently, there is some $c$ in $(a,b)$ for which $h'(c)=0$. Now using the definition of $h$ we have:
    $0=h'(c)=(g(b)-g(a))f'(c)-(f(b)-f(a))g'(c)$
The result easily follows.

## Mean value theorem in several variables

The mean value theorem generalizes to real functions of multiple variables. The trick is to use parametrization to create a real function of one variable, and then apply the one-variable theorem.
Let $G$ be an open subset of $\mathbb {R} ^{n}$, and let $f:G\to \mathbb {R}$ be a differentiable function. Fix points $x,y\in G$ such that the line segment between $x,y$ lies in $G$, and define $g(t)=f{\big(1-t)x+ty{\big )}$. Since $g$ is a differentiable function in one variable, the mean value theorem gives:
    $g(1)-g(0)=g'(c)$
for some $c$ between 0 and 1. But since $g(1)=f(y)$ and $g(0)=f(x)$, computing $g'(c)$ explicitly we have:
    $f(y)-f(x)=\nabla f{\big(1-c)x+cy{\big )}\cdot (y-x)$
where $\nabla$ denotes a gradient and $\cdot$ a dot product. This is an exact analog of the theorem in one variable (in the case $n=1$ this is the theorem in one variable). By the Cauchy–Schwarz inequality, the equation gives the estimate:
    ${\Bigl |}f(y)-f(x){\Bigr |}\leq {\Bigl |}\nabla f{\big(1-c)x+cy{\big )}{\Bigr |}\ {\Bigl |}y-x{\Bigr |}.$
In particular, when $G$ is convex and the partial derivatives of $f$ are bounded, $f$ is Lipschitz continuous (and therefore uniformly continuous).
As an application of the above, we prove that $f$ is constant if the open subset $G$ is connected and every partial derivative of $f$ is 0. Pick some point $x_{0}\in G$, and let $g(x)=f(x)-f(x_{0})$. We want to show $g(x)=0$ for every $x\in G$. For that, let $E=\{x\in G:g(x)=0\}$. Then $E$ is closed in $G$ and nonempty. It is open too: for every $x\in E$ ,
    ${\Big |}g(y){\Big |}={\Big |}g(y)-g(x){\Big |}\leq (0){\Big |}y-x{\Big |}=0$
for every $y$ in open ball centered at $x$ and contained in $G$. Since $G$ is connected, we conclude $E=G$.
The above arguments are made in a coordinate-free manner; hence, they generalize to the case when $G$ is a subset of a Banach space.

## Mean value theorem for vector-valued functions

There is no exact analog of the mean value theorem for vector-valued functions (see below). However, there is an inequality which can be applied to many of the same situations to which the mean value theorem is applicable in the one dimensional case:
Theorem — For a continuous vector-valued function $\mathbf {f} :[a,b]\to \mathbb {R} ^{k}$ differentiable on $(a,b)$, there exists a number $c\in (a,b)$ such that
    $|\mathbf {f} (b)-\mathbf {f} (a)|\leq (b-a)\left|\mathbf {f} '(c)\right|$.
Take $\varphi (t)=({\textbf {f}}(b)-{\textbf {f}}(a))\cdot {\textbf {f}}(t)$. Then $\varphi$ is real-valued and thus, by the mean value theorem,
    $\varphi (b)-\varphi (a)=\varphi '(c)(b-a)$
for some $c\in (a,b)$. Now, $\varphi (b)-\varphi (a)=|{\textbf {f}}(b)-{\textbf {f}}(a)|^{2}$ and $\varphi '(c)=({\textbf {f}}(b)-{\textbf {f}}(a))\cdot {\textbf {f}}'(c).$ Hence, using the Cauchy–Schwarz inequality, from the above equation, we get:
    $|{\textbf {f}}(b)-{\textbf {f}}(a)|^{2}\leq |{\textbf {f}}(b)-{\textbf {f}}(a)||{\textbf {f}}'(c)|(b-a).$
If ${\textbf {f}}(b)={\textbf {f}}(a)$, the theorem holds trivially. Otherwise, dividing both sides by $|{\textbf {f}}(b)-{\textbf {f}}(a)|$ yields the theorem.

### Mean value inequality

Jean Dieudonné in his classic treatise Foundations of Modern Analysis discards the mean value theorem and replaces it by mean inequality as the proof is not constructive and one cannot find the mean value and in applications one only needs mean inequality. Serge Lang in Analysis I uses the mean value theorem, in integral form, as an instant reflex but this use requires the continuity of the derivative. If one uses the Henstock–Kurzweil integral one can have the mean value theorem in integral form without the additional assumption that derivative should be continuous as every derivative is Henstock–Kurzweil integrable.
The reason why there is no analog of mean value equality is the following: If f : U → R$^m$ is a differentiable function (where U ⊂ R$^n$ is open) and if x + th, x, h ∈ R$^n$, t ∈ [0, 1] is the line segment in question (lying inside U), then one can apply the above parametrization procedure to each of the component functions f$_i$ (i = 1, …, m) of f (in the above notation set y = x + h). In doing so one finds points x + t$_i$h on the line segment satisfying
    $f_{i}(x+h)-f_{i}(x)=\nabla f_{i}(x+t_{i}h)\cdot h.$
But generally there will not be a single point x + t*h on the line segment satisfying
    $f_{i}(x+h)-f_{i}(x)=\nabla f_{i}(x+t^{*}h)\cdot h.$
for all i simultaneously. For example, define:
    ${\begin{cases}f:[0,2\pi ]\to \mathbb {R} ^{2}\\f(x)=(\cos(x),\sin(x))\end{cases}}$
Then $f(2\pi )-f(0)=\mathbf {0} \in \mathbb {R} ^{2}$, but $f_{1}'(x)=-\sin(x)$ and $f_{2}'(x)=\cos(x)$ are never simultaneously zero as $x$ ranges over $\left[0,2\pi \right]$.
The above theorem implies the following:
Mean value inequality — For a continuous function ${\textbf {f}}:[a,b]\to \mathbb {R} ^{k}$, if ${\textbf {f}}$ is differentiable on $(a,b)$, then
    $|{\textbf {f}}(b)-{\textbf {f}}(a)|\leq (b-a)\sup _{(a,b)}|{\textbf {f}}'|$.
In fact, the above statement suffices for many applications and can be proved directly as follows. (We shall write $f$ for ${\textbf {f}}$ for readability.)
First assume $f$ is differentiable at $a$ too. If $f'$ is unbounded on $(a,b)$, there is nothing to prove. Thus, assume $\sup _{(a,b)}|f'|<\infty$. Let $M>\sup _{(a,b)}|f'|$ be some real number. Let $E=\{0\leq t\leq 1\mid |f(a+t(b-a))-f(a)|\leq Mt(b-a)\}.$ We want to show $1\in E$. By continuity of $f$, the set $E$ is closed. It is also nonempty as $0$ is in it. Hence, the set $E$ has the largest element $s$. If $s=1$, then $1\in E$ and we are done. Thus suppose otherwise. For $1>t>s$,
    ${\begin{aligned}&|f(a+t(b-a))-f(a)|\\&\leq |f(a+t(b-a))-f(a+s(b-a))-f'(a+s(b-a))(t-s)(b-a)|+|f'(a+s(b-a))|(t-s)(b-a)\\&+|f(a+s(b-a))-f(a)|.\end{aligned}}$
Let $\epsilon >0$ be such that $M-\epsilon >\sup _{(a,b)}|f'|$. By the differentiability of $f$ at $a+s(b-a)$ (note $s$ may be 0), if $t$ is sufficiently close to $s$, the first term is $\leq \epsilon (t-s)(b-a)$. The second term is $\leq (M-\epsilon )(t-s)(b-a)$. The third term is $\leq Ms(b-a)$. Hence, summing the estimates up, we get: $|f(a+t(b-a))-f(a)|\leq tM|b-a|$, a contradiction to the maximality of $s$. Hence, $1=s\in M$ and that means:
    $|f(b)-f(a)|\leq M(b-a).$
Since $M$ is arbitrary, this then implies the assertion. Finally, if $f$ is not differentiable at $a$, let $a'\in (a,b)$ and apply the first case to $f$ restricted on $[a',b]$, giving us:
    $|f(b)-f(a')|\leq (b-a')\sup _{(a,b)}|f'|$
since $(a',b)\subset (a,b)$. Letting $a'\to a$ finishes the proof.

## Cases where the theorem cannot be applied

All conditions for the mean value theorem are necessary:
* ${\boldsymbol {f(x)}}$ is differentiable on ${\boldsymbol {(a,b)}}$
* ${\boldsymbol {f(x)}}$ is continuous on ${\boldsymbol {[a,b]}}$
* ${\boldsymbol {f(x)}}$ is real-valued
When one of the above conditions is not satisfied, the mean value theorem is not valid in general, and so it cannot be applied.
The necessity of the first condition can be seen by the counterexample where the function $f(x)=|x|$ on [-1,1] is not differentiable.
The necessity of the second condition can be seen by the counterexample where the function $f(x)={\begin{cases}1,&{\text{at }}x=0\\0,&{\text{if }}x\in (0,1]\end{cases}}$ satisfies criteria 1 since $f'(x)=0$ on $(0,1)$ but not criteria 2 since ${\frac {f(1)-f(0)}{1-0}}=-1$ and $-1\neq 0=f'(x)$ for all $x\in (0,1)$ so no such $c$ exists.
The theorem is false if a differentiable function is complex-valued instead of real-valued. For example, if $f(x)=e^{xi}$ for all real $x$, then $f(2\pi )-f(0)=0=0(2\pi -0)$ while $f'(x)\neq 0$ for any real $x$.

## Mean value theorems for definite integrals
### First mean value theorem for definite integrals

Let f : [a, b] → R be a continuous function. Then there exists c in (a, b) such that
    $\int _{a}^{b}f(x)\,dx=f(c)(b-a).$
This follows at once from the fundamental theorem of calculus, together with the mean value theorem for derivatives. Since the mean value of f on [a, b] is defined as
    ${\frac {1}{b-a}}\int _{a}^{b}f(x)\,dx,$
we can interpret the conclusion as f achieves its mean value at some c in (a, b).
In general, if f : [a, b] → R is continuous and g is an integrable function that does not change sign on [a, b], then there exists c in (a, b) such that
    $\int _{a}^{b}f(x)g(x)\,dx=f(c)\int _{a}^{b}g(x)\,dx.$

### Second mean value theorem for definite integrals

There are various slightly different theorems called the second mean value theorem for definite integrals. A commonly found version is as follows:
    If $G:[a,b]\to \mathbb {R}$ is a positive monotonically decreasing function and $\varphi :[a,b]\to \mathbb {R}$ is an integrable function, then there exists a number x in (a, b] such that
       $\int _{a}^{b}G(t)\varphi (t)\,dt=G(a^{+})\int _{a}^{x}\varphi (t)\,dt.$
Here $G(a^{+})$ stands for lim$_{x→a+}$G(x){\textstyle {\lim _{x\to a^{+}}G(x)}}, the existence of which follows from the conditions. Note that it is essential that the interval (a, b] contains b. A variant not having this requirement is:
    If $G:[a,b]\to \mathbb {R}$ is a monotonic (not necessarily decreasing and positive) function and $\varphi :[a,b]\to \mathbb {R}$ is an integrable function, then there exists a number x in (a, b) such that
       $\int _{a}^{b}G(t)\varphi (t)\,dt=G(a^{+})\int _{a}^{x}\varphi (t)\,dt+G(b^{-})\int _{x}^{b}\varphi (t)\,dt.$
If the function $G$ returns a multi-dimensional vector, then the MVT for integration is not true, even if the domain of $G$ is also multi-dimensional.
For example, consider the following 2-dimensional function defined on an $n$-dimensional cube:
    ${\begin{cases}G:[0,2\pi ]^{n}\to \mathbb {R} ^{2}\\G(x_{1},\dots ,x_{n})=\left(\sin(x_{1}+\cdots +x_{n}),\cos(x_{1}+\cdots +x_{n})\right)\end{cases}}$
Then, by symmetry it is easy to see that the mean value of $G$ over its domain is (0,0):
    $\int _{[0,2\pi ]^{n}}G(x_{1},\dots ,x_{n})dx_{1}\cdots dx_{n}=(0,0)$
However, there is no point in which $G=(0,0)$, because $|G|=1$ everywhere.

## Generalizations
### Linear algebra

Assume that $f,g,$ and $h$ are differentiable functions on $(a,b)$ that are continuous on $[a,b]$. Define
    $D(x)={\begin{vmatrix}f(x)&g(x)&h(x)\\f(a)&g(a)&h(a)\\f(b)&g(b)&h(b)\end{vmatrix}}$
There exists $c\in (a,b)$ such that $D'(c)=0$.
Notice that
    $D'(x)={\begin{vmatrix}f'(x)&g'(x)&h'(x)\\f(a)&g(a)&h(a)\\f(b)&g(b)&h(b)\end{vmatrix}}$
and if we place $h(x)=1$, we get Cauchy's mean value theorem. If we place $h(x)=1$ and $g(x)=x$ we get Lagrange's mean value theorem.
The proof of the generalization is quite simple: each of $D(a)$ and $D(b)$ are determinants with two identical rows, hence $D(a)=D(b)=0$. The Rolle's theorem implies that there exists $c\in (a,b)$ such that $D'(c)=0$.

### Probability theory

Let X and Y be non-negative random variables such that E[X] < E[Y] < ∞ and $X\leq _{st}Y$ (i.e. X is smaller than Y in the usual stochastic order). Then there exists an absolutely continuous non-negative random variable Z having probability density function
    $f_{Z}(x)={\Pr(Y>x)-\Pr(X>x) \over {\rm {E}}[Y]-{\rm {E}}[X]}\,,\qquad x\geqslant 0.$
Let g be a measurable and differentiable function such that E[g(X)], E[g(Y)] < ∞, and let its derivative g′ be measurable and Riemann-integrable on the interval [x, y] for all y ≥ x ≥ 0. Then, E[g′(Z)] is finite and
    ${\rm {E}}[g(Y)]-{\rm {E}}[g(X)]={\rm {E}}[g'(Z)]\,[{\rm {E}}(Y)-{\rm {E}}(X)].$

### Complex analysis

As noted above, the theorem does not hold for differentiable complex-valued functions. Instead, a generalization of the theorem is stated such:
Let f : Ω → C be a holomorphic function on the open convex set Ω, and let a and b be distinct points in Ω. Then there exist points u, v on the interior of the line segment from a to b such that
    $\operatorname {Re} (f'(u))=\operatorname {Re} \left({\frac {f(b)-f(a)}{b-a}}\right),$
    $\operatorname {Im} (f'(v))=\operatorname {Im} \left({\frac {f(b)-f(a)}{b-a}}\right).$
Where Re is the real part and Im is the imaginary part of a complex-valued function.