Manually grouping symbolic terms
Given a symbolic expression like:
sage: var("a b c x y")
(a, b, c, x, y)
sage: a*x^2 + a*y^2 + b*y^2 + c*y^2 + (2*a*y + b*y)*x
How can I manually collect terms together? I want to represent this equation in the form:
$$ Ax^2 + Bxy + Cy^2 $$
Where $A = a, B = 2a + b, C = a + b + c$. Desired output should be:
a*x^2 + (2*a + b)*x*y + (a + b + c)*y^2
And then is there any way to read off these coefficients? Thanks
it is too bad that sage can't collect on more than one variable. In Mathematica one can just type
expr = a*x^2 + a*y^2 + b*y^2 + c*y^2 + (2*a*y + b*y)*x; Collect[expr, {x, y}]
and geta x^2+(2 a+b) x y+(a+b+c) y^2