Comment #33 on issue 2607 by smi...@gmail.com: as_numer_denom() is too slow
http://code.google.com/p/sympy/issues/detail?id=2607

The unevaluated Mul is a very nice way to go unless you think that `Mul(2,x, evaluate=False)/2` should not be `x`. If you don't like the final touching iwth `+0` of the denominator you can `Mul(*Mul.make_args(den))` or just return the unevaluated Mul. Those changes (as_numer_denom4b) and my best shot at the expanded results with collection of common denominators and processing of Integer denominators (as_numer_denom5) are in the "and" branch of mine.

    >>> from sympy.abc import *
    >>> from sympy import *
    >>> a=x/2 + 1/(5*(x + 1))
    >>> a.as_numer_denom()
    (x*(5*x + 5) + 2, 10*x + 10)
    >>> a.as_numer_denom4()
    (x*(10*x + 10)/2 + (10*x + 10)/(5*x + 5), 10*x + 10)
    >>> a.as_numer_denom4b()
    (x*(5*x + 5) + 2, 2*(5*x + 5))
    >>> a.as_numer_denom5()
    (x*(5*x + 5) + 2, 10*x + 10)

    >>> a=(x/2+1/(x+1)+2)
    >>> a.as_numer_denom()
    (x*(x + 1) + 4*x + 6, 2*x + 2)
    >>> a.as_numer_denom4()
    (x*(2*x + 2)/2 + 4*x + 4 + (2*x + 2)/(x + 1), 2*x + 2)
    >>> a.as_numer_denom4b()
    (x*(x + 1) + 4*x + 6, 2*(x + 1))
    >>> a.as_numer_denom5()
    (x*(x + 1) + 4*x + 6, 2*x + 2)
    >>>


--
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