Skip to main content

Section 7 Continuity: intermediate value theorem

Subsection Continuity of piecewise defined functions

As you may have gathered by now, most of the functions that we write down via formula are essentially automatically continuous. This is a formal consequence of Theorem 6.10–6.12. Since most formulas we use are built up using some basic continuous functions (polynomials, rational functions, trig functions), and some operations that preserve continuity (sum, product, quotient,etc.), it follows that such formulas end up defining continuous functions.
In this sense it is actually somewhat difficult to write down a discontinuous function, at least if we restrict ourselves to using formulas of the type described above. Piecewise-defined functions give us an easy way of getting around this issue, providing us with a useful source of functions that potentially have discontinuities. Of course, being defined in a piecewise manner does not guarantee the existence of a continuity; consider for the example the absolute value function \(f(x)=\abs{x}\text{,}\) which is continuous, but defined piecewise as
\begin{equation*} \abs{x}=\begin{cases} x \amp x\geq 0\\ -x \amp x< 0 \end{cases}\text{.} \end{equation*}
The example below illustrates in general how we determine whether a piecewise-defined function is continuous at various inputs.

Example 7.1. Continuity: piecewise.

Let \(f\colon \R\rightarrow \R\) be defined as
\begin{equation*} f(x)=\begin{cases} c^2x \amp \text{if } x< 1\\ 3cx-2 \amp \text{if } x\geq 1 \end{cases}\text{,} \end{equation*}
where \(c\in \R\) is a fixed constant.
  1. Argue that \(f\) is continuous at all inputs \(a\ne 1\text{.}\)
  2. Find all values of \(c\) for which \(f\) is continuous at the input \(1\text{,}\) and hence everywhere.
Solution.
  1. Take any \(a\in \R\) with \(a\ne 1\text{.}\)
    If \(a< 1\text{,}\) then \(f(x)=cx^2\) for inputs near \(a\text{.}\) Since \(g(x)=cx^2\) is a polynomial, and since polynomials are continuous on their domain, it follows that \(f\) is continuous at \(a\text{.}\)
    Similarly, if \(a\geq 1\text{,}\) then \(f(x)=3cx-2\) for inputs \(x\) near \(a\text{.}\) Again since \(h(x)=3cx-2\) is a polynomial, it is continuous at all such inputs, and hence also at \(a\text{.}\)
    This shows that \(f\) is continuous at \(a\) for all \(a\ne 1\text{,}\) no matter what the value of \(c\text{.}\)
  2. We use the definition of continuity to see what \(c\) must satisfy for \(f\) to be differentiable at \(1\text{.}\) Namely, this is true if and only if
    1. \(\lim\limits_{x\to 1}f(x)\) exists, and further
    2. \(\displaystyle \lim\limits_{x\to 1}f(x)=f(1)\)
    Condition (i) holds if and only if \(\lim\limits_{x\to 1^-}f(x)=\lim\limits_{x\to 1^-}f(x)\text{.}\) We compute both one-sided limits:
    \begin{align*} \lim\limits_{x\to 1^-}f(x) \amp = \lim\limits_{x\to 1^-}c^2x \amp (\text{def., } x< 1)\\ \amp c^2 \amp \text{(poly. eval.)} \\ \lim\limits_{x\to 1^+}f(x) \amp = \lim\limits_{x\to 1^+}3cx-2 \amp (\text{def., } x> 1)\\ \amp 3c-2\amp \text{(poly. eval.)} \text{.} \end{align*}
    We see that (i) is satisfied if and only if \(c^2=3c-2\text{,}\) or
    \begin{equation*} c^2-3c+2=0\text{,} \end{equation*}
    which is true if and only if \(c=1\) or \(c=2\text{.}\)
    It remains to determine which choices of \(c\) guarantee condition (ii). We claim that both work: indeed, since both \(c=1\) and \(c=2\) guarantee that \(\lim\limits_{x\to 1 }f(x)=c^2=3c-2\text{,}\) and since \(f(1)=3c-2\) using the piecewise definition, we conclude that for both choices of \(c\) we have \(\lim\limits_{x\to 1}f(x)=f(1)=3c-2\text{,}\) as desired.
