Using DeepSeek for Math: Models, Prompts and Worked Examples

DeepSeek for math: thinking-mode prompts, model picks, and worked examples for algebra to AIME problems. Compare V4, R1 and DeepSeekMath now.

Use Cases·April 25, 2026·By DS Guide Editorial
DeepSeek for math title card: eyebrow 'Use case · Math', title 'DeepSeek for Math', tagline 'Five prompt workflows; Flash prices in USD per 1M tokens.', and four stats: 5 workflows, 1M context tokens, 0.30 Flash miss peak (deepseek-flash cache-miss input, USD per 1M tokens at peak) and 1.20 Flash out peak (deepseek-flash output, USD per 1M tokens at peak), beside an open-manual illustration.

If you are stuck on a tricky integral, an Olympiad-style number-theory problem, or a 30-row spreadsheet of dosage calculations, which model should you actually open? Using DeepSeek for math is one of the better-documented workflows in the lineup: the lab has published a dedicated math model (DeepSeekMath, 2024), the R1 reasoning model (January 2025), a Lean 4 prover line, and today’s two API models, deepseek-flash and deepseek-v4-pro, both with thinking mode switched on by default. Not every model is right for every problem.

This guide covers which DeepSeek model to pick for which kind of math, how to prompt it, what it costs through the API, and where it still gets things wrong.

The concrete problem: math is not one task

Illustration: a student's notebook with the quadratic 2x² − 5x − 3 = 0 solved by hand beside a laptop whose generic AI chat window shows the same step-by-step solution ending in x = 3, −1/2; not a capture of DeepSeek's interface.

“Doing math” with a language model is a stack of very different jobs. Arithmetic on long numbers, algebraic manipulation, calculus, statistics, formal proofs, contest problems, and applied word problems each stress a model in different ways. A model that scores well on grade-school word problems can still hallucinate a derivative, and a strong contest reasoner can still misread a units conversion in an applied physics question.

The DeepSeek lineup reflects this. There is a small, dedicated math model from 2024; a reasoning model (R1) for which DeepSeek reported 97.3% pass@1 on MATH-500 in January 2025; a formal theorem prover; and the current API models with a thinking mode you control per request. The right pick depends on whether you need speed, depth of reasoning, code-assisted calculation, or formal verification.

Which DeepSeek model for which kind of math

The short version: for everyday algebra, calculus, and applied word problems, deepseek-flash (served by DeepSeek-V4.1-Flash-1017; see our DeepSeek V4 Flash page) in thinking mode is the default. For the hardest contest problems, raise reasoning_effort to "max" and verify the answer. For specialised theorem-proving in Lean 4, the Prover line is the purpose-built choice.

Task Best DeepSeek pick Why
Homework, calculus, statistics deepseek-flash, thinking on (the default) Lower-priced API model, 1M context, returns reasoning_content alongside the answer
Olympiad / AIME / contest math deepseek-flash or deepseek-v4-pro at reasoning_effort="max" DeepSeek reported MathArena Apex 65.6 for the September 2026 V4.1-Flash build (Change Log, 10 Sep 2026)
Tool-using math (Python, SymPy) deepseek-flash or deepseek-v4-pro, thinking on Both support tool calls in thinking mode
Formal proofs in Lean 4 DeepSeek Prover Trained specifically for verified theorem proving
Local, offline math on a laptop DeepSeek Math 7B or an R1 distill About 14 GB of bf16 weights for the 7B model; DeepSeek reported 51.7% on MATH (February 2024 paper)

Why deepseek-flash is the default for most math

The DeepSeek API lists two models today: deepseek-flash, served by DeepSeek-V4.1-Flash-1017 (released 17 October 2026), and deepseek-v4-pro, served by DeepSeek-V4-Pro-0813 (released 13 August 2026). Both publish open weights under the MIT license, accept a 1M-token context with up to 384K output tokens, and run in thinking mode by default, with reasoning_effort set to low, high (default) or max. That is what you want for math: leave thinking on for hard problems, lower the effort or switch it off for trivial ones. deepseek-flash is the lower-priced of the two, and DeepSeek’s 10 September 2026 release news says tests by multiple parties put V4.1-Flash ahead of V4-Pro on performance, cost, speed and total runtime. Endpoint, SDK and model-ID details are in our DeepSeek API documentation guide.

Where R1 fits today

