Contact Us!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.

| Download
Views: 264
Image: ubuntu2204
Kernel: SageMath 10.1

Infinite Series

An infinite series, or series, is the sum of an sequence a1+a2+a3++an+a_1 + a_2 + a_3 + \cdots + a_n + \cdots

Example: 1+12+14+18+116+1+{1\over 2}+{1\over 4}+{1\over 8}+{1\over 16}+\cdots

For series, we need to invest the sum of the infinity many numbers.

Consider its nnth partial sum sn=a1+a2+a3++ans_n=a_1 + a_2 + a_3 + \cdots + a_n which is a sequence.

k=1ak=limnk=1nak=limnsn\sum_{k=1}^\infty a_k=\lim_{n\rightarrow \infty}\sum_{k=1}^na_k =\lim_{n\rightarrow \infty}s_n

Given a series a1+a2+a3++an+a_1+a_2+a_3+\cdots+a_n+\cdots The number ana_n is the nnth term of the series. If the sequence of partial sums converges to a limit LL, we say that the series converges and its sum is LL. In this case, we aslo write a1+a2+a3++an+=n=1an=La_1+a_2+a_3+\cdots+a_n+\cdots=\sum_{n=1}^\infty a_n=L If the sequence of partial sums of the series sns_n does not converge, we say that the series diverges.

There are different notations for a serie: n=1an,k=1ak,an\sum_{n=1}^\infty a_n,\quad \sum_{k=1}^\infty a_k,\quad \sum a_n

import numpy as np n_end = 30 f(n) = 1/(2^(n-1)) sequence_values = np.array([f(n) for n in [1..n_end]]) series_values = sequence_values.cumsum() points([(n+1, series_values[n]) for n in [0..n_end-1]], size = 30, legend_label = r'$\sum_{n=1}^N%s$'%latex(f(n))) # note that n start from 0 in this code.
Image in a Jupyter notebook

Geometric Series (a0a\neq 0 and rr are fixed)

a+ar+ar2++arn1+=n=1arn1=n=0arna + ar + ar^2 + \cdots + ar^{n - 1} + \cdots = \sum_{n=1}^{\infty}ar^{n-1}=\sum_{n=0}^{\infty}ar^{n}
  • r=1r=1

n=1Narn1=Na\sum_{n=1}^{N}ar^{n-1}=Na
  • r1r\neq1

Let sN=n=1Narn1s_N=\sum\limits_{n=1}^{N}ar^{n-1}, then we have rsN=n=1Narn=sNa+arN.r\cdot s_N=\sum_{n=1}^{N}ar^{n}=s_N-a+ar^N. Thus we have sN=n=1Narn1=aarN1rs_N =\sum_{n=1}^{N}ar^{n-1}= {a-ar^N\over 1-r}

Examples:

  • n=0(1)n54n\sum_{n=0}^\infty {(-1)^n5\over 4^n}

We have a=5a=5 and r=14r=-{1\over 4}, then the series converges to a1r=4{a\over 1-r}=4.

var('n, a, r, N') print('The partial sum of the geometric series is', sum(a*r^(n-1), n, 1, N))
The partial sum of the geometric series is (a*r^N - a)/(r - 1)
import numpy as np n_end = 30 a = 5 r = -1/4 f(n) = a*r^(n-1) sequence_values = np.array([f(n) for n in [1..n_end]]) series_values = sequence_values.cumsum() points([(n+1, series_values[n]) for n in [0..n_end-1]], size = 30, legend_label = r'$\sum_{n=1}^N%s$'%latex(f(n))) # note that n start from 0 in this code.
Image in a Jupyter notebook

Telescoping Example: n=11n(n+1)\sum\limits_{n=1}^\infty {1\over n(n+1)}

n=1N1n(n+1)=n=1N(1n1n+1)=11N+1\sum_{n=1}^N {1\over n(n+1)}=\sum_{n=1}^N \left({1\over n}-{1\over n+1}\right) = 1-{1\over N+1}
import numpy as np n_end = 100 f(n) = 1/n/(n+1) sequence_values = np.array([f(n) for n in [1..n_end]]) series_values = sequence_values.cumsum() points([(n+1, series_values[n]) for n in [0..n_end-1]], size = 30, legend_label = r'$\sum_{n=1}^N%s$'%latex(f(n))) # note that n start from 0 in this code.
Image in a Jupyter notebook

