# Is there a way to calculate eigenvalues for symbolic matrices?

**URL:** <https://discourse.julialang.org/t/is-there-a-way-to-calculate-eigenvalues-for-symbolic-matrices/110818>\
**Category:** Statistics\
**Tags:** question, symbolic, sympy\
**Created:** [February 27, 2024, 3:30am UTC](https://discourse.julialang.org/t/is-there-a-way-to-calculate-eigenvalues-for-symbolic-matrices/110818 "2024-02-27T03:30:19Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![swsw](https://avatars.discourse-cdn.com/v4/letter/s/c77e96/32.png) [@swsw](https://discourse.julialang.org/u/swsw)\
**Post date:** [February 27, 2024, 3:30am UTC](https://discourse.julialang.org/t/is-there-a-way-to-calculate-eigenvalues-for-symbolic-matrices/110818/1 "2024-02-27T03:30:19Z")

</div>

I’d like to calculate the eigenvalues for the matrix like

> [1 1; x x]

in julia. is there a way to do it? I tried the following but didn’t work.

> using SymPy
> 
> @syms x  
> A = [1 1; x x]
> 
> eigen(A)

---

<div class="post-metadata">

**Author:** ![jishnub](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jishnub/32/33620_2.png) [@jishnub](https://discourse.julialang.org/u/jishnub)\
**Post date:** [February 27, 2024, 7:25am UTC](https://discourse.julialang.org/t/is-there-a-way-to-calculate-eigenvalues-for-symbolic-matrices/110818/2 "2024-02-27T07:25:27Z")

</div>

You may use

```julia
julia> using GenericLinearAlgebra

julia> GenericLinearAlgebra.eigvals(A)
2-element Vector{Sym{PyCall.PyObject}}:
     0
 x + 1

```

`eigen` isn’t available, though.

---

<div class="post-metadata">

**Author:** ![swsw](https://avatars.discourse-cdn.com/v4/letter/s/c77e96/32.png) [@swsw](https://discourse.julialang.org/u/swsw)\
**Post date:** [February 27, 2024, 8:06am UTC](https://discourse.julialang.org/t/is-there-a-way-to-calculate-eigenvalues-for-symbolic-matrices/110818/3 "2024-02-27T08:06:15Z")

</div>

thank you so much! Can i further ask what about eigen vectors?

---

<div class="post-metadata">

**Author:** ![jishnub](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jishnub/32/33620_2.png) [@jishnub](https://discourse.julialang.org/u/jishnub)\
**Post date:** [February 27, 2024, 8:18am UTC](https://discourse.julialang.org/t/is-there-a-way-to-calculate-eigenvalues-for-symbolic-matrices/110818/4 "2024-02-27T08:18:41Z")

</div>

I don’t think it’s implemented yet

---

<div class="post-metadata">

**Author:** ![j\_verzani](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/j_verzani/32/8551_2.png) [@j\_verzani](https://discourse.julialang.org/u/j_verzani)\
**Post date:** [March 8, 2024, 8:40pm UTC](https://discourse.julialang.org/t/is-there-a-way-to-calculate-eigenvalues-for-symbolic-matrices/110818/5 "2024-03-08T20:40:50Z")

</div>

This doesn’t cover all the bases, but perhaps what is being asked for:

```julia
using LinearAlgebra
function LinearAlgebra.eigen(A::AbstractMatrix{T}) where {T <: Sym}
    LinearAlgebra.Eigen(eigvals(A), eigvecs(A))
end
@syms x
eigen([1 1; x x])

```

---

<div class="post-metadata">

**Author:** ![swsw](https://avatars.discourse-cdn.com/v4/letter/s/c77e96/32.png) [@swsw](https://discourse.julialang.org/u/swsw)\
**Post date:** [March 21, 2024, 2:43am UTC](https://discourse.julialang.org/t/is-there-a-way-to-calculate-eigenvalues-for-symbolic-matrices/110818/7 "2024-03-21T02:43:15Z")

</div>

this is so helpful! thank you! works well!
