Plotting sequences in Mathematica

The Harmonic Series

Recall Example 8 in Section 11.2, about the harmonic series.  In the example, we looked at plots of the sequence of terms {(Subscript[a, n])} and the sequence of partials sums {(Subscript[s, n])}.  (Figure 3.)  We can do this ourselves using Mathematica.

We want to plot the sequences (Subscript[a, n])=(1/n) and (Subscript[s, n])=(Underoverscript[∑ , ( k=1), n])(1/k).

To plot sequences of points in Mathematica, we need to create tables points (n,(Subscript[a, n])) and (n, (Subscript[S, n])).  The following commands create 100 points for each sequence.

aPoints1=Table[{n, 1/n}, {n, 1, 100}];

sPoints1= Table[{n, Sum[1/k, {k, 1, n}]}, {n, 1, 100}];

Now we plot the points to see the trends in (Subscript[a, n]) and (Subscript[s, n]):

ListPlot[{aPoints, SPoints}, PlotStyle->{Red, Blue}]

Another Example

Suppose we want to plot the sequence of terms and the sequence of partial sums for the series (Underoverscript[∑ , ( n=1), ∞])(1/(n^2)).  

So we want to plot the sequences (Subscript[a, n])=(1/(n^2)) and (Subscript[s, n])=(Underoverscript[∑ , ( k=1), n])(1/(k^2)).

We create tables of points (n,(Subscript[a, n])) and (n, (Subscript[S, n])).

aPoints2=Table[{n, 1/n^2}, {n, 1, 100}];

sPoints2= Table[{n, Sum[1/k^2, {k, 1, n}]}, {n, 1, 100}];

Now we plot the points to see the trends in (Subscript[a, n]) and (Subscript[s, n]):

ListPlot[{aPoints2, sPoints2}, PlotStyle->{Red, Blue}]

Quality Solution

Suppose we want to plot the sequence of terms and the sequence of partial sums for the series given in 11.2.9.

First create tables of points (n,(Subscript[a, n])) and (n, (Subscript[S, n])).   Modify the commands below by inserting (Subscript[a, n]) and (Subscript[a, k]) in the appropriate places.

aPoints3=Table[{n, --- }, {n, 1, 100}];

sPoints3= Table[{n, Sum[---, {k, 1, n}]}, {n, 1, 100}];

Next plot the points to see the trends in (Subscript[a, n]) and (Subscript[s, n]):

ListPlot[{aPoints3, sPoints3}, PlotStyle->{Red, Blue}]