I am studying Mathematica myself and doing some exercises for improvement.
Question: Try to guess the internal forms of
b/candc/b. Verify your answer usingFullForm.
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.
b/cis sorted (canonical order) butc/bis not? – emnha Sep 29 '17 at 08:01Sort[{Power[b, -1], a, c}]outputs{a, 1/b, c}. Sadly that ordering remains poorly documented. – Mr.Wizard Sep 29 '17 at 08:07Sort[{foo[b, -1], a, c}]which returns{a, c, foo[b, -1]}-- do you not think it at least plausible for that to cause confusion? – Mr.Wizard Sep 29 '17 at 08:10DownValues,UpValues,OwnValuesand how everything relates toAttributesetc. – halirutan Sep 29 '17 at 08:20cis shorter thanPower[b, -1]– LLlAMnYP Sep 29 '17 at 09:02Sort[{Power[b, -1], Power[b, 1]}]would be reversed, as the-1is longer. Unfortunately, even this isn't true as you can see inSort[{power[b, -1], power[b, 1]}]:) Appending another parameter to the firstpowerhowever does push it to the end. – halirutan Sep 29 '17 at 09:14-1and1are both integer literals, but ofc-1comes before1– LLlAMnYP Sep 29 '17 at 09:16Power[b, 1]directly simplifies tobbut even withSort[Hold[Power[b, 1], Power[b, -1]]]one sees that the sorting is respected. – Mr.Wizard Sep 29 '17 at 09:17