In most cases, style guides favour words over numbers below a certain amount (that amount differing with the style guide, but commonly around a hundred) or precision (again, varying with the style guide, but one might have e.g. "a half" while also having e.g. "0.03").
With mathematical writing, and other technical and scientific contexts though:
- The number has a value to the understanding greater than in other writing.
- The cases where a style guide would favour digits are likely higher in the text as a whole, and using digits throughout will likely read more consistent.
With the last case in particular, even for non-technical cases, we would not mix highly, e.g.
They increased the amount from ten to a thousand and thirty-nine.
They increased the amount from 10 to 1,039.
?They increased the amount from ten to 1,039.
The third would likely not be favoured by many.
So, bearing these two points in mind, it makes good sense to strongly favour digits over words.
It is though, a matter of style rather than correctness, so a given style guide might insist otherwise, but do check if there are exceptions or allowances made by that style guide for technical matters.