Basics of real analysis#

ECON2125/6012 Lecture 4
Fedor Iskhakov

Announcements & Reminders

  1. The first test is due before the next lecture!

  • The test will be published tomorrow (before midnight on Friday)

  • The test will include multiple choice questions (where multiple options can be correct), True/False questions and open response questions where you may need to upload a file

  • Please, find the practice test on Wattle and make sure you are comfortable with the setup, including uploading an image/pdf file

  • Tests are timed: practice paying attention to the countdown timer

  • The deadline for submission of the first test is midnight on Wednesday, August 23

  1. I am traveling next week, no face-to-face lecture on August 24!

Plan for this lecture

Continuing with revision of fundamental concepts and ideas

  1. Sequences

  2. Convergence and limits

  3. Differentiation, Taylor series

  4. Analysis in Rn

  5. Open and closed sets

  6. Continuity of functions

Mainly review of key ideas

Supplementary reading:

  • Simon & Blume: 12.1, 12.2, 12.3, 12.4, 12.5 10.1, 10.2, 10.3, 10.4, 13.4

  • Sundaram: 1.1.1, 1.1.2, 1.2.1, 1.2.2, 1.2.3, 1.2.7, 1.2.8, 1.4.1

Analysis in R#

Example

Let F(x) be a profit function, so for solving profit maximization we have to solve f(x)=0 where f(x)=F(x).

Or: we want to solve an equation g(x)=y for x, equivalently f(x)=g(x)y

_images/root.png

Fig. 31 Existence of a root#

_images/no_root.png

Fig. 32 Non-existence of a root#

One answer: a solution exists under certain conditions including continuity.

Questions:

  • So how can I tell if f is continuous?

  • Can we weaken the continuity assumption?

  • Does this work in multiple dimensions?

  • When is the root unique?

  • How can we compute it?

These are typical problems in analysis

Bounded sets#

Definition

The absolute value of xR denoted |x| is |x|:=max{x,x}.

Hide code cell source
import numpy as np
import matplotlib.pyplot as plt

def subplots():
    "Custom subplots with axes throught the origin"
    fig, ax = plt.subplots()

    # Set the axes through the origin
    for spine in ['left', 'bottom']:
        ax.spines[spine].set_position('zero')
    for spine in ['right', 'top']:
        ax.spines[spine].set_color('none')
    
    ax.grid()
    return fig, ax

fig, ax = subplots()

ax.set_ylim(-3, 3)
ax.set_yticks((-3, -2, -1, 1, 2, 3))
x = np.linspace(-3, 3, 100)
ax.plot(x, np.abs(x), 'g-', lw=2, alpha=0.7, label=r'$f(x) = |x|$')
ax.plot(x, x, 'k--', lw=2, alpha=0.7, label=r'$f(x) = x$')
ax.legend(loc='lower right')

plt.show()
_images/c35f3933df70be5f0b2cdadde0fedf4be147c1226591dc72c848e5a9d7219873.png

Fact

For any x,yR, the following statements hold

  1. |x|y if and only if yxy

  2. |x|<y if and only if y<x<y

  3. |x|=0 if and only if x=0

  4. |xy|=|x||y|

  5. |x+y||x|+|y|

Last inequality is called the triangle inequality

Using these rules, let’s show that if x,y,zR, then

  1. |xy||x|+|y|

  2. |xy||xz|+|zy|

Definition

AR is called bounded if MR s.t. |x|M, all xA

_images/bounded.png

Example

Every finite subset A of R is bounded

Set M:=max{|a|:aA}

Example

N is unbounded

For any MR there is an n that exceeds it

Example

(a,b) is bounded for any a and b

Fact

If A and B are bounded sets then so is AB

Epsilon-balls (ϵ-balls)#

Definition

Given ϵ>0 and aR, the ϵ-ball around a is

Bϵ(a):={xR:|ax|<ϵ}

Equivalently,

Bϵ(a)={xR:aϵ<x<a+ϵ}
_images/eps_ball1D.png

