The situation is as follows:

sage: R.<a, b> = ZZ[]
sage: (2*a/b).factor()
2 * b^-1 * a
sage: (a/(2*b)).factor()
2^-1 * b^-1 * a
sage: (3*a/(2*b)).factor()
Traceback (most recent call last):
...
TypeError: Cannot multiply 3 * a and 2^-1 * b^-1 because they cannot be coerced
into a common universe

However, the univariate ring behaves differently:

sage: S.<c> = ZZ[]
sage: (2*c/(c+1)).factor()
2 * (c + 1)^-1 * c
sage: (c/(2*(c+1))).factor()
2^-1 * (c + 1)^-1 * c
sage: (3*c/(2*(c+1))).factor()
2^-1 * 3 * (c + 1)^-1 * c


Am 2017-02-16 um 17:11 schrieb John Cremona:
> On 16 February 2017 at 15:07, Clemens Heuberger
> I would say that was a bug.  Change ZZ to QQ and it is fine.

I still consider the current behaviour to be a bug, especially in view of the
better behaviour of the univariate ring. In particular, throwing a TypeError
seems to be quite inappropriate here.

I usually prefer to work in the fraction field of ZZ[] because the results tend
to be nicer (and I am not particularly happy to convert my final result just to
get some copy&paste ready version).


-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.

Reply via email to