Automatic State Transition Matrix

Hello,

When solving an ODE with the DifferentialEquations package, is there a way to automatically retrieve the state transition matrix, i.e. the sensitivity of the solution w.r.t. the initial conditions, along the entire trajectory?

I came across Forward-Mode Automatic Differentiation with ForwardDiff.jl, but this just gives me the STM at a given point in time, and f(x) must return an array-like object.

I would need something similar to ODEForwardSensitivityProblem in Direct Forward Sensitivity Analysis of ODEs, but capable of computing the sensitivities w.r.t. u0 rather than p.

Thank you!

Can’t you just put in dual numbers (via ForwardDiff.jl) as the initial conditions?

Yes, but this require a bit of machinery to extract the STM, something like

stack([vcat([[x.partials...] for x in u]'...) for u in sol(t).u],dims=3)

I was wondering if there was a more straightforward way to achieve the same.

Right now there isn’t a nice high level utility for this. I’ve been asked to extend ODEForwardSensitivityProblem for this but just haven’t gotten around to it yet. As Steven suggests, just using dual numbers on u0 and extracting it manually is the current technique, though I do hope to just make ODEForwardSensitivityProblem handle this sometime in the future.

1 Like