## Eigenvalues

The symbolic eigenvalues of a square matrix `A`

or
the symbolic eigenvalues and eigenvectors of `A`

are
computed, respectively, using the commands `E = eig(A)`

and ```
[V,E]
= eig(A)
```

.

The variable-precision counterparts are `E = eig(vpa(A))`

and ```
[V,E]
= eig(vpa(A))
```

.

The eigenvalues of `A`

are the zeros of the
characteristic polynomial of `A`

, `det(A-x*I)`

,
which is computed by `charpoly(A)`

.

The matrix `H`

from the last section provides
the first example:

H = sym([8/9 1/2 1/3; 1/2 1/3 1/4; 1/3 1/4 1/5])

H = [ 8/9, 1/2, 1/3] [ 1/2, 1/3, 1/4] [ 1/3, 1/4, 1/5]

The matrix is singular, so one of its eigenvalues must be zero. The statement

[T,E] = eig(H)

produces the matrices `T`

and `E`

.
The columns of `T`

are the eigenvectors of `H`

and
the diagonal elements of `E`

are the eigenvalues
of `H`

:

T = [ 3/10, 218/285 - (4*12589^(1/2))/285, (4*12589^(1/2))/285 + 218/285] [ -6/5, 292/285 - 12589^(1/2)/285, 12589^(1/2)/285 + 292/285] [ 1, 1, 1] E = [ 0, 0, 0] [ 0, 32/45 - 12589^(1/2)/180, 0] [ 0, 0, 12589^(1/2)/180 + 32/45]

It may be easier to understand the structure of the matrices
of eigenvectors, `T`

, and eigenvalues, `E`

,
if you convert `T`

and `E`

to decimal
notation. To do so, proceed as follows. The commands

Td = double(T) Ed = double(E)

return

Td = 0.3000 -0.8098 2.3397 -1.2000 0.6309 1.4182 1.0000 1.0000 1.0000 Ed = 0 0 0 0 0.0878 0 0 0 1.3344

The first eigenvalue is zero. The corresponding eigenvector
(the first column of `Td`

) is the same as the basis
for the null space found in the last section. The other two eigenvalues
are the result of applying the quadratic formula to $${x}^{2}-\frac{64}{45}x+\frac{253}{2160}$$ which is the quadratic factor
in `factor(charpoly(H, x))`

:

syms x g = factor(charpoly(H, x))/x solve(g(3))

g = [ 1/(2160*x), 1, (2160*x^2 - 3072*x + 253)/x] ans = 32/45 - 12589^(1/2)/180 12589^(1/2)/180 + 32/45

Closed form symbolic expressions for the eigenvalues are possible only when the characteristic polynomial can be expressed as a product of rational polynomials of degree four or less. The Rosser matrix is a classic numerical analysis test matrix that illustrates this requirement. The statement

R = sym(rosser)

generates

R = [ 611, 196, -192, 407, -8, -52, -49, 29] [ 196, 899, 113, -192, -71, -43, -8, -44] [ -192, 113, 899, 196, 61, 49, 8, 52] [ 407, -192, 196, 611, 8, 44, 59, -23] [ -8, -71, 61, 8, 411, -599, 208, 208] [ -52, -43, 49, 44, -599, 411, 208, 208] [ -49, -8, 8, 59, 208, 208, 99, -911] [ 29, -44, 52, -23, 208, 208, -911, 99]

The commands

p = charpoly(R, x); factor(p)

produce

ans = [ x, x - 1020, x^2 - 1040500, x^2 - 1020*x + 100, x - 1000, x - 1000]

The characteristic polynomial (of degree 8) factors nicely into the product of two linear terms and three quadratic terms. You can see immediately that four of the eigenvalues are 0, 1020, and a double root at 1000. The other four roots are obtained from the remaining quadratics. Use

eig(R)

to find all these values

ans = 0 1000 1000 1020 510 - 100*26^(1/2) 100*26^(1/2) + 510 -10*10405^(1/2) 10*10405^(1/2)

The Rosser matrix is not a typical example; it is rare for a
full 8-by-8 matrix to have a characteristic polynomial that factors
into such simple form. If you change the two “corner”
elements of `R`

from 29 to 30 with the commands

S = R; S(1,8) = 30; S(8,1) = 30;

and then try

p = charpoly(S, x)

you find

p = x^8 - 4040*x^7 + 5079941*x^6 + 82706090*x^5... - 5327831918568*x^4 + 4287832912719760*x^3... - 1082699388411166000*x^2 + 51264008540948000*x... + 40250968213600000

You also find that `factor(p)`

is `p`

itself.
That is, the characteristic polynomial cannot be factored over the
rationals.

For this modified Rosser matrix

F = eig(S)

returns

F = -1020.053214255892 -0.17053529728769 0.2180398054830161 999.9469178604428 1000.120698293384 1019.524355263202 1019.993550129163 1020.420188201505

Notice that these values are close to the eigenvalues of the original Rosser matrix.

It is also possible to try to compute eigenvalues of symbolic matrices, but closed form solutions are rare. The Givens transformation is generated as the matrix exponential of the elementary matrix

$$A=\left[\begin{array}{cc}0& 1\\ -1& 0\end{array}\right].$$

Symbolic Math Toolbox™ commands

syms t A = sym([0 1; -1 0]); G = expm(t*A)

return

G = [ exp(-t*1i)/2 + exp(t*1i)/2, (exp(-t*1i)*1i)/2 - (exp(t*1i)*1i)/2] [ - (exp(-t*1i)*1i)/2 + (exp(t*1i)*1i)/2, exp(-t*1i)/2 + exp(t*1i)/2]

You can simplify this expression using `simplify`

:

G = simplify(G)

G = [ cos(t), sin(t)] [ -sin(t), cos(t)]

Next, the command

g = eig(G)

produces

g = cos(t) - sin(t)*1i cos(t) + sin(t)*1i

You can rewrite `g`

in terms of exponents:

g = rewrite(g, 'exp')

g = exp(-t*1i) exp(t*1i)