# Triangular Schur decomposition for a matrix with complex eigenvalues?

**URL:** <https://discourse.julialang.org/t/triangular-schur-decomposition-for-a-matrix-with-complex-eigenvalues/25680>\
**Category:** Numerics\
**Tags:** question\
**Created:** [June 26, 2019, 7:20am UTC](https://discourse.julialang.org/t/triangular-schur-decomposition-for-a-matrix-with-complex-eigenvalues/25680 "2019-06-26T07:20:42Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![zdenek\_hurak](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/zdenek_hurak/32/53118_2.png) [@zdenek\_hurak](https://discourse.julialang.org/u/zdenek_hurak)\
**Post date:** [June 26, 2019, 7:20am UTC](https://discourse.julialang.org/t/triangular-schur-decomposition-for-a-matrix-with-complex-eigenvalues/25680/1 "2019-06-26T07:20:42Z")

</div>

Is it possible to compute a (strictly) triangular Schur decomposition for a matrix with complex eigenvalues?

With the code below I create such a matrix:

```julia
T = rand(2,2)
λ = rand() + rand()*im
D = [real(λ) imag(λ); -imag(λ) real(λ)]
A = T*D/T

```

`schur` then returns a quasitriangular decomposition. In my case of a 2x2 matrix with complex eigenvalues:

```julia
S,U,Λ = schur(A)

```

```julia
Schur{Float64,Array{Float64,2}}
T factor:
2×2 Array{Float64,2}:
 0.921219 -0.0444826
 4.41202 0.921219 
Z factor:
2×2 Array{Float64,2}:
  0.774798 0.632209
 -0.632209 0.774798
eigenvalues:
2-element Array{Complex{Float64},1}:
 0.9212193623156234 + 0.44301030411320136im
 0.9212193623156234 - 0.44301030411320136im

```

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [June 26, 2019, 12:39pm UTC](https://discourse.julialang.org/t/triangular-schur-decomposition-for-a-matrix-with-complex-eigenvalues/25680/2 "2019-06-26T12:39:46Z")

</div>

> [@zdenek\_hurak](#):
>
> Is it possible to compute a (strictly) triangular Schur decomposition for a matrix with complex eigenvalues?

Yes. Do `schur(complex(A))`.

It would be nice to have a function to get this directly from the quasitriangular decomposition, since that would probably be faster (taking advantage of `A` being real for most of the computation), but I don’t think that is implemented? (Should be very straightforward to implement since you just need the Schur decompositions of a bunch of 2x2 blocks.)

---

<div class="post-metadata">

**Author:** ![zdenek\_hurak](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/zdenek_hurak/32/53118_2.png) [@zdenek\_hurak](https://discourse.julialang.org/u/zdenek_hurak)\
**Post date:** [June 26, 2019, 12:45pm UTC](https://discourse.julialang.org/t/triangular-schur-decomposition-for-a-matrix-with-complex-eigenvalues/25680/3 "2019-06-26T12:45:12Z")

</div>

Many thanks. Exactly what I needed.

---

<div class="post-metadata">

**Author:** ![Ralph\_Smith](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ralph_smith/32/10344_2.png) [@Ralph\_Smith](https://discourse.julialang.org/u/Ralph_Smith)\
**Post date:** [June 26, 2019, 1:52pm UTC](https://discourse.julialang.org/t/triangular-schur-decomposition-for-a-matrix-with-complex-eigenvalues/25680/4 "2019-06-26T13:52:44Z")

</div>

The conversion is implemented as `triangularize` in the `GenericSchur` package.

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [June 26, 2019, 3:02pm UTC](https://discourse.julialang.org/t/triangular-schur-decomposition-for-a-matrix-with-complex-eigenvalues/25680/5 "2019-06-26T15:02:50Z")

</div>

We might want to move that into the `LinearAlgebra` stdlib, because some of the matrix-function calculations in `LinearAlgebra` already need the triangular Schur form and resort to the expensive `schur(complex(A))` method to get it IIRC.

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [April 22, 2021, 6:57pm UTC](https://discourse.julialang.org/t/triangular-schur-decomposition-for-a-matrix-with-complex-eigenvalues/25680/6 "2021-04-22T18:57:16Z")

</div>

> [@stevengj](#):
>
> We might want to move that into the `LinearAlgebra` stdlib

Update: there is a now a PR [https://github.com/JuliaLang/julia/pull/40573](https://github.com/JuliaLang/julia/pull/40573)