Exercise: Check equivalence

Fact

If x is in every ϵ-ball around a then x=a

Fact

If ab, then ϵ>0 such that Bϵ(a) and Bϵ(b) are disjoint.

_images/disjnt_balls0.png

Sequences#

Definition

A sequence is a function from N to R

To each nN we associate one xnR

Typically written as {xn}n=1 or {xn} or {x1,x2,x3,}

Example

  • {xn}={2,4,6,}

  • {xn}={1,1/2,1/4,}

  • {xn}={1,1,1,1,}

  • {xn}={0,0,0,}

Definition

Sequence {xn} is called

  • bounded if {x1,x2,} is a bounded set

  • monotone increasing if xn+1xn for all n

  • monotone decreasing if xn+1xn for all n

  • monotone if it is either monotone increasing or monotone decreasing

Example

  • xn=1/n is monotone decreasing, bounded

  • xn=(1)n is not monotone but is bounded

  • xn=2n is monotone increasing but not bounded

Convergence#

Let aR and let {xn} be a sequence

Suppose, for any ϵ>0, we can find an NN such that

xnBϵ(a) for all nN

Then {xn} is said to converge to a

Convergence to a in symbols,

ϵ>0,NN such that nNxnBϵ(a)

The sequence {xn} is eventually in this ϵ-ball around a

_images/convergent_seqs1.png

…and this one

_images/convergent_seqs2.png

…and this one

_images/convergent_seqs3.png

…and this one

_images/convergent_seqs4.png

Definition

The point a is called the limit of the sequence, denoted

xna as n or limnxn=a,

if

ϵ>0,NN such that nNxnBϵ(a)

We call {xn} convergent if it converges to some limit in R

Example

{xn} defined by xn=1+1/n converges to 1:

xn1asn
limnxn=1

To prove this must show that ϵ>0, there is an NN such that

nN|xn1|<ϵ

To show this formally we need to come up with an “algorithm”

  1. You give me any ϵ>0

  2. I respond with an N such that equation above holds

In general, as ϵ shrinks, N will have to grow

Example

The sequence xn=2n converges to 0 as n

What if we want to show that xna fails?

To show convergence fails we need to show the negation of

ϵ>0,NNsuchthatnNxnBϵ(a)

Negation: there is an ϵ>0 where we can’t find any such N

More specifically, ϵ>0 such that, which ever NN we look at, there’s an nN with xn outside Bϵ(a)

One way to say this: there exists a Bϵ(a) such that xnBϵ(a) again and again as n.

This is the kind of picture we’re thinking of

Hide code cell source
from __future__ import division
import matplotlib.pyplot as plt
import numpy as np

from matplotlib import rc
rc('font',**{'family':'serif','serif':['Palatino']})
rc('text', usetex=True)

N = 80
epsilon = 0.15
a = 1

def x(n):
    return 1 + 1/(n**(0.7)) - 0.3 * (n % 8 == 0)
def subplots(fs):
    "Custom subplots with axes throught the origin"
    fig, ax = plt.subplots(figsize=fs)
    # Set the axes through the origin
    for spine in ['left', 'bottom']:
        ax.spines[spine].set_position('zero')
    for spine in ['right', 'top']:
        ax.spines[spine].set_color('none')
    return fig, ax

fig, ax = subplots((9, 5))  

xmin, xmax = 0.5, N+1
ax.set_xlim(xmin, xmax)
ax.set_ylim(0, 2)

n = np.arange(1, N+1)
ax.set_xticks([])
ax.plot(n, x(n), 'ko', label=r'$x_n$', alpha=0.8)

ax.hlines(a, xmin, xmax, color='k', lw=0.5, label='$a$')
ax.hlines([a - epsilon, a + epsilon], xmin, xmax, color='k', lw=0.5, linestyles='dashed')

ax.fill_between((xmin, xmax), a - epsilon, a + epsilon, facecolor='blue', alpha=0.1)

ax.set_yticks((a - epsilon, a, a + epsilon))
ax.set_yticklabels((r'$a - \epsilon$', r'$a$', r'$a + \epsilon$'))

