New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integration error #7383

asmeurer opened this Issue Apr 8, 2014 · 0 comments


None yet
1 participant
Copy link

asmeurer commented Apr 8, 2014

From the mailing list:


I was double-checking an integral with sympy, and noticed that the software comes up with the wrong answer. The integrand has five terms, which can be collected into three groups. Two of the groups -- Ec1 and Ec2 -- cancel after integrating over z. Strangely, sympy gets the answer right if you ask it to integrate the groups separately.

x, z, R, a = symbols('x z R a')
r = sqrt(x**2 + z**2)
u = erf(a*r/sqrt(2))/r
Ec = diff(u, z, z).subs([(x, sqrt(R*R-z*z))])
>>> simplify(integrate(Ec, (z, -R, R)))
-2*sqrt(2)*a*(R**2*a**2 + 3*R**2 - 3)*exp(-R**2*a**2/2)/(3*sqrt(pi)*R**3)
to the analytical answer
in particular, Ec = Ec1 + Ec2 + Ec3, where
Ec1 = sympify('3*z**2*erf(sqrt(2)*a*sqrt(R**2)/2)/(R**2)**(5/2) - erf(sqrt(2)*a*sqrt(R**2)/2)/(R**2)**(3/2)')
Ec2 = sympify('+ sqrt(2)*a*exp(-R**2*a**2/2)/(sqrt(pi)*R**2) - 3*sqrt(2)*a*z**2*exp(-R**2*a**2/2)/(sqrt(pi)*R**4)')
Ec3 = Ec - Ec1 - Ec2 # -sqrt(2)*a**3*z**2*exp(-R**2*a**2/2)/(sqrt(pi)*R**2)

simplify(integrate(Ec1, (z, -R, R))) # -> 0
simplify(integrate(Ec2, (z, -R, R))) # -> 0

integrate(Ec3, (z, -R, R))

skirpichev added a commit to diofant/diofant that referenced this issue Dec 28, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment