Mathematica Labs | Denis Shubleka

Subject: Calculus

Topic: Sequences and Series

Goal: Use Mathematica to explore the behavior of sequences and series.

Task 1

The Limit command helps us determine whether a sequences converges or diverges.
Find the infinity symbol in the Basic Math Assistant palette or simply type 
Infinity. Below we look at a few sequences that you may have encountered in your
assigned reading or class notes. We’ll start with an easy one:

Limit[(1/n),n->Infinity]

Your turn: investigate the following sequences using Mathematica:

a){n cos((π/n))}

b) {((n!)/(n^n))}

c) {(((-1))^n)}

d) {((cos(n))/(n^2))}

e) {((((-1))^n)/(n^2))}

It may be helpful to also plot the sequence, to visually confirm Mathematica’s 
answers. Input and run the following:

DiscretePlot[(1/n),{n,1,100}]

Task 2

An infinite series (∑_(n=1)^∞)(Subscript[a, n]) is the sum the terms of a sequence {(Subscript[a, n])}. When the sum
exists, we say that the series converges; otherwise, it diverges.

Let us ask Mathematica to test a few series. Try these, one at a time:

(∑_(n=1)^∞)(1/n)
(∑_(n=1)^∞)(1/(n^2))
(∑_(n=2)^∞)(1/(Sqrt[n]))
(∑_(n=1)^∞)(((-1))^n)
(∑_(n=1)^∞)Sin[n]

The Sum command can also be used to work with series, especially when an added variable is involved. To get the sum of the geometric series: 1 + (x^3)+(x^6)+(x^9)+...,
enter and run the following:

Sum[(x^n),{n,0,∞,3}]

Remember that the geometric series above will converge whenever the ratio is less
than 1 in absolute value. Mathematica does not tell us that |(x^3)|<1,   which is 
equivalent to |x|<1.

Next, we take a look at the Series command, which gives the Taylor Series of an
algebraic expression. Think of this command as the inverse process of Sum. The 
example below gives the Taylor series representation of (1/(1-x)) , centered at x=0 and 
expanded up to degree 6.

Series[(1/(1-x)),{x,0,6}]

The big O term simply indicates that there are more
terms. Use the Normal command to eliminate the big O term from the final answer,
as shown below.

Normal[%]

It is helpful to compare the original function and its Taylor Polynomial in the
same plot:

Plot[{%,(1/(1-x))},{x,-1,1}]

Would the Taylor Polynomial (Subscript[T, 6])(x) do a good approximation job for x values close 
to 0?

Task 3

To get a general formula for the Taylor series expansion, type and execute:

Normal[Series[f[x],{x,a,5}]]

Next, we define a general function findTaylor that helps us compute a Taylor polynomial for f(x), centered at x=(Subscript[x, 0]) with degree n.

findTaylor[f_,{x_,x0_},n_]:=Normal[Series[f[x],{x,x0,n}]]

Let us put this operation to the test by determining a representation of two 
common trig functions:

findTaylor[Sin,{x,0},7]

Recall that 5!=120 and 7!=5040. The result should not be surprising. And here is 
one more example:

findTaylor[Cos,{x,(ℼ/3)},6]

Feel free to plot the Taylor Polynomial above and y = Cos[x] in the same window.

Plot[{%,Cos[x]},{x,-3,3}]

Related Exercises/Notes:

ap-calc.github.io