# Solving an equation in multiple variables

I have this equation : sqrt((b-a)^2 + (B-A)^2) == A+B and i would like to have it solved to b-a=+- 2 * sqrt(AB) in sage. Right now I have the following code but it doesn't really output what I want. I just get
A^2 - 2AB + B^2 + a^2 - 2ab + b^2 == A^2 + 2AB + B^2
and I don't know how to make sage solve it further.

my code:

var('a,b,c,A,B,C')
eq1 = (sqrt((b-a)^2 + (B-A)^2) == A+B)
(eq1^2).expand()

edit retag close merge delete

Sort by » oldest newest most voted You can try the following with substituting b-a with c

var('a,b,c,A,B,C')
eq1 = (sqrt((c)^2 + (B-A)^2) == A+B)
assume(A>0)
assume(B>0)
solve(eq1,c)


which results in

[c == -2*sqrt(A*B), c == 2*sqrt(A*B)]


But can anybody explain me the results of the computation without the assume statements? For A,B both beeing negative the solver does not do anything and for A being bigger and B being smaller then zero, sage throws an error that maxima needs further inputs (the same as when you're not using assume)

more

If there was no assume, an expression like sqrt(A*B) is not very well defined. The same kind of behavior occurs with simplify_radical.

Thanks, but in this case using different assume scenarios resulting in different results is strange (escpecially in the both is negative case)