How iOS 18 Evaluates Handwritten Math
Apple's iOS 18 introduces Math Notes, a feature that enables users to write mathematical expressions naturally and receive instant, calculated solutions. This article explains the underlying pipeline iOS 18 uses to evaluate handwritten equations, detailing how the operating system captures raw stylus inputs, translates them into structured mathematical syntax via on-device machine learning, solves the expressions, and renders answers directly in the user's own handwriting style.
Stroke Ingestion and Spatial Analysis
The evaluation process begins at the hardware level. When a user writes on the screen using an Apple Pencil or a finger, iOS 18 does not treat the input as a static image. Instead, it records the stroke data as temporal vector paths consisting of coordinates, stroke order, velocity, and pressure.
Because mathematical notation relies heavily on spatial hierarchy—such as superscripts for exponents, horizontal bars for fractions, and stacked rows for matrices—the system continuously analyzes the spatial relationships between individual strokes. This spatial mapping allows iOS to distinguish between a minus sign, a fraction bar, and a hyphen based strictly on stroke placement relative to surrounding characters.
On-Device Neural Recognition
Once the strokes are captured, iOS 18 processes them through localized machine learning models powered by the Apple Neural Engine. This eliminates latency and preserves user privacy by running the entire optical character recognition (OCR) pipeline offline.
The machine learning model operates in two stages:
- Symbol Classification: Individual stroke groupings are classified into mathematical symbols, digits, Greek letters, or variable names.
- Contextual Disambiguation: The engine uses contextual probability to resolve visual ambiguities. For example, it determines whether a circle is the number zero, the letter "O," or a degree symbol based on the surrounding mathematical context.
Semantic Parsing and Abstract Syntax Trees
Recognizing characters is not enough to compute a result; the system must understand the logic of the equation. iOS 18 converts the recognized symbols into an Abstract Syntax Tree (AST), an internal data structure that represents the syntactic structure of the math problem.
The AST enforces standard mathematical rules, such as operator
precedence (order of operations). For instance, in an expression like
2 + 3 × 4, the parser structures the multiplication node
below the addition node to ensure 3 × 4 is evaluated first.
The AST also maps user-defined variables (such as x = 5),
storing their values in memory so they can be referenced in subsequent
expressions or used to generate dynamic graphs.
The Calculation Engine
Once the user writes an equals sign (=), the gesture
acts as an execution trigger. The AST is passed to the internal
calculation engine, which supports standard arithmetic, algebra,
trigonometry, and calculus.
If the expression represents an equation with an unknown variable,
the solver calculates the root. If the expression represents a dependent
function with defined inputs, it computes the scalar result. If the
notation defines a function suitable for plotting (such as
y = 2x + 1), the system prompts the user to insert a
dynamic graph directly onto the canvas.
Output Generation via Smart Script
After computing the result, iOS 18 uses a proprietary technology called Smart Script to display the answer. Rather than inserting a standard digital font, machine learning models analyze the unique characteristics of the user's personal handwriting—including slant, stroke thickness, letter formation, and spacing. The system then generates and renders the solution immediately after the equals sign in a synthetic handwriting style that mimics the user's natural script.