I know how to integrate a function with Scipy. I do it in this way:
from scipy import *
from scipy import integrate
integral = integrate.simps(y,x)
In this way I integrate with the Simpsons’ rule the function y(x), but what if I want to integrate this function in cylindrical coordinates?
I mean, instead of the integral \int y(x)dx I want to solve the integral \int y(x)*2*pi*x*dx.
I tried with
integral = integrate.simps(y,x**2.*pi)
But it doesn’t seem to return the correct result.
I am integrating data points, not functions!
You should try
where
yshould be an array of function values at the positionsx. Note that2*pi*xis the necessary factor to add to your integrand (as you pointed out yourself).