I find the following snippet unexpected.
srand(1); X = rand(1000, 1000) - 0.5; (X' *X) == (X' *X)' #true (1 * X' *X) == (1 * X' *X)' #false
1 changes the symmetry, probably due to floating-point arithmetic issues. But I fail to understand where the failure happens.
A = X' * X. Naively I expect that:
A[i,j] == sum(X[k,i] * X[k,j] for k = 1 : N) A[j,i] == sum(X[k,j] * X[k,i] for k = 1 : N)
Since multiplication is commutative (this holds in floating-point arithmetic as well), it follows that
A[i,j] == A[j,i], so
A is symmetric. I don’t see how multiplying by 1 changes this.