Numerical diagonalization of 3x3 matrices

A common scientific problem is the numerical calculation of the eigensystem of symmetric or hermitian 3x3 matrices. If this calculation has to be performed many times, standard packages like LAPACK, the GNU Scientific Library, and the Numerical Recipes Library may not be the optimal choice because they are optimized mainly for large matrices.

This website offers C and FORTRAN implementations of several algorithms which were specifically optimized for 3x3 problems. All algorithms are discussed in detail in the following paper:

Joachim Kopp
Efficient numerical diagonalization of hermitian 3x3 matrices
Int. J. Mod. Phys. C 19 (2008) 523-548 physics/0610206

Download and Installation

All algorithms are released as C and FORTRAN code. The tarballs contain the respective source code including all dependencies and header files. You have the following download options:

The complete package (including Makefile to generate a shared library)

Algorithm / Version C FORTRAN
Latest versions of all algorithms 3x3-C.tar.gz 3x3-F.tar.gz

Algorithms for real symmetric matrices

Algorithm / Version C FORTRAN
Jacobi dsyevj3-C-1.0.tar.gz dsyevj3-F-1.0.tar.gz
QL with implicit shifts dsyevq3-C-1.0.tar.gz dsyevq3-F-1.0.tar.gz
Cuppen dsyevd3-C-1.0.tar.gz dsyevd3-F-1.0.tar.gz
Cardano (eigenvalues only) dsyevc3-C-1.0.tar.gz dsyevc3-F-1.0.tar.gz
Analytical (Vector Products) dsyevv3-C-1.1.tar.gz dsyevv3-C-1.0.tar.gz dsyevv3-F-1.1.tar.gz dsyevv3-F-1.0.tar.gz
Hybrid dsyevh3-C-1.1.tar.gz
Analytical (2x2 symmetric) dsyev2-C-1.0.tar.gz dsyev2-F-1.0.tar.gz
Householder reduction dsytrd3-C-1.0.tar.gz dsytrd3-F-1.0.tar.gz

Algorithms for complex hermitian matrices

Algorithm / Version C FORTRAN
Jacobi zheevj3-C-1.0.tar.gz zheevj3-F-1.0.tar.gz
QL with implicit shifts zheevq3-C-1.0.tar.gz zheevq3-F-1.0.tar.gz
Cuppen zheevd3-C-1.0.tar.gz zheevd3-F-1.0.tar.gz
Cardano (eigenvalues only) zheevc3-C-1.0.tar.gz zheevc3-F-1.0.tar.gz
Analytical (Vector Products) zheevv3-C-1.0.tar.gz zheevv3-F-1.0.tar.gz
Hybrid zheevh3-C-1.1.tar.gz
Householder reduction zhetrd3-C-1.0.tar.gz zhetrd3-F-1.0.tar.gz

This software cannot be used as a standalone program. Instead, it is intended to be used as a dynamically linked library, or copied directly into your own programs, as is fit for your purposes. Make sure that you also include all required header files and dependencies.

The C code follows the C99 standard, which includes the data type double complex to support complex numbers. For the GNU compiler this requires usage of the option -std=c99.

For optimum performance we recommend switching on all optimizations provided by your compiler. For the GNU compilers, this is done by the option -O3.

Terms of Use

This software is freely available under the terms of the GNU Lesser General Public License (LGPL). However, since it has mainly been developed for academic puposes, the author would appreciate to be given academic credit for it. If you use one of the algorithms to prepare a scientific publication or talk, please cite the reference given above.

Bug reports / Contact

Although this software has been thoroughly tested, we cannot guarantee that it is free of bugs. Therefore, bug reports, comments, and suggestions are always welcome. If you want to contact the author, you can do so under the following email address:

jkopp [at]

Latest changes

12 March 2012

  • Fixed inconsistency in dsyevv3: Even though the documentation says that only the upper triangle of A is accessed, A[1][0] was used in previous versions.
  • Fixed problems in FORTRAN version that led to gfortran errors and warnings: Unnecessary use of DREAL in dsyevh3; unused labels in dsyevh3 and zheevh3.
  • Modified condition for fallback to QL algorithm in dsyevh3, zheevh3, which leads to a small speed-up

October 2006

  • First version (hybrid algorithm came a little later)

Last modified: 12 Mar 2012 04:55:26 CDT