6

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?

Domen
  • 23,608
  • 1
  • 27
  • 45
Thuy Nguyen
  • 909
  • 4
  • 11

3 Answers3

4
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$

azerbajdzan
  • 15,863
  • 1
  • 16
  • 48
2

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.

Nasser
  • 143,286
  • 11
  • 154
  • 359
1

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 *)
mikado
  • 16,741
  • 2
  • 20
  • 54