# 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:** 20\
**Page:** 1

<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:** [January 24, 2025, 4:43pm UTC](https://discourse.julialang.org/t/fastest-way-to-calculate-eigenvectors-of-4x4-matrix/125174/1 "2025-01-24T16:43:00Z")

</div>

Hi guys,

I am trying to run a model which simulates a long time series. For each time step, I need to solve the Eigen values and Eigen vectors for one matrix. This matrix is only 4\*4, but the computation time is important because the huge number of for-loops of the time steps…

The matrix is sparse, it only has values in diagnal and sub-diagonal elements, like below:

 ![Screenshot 2025-01-24 at 17.38.40](https://global.discourse-cdn.com/julialang/original/3X/b/3/b3678f43feb66454e0fd0bdd1fe51b383c17a63d.png)

for now I am using

```julia
e_val = eigvals(A);
e_vec = eigvecs(A);

```

from the `LinearAlgebra`. However, profiling the whole model codes showing that these two lines:

1. creat a lot of allocations…because each time the `eigvals` and `eigvecs` create new arrays;
2. takes a lot of time…

So, is there any way to make it a bit faster, and ZERO allocations? I don’t want to use `eigvals!` to modify it at the original matrix…I could use a preallocated array `prealloc_e_val` for `eigvals`. Typically, what I want is:  
`e_val = eigvals(A, prealloc_e_val)`  
with fastest speed…  
Could you please help me with this? Thanks!

---

<div class="post-metadata">

**Author:** ![Oscar\_Smith](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oscar_smith/32/25343_2.png) [@Oscar\_Smith](https://discourse.julialang.org/u/Oscar_Smith)\
**Post date:** [January 24, 2025, 4:55pm UTC](https://discourse.julialang.org/t/fastest-way-to-calculate-eigenvectors-of-4x4-matrix/125174/2 "2025-01-24T16:55:48Z")

</div>

Have you tried using StaticArrays?

---

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

</div>

not yet…but could you please be more specific? I am quite new to Julia…

---

<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 24, 2025, 7:27pm UTC](https://discourse.julialang.org/t/fastest-way-to-calculate-eigenvectors-of-4x4-matrix/125174/4 "2025-01-24T19:27:45Z")

</div>

> [@Xu\_Shan](#):
>
> For each time step, I need to solve the Eigen values and Eigen vectors for one matrix.

Why? What do you do with these at each timestep? (Maybe there is a way to avoid computing them entirely. And since your matrix is non-symmetric, the whole idea of diagonalizing it is often suspect, e.g. what would you do if the matrix were defective?)

> [@Oscar\_Smith](#):
>
> Have you tried using StaticArrays?

> [@Xu\_Shan](#):
>
> not yet…but could you please be more specific? I am quite new to Julia…

The StaticArrays.jl package has optimized methods for working with small fixed-size vectors and matrices. If you have zillions of 4x4 matrices, they will be _much_ more efficient if represented by the `SMatrix` type from that paper.

However, eigenvectors/values of non-symmetric matrices are not currently supported by StaticArrays.jl.

---

<div class="post-metadata">

**Author:** ![Oscar\_Smith](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oscar_smith/32/25343_2.png) [@Oscar\_Smith](https://discourse.julialang.org/u/Oscar_Smith)\
**Post date:** [January 24, 2025, 7:42pm UTC](https://discourse.julialang.org/t/fastest-way-to-calculate-eigenvectors-of-4x4-matrix/125174/5 "2025-01-24T19:42:19Z")

</div>

Given that this is a Tri-diagonal 4x4 it feels like there should be an analytical solution, is that being too optimistic?

---

<div class="post-metadata">

**Author:** ![Mason](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mason/32/2423_2.png) [@Mason](https://discourse.julialang.org/u/Mason)\
**Post date:** [January 24, 2025, 8:13pm UTC](https://discourse.julialang.org/t/fastest-way-to-calculate-eigenvectors-of-4x4-matrix/125174/6 "2025-01-24T20:13:24Z")

</div>

> [@stevengj](#):
>
> > [@Oscar\_Smith](#):
> >
> > Have you tried using StaticArrays?
> 
> > [@Xu\_Shan](#):
> >
> > not yet…but could you please be more specific? I am quite new to Julia…
> 
> The [StaticArrays.jl](https://juliaregistries.github.io/General/packages/redirect_to_repo/StaticArrays) package has optimized methods for working with small fixed-size vectors and matrices. If you have zillions of 4x4 matrices, they will be _much_ more efficient if represented by the `SMatrix` type from that paper.

Note that StaticArrays.jl does not have any methods for eigenvalues of 4x4 matrices and falls back on allocating and re-wrapping, so it’s actually slightly slower than working with a regular array.

```julia-repl
julia> using StaticArrays

julia> let A = rand(4, 4)
           As = SMatrix{4, 4}(A)
           @btime eigvecs($A)
           @btime eigvecs($As)
       end;
  4.100 μs (30 allocations: 5.81 KiB)
  4.129 μs (32 allocations: 6.02 KiB)

```

---

<div class="post-metadata">

**Author:** ![sgaure](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sgaure/32/14779_2.png) [@sgaure](https://discourse.julialang.org/u/sgaure)\
**Post date:** [January 24, 2025, 8:40pm UTC](https://discourse.julialang.org/t/fastest-way-to-calculate-eigenvectors-of-4x4-matrix/125174/7 "2025-01-24T20:40:52Z")

</div>

> [@Xu\_Shan](#):
>
> So, is there any way to make it a bit faster, and ZERO allocations? I don’t want to use `eigvals!` to modify it at the original matrix…I could use a preallocated array `prealloc_e_val` for `eigvals`. Typically, what I want is:  
> `e_val = eigvals(A, prealloc_e_val)`

I don’t know about zero allocations, but it’s possible to use LAPACK in julia. E.g. `geev!` to find the eigenvalues and the left and right eigenvectors. This might be somewhat faster than calling `eigvals/eigvecs`. For symmetric matrices, there’s a `syev!`. There are still some allocations, though.

```julia
prealloc .= A # make a copy of A, so it's not destroyed
W, VL, VR = LAPACK.geev!('N', 'V', A) # see ?LAPACK.geev!

```

There is also a possibility to call the actual unwrapped LAPACK routines via `@ccall`. Since they don’t allocate, all the workspace must be preallocated. It’s a bit tricky, but absolutely possible. There are quite a few arguments: [LAPACK: dgeev](https://www.netlib.org/lapack/explore-html-3.6.1/d9/d8e/group__double_g_eeigen_ga8ec1625302675b981eb34ed024b27a47.html)

---

<div class="post-metadata">

**Author:** ![sgaure](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sgaure/32/14779_2.png) [@sgaure](https://discourse.julialang.org/u/sgaure)\
**Post date:** [January 24, 2025, 9:25pm UTC](https://discourse.julialang.org/t/fastest-way-to-calculate-eigenvectors-of-4x4-matrix/125174/8 "2025-01-24T21:25:39Z")

</div>

Here’s how to get zero allocations with a direct LAPACK call:

```julia
using LinearAlgebra

const dgeev = let
    preallocA = fill(0.0, 4, 4)
    WR = fill(0.0, 4) # real part of eigval
    WI = fill(0.0, 4) # imag part
    VL = fill(0.0, 4, 4) # left eigvecs
    VR = fill(0.0, 4, 4) # right eigvecs
    LWORK = Int32(64)
    WORK = Vector{Float64}(undef, LWORK)
    INFO = Ref(Int32(0))
    
    function mydgeev(A)
        preallocA .= A
        @ccall "liblapack".dgeev_(
            Ref(Int8('N'))::Ptr{Cchar}, # no left eigvecs
            Ref(Int8('V'))::Ptr{Cchar},
            Ref{Int32}(size(A, 2))::Ptr{Cint},
            preallocA::Ptr{Float64},
            Ref{Int32}(size(A, 1))::Ptr{Cint},
            WR::Ptr{Float64},
            WI::Ptr{Float64},
            VL::Ptr{Float64},
            Ref{Int32}(size(VL, 1))::Ptr{Cint},
            VR::Ptr{Float64},
            Ref{Int32}(size(VR, 1))::Ptr{Cint},
            WORK::Ptr{Float64},
            Ref(LWORK)::Ptr{Cint},
            INFO::Ptr{Cint}
        )::Cvoid
        return WR, WI, VR
    end
end

A = rand(4,4)
dgeev(A)

```

The `@ccall` to `"liblapack".dgeev_` might use a different name on your machine. “liblapack” is the name of the lapack library which is linked into julia, “dgeev\_” with the underscore at the end is a convention for some (most?) fortran compilers. The call arguments are standardized. It’s a bit tricky because lapack is written in/for fortran, where all arguments are passed by reference.

The call to `dgeev(A)` does not allocate. The outputs `(WR, WI, VR)` are overwritten by the next call to `dgeev`. So if you store them in some structure, make sure to copy them.

Complex eigenvectors may come in conjugate pairs. See the docs (linked above) for how they are coded in `VR`.

Note that the `dgeev` above is **not** thread safe. If this is a parallel loop, the preallocated buffers (between `let` and `function mydgeev`) must be task-local, e.g. stored in `Base.task_local_storage()` with a `get!`.

If your matrix is complex, you must call `zgeev_` instead, with different arguments.

---

<div class="post-metadata">

**Author:** ![mstewart](https://avatars.discourse-cdn.com/v4/letter/m/b5a626/32.png) [@mstewart](https://discourse.julialang.org/u/mstewart)\
**Post date:** [January 24, 2025, 10:52pm UTC](https://discourse.julialang.org/t/fastest-way-to-calculate-eigenvectors-of-4x4-matrix/125174/9 "2025-01-24T22:52:23Z")

</div>

I have been hesitating to point it out, because I think the bars over your variables mean your matrix is probably complex and that negative sign in the (4,3) position looks like it could be a deal breaker even if a lot of other things are real and positive, but a real tridiagonal T is diagonally similar to a symmetric tridiagonal if t\_{j, j+1} t\_{j+1, j} \> 0 for each sub/super diagonal pair. Something similar holds for a complex matrix if the diagonal is real and the products of the sub/super diagonals are real and positive. On the off chance that this is the case for your matrix, it does open the possibility of using some simpler algorithms that might be faster.

---

<div class="post-metadata">

**Author:** ![RoyiAvital](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/royiavital/32/571_2.png) [@RoyiAvital](https://discourse.julialang.org/u/RoyiAvital)\
**Post date:** [January 25, 2025, 10:11am UTC](https://discourse.julialang.org/t/fastest-way-to-calculate-eigenvectors-of-4x4-matrix/125174/10 "2025-01-25T10:11:16Z")

</div>

> [@sgaure](#):
>
> I don’t know about zero allocations, but it’s possible to use LAPACK in julia. E.g. `geev!` to find the eigenvalues and the left and right eigenvectors. This might be somewhat faster than calling `eigvals/eigvecs`. For symmetric matrices, there’s a `syev!`. There are still some allocations, though.

Sounds like a feature which should be in [`FastLapackInterface.jl`](https://github.com/DynareJulia/FastLapackInterface.jl) which is a great tool to such cases.

I can see [`geevx!()`](https://dynarejulia.github.io/FastLapackInterface.jl/dev/LAPACK/#LinearAlgebra.LAPACK.geevx!-Tuple%7BEigenWs,%20AbstractChar,%20AbstractChar,%20AbstractChar,%20AbstractChar,%20AbstractMatrix%7D) and [`syevr()!`](https://dynarejulia.github.io/FastLapackInterface.jl/dev/LAPACK/#LinearAlgebra.LAPACK.syevr!-Tuple%7BHermitianEigenWs,%20AbstractChar,%20AbstractChar,%20AbstractChar,%20AbstractMatrix,%20AbstractFloat,%20AbstractFloat,%20Integer,%20Integer,%20AbstractFloat%7D). So maybe all is already there?

---

<div class="post-metadata">

**Author:** ![sgaure](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sgaure/32/14779_2.png) [@sgaure](https://discourse.julialang.org/u/sgaure)\
**Post date:** [January 25, 2025, 12:49pm UTC](https://discourse.julialang.org/t/fastest-way-to-calculate-eigenvectors-of-4x4-matrix/125174/11 "2025-01-25T12:49:05Z")

</div>

You’re right. I wasn’t aware of that package [LAPACK · FastLapackInterface.jl](https://dynarejulia.github.io/FastLapackInterface.jl/dev/LAPACK/#Eigen)  
It seems to do the job with a preallocated workspace.

---

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

</div>

Hi @stevengj, thanks for your reply! For each time step, I need to solve a ODE which is:

 ![Screenshot 2025-01-26 at 13.58.34](https://global.discourse-cdn.com/julialang/original/3X/4/c/4c89dda74884306bc2d8e65d080b68c9b2c58504.png)

I derived the analytical solutions which needs the Eigen values and vectors…(mostly the exp operation of matrix…)

---

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

</div>

Hi @Oscar_Smith, thanks for your idea! Yes I am also thinking about this, but I didn’t find a solution after I googled on the internet…mostly people are talking about symmetric matrix…

---

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

</div>

Hi @mstewart thanks for your points! It does make sense, however, the bar means the average between one item and another…nvd, but the final solution does include complex numbers in Eigen values and vectors, so that the final solution of the ODE always takes the real part…

---

<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, 1:04pm UTC](https://discourse.julialang.org/t/fastest-way-to-calculate-eigenvectors-of-4x4-matrix/125174/15 "2025-01-26T13:04:00Z")

</div>

> [@Xu\_Shan](#):
>
> I derived the analytical solutions which needs the Eigen values and vectors…(mostly the exp operation of matrix…)

You should just use `exp(A * Δt)` for matrix exponentials, not eigenvectors, despite what you may have learned in school.

As explained in the famous paper [“19 Dubious Ways to Compute a the Exponential of a Matrix”](https://www.cs.jhu.edu/~misha/ReadingSeminar/Papers/Moler03.pdf), using eigenvectors is a bad idea to exponentiate non-Hermitian/non-[normal](https://en.wikipedia.org/wiki/Normal_matrix) matrices, because it might be very inaccurate if the matrix happens to be close to defective.

That being said, if you are solving a system of ODEs, then there are probably _much_ better methods available. See DifferentialEquations.jl.

---

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

</div>

Meanwhile, I am also curious to see better solution to solve the ODE in above post…I wrote the analytical solution and hard-coded it. However, the most time consuming comes from the Eigen values and vectors calculation (a simple @profileview shows this…)…so I am wondering is there any other way to avoid the eigen vectors calculation? I tried with numerical package suggested by ChatGPT, however, they are slower than the analytical one…

---

<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, 1:08pm UTC](https://discourse.julialang.org/t/fastest-way-to-calculate-eigenvectors-of-4x4-matrix/125174/17 "2025-01-26T13:08:49Z")

</div>

> [@Xu\_Shan](#):
>
> Meanwhile, I am also curious to see better solution to solve the ODE in above post…

It looks like you are trying to write down the solution for an ODE for just one “timestep”, i.e. for just \Delta t. You should take a step backwards and write down the equations you are actually solving for _all_ t and send _those_ equations to an ODE solver. (A good algorithm will probably not take fixed timestep sizes.)

But it’s hard to give you specific advice without more context. (This is a classic [XY problem](https://en.wikipedia.org/wiki/XY_problem).)

---

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

</div>

yes, it’s true. However, this ODE is interacted in a complex model system which consists of empirical/other analytical equations…it’s a huge model, I don’t think it’s a chance to put the equations for the whole time to an ODE solver…because:

1. the states simulated by this ODE is affected and affect other states from other sub-models…(so-called “interacted”);
2. currently the big model is write for this only one time step…so that there is a for-loop wrap-up thing out side, and people could run it by specifying the range of the time step…

---

<div class="post-metadata">

**Author:** ![Mason](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mason/32/2423_2.png) [@Mason](https://discourse.julialang.org/u/Mason)\
**Post date:** [January 26, 2025, 1:26pm UTC](https://discourse.julialang.org/t/fastest-way-to-calculate-eigenvectors-of-4x4-matrix/125174/20 "2025-01-26T13:26:41Z")

</div>

So you just need to exponentiate the matrix? In that case, StaticArrays.jl is definitely your friend.

```julia-repl
julia> let A = rand(4, 4)
           As = SMatrix{4, 4}(A)
           @btime exp($A)
           @btime exp($As)
       end;
  1.499 μs (18 allocations: 1.58 KiB)
  183.229 ns (0 allocations: 0 bytes)

```

This is way faster than eigensolving.

Also, if what you really want is to calculate `exp(t * A) * v`, then ExponentialUtilities.jl has tools for doing that even more efficiently than calculating the full matrix exponential:

```julia-repl
julia> let 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)
       end;
  1.904 μs (27 allocations: 2.22 KiB)
  146.822 ns (0 allocations: 0 bytes)

```

---

<div class="post-metadata">

**Author:** ![Mason](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mason/32/2423_2.png) [@Mason](https://discourse.julialang.org/u/Mason)\
**Post date:** [January 26, 2025, 4:42pm UTC](https://discourse.julialang.org/t/fastest-way-to-calculate-eigenvectors-of-4x4-matrix/125174/21 "2025-01-26T16:42:18Z")

</div>

> [@Xu\_Shan](#):
>
> yes, it’s true. However, this ODE is interacted in a complex model system which consists of empirical/other analytical equations…it’s a huge model, I don’t think it’s a chance to put the equations for the whole time to an ODE solver…because:
> 
> 1. the states simulated by this ODE is affected and affect other states from other sub-models…(so-called “interacted”);
> 2. currently the big model is write for this only one time step…so that there is a for-loop wrap-up thing out side, and people could run it by specifying the range of the time step…

It’s not clear to me what a lot of this means here, I think the actual problem being solved is still pretty underspecified, but I’ll just mention that DifferentialEquations.jl does support building a differential equation and then `remake`-ing it with different time-spans.

E.g. you could do something like

```julia
using OrdinaryDiffEq, StaticArrays

function f(u, p, t)
    (; a, b, c) = p # p stores parameters a, b, and c
    # build up some potentially time-dependant matrix
    A = SA[a*sin(b*t) b+1
           b-1 c*cos(b*t)]
    A * u
end

# initial condition
u0 = SA[1.0
        0.0]

p = (;a=1.0, b=2.0, c=3.0)

# the timespan we solve over
tspan = (0.0, 1.0)

# construct an ODE problem
prob = ODEProblem(f, u0, tspan, p)

```

and then solve it:

```julia-repl
julia> sol = solve(prob, Tsit5())
retcode: Success
Interpolation: specialized 4th order "free" interpolation
t: 12-element Vector{Float64}:
 0.0
 0.0009990009990009992
 0.010989010989010992
 0.04404476553655739
 0.10104982246948335
 0.17604841169104612
 0.27278951309861316
 0.3924925450833525
 0.5393213697913134
 0.7202827501778557
 0.9573407118994137
 1.0
u: 12-element Vector{SVector{2, Float64}}:
 [1.0, 0.0]
 [1.000002496505656, 0.0010005003304639334]
 [1.0003039254717578, 0.011173253868269296]
 [1.0049882162890587, 0.04715623487012128]
 [1.0273635343800853, 0.11882725033265978]
 [1.088385494639565, 0.23564608045793892]
 [1.2325610793753434, 0.4328632171924387]
 [1.546107921614314, 0.7620787066366294]
 [2.2130677873858833, 1.2954463943225067]
 [3.6169890726518927, 2.0777267620889894]
 [6.617024114295522, 3.043862542508724]
 [7.290497064992269, 3.189883166408041]

```

You can then `remake` this problem to create a new problem that starts where that previous one left off and solve it:

```julia-repl
julia> prob2 = remake(prob; 
                       tspan=(1.0, 1.5),
                       u0 = sol[end])
ODEProblem with uType SVector{2, Float64} and tType Float64. In-place: false
timespan: (1.0, 1.5)
u0: 2-element SVector{2, Float64} with indices SOneTo(2):
 7.290497064992269
 3.189883166408041

julia> sol2 = solve(prob2, Tsit5())
retcode: Success
Interpolation: specialized 4th order "free" interpolation
t: 5-element Vector{Float64}:
 1.0
 1.0858050494318707
 1.2208993653350446
 1.3703727135505457
 1.5
u: 5-element Vector{SVector{2, Float64}}:
 [7.290497064992269, 3.189883166408041]
 [8.742818021206942, 3.454946787443764]
 [11.206831027521389, 3.811693893096692]
 [13.96922356812029, 4.1722693109505045]
 [16.172373463833523, 4.507967667146217]

```

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