Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News Sign UpSign In
| Download

A computable worksheet explaining

Views: 118
Kernel: SageMath 8.9

A computable worksheet on continuity

Barrie Cooper

In this worksheet, we will try to understand the ϵ\epsilon,δ\delta definition of continuity at a point aa.

Definition A function f ⁣:RRf \colon \mathbb{R} \rightarrow \mathbb{R} is continuous if   aR  ϵ>0  δ>0  xRxa<δf(x)f(a)<ϵ\; \forall a \in \mathbb{R} \; \forall \epsilon>0 \; \exists \delta>0 \; \forall x\in\mathbb{R} \quad | x-a | < \delta \Rightarrow | f(x)-f(a)| < \epsilon.

A definition in mathematics is a qualification - we can only call the function ff continuous if it passes the test specified in the definition. In this case, the test has a mixture of quantifiers and it can sometimes be tricky to understand how these relate to what needs to be proved to show that the test is passed or failed.

I like to think of \forall and \exists as defining the rules and moves of a game that you want to win. The \forall (for all) quantifier represents your opponent's move - you don't get any say in this, except you are told the name of the object that your opponent picks. The \exists (there exists) quantifier represents your move - you must expressly indicate your choice, which might depend on the previous moves in the game, but cannot depend on future moves as they haven't happened yet. The final part represents the condition that must be satisfied for you to win the game, in this case, if xx is within δ\delta of aa, then f(x)f(x) must be within ϵ\epsilon of f(a)f(a) - you win the game if you can show this condition holds based on the previous moves in the game.

That might sound a little abstract, but let's look at a specific example. Suppose that I want to prove that the function f ⁣:RRf\colon \mathbb{R} \rightarrow \mathbb{R} defined by xx2x \mapsto x^2 is continuous. Then according to the definition, I must prove that aR  ϵ>0  δ>0  xRxa<δx2a2<ϵ  .\forall a \in \mathbb{R} \; \forall \epsilon>0 \; \exists \delta>0 \; \forall x\in\mathbb{R} \quad | x-a | < \delta \Rightarrow | x^2-a^2| < \epsilon \; . I'm going to take you through the thought process and then write down the clean mathematical proof afterwards. Let's think about this as a game. My opponent starts by picking the point aRa \in \mathbb{R} on which we need to focus our efforts. It might be a=50a=50 or a=1/2a=-1/2, we don't get to know anything other than it is a real number called aa. It is then my opponent's turn again! My opponent gives me a tolerance ϵ\epsilon which tells me how close ultimately the value x2x^2 has to be to a2a^2 (we will get to the xx later). As with aa, I don't know if ϵ\epsilon is something huge like 1000 or something tiny like 1/10001/1000 - I just know that it is a postive real number called ϵ\epsilon. Whatever it is, I need to find a strategy that will win the game. The next move in the game is mine: I need to choose a δ\delta. To work out what that δ\delta needs to be, I need to study the next part of the game - I must anticipate my opponent's every possible move and make sure that no matter what he does next, I still win.

After I choose δ\delta (and I haven't done so yet, I'm just looking ahead to see what the rules for the next part of the game are), then my opponent gives me a real number xx. Note that whatever δ\delta I choose can depend on the aa and the ϵ\epsilon I am given (because my opponent made those moves before I have to pick δ\delta), but it cannot depend on the xx I am given later (because I must pick δ\delta before my opponent picks xx) - it is in that sense that I need to choose a δ\delta that caters for any possible move by my opponent when they pick xx.