R1 (January 2025) was trained with a pipeline of two reinforcement-learning stages and two supervised fine-tuning stages; its model card says the RL-only precursor, DeepSeek-R1-Zero, showed capabilities such as self-verification, reflection and long chains of thought. On its model card DeepSeek reported 97.3% pass@1 on MATH-500 and 79.8% on AIME 2024. R1 is not one of the two current API model IDs; its value today is as MIT-licensed open weights and as the source of the smaller R1 distills you can run locally. Its card’s math directive is also a useful prompt pattern for the current models (see workflow 1). For an architectural deep-dive, see the DeepSeek R1 page.

Five prompt workflows for math

Each one below is a prompt pattern, not a one-shot trick — small adjustments matter.

1. The “show your work” calculus prompt

Use deepseek-flash with thinking on (the default), plus an explicit final-answer directive. The directive is the one DeepSeek publishes on the R1 model card: “For mathematical problems, it is advisable to include a directive in your prompt such as: ‘Please reason step by step, and put your final answer within \boxed{}.’” A fixed answer format makes the final result easy to extract and check.

System: You are a math tutor. Use LaTeX for equations.
User: Compute the indefinite integral of x*ln(x) dx.
       Please reason step by step, and put your final
       answer within \boxed{}.

Thinking mode does not support temperature: the API accepts the parameter without error, but it has no effect. DeepSeek’s guidance of 0.0 for code generation and mathematics applies when you switch thinking off (extra_body={"thinking": {"type": "disabled"}}) for quick, deterministic answers.

2. Tool-augmented arithmetic for ugly numbers

Language models are imperfect calculators. For long multiplication, long division, or exact fractions, ask the model to write Python rather than compute in its head. Both current models support tool calling in OpenAI-compatible format, including in thinking mode. Declare a run_python tool and let the model call it; the model writes from sympy import integrate, symbols and you execute it. When a request carries tools in thinking mode, pass the reasoning_content of all previous turns back to the API, or it returns a 400 error.

For full setup, see the DeepSeek API function calling guide.

3. Verified contest-math attempts

Contest problems reward depth over breadth. Use reasoning_effort="max" and ask for two solutions by different methods, then check that they agree. The pattern looks like this in Python:

import os
from openai import OpenAI
client = OpenAI(base_url="https://api.deepseek.com",
                api_key=os.environ.get("DEEPSEEK_API_KEY"))
resp = client.chat.completions.create(
    model="deepseek-v4-pro",   # or "deepseek-flash"
    messages=[{"role": "user",
               "content": "Find all integer solutions to "
                          "x^2 + y^2 = 2024. Solve twice using "
                          "two different methods, then verify "
                          "the answers agree. Put the result "
                          "within \\boxed{}."}],
    reasoning_effort="max",
    extra_body={"thinking": {"type": "enabled"}},
)
print(resp.choices[0].message.reasoning_content)  # the thinking
print(resp.choices[0].message.content)            # the answer

The response returns reasoning_content alongside the final content, so you can inspect the chain of working separately from the answer.

4. Word problems with hidden constraints

Applied math fails most often on units, edge cases, and unstated assumptions. The fix is to ask the model to list assumptions before solving. Prompt: “List every assumption you are making about units, sign conventions, and edge cases. Then solve. Then check that none of your assumptions contradicts the original problem.”

5. Long datasets with the 1M-token window

If you have a CSV of survey results, exam scores, or experimental data, both current models accept up to 1M tokens of context, so a sizeable file can go into a single request instead of a retrieval pipeline. Paste the data, ask for the analysis, and read the working. For repeating workflows, keep the system prompt identical so it is billed at the cache-hit rate — see DeepSeek context caching.

What it costs to use DeepSeek for math at scale

Reasoning is verbose. In thinking mode each answer includes reasoning_content as well as the final content, and both count as output tokens, so a hard problem can cost several times what its short final answer suggests. Below is a worked example for a tutoring-bot workload on deepseek-flash: 100,000 problems, a 1,500-token cached system prompt, a 250-token user question (cache miss), and a 4,000-token thinking-plus-answer response. Rates are USD per 1M tokens as of October 2026, from DeepSeek’s official pricing page; off-peak is half the peak rate.

