Symbolic Physical Laws DiscoveryLaws in practice

Module 7Ordinary differential equations

Most laws in physics, chemistry and biology say how a system changes in time. With a simulated chemical clock (the Brusselator, a textbook model of oscillating reactions) we treat every derivative as an estimate and compare finite differences, smoothing and the weak form; find a sparse right-hand side from a library of candidate terms, with a threshold that works across a wide window; compare derivative, weak-form and trajectory matching; and design data that cover the state space, with the feed rate written into the law. Then we test the law where the fit never looked: we rebuild a hidden species from partial knowledge, check steady states and the onset of ticking (a Hopf bifurcation), push the feed beyond the data, and handle noise inside the reaction, a slow detector and a pump that varies the feed.

By the end you should be able to treat derivatives as estimates, find a sparse right-hand side, choose a formulation, design data that cover the state space and put parameters in the library, rebuild hidden variables from partial knowledge, and validate a dynamical law on steady states, stability and bifurcations, with noise, delays and inputs in the model.

Key ideas, one per video

  • Video 14At 1% noise the weak form found the clock's five terms in 39 of 40 noise draws, finite differences in 22, smoothing in none. Thresholds from 0.2 to 1.2 all worked; one settled run on the cycle never found the law, six starting mixtures found it 39 times in 40, and with the feed in the library it was found in all 40.
  • Video 15A law for X alone explains 20% of its rate; rebuilding the hidden species from its known chemistry recovered the law in 40 of 40 draws. The found law puts the onset of ticking at b = 2.00, like the truth, and at b = 4 predicts the period within a tenth of a minute, where a 20-term fit blew up, stopped or guessed. A detector 24 s late, or a pump left out of the library, keeps the search from ever finding the law.

Book: Chapter 7 of Computational Methods for Symbolic Physical Laws Discovery by Teddy Lazebnik (coming soon). The videos and slides follow the chapter’s topics in our own words, figures and simulations; nothing is copied from the book.

The title slide of Module 7: Ordinary differential equations

24 slides, written to be read on your own, with worked examples, our own small simulations and check-yourself questions (answers at the end). PDF, 2.1 MB.

Watch

2 videos for this module, each about 8 to 15 minutes. Pick one from the list, and open the transcript to read along: each timestamp plays the video from there. The narration is generated with a voice clone of Teddy, used with his permission.

Video 14 · 8:19

Finding the right-hand side

A beaker that keeps time: plain least squares writes twenty terms for its law, and fits a little better than the truth. The law has five.

At 1% noise the weak form found the clock's five terms in 39 of 40 noise draws, finite differences in 22, smoothing in none. Thresholds from 0.2 to 1.2 all worked; one settled run on the cycle never found the law, six starting mixtures found it 39 times in 40, and with the feed in the library it was found in all 40.

TranscriptVideo 14
0:00

A chemical clock. A beaker that keeps time. Feed it two chemicals at a steady rate, and its colour swings back and forth, about once every six and a half minutes. Chemists call reactions like this chemical clocks. We simulated one with a textbook model called the Brusselator, measured two concentrations every three seconds, and added one percent noise. Then we asked a computer for the law. Plain least squares wrote twenty terms, and fit our data a little better than the truth did. The real law has five terms. This video is about finding those five: the right-hand side of a differential equation. This is Module seven: ordinary differential equations. Part one: derivatives are inferred objects. Part two: sparse libraries and a threshold. Part three: three ways to pose the fit. Part four: many runs and many regimes.

0:56

Derivatives are inferred objects. An ordinary differential equation says how fast each quantity changes, given the current state. In our clock, the rate of change of X depends on X and Y, and so does the rate of change of Y. That rule, the right-hand side, is what we want. But no instrument measures a rate of change. We measure concentrations. Every derivative in a discovery pipeline is estimated, and the estimate has its own errors and its own assumptions. Finite differences assume that samples are close enough for a straight line between them. In our sixth run, X starts out changing at fifty-one units per minute. With a sample every three seconds, the difference quotient misses by up to about five, with no noise at all. Smoothing assumes that the curve is gentle inside its window. Our window was half a minute, longer than that fast start. With perfect data, smoothing first and differentiating second already breaks the search. The weak form avoids the derivative. Multiply the equation by a smooth bump, integrate, and move the derivative onto the bump by integration by parts. What's left needs only the measured concentrations. Across forty noise draws at one percent noise, the weak form found the right terms thirty-nine times. Finite differences found them twenty-two times. Smoothing, never. A derivative is a measurement you didn't make. Treat it like one, with error bars and a stated method.

2:17

Sparse libraries and a threshold. Part two: sparse libraries. We don't know the right-hand side, so we list candidate pieces: a constant, X, Y, and every product up to degree three. That's ten terms for each equation. Then we write each rate as a weighted sum of those pieces and fit the weights. That's a linear problem, fast and exact. But ordinary least squares keeps every term, and that's how we got twenty. Most laws in physics and chemistry use only a few of the possible pieces. So we look for a sparse answer: fit, drop every term whose weight falls below a threshold, refit with what's left, and repeat until nothing changes. On our clock data, that loop returns this. dX by dt equals one, minus 3.5 times X, plus X squared Y. And dY by dt equals 2.5 times X, minus X squared Y. That's the law we simulated, to two decimals. Each term reads as chemistry. The one is the steady feed. Minus 3.5 X is X being used up: 2.5 parts turn into Y, one part leaves. And X squared Y is the step where two X and one Y make a third X. That feedback makes the clock tick. The threshold is the knob that matters. We tried nine values, each on forty noise draws. Set it too low and nothing is dropped. Eighteen or nineteen terms survive, and the law is never found. Set it too high and a real term goes too. Four terms, never right. In between, a wide window, from 0.2 to 1.2, finds the law in thirty-seven to forty draws out of forty. A window that wide is good news. A result that appears at one magic threshold only is a warning. And notice what the threshold didn't do: improve the fit. The twenty-term formula fit our data slightly better than the truth. Fit alone can't choose here. Sparsity, chemistry and later tests must.

