Comment #5 on issue 2818 by smi...@gmail.com: factor() returns nan
http://code.google.com/p/sympy/issues/detail?id=2818

The original expression has expired at the OP link given. Assuming S is available from sympy, the value of p can be reconstructed from the following by copying text between triple-# and running it as a script:

###
code = \
r'''begin 666 -
M'XL( , Z:T\"_^U;S8[C( Q^E1X3*K0*R3S1]K*778WF_:4-20C&-DU,ZY89
M<6K5-/C_\P]P^W2FNWT.IIL_._OUYV_W.?1F^1S[R_7R^]_7\LORZ;;/L=_^
M,O47>UF^A4?AKU/X2UC-];\^YC][,N%WM.9,;:,;EB)4XF*(2B3_Z\,O=/-R
M6069T+N:,B54KA<O3OC=.*14S*]QLQY,%W[>2 *N$CYGDOVNH$!TT>+X6N_P
M=(HTZ4SSCY?X!V!]-E=#CN89,]'.+EHC&@-0DD@_1D8]>[FW;/8M_VP!)RNG
M&67U'BRE'=]>>9B\V"Y5^P@0:22&]^HZS_-B/KIZ?FV$A(E(SN#E^TP88V>T
M>6>\'CMC]+BKHLOO5#)A_!R9N##62%N$CC>N-U02F>/JA53.^UX2@L]>1/&3
M>'X:?6>)IM%7 !AA&0"UZ&40F +NC$M"[01#RQN!!Q/CW;@TJ@H,@Q/? R"'
MPD'"#.OJ\EQ"';9$(AH*WNF5$,N[@@Y*[66UU>$]C2_=@FF594K,\)Q:29HA
MGT[_?%F0DG^.)251JN"J$O(K PWJ-*%NJ:Z1E39!D_(\\3L/,CA!1M?S88OZ
MN7UE&Y].25*E9I:G[5 #RFO^3'U74+_@%DS 2[8J$S1,@7NMKED!^!/ 1\GK
MB;SK)R]0/X;&\Y3-(-QJI[PW8_Z)C&M%JD,HM++_@X9&,P!D^K*W-&:U=V9O
M;LV6 ![,GCS1P-L_&9E1YVW?*"DH*[:5B^9CWA:[>PTI2T-NQ@2K@Z%G1P:C
MR=>L^U,8&U&6#O)#DZ9_BL2!_&"W&$)6P6BP\G$?$< P0FP<ZK9E1DH"9ZU+
MRBM/LH2\:$3*CNZ_K8U6],&2EHO4(2IQ06JQBER1F0P[PY$R#NC()7ACD'7&
MDOGO?96LSZE2>%ZC6@"C0]K@W%.-%+A]2<^[&OB==3; _\ W8O<=#CP'+K<7
M*V_O;+<J0]AG?.=&HW4:M]9J/-9J[(57%1.4*Z@BE7:7@\ Z'LW6?BZ5V_&Y
M8->92/#T5=815JYH?>(.ZA18#&&%\O5)KBY!P#_EBG=J-LA#7F$"4S+ZPLEP
MHOJ*AB"E >F!6-,3??%'B?@LQ\V75$(D4^_KS@?H]JS*:9*=C.IIDD!%CLB;
MS[T?A($H#<I.0QF:#35(.X8TM&KTF:((0EWM6!*#L*5\>DE90Q^N4JO6,/@0
M#P$:LATCFWPTT6#O$/:V]%!!GF=WG02@N8U;:CG4\,-.-80^=9WJ/;)9M1TH
M*-U?0><2Q.-[>M[:DF7*3R94-'8G&J]J%X@Y'%+J6HPQAT>-6>Y:B=KM?NRE
M)()'.BY_,&+",>!B1($[3.D /VZ2@)"*BP HR<!351M6**RKB!SF*-,RW_N)
M=WK:I1[II1Z4H)4W86 2U[X=$L%/R\.96D!GFPQEF-;V"6;SI$1OW=W)H19[
MX%H3)_B*["4AI8<3#/BYEX!?2>*H9?_T@2I1<G#"-C ]"::'?6L#T\,= GB7
M '<=X6Y-NUW0;A>T(S^G;A>TH6(;*FH,%=OE^^]R^;Y-+=K4HDTM6J&=GUK\
)!X?,*NSW3@

end
'''
def tug(string):
    """Return text of a uu encoded gzipped text."""
    import StringIO, uu, gzip
    f1 = StringIO.StringIO()
    f2 = StringIO.StringIO()
    f2.write(string)
    f2.seek(0)
    uu.decode(f2, f1)
    f2.seek(0)
    f2.flush()
    f1.seek(0)
    text = gzip.GzipFile(fileobj=f1, mode='rb')
    msg = text.read()
    [f.close() for f in [text, f1, f2]]
    return msg

p = S(tug(code))
###


If you even apply signsimp to it first it factors:

factor(signsimp(p.rewrite(exp))).count_ops(visual=1)
48*ADD + DIV + 197*EXP + 657*MUL + 24*POW + 55*SUB


Here is a much shorter expression that factors as NaN:


    >>> s
    (1 - 2*(-(-x + 1/x)/(x*(x - 1/x)**2) - 1/(x*(x - 1/x)))/(x*(2*x -
    2/x)))*(-(-x + 1/x)/(x*(x - 1/x)) + 1/x)/((2*x - 2/x)*(2*x - 2/x -
    4/(x**2*(2*x - 2/x)))) - (-(-x + 1/x)/(x*(x - 1/x)**2) - 1/(x*(x -
    1/x)))*(-(1 - 2*(-(-x + 1/x)/(x*(x - 1/x)**2) - 1/(x*(x -
    1/x)))/(x*(2*x - 2/x)))*(-(-x + 1/x)*(-(-x + 1/x)/(x*(x - 1/x)) +
    1/x)/(2*x - 2/x) - 1/x)/(2*x - 2/x - 4/(x**2*(2*x - 2/x))) - (-x +
    1/x)*(-(-x + 1/x)/(x*(x - 1/x)**2) - 1/(x*(x - 1/x)))/(2*x -
    2/x))/(2*x - 2/x) - (-(-x + 1/x)/(x*(x - 1/x)**2) - 1/(x*(x -
    1/x)))/(2*x - 2/x)
    >>> factor(s)
    nan
    >>> factor(signsimp(s))
    1/(2*x*(x**2 - 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