I have written the following code to use simpson's rule to integrate an arbitrary function, in my case, sin(x):
import math
delta_x=(x2-x1)/N
def simpson(x1,x2,f,N):
sum=0
i=1
for i in range(1,N+1):
sum+=f(x1+i*delta_x)
sum1=(3*delta_x)*sum
return(sum1)
print(simpson(0,math.pi,math.sin(x),100))
however I get the error 'float object not callable' on the sum+=f(x1+i*delta_x) line. Anyone know what could be wrong?
Thanks :)