Sympy freezes when trying to solve a simple algebraic equation

I recently reinstalled my python environment and the code that worked very fast now crawls at best (usually just freezes, taking up more and more memory).

The point at which the code hangs:

solve(exp(-alpha * x**2) - 0.01, alpha)

I was able to reproduce this problem with a new IPython 0.13.1 session:

In [1]: from sympy import solve, Symbol, exp
In [2]: x = 14.7296138519
In [3]: alpha = Symbol('alpha', real=True)
In [4]: solve(exp(-alpha * x**2) - 0.01, alpha)

this works for integers, but also pretty slow. In the source code, I went in cycles on this search of hundreds of different alpha for different values ​​of x (except 14.7296138519), and it took no more than a second.

any thoughts?

+3
source share
2 answers

In cases like this, a rational False flag has been introduced.

>>> q=14.7296138519
>>> solve(exp(-alpha * q**2) - 0.01, alpha, rational=False)
[0.0212257459123917]

( , ).

+4

0.7.2 0.7.1 .

easy_install sympy==0.7.1

Google.

+2

Source: https://habr.com/ru/post/1656761/


All Articles