You might look into could_extract_minus_sign: >>> sympify('-Gc*k/(-Gc*k - k*m1*s**2 - k*m2*s**2 - m1*m2*s**4)').could_extract_minus_sign() True >>> sympify('Gc*k/(-Gc*k - k*m1*s**2 - k*m2*s**2 - m1*m2*s**4)').could_extract_minus_sign() False
Perhaps simplify() should do if expr.could_extract_minus_sign(): n, d = expr.as_numer_denom() expr = sympify(-1)*n/(sympify(-1)*d) or some similar. Aaron Meurer On Jun 8, 2009, at 11:36 AM, Ryan Krauss wrote: > So, I have yet another simplification question. What is the correct > way to factor a minus one out of this: > > In [108]: type(x2_tf_ds) > Out[108]: <class 'sympy.core.mul.Mul'> > > In [109]: x2_tf_ds > Out[109]: -Gc*k/(-Gc*k - k*m1*s**2 - k*m2*s**2 - m1*m2*s**4) > > This didn't work: > In [110]: sympy.simplify(x2_tf_ds) > Out[110]: -Gc*k/(-Gc*k - k*m1*s**2 - k*m2*s**2 - m1*m2*s**4) > > This works, and is fine with me. But I wonder if there is a better > way: > In [111]: a,b = x2_tf_ds.as_numer_denom() > > In [112]: -a/-b > Out[112]: Gc*k/(Gc*k + k*m1*s**2 + k*m2*s**2 + m1*m2*s**4) > > > Thanks, > > Ryan > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sympy" group. To post to this group, send email to sympy@googlegroups.com To unsubscribe from this group, send email to sympy+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sympy?hl=en -~----------~----~----~----~------~----~------~--~---