Sequences and Series

This lab introduces the Mathematica commands ListPlot[ ], Table[ ], Sum[ ], and NSum[ ].  Before you begin working, review the Mathematica  command  Limit[ ] that is in both the hard copy and on-line versions of  "Mathematica Reference".   Mathematica now allows us to use  "Free-form input" to enter many commands.  Unfortunately, there are some things that we can’t do using "Free-form input" and it helps to learn the formal commands.

Some examples are done below.  Read the examples carefully to understand the commands.  Position your cursor anywhere on the first input line (the indented lines are input lines), click the mouse, and press the Enter key on the far right of the computer by the numeric keyboard or Shift+Enter (Shift+Return on a Macintosh) on the alphabetical keyboard to execute the commands.  Study the result and, after you understand what happened, move your cursor to the next input line and enter it.  Continue until you reach the end of the notebook.

Examples

Sequences

EXAMPLE 1: To list the values of a sequence we can use the command Table[ ].  Every time you ask Mathematica to carry out an operation, the Wolfram Predictive Interface gives you a Suggestions Bar that is relevant to the current output.  If the Suggestions Bar seems to have disappeared completely, click on the output cell and it will reappear.There does not appear to be a "Free-form input" that we can use to get a table.   If we want the entries of the table in their decimal form, we can use N[% ] where % stands for the last output, or you can start with NTable[ ], or we can click on "more" from the Suggestions Bar and then select "numerical value".  Enter the  lines below where we are looking at the sequence given by {(Subscript[a, n])} = {(n/(n + 1))}.

Table[(n/(n+1)),{n,1,50}]

N[%]

N[Table[(n/(n+1)),{n,1,50}]]

To plot this sequence of values, we click on "plot points" from the Suggestions Bar or we can use ListPlot[ ] as in the line below.

ListPlot[Table[(n/(n+1)),{n,1,50}]]

It appears that this sequence converges to 1.  We can check this by using either the formal Mathematica command or the "Free-form input" below.  You can pull down the Palettes to either Basic Math Assistant  or Classroom Assistant to get the "->" symbol or use a hyphen followed by the "greater than" symbol.

Limit[(n/(n+1)),n->∞]

EXAMPLE 2:  Suppose that we want to compare the rates of growth of two sequences.  If we look at the sequence  {((ln(n))/n)}  we see that it appears to converge.  Remember that Mathematica uses  Log[n]  for ln(n) .

ListPlot[Table[((Log[n])/n),{n,1,30}]]

To see more points we extend our range for  n  to n = 50.

ListPlot[Table[((Log[n])/n),{n,1,50}]]

If we use Mathematica's Limit[ ] command or "Free-form input" we see that the limit is zero, this shows that  {ln (n)} grows more slowly than {n}.  If you use the "Free-form input", click on the " +" in the upper right hand corner of the box around the command, and then click on "Step-by-step solution", Mathematica will show you how to use l’Hôpital’s Rule to find the limit.

Limit[((Log[n])/n),n->∞]

If we look  at a second sequence {((ln(n))/(Sqrt[n]))}, we can again start by plotting it.

ListPlot[Table[((Log[n])/(Sqrt[n])),{n,1,50}]]

This sequence also appears to converge  and again we can use l’Hôpital’s Rule, Mathematica’s Limit[ ] command, or "Free-form input" to show that  the limit is zero.

Limit[((Log[n])/(Sqrt[n])), n->∞]

Both sequences {((ln[n])/n)} and {((ln[n])/(Sqrt[n]))} converge to zero but the graphs imply the second sequence {((ln[n])/(Sqrt[n]))} converges to 0  slower than the first sequence {((ln[n])/n)}.   This makes sense since (Sqrt[n ]) ≤ n  ⇒  (1/(Sqrt[n])) ≥ (1/(n )) ⇒((ln(n) )/(Sqrt[n])) ≥ ((ln(n))/n); this tells us that  {((ln(n))/n)} will go to  0  more quickly.  We can plot the two sequences together with the following line.  The command PlotLegends->{f1, f2} gives us a color code that identifies the sequences.

ListPlot[{Table[((Log[n])/(Sqrt[n])),{n,1,50}],Table[((Log[n])/n),{n,1,50}]},PlotLegends->{((Log[n])/(Sqrt[n])),((Log[n])/n)}]

EXAMPLE 3: Some sequences never settle down like {(((-1))^n)cos(((n π)/12))}

ListPlot[Table[(((-1))^n) Cos[((n π)/12)],{n,1,50}]]

some tend toward more than one value like {sin(nπ/2)}

ListPlot[Table[Sin[((n π)/2)],{n,1,50}]]

some eventually settle down even though the terms jump around a lot like {((sin(n))/n)}

ListPlot[Table[((Sin[n])/n),{n,1,50}]]

some have two separate branches that eventually merge to one limit like {((((-1))^n)/n)}

ListPlot[Table[((((-1))^n)/n),{n,1,50}]]

and some sequences have famous limits like   (({(1 + (1/n)))^n)}  which tends to the irrational number  e,  which is approximately 2.71828.

ListPlot[Table[(((1+(1/n)))^n),{n,1,50}]]

