Perhaps I'm misunderstanding the meaning of Dimensions
in Mathematica, but the following two examples seem very counter-intuitive to me.
If we define
a = {1,2,3}
b = {4,5,6}
then we compute the dimension of its dot product Dimension[ a . b ]
, I get the "empty" result
{}
But if I consider instead,
aa = {a1, a2, a3}
bb = {b1, b2, b3}
and compute the same thing Dimension[ aa . bb ]
, I get the result
{3}
Is this behavior to be expected? I understand that the first case has known constants, and while the second case has unknown constants. But regardless, both are simply scalars, and I would expect Dimensions
would return the same answer in both cases.
Dimensions
does not only work with lists. Take a look atFullForm
of expressions you use inDimensions
. $\endgroup$FullForm
, I see that the first and second case yield wildly different forms. But is there a function in Mathematica where if I literally want to just "count dimensions", they would both yield the same result? For instance, as far as I can tell, in Mathematica, an $n \times m$ matrix of known constants and unknown constants yield the same answer inDimensions
. $\endgroup$Dimensions
which only respectsList
head? Good question. $\endgroup$ArrayQ[]
. $\endgroup$TensorDimensions
would be better used in this context. $\endgroup$