# Conditional exact integration in ODE solving

**URL:** <https://discourse.julialang.org/t/conditional-exact-integration-in-ode-solving/127267>\
**Category:** Modelling & Simulations\
**Tags:** diffeq, ode\
**Created:** [March 22, 2025, 6:48pm UTC](https://discourse.julialang.org/t/conditional-exact-integration-in-ode-solving/127267 "2025-03-22T18:48:51Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![BdeKoning](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bdekoning/32/214557_2.png) [@BdeKoning](https://discourse.julialang.org/u/BdeKoning)\
**Post date:** [March 22, 2025, 6:48pm UTC](https://discourse.julialang.org/t/conditional-exact-integration-in-ode-solving/127267/1 "2025-03-22T18:48:51Z")

</div>

Say in my ODE problem I have an equation like this:

\frac{\text{d}u\_i}{\text{d}t} = r(\mathbf{u})A(t)

Here A(t) is a known non-negative interpolation function and r(\mathbf{u}) is what we call a ‘reduction factor’; it’s a function whose value is in the interval [0,1] used to maintain physical feasiblity, and generally depends on a small number of other states.

There can be large time periods in the simulation where simply r(\mathbf{u}) =1, in which case the above equation can be integrated exactly. My question is this: in OrdinaryDiffEq.jl, is there a nice way to apply the exact integration where applicable? In theory it is possible to rig something together with `VectorContinuousCallback`, but that is too costly because our simulations can contain hundreds of equations of the above form.

Now that I think of it, it might be nicer to have the equation

\frac{\text{d}u\_i}{\text{d}t} = (1-r(\mathbf{u}))A(t)

so that this state represents the deviation from the exact integration case.

---

<div class="post-metadata">

**Author:** ![danielwe](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/danielwe/32/35657_2.png) [@danielwe](https://discourse.julialang.org/u/danielwe)\
**Post date:** [March 22, 2025, 6:56pm UTC](https://discourse.julialang.org/t/conditional-exact-integration-in-ode-solving/127267/2 "2025-03-22T18:56:17Z")

</div>

How about rigging a composite algorithm for this purpose? [ODE Solvers · DifferentialEquations.jl](https://docs.sciml.ai/DiffEqDocs/stable/solvers/ode_solve/#CompositeAlgorithm)

---

<div class="post-metadata">

**Author:** ![BdeKoning](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bdekoning/32/214557_2.png) [@BdeKoning](https://discourse.julialang.org/u/BdeKoning)\
**Post date:** [March 22, 2025, 6:57pm UTC](https://discourse.julialang.org/t/conditional-exact-integration-in-ode-solving/127267/3 "2025-03-22T18:57:53Z")

</div>

That looks interesting. I don’t think it’s applicable though, because this decision has to be made on a per-state basis.
