© Springer Nature Switzerland AG 2018
Michael Oberguggenberger and Alexander OstermannAnalysis for Computer ScientistsUndergraduate Topics in Computer Sciencehttps://doi.org/10.1007/978-3-319-91155-7_6

6. Limits and Continuity of Functions

Michael Oberguggenberger1   and Alexander Ostermann1  
(1)
University of Innsbruck, Innsbruck, Austria
 
 
Michael Oberguggenberger (Corresponding author)
 
Alexander Ostermann

In this section we extend the notion of the limit of a sequence to the concept of the limit of a function. Hereby we obtain a tool which enables us to investigate the behaviour of graphs of functions in the neighbourhood of chosen points. Moreover, limits of functions form the basis of one of the central themes in mathematical analysis, namely differentiation (Chap. 7). In order to derive certain differentiation formulas some elementary limits are needed, for instance, limits of trigonometric functions. The property of continuity of a function has far-reaching consequences like, for instance, the intermediate value theorem, according to which a continuous function which changes its sign in an interval has a zero. Not only does this theorem allow one to show the solvability of equations, it also provides numerical procedures to approximate the solutions. Further material on continuity can be found in Appendix C.

6.1 The Notion of Continuity

We start with the investigation of the behaviour of graphs of real functions
$$ f: (a, b) \rightarrow \mathbb R$$
while approaching a point x in the open interval (ab) or a boundary point of the closed interval [ab]. For that we need the notion of a zero sequence , i.e. a sequence of real numbers $$(h_n)_{n \ge 1}$$ with $$\lim _{n \rightarrow \infty } h_n = 0$$.

Definition 6.1

(Limits and continuity)
  1. (a)
    The function f has a limit M at a point $$x \in (a, b)$$, if
    $$ \lim _{n \rightarrow \infty } f (x + h_n) = M $$
    for all zero sequences $$(h_n)_{n \ge 1}$$ with $$h_n \ne 0$$. In this case one writes
    $$ M = \lim _{h \rightarrow 0} f (x + h) = \lim _{\xi \rightarrow x} f (\xi ) $$
    or
    $$ f(x + h) \rightarrow M \ \text {as}\ h \rightarrow 0. $$
     
  2. (b)
    The function f has a right-hand limit R at the point $$ x \in [a, b)$$, if
    $$ \lim _{n \rightarrow \infty } f (x + h_n) = R $$
    for all zero sequences $$(h_n)_{n \ge 1}$$ with $$h_n > 0$$, with the corresponding notation
    $$ R = \lim _{h \rightarrow 0+} f (x + h) = \lim _{\xi \rightarrow x+} f (\xi ). $$
     
  3. (c)
    The function f has a left-hand limit L at the point $$x \in (a, b]$$, if:
    $$ \lim _{n \rightarrow \infty } f (x + h_n) = L $$
    for all zero sequences $$(h_n)_{n \ge 1}$$ with $$h_n < 0$$. Notations:
    $$ L = \lim _{h \rightarrow 0-} f (x + h) = \lim _{\xi \rightarrow x-} f (\xi ). $$
     
  4. (d)

    If f has a limit M at $$x \in (a, b)$$ which coincides with the value of the function, i.e. $$f(x) = M$$, then f is called continuous at the point x.

     
  5. (e)

    If f is continuous at every $$x \in (a, b)$$, then f is said to be continuous on the open interval (ab). If in addition f has right- and left-hand limits at the endpoints a and b, it is called continuous on the closed interval [ab].

     
Figure 6.1 illustrates the idea of approaching a point x for $$h \rightarrow 0$$ as well as possible differences between left-hand and right-hand limits and the value of the function.
images/215236_2_En_6_Chapter/215236_2_En_6_Fig1_HTML.gif
Fig. 6.1

Limit and continuity; left- and right-hand limits