Bucket (deepseek-flash) Tokens Peak rate → cost Off-peak rate → cost
Input, cache hit 1,500 × 100,000 = 150,000,000 150M × $0.006 = $0.90 150M × $0.003 = $0.45
Input, cache miss 250 × 100,000 = 25,000,000 25M × $0.30 = $7.50 25M × $0.15 = $3.75
Output (incl. reasoning) 4,000 × 100,000 = 400,000,000 400M × $1.20 = $480.00 400M × $0.60 = $240.00
Total $488.40 $244.20

On deepseek-v4-pro (cache hit $0.044 / $0.022, cache miss $1.32 / $0.66, output $3.96 / $1.98 per 1M tokens, peak / off-peak) the same workload costs $6.60 + $33.00 + $1,584.00 = $1,623.60 at peak and $3.30 + $16.50 + $792.00 = $811.80 off-peak. Peak hours are 01:00–04:00 and 06:00–10:00 UTC, Monday to Friday, excluding Chinese public holidays; everything else, including weekends, is billed at the off-peak rate. For a calculator that handles your specific numbers, see the DeepSeek pricing calculator and our DeepSeek API pricing guide. DeepSeek says prices may change, so check the official page before committing.

One trap to avoid: when thinking mode is enabled, set max_tokens high. A response cut off mid-reasoning has no final answer to check. Both current models allow up to 384K output tokens on the API, and for local deployment the DeepSeek-V4-Pro-0813 model card recommends a maximum output length of 384K tokens for the high and max effort levels.

The legacy specialists: DeepSeek Math 7B and DeepSeek Prover

Before R1 and the V4 generation, the lab shipped a dedicated 7B math model that still has its uses. According to DeepSeek’s paper (arXiv 2402.03300, February 2024), DeepSeekMath 7B continues pre-training DeepSeek-Coder-Base-v1.5 7B with 120B math-related tokens sourced from Common Crawl, together with natural language and code data. DeepSeek reported 51.7% on the competition-level MATH benchmark without external toolkits or voting, which the paper describes as approaching the performance level of Gemini-Ultra and GPT-4.

Two reasons to still care about it: its 7B weights (about 14 GB in bf16) fit on a single consumer GPU, and the same paper introduced Group Relative Policy Optimization (GRPO), a variant of PPO that drops the critic model and estimates the baseline from group scores, reducing training resources. GRPO is the reinforcement-learning recipe DeepSeek later used for R1. If you need a local, offline math model and cannot run a 70B distill, this is the one. For offline setup, see the guide on how to install DeepSeek locally.

For Lean 4 theorem proving — a much narrower use case — the DeepSeek Prover line is purpose-built for formally verified proofs.

Where DeepSeek still gets math wrong

Common failure patterns to plan for:

  • Long-form arithmetic without code. Long multiplications and divisions are error-prone in natural language. Route them through Python.
  • Geometry from word descriptions. Without a diagram, a model can misread orientations. Sketch first; deepseek-flash accepts images, so you can send the figure.
  • Probability with subtle conditioning. Conditional-probability traps can still fool reasoning models. Ask for the sample space explicitly.
  • Statistics on real data. The model can compute a t-test but may not catch when your data violates the test’s assumptions. You still need to know stats.
  • “Slick” proofs. Reasoning models can produce a long proof when a two-line one exists. Ask for “the shortest valid argument” if brevity matters.

For a broader breakdown, see DeepSeek limitations.

Honest alternatives for specific math sub-tasks

DeepSeek is not the right tool for every category. For exact symbolic computation, a computer algebra system such as SymPy or Wolfram|Alpha is built for exact results — and you can expose one to DeepSeek as a function tool (workflow 2). For formal proofs outside the DeepSeek Prover’s training distribution, Lean’s own proof checker remains the final arbiter. The practical framing: pick deepseek-flash for cost-efficient API math at scale, raise the reasoning effort for olympiad depth, and use external tools for symbolic exactness.

For broader head-to-heads, see DeepSeek vs ChatGPT and DeepSeek vs Claude.

Getting started for math

If you have never used DeepSeek for math before, the cheapest way to try the API is:

  1. Sign up and get a DeepSeek API key.
  2. Try a single call against POST /chat/completions with model="deepseek-flash" and reasoning_effort="high" (the default).
  3. Add a directive like “reason step by step, then put the final answer in \boxed{}” to your prompt.
  4. Read the reasoning_content as well as the content — the working is where errors hide.
  5. For repeated workloads, move shared instructions into a cached system prompt.

Note that the API is stateless: you must resend the conversation history with each request.

