Status: Accepted
Owner: asmeurer
CC: mattpap
Labels: Type-Enhancement Priority-Medium Polynomial
New issue 2042 by asmeurer: Frac() object for rational function arithmetics
http://code.google.com/p/sympy/issues/detail?id=2042
I've been thinking about this for a while now, so I figured I would go
ahead and throw it out. In my integration work, about half the time I deal
with elements of K[t], and the other half of the time I deal with elements
of K(x). My solution for the latter case has been to keep track of the
numerator and denominator of the expression separately, but things would be
really easier if there was some kind of Frac() object that was just like
Poly(), only for rational functions.
It probably would be just a wrapper around DMF, like Poly is a wrapper
around DMP, but it could also be a wrapper around two Polys.
It would automatically do things like addition and multiplication correctly
(I've had more than one case where I misapplied the rule a/b + c/d == (a*d
+ c*b)/(b*d), which gets complicated with multiple items, which may not all
be fractions, or when additively incrementing an item). It ideally would
also have options to do things like automatically keep the numerator and
denominator canceled, and keep one of the two monic. If you look around
the code in my integration3 branch, you will see that a large part of it is
dedicated simply to keeping track of the numerator and denominator of a
rational expression (for example, the lines at the end of hermite_reduce()
in risch.py). I even created a simple frac_in() function to handle a
particularly common idiom, which is to create a new "rational function
object" (i.e., Poly tuple pair) in a different variable. This all makes
things harder to read and easier to contain a bug.
This would also be the best way to deal with issue 2032.
Mateusz, have you ever considered something like this?
--
You received this message because you are subscribed to the Google Groups
"sympy-issues" group.
To post to this group, send email to sympy-iss...@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.