I reproduced your results and then calculated the equation using for loops, just to make sure, and got 1.8767e37, same as the second way. Anyway,
can't really be correct since it squares the entire matrix as a matrix product, but both
and the for loop way of doing things proceed element-by-element.
Such a large result as 10^37, is that expected? The expression depends on the scaling of the matrix, i.e. if every element in the matrix were multiplied by 2, the result would be different. If the result is supposed to be a dimensionless condition number, I would think there would have to be some kind of normalization done on aij before using the expression that you have.
Here's Matlab cond: