# Can ChatGPT do math reliably?

Date: 2022-12-21 · Author: Robert Scales · https://guidetoartificialintelligence.com/en/learn/chatgpt-math-reliably/

**Answer:** Not reliably. ChatGPT is a language model that writes answers as text, so it can explain a method well and still slip on the arithmetic, especially in multi-step problems with larger numbers; asking it to work step by step helps, and a calculator check is still the final word.

ChatGPT can explain what a percentage is, walk through how to solve a pair of equations, and set up a word problem in a way many students find clearer than their textbook. Yet the same chatbot can get a multiplication wrong, and state the wrong product in the same confident tone. Both things are true for one reason: it is a language model, not a calculator.

A language model produces text one small piece at a time, choosing what is likely to come next given everything before it. When the next piece is a word in an explanation, "likely" and "right" usually line up. When the next piece is a digit in the middle of a long multiplication, there is no built-in arithmetic unit checking it. The model is producing digits that look right, and most of the time they are, which is exactly what makes the occasional error easy to miss.

## What the research shows

This is not new to ChatGPT. The 2020 paper that introduced GPT-3, the model family behind it, tested plain arithmetic. With a few examples in the prompt, the largest GPT-3 model got two-digit addition right every time and three-digit addition about 80 percent of the time, and accuracy kept falling as the numbers grew longer. Small numbers are easy; long ones are where slips appear.

Word problems add another difficulty: several steps, each depending on the last. One wrong intermediate number spoils the final answer. Two papers from Google and the University of Tokyo this year show that the way you ask matters a great deal here. Jason Wei and colleagues found that large models solve more multi-step math problems when the examples in the prompt show the reasoning written out, an approach they call **chain-of-thought prompting**. Takeshi Kojima and colleagues found that simply adding "Let's think step by step" before the answer, with no examples at all, raised the accuracy of an OpenAI model on one set of arithmetic word problems from about 18 percent to about 79 percent.

Both papers also show the limits. The written-out reasoning can contain a small error that carries through to the end, and the gains depend on a very large model. Step-by-step prompting makes errors rarer and easier to spot; it does not remove them.

## A worked example: the slip and the fix

Here is a typical problem:

```prompt
A school orders 14 boxes of pencils with 36 pencils in each box. It gives out 289 pencils. How many pencils are left?
```

An illustrative reply that goes straight to the answer might read: "The school has 14 × 36 = 494 pencils. After giving out 289, it has 205 pencils left." The method is right. The multiplication is wrong, so the answer is wrong, and nothing in the tone of the reply warns you.

Now ask for the steps, broken down so that each one is small:

```prompt
A school orders 14 boxes of pencils with 36 pencils in each box. It gives out 289 pencils. How many pencils are left?

Let's think step by step. Break any multiplication into smaller parts, show each intermediate result on its own line, and give the final answer on the last line.
```

An illustrative step-by-step reply:

| Step | Working | Result |
|---|---|---|
| 1 | 14 × 30 | 420 |
| 2 | 14 × 6 | 84 |
| 3 | 420 + 84 | 504 pencils in total |
| 4 | 504 − 289 | 215 pencils left |

Each line is now small enough to check in your head or on a calculator. That is the real benefit: even if the model slipped again, you would see on which line.

**The calculator check.** Type 14 × 36 − 289 into any calculator: it gives 215. Make this a habit for any number you plan to use, whether in homework, a budget or an invoice.

> **Try it:** Ask ChatGPT a two-step word problem with three-digit numbers, once plainly and once with "Let's think step by step" and a request to show each intermediate result. Check every line of both replies with a calculator and note where, if anywhere, they differ.

## How do you get it to show its working?

Ask for it explicitly, and say what form you want. "Let's think step by step" is the shortest version, and the Tokyo team found it worked better than other phrasings they tested. You can be more specific: "Show each calculation on its own line before giving the answer" or "Explain your method first, then do the arithmetic." Asking for a table, as in the example above, keeps every intermediate number in one place.

If you want the model to follow a particular method, show it one solved example in the prompt with the working written out, then give your new problem. That is the chain-of-thought approach from the Wei paper, and it is handy when you need answers in a consistent format, such as for a worksheet.

Then use the working as a checklist rather than a guarantee. Verify each line, starting with the multiplications and divisions, where slips are most likely. If a step is wrong, point to it ("Step 2 is wrong; 14 × 6 is 84. Please redo from there") and let it continue. For anything where the number matters, the calculator decides, and ChatGPT's job is to help you understand how the answer was reached.

## Sources

- Chain of Thought Prompting Elicits Reasoning in Large Language Models: https://arxiv.org/abs/2201.11903v3
- Large Language Models are Zero-Shot Reasoners: https://arxiv.org/abs/2205.11916v1
- Language Models are Few-Shot Learners: https://arxiv.org/abs/2005.14165