ax.legend(loc='upper right', frameon=False, fontsize=14)
plt.show()
_images/f24846ec9fea08a2dc55439fd8fd828dcd81d99bd90f6f0adbf4b4d0e5eb572b.png

Example

The sequence xn=(1)n does not converge to any aR

Properties of Limits#

Fact

Let {xn} be a sequence in R and let aR. Then as n

xna|xna|0

Fact

Each sequence in R has at most one limit

Fact

Every convergent sequence is bounded

Operations with limits#

Here are some basic tools for working with limits

Fact

If xnx and yny, then

  1. xn+ynx+y

  2. xnynxy

  3. xn/ynx/y when yn and y are 0

  4. xnyn for all nxy

Let’s check that xnx and yny implies xn+ynx+y

Let’s also check the claim that xnx, yny and xnyn for all nN implies xy

In words: “Weak inequalities are preserved under limits”

Here’s another property of limits, called the “squeeze theorem”

Fact

Let {xn} {yn} and {zn} be sequences in R. If

  1. xnynzn for all nN

  2. xna and zna

then yna also holds

Infinite Sums#

Definition

Let {xn} be a sequence in R

Then the infinite sum of n=1xn is defined by

n=1xn:=limkn=1kxn

Thus, n=1xn is defined as the limit, if it exists, of {yk} where

yk:=n=1kxn

Other notation:

nxn,n1xn,nNxn,etc.

Example

If xn=αn for α(0,1), then

n=1xn=limkn=1kαn=limkα1αk1α=α1α

Exercise: show that n=1kαn=α1αk1α.

Example

If xn=(1)n the limit fails to exist because

