Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Your example:

sage: y == C.add(-A*x,hold=True)/B
y == (C - A*x)/B

Another example:

sage: a = (-2*x).add(x^2,-x^3, hold=True); a
-2*x + x^2 - x^3

Further operations reorder the expression

sage: -2*a
2*x^3 - 2*x^2 + 4*x

You have to start with a symbolic expression:

sage: -2.mul(a,hold=True)
AttributeError: 'sage.rings.integer.Integer' object has no attribute

sage: Expression(SR,-2).mul(a,hold=True)
-2*(-2*x + x^2 - x^3)

sage: a.mul(-2,hold=True)
-2*(-2*x + x^2 - x^3)

Don't know why kcrisman gets a reordered expression

sage: B.add(A,hold=True)
B + A