Part III: Discovery Through Data and Models
Chapter 35: Symbolic Regression and Equation Discovery

Symbolic Regression and Equation Discovery

"I spent three billion generations evolving the perfect expression tree. It was $x + 1$."

A Genetic Program With a Complexity Penalty

Overview

Neural networks are powerful function approximators, but they are opaque. A neural network that predicts planetary orbits with nine decimal places of accuracy tells you nothing about the underlying law of gravitation. Symbolic regression inverts this trade-off: it searches the space of mathematical expressions for compact, interpretable formulas that fit the data. When it works, the result is not a black-box model but a human-readable equation that a scientist can analyze, generalize, and physically interpret.

The idea is simple to state and extraordinarily difficult to execute. The space of possible mathematical expressions is combinatorially vast: even restricting to binary operators $\{+, -, \times, \div\}$ and unary functions $\{\sin, \cos, \exp, \log\}$ over three variables, the number of syntactically valid expression trees of depth 5 exceeds $10^{10}$. Most of these expressions are garbage. A tiny fraction fit the data by coincidence. An even tinier fraction represent genuine physical laws. Finding the needle in this haystack requires both intelligent search and principled model selection.

This chapter covers three complementary approaches to the search. Genetic programming (Section 35.1) evolves populations of expression trees through mutation, crossover, and selection, using biological metaphors to explore the space. Neural-guided symbolic regression (Section 35.2) uses neural networks to propose candidate expressions or guide the search, combining the flexibility of deep learning with the interpretability of symbolic formulas. The equation discovery pipeline (Section 35.3) puts everything together with PySR, dimensional constraints, and SymPy-based validation to recover hidden scientific laws from experimental data.

These techniques connect directly to the scientific machine learning methods of Chapter 33, where neural networks learn solutions to differential equations. Where SciML produces fast but opaque surrogates, symbolic regression aims for the equation itself. They also connect to the discovery as search framework of Chapter 1 (expression trees as search spaces), the reasoning for discovery methods of Chapter 4 (symbolic manipulation), and the optimization techniques of Chapter 45 (fitness landscape navigation). Looking ahead, the interpretable equations produced here feed directly into the hypothesis generation pipelines of Chapter 39 and the AI scientist systems of Chapter 53.

Prerequisites

Readers should be familiar with Chapter 1: Discovery as Search for the general framework of search spaces and heuristics, and with Chapter 25: Exploratory Discovery for data preprocessing and feature selection. Basic familiarity with tree data structures and recursion is assumed; Appendix B covers Python prerequisites. The dimensional analysis in Section 35.3 uses concepts from Chapter 5: Discovery Through Data, Models, and Simulation.

Learning Outcomes

Sections

35.1 Equation Discovery from Data

Expression trees as search spaces. Fitness, bloat, and the Pareto front of accuracy vs. complexity. Kolmogorov complexity, minimum description length, and information-theoretic model selection. Dimensional analysis as hard constraints. The gplearn library for classical genetic programming.

35.2 Genetic Programming and Neural Guidance

Tournament selection, subtree crossover, and point mutation. Neural-guided symbolic regression with transformers (SymbolicGPT, NeSymReS). Reinforcement learning for expression construction. PySR's multi-population evolutionary algorithm. Scaling to high-dimensional problems.

35.3 Building an Equation Discovery Pipeline

Recipe: recover Kepler's third law and a damped oscillator equation from synthetic data using PySR with dimensional constraints. Validate with SymPy simplification. Integrate with scipy curve fitting. Deploy as a Discovery Workbench component for automated law discovery.

What's Next

Symbolic regression closes Part III by producing the artifact the rest of the book builds on: a human-readable equation that can be tested, generalized, and published. Chapter 36: Literature Mining opens Part IV: Discovery Through Knowledge, where the focus shifts from discovering patterns in data to discovering patterns in the scientific literature. The equations produced here become testable hypotheses when connected to the literature-mining and knowledge-graph tools of Part IV.

