Ten candidate terms for each rate; twenty when the feed b multiplies a second copy.
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.
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.
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
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.
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.
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.
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.
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.
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.
Two laws, one stress test. Two laws for our chemical clock. One has five terms, the other twenty. On our data, the twenty-term law fits slightly better, and both say that the clock starts ticking when the feed b passes two. Now turn the feed up to four, beyond anything we ran. We refitted both laws on eight noise draws. Every time, the five-term law predicts a period within a tenth of a minute of the truth, 9.0 minutes. The twenty-term law blew up once, stopped ticking twice, and otherwise said anything from 6.9 to 9.2 minutes. A good fit is where a dynamical law starts, not where it ends. This video is about the tests beyond the fit. This is the second video of Module seven. Part one: hidden species and partial knowledge. Part two: steady states and bifurcations as tests. Part three: noise inside the system, delays and inputs. Part four: a worked study, end to end.
Hidden species. Part one: hidden species. Suppose only X has a colour, and Y is invisible to our instrument. Pause here. Can any law for X alone, using only X, reproduce the clock? We tried: a law for the rate of X built from X and its powers up to five. It explains 20 percent of how X changes. With Y in the library, the same rates are explained to 99.96 percent. There's a reason. A law in one variable can only push a state up or down a line. It can never bring it back around. An oscillation needs at least two variables, so a hidden one must exist. Picture X as a bead on a wire. At each position, the law gives it one speed, with one sign. So the bead can only slide one way, or stop. To come back around, it would have to pass the same point moving the other way, and with one variable, it can't. With no knowledge of Y at all, there is another route: use X from a moment ago as a stand-in for the hidden variable. That can reproduce the motion, but the formula is written in borrowed coordinates, and its terms no longer read as chemistry. Partial knowledge helps. Suppose the chemistry of Y is known: it's made from X at rate b, and used up by the step that makes X. That gives dY by dt equals b X minus X squared Y, a law we can run with the measured X as its input. Start that law from a wrong guess, and the error fades. Y's equation forgets where it started. From a guess of zero, or of five, the rebuilt Y was within one percent of the truth after about six minutes. Better still, we know how much Y we poured in at the start. With that, rebuilding Y and running the search found the law for X in forty draws out of forty, with every coefficient within 0.1 percent. Hidden variables don't end discovery. But the knowledge that fills them in, here the chemistry of Y, becomes part of the claim, and it must be stated.
Steady states and bifurcations. Part two: structure as a test. A law makes promises the fit never checked. Where does the mixture stand still? Is that resting point stable? And at what feed does the clock begin to tick? Set both rates of the found law to zero. The steady state is X equal to one, and Y equal to b. At a feed of 2.5, the found law puts it at 1.00 and 2.50, right where the chemistry puts it. Then linearize around it. The eigenvalues of the Jacobian say whether small disturbances die out or grow. As b rises, a pair of complex eigenvalues crosses into growth at b equal to 2.00, for the found law and for the truth. That's a Hopf bifurcation: a steady state gives way to a cycle. The onset is an experiment you can run: raise the feed slowly, and note where the colour starts to swing. Both of our laws passed that test, because both were fitted on feeds on either side of it. Why does a pair of complex eigenvalues mean a clock? Near the steady state, the mixture moves in a spiral. While the pair's real part is negative, the spiral winds inward, and the colour settles. Once it turns positive, the spiral winds outward until it reaches a closed loop, and the colour keeps swinging. So we traced the whole diagram: the swing of X after settling, for feeds from one to four and a half. The truth and the five-term law overlap everywhere. The twenty-term law tracks them across the feeds we ran. Beyond them it drifts, blows up at 3.5, and from 3.75 on says the clock stops, while the real one keeps swinging wider. Steady states, stability and bifurcations are strong tests, because the fit never aimed at them. A law that passes them, outside the data too, has earned some trust. These tests run on the law alone, so they're cheap. Find every steady state, check its stability, compare the onsets with experiments, and look for cycles where the data had none.
Noise, delays and inputs. Part three: the real world. So far, the reaction was exact, and only our instrument was noisy. In a tiny droplet, the reaction itself is random. Molecules meet by chance, one at a time. Then there are two laws in the data: the average push, called the drift, and the size of the random kicks, called the diffusion. In a big beaker, with twenty thousand molecules per unit of concentration, six runs still gave the law in five noise draws out of six. In a droplet a hundred times smaller, the same search kept fourteen to twenty terms, even with thirty-six runs. But the kicks carry information too. Their size grows with the reaction rates, and fitting that relation put the droplet at about 180 to 210 molecules per unit. The truth is 200. So in a small system, the noise is more than a nuisance to average away. Its size is a measurement in its own right. Delays are another trap. Suppose the detector for X responds 24 seconds late. Ignore that, and the search keeps all twenty terms. Scan the assumed delay, and the fit error is smallest at 0.4 minutes, which is 24 seconds, where the law comes back in nine draws out of ten. Why so many terms? X arrives late, so each of its readings sits next to a Y from a different moment. No short law links the two, so the search piles up terms to bend one onto the other. And inputs. Suppose a pump varies the feed of the first chemical over a five-minute cycle. A library without the pump can't represent that: the search keeps nine terms for X and never finds the law. Add the pump's signal, u, as a candidate, and the law comes back in twenty draws of twenty: dX by dt equals u, minus 3.5 X, plus X squared Y. Delays, inputs and hidden states are part of the system. If the library can't express them, the search will invent something else to fill the gap.
A worked study, end to end. Part four: the whole study, end to end. Six starting mixtures at each of three feeds, a reading every three seconds, one percent noise. The weak form, a library with the feed inside it, and a threshold from a wide, stable window. The result is the Brusselator, found in all forty draws, with coefficients within about half a percent. Then the checks that the fit never saw. The steady state sits at one and b. The clock starts ticking at b equal to two. And at b equal to four, outside the data, the period is within a tenth of a minute of the true nine. And the report states it all: the data and how they were taken, the library, the threshold window, the steady-state and onset checks, the feeds where the law was tested, and what was assumed to be known. The weakest link is coverage. We ran feeds from 1.5 to 3. Outside that range, only the single check at four backs the law up, and the report should say so.
Recap. Let's recap. Hidden variables can be rebuilt when part of the system is known, and that knowledge becomes part of the claim. Steady states, stability and bifurcations are tests the fit never aimed at. A law should pass them before it's trusted outside the data. Noise inside the system, delays and inputs each need a place in the model. Otherwise the search fills the gap with terms that don't exist. In the lab, you'll break the clock and repair it yourself. Next module: laws in space and time, from partial differential equations to graphs.
8:19Video 14 · 7.1Finding the right-hand sideAt 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.
8:17Video 15 · 7.2Beyond the fit: structure, stability and the real worldA 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.
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.
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.
Repeat until nothing changes. The threshold is the one knob.
With the feed inside the law, ask about feeds that were never run.
–
The law found
Sparse regression on the recorded runs.
–
–
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.
Challenges
Each one is checked as you go.
- Recover the clock’s five-term law at 1% noise or more. Hint: one starting mixture isn’t enough.
- Show that coverage matters: with the same noise, method and threshold, one run settled on the cycle fails where six starting mixtures succeed.
- 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.
- 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.