This use case lives in the broader DeepSeek use cases hub if you want to see how math compares to coding, research, or education workflows.

Is DeepSeek good at math?

DeepSeek’s own reported numbers are strong: 97.3% pass@1 on MATH-500 for R1 (January 2025 model card) and MathArena Apex 65.6 for the September 2026 V4.1-Flash build (Change Log, 10 Sep 2026). These are DeepSeek-reported results; check final answers yourself, especially for multi-step problems. For everyday calculus, statistics, and word problems, deepseek-flash in thinking mode is the place to start. See the DeepSeek performance review for more.

Which DeepSeek model is best for math homework?

For typical school and university homework, deepseek-flash in thinking mode is the lower-priced option. It returns reasoning_content alongside the final content, so students can read the working and check each step. For contest-level problems, raise reasoning_effort to "max" on deepseek-flash or deepseek-v4-pro; for offline use, an R1 distill or DeepSeek R1 itself runs on your own hardware.

How do I turn on thinking mode for math problems?

Through the API, thinking mode is on by default on both deepseek-flash and deepseek-v4-pro, at reasoning_effort="high"; to set it explicitly, pass extra_body={"thinking": {"type": "enabled"}}. Use "max" for the hardest problems, but raise max_tokens to avoid truncation. Worked examples live in the DeepSeek API getting started tutorial.

Can DeepSeek do calculus and linear algebra step by step?

Yes. With thinking mode on and a “reason step by step, put the final answer within \boxed{}” directive, the model returns a full chain of working for derivatives, integrals, eigenvalue problems, and matrix manipulations. For exact symbolic results, ask the model to call SymPy via tool use rather than computing in natural language. See DeepSeek prompt engineering for the exact prompt patterns.

What does it cost to solve a thousand math problems with DeepSeek?

On deepseek-flash as of October 2026, a thousand thinking-mode problems with a 1,500-token cached system prompt, a 250-token question and a 4,000-token response cost 1.5M × $0.006 + 0.25M × $0.30 + 4M × $1.20 = about $4.88 at peak, or 1.5M × $0.003 + 0.25M × $0.15 + 4M × $0.60 = about $2.44 off-peak. On deepseek-v4-pro the same workload costs about $16.24 at peak and $8.12 off-peak. The DeepSeek cost estimator gives a per-workload figure once you plug in your token counts.

Sources & Methodology

Last source check: October 27, 2026

Primary sources

  • OfficialDeepSeek API documentationEndpoints, request/response shape, model IDsLast checked: October 27, 2026
  • Official documentationDeepSeek pricing pagedeepseek-flash and deepseek-v4-pro peak/off-peak prices, peak hours, 1M context / 384K output, thinking defaultLast checked: October 27, 2026
  • Official documentationDeepSeek Change LogV4.1-Flash-1017 (17 Oct 2026) and V4-Pro-0813 (13 Aug 2026); MathArena Apex 65.6 for the September 2026 V4.1-Flash buildLast checked: October 27, 2026
  • Official newsDeepSeek V4.1-Flash release news, 10 Sep 2026Tests by multiple parties put V4.1-Flash ahead of V4-ProLast checked: October 27, 2026
  • Official documentationDeepSeek Thinking Mode guideThinking default; reasoning_effort; temperature not supported in thinking mode; reasoning_content pass-back with toolsLast checked: October 27, 2026
  • Official model cardDeepSeek-R1 model cardMATH-500 97.3 and AIME 2024 79.8 pass@1 (DeepSeek-reported, Jan 2025); math prompt directive; MIT licenseLast checked: October 27, 2026
  • Research paperDeepSeekMath paper (arXiv 2402.03300, Feb 2024)120B math tokens; 51.7% on MATH; GRPOLast checked: October 27, 2026
  • Official model cardDeepSeek-V4-Pro-0813 model card384K max output recommended for high/max effort in local deploymentLast checked: October 27, 2026

Technical references

Methodology

Information in this article was checked against the official DeepSeek documentation, the article's cited primary sources, and the deepseekai.guide pricing dataset on the date shown above. Where third-party numbers are quoted, the originating source is linked inline so the reader can verify and re-check.

Data confidence

High for facts cited inline with primary-source links; medium for context narrative.

Editorial note

AI tooling moves quickly. If you spot an outdated number or a broken link, the contact link in the footer is the fastest way to flag it for the editorial team.

Leave a Reply

Your email address will not be published. Required fields are marked *