1

The equation

29/36 - x/2 + x^2/4 + y/9 + y^2/36 - (4 z)/9 + z^2/9 == 1

is equivalent to

1/4 (-1 + x)^2 + 1/36 (2 + y)^2 + 1/9 (-2 + z)^2 == 1

This describes an ellipsoid. Using Expand on the second one give us the first one easily. But is there any way to go the other direction in Mathematica?

J. M.'s missing motivation
  • 124,525
  • 11
  • 401
  • 574
NonalcoholicBeer
  • 1,453
  • 7
  • 11
  • FullSimplify gives 9 (-2 + x) x + y (4 + y) + 4 (-4 + z) z == 7 which is even more compact and DivideSides[FullSimplify[...]] gives 1/7 (9 (-2 + x) x + y (4 + y) + 4 (-4 + z) z) == 1 – flinty Sep 10 '20 at 16:19

2 Answers2

4

Apart from FullSimplify in my comment, you can also use SolveAlways to get the constants that make the two forms match:

eqn = 29/36 - x/2 + x^2/4 + y/9 + y^2/36 - (4 z)/9 + z^2/9 == 1;
otherform = a (b + x)^2 + c (d + y)^2 + e (f + z)^2 == 1;
sol = SolveAlways[First[eqn] == First[otherform], {x, y, z}]

(* {{a -> 1/4, c -> 1/36, e -> 1/9, f -> -2, d -> 2, b -> -1}} *)

otherform /. First[sol]

(* 1/4 (-1 + x)^2 + 1/36 (2 + y)^2 + 1/9 (-2 + z)^2 == 1 *)

flinty
  • 25,147
  • 2
  • 20
  • 86
3

You could use ReplaceRepeatedand completing squares:

29/36 - x/2 + x^2/4 + y/9 + y^2/36 - (4 z)/9 + z^2/9 == 1 //. 
 a_ *s_^2 + b_ *s_ + rest__ :> a (s + b/(2 a))^2 - b^2/(4 a) + rest
(*1/4 (-1 + x)^2 + 1/36 (2 + y)^2 + 1/9 (-2 + z)^2 == 1*)
Ferca
  • 494
  • 3
  • 8