The nnth-Term Test for a Divergent Series

If n=1an\sum_{n=1}^\infty a_n converges, then an0a_n\rightarrow 0. (This is a necessary condition for convergence.)

n=1an\sum\limits_{n=1}^\infty a_n diverges if limnan\lim_{n\rightarrow \infty}a_n fails to exists or is different from zero. (This is a sufficient condition for divergence.)

Examples: Divergence or Convergence

  • n=1n2\sum\limits_{n=1}^\infty n^2 divergence because ana_n\rightarrow \infty.

  • n=1(1)n+1\sum\limits_{n=1}^\infty (-1)^{n+1} divergence because ana_n does not convergence.

  • n=1n2n+5\sum\limits_{n=1}^\infty {-n\over 2n+5} divergence because ana_n converges to 12-{1\over 2}.

import numpy as np n_end = 30 f(n) = n^2 sequence_values = np.array([f(n) for n in [1..n_end]]) series_values = sequence_values.cumsum() points([(n+1, series_values[n]) for n in [0..n_end-1]], size = 30, legend_label = r'$\sum_{n=1}^N%s$'%latex(f(n))) # note that n start from 0 in this code.
Image in a Jupyter notebook

limnan=0\lim\limits_{n\rightarrow \infty}a_n=0 does not mean n=1an\sum\limits_{n=1}^\infty a_n converges

Example: n=11n\sum_{n=1}^\infty {1\over n}

import numpy as np n_end = 30 f(n) = 1/n sequence_values = np.array([f(n) for n in [1..n_end]]) series_values = sequence_values.cumsum() points([(n+1, series_values[n]) for n in [0..n_end-1]], size = 30, legend_label = r'$\sum_{n=1}^N%s$'%latex(f(n))) # note that n start from 0 in this code.
Image in a Jupyter notebook

Combing Series

If an=A\sum a_n=A and bn=B\sum b_n=B are convergent series, then

  • Sum rule: (an+bn)=an+bn=A+B\sum(a_n+b_n)=\sum a_n+\sum b_n = A+B

  • Difference rule: (anbn)=anbn=AB\sum(a_n-b_n)=\sum a_n-\sum b_n = A-B

  • Constant Multiple rule: (kan)=kan=kA\sum(ka_n)=k\sum a_n= kA

Corollary

  • If an\sum a_n diverges, then kank \sum a_n for k0k\neq 0?

  • If an\sum a_n diverges and bn\sum b_n converges, then (an+bn)\sum(a_n+b_n) ?

Example: n=13n116n1\sum\limits_{n=1}^\infty {3^{n-1}-1\over 6^{n-1}}

n=13n116n1=n=13n16n1n=116n1=11121116=265=0.8\sum\limits_{n=1}^\infty {3^{n-1}-1\over 6^{n-1}}=\sum\limits_{n=1}^\infty {3^{n-1}\over 6^{n-1}}-\sum\limits_{n=1}^\infty {1\over 6^{n-1}}={1\over 1-{1\over 2}}-{1\over 1-{1\over 6}}= 2-{6\over 5}=0.8
import numpy as np n_end = 30 f(n) = (3^(n-1)-1)/(6^(n-1)) sequence_values = np.array([f(n) for n in [1..n_end]]) series_values = sequence_values.cumsum() points([(n+1, series_values[n]) for n in [0..n_end-1]], size = 30, legend_label = r'$\sum_{n=1}^N%s$'%latex(f(n))) # note that n start from 0 in this code.
Image in a Jupyter notebook

Adding or Deleting Terms

Adding or deleting a finite number of terms does not change the series's convergence or divergence.

Reindexing

The following four notations are equivalent. n=112n1,n=012n,n=512n5,n=412n+4\sum_{n=1}^\infty {1\over 2^{n-1}},\qquad \sum_{n=0}^\infty{1\over 2^n},\qquad \sum_{n=5}^\infty {1\over 2^{n-5}},\qquad \sum_{n=-4}^\infty {1\over 2^{n+4}}

Nondecreasing Partial Sums

Consider n=1an\sum\limits_{n=1}^\infty a_n with an0a_n\geq 0 for all nn. We have

