# Matrix factorization with Symbolics.jl

**URL:** <https://discourse.julialang.org/t/matrix-factorization-with-symbolics-jl/68266>\
**Category:** General Usage\
**Tags:** symbolics\
**Created:** [September 16, 2021, 2:51pm UTC](https://discourse.julialang.org/t/matrix-factorization-with-symbolics-jl/68266 "2021-09-16T14:51:26Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jamblejoe](https://avatars.discourse-cdn.com/v4/letter/j/ee7513/32.png) [@jamblejoe](https://discourse.julialang.org/u/jamblejoe)\
**Post date:** [September 16, 2021, 2:51pm UTC](https://discourse.julialang.org/t/matrix-factorization-with-symbolics-jl/68266/1 "2021-09-16T14:51:26Z")

</div>

I want to factorize a small matrix of integers symbolically with Symbols.jl. For examble

```julia
A = [0 1; 1 0]

```

How do I get symbolically the spectral decomposition? I could not find a way to specify a symbolic `1` with Symbolics.jl. In SymPy one would do `Sym(1)`.

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [September 16, 2021, 3:45pm UTC](https://discourse.julialang.org/t/matrix-factorization-with-symbolics-jl/68266/2 "2021-09-16T15:45:58Z")

</div>

if all of the values are numbers then how is it symbolic?

---

<div class="post-metadata">

**Author:** ![jamblejoe](https://avatars.discourse-cdn.com/v4/letter/j/ee7513/32.png) [@jamblejoe](https://discourse.julialang.org/u/jamblejoe)\
**Post date:** [September 16, 2021, 6:17pm UTC](https://discourse.julialang.org/t/matrix-factorization-with-symbolics-jl/68266/3 "2021-09-16T18:17:05Z")

</div>

`1` is a symbol as well. My goal is to get an expression in terms of fractions/square roots/etc. For example compare

```julia
eigvals(Sym[0 0 1 0; 1 0 0 1; 0 1 0 0; 0 0 1 0])

```

resulting in  
 ![image](https://global.discourse-cdn.com/julialang/original/3X/3/0/3032c3d15bcfd5b4303cfd99635557a2750af5ad.png)

to

```julia
eigvals([0 0 1 0; 1 0 0 1; 0 1 0 0; 0 0 1 0])

4-element Vector{ComplexF64}:
    -0.6299605249474369 - 1.091123635971722im
    -0.6299605249474369 + 1.091123635971722im
 1.6032453817751706e-48 + 0.0im
      1.259921049894875 + 0.0im

```

I cannot come up with the expression in square roots and fractions from the digit output of the non-symbolic result. I can understand the SymPy output immediately though. The eigenvalues are 0 and roots of unity scaled by `2^(1/3)`.

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [September 16, 2021, 7:51pm UTC](https://discourse.julialang.org/t/matrix-factorization-with-symbolics-jl/68266/4 "2021-09-16T19:51:56Z")

</div>

Worth filing an issue.
