[Video 2] "MemoryError:" when doing the "Confirm that U, Vh are orthonormal" exercise

In one of the exercises in the SVD section, we are asked to confirm that U, Vh are orthonormal. In Rachel’s answer, she mentioned that with the U matrix, we should do the multiplication testings with columns, so we are using U.T @ U here. However with Vh we should be dealing with rows.

I am confused about this. Reading this post on Wolfram MathWorld, I think determining whether the matrices are orthonormal by doing U.T @ U and U @ U.T should yield the same result, and my experiment confirmed that. However, when I was trying to do Vh.T @ Vh, the notebook immediately throws out a “MemoryError”. Running Vh @ Vh.T was fine though. Why did this happen? Have I misunderstood something?

Thank you very much!

I tried running Vh.T @ Vh and it worked for me. I checked the memory usage and it was extremely high (around 6 GBs of RAM usage). Probably your computer was not able to handle it and that’s why you got an out of memory error.

But if you think about both of them should not be the same size. I am talking simply based on dimensions that would be created for the resulting matrix. Vh @ Vh.T will result in 2034 X 2034 matrix but Vh.T @ Vh will result in a 26576 X 26576 matrix. The storage would be 100 times compared to the first thing. I am not so sure about the memory model so the last sentence is based only considering the number of elements.