Infinite Series

Suppose an infinite series  (Underoverscript[∑ , (n =1), ∞])(Subscript[a, n])  =  (Subscript[a, 1]) + (Subscript[a, 2]) + (Subscript[a, 3]) + . . . + (Subscript[a, n]) + . . .   is convergent and its sum is  L.  This means  L  is the limit of the sequence {(Subscript[s, n])} of partial sums where  (Subscript[s, n]) is the sum of the first  n  terms of the series; that is,  (Subscript[s, n])  =  (Subscript[a, 1]) + (Subscript[a, 2]) + (Subscript[a, 3]) + . . . + (Subscript[a, n]).

EXAMPLE 4:  The Mathematica commands Sum[(Subscript[a, n]), {n, i, j} ]  and NSum[(Subscript[a, n]), {n, i, j} ] both add up the terms from  (Subscript[a, i]) to  (Subscript[a, j]); that is, (Subscript[a, i])  + (Subscript[a, i+1]) + (Subscript[a, i+2]) + . . . + (Subscript[a, j]). Sum[ ] will give us an exact answer while NSum[ ] gives us a decimal approximation.  There does not appear to be "Free-form input" equivalent.

Table[(1/(2^n)),{n,1,3}]

Sum[(1/(2^n)),{n,1,3}]

To get this in decimal form, you can select "numerical value" from the Suggestions Bar, or  use  N[% ] where % stands for the last output, or you can start with NSum[ ].

N[%]

NSum[(1/(2^n)),{n,1,3}]

There is still another way to find the sum, if you go back to the output line for Table[(1/(2^n)), {n, 1,3}], click on the line and Suggestions Bar reappears, click on "total" from the Suggestions Bar  you will get the sum.

Now, add up 10 (or 20) terms instead of just 3 to get an idea whether {(Subscript[s, n])} converges or not.

NSum[(1/(2^n)),{n,1,10}]

NSum[(1/(2^n)),{n,1,20}]

NSum[(1/(2^n)),{n,1,40}]

NSum[(1/(2^n)),{n,1,80}]

It appears that the sequence {(Subscript[s, n])} of partial sums converges to  1.  We can also consider the following

NSum[(1/(2^n)), {n,1,∞}]

The sum of the infinite series  1/2 + 1/4 + 1/8 + 1/16 +  . . .  is  1.

If you want to add up the terms from the  (80^th) to the  (160^th), we can enter the next line below.

NSum[(1/(2^n)),{n,80,160}]

If we want to see the terms of the sequence of partial sums, we can list them in a table.

Table[NSum[(1/(2^n)),{n,1,i}], {i,1,20}]

In the command above, the statement {n, 1, i} gives the extent of the sum (n runs from 1 to i), while {i, 1, 20} indicates that i runs from 1 to 20.  The table above is a list of the first 20 partial sums.

The first entry of the table is for  i = 1, that is,  NSum[(1/(2^n)), {n, 1, 1} ] =  1/2 = 0.5. The second entry, for i = 2, is described by the command NSum[(1/(2^n)), {n, 1, 2} ] =  (1/2)+(1/(2^2))  = 0.75.  The third entry, for i = 3, is NSum[(1/(2^n)), {n, 1, 3} ] =  (1/2)+(1/(2^2))+(1/(2^3))=  0.875.

Finally, if we want to plot the terms of the sequence of partial sums, we can select "plot points" from the Suggestions Bar  or we can apply ListPlot[ ] to the table of values.

ListPlot[Table[NSum[(1/(2^n)),{n,1,i}],{i,1,20}]]

The result is a picture of the terms of the sequence {(Subscript[s, n])} of partial sums. We also should look at a plot of the terms of the sequence {(Subscript[a, n])}.  Remember, for a convergent series the sequence {(Subscript[a, n])} must go to  0, even if {(Subscript[s, n])} does not.

ListPlot[Table[(1/(2^n)),{n,1,20}]]

Estimating the Sum of an Infinite Series

Alternating Series Estimation Rule: This is used only for alternating series with (Subscript[a, n]) -> 0 and | (Subscript[a, n + 1]) | ≤  | (Subscript[a, n]) |.  (Note: these conditions need only hold for the tail of the series.)

RULE: If you want to find the value of the infinite sum to within .001, for instance, you  examine the terms one by one, until you come to a term  (Subscript[a, n]) such that  | (Subscript[a, n]) | ≤ .001, and then calculate the sum   (Subscript[a, 1]) + (Subscript[a, 2]) + (Subscript[a, 3]) + . . . + (Subscript[a, n - 1]) .

Integral Tail Estimation Rule:  This is used only if all  (Subscript[a, n]) are positive and if you can find a positive, decreasing function  f(x)  corresponding to the series in the sense that  f(n) = (Subscript[a, n])  for all integers n.  (Note: this need only hold for the tail of the series.)

RULE:  If you want to find the sum of a positive, decreasing infinite series to within .001, for instance, you  experiment with the Mathematica  input line   NIntegrate[ f[x], {x, n, ∞}].  Plug in several different values for  n  until you find one for which the output is less than  .001.   Then you add up all the terms from the first to the (n^th) and stop; this gives you the accuracy you wanted.