s1s2s3snsn+1s_1\leq s_2\leq s_3\leq \cdots\leq s_n\leq s_{n+1}\leq \cdots

Corollary

A series n=1an\sum\limits_{n=1}^\infty a_n of nonnegative terms converges if and only if its partial sums {sn}\{s_n\} are bounded from above.

  • Does the harmonic series n=11n\sum\limits_{n=1}^\infty {1\over n} converge or not? (Check the Comparison Test)

The Integral Test (Theorem 9--The integral test)

Let {an}\{a_n\} be a sequence of positive terms. Suppose that an=f(n)a_n=f(n), where ff is a continuous, positive, decreasing function of xx for all xNx\geq N. Then the series n=Nan\sum\limits_{n=N}^\infty a_n and the integral Nf(x)dx\int\limits_N^\infty f(x)dx both converge or both diverge.

  • pp-series: n=11np\sum\limits_{n=1}^\infty {1\over n^p}

Consider 11xpdx\int_1^\infty {1\over x^p}dx If p=1p=1, we have that 11xpdx=ln(+)=\int_1^\infty {1\over x^p}dx=\ln (+\infty)=\infty If p1p\neq 1, we have that 11xpdx=11px1p1\int_1^\infty {1\over x^p}dx={1\over 1-p}x^{1-p}\big|_{1}^\infty It converges when p>1p>1 and diverges when p<1p<1.

  • n=11n2+1\sum\limits_{n=1}^\infty {1\over n^2+1}

Consider 11x2+1dx\int_1^\infty {1\over x^2+1}dx

  • n=11nlnn\sum\limits_{n=1}^\infty {1\over n\ln n}

Consider 11xlnxdx\int_1^\infty {1\over x\ln x}dx

import numpy as np n_end = 100 p = float(1.5) f(n) = 1/n^p sequence_values = np.array([f(n) for n in [1..n_end]]) series_values = sequence_values.cumsum() points([(n+1, series_values[n]) for n in [0..n_end-1]], size = 30, legend_label = r'$\sum_{n=1}^N%s$'%latex(f(n))) # note that n start from 0 in this code.
Image in a Jupyter notebook

Integral Test: Approximation

Though we can show that the series converges, we can not easily find the total sum SS. But, we can estimate it with the parital sum sns_n with the remainder Rn=Ssn=an+1+an+2+an+3+R_n=S-s_n=a_{n+1}+a_{n+2}+a_{n+3}+\cdots

Estimate n=11n2\sum\limits_{n=1}^\infty {1\over n^2} with s10s_{10}

s10=1+14+19++11001.54977s_{10}=1+{1\over 4}+{1\over 9}+\cdots+{1\over 100}\approx 1.54977

We have that s1.64493s_\infty\approx 1.64493

var('n') n_end = 10 f(n) = 1/n^2 print('The sum of the first', n_end, 'terms of', f(n) ,'is', N(sum(f(n), n, 1, n_end))) print('The total sum is', N(sum(f(n),n,1,Infinity)))
The sum of the first 10 terms of n^(-2) is 1.54976773116654 The total sum is 1.64493406684823

The Comparison Test

Let an\sum a_n, cn\sum c_n, and dn\sum d_n be series with nonnegative terms. Suppose that for some integer NN, we have dnancn,n>N.d_n\leq a_n\leq c_n,\qquad\forall n>N. Then

  • If cn\sum c_n converges, then an\sum a_n also converges, because its partial sum is increasing and bounded.

  • If dn\sum d_n diverges, then an\sum a_n also diverges, because its partial sum is unbounded.

Examples

  • n=155n1\displaystyle\sum\limits_{n=1}^\infty {5\over 5n-1} diverges because 55n11n {5\over 5n-1}\geq {1\over n}

  • n=11n!\displaystyle\sum\limits_{n=1}^\infty {1\over n!} converges because 1n!12n1{1\over n!}\leq {1\over 2^{n-1}}