yk=n=1kxn={0if k is even1otherwise

Fact

If {xn} is nonnegative and nxn<, then xn0

Cauchy Sequences#

Informal definition: Cauchy sequences are those where |xnxn+1| gets smaller and smaller

_images/cauchy.png

Example

Sequences generated by iterative methods for solving nonlinear equations often have this property

Hide code cell source
f = lambda x: -4*x**3+5*x+1
g = lambda x: -12*x**2+5

def newton(fun,grad,x0,tol=1e-6,maxiter=100,callback=None):
    '''Newton method for solving equation f(x)=0
    with given tolerance and number of iterations.
    Callback function is invoked at each iteration if given.
    '''
    for i in range(maxiter):
        x1 = x0 - fun(x0)/grad(x0)
        err = abs(x1-x0)
        if callback != None: callback(err=err,x0=x0,x1=x1,iter=i)
        if err<tol: break
        x0 = x1
    else:
        raise RuntimeError('Failed to converge in %d iterations'%maxiter)
    return (x0+x1)/2

def print_err(iter,err,**kwargs):
    x = kwargs['x'] if 'x' in kwargs.keys() else kwargs['x0']
    print('{:4d}:  x = {:14.8f}    diff = {:14.10f}'.format(iter,x,err))

print('Newton method')
res = newton(f,g,x0=123.45,callback=print_err,tol=1e-10)
Newton method
   0:  x =   123.45000000    diff =  41.1477443465
   1:  x =    82.30225565    diff =  27.4306976138
   2:  x =    54.87155804    diff =  18.2854286376
   3:  x =    36.58612940    diff =  12.1877193931
   4:  x =    24.39841001    diff =   8.1212701971
   5:  x =    16.27713981    diff =   5.4083058492
   6:  x =    10.86883396    diff =   3.5965889909
   7:  x =     7.27224497    diff =   2.3839931063
   8:  x =     4.88825187    diff =   1.5680338561
   9:  x =     3.32021801    diff =   1.0119341175
  10:  x =     2.30828389    diff =   0.6219125117
  11:  x =     1.68637138    diff =   0.3347943714
  12:  x =     1.35157701    diff =   0.1251775194
  13:  x =     1.22639949    diff =   0.0188751183
  14:  x =     1.20752437    diff =   0.0004173878
  15:  x =     1.20710698    diff =   0.0000002022
  16:  x =     1.20710678    diff =   0.0000000000

Cauchy sequences “look like” they are converging to something

A key axiom of analysis is that such sequences do converge to something — details follow

Definition

A sequence {xn} is called Cauchy if ϵ>0,NN such that

nN and j1|xnxn+j|<ϵ

Example

{xn} defined by xn=αn where α(0,1) is Cauchy

Fact

For any sequence the following equivalence holds: convergent Cauchy

Implications:

  • There are no “gaps” in the real line

  • To check {xn} converges to something we just need to check Cauchy property

Fact

Every bounded monotone sequence in R is convergent

Sketch of the proof:

Suffices to show that {xn} is Cauchy

Suppose not

Then no matter how far we go down the sequence we can find another jump of size ϵ>0

Since monotone, all the jumps are in the same direction

But then {xn} not bounded — a contradiction

Full proof: See any text on analysis

Subsequences#

Definition

A sequence {xnk} is called a subsequence of {xn} if

  1. {xnk} is a subset of {xn}

  2. the indices nk are strictly increasing

Example

{xn}={x1,x2,x3,x4,x5,}
{xnk}={x2,x4,x6,x8}

In this case

{nk}={n1,n2,n3,}={2,4,6,}

Example

{11,13,15,} is a subsequence of {11,12,13,}

{11,12,13,} is a subsequence of {11,12,13,}

{12,12,12,} is not a subsequence of {11,12,13,}

Fact

Every sequence has a monotone subsequence

Proof omitted

Example

The sequence xn=(1)n has monotone subsequence

{x2,x4,x6,}={1,1,1,}

This leads us to the famous Bolzano-Weierstrass theorem, to be used later when we discuss optimization.

Fact: Bolzano-Weierstrass theorem

Every bounded sequence in R has a convergent subsequence

Derivatives#

Definition

Let f:(a,b)R and let x(a,b)

Let H be all sequences {hn} such that hn0 and hn0

If there exists a constant f(x) such that

f(x+hn)f(x)hnf(x)

for every {hn}H, then

  • f is said to be differentiable at x

  • f(x) is called the derivative of f at x

_images/derivative.png

Example

Let f:RR be defined by f(x)=x2

Fix any xR and any hn0 with n

We have

f(x+hn)f(x)hn=(x+hn)2x2hn=
=x2+2xhn+hn2x2hn=2x+hn
therefore f(x)=limn(2x+hn)=2x

Example

Let f:RR be defined by f(x)=|x|

This function is not differentiable at x=0

Indeed, if hn=1/n, then

f(0+hn)f(0)hn=|0+1/n||0|1/n1

On the other hand, if hn=1/n, then

f(0+hn)f(0)hn=|01/n||0|1/n1

Taylor series#

Loosely speaking, if f:RR is suitably differentiable at a, then

f(x)f(a)+f(a)(xa)

for x very close to a,

f(x)f(a)+f(a)(xa)+f(a)2!(xa)2

on a slightly wider interval, etc.

These are the 1st and 2nd order Taylor series approximations to f at a respectively

As the order goes higher we get better approximation

_images/taylor_4.png

Fig. 33 4th order Taylor series for f(x)=sin(x)/x at 0#

_images/taylor_6.png

Fig. 34 6th order Taylor series for f(x)=sin(x)/x at 0#

_images/taylor_8.png

Fig. 35 8th order Taylor series for f(x)=sin(x)/x at 0#

_images/taylor_10.png

Fig. 36 10th order Taylor series for f(x)=sin(x)/x at 0#

Analysis in RK#

Now we switch from studying points xR to vectors xRK

  • Replace distance |xy| with xy

Many of the same results go through otherwise unchanged

We state the analogous results briefly since

  • You already have the intuition from R

  • Similar arguments, just replacing || with

We’ll spend longer on things that are different

Norm and distance#

Definition

The (Euclidean) norm of xRN is defined as

x:=xx=(n=1Nxn2)1/2

Interpretation:

  • x represents the length of x

  • xy represents distance between x and y

_images/vec.png

Fig. 37 Length of red line =x12+x22=:x#

xy represents distance between x and y

_images/vec_minus.png

Fig. 38 Length of red line =xy#

Fact

For any αR and any x,yRN, the following statements are true:

  • x0 and x=0 if and only if x=0

  • αx=|α|x

  • x+yx+y (triangle inequality)

  • |xy|xy (Cauchy-Schwarz inequality)

For example, let’s show that x=0x=0

First let’s assume that x=0 and show x=0

Since x=0 we have x2=0 and hence n=1Nxn2=0

That is xn=0 for all n, or, equivalently, x=0

Next let’s assume that x=0 and show x=0

This is immediate from the definition of the norm

Bounded sets and ϵ-balls#

Definition

A set ARK called bounded if

MRsuchthatxM,xA

Remarks:

  • A generalization of the scalar definition

  • When K=1, the norm reduces to ||

Fact

If A and B are bounded sets then so is C:=AB

Proof: Same as the scalar case — just replace || with

Exercise: Check it

Definition

For ϵ>0, the ϵ-ball Bϵ(a) around aRK is all xRK such that ax<ϵ

_images/eps_ball2D.png

Fact

If x is in every ϵ-ball around a then x=a

Fact

If ab, then ϵ>0 such that Bϵ(a)Bϵ(b)=

Definition

A sequence {xn} in RK is a function from N to RK

Definition

Sequence {xn} is said to converge to aRK if

ϵ>0,NN such that nNxnBϵ(a)

We say: “{xn} is eventually in any ϵ-neighborhood of a

In this case a is called the limit of the sequence, and we write

xna as norlimnxn=a

Definition

We call {xn} convergent if it converges to some limit in RK

_images/convergence.png
_images/convergence2.png
_images/convergence3.png

Vector vs Componentwise Convergence#

Fact

A sequence {xn} in RK converges to aRK if and only if each component sequence converges in R

That is,

(xn1xnK)(a1aK)in RKxn1a1in RxnKaKin R
_images/norm_and_pointwise.png

From Scalar to Vector Analysis#

More definitions analogous to scalar case:

Definition

A sequence {xn} is called Cauchy if

ϵ>0,NNsuchthatn,mNxnxm<ϵ

Definition

A sequence {xnk} is called a subsequence of {xn} if

  1. {xnk} is a subset of {xn}

  2. the indices nk are strictly increasing

Fact

Analogous to the scalar case,

  1. xna in RK if and only if xna0 in R

  2. If xnx and yny then xn+ynx+y

  3. If xnx and αR then αxnαx

  4. If xnx and zRK then zxnzx

  5. Each sequence in RK has at most one limit

  6. Every convergent sequence in RK is bounded

  7. Every convergent sequence in RK is Cauchy

  8. Every Cauchy sequence in RK is convergent

Exercise: Adapt proofs given for the scalar case to these results

Example

Let’s check that

xna in RKxna0 in R

Reminder — these facts are more general than scalar ones!

  • True for any finite K

  • So true for K=1

  • This recovers the corresponding scalar fact

You can forget the scalar fact if you remember the vector one

Fact

If {xn} converges to x in RK, then every subsequence of {xn} also converges to x

_images/subseqconverg.png

Fig. 39 Convergence of subsequences#

Infinite Sums in RK#

Analogous to the scalar case, an infinite sum in RK is the limit of the partial sum

Definition

If {xn} is a sequence in RK, then

n=1xn:=limJn=1Jxn if the limit exists

In other words,

y=n=1xnlimJn=1Jxny0

Open and Closed Sets#

Let GRK

Definition

We call xG interior to G if ϵ>0 with Bϵ(x)G

Loosely speaking, interior means “not on the boundary”

_images/interior.png

Example

If G=(a,b) for some a<b, then any x(a,b) is interior

_images/x_interior.png

Example

If G=[1,1], then 1 is not interior

_images/not_interior.png

Intuitively, any ϵ-ball centered on 1 will contain points >1

More formally, pick any ϵ>0 and consider Bϵ(1)

There exists a yBϵ(1) such that y[1,1]

For example, consider the point y:=1+ϵ/2

Exercise: Check this point: lies in Bϵ(1) but not in [1,1]

Definition

A set GRK is called open if all of its points are interior

Example

Open sets:

  • any “open” interval (a,b)R, since we showed all points are interior

  • any “open” ball Bϵ(a)=xRK:xa<ϵ

  • RK itself

Example

Sets that are not open

  • (a,b] because b is not interior

  • [a,b) because a is not interior

Closed Sets#

Definition

A set FRK is called closed if every convergent sequence in F converges to a point in F

Rephrased: If {xn}F and xnx for some xRK, then xF

Example

All of RK is closed because every sequence converging to a point in RK converges to a point in RK… right?

Example

If (1,1)R is not closed

Example

If F=[a,b]R then F is closed in R

Example

Any “hyperplane” of the form

H={xRK:xa=c}

is closed

Properties of Open and Closed Sets#

Fact

GRK is open Gc is closed

Example

Any singleton {x}RK is closed

Fact

  1. Any union of open sets is open

  2. Any intersection of closed sets is closed

But be careful:

  • An infinite intersection of open sets is not necessarily open

  • An infinite union of closed sets is not necessarily closed

For example, if Gn:=(1/n,1/n), then nNGn={0}

To see this, suppose that xnGn

Then

1/n<x<1/n,nN

Therefore x=0, and hence x{0}

On the other hand, if x{0} then xnGn

Fact

If A is closed and bounded then every sequence in A has a subsequence which converges to a point of A

Take any sequence {xn} contained in A

Since A is bounded, {xn} is bounded

Therefore it has a convergent subsequence

Since the subsequence is also contained in A, and A is closed, the limit must lie in A.

Definition

Bounded and closed sets are called compact sets or compacts

Continuity#

One of the most fundamental properties of functions

Related to existence of

  • optima

  • roots

  • fixed points

  • etc

as well as a variety of other useful concepts

Definition

A function F is called bounded if its range is a bounded set.

Fact

If F and G are bounded, then so are F+G, FG and αF for any finite α

Let F:ARJ where A is a subset of RK

Definition

F is called continuous at xA if as n

xnxF(xn)F(x)

Requires that

  • F(xn) converges for each choice of xnx,

  • The limit is always the same, and that limit is F(x)

Definition

F is called continuous if it is continuous at every xA

_images/cont_func.png

Fig. 40 Continuity#

_images/discont_func.png

Fig. 41 Discontinuity at x#

Example

Let A be an J×K matrix and let F(x)=Ax

The function F is continuous at every xRK

To see this take

  • any xRK

  • any xnx

By the definition of the matrix norm A, we have

AxnAx=A(xnx)Axnx
therefore xnxAxnAx

Exercise: Exactly what rules are we using here?

Fact

If f:RR is differentiable at x, then f is continuous at x

Fact

Some functions known to be continuous on their domains:

  • xxα

  • x|x|

  • xlog(x)

  • xexp(x)

  • xsin(x)

  • xcos(x)

Example

Discontinuous at zero: x1{x>0}.

Fact

Let F and G be functions and let αR

  1. If F and G are continuous at x then so is F+G, where

(F+G)(x):=F(x)+G(x)
  1. If F is continuous at x then so is αF, where

(αF)(x):=αF(x)
  1. If F and G are continuous at x and real valued then so is FG, where

(FG)(x):=F(x)G(x)

In the latter case, if in addition G(x)0, then F/G is also continuous.

As a result, set of continuous functions is “closed” under elementary arithmetic operations

Example

The function F:RR defined by

F(x)=exp(x)+sin(x)2+cos(x)+x42cos3(x)8!

is continuous

Extra material#

Watch excellent video by Grant Sanderson (3blue1brown) on limits, and continue onto his whole amazing series on calculus