# Why don't eigenpairs calculated through torch.linalg.eig pass the eigenpair test?

Running the following code:

``````import torch

torch.manual_seed(47)

m = torch.rand([8, 8])

eigvals, eigvecs = torch.linalg.eig(m)

print(m.type(torch.complex64) @ eigvecs[0] - eigvals[0] * eigvecs[0])  # Should be close to →0.
``````

Results with output:

``````tensor([ 2.2827+0.0995j, -0.9539-0.0442j, -1.9871-0.0204j, -0.6442-0.0372j,
-0.8338-0.0518j,  1.2168-0.0077j,  0.4924-0.5008j,  0.9643+0.4292j])
``````

What is going on here? How is it that the eigenpair test fails?

Hi Amos!

The individual eigenvectors are stored column-wise in you `eigvecs` tensor.

Consider:

``````>>> import torch
>>> torch.__version__
'2.3.0'
>>> _ = torch.manual_seed (47)
>>> m = torch.rand ([8, 8])
>>> eigvals, eigvecs = torch.linalg.eig (m)
>>> m.type(torch.complex64) @ eigvecs[0] - eigvals[0] * eigvecs[0]
tensor([ 0.8314-0.0995j, -2.1299+0.0442j, -2.9472+0.0204j,  2.5143+0.0372j,
1.4673+0.0518j,  0.5620+0.0077j, -0.1461+0.5008j, -0.4469-0.4292j])
>>> m.type(torch.complex64) @ eigvecs[:,0] - eigvals[0] * eigvecs[:,0]
tensor([ 3.5763e-07+0.j,  5.9605e-07+0.j,  4.7684e-07+0.j,  2.3842e-07+0.j,
3.5763e-07+0.j,  2.3842e-07+0.j, -2.3842e-07+0.j,  1.1921e-07+0.j])
``````

Best.

K. Frank