> > Suppose I know a function of x and y simplifies into the form
> > a*(x + y)^2 + b*(x^2 + y^2)
> > where a and b are constants. If maxima has the function in the form
> > 2*(x^2 + y^2 + x*y)
> > how can I get it to give me it in the desired form?
This particular case is easy, because there are all sorts of useful
relations among the variables.
In particular, subst([x=0,y=1], form ) == a+b and
subst([x=-y,y=1],form) == 2*b, where form: a*(x + y)^2 + b*(x^2 +
y^2).
So for example:
expr: y^2+4*x*y+x^2$
solve( [ subst([x=0,y=1],expr)=a+b, subst([x=-y, y=1], expr) ], [a,b] ) =>
[[a = 2, b = - 1]]
Similarly,
diff(diff(expr,x),y) == 2*a and diff(expr,x,2) == diff(expr,y,2) == 2*(a+b).
So:
solve( [ diff(diff(expr,x),y) = 2*a, diff(expr,x,2) = 2*(a+b)], [a,b] )
=> [[a = 2, b = - 1]]
Of course, this only works if a and b are free of x and y... and you
mention that this is an "oversimplified" version. What is the
original problem? Does it lend itself to isolating constants by
tricks like this?
-s