Large numerical discrepancy in the scipy package(see the screenshots for the reproducibility)

Viewed 38

Consider the following integral

int dv from -1 to 1  ( int du from -1 to v  ( 1/sqrt(1-u^2)/sqrt(v-u) ))

where the exact result was 4/sqrt(2)=5.65685. The wolframalpha was able to provide the exact result, while in scipy

def integrand02(u, v): 
    return (1/np.sqrt(v-u))/np.sqrt(1-u**2);
def integral_03(v):
    return integrate.quad(integrand02, -1, v , args=(v,))[0];
integrate.quad(integral_03, -1,1)

(5.158207687859731, 4.814388887552923e-10)

and

def integrand02(u, v): 
    return (1/np.sqrt(v-u))/np.sqrt(1-u**2);

integrate.dblquad(integrand02, -1,1,-1, lambda v:v)

(5.158207687859731, 8.408088447708906e-08)

consistently provided a value that's smaller than 5.6 by almost 10%.

Just in case if you could not reproduce the result.

This did not appear to be an issue of the interface

enter image description here

Is there a bug and how to fix it?

0 Answers
Related