I am considering the following function called funAl:
1/2 (1 + (Sqrt[3] Sqrt[868 - 1700 xi + 825 xi^2])/Sqrt[4 - 25 xi^2]) This function occurs as a boundary in one of my integrals which i am integrating with Vegas numerically. For all considered values of xi funAl should be real and less than 1. But for some values of xi (values which are allowed), i get something like:
funAl //. xi -> 0.973991669410735` 0.942244 + 0. I Vegas stopes integrating because of non-real values, but as you see the imaginary part is just 0. NIntegrate for example works perfectly fine. Any ideas why the funtions funAl containing only square roots gives back such values?
The integral is of the following form:
contr42 = Vegas[Sqrt[xi^2*u0Max2^2 - mu^2]*u0Max2*1/(2*(2*Pi)^3)*g* J2[xi *u0Max2], {xi, 14/15, 1}, {alpha, funAl, 1}, {eta, 0, 1}, {rho, 0, 1}, {beta, 0, 1}, MaxPoints -> 10^6] So values of xi are inserted into funAl and return the kind of numbers given above and due to the imaginary part i get an error.
//Chopshould be OK $\endgroup$xi. The imaginary parts just happen to cancel each other out. But they're there in the intermediate calculations, which means that the expression is type-casted intoComplex, thus the (float-vanishing) imaginary part. You should useChopto remove this small number (or, say,Limitinstead ofReplaceRepeated; and, FWIW, you should probably usingReplaceAllin the first place anyway). $\endgroup$WorkingPrecision. We cannot verify that it will work since you have not provided a definition forVegas,J2, ... $\endgroup$funAl = 1/2 (1 + Sqrt[3 (868 - 1700 xi + 825 xi^2)/(4 - 25 xi^2)])? $\endgroup$