Mathematics Prompts
Mathematical understanding prompts (overview)
This section covers prompts for testing and practicing LLM math capabilities. The goal isn't "compute fast" -- it's a verifiable, reusable, self-checkable math problem-solving workflow.
What Are Math Prompts?
Math prompts use clear constraints + verifiable steps to have the model complete calculations, reasoning, or proofs.
┌─────────────────────────────────────────────────────────────┐
│ Math Prompt Flow │
├─────────────────────────────────────────────────────────────┤
│ │
│ Problem input → Break into steps → Calculate/reason → Verify result │
│ (conditions) (split variables) (step by step) (self-check) │
│ │
└─────────────────────────────────────────────────────────────┘
Why Math Prompts Matter
| Use Case | Specific Application | Business Value |
|---|---|---|
| Education | Problem walkthroughs, homework help | Better understanding |
| Financial analysis | Interest/yield/cost calculations | Fewer calculation errors |
| Engineering estimates | Resource/capacity/cost estimates | More accurate decisions |
| Product data | A/B tests, conversion rate inference | Quick hypothesis checks |
| Research support | Derivations, formula verification | Reduced reasoning bias |
Common Math Task Types
| Type | Typical Problem | Prompt Focus |
|---|---|---|
| Arithmetic | Basic operations, ratios | Show your work |
| Algebra | Equations, variable relations | Define variables |
| Functions | Composite functions, evaluation | Step-by-step substitution |
| Geometry | Area/volume/angles | Complete conditions |
| Probability/Stats | Expected value, probability | Define sample space |
| Proofs/Logic | Contradiction/induction | State the rules |
Core Prompt Structure
A stable math prompt usually has four parts:
Goal: What to solve
Conditions: Given information and constraints
Process: Must be step-by-step and verifiable
Format: Final answer output separately
General Template
You are a rigorous math tutor. Solve step by step.
Problem:
{problem}
Requirements:
1) List variables and known conditions first
2) Show step-by-step derivation/calculation with intermediate results
3) Output the final answer separately
4) Self-check: substitute the result back to verify
Output format:
- Known/Variables:
- Steps:
- Final answer:
- Self-check:
Quick Start: Basic Arithmetic
Prompt:
Calculate and show intermediate steps.
Problem: An item originally costs $80. What's the price after a 25% discount?
Output:
Original price 80, discount 25% = 0.25
Discount amount = 80 × 0.25 = 20
Discounted price = 80 - 20 = 60
Final answer: $60
Example 1: Algebraic Equation
Scenario: Solve a linear equation
Prompt:
Solve the equation and show each step:
2x + 5 = 17
Output:
2x + 5 = 17
2x = 17 - 5 = 12
x = 12 / 2 = 6
Final answer: x = 6
Example 2: Word Problem (Work Rate)
Scenario: Two people completing a task together
Prompt:
A can finish a task alone in 6 hours. B can finish it in 4 hours. How long does it take if they work together?
Requirements: Show rates and calculation process.
Output:
A's rate: 1/6 task/hour
B's rate: 1/4 task/hour
Combined rate: 1/6 + 1/4 = 2/12 + 3/12 = 5/12 task/hour
Time = 1 ÷ (5/12) = 12/5 hours = 2.4 hours
Final answer: 2.4 hours
Example 3: Function Substitution
Scenario: Composite function evaluation
Prompt:
Given f(x) = 2x + 1, g(x) = x^2 - 3.
Find f(g(2)). Show step-by-step substitution.
Output:
First compute g(2) = 2^2 - 3 = 4 - 3 = 1
Then compute f(g(2)) = f(1) = 2 × 1 + 1 = 3
Final answer: 3
Example 4: Basic Probability
Scenario: Simple event probability
Prompt:
A bag contains 3 red balls and 2 blue balls. If you draw 1 ball at random, what's the probability of drawing a red ball?
Requirements: Show sample space and calculation.
Output:
Total balls = 3 + 2 = 5
Red balls = 3
Probability = 3 / 5
Final answer: 3/5
Advanced Tips
- Restate the problem first: Reduces misreading.
- Unify units: Convert time/length/currency first, then calculate.
- Boundary check: Use extreme values for quick sanity checks.
- Require self-check: Substitute back or reverse-verify the result.
- Limit output length: Prevent divergent reasoning.
Common Problems & Solutions
| Problem | Cause | Solution |
|---|---|---|
| Wrong result | Skipped steps | Force step-by-step + intermediates |
| Misread problem | Unclear conditions | Restate problem first |
| Unit confusion | Undefined variables | List variables + units first |
| Output too long | Reasoning spirals | Limit number of steps |
| Can't verify | No self-check | Add "substitute to verify" step |
API Examples
Python (OpenAI)
from openai import OpenAI
client = OpenAI()
def solve_math(problem: str) -> str:
response = client.chat.completions.create(
model="gpt-4o",
messages=[
{
"role": "system",
"content": "You are a rigorous math tutor. You must show step-by-step derivation and give a final answer."
},
{
"role": "user",
"content": f"Solve step by step, output the final answer separately:\n{problem}"
}
],
temperature=0,
max_tokens=300
)
return response.choices[0].message.content.strip()
print(solve_math("2x + 5 = 17"))
Python (Claude)
import anthropic
client = anthropic.Anthropic()
def solve_math(problem: str) -> str:
message = client.messages.create(
model="claude-sonnet-4-20250514",
max_tokens=300,
messages=[
{
"role": "user",
"content": f"""You are a math tutor.
Requirements: Step-by-step derivation, clear intermediate results, final answer output separately.
Problem: {problem}"""
}
]
)
return message.content[0].text.strip()
print(solve_math("A bag has 3 red and 2 blue balls. What's the probability of drawing red?"))
Hands-on Exercises
Exercise 1: Ratio and Discount
Original price $120. Apply a 20% discount first, then subtract $10. What's the final price?
Requirements: step-by-step calculation + final answer.
Exercise 2: Composite Function
f(x) = x + 4, g(x) = 3x - 2.
Find g(f(5)). Show step-by-step substitution.
Exercise 3: Word Problem to Formula
A car travels at 60 km/h for 2.5 hours. How far does it go?
Requirements: write the formula first, then substitute and calculate.
Related Reading
Takeaways
- Math prompts need to emphasize step-by-step reasoning + self-check.
- List variables and conditions before computing.
- Fixed output format makes reuse and batch testing easier.
- Low
temperatureproduces more stable results. - Build a reusable template library through examples and exercises.