I am new to python coding
and i am writing a code to calculate the sum of a series, i started by writing a function where the input is the number of iterations of the sum, but when i compile it gives me the error in the line under def G(i)
: only length-1 arrays can be converted to Python scalars
Can you help me please
import matplotlib.pyplot as plt
import numpy as np
import scipy.special as sp
import pylab as pylab
def G(i):
return (sum(((-1*(2*l+1))/(4*np.pi*(l**2+l)))*sp.legendre(l)(0.5) for l in i))
pylab.ylim([-1,1])
sumrange = np.arange(1,70,1)
plt.plot(sumrange,G(sumrange),color='red')