Comment #3 on issue 2818 by [email protected]: factor() returns nan
http://code.google.com/p/sympy/issues/detail?id=2818
Also, simply expanding the rewrite allows factor to work. I also note the
following:
The original equation and the rewritten form
>>> p.count_ops(1)
212*ADD + 1017*COS + 98*DIV + 1913*MUL + 54*NEG + 40*POW + 985*SIN +
392*SUB
>>> sy=[str(s) for s in p.atoms(Symbol)]
>>> reps=zip(sy,[random.random() for s in sy])
>>> r=p.rewrite(exp)
>>> r.count_ops(1)
1306*ADD + 2682*DIV + 4004*EXP + 7239*MUL + 1076*NEG + 40*POW + 1300*SUB
>>> for i in reps:
... print i
...
('ddq4', 0.2315276327819824)
('dq2', 0.6751187444977427)
('dq3', 0.9226385283535564)
('dq1', 0.9187815293632833)
('dq4', 0.2296241539199898)
('ddq1', 0.5335199170579924)
('q4', 0.3217152633971888)
('q3', 0.8734801791983745)
('q2', 0.2518438953323938)
('ddq3', 0.8434382084910548)
('q1', 0.10355316353030186)
('ddq2', 0.9777986015874235)
check the numerical values -- they are different
>>> p.subs(reps).n()
-0.0233749453428897
>>> r.subs(reps).n()
.0e+0 + .0e+0*I
>>> (expand_mul(r)).subs(reps).n()
-0.0233749453428896 + .0e-22*I
Factoring after expanding works and the numerical values agree with
that obtained for p.
>>> factor(expand_mul(r)).subs(reps).n()
-0.0233749453428895 + 2.73168125489512e-19*I
>>> g=gcd_terms(expand_mul(r)).subs(reps).n()
-0.0233749453428895 + 7.71594075389464e-18*I
--
You received this message because you are subscribed to the Google Groups
"sympy-issues" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sympy-issues?hl=en.