# Integral of some ModelingToolkitQuantity

**URL:** <https://discourse.julialang.org/t/integral-of-some-modelingtoolkitquantity/118398>\
**Category:** Modelling & Simulations\
**Tags:** modelingtoolkit\
**Created:** [August 20, 2024, 1:02am UTC](https://discourse.julialang.org/t/integral-of-some-modelingtoolkitquantity/118398 "2024-08-20T01:02:09Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![cstjean](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cstjean/32/1444_2.png) [@cstjean](https://discourse.julialang.org/u/cstjean)\
**Post date:** [August 20, 2024, 1:02am UTC](https://discourse.julialang.org/t/integral-of-some-modelingtoolkitquantity/118398/1 "2024-08-20T01:02:09Z")

</div>

I’m interested in computing the definite integral of some variable `X`, defined in ModelingToolkit. For sake of example, consider something like:

```julia
X ~ Y * Z
D(Y) ~ Y * 2
D(Z) ~ Z / t

```

(in particular, `X` is an “observed” in my case, AFAICT)

In the SciML world, these are the options?

- I can introduce `D(integral_of_X) ~ X` and let MTK deal with it.
- I can use `Integral(x in DomainSets.ClosedInterval(...))`
- Integrals.jl

I’m guessing that since it’s an observed, the fastest / most accurate is to set up an `IntegralProblem`?

---

<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:** [August 20, 2024, 3:05am UTC](https://discourse.julialang.org/t/integral-of-some-modelingtoolkitquantity/118398/2 "2024-08-20T03:05:57Z")

</div>

You can use

> **[Numerical Integration Callbacks · DiffEqCallbacks.jl](https://docs.sciml.ai/DiffEqCallbacks/stable/integrating/)**
>
> Documentation for DiffEqCallbacks.jl.

" \* I can introduce `D(integral_of_X) ~ X` and let MTK deal with it.", that will work, but it will lost a bit of performance.
