Shared03 - Limits Assignment / Limits Notes.sagewsOpen in CoCalc
This material was developed by Aaron Tresham at the University of Hawaii at Hilo and is Creative Commons License
licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.

Prerequisites:

  • Intro to Sage
  • Graphing and Solving Equations

Limits

In this lab we will be exploring the concept of limits graphically, numerically, and computationally.

As you know from the lecture, a limit is the value approached by the outputs of a function as the inputs approach some given value.

Example 1

Consider the function f(x)=sin(x)x\displaystyle f(x)=\frac{\sin(x)}{x}. Notice that f(0)f(0) is not defined, but we may be able to find limx0f(x)\displaystyle\lim_{x\to 0}f(x), so let's look at a graph.

plot(sin(x)/x)

From the graph, it appears that as x0x\to 0, f(x)1f(x)\to1. Let's zoom in to confirm:

plot(sin(x)/x,xmin=-.25,xmax=.25)

One more time:

plot(sin(x)/x,xmin=-.1,xmax=.1)

Of course, a graph is no proof, but this is evidence that limx0f(x)=1\displaystyle\lim_{x\to0}f(x)=1.

Example 2

Find limt0t2+93t2\displaystyle\lim_{t\to 0}\frac{\sqrt{t^2+9}-3}{t^2} by zooming in on a graph.

%var t
plot((sqrt(t^2+9)-3)/t^2)

It looks like the limit is just above 1.66×101=0.1661.66\times 10^{-1}=0.166.

Let's zoom in:

plot((sqrt(t^2+9)-3)/t^2,xmin=-.1,xmax=.1)
plot((sqrt(t^2+9)-3)/t^2,xmin=-.01,xmax=.01)

It looks like 0.1667 is our best estimate for the limit.

Example 3

Find limx4x2x4\displaystyle\lim_{x \to 4}\frac{\sqrt{x}-2}{x-4}

We want to see what happens around x=4x=4, so we need to change the window.

f(x)=(sqrt(x)-2)/(x-4)
plot(f,xmin=3,xmax=5)

Let's zoom in.

plot(f,xmin=3.9,xmax=4.1)

It looks like the limit is 0.25.

Finding Limits Numerically

Now let's consider limits numerically. We want to see what happens to f(x)f(x) when we make xx close to something. Since it may make a difference whether we approach from the left or right, we should estimate both.

Example 4

Estimate limx0sin(x)x\displaystyle\lim_{x\to0}\frac{\sin(x)}{x}.

To do this we'll need to estimate limx0+sin(x)x\displaystyle\lim_{x\to0^+}\frac{\sin(x)}{x} and limx0sin(x)x\displaystyle\lim_{x\to0^-}\frac{\sin(x)}{x}.

First, we'll do the right limit. So I am going to calculate f(x)f(x) for values of xx close to 00, but greater than 00. I'll use 0.10.1, 0.010.01, 0.0010.001, etc. for my inputs.

f(x)=sin(x)/x
f(.1)
f(.01)
f(.001)
f(.0001)
f(.00001)
f(.000001)
f(.0000001)
0.998334166468282 0.999983333416666 0.999999833333342 0.999999998333333 0.999999999983333 0.999999999999833 0.999999999999998

Notice that the outputs get closer and closer to 1, so it looks like limx0+sin(x)x=1\displaystyle\lim_{x\to0^+}\frac{\sin(x)}{x}=1

Now let's do the left limit. I need values of xx close to 00 but less than 00, so I'll use 0.1-0.1, 0.01-0.01, 0.001-0.001, etc.

f(-.1)
f(-.01)
f(-.001)
f(-.0001)
f(-.00001)
f(-.000001)
f(-.0000001)
0.998334166468282 0.999983333416666 0.999999833333342 0.999999998333333 0.999999999983333 0.999999999999833 0.999999999999998

Once again the outputs get closer and closer to 1, so it looks like limx0sin(x)x=1\displaystyle\lim_{x\to0^-}\frac{\sin(x)}{x}=1.


So I conclude the two-side limit is also 11: limx0sin(x)x=1\quad\displaystyle\lim_{x\to0}\frac{\sin(x)}{x}=1.

[Note: This is not a proof that the limit is 1, it is simply numerical evidence.]

Example 5

Estimate limx4x216x4\displaystyle\lim_{x\to4}\frac{x^2-16}{x-4}.

First let's estimate the limit from the right. I need inputs close to 44 but bigger than 44. I'll use 4.14.1, 4.014.01, 4.0014.001, etc.

f(x)=(x^2-16)/(x-4)
f(4.1)
f(4.01)
f(4.001)
f(4.0001)
f(4.00001)
f(4.000001)
f(4.0000001)
8.10000000000002 8.00999999999998 8.00100000000103 8.00010000000828 8.00000999982319 8.00000099831254 8.00000010658141

