Reputation: 83
I want to calculate the integral or derivative of the modified Bessel functions in python. I want to calculate the infinite integral (without limits). Recently I found a method to do this. You can see an example for a simple function (x**2) below:
from sympy import *
x = Symbol('x')
print integrate(x**2, x)
The result is: x^3/3 . But when I put a modified Bessel function instead of x**2:
import scipy.integrate as integrate
import scipy.special as special
from scipy import integrate
from sympy import *
x = Symbol('x')
print integrate(special.iv(1,x), x)
In this case I get this error:
AttributeError: 'module' object has no attribute 'iv'
It should be noted that the integral of Bessel function of the first kind is Bessel function of the zero kind. I expect to get: iv(0,x)
How can I do that in python?
Upvotes: 2
Views: 2940
Reputation: 11
It can be easily integrated numerically, say from limit 1 to 10
from scipy import integrate
import scipy.special as sp
def f(x):
return sp.iv(1,x)
I,err=integrate.quad(f,1,10)
print(I,err)
The result of Integral is 2814.4505625885026, Error is 3.124667816254981e-11
Upvotes: 1