I consistently observe that mathematica is not able to simplify a few expressions that are quite obvious to human eye. I tried Simplify, FullSimplify, and other such functions.
For instance,
Simplify[128 d^2 + 412 d g - 49 g^2 - 256 d m - 412 g m + 128 m^2 + 412 d w - 98 g w - 412 m w - 49 w^2]
FullSimplify[ 128 d^2 + 412 d g - 49 g^2 - 256 d m - 412 g m + 128 m^2 + 412 d w - 98 g w - 412 m w - 49 w^2]
give the same expression 128 d^2 + 412 d g - 49 g^2 - 256 d m - 412 g m + 128 m^2 + 412 d w - 98 g w - 412 m w - 49 w^2, though one can easily see that it could be written more simply as 128(d-m)^2 - 49(g+w)^2 +…
Can anyone suggest the appropriate command to use to attain this simplification?
Whats obvious to a human is not always obvious to a machine. How does the machine know what form you want? You can help along with substitutions:
In[27]:= FullSimplify[
128 d^2 + 412 d g - 49 g^2 - 256 d m - 412 g m + 128 m^2 + 412 d w -
98 g w - 412 m w - 49 w^2]
Out[27]= 128 d^2 - 49 g^2 - 412 g m + 128 m^2 - 98 g w - 412 m w -
49 w^2 + 4 d (103 g - 64 m + 103 w)
In[28]:= FullSimplify[
128 d^2 + 412 d g - 49 g^2 - 256 d m - 412 g m + 128 m^2 + 412 d w -
98 g w - 412 m w - 49 w^2 /. m -> d - x /. g -> y - w]
Out[28]= 128 x^2 + 412 x y - 49 y^2
In[29]:= % /. x -> (d - m) /. y -> (g + w)
Out[29]= 128 (d - m)^2 + 412 (d - m) (g + w) - 49 (g + w)^2