import numpy as np n_end = 100 f(n) = 5/(5*n-1) sequence_values = np.array([f(n) for n in [1..n_end]]) series_values = sequence_values.cumsum() g = points([(n+1, series_values[n]) for n in [0..n_end-1]], size = 30, legend_label = r'$\sum_{n=1}^N%s$'%latex(f(n))) # note that n start from 0 in this code. f(n) = 1/n sequence_values = np.array([f(n) for n in [1..n_end]]) series_values = sequence_values.cumsum() g += points([(n+1, series_values[n]) for n in [0..n_end-1]], size = 30, color='red', legend_label = r'$\sum_{n=1}^N%s$'%latex(f(n))) # note that n start from 0 in this code. g.show()
Image in a Jupyter notebook
import numpy as np n_end = 50 f(n) = 1/factorial(n) sequence_values = np.array([f(n) for n in [1..n_end]]) series_values = sequence_values.cumsum() g = points([(n+1, series_values[n]) for n in [0..n_end-1]], size = 30, legend_label = r'$\sum_{n=1}^N%s$'%latex(f(n))) # note that n start from 0 in this code. f(n) = 1/2^(n-1) sequence_values = np.array([f(n) for n in [1..n_end]]) series_values = sequence_values.cumsum() g += points([(n+1, series_values[n]) for n in [0..n_end-1]], size = 30, color='red', legend_label = r'$\sum_{n=1}^N%s$'%latex(f(n))) # note that n start from 0 in this code. g.show()
Image in a Jupyter notebook

Harmonic series 1n\sum{1\over n}

We can find a lower bound of the series.

1+12+13+14+15+16+17+18++1n+1+12+(14+14)+(18+18+18+18)+1+12+12+12+\begin{align*} & 1+ {1\over 2}+ {1\over 3} + {1\over 4} + {1\over 5} + {1\over 6} + {1\over 7} + {1\over 8}+ \cdots + {1\over n} + \cdots \\ \geq & 1+ {1\over 2} + \left({1\over 4} + {1\over 4}\right) + \left({1\over 8} + {1\over 8} + {1\over 8} + {1\over 8}\right) + \cdots\\ \geq & 1+ {1\over 2} + {1\over 2} + {1\over 2} + \cdots \end{align*}

The Limit Comparison Test

Suppose that an>0a_n>0 and bn>0b_n>0 for nNn\geq N

  • If limnanbn=c>0\displaystyle\lim\limits_{n\rightarrow\infty}{a_n\over b_n}=c>0, then both an\sum a_n and bn\sum b_n converge or both diverge. (Note (0.5c)bn<an<(1.5c)bn(0.5 c)\cdot b_n<a_n<(1.5c)\cdot b_n for large nn)

  • If limnanbn=0\displaystyle\lim\limits_{n\rightarrow\infty}{a_n\over b_n}=0 and bn\sum b_n converges, then an\sum a_n converges. (Note an<bna_n<b_n for large nn)

  • If limnanbn=\displaystyle\lim\limits_{n\rightarrow\infty}{a_n\over b_n}=\infty and bn\sum b_n diverges, then an\sum a_n diverges. (Note an>bna_n>b_n for large nn)

Example

  • 2n+1n2+2n+1\displaystyle\sum {2n+1\over n^2+2n+1} limn2n+1n2+2n+11n=2\lim_{n\rightarrow\infty}{{2n+1\over n^2+2n+1}\over {1\over n}}=2

  • 1+nlnnn2+5\displaystyle\sum {1+n\ln n\over n^2+5} limn1+nlnnn2+51n=\lim_{n\rightarrow\infty}{{1+n\ln n\over n^2+5}\over {1\over n}}=\infty

  • lnnn1.1\displaystyle\sum {\ln n \over n^{1.1}} limnlnnn1.11n1.05=0\lim_{n\rightarrow\infty}{{\ln n \over n^{1.1}}\over {1\over n^{1.05}}}=0