The figure below shows the resulting graph for \(f\text{,}\) taking \(c=1\) and \(c=2\text{.}\) You can think of condition (i) as guaranteeing that our two linear segments join up correctly at \(x=1\text{.}\)
Graph of piecewise-defined function
(a) \(c=1\)
Graph of piecewise-defined function
(b) \(c=2\)
Figure 7.2. Graphs of \(f\text{:}\) \(c=1\) and \(c=2\)

Subsection Intermediate value theorem

Recall the cute informal description of a continuous function as one whose graph can be traced without lifting your pencil. This can be further interpreted as saying that as we trace a segment of the graph lying over some interval in the \(x\)-axis, it should not be possible to “skip” over a particular \(y\)-value. Indeed, to skip this value, we would have to lift our pencil. This seems plausible, starting from our cutesy informal description of continuity, but can we prove it rigorously? Yes, we can as witnessed by the intermediate value theorem.

Remark 7.4. IVT and existence of solutions.

A common application of the IVT is to prove that an equation of the form \(f(x)=d\) has a solution in a given open interval \((a,b)\text{.}\) Indeed, if \(f\) is continuous on \([a,b]\text{,}\) and if \(d\) lies strictly between \(f(a)\) and \(f(b)\text{,}\) then the IVT guarantees the existence of an element \(c\in (a,b)\) satisfying \(f(c)=d\text{.}\)
Interestingly, however, this method does not actually provide the solution \(c\text{;}\) it only tells us that it exists. This is probably the first time you have encountered what is called a “nonconstructive proof” in mathematics. The theorem tells us that the value \(c\) exists (assuming the necessary conditions hold), but does not explicitly tell us what \(c\) is.

Example 7.5. Sine equation.

Prove that the equation \(\sin x=\frac{7}{8}\) has a solution that lies in the interval \((\pi/6, \pi/2)\text{.}\)
Solution.
Note that \(\sin\) is continuous on \([\pi/6, \pi/2]\text{,}\) and that
\begin{align*} \sin(\pi/6) \amp = \frac{1}{2}\\ \sin(\pi/2) \amp = 1\text{.} \end{align*}
Since \(\frac{1}{2}< \frac{7}{8}< 1\text{,}\) the IVT implies that for every there is an input \(c\in (\pi/6, \pi/2)\) such that \(f(c)=7/8\text{.}\) In other words, the given equation has a solution lying in the interval \((\pi/6, \pi/2)\text{.}\)

Example 7.6. Roots of polynomials.

Show that the polynomial \(f(x)=x^5-x+1\) has a root.
Solution.
A root of \(f\) is an input \(c\) satisfying \(f(c)=0\text{.}\) Since \(f\) is continuous everywhere, the IVT will guarantee the existence of such a \(c\) as long as we can find inputs \(a\text{,}\) \(b\) satisfying \(f(a)> 0\) and \(f(b)< 0\text{.}\) Let’s make a table of values of \(f\) for small inputs \(x\text{:}\)
\begin{equation*} \begin{array}{c|c} x \amp f(x) \\ \hline -1 \amp 1 \\ 0\amp 1 \\ 1 \amp 1\\ 2 \amp 31 \end{array}\text{.} \end{equation*}
This so far is not helpful to us, as all the values are positive. Let’s try another negative value:
\begin{equation*} \begin{array}{c|c} x \amp f(x) \\ \hline -2 \amp -29\\ -1 \amp 1 \\ 0\amp 1 \\ 1 \amp 1\\ 2 \amp 31 \end{array}\text{.} \end{equation*}
That’s more like it! Since \(f\) is continuous on \([-2,-1]\text{,}\) and since
\begin{equation*} -29=f(-2)< 0 < f(-1)=1\text{,} \end{equation*}
the IVT now implies there is a \(c\in (-2,-1)\) such that \(f(c)=0\text{.}\)
Observe that this not only shows that \(f\) has a real root, it tells us further that there is a root lying between -2 and -1. Are there any other roots of this function? Further investigation is required. We will have the tools to answer this later.

Example 7.7. Complicated equation.

