Skip to content
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 failure #14035

Open
tverticalis opened this issue Jan 30, 2018 · 1 comment
Open

Integration failure #14035

tverticalis opened this issue Jan 30, 2018 · 1 comment

Comments

@tverticalis
Copy link

tverticalis commented Jan 30, 2018

The following integral should evaluate to 1 (for beta > 0). The function is a probability density function (PDF) of the angular elevation of points distributed on a unit sphere. If beta = 1, the points are uniformly distributed on the sphere. In the general case, Python 3.6.3 does not produce an answer in a reasonable amount of time (< 30 min):

from sympy import Symbol, integrate, Rational, Pow, exp, sin, cos, pi
beta = Symbol('beta', positive = True)
theta = Symbol('theta')
res = integrate(beta*sin(theta)/(2*Pow(1+(beta**2-1)*(cos(theta))**2, Rational(3,2))), (theta,0,pi))

(I am not sure why line breaks are not formatted correctly in the Preview.)

It works for beta = 1 (which greatly simplifies the expression) but again fails for beta = 2.

For comparison, Mathematica 11.2 produces the expected result (1) in less than 0.3 s on the same system:

Assuming[beta > 0, Integrate[beta*Sin[theta]/(2*(1 + (beta^2 - 1)*Cos[theta]^2)^(3/2)), {theta, 0, Pi}]] // Timing

In all other respects, Python did as well as Mathematica.

Thank you.

@ylemkimon
Copy link
Member

You can use triple backticks(```) for multi-line codes.

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

No branches or pull requests

3 participants