This is a code in python which calculates f (x) =∑ ((-1)*x)/(x*x+n*n)
n from 1 to infinite….
correct to 0.0001, for the range 1 < x < 100 in steps of 0.1.
But i am getting an syntax error, as i am new to programming in python…
from scipy import *
from matplotlib.pyplot import *
x=arange(0.1,100,0.1)
f=zeros(len(x))
s=-1
for n in range (1,10000):
t=s*x/(x*x+n*n)
f +=t
s =-s
if max(abs(t))< 1e-4
break
for xx in c_[x,f]:
print "%f %f" % (xx[0],xx[1])
you need to add
:afterif max(abs(t))< 1e-4