FullForm of b/c and c/b with different order

I am studying Mathematica myself and doing some exercises for improvement.

Question: Try to guess the internal forms of b/c and c/b. Verify your answer using FullForm.

Here is what I got by using FullForm:

FullForm[b/c]

Times[b,Power[c,-1]]

FullForm[c/b]

Times[Power[b,-1],c]


As you can see from the full form of b/c and c/b, the order of two terms in function Times is different. I am wondering why does this happen? What is the purpose of this? For the full form of c/b, why not Times[c,Power[b,-1]]? Just curious, however this doesn't seem to be important.

Times has the Attribute Orderless:

Attributes[Times]

{Flat, Listable, NumericFunction, OneIdentity, Orderless, Protected}


As the documentation states:

Orderless is an attribute that can be assigned to a symbol f to indicate that the elements ei in expressions of the form f[e1, e2, ...] should automatically be sorted into canonical order. This property is accounted for in pattern matching.

Observe it acting on an arbitrary user head:

Attributes[head] = {Orderless};

head[b, c]


Among other things this helps to put expressions into a canonical form, allowing e.g. head[b, c] == head[c, b] to return True, as it should be for a commutative operator.
• Thanks. I still wonder why the form of b/c is sorted (canonical order) but c/b is not? Sep 29, 2017 at 8:01
• @anhnha It is sorted according to the canonical ordering function of Mathematica, e.g. Sort[{Power[b, -1], a, c}] outputs {a, 1/b, c}. Sadly that ordering remains poorly documented. Sep 29, 2017 at 8:07