Comment #6 on issue 2040 by [email protected]: Better way to make a rational
function out of an expression
http://code.google.com/p/sympy/issues/detail?id=2040
This is a fairly old issue, but just as a follow up: yes, powdenest does
the right thing by not doing anything with that expression since doing so
is not generally valid. (Note at the end of the example that powdenest is
not necessary if the symbols are posified.)
>>> eq=sqrt((x + y)**2*(x - y)**4)
>>> wish = (x + y)*(x - y)**2
>>> powdenest(eq) == eq
True
>>> reps = {x:-3*I,y:-1}
>>> eq.subs(reps).n() - wish.subs(reps).n()
20.0 - 60.0*I
>>> posify(eq)
((_x - _y)**2*(_x + _y), {_y: y, _x: x})
>>> _[0].subs(_[1])
(x - y)**2*(x + y)
posify was made to allow one to bypass the "assumptions nonsense"; anyone
wanting to do purely algebraic manipulation of expressions should consider
recasting the input formula with posify. (This is the sort of thing that
solve does in solving equations.)
As for streamlining the process, is there any reason not to just posify the
expression and apply sqf to it?
>>> sqrt(x**2 + y**2 + 2*x*y)
sqrt(x**2 + 2*x*y + y**2)
>>> posify(_)
(sqrt(_x**2 + 2*_x*_y + _y**2), {_y: y, _x: x})
>>> sqf(eq[0])
_x + _y
--
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.