# Unable to find the exact dimension of an expression

I have defined a variable called y, this contains a huge equation, but when I look for the dimension of y it shows 3. How come a single expression has dimensions of 3? It is supposed to be 1 right?

y=39.25 ω^2 (1.00519 Subscript[a,4]^2+1.00102 Subscript[a,4]^2+2.19056 Subscript[a,4] Subscript[a,4]-1.07645 Subscript[a,4] Subscript[a,4]+1.5 Subscript[a,4]^2+0.55507 Subscript[a,4] Subscript[a,4]+1.54742 Subscript[a,4] Subscript[a,4]+1.5 Subscript[a,4]^2);;
Dimensions[y]

• Well, it is a product of three things. A one-dimensional list, of three elements. Jan 10, 2020 at 13:56
• Dimensions needs a full array as argument (see documentation) . If you apply it to a scalar surprising results like Dimension[a+b] (* 2*)  occur. Jan 10, 2020 at 14:00
• It is a single expression right. Is it possible to make one expression with dimension 1 Jan 10, 2020 at 14:00
• Yes, something like {a +b} Jan 10, 2020 at 14:05
• Perhaps you would be interested in LeafCount which gives the total number of indivisible subexpressions. In this case, 78 Jan 10, 2020 at 15:53

Maybe what you are looking for is LeafCount. TreeForm is also useful for visualizing expressions.

TreeForm @ y From the point of view of tensor analysis, a scalar has no dimensions at all. You can make your own function that reflects this:

arrayDimensions[x_?ArrayQ] := Dimensions[x]
arrayDimensions[x_] := {}
arrayDimensions[{1, 2}]
(* {2} *)
arrayDimensions[a + b]
(* {} *}