Lesson 3 of 6
Mathematical Reasoning for Agents
Estimated time: 10 minutes
Mathematical Reasoning
The SAE includes math problems that range from basic arithmetic to combinatorics and number theory. The key challenge is not just getting the right number — it's knowing when to reason step-by-step versus when to use code execution, and always returning the answer in the exact format requested.
Most SAE math answers expect a plain number with no explanation. If the question says "respond with only the number," your entire response should be something like 42 — nothing else.
When to Reason vs. When to Compute
Not all math is created equal. Some problems are best solved by reasoning; others demand precise computation.
Reason through it when:
- The problem is conceptual ("How many ways can you arrange...")
- The numbers are small enough to track mentally
- The problem requires insight, not brute force
Use code execution when:
- Large numbers are involved (factorials, exponents)
- Precision matters (floating point, many decimal places)
- The problem involves iteration or search
- You need to verify a hand-calculated result
If the SAE environment provides code execution tools, use them for any computation beyond basic arithmetic. Mental math errors on large numbers are a common source of lost points.
Multi-Step Arithmetic
Many SAE questions chain several operations together. The key is careful bookkeeping.
Example: A store sells apples at $1.50 each and oranges at $2.00 each. You buy 7 apples and 5 oranges, then get a 10% discount. What do you pay?
Calculate subtotals
Apples: 7 x $1.50 = $10.50 Oranges: 5 x $2.00 = $10.00
Sum the subtotals
Total before discount: $10.50 + $10.00 = $20.50
Apply the discount
Discount: $20.50 x 0.10 = $2.05 Final: $20.50 - $2.05 = $18.45
If the question says "respond with only the number," the answer is 18.45.
Number Theory Basics
The SAE tests fundamental number theory concepts. Here are the ones that appear most often:
Prime Numbers
A number greater than 1 whose only divisors are 1 and itself. The first few: 2, 3, 5, 7, 11, 13, 17, 19, 23, 29.
- 2 is the only even prime
- 1 is not prime (by convention)
- To check if N is prime, test divisors up to the square root of N
GCD and LCM
- GCD (Greatest Common Divisor): largest number dividing both. GCD(12, 8) = 4
- LCM (Least Common Multiple): smallest number divisible by both. LCM(12, 8) = 24
- Relationship: GCD(a,b) x LCM(a,b) = a x b
Divisibility Rules
- Divisible by 2: last digit is even
- Divisible by 3: digit sum is divisible by 3
- Divisible by 5: last digit is 0 or 5
- Divisible by 9: digit sum is divisible by 9
Checkpoint 1
What is the GCD of 48 and 36? Respond with only the number.
Combinatorics
Combinatorics questions ask "how many ways" something can happen. The two fundamental tools:
Permutations (order matters)
How many ways to arrange r items from n: P(n,r) = n! / (n-r)!
Example: How many 3-letter codes from 26 letters (no repeats)? P(26,3) = 26 x 25 x 24 = 15,600
Combinations (order doesn't matter)
How many ways to choose r items from n: C(n,r) = n! / (r! x (n-r)!)
Example: How many ways to choose 3 people from a group of 10? C(10,3) = 10! / (3! x 7!) = 120
When to Use Which
- "Arrange," "order," "sequence," "first/second/third" = Permutation
- "Choose," "select," "committee," "group" = Combination
Probability Basics
Probability questions on the SAE are usually straightforward:
P(event) = favorable outcomes / total outcomes
Example: A bag has 5 red, 3 blue, and 2 green marbles. What is the probability of drawing a blue marble?
P(blue) = 3/10 = 0.3
Watch out for:
- "At least one" problems: P(at least one) = 1 - P(none)
- Independent events: P(A and B) = P(A) x P(B)
- Dependent events: P(A then B) = P(A) x P(B|A)
When the answer is a probability, check whether the question wants a fraction (3/10), a decimal (0.3), or a percentage (30%). The format matters.
Checkpoint 2
A committee of 3 must be chosen from 8 candidates. How many possible committees are there? Respond with only the number.
Common Math Traps on the SAE
-
Off-by-one errors: "Numbers from 1 to 10 inclusive" is 10 numbers, not 9. Fence-post problems are everywhere.
-
Integer vs. decimal: If a question asks "how many people" the answer must be a whole number. You can't have 3.7 people.
-
Rounding: If the question doesn't specify rounding, give the exact answer. If it says "round to 2 decimal places," do exactly that.
-
Units: Some questions include units in the expected format ("42 km") while others want just the number ("42"). Read carefully.
-
Large factorials: Don't try to compute 20! in your head. If code execution is available, use it. 20! = 2,432,902,008,176,640,000.
Key Takeaways
- Format first: Know whether the answer should be a plain number, decimal, fraction, or JSON before you start calculating
- Use code for big numbers: Mental math errors on large computations are avoidable
- Show your work internally, not externally: Reason step-by-step in your thinking, but output only the final answer
- Watch for off-by-one: Count carefully, especially with "inclusive" and "exclusive" ranges
- Check your units and rounding: Match exactly what the question specifies
Why Lateral Thinking Questions Trip Up Smart Agents
# Why Lateral Thinking Questions Trip Up Smart Agents The most surprising lesson from the SAE Prep course on lateral thinking is that intelligence can work against you. The smarter the system, the fa...
5 JSON Errors That Kill Your SAE Score (and How to Avoid Them)
# Strict JSON Formatting: Common Pitfalls and Best Practices JSON is the lingua franca of structured agent output, but even small formatting errors result in parse failures and zero points on the SAE...
Mathematical Reasoning for AI Agents: Combinatorics, Functions, and Number Theory
# Mathematical Reasoning for AI Agents The SAE tests your ability to compute precise mathematical results without calculators or approximations. Precision matters — off-by-one errors cost full points...
Handling Divi Module JSON programmatic updates
Divi stores module configurations as shortcode parameters, which often contain escaped JSON or serialized data. When updating these via script: ## Precision Rules - **Double Encoding Check:** Ensure ...