The outputs get closer and closer to 88, so it looks like the right limit is 88.


Now let's look at the limit from the left. Now I need numbers less than 44, so I'll use 3.93.9, 3.993.99, 3.9993.999, etc.
f(3.9)
f(3.99)
f(3.999)
f(3.9999)
f(3.99999)
f(3.999999)
f(3.9999999)
7.90000000000000 7.99000000000002 7.99900000000075 7.99989999999173 7.99998999999917 7.99999899991110 7.99999989341859

Once again, the outputs get closer and closer to 88, so it looks like the left limit is also 88. So I conclude limx4x216x4=8\displaystyle\lim_{x\to4}\frac{x^2-16}{x-4}=8.

Example 6

Estimate limx1x9+1x+1\displaystyle\lim_{x\to-1}\frac{x^9+1}{x+1}.

Once again, we'll look at the limit from the left and right.

First, approximate limx1+x9+1x+1\displaystyle\lim_{x\to-1^+}\frac{x^9+1}{x+1}.

I want values slightly bigger than 1-1 that approach 1-1. I'll use 0.9-0.9, 0.99-0.99, 0.999-0.999, etc. [Note that these values are bigger than 1-1.]

f(x)=(x^9+1)/(x+1)
f(-.9)
f(-.99)
f(-.999)
f(-.9999)
f(-.99999)
f(-.999999)
f(-.9999999)
6.12579511000000 8.64827525163591 8.96408387412594 8.99640083987451 8.99964000839680 8.99996400013025 8.99999639954673

The outputs get closer and closer to 99, so it looks like the right limit is 99.

Now approximate limx1x9+1x+1\displaystyle\lim_{x\to-1^-}\frac{x^9+1}{x+1}. I need inputs close to 1-1 and less than 1-1. I'll use 1.1-1.1, 1.01-1.01, 1.001-1.001, etc. [Note that these values are less than 1-1.]

f(x)=(x^9+1)/(x+1)
f(-1.1)
f(-1.01)
f(-1.001)
f(-1.0001)
f(-1.00001)
f(-1.000001)
f(-1.0000001)
13.5794769100000 9.36852726843608 9.03608412612599 9.00360084012607 9.00036000840086 9.00003600009180 9.00000359934304

Once again, the outputs get closer and closer to 99, so it looks like the left limit is also 99.


Therefore, I conclude that limx1x9+1x+1=9\displaystyle\lim_{x\to-1}\frac{x^9+1}{x+1}=9 (you could confirm this using algebra).

Computing Limits Using Sage

You can use the limit command to compute limits in Sage: limxaf(x)=\displaystyle\lim_{x\to a}f(x)= limit(f(x),x=a)

Example 7

First, let's try limx0sin(x)x\displaystyle\lim_{x\to0}\frac{\sin(x)}{x}.

limit(sin(x)/x,x=0)
1

You can also use a function name in the limit command.

f(x)=sin(x)/x
limit(f(x),x=0)
1

Example 8

Now let's try limx1x9+1x+1\displaystyle\lim_{x\to -1}\frac{x^9+1}{x+1}.

limit((x^9+1)/(x+1),x=-1)
9

We can also compute limits at ±\pm\infty (end behavior).

Example 9

Find limx(x2+xx2+1)\displaystyle\lim_{x\to\infty}\left(\sqrt{x^2+x}-\sqrt{x^2+1}\right).

limit(sqrt(x^2+x)-sqrt(x^2+1),x=+Infinity)
1/2

Here's a graph that confirms limx(x2+xx2+1)=12\displaystyle\lim_{x\to\infty}\left(\sqrt{x^2+x}-\sqrt{x^2+1}\right)=\frac{1}{2}.

plot(sqrt(x^2+x)-sqrt(x^2+1),xmin=0,xmax=100)+plot(.5,xmin=0,xmax=100,color='red',linestyle='dotted',ymin=-.2,ymax=.6)

Example 10

Find limxsin(x)x\displaystyle\lim_{x\to-\infty}\frac{\sin(x)}{x}.

limit(sin(x)/x,x=-Infinity)
0
plot(sin(x)/x,xmin=-50,xmax=0)

We have to be careful when we do two-sided limits, because Sage may lead us astray.

Example 11

Consider limx01x\displaystyle\lim_{x\to0}\frac{1}{x}. We know from the graph that the left and right limits are different (one is positive infinity and the other is negative infinity). But look at what Sage tells us:

limit(1/x,x=0)
Infinity
plot(1/x,xmin=-5,xmax=5,ymin=-25, ymax=25)

