# Accessing derivative using HermiteInterpolation with DifferentialEquations.jl

**URL:** <https://discourse.julialang.org/t/accessing-derivative-using-hermiteinterpolation-with-differentialequations-jl/12296>\
**Category:** General Usage\
**Tags:** diffeq\
**Created:** [July 10, 2018, 2:02pm UTC](https://discourse.julialang.org/t/accessing-derivative-using-hermiteinterpolation-with-differentialequations-jl/12296 "2018-07-10T14:02:57Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Libbum](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/libbum/32/3935_2.png) [@Libbum](https://discourse.julialang.org/u/Libbum)\
**Post date:** [July 10, 2018, 2:02pm UTC](https://discourse.julialang.org/t/accessing-derivative-using-hermiteinterpolation-with-differentialequations-jl/12296/1 "2018-07-10T14:02:58Z")

</div>

I have a solution to a [DAE](http://docs.juliadiffeq.org/latest/tutorials/dae_example.html) via DifferentialEquations.jl, which uses Hermite interpolation as can be seen here:

```julia
julia> sol
retcode: Success
Interpolation: 3rd order Hermite
...

```

(the example in the tutorial page linked above can be used as a MWE if you need one)

I can use the interpolation to obtain solutions to my system via:

```julia
julia> sol(1987.4)
5-element Array{Float64,1}:
 1877.24
  913.053
 3522.07
    0.512887
  731.781

```

which are interpolated values of `sol.u` at time `t = 1987.4`.  
`sol.u` is an `Array{Array{Float64,1},1}` with a corresponding array `sol.t` calculated at specific times.

I’d also like to access the interpolation for my derivatives `sol.du`, which again is an `Array{Array{Float64,1},1}` corresponding to `sol.t`.

Is it possible to do this? Neither `sol(1987.4).du` or `sol.du(1987.4)` work.  
I’d be happy to set up my own linear interpolation of the `sol.du` array after the fact, but at face value it seems like accessing this data should be possible already since [`struct HermiteInterpolation`](https://github.com/JuliaDiffEq/DiffEqBase.jl/blob/602d8ea66c2dcbeb60453b5b2d1e7a8c915d1c6d/src/interpolation.jl#L1-L5) uses `t, u, du`, and I’ve just missed that section of the docs.

---

<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:** [July 10, 2018, 7:08pm UTC](https://discourse.julialang.org/t/accessing-derivative-using-hermiteinterpolation-with-differentialequations-jl/12296/2 "2018-07-10T19:08:51Z")

</div>

Are you asking for `sol(t,Val{1})`, the function for the derivative?

[http://docs.juliadiffeq.org/latest/basics/solution.html#Interpolations-1](http://docs.juliadiffeq.org/latest/basics/solution.html#Interpolations-1)

If you access that at one of the solution time points it will just give you the value of the derivative that it had stored in `sol.k` (and then the structure of `k` is different depending on the algorithm though… we can add a fake `sol.du` using getproperty overloading on v0.7 though if that’s useful?). But this is an interpolating function of the derivative as well.

---

<div class="post-metadata">

**Author:** ![Libbum](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/libbum/32/3935_2.png) [@Libbum](https://discourse.julialang.org/u/Libbum)\
**Post date:** [July 11, 2018, 8:19am UTC](https://discourse.julialang.org/t/accessing-derivative-using-hermiteinterpolation-with-differentialequations-jl/12296/3 "2018-07-11T08:19:27Z")

</div>

Thanks Chris,

Yeah, `sol(t,Val{1})` is what I was after—looks like I missed the point of the second argument to the interpolation functions when reading this before.

As for the second point, I’m not sure if that would be needed in my case, so probably not worth the trouble of implementing anything here.
