# Replicating off-the-shelf ODE solvers

I've been working through some literature on ODEs and keep coming across the below pseudo-code expression and am having trouble interpreting it for use in the Wolfram Language. I feel like I've solved many initial value problems over the years with NDSolve, but now think I need some help from someone who works with ODEs in a more robust capacity to describe the differences.

The above is from here which states that h(t0) is the initial state of the system, G is the function that defines the system. t0 & t1 are the start and end times and Theta is the parameters. (Pytorch also has an implementation I've been looking at).

As I researched ways to understand the parameters, I kept coming up with pseudo-code examples using ODESolve. Should I be using a different MMA function? Maybe there is an option I'm not understanding? What's the most straightforward way to think about this pseudo-code example in Mathematica?

• In MA $\theta$-parameters are embedded in $G$. That is the only difference. However, there are several things that come as options to NDSolve that can be regarded as parameters $\theta$: AccuracyGoal, PrecisionGoal and WhenEvent . Commented Mar 2, 2021 at 16:56
• This is relevant to my previous comment mathematica.stackexchange.com/questions/23102/… Commented Mar 2, 2021 at 16:57
• To expand on @yarchik: I think it's something like NDSolve[{h'[t] == G[h[t], t, theta], h[t0] == h0}, {t, t0, t1}, opts...], where h0 is ${\bf h}(t_0)$. The parameters theta have to be specified numerically and are updated after each NDSolve call, to minimize the loss function I suppose. But I'll leave that for folks who do machine learning to explain. Commented Mar 2, 2021 at 17:15
• There's also ParametricNDSolve, which explicitly separates out parameters $\theta$. Commented Mar 2, 2021 at 17:21
• @ChrisK Good rec. It also has the option, Method -> {"ParametricSensitivity" -> "AdjointSensitivity"}, which might do what the paper describes. I have yet to find a discussion of "ParametricSensitivity", other than a few scattered examples. There is probably more than is shown in them, judging by the error messages I get if I use "ParametricSensitivity" -> Foo and "ParametricSensitivity" -> {1, 0} in Method option to ParametricNDSolve. Would you happen to know of more complete documentation of "ParametricSensitivity"? Commented Mar 2, 2021 at 18:28