Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download

All published worksheets from http://sagenb.org

Views: 168714
Image: ubuntu2004

Limit Basics

This worksheet will introduce you to the basics of using Sage to find limits.  Please read through it and then try some examples from the text. I've left some empty cells at the end of each section so you can type in your own examples (or better yet, copy the code from above and then change it to fit your example).

If you would like to modify this sheet and try examples, just click "login to edit a copy" at the top of the screen. If you have not created a user account yet, please do so. Creating your own account will let you copy this worksheet and more.  If you have internet access at home, you can always use these worksheets from the web and you won't have to download and install any software.

#auto #This first line just defines x and y to be variables so that I can use them below. var('x,y')
(x, y)

Remember that limits can be computed in 3 ways.

  1. By computing a number
  2. By constructing a graph
  3. By using algebra

The following example contructs a table, gives the limit, and then shows a graph of the function f(x) at x=c.  Just change f(x) and c, and then evaluate the cell. The x values appear on the left, and the y values appear on the right. This block of code can be used to study most problems in the section.

Tip: Type Shift+Enter while in a cell to evaluate it, rather than clicking evaluate.

Try: Try using this code to do problems 2.1:18-20, 41-46

var('x') f(x)=sin(x)/x c=0 print matrix([[a,f(a).n(digits=5)] for a in (c+.5,c+.1,c+.01,c+.001,c+.0001)]) print matrix([[a,f(a).n(digits=5)] for a in (c-.5,c-.1,c-.01,c-.001,c-.0001)]) f(x).limit(x=c).show() plot(f(x),(x,c-2,c+2))
[ 0.50000 0.95885] [ 0.10000 0.99833] [ 0.010000 0.99998] [ 0.0010000 1.0000] [0.00010000 1.0000] [ -0.50000 0.95885] [ -0.10000 0.99833] [ -0.010000 0.99998] [ -0.0010000 1.0000] [-0.00010000 1.0000]
1

Basic Limit Commands

Let's now just look at some basic commands to find limits.  Once you have entered a function, you can type f. (f and then a period) and hit the tab key.  Doing so will open up a huge list of commands you can use on f.  In the examples below, I'll show you how to print f, make it show up nicely as a fraction using .show(), compute a limit, factor, simplify, get denominators and numerators, and plot.

Try: Use this code to try any of the problems in 2.2

var('x') f=(x^2-3*x+2)/(x^2-1)
print f
(x^2 - 3*x + 2)/(x^2 - 1)
f.show()
\frac{{(x^{2} - 3 \, x + 2)}}{{(x^{2} - 1)}}
f.limit(x=1)
-1/2
limit(f,x=1)
-1/2
f.factor()
(x - 2)/(x + 1)
f.full_simplify()
(x - 2)/(x + 1)
f.numerator()
x^2 - 3*x + 2
f.numerator().factor()
(x - 2)*(x - 1)
f.denominator().factor()
(x - 1)*(x + 1)
f.plot(0,2)
f.plot(-3,3,ymin=-3,ymax=3)

This is an example of how to use Sage to help you see the computations involved when you must rationalize either the numerator or denominator.  Use the expand() function to force Sage to multiply factors.

var('x') f=(sqrt(x^2+5)-3)/(x-2)
f.show()
\frac{{(\sqrt{x^{2} + 5} - 3)}}{{(x - 2)}}
print (f.numerator()*(sqrt(x^2+5)+3)).expand().factor() print (f.denominator() * (sqrt(x^2+5)+3))
(x - 2)*(x + 2) (sqrt(x^2 + 5) + 3)*(x - 2)
f.limit(x=2)
2/3

One-Sided Limits

You can use Sage to compute one-sided limits as well. All you have to do is add "dir = 'above' " or "dir = 'below' " to the limit command. Remember that a limit exists if and only if both one sided limits exist and are the same.

Try: Use this code to try any of the problems in 2.4. In particular, 2.4: 7-8, 15-18.

var('x') f=abs(x)/x c=0
f.limit(x=c,dir='above')
1
f.limit(x=c,dir='below')
-1
f.limit(x=c)
und
f.plot(c-1,c+1)

Warning: Sage gives limits sometimes when we would not give limits.  For example, the limit from the left of 0 for sqrt(x) should be undefined, but Sage gives the value 0.  Different textbooks define limits slightly differently, and this difference leads to the discrepancy you see here.

f=sqrt(x) f.limit(x=0,dir='below')
0

Infinite Limits and Limits at Infinity

You can also compute infinite limits (to find vertical aymptotes) and infinite limits (to find horizontal asymptotes).  Just type "x=infinity" to compute a limit at infinity.

Try: Use this code to try problems in 2.4 and 2.5 In particular, 2.4: 41, 55, 59, 53 (use ^(1/3) to get a cube root) and 2.5:5, 7, 21, 31, 33

var('x') f=(x^2-3*x+2)/(x^2-1)
f.limit(x=infinity)
1
f.limit(x=-infinity)
1
f.limit(x=-1)
und
f.limit(x=-1,dir='above')
-Infinity
f.limit(x=-1,dir='below')
+Infinity
f.plot(-10,10,ymin=-10,ymax=10)

Average and Instantaneous Velocity

The example below computes the slope of the line connecting the point (x1,f(x1)) and (x2,f(x2)), as well as draws f and the line through these two points.  If f(x) represents the position of an object. then this slope represents the average vecity from x=x1 to x=x2.  To find the instantaneous velocity at x1, change x_3 so that it gets closer and closer to x1. In the example below, let x2 be the following values: 2, 1.5, 1.1, 1.01, 1.001.  You should notice that the slope of the line approaches 2.  Try changing the funciton and the value of x1.

Try: Use this code to try 2.1: 38-40

var('x') f(x)=x^2 x1=1 x2=3 plotrange=(x,0,4) m=(f(x2)-f(x1))/(x2-x1) m.show() plot(f(x),plotrange,color='blue')+plot(f(x1)+m*(x-x1),plotrange,color='red')
4