Al-Khwarizmi: Discovering Physical Laws with Foundation Models

Christopher E. Mower, Haitham Bou-AmmararXiv 2025 · DOI

Introduction

The quest to uncover the mathematical laws governing physical systems—from the orbits of planets to the dynamics of fluid flow—has traditionally relied on human intuition and rigorous symbolic regression. A prominent tool in this field is Sparse Identification of Nonlinear Dynamics (SINDy), which constructs interpretable models by selecting optimal terms from a predefined library of candidate functions. However, SINDy's effectiveness is often bottlenecked by the "expert-in-the-loop" requirement: a human must manually curate the function library and tune the optimizer.

Al-Khwarizmi is a novel agentic framework designed to automate this discovery process. By integrating Large Language Models (LLMs) and Vision-Language Models (VLMs) with the SINDy method, Al-Khwarizmi removes the need for manual intervention, enabling the automated discovery of physical laws directly from raw data.

The Al-Khwarizmi Framework

Al-Khwarizmi operates as an iterative, multi-modal pipeline that leverages open-source models (such as Qwen2 and InternVL2.5) to reason about dynamical systems.

The Al-Khwarizmi agentic framework, illustrating the flow from system observation and RAG to iterative prompt reflection and optimization.

The framework consists of several integrated stages:

  1. Multi-modal Summarization: To handle large datasets, the system uses an LLM to summarize numerical trends and a VLM to analyze visual plots. This allows the model to identify qualitative behaviors like oscillations or chaotic attractors.
  2. Retrieval-Augmented Generation (RAG): The agent queries a database of known physical systems to find analogous examples, providing the LLM with relevant prior knowledge.
  3. Code Generation and Optimization: The LLM generates Python code to construct a tailored SINDy feature library and configure the optimization parameters.
  4. Iterative Reflection: This core component allows the system to evaluate its own performance. If the initial $R^2$ score is insufficient, the LLM "reflects" on the failure and refines the function library in subsequent attempts.
  5. Human-in-the-loop: While fully automated, the system can optionally incorporate non-expert feedback to guide the search.

Evaluation and Benchmarks

The framework was rigorously tested on 198 dynamical systems across two major benchmarks:

  • DYSTS: 135 systems encompassing a variety of chaotic and non-chaotic behaviors.
  • ODEBench: 63 systems defined by ordinary differential equations.

These benchmarks represent a broad spectrum of physical phenomena, challenging the model to generalize across diverse mathematical structures.

Performance Results

Al-Khwarizmi achieves state-of-the-art performance, significantly outperforming existing automated discovery methods like PySR and ODEFormer.

Comparison of Al-Khwarizmi (Ours) against baselines across DYSTS and ODEBench benchmarks, showing the percentage of models achieving R2 > 0.99.

Key results include:

  • 20% Performance Gain: Al-Khwarizmi demonstrates a substantial improvement over the best-performing alternatives.
  • High Precision: On the ODEBench dataset, the framework achieved a near-perfect fit ($R^2 > 0.99$) for 87.5% of the models, compared to the previous baseline of 75%.
  • Symbolic Generalization: By discovering the underlying symbolic equations rather than just fitting curves, the framework maintains high accuracy on unseen test data.

Key Insights

The research highlights several critical advantages of the agentic approach:

  • Visual Intuition: Allowing a VLM to "see" data plots is highly effective. Visual patterns often suggest specific mathematical primitives (e.g., trigonometric functions for periodic motion) that are difficult to discern from raw numbers.
  • The Impact of Reflection: Iterative refinement is the "secret sauce" of the framework. Reflection improved $R^2$ scores by up to 350% on DYSTS and nearly 1400% on specific ODEBench systems.
  • Open-Source Viability: The framework demonstrates that specialized scientific reasoning can be achieved using entirely open-source models, rivaling the capabilities of closed-source giants.

Limitations and Future Work

Despite its success, Al-Khwarizmi faces challenges such as context window constraints during long iterative sessions and SINDy's inherent assumption that laws are linear combinations of functions. Future developments aim to expand the set of functional primitives, improve robustness to noisy real-world sensor data, and extend the framework to synthesize optimal controllers for the discovered systems.

Summary updated

BibTeX
@misc{mower2025al,
  author = {Christopher E. Mower and Haitham Bou-Ammar},
  title = {{Al-Khwarizmi: Discovering Physical Laws with Foundation Models}},
  year = {2025},
  eprint = {2502.01702},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2502.01702},
}
Figure