# Global order setting

I'm working on mathematical models using many alphabets and Greek characters as parameters or variables. However, The outputs show them in undesired order. Here are some examples:

(1/2)*(\[Beta]^2*(-A + m*\[Delta] + \[CapitalDelta])^2*\[Theta]1 + k*(m^2*\[Beta]^2 - 8*\[Beta]*\[Theta]1 + 2*m*\[Beta]*\[Lambda]1 + \[Lambda]1^2))

this $$(-A+m \delta+\Delta)^2$$ should have been written like this $$(A - m\delta - \Delta)^2$$

or this $$1/2 (-m \beta + \lambda1)$$ should be like $$1/2 (\lambda1-m \beta)$$

How can I get the entire notebook's output in the desired order?

• Edit your question to include the Mathematica code (InputForm) for your expressions so that they can be copy and pasted into a notebook Commented Dec 12, 2022 at 2:39
• expr /. (z_)^2 :> (-z)^2 Commented Dec 12, 2022 at 4:25
• To make a simpler example, the input b-a returns -a+b. That is because Plus has attribute Orderless and uses a certain built-in ordering. I would not try to change that. It is not important and not worth it. Just accept the built-in ordering when you do calculations. If you have to include a result in a paper, you can change it then if you can't help it. Commented Dec 12, 2022 at 6:19
• Just to add on the comment above b-a returns -a+b and a - b returns a-b because Mathematica is imposing a canonical order which might make it easier to match patterns and possibly also simplify. The order of a and b in the expression is the same as Sort[{b,a}]. This automatic sorting can also make pattern matching a bit more difficult when the pattern is inside an even function such as Cos. An example of that is given here Commented Dec 12, 2022 at 6:31

You can change how expressions are displayed (not stored) to some extent. Applying TraditionalForm produces an output with a more pleasing order, usually avoiding leading minus signs.