4:12

Three ways to pose the fit. Part three: three ways to pose the fit. Derivative matching estimates the rates and regresses them on the library. The weak form matches integrals against test functions. Trajectory matching simulates the candidate equations and compares whole curves with the data. We kept the five true terms fixed and compared the three on the numbers alone, ten noise draws each. At one percent noise, the worst coefficient error was 5.4 percent for finite differences. The weak form got it down to 0.6 percent. And trajectory matching got it to 0.08 percent. At five times the noise: 14 percent, 4.7 percent, and 0.3 percent. Matching whole trajectories weighs every sample against the noise, and never differentiates anything. So why not always simulate? Because it's slow, and because the error surface has more than one valley. Every guess needs a full simulation, and an oscillation that's slightly off in timing can score worse than one that's far off. Here's a real slice. Take a one-hour recording, and vary only the feedback coefficient, whose true value is one. The error has five valleys. A local search that starts outside 0.87 to 1.12 settles in a wrong one. Started from the weak-form estimate, it went straight to the law. A practical recipe: let a fast, robust formulation choose the terms and a starting point, then let trajectory matching polish the numbers.

5:35

Many runs, many regimes. Part four: many runs and many regimes. Pause here. Which data would you rather have: one long recording of the clock, ticking steadily, or six short runs from six different starting mixtures? Once the clock settles onto its cycle, the data trace the same closed loop again and again. On that loop, many different formulas agree, so the library becomes nearly redundant. With thirty minutes on the cycle, the law was found in none of forty draws. Six runs from six starting mixtures fill the space around the loop, fast starts included. Same noise, same method: thirty-nine out of forty. The same holds below the clock's threshold. With less of the second chemical, the mixture settles to a steady state. One run that started close to that steady state never found the law. Six starts found it twenty-eight times in forty. Discovery needs states that disagree with each other. Plan experiments that push the system into places the equation must explain. Real experiments rarely run one setting. Suppose we ran the clock at three feeds of the second chemical, b equal to 1.5, 2.5 and 3. Each run obeys its own law, but we suspect that one law covers them all, with the feed b inside it. So we give the library a second copy of every term, multiplied by b. Twenty candidates per equation. The search returned: dX by dt equals one, minus X, minus b times X, plus X squared Y. And dY by dt equals b times X, minus X squared Y. That's the Brusselator, with the feed in the right places, found in all forty draws. One equation now describes three regimes, including one where the clock doesn't tick at all. And a law with the feed inside it can be asked about feeds nobody ran. That's where the next video starts.

7:20

Recap. Let's recap. Derivatives are inferred objects. Finite differences, smoothing and weak forms each assume something, and those assumptions can fail even with perfect data. Sparse regression turns the search for terms into a fast linear problem, and its threshold should work across a wide window. Trajectory matching gives the best numbers, once you know the terms and have a good start. And the data must cover the space: many starting states, several settings, and the parameters written into the library. In the lab, you'll run this loop on the clock yourself. Next video: beyond the fit. Hidden species, bifurcations, noise inside the system, delays and forcing.

Interactive lab

Sparse dynamics

Record a chemical clock from one or several starting mixtures, choose the noise, the pipeline and the threshold, and run sparse regression. Then put the feed into the library and test the law where the fit never looked: its steady state, the feed where it starts to tick, and its period at a feed nobody ran.

The clock is the Brusselator, a textbook model of oscillating reactions, simulated in your browser (readings every 3 s for 15 min, Gaussian noise). Four challenges are checked as you go.

Simple math

A chemical clock, one sparse law

The page simulates a chemical clock with the Brusselator, a textbook model of oscillating reactions: dX/dt = 1 − (b+1)·X + X²·Y and dY/dt = b·X − X²·Y, where b is the feed of the second chemical. Both concentrations are read every 3 seconds for 15 minutes, from up to six starting mixtures, with the noise you choose. Everything runs in your browser.

A library of pieces
1, X, Y, X², X·Y, … Y³

Ten candidate terms for each rate; twenty when the feed b multiplies a second copy.

Sparse regression
fit · drop |ξ| < threshold · refit

Repeat until nothing changes. The threshold is the one knob.

Tests beyond the fit
steady state · onset · period at b = 4

With the feed inside the law, ask about feeds that were never run.

–

The law found

Sparse regression on the recorded runs.

–

–

Terms kept
–
The clock’s law?
–

Tests beyond the fit

Grey: the recorded runs. Dashed: the true clock from the first mixture. Orange: the found law from the same mixture. Blue dot: the found law’s steady state.

Steady state
–
Onset of ticking
–
Period at b = 4
–

Challenges

Each one is checked as you go.

  1. Recover the clock’s five-term law at 1% noise or more. Hint: one starting mixture isn’t enough.
  2. Show that coverage matters: with the same noise, method and threshold, one run settled on the cycle fails where six starting mixtures succeed.
  3. Find the threshold window at 1% noise with the weak form: one threshold that keeps more than ten terms, one that keeps fewer than five, and one that finds the law.
  4. Put the feed in the library and find a law whose onset is within 0.05 of b = 2 and whose period at b = 4 is within 3% of the truth.