# Is there any way to find the eigenvalues of a matrix in terms of a variable?

I have the following matrix

M=

2n-1 & n-1 & n

1 & 2n-3 & 0

1& 0 & 1

Here $n$ is a variable

I want to find its eigenvalues.

Is there any way to find the eigenvalues of this matrix in terms of $n$ in sagemath.

I even cant input a matrix in terms of a variable.

edit retag close merge delete

Sort by ยป oldest newest most voted

Like this:

n = var('n')
M = matrix([[2*n-1, n-1, n],
[1, 2*n-3, 0],
[1, 0, 1]])
M.eigenvalues()


The outcome is a list of three eigenvalues:

[-1/6*((4*n - 3)^2 - 12*n^2 + 18*n)*(-I*sqrt(3) + 1)/((4*n - 3)^3 - 9*(2*n^2 - 3*n)*(4*n - 3) + 27*n^2 + 9*sqrt(1/3)*sqrt(-(16*n^4 - 75*n^3 + 140*n^2 - 126*n + 54)*n) - 81*n + 54)^(1/3) - 1/6*((4*n - 3)^3 - 9*(2*n^2 - 3*n)*(4*n - 3) + 27*n^2 + 9*sqrt(1/3)*sqrt(-(16*n^4 - 75*n^3 + 140*n^2 - 126*n + 54)*n) - 81*n + 54)^(1/3)*(I*sqrt(3) + 1) + 4/3*n - 1,
-1/6*((4*n - 3)^2 - 12*n^2 + 18*n)*(I*sqrt(3) + 1)/((4*n - 3)^3 - 9*(2*n^2 - 3*n)*(4*n - 3) + 27*n^2 + 9*sqrt(1/3)*sqrt(-(16*n^4 - 75*n^3 + 140*n^2 - 126*n + 54)*n) - 81*n + 54)^(1/3) - 1/6*((4*n - 3)^3 - 9*(2*n^2 - 3*n)*(4*n - 3) + 27*n^2 + 9*sqrt(1/3)*sqrt(-(16*n^4 - 75*n^3 + 140*n^2 - 126*n + 54)*n) - 81*n + 54)^(1/3)*(-I*sqrt(3) + 1) + 4/3*n - 1,
4/3*n + 1/3*((4*n - 3)^2 - 12*n^2 + 18*n)/((4*n - 3)^3 - 9*(2*n^2 - 3*n)*(4*n - 3) + 27*n^2 + 9*sqrt(1/3)*sqrt(-(16*n^4 - 75*n^3 + 140*n^2 - 126*n + 54)*n) - 81*n + 54)^(1/3) + 1/3*((4*n - 3)^3 - 9*(2*n^2 - 3*n)*(4*n - 3) + 27*n^2 + 9*sqrt(1/3)*sqrt(-(16*n^4 - 75*n^3 + 140*n^2 - 126*n + 54)*n) - 81*n + 54)^(1/3) - 1]


Let us check that the first element of this list is indeed an eigenvalue of M:

lamb = M.eigenvalues()[0]
det(M - lamb*identity_matrix(SR, 3)).simplify_full()


The outcome is

0

more

From the output it looks that the first two eigenvalues are imaginary , but if you put any particular value of $n$ the eigenvalues are real and hence the result does not match

( 2020-01-12 14:14:51 +0200 )edit

what shall i do?

( 2020-01-12 14:15:53 +0200 )edit

## Stats

Seen: 219 times

Last updated: Jan 10 '20