# DiffEqCallback and quadrature calculation with IntegratingCallback

**URL:** <https://discourse.julialang.org/t/diffeqcallback-and-quadrature-calculation-with-integratingcallback/110836>\
**Category:** Modelling & Simulations\
**Tags:** differentialequation, diffeqcallbacks, quadrature\
**Created:** [February 27, 2024, 9:36am UTC](https://discourse.julialang.org/t/diffeqcallback-and-quadrature-calculation-with-integratingcallback/110836 "2024-02-27T09:36:58Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![a6a3uh](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/a6a3uh/32/33773_2.png) [@a6a3uh](https://discourse.julialang.org/u/a6a3uh)\
**Post date:** [February 27, 2024, 9:36am UTC](https://discourse.julialang.org/t/diffeqcallback-and-quadrature-calculation-with-integratingcallback/110836/1 "2024-02-27T09:36:58Z")

</div>

Hi! I’m trying to calculate some integral along the IVP for some ODE. In particular I’m calculating a running cost for my control system simulation (or value of some functional).

It looks like IntegratingCallback and IntegratingSumCallback are designed exactly for that purpose.

But due to lack of documentation I can’t figure out how to use that functionality.

Here my simplified example. It is very simple equation dx = 1 and running cost again simplest possible - just integral of 1 which should return the total time eventually:

```julia
      prob = ODEProblem((u,p,t)->[1.0], [0.0], (0.0,1.0), ())
      integrated = IntegrandValues(Float64, Vector{Float64})
      sol = solve(prob, Euler(),
                  callback = IntegratingCallback(
                      (u, t, integrator) -> 1.0, integrated),
                  dt=0.1)

```

or this one

```julia
      prob = ODEProblem((u,p,t)->[1.0], [0.0], (0.0,1.0), ())
      integrated = IntegrandValuesSum(0.)
      sol = solve(prob, Euler(),
                  callback = IntegratingSumCallback(
                      (u, t, integrator) -> 1.0, integrated),
                  dt=0.1)

```

Both produce errors complain wrong Fix1 usage. Interestingly if I provide nonempty scalar parameter to ODEProblem I get StackOverflow. And if the parameter is Vector then error is again about Fix1 usage.

Maybe I’m using it wrong or this is not intended for that particular usage at all? Why it even tries to do anything with parameter?
