Lab 10: Instructors’ notes

Week 10

MAT 229, Spring 2021

Sequence

Functions

If you have a formula for a sequence, say (Subscript[a, n])=(((-1))^n)((2^n)/(n!)), you can define it as a function as usual.

Clear[n]
a[n_]:=(((-1))^n)2^n/n!

a[n]

Be aware that often you can only evaluate it for whole number values of n.

Legitimate input values

a[2]

a[3]

Non-legitimate input values

a[1/2]

a[-3]

Plot[a[n],{n,1,10}]
a[2.2]

Generating values

To generate the first few values of a sequence, use the Table command.

Table[a[k],{k,1,10}]

Table[N[a[k]],{k,1,10}]

Note

The name of the index does not matter.

Table[N[a[n]],{n,1,10}]

Try

Create the first 30 decimal values for the sequence (Subscript[{(((-1))^(j+1))(1/(2j-1))}, j=1]^∞).

Table[(-1)^(j+1)1./(2j-1),{j,1,30}]

Try

To see the index along with the value of the sequence at the location include {n,(Subscript[a, n])} in the Table. You can give it a name as well.

sequence=Table[{j,(-1)^(j+1)1./(2j-1)},{j,1,30}]

To view it as a table of values use TableForm or MatrixForm.

TableForm[sequence]

MatrixForm[sequence]

Plotting sequences

Create and name a list of the first 100 decimal values for the sequence {(100^n)((n!+(2n)!)/((3n)!))}.

list=Table[N[{n,(100^n)(n!+(2n)!)/(3n)!}],{n,1,100}]

Use the semicolon to suppress the output if it becomes too long.

Use ListPlot to get a visualization a sequence

ListPlot[list]

Use the PlotRange option if you want to specify the y-range to view.

ListPlot[list,PlotRange->{0,2}]

Series

Approximate infinite series with its partial sums.

Geometric series

(((Underoverscript[Σ, (k=0), ∞])(0.7))^k)≈(((Underoverscript[Σ, (k=0), 10])(0.7))^k)=1+0.7+(((0.7))^2)+(((0.7))^3)+…+(((0.7))^10)

Sum[0.7^k,{k,0,10}]

Note

Geometric series (Underoverscript[Σ, (k=0), ∞])a (r^k) converges if |r|<1 and converges to a (1/(1-r)). What is the error in the approximation (((Underoverscript[Σ, (k=0), ∞])(0.7))^k)≈(((Underoverscript[Σ, (k=0), 10])(0.7))^k)?

Example

To study the series (Underoverscript[Σ, (k=1), ∞])(1/((k^3)+1)) create a sequence of partial sums (Subscript[s, n])=(Underoverscript[Σ, (k=1), n])(1/((k^3)+1)).

Clear[n]
s[n_]:=Sum[1/(k^3+1),{k,1,n}]

s[1]

s[10]

The exact value is not too helpful. Change the 1 to 1.0 to get just decimal values.

s[n_]:=Sum[1.0/(k^3+1),{k,1,n}]

s[10]

A sequence of the first 20 partial sums:

partial=Table[{n,s[n]},{n,1,50}]

Plot them.

ListPlot[partial]

Combine this plot with a plot of the horizontal line y=0.069 using the Show command.

Show[
Plot[0.69,{x,1,50},PlotLabel->"Partial Sums"], (* Show takes its marching orders from the first plot.... *)
ListPlot[partial]
]