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

sympy.integrate gives inconsistent results on a mathematically equivalent expression #26579

Open
terben opened this issue May 8, 2024 · 2 comments

Comments

@terben
Copy link

terben commented May 8, 2024

Here is my code:

import sympy as sp

u, b, x = sp.symbols('u, b, x', real=True)

sp.integrate(sp.sinh(x / u + b / u)**2 + 1, x)

sp.integrate(sp.sinh((x + b) / u)**2 + 1, x)

SymPy evaluates the first integral but it gives back the second one unevaluated.

The only difference is that the argument of the sinh in the first integral is written as x / u + b / u and in the second one as (x + b) / u.

sympy.__version__ returns 1.12

I would expect that both expressions return the same result.

@asmeurer
Copy link
Member

asmeurer commented May 8, 2024

The result is coming from heurisch. It's too surprising heurisch sensitive to the input format.

A good fix here would be to make powers of hyperbolic functions work in manualintegrate. The strategy should be similar to the one used for powers of regular trig functions. For example, $\sinh(x)^2 = \frac{\sinh(x)}{2} - \frac{1}{2}$ (that identity may need to be implemented somewhere, I'm not sure if it already is). Manualintegrate should handle the argument being (x + b)/u automatically via u-substitution.

Actually, I imagine quite a bit of manualintegrate's trig functionality could be extended to work with hyperbolic trig functions.

@smichr
Copy link
Member

smichr commented May 14, 2024

If possible, hyperbolics can be recast to normal trig functions with the Osborne transformation (private functions in fu.py), simplified, and recast to hyperbolics before integration.

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