If a function f is continuous at a point x, the function evaluation can be interchanged with the limit:
$$ \lim _{\xi \rightarrow x}f(\xi ) = f(x) = f(\lim _{\xi \rightarrow x}\xi ). $$
The following examples show some further possibilities how a function can behave in the neighbourhood of a point: Jump discontinuity with left- and right-hand limits, vertical asymptote, oscillations with non-vanishing amplitude and ever-increasing frequency.

Example 6.2

The quadratic function $$f(x) = x^2$$ is continuous at every $$x \in \mathbb R$$ since
$$ f(x + h_n) - f(x) = (x + h_n)^2 - x^2 = 2x h_n + h_n^2 \rightarrow 0 $$
as $$n \rightarrow \infty $$ for any zero sequence $$(h_n)_{n \ge 1}$$. Therefore
$$ \lim _{h \rightarrow 0} f (x + h) = f(x). $$
Likewise the continuity of the power functions $$x \mapsto x^m$$ for $$m \in \mathbb N$$ can be shown.

Example 6.3

The absolute value function $$f(x) = |x|$$ and the third root $$g(x) = \root 3 \of {x}$$ are everywhere continuous. The former has a kink at $$x = 0$$, the latter a vertical tangent; see Fig. 6.2.

images/215236_2_En_6_Chapter/215236_2_En_6_Fig2_HTML.gif
Fig. 6.2

Continuity and kink or vertical tangent

Example 6.4

The sign function $$f(x) = {\text {sign}}x$$ has different left- and right-hand limits $$L=-1$$, $$R=1$$ at $$x =0$$. In particular, it is discontinuous at that point. At all other points $$x \ne 0$$ it is continuous; see Fig. 6.3.

Example 6.5

