geneigComplex

Computes the generalized eigenexpansion of a system \(Ax = \lambda Bx\), with A and B complex.

Synopsis

geneigComplex (a, b, alpha, beta)

Required Arguments

complex a[[]] (Input)
Array of size n × n containing the coefficient matrix A.
complex b[[]] (Input)
Array of size n × n containing the coefficient matrix B.
complex alpha (Output)
Vector of size n containing scalars \(\alpha_i\). If \(\beta_i \neq 0\), \(\lambda_i = \alpha_i / \beta_i\) for i = 0, …, n − 1 are the eigenvalues of the system.
complex beta (Output)
Vector of size n .

Optional Arguments

vectors (Output)
An array of size n × n containing eigenvectors of the problem. Each vector is normalized to have Euclidean length equal to the value one.

Description

The function geneigComplex uses the QZ algorithm to compute the eigenvalues and eigenvectors of the generalized eigensystem \(Ax = \lambda Bx\), where A and B are complex matrices of order n. The eigenvalues for this problem can be infinite, so α and β are returned instead of λ. If β is nonzero, \(\lambda = \alpha / \beta\).

The first step of the QZ algorithm is to simultaneously reduce A to upper-Hessenberg form and B to upper-triangular form. Then, orthogonal transformations are used to reduce A to quasi-upper­triangular form while keeping B upper triangular. The generalized eigenvalues and eigenvectors for the reduced problem are then computed.

The function geneigComplex is based on the QZ algorithm due to Moler and Stewart (1973).

Examples

Example 1

In this example, the eigenvalue, λ, of system \(Ax = \lambda Bx\) is solved, where

\[\begin{split}A = \begin{bmatrix} 1 & 0.5+i & 5i \\ -10 & 2+i & 0 \\ 5+i & 1 & 0.5+3i \\ \end{bmatrix} \text{ and } B = \begin{bmatrix} 0.5 & 0 & 0 \\ 3+3i & 3+3i & i \\ 4+2i & 0.5+i & 1+i \\ \end{bmatrix}\end{split}\]
from __future__ import print_function
from numpy import *
from pyimsl.math.geneigComplex import geneigComplex
from pyimsl.math.writeMatrixComplex import writeMatrixComplex

a = [[1 + 0j, 0.5 + 1j, 0 + 5j],
     [-10 + 0j, 2 + 1j, 0 + 0j],
     [5 + 1j, 1 + 0j, .5 + 3j]]
b = [[0.5 + 0j, 0 + 0j, 0 + 0j],
     [3 + 3j, 3 + 3j, 0 + 1j],
     [4 + 2j, 0.5 + 1j, 1 + 1j]]
alpha = []
beta = []

# Compute eigenvalues
eval = geneigComplex(a, b, alpha, beta)
eval = zeros(len(alpha), dtype='complex64')
for i in range(0, len(alpha)):
    if (beta[i] != 0.0):
        eval[i] = alpha[i] / beta[i]
    else:
        print("Infinite eigenvalue at: ", i)

# Print eigenvalues
writeMatrixComplex("Eigenvalues", eval)

Output

 
                     Eigenvalues
                        1                          2
(      -8.18,     -25.38)  (       2.18,       0.61)
 
                        3
(       0.12,      -0.39)

Example 2

This example finds the eigenvalues and eigenvectors of the same eigensystem given in the last example.

from __future__ import print_function
from numpy import *
from pyimsl.math.geneigComplex import geneigComplex
from pyimsl.math.writeMatrixComplex import writeMatrixComplex

a = [[1 + 0j, 0.5 + 1j, 0 + 5j],
     [-10 + 0j, 2 + 1j, 0 + 0j],
     [5 + 1j, 1 + 0j, .5 + 3j]]
b = [[0.5 + 0j, 0 + 0j, 0 + 0j],
     [3 + 3j, 3 + 3j, 0 + 1j],
     [4 + 2j, 0.5 + 1j, 1 + 1j]]
alpha = []
beta = []
evec = []

# Compute eigenvalues and eigenvectors
eval = geneigComplex(a, b, alpha, beta, vectors=evec)
eval = zeros(len(alpha), dtype='complex64')
for i in range(0, len(alpha)):
    if (beta[i] != 0.0):
        eval[i] = alpha[i] / beta[i]
    else:
        print("Infinite eigenvalue at: ", i)

# Print eigenvalues and eigenvectors
writeMatrixComplex("Eigenvalues", eval)
writeMatrixComplex("Eigenvectors", evec)

Output

 
                     Eigenvalues
                        1                          2
(      -8.18,     -25.38)  (       2.18,       0.61)
 
                        3
(       0.12,      -0.39)
 
                     Eigenvectors
                           1                          2
1  (    -0.3267,    -0.1245)  (    -0.3007,    -0.2444)
2  (     0.1767,     0.0054)  (     0.8959,     0.0000)
3  (     0.9201,     0.0000)  (    -0.2019,     0.0801)
 
                           3
1  (     0.0371,     0.1518)
2  (     0.9577,     0.0000)
3  (    -0.2215,     0.0968)