# Solving an analytical ODE \*slower\* than numerical?

**URL:** <https://discourse.julialang.org/t/solving-an-analytical-ode-slower-than-numerical/82499>\
**Category:** Modelling & Simulations\
**Tags:** modelingtoolkit\
**Created:** [June 9, 2022, 1:07pm UTC](https://discourse.julialang.org/t/solving-an-analytical-ode-slower-than-numerical/82499 "2022-06-09T13:07:09Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![dodoplus](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dodoplus/32/30148_2.png) [@dodoplus](https://discourse.julialang.org/u/dodoplus)\
**Post date:** [June 9, 2022, 1:07pm UTC](https://discourse.julialang.org/t/solving-an-analytical-ode-slower-than-numerical/82499/1 "2022-06-09T13:07:09Z")

</div>

The documentation ([Composing Ordinary Differential Equations · ModelingToolkit.jl](https://mtk.sciml.ai/stable/tutorials/ode_modeling/)) gives the following example to show symbolic derivatives result in higher performance vs. numerical approximation:

```julia
using BenchmarkTools

@btime solve($prob, Rodas4());
      # 251.300 μs (873 allocations: 31.18 KiB)

```

```julia

prob_an = ODEProblem(connected_simp, u0, (0.0,10.0), p; jac=true, sparse=true)

@btime solve($prob_an, Rodas4());
      # 142.899 μs (1297 allocations: 83.96 KiB

```

However, running these two examples (Julia 1.7.2 on Apple M1, native) I’m getting:

```julia
13.458 μs (206 allocations: 16.86 KiB)

```

And

```julia
48.125 μs (1330 allocations: 86.09 KiB)

```

What am I missing?

---

<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:** [June 9, 2022, 2:51pm UTC](https://discourse.julialang.org/t/solving-an-analytical-ode-slower-than-numerical/82499/2 "2022-06-09T14:51:17Z")

</div>

That example is just too small for sparsity to make it faster. You need a really large system for sparsity to be helpful.
