# Fastest way to calculate eigenvectors of 4x4 matrix

**URL:** <https://discourse.julialang.org/t/fastest-way-to-calculate-eigenvectors-of-4x4-matrix/125174>\
**Category:** Specific Domains\
**Tags:** linearalgebra, numerics\
**Created:** [January 24, 2025, 4:43pm UTC](https://discourse.julialang.org/t/fastest-way-to-calculate-eigenvectors-of-4x4-matrix/125174 "2025-01-24T16:43:00Z")\
**Posts on this page:** 2\
**Page:** 2

<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:** [January 26, 2025, 5:45pm UTC](https://discourse.julialang.org/t/fastest-way-to-calculate-eigenvectors-of-4x4-matrix/125174/22 "2025-01-26T17:45:21Z")

</div>

> [@Xu\_Shan](#):
>
> the states simulated by this ODE is affected and affect other states from other sub-models…(so-called “interacted”);

Big coupled systems are nothing new. Sounds like you may have a differential-algebraic equation (DAE)? There are solvers for this too.

Using a coupled solver, e.g. a DAE solver, lets you focus on formulating the continuous-time equations, and let the solver handle discretizing into time steps (often at high order accuracy, often with adaptive sizes).

---

<div class="post-metadata">

**Author:** ![Xu\_Shan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/xu_shan/32/214900_2.png) [@Xu\_Shan](https://discourse.julialang.org/u/Xu_Shan)\
**Post date:** [July 13, 2025, 2:06pm UTC](https://discourse.julialang.org/t/fastest-way-to-calculate-eigenvectors-of-4x4-matrix/125174/23 "2025-07-13T14:06:05Z")

</div>

Hi @Mason, thanks for your solution! But in latest Julia, I found `expv` has similar performance compared to `exp`…not sure whether I got the correct way to use it…but if I ran this:

```julia
using ExponentialUtilities
using BenchmarkTools
using StaticArrays

A = rand(4, 4)
As = SMatrix{4, 4}(A)
v = rand(4)
vs = SVector{4}(v)
           
t = 1e-3

# calculate exp(t * A) * v
@btime expv($t, $A, $v)     
@btime expv($t, $As, $vs)
@btime exp($t*$As)*$vs

```

I got

```julia
  2.989 μs (27 allocations: 2.22 KiB)
4-element Vector{Float64}:
 0.6843916614773726
 0.6584018736208126
 0.9509576202197598
 0.6793439922385884

  213.225 ns (0 allocations: 0 bytes)
4-element SVector{4, Float64} with indices SOneTo(4):
 0.6843916614773728
 0.6584018736208129
 0.9509576202197598
 0.6793439922385885

  213.211 ns (0 allocations: 0 bytes)
4-element SVector{4, Float64} with indices SOneTo(4):
 0.6843916614773728
 0.6584018736208129
 0.9509576202197598
 0.6793439922385885

```

Is that normal (compared the second and third ones)? I am using Julia with the version of `1.11.5`

[Previous page](https://discourse.julialang.org/t/fastest-way-to-calculate-eigenvectors-of-4x4-matrix/125174.md?page=1)
