Check whether sequence converges or diverges in Python
Check whether sequence converges or diverges in Python
In this, we discuss the program to Check whether sequence converges or diverges in Python. We discuss three different examples here. Let's discuss all these one by one.
Example 1: Check whether the following sequence converges or diverges
Python Code:
from sympy import *
x = symbols('x')
r = limit((1+1/x)**x,x,oo)
if (r==0):
print('The given sequence does not converge to any number')
else:
print('The given sequence converge to a number' + str(r))
print('limit of a given function')
print(r)
Output:
The given sequence converge to a number E
limit of a given function
E
Example 2: Check whether the following sequence converges or diverges
Python Code:from sympy import *
x = symbols('x')
r = limit((x) ** 2, x, oo)
if (r == oo):
print('The given sequence does not converge to any number')
else:
print('The given sequence converge to a number' + str(r))
print('limit of a given function')
print(r)
Output:
The given sequence does not converge to any number limit of a given function oofrom sympy import *Example 3: Check whether the following sequence converges or diverges
Python Code:
x = symbols('x')
r = limit(sqrt(x+1)- sqrt(x), x, oo)
if (r == oo):
print('The given sequence does not converge to any number')
else:
print('The given sequence converge to a number' + str(r))
print('limit of a given function')
print(r)
Output:
The given sequence converge to a number 0
limit of a given function
0
Recommended Post:Program to check whether the number is prime or not
Plotting of even, odd, prime numbers from a list
Subplot of even, odd and prime numbers from a list
Python Program to print Arithmetic Progress series
Program to find even and odd numbers from the list
Program to check whether a number is odd or even