REAMS: Reasoning Enhanced Algorithm for Maths Solving

Eishkaran Singh, Tanav Singh Bajaj, Siddharth NayakarXiv 2025 · DOI

Introduction

University-level mathematics—encompassing advanced calculus, linear algebra, and differential equations—represents a significant challenge for artificial intelligence. While Large Language Models (LLMs) excel at basic arithmetic, these complex domains require high precision and abstract logical reasoning. Previous approaches primarily utilized program synthesis, where models write Python scripts to solve problems. However, these "code-first" methods often fail when problems require conceptual bridges between natural language and algorithmic implementation.

To address this, we present REAMS (Reasoning Enhanced Algorithm for Maths Solving), a framework that integrates code generation with step-by-step logical reasoning to achieve state-of-the-art performance on university-level benchmarks.

The REAMS Methodology

The core of REAMS is a two-stage hybrid methodology that moves beyond simple one-shot code generation. The system implements an iterative "Reason-then-Code" loop designed to mimic human problem-solving strategies.

The iterative REAMS workflow combining CodeLlama 13B and Llama 3.1 8B.

The process begins with Zero-Shot Code Generation, where CodeLlama 13B attempts to solve the problem via Python. If the execution fails or produces an error, the system invokes Reasoning-Based Refinement. In this stage, Llama 3.1 8B generates a detailed mathematical explanation of the underlying principles. This reasoning is then fed back to CodeLlama as context for a second, informed coding attempt. This synergy allows a smaller, reasoning-optimized model to guide a larger, code-optimized model through conceptual hurdles.

Experimental Setup and Datasets

REAMS was evaluated against a rigorous dataset of 265 problems sourced from prestigious institutions and standard benchmarks:

  • MIT Courseware: Covering 18.01 (Calculus) through 18.06 (Linear Algebra) and 6.042 (Computer Science Math).
  • Columbia University: COMS3251 (Computational Linear Algebra).
  • The MATH Dataset: Including topics such as Number Theory and Precalculus.

Results and Comparative Analysis

The REAMS framework achieved a record-breaking overall accuracy of 90.15%, significantly surpassing the previous benchmark of 81% established by OpenAI’s Codex.

Comparative accuracy of REAMS against state-of-the-art LLMs on the MATH dataset subset.

As illustrated in the comparative data, REAMS (89.96% on the MATH subset) dramatically outperforms monolithic models like GPT-4 (42.5%) and Claude 2 (37.6%). The model showed particular strength in specialized subjects, reaching 92% accuracy in both Linear Algebra and Differential Equations. These results underscore the efficacy of combining symbolic reasoning with code execution rather than relying solely on massive scale.

Discussion and Limitations

The success of REAMS highlights that logic serves as a vital bridge for code generation. By forcing the system to "think" before it "acts," the framework corrects errors that were previously insurmountable. Furthermore, the generated reasoning chains provide pedagogical value, offering interpretable solutions rather than "black box" answers.

However, several limitations remain. The model currently lacks visual interpretation capabilities (visual blindness) and cannot perform formal axiomatic verification (e.g., using Lean). It also remains dependent on the capabilities of underlying Python libraries like NumPy and SymPy. Future research will focus on integrating formal proof assistants and multi-modal data handling to further expand the system's mathematical proficiency.

Summary updated

BibTeX
@misc{singh2025reams,
  author = {Eishkaran Singh and Tanav Singh Bajaj and Siddharth Nayak},
  title = {{REAMS: Reasoning Enhanced Algorithm for Maths Solving}},
  year = {2025},
  eprint = {2509.16241},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2509.16241},
}
Figure