An integral related to solid angle and flux

28 views
Skip to first unread message

Joe Heafner

unread,
Aug 17, 2021, 3:29:10 PM8/17/21
to sympy
I need to evaluate an integral of the form

a/(x**2 + y**2 + a**2)**(3/2) where x, y, and a are Real and a is always positive. The integration limits are x = -a to x = a and y = -a to y = a.

This integral should have a value of 2*pi/3 but SymPy can't seem to evaluate it. 

The code integrate(a/(x**2+y**2+a**2)**Rational(3,2),(x,-a,a),(y,-a,a)) gets as far as doing the x integration but can't seem to complete the y integration. Changing Rational(3,2) to just 1.5 helps a tiny bit, but still leave the y integration unresolved.

Is there something I can do to get SymPy to evaluate this integral?

Joe Heafner

unread,
Aug 19, 2021, 3:09:48 PM8/19/21
to sympy
Here is some interesting code:

import sympy as smp
from sympy import *  # please pardon my use of import *
from sympy.vector import *
x,y,R = smp.symbols(' x y R', real = True, positive = True)
f = atan(x/xmp.sqrt(x**2 + 2*R**2))
diff(f,x).simplify(
Integral(_, (x,0,R)).doit()
g = atan(x)
diff(g,x).simplify()
Integral(_, x).doit()

It seems that SymPy can easily take the derivative of atan(x) and integrate that to get back atan(x), but has problems when the argument to atan() is a more complicated function. I wish I understood underlying algorithms so I could investigate this further.
Reply all
Reply to author
Forward
0 new messages