Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
License: OTHER
Image: ubuntu2004

licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.
Prerequisites:
Intro to Sage
Sequences
A sequence is simply an ordered list of objects. We will consider countably infinite lists of numbers. Such a sequence may be considered as a function with domain the set of positive integers and codomain the real numbers.
The elements (or terms) of a sequence are usually denoted using subscripts rather than function notation: .
The sequence is then denoted , or more explicitly . The integer is called the index of .
Example 1
Consider the sequence
This may be written in various ways:
for
.
Of course, there is really no reason to start with all the time.
for
These give the same sequence.
Infinite sequences may be defined in various ways.
A list of numbers with some discernible pattern.
An explicit forumla for the term.
A recursive formula that gives one term in terms of one or more previous terms.
Example 2
List of numbers:
(prime numbers)
Example 3
Explicit formula:
(unless otherwise stated, we'll assume starts at 1)
Example 4
Recursive definition:
for , , (Fibonacci Sequence)
Graphing a Sequence
To graph a sequence, you put the index variable on the x-axis and the sequence values on the y-axis.
One way to graph a sequence in Sage is to use the "point" command with an imbedded for-loop.
Example 5
Graph the first 50 terms of .
(Be very careful with the brackets and parentheses.)
Example 6
Graph the first 50 terms of the sequence .
I'll set up the formulas so you can cut and paste for your assignment.
Example 7
Graph the first 10 terms of the Fibonacci Sequence: for , , .
There are different ways you might deal with this recursive definition in Sage. I will use a list. One issue is that a list in Sage always begins with index 0, while our sequence begins at 1. I'm going to get around this by sticking an extra 0 in the zero position.
Writing a=[0,1,1] makes a list of three numbers.
The first item in the list has index 0. You can access this by typing a[0]. Similarly, a[2] is the element in the list with index 2 (the third element in the list).
Example 8
Graph the first 20 terms of the sequence for , .
Limit of a Sequence
If the sequence approaches some fixed number as , then we call this the limit of the sequence. We write .
Here is the formal definition:
If for every there exists such that whenever , then .
In other words, you can get the terms of the sequence arbitrarily close to by making big enough.
Example 9
Let's explore the definition of a limit graphically, using .
In the interactive box below, represents the potential limit, and is the from the definition. If really is the limit, then eventually the sequence will stay in the band between and .
Is the sequence eventually inside the red band?
Now make epsilon smaller (you may need to increase the starting and ending indices).
Computing Limits with Sage
If we have an explicit formula, we can often compute the limit using Sage.
The limit command treats the sequence as a function on the real numbers, rather than just on the whole numbers. That means the limit command can give us the wrong answer.
Example 10
Consider
Here Sage gives the answer "ind," which means "indefinite but bounded." If we look at a graph of the function , we can see why the limit does not exist: the function oscillates between and forever.
However, the limit of the sequence does exist. When is a whole number, for all , so the limit of the sequence is .
If we have a recursive definition, then our best bet is to look at the graph to see if it looks like the limit exists. Then calculate many, many values of the sequence and see where we end up.
Example 11
If is the Fibonacci Sequence, then consider the sequence .
First, let's look at a graph.
It looks like the sequence is approaching a limit, somewhere around 1.6.
Let's compute values of the sequence and approximate what the limit is.
Try increasing "terms" and see what happens.
The actual limit of this sequence is the "Golden Ratio," denoted by the Greek letter . The actual value is .
Example 12
Estimate the limit of the sequence for , .
Solution: First, we'll graph the first 20 terms to see if the limit exists.
It looks like the limit exists. Graphically, we estimate that the limit is 1.
Let's confirm this numerically by calculating 50 terms.
It looks like the limit is indeed 1.