Bibliography

Foundational Papers

Koza, J. R. (1994). Genetic programming as a means for programming computers by natural selection. Statistics and Computing, 4(2), 87-112.

The foundational work on genetic programming that established expression-tree evolution as a method for automatic program synthesis.

Cranmer, M. (2023). Interpretable machine learning for science with PySR and SymbolicRegression.jl. arXiv preprint arXiv:2305.01582.

The PySR paper describing the multi-population evolutionary algorithm with adaptive complexity penalties that is the primary tool in this chapter.

Schmidt, M. & Lipson, H. (2009). Distilling free-form natural laws from experimental data. Science, 324(5923), 81-85.

Eureqa: the landmark demonstration that symbolic regression can rediscover known physics laws (Hamiltonians, Lagrangians) from raw experimental data without prior knowledge.

Udrescu, S.-M. & Tegmark, M. (2020). AI Feynman: A physics-inspired method for symbolic regression. Science Advances, 6(16), eaay2631.

AI Feynman combines neural networks with physics-inspired decomposition (dimensional analysis, symmetry, separability) to solve symbolic regression problems from the Feynman Lectures.

Neural-Guided Approaches

Biggio, L., Bendinelli, T., Neitz, A., Lucchi, A., & Parascandolo, G. (2021). Neural symbolic regression that scales. Proc. ICML.

NeSymReS: a set-transformer architecture that generates symbolic expressions directly from datasets, scaling to hundreds of input variables.

Kamienny, P.-A., d'Ascoli, S., Lample, G., & Charton, F. (2022). End-to-end symbolic regression with transformers. NeurIPS.

Transformer-based symbolic regression that generates expression tokens autoregressively, trained on millions of synthetic equation-data pairs.

Petersen, B. K., Landajuela, M., Mundhenk, T. N., Santiago, C. P., Kim, S. K., & Kim, J. T. (2021). Deep symbolic regression: Recovering mathematical expressions from data via risk-seeking policy gradients. Proc. ICLR.

Uses reinforcement learning to construct symbolic expressions token-by-token, with a risk-seeking policy gradient that prioritizes finding exact solutions.

Theory and Complexity

Grünwald, P. D. (1998). The minimum description length principle and reasoning under uncertainty. PhD thesis, University of Amsterdam.

The MDL principle provides the information-theoretic foundation for balancing model fit against complexity in symbolic regression.

Li, M. & Vitányi, P. (2008). An Introduction to Kolmogorov Complexity and Its Applications. Springer, 3rd edition.

The definitive reference on algorithmic information theory and Kolmogorov complexity, which provides the theoretical motivation for preferring shorter expressions.

Tools & Libraries

Cranmer, M. (2023). PySR: High-performance symbolic regression in Python.

The primary symbolic regression tool used in this chapter: a Python wrapper for SymbolicRegression.jl with multi-population evolution and dimensional constraints.

Meurer, A., et al. (2017). SymPy: Symbolic computing in Python. PeerJ Computer Science, 3, e103.

SymPy provides the symbolic algebra engine used for simplifying, validating, and analyzing discovered equations.

Stephens, T. (2015). gplearn: Genetic programming in Python.

A scikit-learn compatible genetic programming library for symbolic regression, used in Section 35.1 for pedagogical examples.

Virtanen, P., et al. (2020). SciPy 1.0: Fundamental algorithms for scientific computing in Python. Nature Methods, 17, 261-272.

SciPy's optimization module (curve_fit, minimize) is used for refining constants in discovered symbolic expressions.

Benchmarks & Datasets

La Cava, W., et al. (2021). Contemporary symbolic regression methods and their relative performance. NeurIPS Datasets and Benchmarks Track.

SRBench: a comprehensive benchmark of 14 symbolic regression methods on 122 real-world datasets, establishing performance baselines for the field.