I'm still reading the rules of the game at this point: I need to know the final condition that needs to be satisfied for me to win, once my opponent has chosen aa and ϵ\epsilon and then I've chosen δ\delta and then my opponent has chosen xx. Well, the final condition is that if xa<δ| x-a | < \delta then x2a2<ϵ| x^2-a^2| < \epsilon, which I read as if xx is within δ\delta of aa, then x2x^2 must be within ϵ\epsilon of a2a^2. I control δ\delta, which means I get to control how close xx must be to aa; I need to use this to control how close x2x^2 is to a2a^2, and in particular I must make sure that it is within the tolerance ϵ\epsilon I was given by my opponent. This is where we now need to do some calculation: x2a2=(xa)(x+a)=xax+a=xaxa+2axa(xa+2a). | x^2-a^2| = |(x-a)(x+a)| = |x - a||x+a| = |x-a||x-a+2a| \leq |x-a|(|x-a|+2|a|). Note that whenever xa<δ|x-a|<\delta, then I have just derived the inequality x2a2<δ(δ+2a). |x^2-a^2| < \delta(\delta+2|a|). Provided, I choose δ\delta so that δ(δ+2a)<ϵ\delta(\delta+2|a|) < \epsilon, then I win the game. I could now do some algebra to work out what δ\delta would do, but don't forget that I get to choose δ\delta, so I can put other constraints on δ\delta to make my life easier. In particular, I am going to decide that δ1\delta\leq 1. I can simplify my bound even further now: x2a2<δ(δ+2a)δ(1+2a). |x^2 - a^2 | < \delta(\delta+2|a|) \leq \delta (1+2|a|). So, in fact, provided I choose δ\delta so that δ1\delta\leq 1 and δ(1+2a)<ϵ\delta (1+2|a|) < \epsilon, then I win the game. Well that's easy ... I'm going to insist that δ=min{1,ϵ/(1+2a)}\delta = \min\{1,\epsilon/(1+2|a|)\}. Note that my choice of δ\delta does depend on aa and ϵ\epsilon - which is ok because they are moves my opponent makes before I have to choose δ\delta - but it is important that my choice of δ\delta does not depend on xx - which is a move my opponent makes after I have chosen δ\delta.

Finally, the infuriating thing about mathematics is that mathematicians would not write that as a proof - to a professional mathematician it is just too long and unnecessary an explanation and doesn't cut to the heart of the matter. With direct proofs like this, the statement we are trying to prove tells us the structure of the proof as follows: whenever you see the quantifier \forall, you write Let ... in the proof; whenever you see the quantifier \exists, you write Choose ... in the proof; and then you show the final condition must hold.

Our statement we need to prove is aR  ϵ>0  δ>0  xRxa<δx2a2<ϵ\forall a \in \mathbb{R} \; \forall \epsilon>0 \; \exists \delta>0 \; \forall x\in\mathbb{R} \quad | x-a | < \delta \Rightarrow | x^2-a^2| < \epsilon so the template for our proof must be as follows:

"Let aRa \in \mathbb{R}. Let ϵ>0\epsilon >0. Choose δ=\delta = \dotsb. Let xRx \in \mathbb{R}. Now, if xa<δ|x-a|<\delta we have x2a2=<ϵ|x^2 - a^2| = \dotsb \leq \dotsb < \epsilon."

We could have written out that template before we did any calculations, in fact, because so far we've not included any of that stuff. All that remains is for us to fill in the blanks ...

Proposition The function f ⁣:RRf \colon \mathbb{R}\to\mathbb{R} defined by xx2x \mapsto x^2 is continuous.

Proof

Let aRa \in \mathbb{R}. Let ϵ>0\epsilon >0. Choose δ=min{1,ϵ/(1+2a)}\delta = \min\{1,\epsilon/(1+2|a|)\}. Let xRx \in \mathbb{R}. Now, if xa<δ|x-a|<\delta we have

x2a2=(xa)(x+a)=xax+a=xaxa+2axa(xa+2a)<δ(xa+2a)<δ(δ+2a)δ(1+2a)ϵ1+2a(1+2a)=ϵ.|x^2 - a^2| = |(x-a)(x+a)| = |x - a||x+a| = |x-a||x-a+2a| \leq |x-a|(|x-a|+2|a|) < \delta(|x-a|+2|a|) < \delta(\delta+2|a|) \leq \delta(1+2|a|) \leq \frac{\epsilon}{1+2|a|}(1+2|a|) = \epsilon.

