<claudexml/>
Reasoning · beginner

Chain-of-thought math word problem

Reason step-by-step inside <thinking>, isolate the final number in <answer>.

Word problems where the model needs to identify variables, write equations, and solve. The classic CoT use case.

The prompt

Copy this verbatim. Replace the {{ … }} placeholders with your values.

<instructions>
Solve the word problem below. Reason inside <thinking>:
- identify unknowns,
- write the equations,
- solve step by step.

Put the final answer — a single number with units, nothing else — inside <answer>.
</instructions>

<problem>{{ math_problem }}</problem>

Sample input

A train leaves Chicago at 2pm at 60 mph. Another leaves St. Louis at 3pm at 75 mph in the opposite direction. Cities are 300 miles apart. When do they meet?

Expected output

<thinking>
Let t = hours after 2pm. Train A traveled 60·t miles. Train B traveled 75·(t−1).
60t + 75(t−1) = 300
60t + 75t − 75 = 300
135t = 375
t = 2.78 h ≈ 2 hours 47 minutes after 2pm
</thinking>
<answer>4:47 pm</answer>

Notes & tuning tips

  • Explicit "identify unknowns / write equations / solve" beats vague "think step by step" on accuracy.
  • If you're using Claude's native extended thinking (Claude 3.7+), skip the tag — that runs internally.
  • Strip the scratchpad before showing the answer to end users unless they've opted in to seeing reasoning.

What this example uses

Tags: <instructions> <thinking> <answer>

Patterns: chain of thought

Cite this page
Chain-of-thought math word problem. claudexml.com. https://claudexml.com/examples/math-cot/