I want to compute following sum (last line of the code) in Python using Sympy:
# Theta Functions, n = 0, 1, ... , x
theta_n = [0]*(x+1)
sig = sy.symbols('sigma^2', real=True)
j = sy.symbols('j', integer=True)
theta_n[0] = 1
theta_n[1] = 1
for n in range(2,x+1):
theta_n[n] = sy.Sum( sig**j * theta_n[n-2*j], (j,1,int(n/2))).doit()
but I get the following error
TypeError: list indices must be integers or slices, not Add
I am a complete Sympy newbie and would like to know how to do this in the right way. One workaround would be to compute the sum with a for loop which works nice but i think isnt the right way to do it. Maybe i need a other representation for thetan or I can somehow convert j to an integer in the sum to get access to the elements of the python list.