# Exponential of simple block triangular matrix

**URL:** <https://discourse.julialang.org/t/exponential-of-simple-block-triangular-matrix/117365>\
**Category:** Numerics\
**Tags:** question, linearalgebra\
**Created:** [July 22, 2024, 9:24pm UTC](https://discourse.julialang.org/t/exponential-of-simple-block-triangular-matrix/117365 "2024-07-22T21:24:15Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![goerz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/goerz/32/3269_2.png) [@goerz](https://discourse.julialang.org/u/goerz)\
**Post date:** [July 22, 2024, 9:24pm UTC](https://discourse.julialang.org/t/exponential-of-simple-block-triangular-matrix/117365/1 "2024-07-22T21:24:15Z")

</div>

I have a custom struct that represents a block-matrix of the form

```julia
X = [
    A B
    0 A 
]

```

Where `A` and `B` are arbitrary (probably non-pathological) square matrices. `A` and `B` are small in the context I’m currently looking at. They’d be stored as `StaticArrays.SMatrix` instances, as properties of my struct.

I’m looking to implement a method for `exp` for my struct. The exponential is going to have the same block structure as the original `X`, with

```julia
exp(X) = [
    exp(A) F
       0 exp(A)
]

```

where the matrix `F` is a little less trivial. I found [some notes about the mathematical background](https://dieci.math.gatech.edu/preps/DiPa-CondExp.pdf), which also discusses solutions.

Does anyone who is less rusty than me on their linear algebra have any recommendations for how to most easily (but efficiently) get `F`? Is there any package I should be aware of that helps with this? Again, `A` and `B` are small, so I’m not looking for anything Krylov-based. I was thinking maybe I should adapt [`padm` from `Expokit`](https://github.com/acroy/Expokit.jl/blob/master/src/padm.jl). Is there something easier or better?

---

<div class="post-metadata">

**Author:** ![juthohaegeman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juthohaegeman/32/8620_2.png) [@juthohaegeman](https://discourse.julialang.org/u/juthohaegeman)\
**Post date:** [July 23, 2024, 12:33am UTC](https://discourse.julialang.org/t/exponential-of-simple-block-triangular-matrix/117365/2 "2024-07-23T00:33:07Z")

</div>

I at some point worked out what you get from applying the Base.exp implementation (using Pade approximation) to the upper triangular block matrix case, so as to explicitly get the nonzero blocks of the exponential; the result is in the attachment.  
[exp.jl](https://discourse.julialang.org/uploads/short-url/d4RGojLD5B3lclsMjCqPoUJkUU3.jl) (13.5 KB)
