For calculations with several variables or that require precision, tell Claude to write and run Python instead of doing the math in prose. Code execution is deterministic where language generation is not.
Last Updated: August 2026 · Cole Bridges Research Lab
Pre-calculation failure patterns and prompt fixes documented on live Claude Sonnet 4.6 API by Cole Bridges Research Lab.
Claude Sonnet 4.6 produces wrong math when it generates the narrative answer and the calculation simultaneously. The fix is forcing a calculation-first structure: use a <scratchpad> tag to make Claude show all math before writing a single word of explanation.
Anthropic's current lineup is Claude Haiku 4.5, Claude Sonnet 5 (released June 30, 2026), Claude Opus 5 (released July 24, 2026), and Claude Fable 5, with Claude Mythos 5 restricted to approved partners. Sonnet 5 is the default model on the Free and Pro plans, Opus 5 is the default on Max and the strongest model available on Pro. Source: Anthropic.
The test runs on this page were performed on Claude Sonnet 4.6, which Sonnet 5 replaced as the default model on June 30, 2026. We publish these results as a dated snapshot rather than restating them as current-model behavior. Where a finding has not been re-tested on Sonnet 5 or Opus 5, treat it as history, not as a live bug report.
Why Claude Gets Math Wrong With Confidence
Claude Sonnet 4.6 is a language model, not a calculator. When you ask it a question that involves numbers, it generates tokens sequentially, which means it often commits to a narrative direction before it has fully resolved the calculation. The number it produces fits the narrative, not reality.
This is a Silent Failure, one of the most costly patterns in production AI use. Claude does not flag uncertainty. It delivers the wrong number at the same confidence level as a correct one, complete with explanation and formatting that makes it look authoritative.
The Pre-Calculation Prompt Fix
Force Claude to complete all math before generating any explanatory text. The scratchpad structure is the most reliable method tested on Sonnet 4.6:
<task>Calculate the total project cost and monthly payment.</task>
<data>
Project total: $48,500
Down payment: $5,000
Loan term: 36 months
Interest rate: 6.9% APR
</data>
<scratchpad>
Show all calculations here step by step before writing any summary.
Do not skip steps. Show each arithmetic operation.
</scratchpad>
<answer>
Only write the final summary after completing all scratchpad calculations.
</answer>
The <scratchpad> tag forces Claude to externalize its reasoning before committing to output. Once the math is written out in the scratchpad, Claude cannot contradict it in the answer section without creating an obvious inconsistency, which it avoids. In our testing on Sonnet 4.6, this structure sharply reduced arithmetic errors on multi-step financial calculations.
When to Use Code Execution Instead
For calculations with more than 4 variables or requiring precision beyond 2 decimal places, prompt Claude Sonnet 4.6 to write and execute Python code rather than calculate natively. Claude's code execution is deterministic in a way its language generation is not.
<task>Write and execute Python code to calculate this. Show the code and output.</task>
<data>[your numbers here]</data>
<requirement>Do not calculate manually. Write Python and run it.</requirement>
The 3 Highest-Risk Calculation Types
| Calculation Type | Without Fix | With Scratchpad |
|---|---|---|
| Compound interest / loan amortization | Frequent errors | Rare errors |
| Multi-step percentage calculations | Frequent errors | Rare errors |
| Unit conversions across 3+ steps | Frequent errors | Rare errors |