Infinite Series Mathematica Introduction
Author
Abby Brown
Title
Infinite Series Mathematica Introduction
Description
Numerically and graphically representing sequences and series. Written as a handout for calculus students.
Category
Educational Materials
Keywords
series, sequences, DiscretePlot, discrete plot, calculus, limits, limit, sum, NSum, Table, harmonic series, p-series, CT@TP, Computational Thinking, Torrey Pines High School, beginner, introduction, school, teachers, students, Abby Brown
URL
http://www.notebookarchive.org/2018-10-61p3ex1/
DOI
https://notebookarchive.org/2018-10-61p3ex1
Date Added
2018-10-13
Date Last Modified
2018-10-13
File Size
50.99 kilobytes
Supplements
Rights
Redistribution rights reserved



Infinite Series Mathematica Introduction
Read the notes below. Type and evaluate (shift-enter) the items listed with In[#]:= below.
You do not need to retype similar examples. Copy/paste/edit what you already did and evaluate.
You do not need to retype similar examples. Copy/paste/edit what you already did and evaluate.
Tip: Turn off the Suggestions Bar. When you evaluate something, turn that off by clicking the x on the right.
p-Series: ∞∑n=112n
p-Series:
∞
∑
n=1
1
2
n
Out[]=
Let's look at the series by starting with a plot of the sequence using DiscretePlot .
∞
∑
n=1
1
2
n
1
2
n
In[]:=
DiscretePlot[1/n^2,{n,1,20}]
You can remove the bars by using the option Filling→None as below. However, in the rest of the examples I have chosen to include the bars. You may remove them if you prefer.
You can remove the bars by using the option Filling→None as below. However, in the rest of the examples I have chosen to include the bars. You may remove them if you prefer.
In[]:=
DiscretePlot[1/n^2,{n,1,20},FillingNone]
Add some options to help make the plot look better. Try adding each option separately to see how it affects the plot. Follow the example below. Note that this plot is also set equal to seq1overnsq (sequence 1 over n squared). We are giving this plot a name for future use.
Add some options to help make the plot look better. Try adding each option separately to see how it affects the plot. Follow the example below. Note that this plot is also set equal to seq1overnsq (sequence 1 over n squared). We are giving this plot a name for future use.
In[]:=
seq1overnsq=DiscretePlot[1/n^2,{n,1,20},PlotStyle{PointSize[Large],Blue},PlotRangeAll,AxesOrigin{0,0},ImageSize300,PlotLabel"Sequence 1/n^2"]
To see the terms of the sequence, use Table. If you want more terms (or less), change the 20 to another value.
To see the terms of the sequence, use Table. If you want more terms (or less), change the 20 to another value.
In[]:=
Table[1/n^2,{n,1,20}]
The function Sum will allow you to add terms of the sequence together. Use the below to add the first 20 terms.
The function Sum will allow you to add terms of the sequence together. Use the below to add the first 20 terms.
In[]:=
Sum[1/n^2,{n,1,20}]
Using NSum will give you a decimal answer.
Using NSum will give you a decimal answer.
In[]:=
NSum[1/n^2,{n,1,20}]
To see the first 20 partial sums, you need to add the first “m” terms and then allow m to go from 1 to 20. This is done with a combination of Sum (or NSum) and Table. Think about how the code below works.
To see the first 20 partial sums, you need to add the first “m” terms and then allow m to go from 1 to 20. This is done with a combination of Sum (or NSum) and Table. Think about how the code below works.
In[]:=
Table[Sum[1/n^2,{n,1,m}],{m,1,20}]
In[]:=
Table[NSum[1/n^2,{n,1,m}],{m,1,20}]
To make the list vertical, use TableForm.
To make the list vertical, use TableForm.
In[]:=
Table[NSum[1/n^2,{n,1,m}],{m,1,20}]//TableForm
To put the sequence values and the partial sum (series) values along with n, use the following.
Note that //N makes all of the values decimals. Try extending this to more than 20 terms.
To put the sequence values and the partial sum (series) values along with n, use the following.
Note that //N makes all of the values decimals. Try extending this to more than 20 terms.
In[]:=
Table[{m,1/m^2,Sum[1/n^2,{n,1,m}]},{m,1,20}]//TableForm//N
To plot the series, use DiscretePlot the same way you used Table for the partial sums.
To plot the series, use DiscretePlot the same way you used Table for the partial sums.
In[]:=
DiscretePlot[Sum[1/n^2,{n,1,m}],{m,1,20}]
Add options to make the plot look better as we did earlier. You can copy/paste what was included in the sequence plot, however be sure to change the text within the PlotLabel. Note that this plot is named “series1overnsq” for use later.
Add options to make the plot look better as we did earlier. You can copy/paste what was included in the sequence plot, however be sure to change the text within the PlotLabel. Note that this plot is named “series1overnsq” for use later.
In[]:=
series1overnsq=DiscretePlot[Sum[1/n^2,{n,1,m}],{m,1,20},PlotStyle{PointSize[Large],Blue},PlotRangeAll,AxesOrigin{0,0},ImageSize300,PlotLabel"Series 1/n^2"]
Harmonic Series: ∞∑n=11n
Harmonic Series:
∞
∑
n=1
1
n
Out[]=
Let's look at the series and the sequence as we did above with plots and Tables.
∞
∑
n=1
1
n
1
n
In[]:=
DiscretePlot[1/n,{n,1,20}]
Note the options below are similar to what we did for the other sequence, however now I suggest Red and be sure to change the text in PlotLabel. This one is named “harmonicsequence” for future use.
Note the options below are similar to what we did for the other sequence, however now I suggest Red and be sure to change the text in PlotLabel. This one is named “harmonicsequence” for future use.
In[]:=
harmonicsequence=DiscretePlot[1/n,{n,1,20},PlotStyle{PointSize[Large],Red},PlotRangeAll,AxesOrigin{0,0},ImageSize300,PlotLabel"Sequence 1/n"]
Look at the Table of sequence values and evaluate the sum for various amounts of terms. Create a table of partial sums. Look at the sequence terms and partial sums together. Extend this to more terms. See what happens.
Look at the Table of sequence values and evaluate the sum for various amounts of terms. Create a table of partial sums. Look at the sequence terms and partial sums together. Extend this to more terms. See what happens.
In[]:=
Table[1/n,{n,1,20}]
In[]:=
Sum[1/n,{n,1,20}]
In[]:=
NSum[1/n,{n,1,20}]
In[]:=
Table[NSum[1/n,{n,1,m}],{m,1,20}]
In[]:=
Table[{m,1/m,Sum[1/n,{n,1,m}]},{m,1,20}]//TableForm//N
Graphing the partial sums illustrates the series.
Graphing the partial sums illustrates the series.
In[]:=
DiscretePlot[Sum[1/n,{n,1,m}],{m,1,20}]
Add the options to make it look better, change the PlotLabel text, and name this “harmonicseries” for later use.
Add the options to make it look better, change the PlotLabel text, and name this “harmonicseries” for later use.
In[]:=
harmonicseries=DiscretePlot[Sum[1/n,{n,1,m}],{m,1,20},PlotStyle{PointSize[Large],Red},PlotRangeAll,AxesOrigin{0,0},ImageSize300,PlotLabel"Series 1/n"]
All Together
All Together
Use Grid to make a matrix of the plots generated above. You can call them by the names assigned. Look at the graphs together. What do you notice?
In[]:=
Grid[{{seq1overnsq,harmonicsequence},{series1overnsq,harmonicseries}}]
More with Sum and DiscretePlot
More with Sum and DiscretePlot
Sum and NSum can be evaluated with infinitely many terms. See what happens in each case.
In[]:=
Sum[1/n^2,{n,1,Infinity}]
In[]:=
NSum[1/n^2,{n,1,Infinity}]
In[]:=
Sum[1/n,{n,1,Infinity}]
Try using DiscretePlot with more terms. Change 20 to 200, for example.
Try using DiscretePlot with more terms. Change 20 to 200, for example.
In[]:=
DiscretePlot[Sum[1/n,{n,1,m}],{m,1,200},PlotStyle{PointSize[Large],Red},PlotRangeAll,AxesOrigin{0,0},ImageSize300,PlotLabel"Series 1/n"]
If you want it to look like points again, you can change the increments of the points. For example, go from 1 to 200 counting by 10. Note how that adds an element to the domain list below. Notice how it changes the range of the graph by looking at the y-axis. Try 1 to 2000 counting by 100 and look at the range now.
If you want it to look like points again, you can change the increments of the points. For example, go from 1 to 200 counting by 10. Note how that adds an element to the domain list below. Notice how it changes the range of the graph by looking at the y-axis. Try 1 to 2000 counting by 100 and look at the range now.
In[]:=
DiscretePlot[Sum[1/n,{n,1,m}],{m,1,200,10},PlotStyle{PointSize[Large],Red},PlotRangeAll,AxesOrigin{0,0},ImageSize300,PlotLabel"Series 1/n"]
Other Series to Try
Other Series to Try
Use what you have learned in class about infinite series to predict what will happen with the following series. Use what you learned through this activity to create plots and tables to illustrate what they do.
Out[]=
1. Note that the term can be typed as (-1)^(n+1)Sqrt[n]/(5n+1).
∞
∑
n=1
n+1
(-1)
n
5n+1
Out[]=
2. Note that the term can be typed as (n/(3n+1))^n.
∞
∑
n=1
n
n
3n+1
Out[]=
3. Note that the term can be typed as Log[n]/Sqrt[n]. Log is used for ln.
∞
∑
n=1
ln(n)
n
Abby Brown - www.abbymath.com - October 2015
Adapted from “Infinite Series and Mathematica” 10/2002 and 10/2009
Originally written to print and photocopy as a handout for class.
Abby Brown - www.abbymath.com - October 2015
Adapted from “Infinite Series and Mathematica” 10/2002 and 10/2009
Originally written to print and photocopy as a handout for class.
Adapted from “Infinite Series and Mathematica” 10/2002 and 10/2009
Originally written to print and photocopy as a handout for class.


Cite this as: Abby Brown, "Infinite Series Mathematica Introduction" from the Notebook Archive (2018), https://notebookarchive.org/2018-10-61p3ex1

Download