In this context, 'Infinity' refers to complex infinity, in which case postive and negative are not distinguished.

It's a good idea to check your answers with a quick graph. Then you won't have to worry about this.

One-Sided Limits

To do one-sided limits in Sage, simply add dir='+' or dir='-' to the limit command.

limit(1/x,x=0,dir='+')
+Infinity
limit(1/x,x=0,dir='-')
-Infinity

Example 12

Here is an example of a piecewise function: $$f(x)=\begin{cases} x^2, & \text{if } -5\le x\le 2\\ -2x+5, & \text{if } 2

Sage is able to graph a piecewise function, although it inserts some extra horizontal line segments that shouldn't really be there.

f=piecewise([[(-5,2),x^2],[(2,3),-2*x+5],[(3,5),x^3/10]])
plot(f,xmin=-5,xmax=5)

We can see from the graph that limx2f(x)\displaystyle\lim_{x\to2}f(x) does not exist. We may want to find limx2+f(x)\displaystyle\lim_{x\to2^+}f(x) and limx2f(x)\displaystyle\lim_{x\to2^-}f(x), but Sage's limit command is not yet able to handle piecewise functions. Instead, we'll have to figure out which formula to give the limit. In this case, limx2+f(x)=limx2+(2x+5)=1\displaystyle\lim_{x\to2^+}f(x)=\lim_{x\to2^+}(-2x+5)=1 and limx2f(x)=limx2x2=4\displaystyle\lim_{x\to2^-}f(x)=\lim_{x\to2^-}x^2=4.

limit(-2*x+5,x=2,dir='+')
limit(x^2,x=2,dir='-')
1 4

Limits Involving More Than One Variable

Sage can also evaluate limits involving more than one variable. Don't forget to declare all variables other than xx.

Example 13

Suppose f(x)=x2f(x)=x^2. Evaluate limh0f(x+h)f(x)h\displaystyle\lim_{h\to 0}\frac{f(x+h)-f(x)}{h}.

%var h
f(x)=x^2
limit((f(x+h)-f(x))/h,h=0)
2*x

Putting It All Together

Here is an example that uses the graphical, numerical, and computational approaches to evaluate a limit.

Example 14

Find limx0sin(1x)\displaystyle\lim_{x\to0}\sin\left(\frac{1}{x}\right).

plot(sin(1/x))

Let's zoom in.

plot(sin(1/x),xmin=-.1,xmax=.1)

From the graph, we can see that there is a lot of oscillation near 00. Let's see what happens numerically.

We'll start with input values that approach 00 from the right.

f(x)=sin(1/x)
f(0.1)
f(0.01)
f(0.001)
f(0.0001)
f(0.00001)
f(0.000001)
f(0.0000001)
-0.544021110889370 -0.506365641109759 0.826879540532003 -0.305614388888252 0.0357487979865591 -0.349993502171293 0.420547793190783

These values do not appear to approach anything. Notice how they jump between positive and negative, and the magnitudes get bigger and smaller.

Now let's consider input values approaching 00 from the left.

f(-0.1)
f(-0.01)
f(-0.001)
f(-0.0001)
f(-0.00001)
f(-0.000001)
f(-0.0000001)
0.544021110889370 0.506365641109759 -0.826879540532003 0.305614388888252 -0.0357487979865591 0.349993502171293 -0.420547793190783

Once again, it does not appear that the outputs are approaching anything.

Let's see what Sage tells us.

limit(sin(1/x),x=0,dir='+')
limit(sin(1/x),x=0,dir='-')
limit(sin(1/x),x=0)
ind ind ind

Whether we try a one- or two-sided limit, Sage gives the same answer: "ind." This stands for "indefinite but bounded," but for us this means "does not exist."

This confirms what we saw on the graph and from the numbers. This should make sense algebraically as well. As xx approaches 00, 1x\frac{1}{x} approaches ±\pm \infty. As the magnitude of the input gets larger, the sine function continues to oscillate between 11 and 1-1.

Limits that do not exist

There are several different outputs in Sage that are possible when a limit does not exist.

  1. und = "undefined" (this happens when the left and right limits exist but do not agree)

  2. ind = "indefinite but bounded" (this happens when you have oscillation, like in the example above)

  3. Infinity = "complex infinity" (the left limit is \infty and the right limit is -\infty, or vice versa)

  4. +Infinity = \infty (the function increases without bound)

  5. -Infinity = -\infty (the function decreases without bound)

Here are examples of each:

limit(x/abs(x),x=0)
und
limit(sin(1/x),x=0)
ind
limit(1/x,x=0)
Infinity
limit(1/x^2,x=0)
+Infinity
limit(-1/x^2,x=0)
-Infinity