Note that we had to do lots of thinking and calculations on a bit of scrap paper before we could write down that proof, but that concise two-line proof is the generally accepted way in which mathematics is written (and it is beautiful!).

A coded example

To help get your head round what is happening in these ϵ,δ\epsilon,\delta proofs, I've coded up a simple example using SageMath below. All the elements of the code can be changed, so feel free to fiddle with it to your heart's content! Note that if you are playing the game properly, then your choice of δ\delta should be written in terms of the variables aa and ϵ\epsilon, rather than being hard-coded as a number. Experiment with different functions ff and remember that you are looking to write δ\delta as a function of aa and ϵ\epsilon in such a way that if xx is within δ\delta of aa, then f(x)f(x) is within ϵ\epsilon of f(a)f(a). If you understand that, then you understand ϵ,δ\epsilon,\delta proofs of continuity!

#First we declare our variables. var('x a delta epsilon') # Now we specify our function f ... feel free to play with this! f(x)=x^2 # Our opponent gets to choose a and epsilon ... you could generate two random numbers here if you were really feeling brave and want to challenge yourself! a=0.5 epsilon = 0.01 # This is the crucial decision ... we must define delta as a function of a and epsilon. delta = min(epsilon/(1+2*abs(a)), 1) # The rest of the code plots the corresponding figure for us ... M = max(delta,epsilon) xl = a-2*M xu = a+2*M yl = f(a)-2*M yu = f(a)+2*M Fig = f.plot(xmin=xl,xmax=xu,ymin=yl,ymax=yu) Fig += point((a,f(a)),size=100) Fig += line([(a-delta,yl),(a-delta,yu)],color="red",linestyle="dashed") Fig += line([(a+delta,yl),(a+delta,yu)],color="red",linestyle="dashed") Fig += line([(a,yl),(a,yu)],color="red") Fig += line([(xl,f(a)+epsilon),(xu,f(a)+epsilon)],color="green",linestyle="dashed") Fig += line([(xl,f(a)-epsilon),(xu,f(a)-epsilon)],color="green",linestyle="dashed") Fig += line([(xl,f(a)),(xu,f(a))],color="green") Fig += arrow((xu,f(a)),(xu,f(a)+epsilon),color="green") Fig += arrow((xu,f(a)),(xu,f(a)-epsilon),color="green") Fig += arrow((a,yu),(a+delta,yu),color="red") Fig += arrow((a,yu),(a-delta,yu),color="red") Fig += text(' $f(a) \cong %s$'%round(f(a),2),(xu,f(a)),horizontal_alignment='left',color='green') Fig += text(' $f(a)+\epsilon \cong %s$'%round(f(a)+epsilon,2),(xu,f(a)+epsilon),horizontal_alignment='left',color='green') Fig += text(' $f(a)-\epsilon \cong %s$'%round(f(a)-epsilon,2),(xu,f(a)-epsilon),horizontal_alignment='left',color='green') Fig += text('$a$',(a,yu),vertical_alignment='bottom',color='red') Fig += text('$a+\delta$',(a+delta,yu),vertical_alignment='bottom',horizontal_alignment='left',color='red') Fig += text('$a-\delta$',(a-delta,yu),vertical_alignment='bottom',horizontal_alignment='right',color='red') Fig += text('$\epsilon$ ',(xu,f(a)+epsilon/2),horizontal_alignment='right',color='green') Fig += text('$\epsilon$ ',(xu,f(a)-epsilon/2),horizontal_alignment='right',color='green') Fig += text('$\delta$',(a-delta/2,yu),vertical_alignment='top',color='red') Fig += text('$\delta$',(a+delta/2,yu),vertical_alignment='top',color='red') Fig.show()
Image in a Jupyter notebook