6626070
2997924

MATH02, Sums and products

Back to the previous page
List of posts to read before reading this article


Contents


Sum

Sum

import sympy
#symypy.init_printing()
from sympy import symbols, Sum, oo

n = symbols("n", integer=True)
Sum(1/(n**2), (n, 1, oo))

OUTPUT : \(\displaystyle \sum_{n=1}^{\infty} \frac{1}{n^{2}}\)



Evaluation for sum

import sympy
#symypy.init_printing()
from sympy import symbols, Sum, oo

n = symbols("n", integer=True)
x = Sum(1/(n**2), (n, 1, oo))
x.doit()

OUTPUT : \(\displaystyle \frac{\pi^{2}}{6}\)



Product

Product

import sympy
#symypy.init_printing()
from sympy import symbols, Product

n = symbols("n", integer=True)
Product(n, (n, 1, 7))

OUTPUT : \(\displaystyle \prod_{n=1}^{7} n\)



Evaluation for product

import sympy
#symypy.init_printing()
from sympy import symbols, Product

n = symbols("n", integer=True)
x = Product(n, (n, 1, 7))
x.doit()

OUTPUT : \(5040\)



List of posts followed by this article


Reference