There are more rules than just the two above for estimating the sum of an infinite series;  one is based on the Ratio Test and another on the Root Test.  However, the exercises in this lab deal only with the two rules above.  See your textbook for more information.

If you want to type new command lines, move your cursor on the page until it becomes horizontal and click the mouse.   If you want to use formal Mathematica, simply begin typing.  Notice that if you are using formal Mathematica, once you start typing a command it gives you a list of commands from which you can select one.  If you want to use  "Free-form input",  press the equal sign and then begin typing.

Exercises - Your report should contain a cover page with the name of your instructor, your name and your partner's name, along with the title of the lab.  Your printouts should include the Mathematica commands, not just the outputs, for your graphs and any work that you used to arrive at the solutions to the problems.  You can write explanations by hand on the printed pages.  Include the numbers of the exercises!  No credit will be given without a write-up which shows all your work and gives clear explanations.

1.  Consider the sequence  {(n^4)/(((1.1))^n)}.
     a)  Obtain a printout that shows the ListPlot[ ] for the first 10 terms of the sequence.  Based on this plot of the first 10 terms, does it appear that this sequence converges or diverges?  If it appears to converge, indicate what do you think the limit is.
     b)  Obtain a printout that shows the ListPlot[ ] for the first 20 terms.  Based on this plot of the first 20 terms,  does it appear that this sequence converges or diverges?  If it appears to converge, indicate what do you think the limit is.
     c)   Obtain a printout that shows the ListPlot[ ] for the first 40 terms.  Based on this plot of the first 40 terms,  does it appear that this sequence converges or diverges?  If it appears to converge, indicate what do you think the limit is.
     d)  Use Mathematica  to evaluate (lim_(n->∞))((n^4)/(((1.1))^n)).

2.  Consider the sequence  {(cos^2)(((3n))^(1/n))}.
     a)  Obtain a printout that shows the ListPlot[ ] for the first 10 terms of the sequence.  Based on this plot of the first 10 terms, does it appear that this sequence converges or diverges?  If it appears to converge, indicate what do you think the limit is.
     b)  Obtain a printout that shows the ListPlot[ ] for the first 20 terms.  Based on this plot of the first 20 terms,  does it appear that this sequence converges or diverges?  If it appears to converge, indicate what do you think the limit is.
     c)   Obtain a printout that shows the ListPlot[ ] for the first 40 terms.  Based on this plot of the first 40 terms,  does it appear that this sequence converges or diverges?  If it appears to converge, indicate what do you think the limit is.
     d)  Use Mathematica  to evaluate (lim_(n->∞))((((cos^2)(3n))^(1/n))).

3.  The following sequences: {(Subscript[a, n])} = {1/(n^2)} and {(Subscript[b, n])} = {1/(((1.3))^n)}  both converge to zero as n->∞.  
     s)  Obtain a printout of these two sequences together as in Example 2, for 1 < n < 20.  Which sequence appears to be approaching zero more quickly?
     b)  Obtain a printout of these two sequences together as in Example 2, for 20 < n < 30.  Which sequence appears to be approaching zero more quickly?
     c)  For what value of  "n"  do the sequences switch from  (Subscript[a, n]) < (Subscript[b, n]) to  (Subscript[a, n]) > (Subscript[b, n]) or vice versa?

4.  Consider the infinite sequence  {(Subscript[a, n]) } =  {((5n + 6(((-1))^n))/(4 + 3n))} .
     a)   Obtain a printout that shows the ListPlot[ ] for the first  20  terms of the sequence.     
     b)   Obtain a printout that shows the ListPlot[ ] for the first  40  terms of the sequence.     
     c)   Prove, by hand, that the limit does exist and determine its value.   (Hint:  try the "Squeeze Theorem")

5.   The alternating  series  (∑_(n = 1)^∞)((((-1))^(n ))/(Sqrt[2n + 1])) is convergent.  
     a)  Estimate the sum of the series to within  0.1.  How many terms do you have to include to get that degree of accuracy?     
     b)  Estimate the sum of the series to within  0.01.  How many terms do you have to include to get that degree of accuracy?

6.   The series  (∑_(n = 1)^∞)((n^2)/(e^n)) is convergent.
     a)  Estimate the sum of the series to within  0.01.  How many terms do you have to include to get that degree of accuracy?     
     b)  Estimate the sum of the series to within  0.001.  How many terms do you have to include to get that degree of accuracy?

7.   A chemical plant produces pesticide that contains a molecule potentially harmful to people if the concentration is too high.  The plant flushes out the tanks containing the pesticide once a week and the discharge flows into a river that feeds the water reservoir of a nearby town.  The dangerous molecule breaks down gradually in water so that  90% of the amount remaining each week is dissipated by the end of the next week.  Suppose that  12,000 units of the molecule are discharged each week.
     a)  Find a formula for the number of units of the molecule discharged into the river after  "n"  weeks.     
     b)  Estimate the amount of the molecule in the water supply after a very long time.     
     c)  If the toxic level of the molecule is 20,000 units how large an amount of the molecule can the plant discharge each week?