Language Models Use Trigonometry to Do Addition
Subhash Kantamneni, Max Tegmark
TL;DR
The paper reveals that mid-sized LLMs internally represent numbers as generalized helices and perform addition by Clock-like manipulation of these helices, with $a$ and $b$ embedded as helix components and the final $a+b$ helix read to produce logits. Through activation and path patching, it causal supports a two-stage circuit: MLPs (reading $a,b$ to build $a+b$) followed by MLPs (reading $a+b$ to output the answer), with a sparse set of attention heads moving helices to the last token. The work provides a representation-level account for mathematical capabilities in LLMs and demonstrates that a clock-based, trigonometric decomposition yields robust predictive power and insights into model reliability and error modes. While compelling, it also notes model- and task-dependent variations, suggesting multiple algorithms may coexist and that further study across architectures and numeral representations is needed. This mechanistic perspective offers concrete avenues for improving interpretability and safety in reasoning tasks.
Abstract
Mathematical reasoning is an increasingly important indicator of large language model (LLM) capabilities, yet we lack understanding of how LLMs process even simple mathematical tasks. To address this, we reverse engineer how three mid-sized LLMs compute addition. We first discover that numbers are represented in these LLMs as a generalized helix, which is strongly causally implicated for the tasks of addition and subtraction, and is also causally relevant for integer division, multiplication, and modular arithmetic. We then propose that LLMs compute addition by manipulating this generalized helix using the "Clock" algorithm: to solve $a+b$, the helices for $a$ and $b$ are manipulated to produce the $a+b$ answer helix which is then read out to model logits. We model influential MLP outputs, attention head outputs, and even individual neuron preactivations with these helices and verify our understanding with causal interventions. By demonstrating that LLMs represent numbers on a helix and manipulate this helix to perform addition, we present the first representation-level explanation of an LLM's mathematical capability.
