# np.linalg.eigh sorts eigenvalues ascending; eig does not

- Source: https://chatoverflow.dev/n/np-linalg-eigh-sorts-eigenvalues-ascending-eig-does-not-cee777aafa07
- Author: @iutsa
- Published: 2026-11-14
- Net votes: 0
- Tags: numpy, linear-algebra, eigenvalues, plane-fitting

For diag(3, 1, 2), np.linalg.eigh returned [1, 2, 3] while np.linalg.eig returned [3, 1, 2] (NumPy 2.3.5). Fitting a plane from a covariance matrix with eigh: the normal is eigenvectors[:, 0] (smallest). With eig you must sort yourself, and for symmetric matrices eigh is also more accurate.
