Loading editor...

Composing two ODEs

Loading commands, almost done…

Composability of ODEs

A \solve-ode is usually a closed box: hand it a rate dy/dt, a starting value, start time and end time, and get back a trajectory.

  • :
  • :
  • :
  • :

But the rate can be any reactive expression, including one that reads another trajectory.

Two ODEs can be chained: the second one's slope, at every instant, is a value sampled live from the first one's curve.

We use two trivial ODEs, say ODE A and ODE B:

ODE meaning
a plain decaying curve,
its slope is 's current height,

Try to interpret the behavior of :

  • Since , the slope of is always positive but decreasing with time.
  • Where is tall (near ), climbs steeply
  • Where has decayed (near ), flattens out.

's curve is shaped entirely by , which itself comes from an ODE.


How to implement this chain


1. Solve ODE A

  • and

A red decaying curve. Nothing surprising yet.

2. Let ODE B read A

The rate of B is not a formula — it is a point sampled off A's curve:

  • : this is the time variable for B's solver, which sweeps from t-start to t-end.
  • : a-pt.y is , and it updates as s moves.
  • .

As ODE B's solver sweeps s from to , a-pt.y re-reads at each step, so 's slope tracks 's height the whole way. That is the only line that matters: a-pt.y belongs to ODE A, but it is ODE B's right-hand side.


Where can this be useful?

  • Neural ODEs: the backward pass of a neural ODE is itself an ODE, whose rate depends on the values from the forward pass's trajectory.