# Diffeq.jl problem terminology

**URL:** <https://discourse.julialang.org/t/diffeq-jl-problem-terminology/46024>\
**Category:** Modelling & Simulations\
**Tags:** diffeq\
**Created:** [September 3, 2020, 8:07pm UTC](https://discourse.julialang.org/t/diffeq-jl-problem-terminology/46024 "2020-09-03T20:07:06Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![pkairys](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pkairys/32/2495_2.png) [@pkairys](https://discourse.julialang.org/u/pkairys)\
**Post date:** [September 3, 2020, 8:07pm UTC](https://discourse.julialang.org/t/diffeq-jl-problem-terminology/46024/1 "2020-09-03T20:07:07Z")

</div>

I’m trying to clarify a bit of terminology that is popping up in the DifferentialEquations.jl documentation relating to the “problem size” and “large systems.”

I have a linear matrix differential equation like \partial\_t \vec{u}(t) = \hat{A}(t)\vec{u}(t) where dim(\hat{A}(t))= Nd \times Nd and dim(\vec{u}(t))=Nd \times d and both are filled with ComplexF64 types. In the context of DifferentialEquations.jl do I have Nd \times d ODEs or 1? Because I’m trying to determine a good class of algorithms to use when I need high accuracy \varepsilon\<10^{-9} for a system like above where N\approx \mathcal{O}(10^2) and d \approx \mathcal{O}(10^2).

My impression would be that I really have Nd \times d \approx \mathcal{O}(10^6) ODEs even though I am specifying the system in a linear algebraic form. Is this correct?

Also it turns out that \hat{A}(t) is particularly sparse, I am currently using an the DiffeqOperator method to define the system with a sparse array. How can I accelerate this implementation? Should I be using a more sophisticated array type. I’m currently letting DIfferentialEquations.jl choose the algorithm.

---

<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:** [September 5, 2020, 8:06am UTC](https://discourse.julialang.org/t/diffeq-jl-problem-terminology/46024/2 "2020-09-05T08:06:38Z")

</div>

> [@pkairys](#):
>
> My impression would be that I really have Nd×d≈O(106)Nd \times d \approx \mathcal{O}(10^6) ODEs even though I am specifying the system in a linear algebraic form. Is this correct?

Yes

> [@pkairys](#):
>
> Also it turns out that ^A(t)\hat{A}(t) is particularly sparse, I am currently using an the DiffeqOperator method to define the system with a sparse array. How can I accelerate this implementation? Should I be using a more sophisticated array type. I’m currently letting DIfferentialEquations.jl choose the algorithm.

I don’t think I have adequately benchmarked this area enough, but my guess is that you will want to specialize on this structure. You can define your function as a DiffEqOperator with a sparse array and use a Magnus integrator

[https://diffeq.sciml.ai/stable/solvers/nonautonomous\_linear\_ode/#State-Independent-Solvers](https://diffeq.sciml.ai/stable/solvers/nonautonomous_linear_ode/#State-Independent-Solvers)

which is specifically for `u' = A(t)u` types of problems. You’re going to want to specify it directly since these are pretty new and haven’t been added to the automatic algorithm handler.

---

<div class="post-metadata">

**Author:** ![pkairys](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pkairys/32/2495_2.png) [@pkairys](https://discourse.julialang.org/u/pkairys)\
**Post date:** [September 8, 2020, 8:06pm UTC](https://discourse.julialang.org/t/diffeq-jl-problem-terminology/46024/3 "2020-09-08T20:06:34Z")

</div>

Thanks Chris. I have played around with the Magnus integrators but I’ve observed that they are slower than the default solver for similar accuracy. (or at least I believe similar accuracy because the Magnus integrators take in an explicit time step that I have estimated to give me similar accuracy as the default solver). Perhaps I haven’t scaled up the problem large enough yet to notice an advantage with the Magnus integrators. I’ll probe it a bit more and try a few of the different Magnus methods.

---

<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:** [September 8, 2020, 8:09pm UTC](https://discourse.julialang.org/t/diffeq-jl-problem-terminology/46024/4 "2020-09-08T20:09:03Z")

</div>

They can be optimized a bit. Right now they allocate more than they need to, but I can fix that up probably over the weekend. How close did you get?
