Comments

1

Asking for some more words in

sage: var('y t');
sage: E = -2/3*y + 2/3 * t
sage: E.factor?

we get (also)

If you are factoring a polynomial with rational coefficients (and
dontfactor is empty) the factorization is done using Singular
instead of Maxima, so the following is very fast instead of
dreadfully slow:
sage: var('x,y')
(x, y)
sage: (x^99 + y^99).factor()

From a practical view, my need is to factor "true factors", not units over $\mathbb Q[t,y]$. (Working over $\mathbb Q$ 2/3 is a unit. Why factor it?) If i would have to chose between a quick existing factorization - when i need it - and a rewritten version of it...

This does not answer the question, it changes the view so that the issue is less important

2 answers

[tl:dr] The Symbolic Ring is not able to represent expressions such as (2/3) * (t - y) and directly uses associativity to "simplify" such an expression.[/tl;dr]

Another answer to your question, which is complementary to the other one. Since your expression is a polynomial with rational coefficients, the factorization is done using Singular. The code for this can be seen using E.factor?? and the part of interest is

where self is the expression you want to factor (here self is E, that is 2/3 * t - 2/3 * y. At the first line, f gets the expression as a polynomial over QQ, and at the second line this polynomial f is factored, and w gets the string representation of the polynomial. If you try this by hand you get:

So you get the string representation of what you want. Now the third line converts the string back to a symbolic expression, and you can verify that you obtain the same result as with E.factor(), which is not what you want:

As you can see, the integer sums are directly "reduced", associativity is used as soon as one operand of a multiplication is an integer (or a rational number, etc.). The current implementation of symbolic expressions is thus unable to represent the factorization you want. I am not able to dig in the code for symbolic expressions, so I cannot explain why some simplifications are performed and other are not. Yet, note that one aim of the Symbolic Ring is to present the results as the user would probably like to see them. Of course, this is ill-defined and results in problems like the one you are experiencing. As a rule of thumb, you should try to avoid the Symbolic Ring as much as possible, and work with more specialized rings as often as you can.