# Solving a large sparse ODE using Exponential methods

**URL:** https://discourse.julialang.org/t/solving-a-large-sparse-ode-using-exponential-methods/125159
**Category:** Numerics
**Tags:** ode, differentialequation
**Created:** [January 24, 2025, 11:10am UTC](https://discourse.julialang.org/t/solving-a-large-sparse-ode-using-exponential-methods/125159 "2025-01-24T11:10:04Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![albertomercurio](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/albertomercurio/32/27051_2.png) [@albertomercurio](https://discourse.julialang.org/u/albertomercurio)
#### Post date: [January 24, 2025, 11:10am UTC](https://discourse.julialang.org/t/solving-a-large-sparse-ode-using-exponential-methods/125159/1 "2025-01-24T11:10:04Z")

</div>

Hello,

I need to integrate a differential equation of the form

\dot{u} = L(t) u \, ,

where u is a vector,

L(t) = L\_0 + c(t) \* L\_1 \, ,

L\_0 and L\_1 large sparse matrices, and c(t) a time dependent coefficient.

I know I can use the Runge Kutta solvers inside DifferentialEquations.jl, or their derivatives like Tsit5 or Vern7.

I recently knew about a method that first expands e^{x} into a truncated series, then express it into the product of x-z\_i (where z\_i are the roots of the polynomial. Then the time evolution evolves according to the product of 1 - dt / z\_i \* L(t + t + dt) where L(t, t + dt) is the Magnus expansion of it. Are there similar methods within DifferentialEquations.jl? Would I see some advantages with respect to `Tsit5` or `Vern7` for example?

My current implementation involves SciMLOperator.jl, where I construct similar to

```julia
L = MatrixOperator(L_0) + ScalarOperator(0, update_func=my_func) * MatrixOperator(L_1)

```

and I efficiently use it with non-exponential methods like `Tsit5` and similars.

Do the state-independent solvers [expressed here](https://docs.sciml.ai/DiffEqDocs/stable/solvers/nonautonomous_linear_ode/#State-Independent-Solvers) support SciMLOperators.jl? I see that they use `DiffEqArrayOperator` instead.

Moreover, I see there are many solvers that might be the case, like the ones [here](https://docs.sciml.ai/DiffEqDocs/stable/solvers/ode_solve/#exp_RK) and [here](https://docs.sciml.ai/DiffEqDocs/stable/solvers/ode_solve/#Exponential-Propagation-Iterative-Runge-Kutta-Methods-(EPIRK)). Can I use them form my case?

---

<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: [January 25, 2025, 10:29am UTC](https://discourse.julialang.org/t/solving-a-large-sparse-ode-using-exponential-methods/125159/2 "2025-01-25T10:29:26Z")

</div>

> [@albertomercurio](#):
>
> I recently knew about a method that first expands e^{x}exe^{x} into a truncated series, then express it into the product of x-z\_ix−zix-z\_i (where z\_iziz\_i are the roots of the polynomial. Then the time evolution evolves according to the product of 1 - dt / z\_i \* L(t + t + dt)1−dt/zi∗L(t+t+dt)1 - dt / z\_i \* L(t + t + dt) where L(t, t + dt)L(t,t+dt)L(t, t + dt) is the Magnus expansion of it. Are there similar methods within [DifferentialEquations.jl](https://juliaregistries.github.io/General/packages/redirect_to_repo/DifferentialEquations)?

> **[Non-autonomous Linear ODE / Lie Group Problems · DifferentialEquations.jl](https://docs.sciml.ai/DiffEqDocs/stable/types/nonautonomous_linear_ode/)**
>
> Documentation for DifferentialEquations.jl.

Note these kinds of things are generally only better if there are manifold constraints you’re trying to impose.

> [@albertomercurio](#):
>
> Do the state-independent solvers [expressed here](https://docs.sciml.ai/DiffEqDocs/stable/solvers/nonautonomous_linear_ode/#State-Independent-Solvers) support [SciMLOperators.jl](https://juliaregistries.github.io/General/packages/redirect_to_repo/SciMLOperators)? I see that they use `DiffEqArrayOperator` instead.

Yes

---

<div class="post-metadata">

### Author: ![albertomercurio](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/albertomercurio/32/27051_2.png) [@albertomercurio](https://discourse.julialang.org/u/albertomercurio)
#### Post date: [January 25, 2025, 10:08pm UTC](https://discourse.julialang.org/t/solving-a-large-sparse-ode-using-exponential-methods/125159/3 "2025-01-25T22:08:37Z")

</div>

> [@ChrisRackauckas](#):
>
> Note these kinds of things are generally only better if there are manifold constraints you’re trying to impose.

Could you explain it better?

Also is there some documentation for the solvers [here](https://docs.sciml.ai/DiffEqDocs/stable/solvers/ode_solve/#exp_RK) and [here](https://docs.sciml.ai/DiffEqDocs/stable/solvers/ode_solve/#Exponential-Propagation-Iterative-Runge-Kutta-Methods-(EPIRK))? Some of them seem very interesting to my case, if not exactly the thing I want. But I don’t have so much information about these algorithms.

---

<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: [January 26, 2025, 11:08am UTC](https://discourse.julialang.org/t/solving-a-large-sparse-ode-using-exponential-methods/125159/4 "2025-01-26T11:08:42Z")

</div>

At least at this time, these methods are not faster than the normal methods in most cases. It’s only if you really need the manifold constraint guaranteed (for example, positivity) that these methods give a property that the other methods don’t. At least, that’s with the current state of the methods, the current state of ExponentialUtilities.jl, etc. Maybe some benchmarks will change in their future if we keep improving the exponential tooling.

---

<div class="post-metadata">

### Author: ![liuyxpp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/liuyxpp/32/9870_2.png) [@liuyxpp](https://discourse.julialang.org/u/liuyxpp)
#### Post date: [January 30, 2025, 3:00am UTC](https://discourse.julialang.org/t/solving-a-large-sparse-ode-using-exponential-methods/125159/5 "2025-01-30T03:00:04Z")

</div>

Can you provide any references or benchmark results for this conclusion that ETDRK4 is slower than Tsit5 and Vern7 in most cases?

---

<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 30, 2025, 3:56am UTC](https://discourse.julialang.org/t/solving-a-large-sparse-ode-using-exponential-methods/125159/6 "2025-01-30T03:56:36Z")

</div>

I think we have comparisons in SciMLBenchmarks

---

<div class="post-metadata">

### Author: ![photor](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/photor/32/14343_2.png) [@photor](https://discourse.julialang.org/u/photor)
#### Post date: [January 30, 2025, 4:38am UTC](https://discourse.julialang.org/t/solving-a-large-sparse-ode-using-exponential-methods/125159/7 "2025-01-30T04:38:22Z")

</div>

> [@Oscar\_Smith](#):
>
> SciMLBenchmarks

I browsed around the website, but couldn’t find the relevant result about the comparison between the exponential methods and the other methods. Could you provide the exact web page links? Thanks a lot.

---

<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 30, 2025, 4:47am UTC](https://discourse.julialang.org/t/solving-a-large-sparse-ode-using-exponential-methods/125159/8 "2025-01-30T04:47:52Z")

</div>

it actually looks like we’re missing those benchmarks. Time to add a new section…

---

<div class="post-metadata">

### Author: ![albertomercurio](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/albertomercurio/32/27051_2.png) [@albertomercurio](https://discourse.julialang.org/u/albertomercurio)
#### Post date: [June 25, 2025, 7:49pm UTC](https://discourse.julialang.org/t/solving-a-large-sparse-ode-using-exponential-methods/125159/9 "2025-06-25T19:49:29Z")

</div>

Hi @Oscar_Smith, do you have any updates on the benchmark comparison between these methods? For example using a sparse ODE as in my first example.
