6
$\begingroup$

With Maple, I tried

expand((x - 1)^2 + (y + 2)^2 + (z - 5)^2 - 25 = 0);

and got

enter image description here

With Mathematica, I tried

Expand[(x - 1)^2 + (y + 2)^2 + (z - 5)^2 - 25 == 0]

I got

5 - 2 x + x^2 + 4 y + y^2 - 10 z + z^2 == 0

How can I get the result like result of Maple?

$\endgroup$
1

3 Answers 3

4
$\begingroup$
HoldForm[+##] & @@ 
 MonomialList[(x - 1)^2 + (y + 2)^2 + (z - 5)^2 - 25, 
  "DegreeLexicographic"]

$x^2+y^2+z^2-2 x+4 y-10 z+5$

$\endgroup$
2
$\begingroup$

cheating by using answer in The ordering problem of multivariate polynomials

With very minor change to make the order reverses from the original code.

p = Expand[(x - 1)^2 + (y + 2)^2 + (z - 5)^2 - 25];
orderedForm[poly_, var_List] := 
  HoldForm[+##] & @@ 
   MonomialList[poly, 
     var][[Ordering[Total[#] & @@@ CoefficientRules[poly, var], All, 
      GreaterEqual]]];
orderedForm[p, {x, y, z}]

Mathematica graphics

There should be simpler way I would think.

$\endgroup$
1
$\begingroup$

While it doesn't give exactly the form you request, you can get an order that you might prefer, using TraditionalForm

Expand[(x - 1)^2 + (y + 2)^2 + (z - 5)^2 - 25 == 0] // TraditionalForm
(* x^2-2 x+y^2+4 y+z^2-10 z+5==0 *)
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.