How Math Notes Evaluates Variables in iOS 18

Apple’s iOS 18 introduces Math Notes, a feature integrated into the Calculator and Notes apps that interprets and solves handwritten mathematical expressions in real time. This article explains the technical process behind how Math Notes recognizes handwritten variable assignments, maintains their values in an active memory state, and dynamically evaluates downstream calculations or graphs that depend on those variables.

Handwriting Recognition and Syntax Parsing

When you write an assignment expression using your finger or Apple Pencil—such as x = 10 or length = 25—the operating system uses machine learning models trained on handwriting recognition to convert stroke data into structured mathematical notation. The system processes the strokes as discrete tokens, identifying the variable name (a letter or word), the assignment operator (=), and the assigned value (a scalar number, unit, or another expression).

Contextual State and Symbol Storage

Once an assignment is recognized, Math Notes stores the variable and its assigned value in a session-specific symbol table tied to that specific note. Unlike a traditional static calculator, Math Notes treats the document as a live computational workspace:

  • Scope: Variables are scoped to the note document, meaning any expression written within the same note can reference previously declared variables.
  • Order of Operations: The system reads spatial hierarchy and logical flow, allowing variables defined higher up or earlier on the page to populate subsequent formulas.
  • Units of Measure: Math Notes natively recognizes standard units (e.g., feet, meters, kilograms). If a variable includes units, such as speed = 60 mph, the internal engine stores both the numerical magnitude and the dimensional unit.

Real-Time Evaluation and Substitution

When you write an expression that references a defined variable and end it with an equals sign (for example, x * 2 =), Math Notes performs variable substitution:

  1. Token Match: The engine scans the active symbol table to find matching identifiers for the variables present in the expression.
  2. Value Injection: The stored values and units are substituted into the formula.
  3. Calculation: The on-device math engine computes the final result, handling any unit conversions automatically if requested.
  4. Smart Script Rendering: The calculated result is generated instantly and rendered directly next to the handwritten equals sign using Smart Script, matching the user's personal handwriting style.

Dynamic Reactivity

Math Notes creates a reactive dependency graph between variables and calculations. If you modify an original variable assignment—such as erasing 10 and writing 20 in x = 10—Math Notes re-evaluates the symbol table immediately. Every downstream equation, formula, or plotted graph that depends on x recalculates and updates automatically without requiring manual re-entry.