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

Simplify hangs #21641

Open
proy87 opened this issue Jun 19, 2021 · 2 comments
Open

Simplify hangs #21641

proy87 opened this issue Jun 19, 2021 · 2 comments

Comments

@proy87
Copy link

proy87 commented Jun 19, 2021

simplify(65712362363534280139543*ln(49/50)/2441406250000000000) is hanging. I guess it is because of coeff near ln.

@smichr
Copy link
Member

smichr commented Jun 21, 2021

>>> simplify(S.Half*log(4))
log(2)

logombine is responsible for making this change. Here is a less fortuitous change:

>>> logcombine(65*ln(49/S(50))/24)
log(16807*2**(7/24)*5**(7/12)*7**(5/12)/125000)

In simplify, logcombine is attempted without any requirements other than that the expression has log in it. There may be a better way to test whether such a change should be attempted.

skirpichev added a commit to skirpichev/diofant that referenced this issue Jun 21, 2021
@oscarbenjamin
Copy link
Contributor

This no longer hangs and simplify does not seem to call logcombine any more:

In [47]: e = simplify(65712362363534280139543*ln(S(49)/50)/2441406250000000000)

In [48]: e
Out[48]: 
                           ⎛4965712362363534280139543log⎜──⎟
                           ⎝50⎠
───────────────────────────────
      2441406250000000000

Calling logcombine explicitly does create a large expression but it is still computed quickly:

In [1]: %time e = logcombine(65712362363534280139543*ln(S(49)/50)/2441406250000000000)
CPU times: user 65.6 ms, sys: 424 µs, total: 66 ms
Wall time: 64.9 ms

In [5]: %time len(str(e))
CPU times: user 91.4 ms, sys: 205 µs, total: 91.6 ms
Wall time: 91.1 ms
Out[5]: 91361

Possibly what was hanging before was converting the output to a string. By default this fails now (I had to use sys.set_int_max_str_digits(0)) so that would not hang any more.

Probably with large enough inputs logcombine would still hang on an expression like this.

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