ArticleslgStudy

mathematics

Residue number system

Residue number system is a mathematics topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Residue number system rather than just read about it. In short: A residue number system or residue numeral system (RNS) is a numeral system representing integers by their values modulo several pairwise coprime integers called the moduli. This representation is allowed by the Chinese remainder theorem, which asserts that, if M is the product of the moduli, there is, in an interval of length M, exactly one integer having any given set of modular values.

Key takeaways

  • Residue number system belongs to mathematics; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Residue number system to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Residue number system from memory before moving on to harder problems.

Reference excerpt

A residue number system or residue numeral system (RNS) is a numeral system representing integers by their values modulo several pairwise coprime integers called the moduli. This representation is allowed by the Chinese remainder theorem, which asserts that, if M is the product of the moduli, there is, in an interval of length M, exactly one integer having any given set of modular values. Using a residue numeral system for arithmetic operations is also called multi-modular arithmetic. Multi-modular arithmetic is widely used for computation with large integers, typically in linear algebra, because it provides faster computation than with the usual numeral systems, even when the time for converting between numeral systems is taken into account. Other applications of multi-modular arithmetic include polynomial greatest common divisor, Gröbner basis computation and cryptography.

Definition A residue numeral system is defined by a set of k integers

{ m 1 , m 2 , m 3 , … , m k } , {\displaystyle \{m_{1},m_{2},m_{3},\ldots ,m_{k}\},}

called the moduli, which are generally supposed to be pairwise coprime (that is, any two of them have a greatest common divisor equal to one). Residue number systems have been defined for non-coprime moduli, but are not commonly used because of worse properties. An integer x is represented in the residue numeral system by the family of its remainders (indexed by the moduli of the indexes of the moduli)

{ x 1 , x 2 , x 3 , … , x k } {\displaystyle \{x_{1},x_{2},x_{3},\ldots ,x_{k}\}}

under Euclidean division by the moduli. That is

x i = x mod ⁡ m i , {\displaystyle x_{i}=x\operatorname {mod} m_{i},}

and

0 ≤ x i < m i {\displaystyle 0\leq x_{i}<m_{i}}

for every i Let M be the product of all the m i {\displaystyle m_{i}} . Two integers whose difference is a multiple of M have the same representation in the residue numeral system defined by the mis. More precisely, the Chinese remainder theorem asserts that each of the M different sets of possible residues represents exactly one residue class modulo M. That is, each set of residues represents exactly one integer X {\displaystyle X} in the interval 0 , … , M − 1 {\displaystyle 0,\dots ,M-1} . For signed numbers, the dynamic range is − ⌊ M / 2 ⌋ ≤ X ≤ ⌊ ( M − 1 ) / 2 ⌋ {\textstyle {-\lfloor M/2\rfloor }\leq X\leq \lfloor (M-1)/2\rfloor }

(when M {\displaystyle M} is even, generally an extra negative value is represented).

Arithmetic operations For adding, subtracting and multiplying numbers represented in a residue number system, it suffices to perform the same modular operation on each pair of residues. More precisely, if

[ m 1 , … , m k ] {\displaystyle [m_{1},\ldots ,m_{k}]}

is the list of moduli, the sum of the integers x and y, respectively represented by the residues [ x 1 , … , x k ] {\displaystyle [x_{1},\ldots ,x_{k}]} and [ y 1 , … , y k ] , {\displaystyle [y_{1},\ldots ,y_{k}],} is the integer z represented by [ z 1 , … , z k ] , {\displaystyle [z_{1},\ldots ,z_{k}],} such that

z i = ( x i + y i ) mod ⁡ m i , {\displaystyle z_{i}=(x_{i}+y_{i})\operatorname {mod} m_{i},}

for i = 1, ..., k (as usual, mod denotes the modulo operation consisting of taking the remainder of the Euclidean division by the right operand). Subtraction and multiplication are defined similarly. For a succession of operations, it is not necessary to apply the modulo operation at each step. It may be applied at the end of the computation, or, during the computation, for avoiding overflow of hardware operations. However, operations such as magnitude comparison, sign computation, overflow detection, scaling, and division are difficult to perform in a residue number system.

… excerpt ends here. Continue reading the full article.

Worked examples

Example 1 — a first encounter with Residue number system

Start with the simplest possible case. Write down what Residue number system claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In mathematics, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Residue number system before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Residue number system ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Residue number system

In research
Residue number system appears in mathematics research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Residue number system in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Residue number system is common in secondary-school and first-year university syllabi. It links to neighbouring topics Computer arithmetic, Modular arithmetic, so understanding it makes those chapters shorter.
In everyday life
Look for Residue number system outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.

Affiliate

Preply — study more efficiently by working with a personal tutor. 50% off.

How to study Residue number system in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Residue number system means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Residue number system out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Residue number system in simple terms?

A residue number system or residue numeral system (RNS) is a numeral system representing integers by their values modulo several pairwise coprime integers called the moduli. This representation is allowed by the Chinese remainder theorem, which asserts that, if M is the product of the moduli, there…

Why does Residue number system matter?

Because it connects several mathematics ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Residue number system?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Residue number system.

Tags

  • Computer arithmetic
  • Modular arithmetic

Keep exploring