Comment #2 on issue 1844 by smi...@gmail.com: expand methods pruned
http://code.google.com/p/sympy/issues/detail?id=1844

My attempts at getting expand fix have never caught on (#1725, #1849, and this issue), so I will just record here a suggestion that is easiest to implement: use cacheit. Then any repeated request will quickly resolve instead of repeating the substitution process. The only problem is that keywords to functions are converted to bools and this causes problems:

File "c:\users\leslie\sympy\sympy\core\tests\test_functions.py", line 222, in
test_expand_function
    assert expand((x + y)**11, modulus=11) == x**11 + y**11
  File "C:\Users\leslie\sympy\sympy\core\function.py", line 1562, in expand
    return sympify(e).expand(deep=deep, modulus=modulus, **hints)
  File "C:\Users\leslie\sympy\sympy\core\cache.py", line 101, in wrapper
    func_cache_it_cache[k] = r = func(*args, **kw_args)
  File "C:\Users\leslie\sympy\sympy\core\expr.py", line 1929, in expand
    if not modulus.is_Integer or modulus <= 0:
AttributeError: 'bool' object has no attribute 'is_Integer'

If keywords having argument of only 0 or 1 are bool'ified then expand can be decorated and the time to compute the solution to

    var('u',real=True)
    eq=u - (x**2 + y**2 + 1)*x/(x**2 + y**2)

drops from 76 seconds to 3 seconds: most of that time is spent in expand. The expression is not very complicated, so even 3 seconds seems like a long time:

[u/3 + (-u**2/9 + y**2/3 + 1/3)/((-1/2 + sqrt(3)*I/2)*(-u**3/27 - u*y**2/2 + u*( y**2 + 1)/6 + sqrt((-u**2/9 + y**2/3 + 1/3)**3 + (-2*u**3/27 - u*y**2 + u*(y**2 + 1)/3)**2/4))**(1/3)) - (-1/2 + sqrt(3)*I/2)*(-u**3/27 - u*y**2/2 + u*(y**2 + 1 )/6 + sqrt((-u**2/9 + y**2/3 + 1/3)**3 + (-2*u**3/27 - u*y**2 + u*(y**2 + 1)/3)* *2/4))**(1/3), u/3 + (-u**2/9 + y**2/3 + 1/3)/((-1/2 - sqrt(3)*I/2)*(-u**3/27 - u*y**2/2 + u*(y**2 + 1)/6 + sqrt((-u**2/9 + y**2/3 + 1/3)**3 + (-2*u**3/27 - u*y **2 + u*(y**2 + 1)/3)**2/4))**(1/3)) - (-1/2 - sqrt(3)*I/2)*(-u**3/27 - u*y**2/2 + u*(y**2 + 1)/6 + sqrt((-u**2/9 + y**2/3 + 1/3)**3 + (-2*u**3/27 - u*y**2 + u* (y**2 + 1)/3)**2/4))**(1/3), u/3 + (-u**2/9 + y**2/3 + 1/3)/(-u**3/27 - u*y**2/2 + u*(y**2 + 1)/6 + sqrt((-u**2/9 + y**2/3 + 1/3)**3 + (-2*u**3/27 - u*y**2 + u* (y**2 + 1)/3)**2/4))**(1/3) - (-u**3/27 - u*y**2/2 + u*(y**2 + 1)/6 + sqrt((-u** 2/9 + y**2/3 + 1/3)**3 + (-2*u**3/27 - u*y**2 + u*(y**2 + 1)/3)**2/4))**(1/3)]


https://github.com/sympy/sympy/pull/583

--
You received this message because you are subscribed to the Google Groups 
"sympy-issues" group.
To post to this group, send email to sympy-issues@googlegroups.com.
To unsubscribe from this group, send email to 
sympy-issues+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sympy-issues?hl=en.

Reply via email to