The integral in question is:
integrand<-function(y){
exp(-sqrt(2*y + alpha^2)*abs(x))/ (pi^2 * y * ((besselJ(delta*sqrt(2*y), lambda))^2)
+ (besselY(delta*sqrt(2*y), lambda))^2)
}
integral<-function(x){integrate(integrand, lower=0, upper=Inf, subdivisions=20000)$value}
For some reason, when I try to run this (specifically for very small values of x), I get the error "The integral is probably divergent." I assumed that, since I was dividing by 'y', this was causing the error. However, if I change the equation around, ie,
integrand<-function(y){
(1/y)*(exp(-sqrt(2*y + alpha^2)*abs(x))/ (pi^2 * ((besselJ(delta*sqrt(2*y), lambda))^2)
+ (besselY(delta*sqrt(2*y), lambda))^2))
}
integral<-function(x){integrate(integrand, lower=0, upper=Inf, subdivisions=20000)$value}
Unless I'm mistaken (which I quite likely am) this should still be running the same equation. (Since multiplying by '1/y' should yield the same result as dividing by 'y'). However, running the integral this way, I don't get the "The integral is probably divergent" error. I'm very confused, and clearly I'm doing something terribly wrong here!
Edit: This was in fact not a duplicate of another question. The reason I was getting the error was due to a missing pair of brackets, not due to the tolerance as per the other question.