Skip to main content
Lesson 9 of 12 · AI Reasoning with Mistral: reasoning_effort, Small 4 and Large 4

Mathematical Problem Solving

Lesson 9 of 12 Updated November 2, 2026 Developer
On this page
  1. Mathematics: The Ideal Ground for Reasoning
  2. Multi-Step Arithmetic Problems
  3. Equations and Systems of Equations
  4. Proofs and Demonstrations
  5. Logic Puzzles
  6. Optimization and Probability
  7. Pattern: Automatic Validation
  8. Comparison: With and Without Reasoning
  9. Key Takeaways

Lesson updated November 2, 2026. The original examples used Magistral, which was retired on July 31, 2026. They now call Mistral Small 4 (mistral-small-2603) or Mistral Large 4 (mistral-large-4-0) with reasoning_effort="high", and parse the response using the separer function from Lesson 3. Source: Reasoning (Mistral Documentation).

Mathematics: The Ideal Ground for Reasoning

Mathematical problems are the use case where reasoning delivers the most value. A non-reasoning model answers “2 + 2” correctly but often fails on multi-step problems, proofs, and logic puzzles. With reasoning enabled, the model decomposes the problem, verifies each step, and validates the result—exactly what token-by-token generation lacks.

Multi-Step Arithmetic Problems

Let’s start with a case where the order of operations determines the outcome. A 20% discount followed by a €15 voucher does not yield the same total as a voucher applied before the discount; a rushed model often mixes them up.

from mistralai.client import Mistral

client = Mistral(api_key="YOUR_API_KEY")

probleme = """A store offers a 20% discount on all items.
A customer buys 3 items at 45 euros, 2 items at 30 euros, and 1 item at 75 euros.
They also have an additional 15-euro voucher applicable after the discount.
What is the final amount to pay? Detail each step."""

response = client.chat.complete(
    model="mistral-small-2603",
    reasoning_effort="high",
    messages=[{"role": "user", "content": probleme}]
)

# The model reasons step by step:
# 1. Calculate total price before discount
# 2. Apply 20% discount
# 3. Subtract 15-euro voucher
# 4. Verify the result

Reasoning prevents the model from skipping steps and ensures it checks the consistency of its intermediate calculations before delivering a final amount.

Equations and Systems of Equations

Systems of equations test this same discipline in a more formal setting. Here, the system prompt enforces a strict requirement for detail:

systeme = """Solve the following system of equations:
3x + 2y - z = 7
x - y + 2z = 3
2x + 3y + z = 12

Show every step of the solution."""

response = client.chat.complete(
    model="mistral-small-2603",
    reasoning_effort="high",
    messages=[
        {"role": "system", "content": "You are a mathematics teacher. Detail every operation."},
        {"role": "user", "content": systeme}
    ],
)

The model starts by choosing a method—substitution, elimination, or matrices—applies the operations one by one, and then substitutes its values back into the original equations to verify they hold. This final step, often neglected by non-reasoning models, is what catches sign errors.

Proofs and Demonstrations

Mathematical proofs reveal the full power of reasoning, provided you define the expected framework. For longer proofs, Mistral Large 4 in high mode is worth testing if Small 4 falls short. Enforcing the four stages of induction in the system prompt prevents the model from “concluding” based on just two specific cases:

demonstration = """Prove by induction that for any integer n >= 1:
1^2 + 2^2 + 3^2 + ... + n^2 = n(n+1)(2n+1) / 6"""

response = client.chat.complete(
    model="mistral-small-2603",
    reasoning_effort="high",
    messages=[
        {"role": "system", "content": """You are a rigorous mathematician.
Expected proof structure:
1. Base case (Initialization)
2. Inductive hypothesis
3. Inductive step (from n to n+1)
4. Conclusion"""},
        {"role": "user", "content": demonstration}
    ],
)

Logic Puzzles

Constraint-based puzzles are particularly revealing because no single formula leads to the solution; the model must explore possibilities and then eliminate them. The classic puzzle involving three friends, three professions, and three car colors is the purest example.

