companion_matrix, a Fortran90 code which computes the companion matrix for a polynomial. The polynomial may be represented in the standard monomial basis, or as a sum of Chebyshev, Gegenbauer, Hermite, Laguerre, or Lagrange basis polynomials. All the roots of the polynomial can be determined as the eigenvalues of the corresponding companion matrix.

The Fortran90 test code must compute eigenvalues and polynomial roots. To do so, it relies on help from the eigs() function, which in turn calls the lapack() library, and the r8poly_roots() function, which calls the toms493() library.


The information on this web page is distributed under the MIT license.


companion_matrix is available in a Fortran77 version and a Fortran90 version and a MATLAB version and an Octave version and a Python version.

Related Data and Programs:


chebyshev_polynomial, a Fortran90 code which considers the Chebyshev polynomials T(i,x), U(i,x), V(i,x) and W(i,x). Functions are provided to evaluate the polynomials, determine their zeros, produce their polynomial coefficients, produce related quadrature rules, project other functions onto these polynomial bases, and integrate double and triple products of the polynomials.

eigs, a Fortran90 code which computes the eigenvalues and eigenvectors of a matrix.

gegenbauer_polynomial, a Fortran90 code which evaluates the Gegenbauer polynomial and associated functions.

hermite_polynomial, a Fortran90 code which evaluates the physicist's Hermite polynomial, the probabilist's Hermite polynomial, the Hermite function, and related functions.

laguerre_polynomial, a Fortran90 code which evaluates the Laguerre polynomial, the generalized Laguerre polynomial, and the Laguerre function.

lapack_test, a Fortran90 code which calls lapack(), which is a standard linear algebra package for solving linear systems, computing matrix factorizations, and solving eigenvalue problems.

legendre_polynomial, a Fortran90 code which evaluates the Legendre polynomial and associated functions.

polynomial_conversion, a Fortran90 code which converts representations of a polynomial between monomial, Bernstein, Chebyshev, Hermite, Laguerre and Legendre forms.

test_matrix, a Fortran90 code which defines test matrices for which the condition number, determinant, eigenvalues, eigenvectors, inverse, null vectors, P*L*U factorization or linear system solution are known. Examples include the Fibonacci, Hilbert, Redheffer, Vandermonde, Wathen and Wilkinson matrices.


Source Code:

Last revised on 08 June 2024.