The square of the sign function
$$ g(x) = ({{\text {sign}}}\, x)^2 = \left\{ \begin{array}{ll} 1, &{}\quad x \ne 0\\ 0, &{}\quad x = 0 \end{array} \right. $$
has equal left- and right-hand limits at $$x = 0$$. However, they are different from the value of the function (see Fig. 6.3):
$$ \lim _{\xi \rightarrow 0} g (\xi ) = 1 \ne 0 = g(0). $$
Therefore, g is discontinuous at $$x = 0$$.
images/215236_2_En_6_Chapter/215236_2_En_6_Fig3_HTML.gif
Fig. 6.3

Discontinuities: jump discontinuity and exceptional value

Example 6.6

The functions $$f(x) = \frac{1}{x}$$ and $$g(x) = \tan x$$ have vertical asymptotes at $$x = 0$$ and $$x = \frac{\pi }{2} + k \pi ,\, k \in \mathbb Z$$, respectively, and in particular no left- or right-hand limit at these points. At all other points, however, they are continuous. We refer to Figs. 2.​9 and 3.​10.

Example 6.7

The function $$f(x) = \sin \frac{1}{x}$$ has no left- or right-hand limit at $$x = 0$$ but oscillates with non-vanishing amplitude (Fig. 6.4). Indeed, one obtains different limits for different zero sequences. For example, for
$$ h_n = \dfrac{1}{n \pi }, \quad k_n = \dfrac{1}{\pi /2 + 2n \pi }, \quad l_n = \dfrac{1}{3\pi /2 + 2n\pi } $$
the respective limits are
$$ \lim _{n \rightarrow \infty } f(h_n) = 0, \quad \lim _{n \rightarrow \infty } f (k_n) = 1, \quad \lim _{n \rightarrow \infty } f (l_n) = -1. $$
All other values in the interval $$[-1,1]$$ can also be obtained as limits with the help of suitable zero sequences.
images/215236_2_En_6_Chapter/215236_2_En_6_Fig4_HTML.gif
Fig. 6.4

No limits, oscillation with non-vanishing amplitude

Example 6.8

The function $$g(x) = x \sin \frac{1}{x}$$ can be continuously extended by $$g(0) = 0$$ at $$x = 0$$; it oscillates with vanishing amplitude (Fig. 6.5). Indeed,
$$ |g (h_n) - g(0)| = |h_n \sin \tfrac{1}{h_n} - 0| \le |h_n| \rightarrow 0 $$
for all zero sequences $$(h_n)_{n \ge 1}$$, thus $$\lim _{h \rightarrow 0} h \sin \frac{1}{h} = 0$$.
images/215236_2_En_6_Chapter/215236_2_En_6_Fig5_HTML.gif
Fig. 6.5

Continuity, oscillation with vanishing amplitude

Experiment 6.9

Open the M-files mat06_1.m and mat06_2.m, and study the graphs of the functions in Figs. 6.4 and 6.5 with the use of the zoom tool in the figure window. How can you improve the accuracy of the visualisation in the neighbourhood of $$x=0$$?

6.2 Trigonometric Limits

Comparing the areas in Fig. 6.6 shows that the area of the grey triangle with sides $$\cos x$$ and $$\sin x$$ is smaller than the area of the sector which in turn is smaller or equal to the area of the big triangle with sides 1 and $$\tan x$$.
images/215236_2_En_6_Chapter/215236_2_En_6_Fig6_HTML.gif
Fig. 6.6

Illustration of trigonometric inequalities

The area of a sector in the unit circle (with angle x in radian measure) equals x / 2 as is well-known. In summary we obtain the inequalities
$$ \frac{1}{2}\sin x\cos x \le \frac{x}{2} \le \frac{1}{2}\tan x $$
or after division by $$\sin x$$ and taking the reciprocal
$$ \cos x \le \frac{\sin x}{x} \le \frac{1}{\cos x}, $$
valid for all x with $$0< |x| < \pi /2$$.
With the help of these inequalities we can compute several important limits. From an elementary geometric consideration, one obtains
$$ \left| \cos x\right| \ge \frac{1}{2} \qquad \text{ for } \quad -\frac{\pi }{3} \le x \le \frac{\pi }{3}, $$
and together with the previous inequalities
$$ \left| \sin h_n\right| \le \frac{|h_n|}{\left| \cos h_n\right| } \le 2\left| h_n\right| \rightarrow 0 $$
for all zero sequences $$(h_n)_{n\ge 1}$$. This means that
$$ \lim _{h \rightarrow 0} \sin h = 0. $$
The sine function is therefore continuous at zero. From the continuity of the square function and the root function as well as the fact that $$\cos h$$ equals the positive square root of $$1 - \sin ^2 h$$ for small h it follows that
$$ \lim _{h \rightarrow 0} \cos h = \lim _{h \rightarrow 0}\sqrt{1 - \sin ^2 h} = 1. $$
With this the continuity of the sine function at every point $$x \in \mathbb R$$ can be proven:
$$ \lim _{h \rightarrow 0}\sin (x + h) = \lim _{h \rightarrow 0}\big (\sin x\cos h + \cos x\sin h\big ) = \sin x. $$
The inequality illustrated at the beginning of the section allows one to deduce one of the most important trigonometric limits. It forms the basis of the differentiation rules for trigonometric functions.

Proposition 6.10

$$\lim _{x \rightarrow 0} \frac{\sin x}{x} = 1$$.

Proof

We combine the above result $$\lim _{x\rightarrow 0}\cos x = 1$$ with the inequality deduced earlier and obtain
$$ 1 = \lim _{x \rightarrow 0} \cos x \le \lim _{x \rightarrow 0} \frac{\sin x }{x} \le \lim _{x \rightarrow 0} \frac{1}{\cos x} = 1, $$
and therefore $$\lim _{x \rightarrow 0} \frac{\sin x}{x} = 1$$.    $$\square $$

6.3 Zeros of Continuous Functions

Figure 6.7 shows the graph of a function that is continuous on a closed interval [ab] and that is negative at the left endpoint and positive at the right endpoint. Geometrically the graph has to intersect the x-axis at least once since it has no jumps due to the continuity. This means that f has to have at least one zero in (ab). This is a criterion that guarantees the existences of a solution to the equation $$f(x) = 0$$. A first rigorous proof of this intuitively evident statement goes back to Bolzano.
images/215236_2_En_6_Chapter/215236_2_En_6_Fig7_HTML.gif
Fig. 6.7

The intermediate value theorem

Proposition 6.11

(Intermediate value theorem)   Let $$f:[a, b] \rightarrow \mathbb R$$ be continuous and $$f(a) < 0$$, $$f(b) > 0$$. Then there exists a point $$\xi \in (a, b)$$ with $$f(\xi ) = 0$$.

Proof

The proof is based on the successive bisection of the intervals and the completeness of the set of real numbers. One starts with the interval [ab] and sets $$a_1 = a$$, $$b_1 = b$$.

Step 1: Compute $$y_1 = f \left( \frac{a_1 + b_1}{2}\right) $$.
$$\begin{aligned} \text {If} \ y_1 > 0 :&\text {set} \ a_2 = a_1, b_2 = \tfrac{a_1 + b_1}{2}.\\ \text {If} \ y_1 < 0 :&\text {set} \ a_2 = \tfrac{a_1 + b_1}{2}, b_2 = b_1.\\ \text {If} \ y_1 = 0 :&\text {termination,} \ \xi = \tfrac{a_1 + b_1}{2} \ \text {is a zero}. \end{aligned}$$
By construction $$f(a_2) < 0$$, $$f(b_2) > 0$$ and the interval length is halved:
$$ b_2 - a_2 = \frac{1}{2} (b_1 - a_1). $$
Step 2: Compute $$y_2 = f \left( \frac{a_2 + b_2}{2}\right) $$.
$$\begin{aligned} \text {If} \ y_2 > 0:&\text {set} \ a_3 = a_2, b_3 = \tfrac{a_2 + b_2}{2}.\\ \text {If} \ y_2 < 0:&\text {set} \ a_3 = \tfrac{a_2 + b_2}{2}, b_3 = b_2.\\ \text {If} \ y_2 = 0:&\text {termination,} \ \xi = \tfrac{a_2 + b_2}{2} \ \text {is a zero.} \end{aligned}$$
Further iterations lead to a monotonically increasing sequence
$$ a_1 \le a_2 \le a_3 \le \cdots \le b $$
which is bounded from above. According to Proposition 5.​10 the limit $$\displaystyle \xi = \lim _{n \rightarrow \infty } a_n$$ exists.
On the other hand $$|a_n - b_n| \le |a - b| / 2^{n-1} \rightarrow 0$$, therefore $$\lim _{n \rightarrow \infty } b_n = \xi $$ as well. If $$\xi $$ has not appeared after a finite number of steps as either $$a_k$$ or $$b_k$$ then for all $$n \in \mathbb N$$:
$$ f(a_n) < 0,\quad f(b_n) > 0. $$
From the continuity of f it follows that
$$ f(\xi ) = \lim _{n \rightarrow \infty } f(a_n) \le 0,\qquad f(\xi ) = \lim _{n \rightarrow \infty } f(b_n) \ge 0 $$
which implies $$f(\xi ) = 0$$, as claimed.    $$\square $$

The proof provides at the same time a numerical method to compute zeros of functions, the bisection method . Although it converges rather slowly, it is easily implementable and universally applicable—also for non-differentiable, continuous functions. For differentiable functions, however, considerably faster algorithms exist. The order of convergence and the discussion of faster procedures will be taken up in Sect. 8.​2.

Example 6.12

Calculation of $$\sqrt{2}$$ as the root of $$f(x) = x^2 - 2 = 0$$ in the interval [1, 2] using the bisection method:
$$ \begin{array}{lll} \text {Start:} &{} \quad f(1) = -1< 0,\ f(2) = 2> 0; &{} \quad a_1 = 1,\ b_1 = 2\\ \text {Step 1:} &{} \quad f(1.5) = 0.25> 0; &{} \quad a_2 = 1,\ b_2 = 1.5\\ \text {Step 2:} &{} \quad f(1.25) = -0.4375< 0; &{} \quad a_3 = 1.25,\ b_3 = 1.5\\ \text {Step 3:} &{} \quad f(1.375) = - 0.109375< 0; &{} \quad a_4 = 1.375,\ b_4 = 1.5\\ \text {Step 4:} &{} \quad f(1.4375) = 0.066406\ldots > 0; &{} \quad a_5 = 1.375,\ b_5 = 1.4375\\ \text {Step 5:} &{} \quad f(1.40625) = -0.022461\ldots < 0; &{} \quad a_6 = 1.40625,\ b_6 = 1.4375\\ \text {etc.} &{} &{} \end{array} $$
After 5 steps the first decimal place is ascertained:
$$ 1.40625< \sqrt{2} < 1.4375 $$

Experiment 6.13

Sketch the graph of the function $$ y = x^3 + 3x^2-2$$ on the interval $$[-3,2]$$, and try to first estimate graphically one of the roots by successive bisection. Execute the interval bisection with the help of the applet Bisection method. Assure yourself of the plausibility of the intermediate value theorem using the applet Animation of the intermediate value theorem.

As an important application of the intermediate value theorem we now show that images of intervals under continuous functions are again intervals. For the different types of intervals which appear in the following proposition we refer to Sect. 1.​2; for the notion of the proper range to Sect. 2.​1.

Proposition 6.14

Let $$I\subset \mathbb R$$ be an interval (open, half-open or closed, bounded or improper) and $$f : I \rightarrow \mathbb R$$ a continuous function with proper range $$J = f(I)$$. Then J is also an interval.

Proof

As subsets of the real line, intervals are characterised by the following property: With any two points all intermediate points are contained in it as well. Let $$y_1, y_2 \in J$$, $$y_1 < y_2,$$ and $$\eta $$ be an intermediate point, i.e. $$y_1< \eta < y_2$$. Since $$f: I \rightarrow J$$ is surjective there are $$x_1, x_2 \in I$$ such that $$y_1 = f(x_1)$$ and $$y_2 = f(x_2)$$. We consider the case $$x_1 < x_2$$. Since $$f(x_1) - \eta < 0$$ and $$f(x_2) - \eta > 0$$ it follows from the intermediate value theorem applied on the interval $$[x_1, x_2]$$ that there exists a point $$\xi \in (x_1,x_2)$$ with $$f(\xi ) - \eta = 0$$, thus $$f(\xi ) = \eta $$. Hence $$\eta $$ is attained as a value of the function and therefore lies in $$J = f(I)$$.    $$\square $$

Proposition 6.15

Let $$I = [a, b]$$ be a closed, bounded interval and $$f : I \rightarrow \mathbb R$$ a continuous function. Then the proper range $$J = f(I)$$ is also a closed, bounded interval.

Proof

According to Proposition 6.14 the range J is an interval. Let d be the least upper bound (possibly $$d = \infty $$). We take a sequence of values $$y_n \in J$$ which converges to d. The values $$y_n$$ are function values of certain arguments $$x_n\in I = [a, b]$$. The sequence $$(x_n)_{n \ge 1}$$ is bounded and, according to Proposition 5.​30, has an accumulation point $$x_0$$, $$a\le x_0 \le b$$. Thus a subsequence $$(x_{n_j})_{j \ge 1}$$ exists which converges to $$x_0$$ (see Sect. 5.​4). From the continuity of the function f it follows that
$$ d = \lim _{j\rightarrow \infty }y_{n_j} = \lim _{j\rightarrow \infty }f(x_{n_j}) = f(x_0). $$
This shows that the upper endpoint of the interval J is finite and is attained as function value. The same argument is applied to the lower boundary c; the range J is therefore a closed, bounded interval [cd].    $$\square $$

From the proof of the proposition it is clear that d is the largest and c the smallest value of the function f on the interval [ab]. We thus obtain the following important consequence.

Corollary 6.16

Each continuous function defined on a closed interval $$I=[a, b]$$ attains its maximum and minimum there.

6.4 Exercises

1.
(a)
Investigate the behaviour of the functions
$$\begin{aligned} \frac{x+x^2}{|x|}, \qquad \frac{\sqrt{1+x} -1}{x}, \qquad \frac{x^2 + \sin x}{\sqrt{1-\cos ^{2} x}} \end{aligned}$$
in a neighbourhood of $$x = 0$$ by plotting their graphs for arguments in $$[-2, - \frac{1}{100}) \cup (\frac{1}{100}, 2]$$.
(b)

Find out by inspection of the graphs whether there are left- or right-hand limits at $$x = 0$$. Which value do they have? Explain your results by rearranging the expressions in (a).

Hint. Some guidance for part (a) can be found in the M-file mat06_ex1.m. Expand the middle term in (b) with $${\sqrt{1+x} +1}$$.

2.
Do the following functions have a limit at the given points? If so, what is its value?
(a)

$$ y = x^3 + 5x + 10, \ x = 1.$$

(b)

$$ y = {\frac{x^2 - 1}{x^2 + x}}, \ x = 0, \, x = 1, \, x = -1.$$

(c)

$$ y = {\frac{1- \cos x}{x^2}}, \ x = 0.$$

Hint. Expand with $$(1 + \cos x).$$

(d)

$$ y = {\text {sign}}x \cdot \sin x, \ x =0.$$

(e)

$$ y ={\text {sign}}x \cdot \cos x, \ x =0.$$

3.
Let $$f_n(x) = \arctan n x,\, g_n(x) = (1 + x^2)^{-n}$$. Compute the limits
$$ f(x) = \lim _{n \rightarrow \infty } f_n(x), \qquad g(x) = \lim _{n \rightarrow \infty } g_n(x) $$
for each $$x \in \mathbb R$$, and sketch the graphs of the thereby defined functions f and g. Are they continuous? Plot $$f_n$$ and $$g_n$$ using MATLAB, and investigate the behaviour of the graphs for $$n \rightarrow \infty $$.

Hint. An advice can be found in the M-file mat06_ex3.m.

4.

With the help of zero sequences, carry out a formal proof of the fact that the absolute value function and the third root function of Example 6.3 are continuous.

5.

Argue with the help of the intermediate value theorem that $$p(x)= x^3 + 5 \, x + 10$$ has a zero in the interval $$[-2,1]$$. Compute this zero up to four decimal places using the applet Bisection method.

6.
Compute all zeros of the following functions in the given interval with accuracy $$10^{-3}$$, using the applet Bisection method.
$$ \begin{array} {lll} f(x) &{} = &{} x^4 - 2, \qquad I = \mathbb {R};\\ g(x) &{} = &{} x - \cos x, \,\,\, I = \mathbb {R};\\ h(x) &{} = &{} \sin \frac{1}{x}, \qquad \quad I = \left[ \frac{1}{20}, \frac{1}{10} \right] . \end{array} $$
7.
Write a MATLAB program which locates—with the help of the bisection method—the zero of an arbitrary polynomial
$$ p(x) = x^3 + c_1 x^2 + c_2 x + c_3 $$
of degree three. Your program should automatically provide starting values ab with $$p(a) < 0$$, $$p(b) > 0$$ (why do such values always exist?). Test your program by choosing the coefficient vector $$(c_1, c_2, c_3)$$ randomly, for example by using c = 1000*rand(1,3).

Hint. A solution is suggested in the M-file mat06_ex7.m.