enigme = """Three friends (Alice, Bob, Charlie) each have a different profession
(doctor, lawyer, engineer) and a car of a different color (red, blue, green).

Clues:
1. Alice is not the doctor
2. The owner of the red car is the lawyer
3. Bob does not have the green car
4. Charlie is not the lawyer
5. The engineer has the blue car
6. Alice does not have the red car

Find the profession and car color for each person."""

response = client.chat.complete(
    model="mistral-small-2603",
    reasoning_effort="high",
    messages=[{"role": "user", "content": enigme}]
)

In its reasoning traces, the model lists possibilities for each person, applies constraints one by one, eliminates impossible combinations, and then validates the selected solution against all six clues: Alice is the engineer with the blue car, Bob is the lawyer with the red car, and Charlie is the doctor with the green car. The sixth clue is not decorative; without it, Alice and Bob could swap their roles as lawyer and engineer, leaving the puzzle with two solutions. A good reasoning model flags this; it’s an excellent way to test your own problem statements. This final validation pass distinguishes deduction from a lucky guess.

Optimization and Probability

Counting problems pose a similar challenge: the answer depends on a probabilistic model choice that the AI must explicit before calculating.

proba = """An urn contains 5 red balls, 3 blue balls, and 2 green balls.
We draw 3 balls without replacement.
What is the probability of getting exactly 2 red balls and 1 blue ball?
Express the result as an irreducible fraction."""

response = client.chat.complete(
    model="mistral-small-2603",
    reasoning_effort="high",
    messages=[{"role": "user", "content": proba}]
)

Pattern: Automatic Validation

For critical results, a single call isn’t enough. You can leverage reasoning a second time by submitting the generated solution to an independent check: the model then approaches the problem with the answer already in view, forcing it to verify rather than generate.

def solve_and_verify(client, problem):
    """Solves a problem and requests verification."""

    # Step 1: Resolution
    solve_response = client.chat.complete(
        model="mistral-small-2603",
        reasoning_effort="high",
        messages=[{"role": "user", "content": problem}]
    )

    _, answer = separer(solve_response.choices[0].message.content)

    # Step 2: Verification via a second call
    verify_response = client.chat.complete(
        model="mistral-small-2603",
        reasoning_effort="high",
        messages=[
            {"role": "user", "content": f"""Verify this solution to the following problem:

PROBLEM: {problem}

PROPOSED SOLUTION: {answer}

Is the solution correct? If not, correct it."""}
        ]
    )

    return {
        "solution": answer,
        "verification": separer(verify_response.choices[0].message.content)[1],
    }

Comparison: With and Without Reasoning

To measure the impact on a concrete example, revisit the chicken puzzle. The proportionality is deceptive and pushes a non-reasoning model toward the answer “12” through simple analogy with the prompt.

probleme_test = "If 3 chickens lay 3 eggs in 3 days, how many eggs do 12 chickens lay in 12 days?"

# Without reasoning — risk of error via naive analogy (answer "12")
response_none = client.chat.complete(
    model="mistral-small-2603",
    messages=[{"role": "user", "content": probleme_test}],
    reasoning_effort="none"
)

# With reasoning — correct decomposition
response_high = client.chat.complete(
    model="mistral-small-2603",
    reasoning_effort="high",
    messages=[{"role": "user", "content": probleme_test}]
)
# Expected reasoning: 1 chicken = 1 egg / 3 days
# 12 chickens in 12 days = 12 * (12/3) = 48 eggs

Run both calls on your own problems before deciding; it’s the only reliable way to know if the extra cost of reasoning is justified in your domain.

Key Takeaways

  • Reasoning excels at multi-step mathematical problems
  • Use a system prompt that enforces a solution structure (steps, verification)
  • Proofs by induction benefit enormously from structured reasoning
  • Logic puzzles highlight the exploration and elimination of possibilities
  • Implement double verification for critical results
  • Always compare results with and without reasoning to validate the added value