Scroll to Top

Virtual Math Learning Center

Virtual Math Learning Center Texas A&M University Virtual Math Learning Center

Radius and Interval of Convergence in Python

Author: David Manuel

In this video, we demonstrate how to use Python to find the radius and interval of convergence of a power series. We will use the Ratio Test when determining the radius of convergence. When testing the end points of the interval of convergence, we use the Comparison Test and the Alternating Series Test.

Transcript 28

Problem: Find the radius and interval of convergence of 
\[\sum_{n=0}^\infty \frac{(-1)^n x^n}{ (n+2) 2^n}\]

Python Code: 
Find the radius and interval of convergence of the sum from 0 to infinity of (-1)^n * x^n/( (n+2) * 2^n)

from sympy import *

n=symbols('n',positive=True,integer=True)
x=symbols('x')
a=(-1)**n*x**n/((n+2)*2**n)
RatioTest=abs(a.subs(n,n+1)/a)
print(RatioTest.simplify())
L=limit(RatioTest.simplify(),n,oo)
print('The limit of the Ratio Test is',L) 
# likely obvious x is between -2 and 2
reduce_inequalities(L<1)

# Left endpoint
aLeft=a.subs(x,-2)
print(aLeft.simplify(),'This series diverges by limit comparison with the series 1/n.')

# Right endpoint
aRight=a.subs(x,2)
print(aRight.simplify(),'This series converges by the Alternating Series Test.')

Open Python Notebook File

See more videos from this section