I suppose you're wondering about expression structure, for which one might look into some of the Tech Note links in the guide Expression Structure. An expression in WL has the structure h[a, b,...] where h is called the Head and the number of "arguments" a , b ,... is a nonnegative integer. For instance f[] , f[x] , f[x, y] , f[x, y, z] , etc.
Parts of expressions.
The parts of say h[a, b] are numbered: h is part 0, a is part 1, b is part 2.
If k is a nonnegative integer, expr[[k]] returns part k if it exists. So h[a, b][[0]] returns h , h[a, b][[1]] returns a , and h[a, b][[2]] returns b . In the case of Sqrt[2] = Power[2, 1/2] , part 0 is Power , part 1 is 2 , and part 2 is 1/2 .
What Dimensions calculates.
Dimensions[h[a, b]] returns {2} because the expression is a list of two arguments with head h . Dimensions[h[h[a, b, c], h[d, e, f]]] returns {2, 3} because the expression is a list of 2 expressions, each having a list of 3 arguments, and all with the same head h as at the top level. Dimensions[h[h[a, b, c], g[d, e, f]]] returns {2} because it is a list of two expressions, but each expression does not have the same head h . Dimensions[h[h[a, b, c], h[d, e]]] returns {2} because it is a list of two expressions, but each expression does not have the same length. Both head and length have to be the same for Dimensions to return a number for the next level.
Numbers and numeric expressions.
You were perhaps expecting Sqrt[2] to be a number. It is not, not in WL according to what is defined to be a number: NumberQ[Sqrt[2]] returns False . It is, instead, a numeric expression: NumericQ[Sqrt[2]] returns True . Power[2, 1/2] is an "exact" symbolic expression representing the real number
$\sqrt{2}$. When you square it, you get the Integer 2 and not the Real 2. (Integer and Real are two types of numbers in WL, which you can look up.) It can be approximated to arbitrary precision. And generally it is used in computations as if it were the exact
$\sqrt{2}$. But Power[2, 1/2] is an expression with parts and not a type of WL number.
|