import numpy as np n_end = 100 f(n) = (2*n+1)/(n^2+2*n+1) sequence_values = np.array([f(n) for n in [1..n_end]]) series_values = sequence_values.cumsum() g1 = points([(n+1, series_values[n]) for n in [0..n_end-1]], size = 30, legend_label = r'$\sum_{n=1}^N%s$'%latex(f(n))) # note that n start from 0 in this code. f(n) = 1/n sequence_values = np.array([f(n) for n in [1..n_end]]) series_values = sequence_values.cumsum() g1 += points([(n+1, series_values[n]) for n in [0..n_end-1]], size = 30, color='red', legend_label = r'$\sum_{n=1}^N%s$'%latex(f(n))) # note that n start from 0 in this code. f(n) = (1+n*np.log(n))/(n^2+5) sequence_values = np.array([f(n) for n in [1..n_end]]) series_values = sequence_values.cumsum() g2 = points([(n+1, series_values[n]) for n in [0..n_end-1]], size = 30, legend_label = r'$\sum_{n=1}^N%s$'%latex(f(n))) # note that n start from 0 in this code. f(n) = 1/n sequence_values = np.array([f(n) for n in [1..n_end]]) series_values = sequence_values.cumsum() g2 += points([(n+1, series_values[n]) for n in [0..n_end-1]], size = 30, color='red', legend_label = r'$\sum_{n=1}^N%s$'%latex(f(n))) # note that n start from 0 in this code. n_end = 1000 f(n) = log(n)/(n^float(1.1)) sequence_values = np.array([f(n) for n in [1..n_end]]) series_values = sequence_values.cumsum() g3 = points([(n+1, series_values[n]) for n in [0..n_end-1]], size = 30, legend_label = r'$\sum_{n=1}^N%s$'%latex(f(n))) # note that n start from 0 in this code. f(n) = 1/n^float(1.05) sequence_values = np.array([f(n) for n in [1..n_end]]) series_values = sequence_values.cumsum() g3 += points([(n+1, series_values[n]) for n in [0..n_end-1]], size = 30, color='red', legend_label = r'$\sum_{n=1}^N%s$'%latex(f(n))) # note that n start from 0 in this code. graphics_array([g1, g2, g3], 1, 3)
Image in a Jupyter notebook

What happens with negative terms?

A series an\sum a_n converges absolutely (is absolutely convergent) if an\sum |a_n| converges.

A absolutely convergent series converges, i.e., if an\sum |a_n| converges, then an\sum a_n converges.

Because an=an+an2anan2a_n = {|a_n|+a_n\over 2} - {|a_n|-a_n\over 2}, and both an+an2\sum {|a_n|+a_n\over 2} and anan2\sum {|a_n|-a_n\over 2} converges.

# a_n = sin(n)/n^2 import numpy as np n_end = 100 f(n) = sin(n)/n^2 sequence_values = np.array([f(n) for n in [1..n_end]]) series_values = sequence_values.cumsum() g = points([(n+1, series_values[n]) for n in [0..n_end-1]], size = 30, legend_label = r'$\sum_{n=1}^N%s$'%latex(f(n))) # note that n start from 0 in this code. g.show()
Image in a Jupyter notebook

The Ratio Test (Important)

Suppose that limnan+1an=ρ\lim_{n\rightarrow \infty}\left|{a_{n+1}\over a_n}\right|=\rho

  • If ρ<1\rho<1, then the series an\sum a_n converges.

Compare with (ρ+12)n\left({\rho+1\over 2}\right)^n

  • If ρ>1\rho>1 or ρ=\rho =\infty, the series diverges

limnan0\lim_{n\rightarrow \infty} |a_n|\neq 0
  • If ρ=1\rho=1, the test is inconclusive.

1n and 1n2\sum{1\over n} \text{ and }\sum{1\over n^2}

Examples

  • (2n)!n!n!\displaystyle\sum {(2n)!\over n!n!}

  • 4nn!n!(2n)!\displaystyle\sum {4^nn!n!\over (2n)!}

