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.
Path: blob/main/142-Labs/Lab 07 - Sequences and Series.ipynb
Views: 491
Lab 07 - Sequences and Series
Overview
In this lab, we will use SageMath to determine the convergence or divergence of a sequence of numbers and of infinite series.
Important SageMath Commands Introduced in this Lab
ParseError: KaTeX parse error: Undefined control sequence: \hfill at position 32: …|l|l|} \hline \̲h̲f̲i̲l̲l̲ ̲\textbf{Command…Related Course Material
Example 1
Consider the sequence . We start by determining the first 10 terms of this sequence. We can do this in SageMath by letting and then using a loop and the command.
We can get a better idea of what these numbers are by using the command.
Note that the terms of the sequence do not appear to approach a specific number. We can better tell what is happening by plotting the first 100 or so terms of the sequence. We can plot a point in SageMath by using the command along with the command. To plot multiple points on the same plot, we will store the points in a list and then show the list. SageMath does not allow us to plug the list directly into the command. Instead, we must input the sum of the elements in the list.
From the graph, we see that the odd terms are approaching a specific value, namely , and the even terms are approaching a specfic value, namely However, since these values are different, the sequence diverges.
We can check our answer in SageMath.
The output for a limit means that the answer is indefinite but the terms are bounded.
Example 2
Consider the sequence . Again, let us find the first 10 terms of this sequence. In order to define , we need to recall how to define a summation in SageMath. One way to do this is to place all of the summands into a list and then use the command. Let's practice this with . We know that when , we should get
Now that we know how to define the summation in SageMath, we can create the sequence .
Now, let's use our definition of to find the first 10 terms of the sequence.
To better see if these number are approaching a specific number, we can round.
It looks like the terms are getting closer together. Let's plot the first 100 terms and see.
According to the graph, these terms are converging to a specific number. In fact, they are converging to .
SageMath has the ability to tell us that this is indeed what the sequence converges to. Unfortunately, it will not work with our current definition of .
To fix this, we can use the command to define our summation instead of a loop. Let's first test this command with and make sure that we get as expected.
Therefore, we will use the command and let .
Example 3
A typical format for a recursively defined sequence is for with given explicitly. Under the assumptions that converges to and is a continuous function, we have that Therefore, must be a solution to This equation is often difficult to solve by hand, but we can use SageMath to find a solution.
Consider the recursive sequence defined by and . Let's determine the first 10 terms of this sequence.
We can round our outputs by either using the command or by starting with instead of .
It appears that the terms are converging to . First, let's check this by plotting the first 100 terms and the line .
A second way to verify that the sequence converges to is to solve the equation ; that is, we need to solve the equation We can solve this in SageMath by using the command.
Unfortunately, SageMath offers no help with the equation in its current state. However, we can simplify the equation a bit by squaring both sides and obtaining . Now, we can ask SageMath to solve this equation.
SageMath returns the two answers and . We know that will always be positive. Thus, the solution is not possible. Therefore, we find that the sequence converges to .
Example 4
For each of the following sequences generate the first 10 terms, plot the first 100 terms, and determine whether the sequence converges or diverges. If it converges, determine the exact value it converges to.
You need to use for n!
Example 5
Consider the recursive sequence , where . Generate the first 10 terms, plot the first 100 terms, and verify that the sequence converges to .