geigen (version 2.3)

geigen: Generalized Eigenvalues


Computes generalized eigenvalues and eigenvectors of a pair of matrices.


geigen(A, B, symmetric, only.values=FALSE)



left hand side matrix.


right hand side matrix.


if TRUE, both matrices are assumed to be symmetric (or Hermitian if complex) and only their lower triangle (diagonal included) is used. If symmetric is not specified, the matrices are inspected for symmetry.


if TRUE only eigenvalues are computed otherwise both eigenvalues and eigenvctors are returned.


A list containing components


a vector containing the \(n\) generalized eigenvalues.


an \(n\times n\) matrix containing the generalized eigenvectors or NULL if only.values is TRUE.


the numerator of the generalized eigenvalues and may be NULL if not applicable.


the denominator of the generalized eigenvalues and may be NULL if not applicable.


If the argument symmetric is missing, the function will try to determine if the matrices are symmetric with the function isSymmetric from the base package. It is faster to specify the argument.

Both matrices must be square. This function provides the solution to the generalized eigenvalue problem defined by $$A x = \lambda Bx$$ If either one of the matrices is complex the other matrix is coerced to be complex.

If the matrices are symmetric then the matrix B must be positive definite; if it is not an error message will be issued. If the matrix B is known to be symmetric but not positive definite then the argument symmetric should be set to FALSE explicitly.

If the matrix B is not positive definite when it should be an error message of the form

Leading minor of order ... of B is not positive definite

will be issued. In that case set the argument symmetric to FALSE if not set and try again.

For general matrices the generalized eigenvalues \(\lambda\) are calculated as the ratio \(\alpha / \beta\) where \(\beta\) may be zero or very small leading to non finite or very large values for the eigenvalues. Therefore the values for \(\alpha\) and \(\beta\) are also included in the return value of the function. When both matrices are complex (or coerced to be so) the generalized eigenvalues, \(\alpha\) and \(\beta\) are complex. When both matrices are numeric \(\alpha\) may be numeric or complex and \(\beta\) is numeric.

When both matrices are symmetric (or Hermitian) the generalized eigenvalues are numeric and no components \(\alpha\) and \(\beta\) are available.


Anderson. E. and ten others (1999) LAPACK Users' Guide. Third Edition. SIAM. Available on-line at See the section Generalized Eigenvalue and Singular Value Problems (

See Also



Run this code
A <- matrix(c(14, 10, 12,
              10, 12, 13,
              12, 13, 14), nrow=3, byrow=TRUE)

B <- matrix(c(48, 17, 26,
              17, 33, 32,
              26, 32, 34), nrow=3, byrow=TRUE)

z1 <- geigen(A, B, symmetric=FALSE, only.values=TRUE)
z2 <- geigen(A, B, symmetric=FALSE, only.values=FALSE )

# geigen(A, B)
z1 <- geigen(A, B, only.values=TRUE)
z2 <- geigen(A, B, only.values=FALSE)

A.c <- A + 1i
B.c <- B + 1i

A[upper.tri(A)] <- A[upper.tri(A)] + 1i
A[lower.tri(A)] <- Conj(t(A[upper.tri(A)]))

B[upper.tri(B)] <- B[upper.tri(B)] + 1i
B[lower.tri(B)] <- Conj(t(B[upper.tri(B)]))


z1 <- geigen(A, B, only.values=TRUE)
z2 <- geigen(A, B, only.values=FALSE)
# }

Run the code above in your browser using DataCamp Workspace