Prove that the equation
\begin{equation*} \cos x=\frac{1}{\sqrt{x^2+4}} \end{equation*}
has a solution.
Solution.
To get this problem into a state where we can apply the IVT, we rewrite the equation as
\begin{equation*} \cos x-\frac{1}{\sqrt{x^2+4}}=0 \end{equation*}
and define \(f(x)=\cos x-\frac{1}{\sqrt{x^2+4}}\text{.}\) Thus we are looking for a solution to \(f(x)=0\text{.}\) As with Example 7.6, this will boil down to finding inputs where \(f\) is positive and negative, respectively. Let’s create a table of values for \(f\text{:}\)
\begin{equation*} \begin{array}{r|l} x\amp f(x)\\ \hline -\pi/2 \amp 0-\frac{1}{\sqrt{\pi^2/4+4}}=-\frac{1}{\sqrt{\pi^2/4+4}}\\ 0 \amp 1-\frac{1}{\sqrt{4}}=\frac{1}{2}\\ \pi/2 \amp -\frac{1}{\sqrt{\pi^2/4+4}} \end{array}\text{.} \end{equation*}
We observe that
\begin{equation*} -\frac{1}{\sqrt{\pi^2/4+4}}=f(-\pi/2)< 0< f(0)=\frac{1}{2} \text{.} \end{equation*}
Since \(f\) is continuous on \([-\pi/2, 0]\text{,}\) the IVT now implies there is an element \(c\in (\pi/2, 0)\) satisfying \(f(c)=0\text{.}\) Thus we have shown, not only that there is a solution, but one lying in this particular interval.
Note that the same reasoning tells us there is another solution between \(0\) and \(\pi/2\text{.}\) That is the inequality
\begin{equation*} f(0)> 0 > f(\pi/2) \end{equation*}
implies there is another solution \(d\) lying between \(0\) and \(\pi/2\text{.}\) Thus, we are able to roughly locate two solutions to the original equation, using the IVT twice.
Note: since the given function happens to be even (\(f(-x)=f(x)\)), from our first solution \(c\) lying in \((-\pi/2, 0)\) we obtain a second solution \(-c\) lying in \((0,\pi/2)\text{.}\)
Recall that the range of a function \(f\colon D\rightarrow \R\) is the set of all outputs of \(f\text{:}\)
\begin{equation*} \range f=\{b \in \R\colon b=f(x) \text{ for some } x\in D\}=\{f(x)\colon x\in D\}\text{.} \end{equation*}
The intermediate value theorem implies that if \(f\) is a continuous function and \(D\) is an interval, then given any two values \(c< d\text{,}\) if \(c,d\in \range f\text{,}\) then \([c,d]\subseteq \range f\text{.}\) This observation often allows us to explicitly compute the range of a continuous function.

Example 7.8. Range of sine.

Prove that the range of the sine function \(f(x)=\sin x\) is the entire interval \([-1,1]\text{.}\)
Solution.
Since by definition \(\sin(x)\) is the \(y\)-value of a certain point lying on the unit circle, and since all such \(y\)-values lie between \(-1\) and \(1\text{,}\) we know that
\begin{equation*} -1\leq \sin x\leq 1 \end{equation*}
for all \(x\in \R\text{.}\) Note that so far this only tells us that the outputs of \(\sin\) form a subset of \([-1,1]\text{:}\) that is, this only tells us that \(\range f\subseteq [-1,1]\text{.}\) To show this set inclusion is in fact a set equality, we need to show that given any \(b\in [-1,1]\text{,}\) \(b\in \range f\text{:}\) i.e., given any \(b\in [-1,1]\text{,}\) there is an \(a\in \R\) such that \(\sin(a)=b\text{.}\)
To this end, note that \(\sin(-\pi/2)=-1\) and \(\sin(\pi/2)=1\text{.}\) Thus \(-1,1\in \range f\text{.}\) Furthermore given any \(b\in (-1,1)\text{,}\) since \(\sin\) is continuous on \([-\pi/2, \pi/2]\text{,}\) and since
\begin{equation*} -1=\sin(-\pi/2)< b < \sin(\pi/2)=1\text{,} \end{equation*}
we conclude by the IVT that there is an element \(a\in (-\pi/2, \pi/2)\) satisfying \(\sin(a)=b\text{.}\) Thus \(b\in \range f\text{,}\) as desired.