var('n') f(n) = factorial(2*n)/factorial(n)/factorial(n) n_end = Infinity print('The sum of the first', n_end, 'terms of', f(n) ,'is', N(sum(f(n), n, 1, n_end)))
--------------------------------------------------------------------------- RuntimeError Traceback (most recent call last)
File /ext/sage/10.1/src/sage/interfaces/maxima_lib.py:891, in MaximaLib.sr_sum(self, *args) 890 try: --> 891 return max_to_sr(maxima_eval([[max_ratsimp],[[max_simplify_sum],([max_sum],[sr_to_max(SR(a)) for a in args])]])) 892 except RuntimeError as error:
File /ext/sage/10.1/src/sage/libs/ecl.pyx:830, in sage.libs.ecl.EclObject.__call__() 829 lispargs = EclObject(list(args)) --> 830 return ecl_wrap(ecl_safe_apply(self.obj,(<EclObject>lispargs).obj)) 831
File /ext/sage/10.1/src/sage/libs/ecl.pyx:353, in sage.libs.ecl.ecl_safe_apply() 352 else: --> 353 raise RuntimeError("ECL says: {}".format(message)) 354 else:
RuntimeError: ECL says: Sum is divergent! During handling of the above exception, another exception occurred: ValueError Traceback (most recent call last) Cell In [2], line 5 2 __tmp__=var("n"); f = symbolic_expression(factorial(Integer(2)*n)/factorial(n)/factorial(n)).function(n) 3 n_end = Infinity ----> 5 print('The sum of the first', n_end, 'terms of', f(n) ,'is', N(sum(f(n), n, Integer(1), n_end)))
File /ext/sage/10.1/src/sage/misc/functional.py:583, in symbolic_sum(expression, *args, **kwds) 410 r""" 411 Return the symbolic sum `\sum_{v = a}^b expression` with respect 412 to the variable `v` with endpoints `a` and `b`. (...) 580 581 """ 582 if hasattr(expression, 'sum'): --> 583 return expression.sum(*args, **kwds) 584 elif max(len(args),len(kwds)) <= 1: 585 return sum(expression, *args, **kwds)
File /ext/sage/10.1/src/sage/symbolic/expression.pyx:13170, in sage.symbolic.expression.Expression.sum() 13168 """ 13169 from sage.calculus.calculus import symbolic_sum > 13170 return symbolic_sum(self, *args, **kwds) 13171 13172 def prod(self, *args, **kwds):
File /ext/sage/10.1/src/sage/calculus/calculus.py:633, in symbolic_sum(expression, v, a, b, algorithm, hold) 630 return ssum(expression, v, a, b) 632 if algorithm == 'maxima': --> 633 return maxima.sr_sum(expression,v,a,b) 635 elif algorithm == 'mathematica': 636 try:
File /ext/sage/10.1/src/sage/interfaces/maxima_lib.py:898, in MaximaLib.sr_sum(self, *args) 893 s = str(error) 894 if "divergent" in s: 895 # in pexpect interface, one looks for this; 896 # could not find an example where 'Pole encountered' occurred, though 897 # if "divergent" in s or 'Pole encountered' in s: --> 898 raise ValueError("Sum is divergent.") 899 elif "Is" in s: # Maxima asked for a condition 900 self._missing_assumption(s)
ValueError: Sum is divergent.
var('n') f(n) = 4^n*factorial(n)*factorial(n)/factorial(2*n) n_end = Infinity print('The total sum of', f(n), 'is', N(sum(f(n),n,1,n_end)))
The total sum of 4^n*factorial(n)^2/factorial(2*n) is +infinity
var('n') f(n) = 1/n^2 print('The total sum of', f(n), 'is', sum(f(n),n,1,Infinity))
The total sum of n^(-2) is 1/6*pi^2

Another example

an={n2nn odd12n,n even\displaystyle a_n=\left\{\begin{array}{cc}\displaystyle {n\over 2^n}& n\mbox{ odd}\\\displaystyle {1\over 2^n}, & n\mbox{ even} \end{array}\right.

The Root Test

Suppose that limnann=ρ\lim_{n\rightarrow \infty}\sqrt[n]{|a_n|}=\rho

  • If ρ<1\rho<1, then the series converges

Compare with (ρ+12)n\left(\rho+1\over 2\right)^n

  • If ρ>1\rho>1 or ρ=\rho=\infty, then the series diverges

limnan0\lim_{n\rightarrow \infty} |a_n|\neq 0
  • If ρ=1\rho=1, then the test is inconclusive.

1n and 1n2\sum{1\over n} \text{ and }\sum{1\over n^2}

Alternating Series

An alternating series has terms that are alternatively positive and negative.

The series n=1(1)n+1un\sum_{n=1}^\infty (-1)^{n+1}u_n converges if the following are satisfied

  • unun+1>0u_n\geq u_{n+1}>0 for nNn\geq N.

  • un0u_n\rightarrow 0.

WLOG, assume that N=1N=1. Consider s2ms_{2m}

  • s2ms_{2m} is increasing, while s2m+1s_{2m+1} is decreasing.

  • 0s2ms2m+1u10\leq s_{2m}\leq s_{2m+1}\leq u_1.

  • Both s2ms_{2m} and s2m+1s_{2m+1} converge, and u2m+10u_{2m+1}\rightarrow 0.

Example

  • n=1(1)n+11n\sum\limits_{n=1}^\infty (-1)^{n+1}{1\over n}

import numpy as np var('n') n_end = 100 f(n) = (-1)^(n+1)/n sequence_values = np.array([f(n) for n in [1..n_end]]) series_values = sequence_values.cumsum() p = points([(n+1, series_values[n]) for n in [0..n_end-1]], size = 30, legend_label = r'$\sum_{n=1}^N%s$'%latex(f(n))) # note that n start from 0 in this code. p.show() print('The total sum of', f(n), 'is', sum(f(n),n,1,Infinity))
Image in a Jupyter notebook
The total sum of (-1)^(n + 1)/n is log(2)

Use derivative to check monotonicity

Define f(x)f(x) such that f(n)=unf(n)=u_n. un=10nn2+16u_n={10 n\over n^2+16}

Alternating Series Estimation Theorem

If the alternating series n=1(1)n+1un\sum\limits_{n=1}^\infty (-1)^{n+1}u_n satisfies the conditions of Theorem 15, then for nNn\geq N, then we have sn=u1u2++(1)n+1uns_n=u_1-u_2+\cdots+(-1)^{n+1}u_n approximates the total sum LL of the series with an error whose absolute values is less than un+1u_{n+1}. Furthermore, the sum LL lies between any two successive partial sums sns_n and sn+1s_{n+1}, and the remainder LsnL-s_n has the same sign as the first unused term.

Example

n=0(1)n12n=112+1418+\sum_{n=0}^\infty (-1)^n{1\over 2^n}=1-{1\over 2}+{1\over 4}-{1\over 8}+\cdotss8=112+1418+116132+1641128=85128=0.6640625, s9=0.66796875s_8 = 1-{1\over 2}+{1\over 4}-{1\over 8}+{1\over 16}-{1\over 32}+{1\over 64}-{1\over 128}={85\over 128}=0.6640625,~s_9=0.66796875
import numpy as np n_end = 15 f(n) = (-1)^(n-1)/2^(n-1) sequence_values = np.array([f(n) for n in [1..n_end]]) series_values = sequence_values.cumsum() p = points([(n+1, series_values[n]) for n in [0..n_end-1]], size = 30, legend_label = r'$\sum_{n=1}^N%s$'%latex(f(n))) # note that n start from 0 in this code. p += points([(n+1, series_values[n]) for n in [7]], size = 30, color = 'red', legend_label = r'$s_8$') p += points([(n+1, series_values[n]) for n in [8]], size = 30, color = 'cyan', legend_label = r'$s_9$') p.show()
Image in a Jupyter notebook

Code for showing a series and comput the sum of the series

import numpy as np n_end = 100 p = float(1.5) f(n) = 1/n^p sequence_values = np.array([f(n) for n in [1..n_end]]) series_values = sequence_values.cumsum() points([(n+1, series_values[n]) for n in [0..n_end-1]], size = 30, legend_label = r'$\sum_{n=1}^N%s$'%latex(f(n))) # note that n start from 0 in this code.
Image in a Jupyter notebook
var('n') p = 2.5 f(n) = 1/n^p print('The total sum of', f(n), 'is', N(sum(f(n), n, 1, Infinity)))
--------------------------------------------------------------------------- TypeError Traceback (most recent call last) Cell In [43], line 5 2 p = RealNumber('2.5') 4 __tmp__=var("n"); f = symbolic_expression(Integer(1)/n**p).function(n) ----> 5 print('The total sum of', f(n), 'is', N(sum(f(n), n, Integer(1), Infinity)))
File /ext/sage/10.1/src/sage/misc/functional.py:1590, in numerical_approx(x, prec, digits, algorithm) 1588 return numerical_approx_generic(x, prec) 1589 else: -> 1590 return n(prec, algorithm=algorithm)
File /ext/sage/10.1/src/sage/symbolic/expression.pyx:6726, in sage.symbolic.expression.Expression.numerical_approx() 6724 res = x.pyobject() 6725 else: -> 6726 raise TypeError("cannot evaluate symbolic expression numerically") 6727 6728 # Important -- the we get might not be a valid output for numerical_approx in
TypeError: cannot evaluate symbolic expression numerically