A ring is a set R with two operations, addition and multiplication, that satisfy the following rules. Under addition, R is an abelian group: addition is associative and commutative, there is a zero element 0, and every element a has a negative -a. Multiplication is associative and has an identity element 1. The two operations are linked by the distributive laws a(b + c) = ab + ac and (a + b)c = ac + bc [1].
Division is not part of the definition. In the integers \mathbb{Z} we can add, subtract and multiply freely, but \frac{1}{2} is not an integer. Other examples are the polynomials with real coefficients, and the real-valued functions on a set with pointwise addition and multiplication.
In the figure, the rectangle with sides a and b + c splits into rectangles with sides a, b and a, c, so its area a(b + c) equals ab + ac. In a general ring the distributive law is an axiom rather than a fact about areas, but it says the same thing.
A ring is commutative when ab = ba for all elements a and b. The real 2 \times 2 matrices form a ring that is not commutative. Let A be the shear (x, y) \mapsto (x + y, y) and B the rotation by 90 degrees, (x, y) \mapsto (-y, x).
The product AB applies B first and then A, and BA applies them in the other order. The figure applies both products to the unit square. The two images are different parallelograms, so AB \neq BA.
From now on, every ring is commutative. Commutative rings appear throughout number theory and algebraic geometry, and they are the subject of every article in this section [1].
For a commutative ring k, the polynomials a_0 + a_1x + \cdots + a_nx^n with coefficients in k form a commutative ring k[x]. Polynomials are added coefficient by coefficient. If f = \sum_i a_ix^i and g = \sum_j b_jx^j, the coefficient of x^n in the product fg is \sum_i a_ib_{n-i}.
In the figure, the coefficients of f = 1 + 2x - x^2 and g = 1 + x + 2x^2 are drawn as bars. The coefficients of g are reversed and shifted one step at a time, and each coefficient of fg = 1 + 3x + 3x^2 + 3x^3 - 2x^4 is the sum of the products of the coefficients that line up.
Only addition and multiplication of coefficients are used, so the same construction works over any commutative ring, for example \mathbb{Z}[x] or (\mathbb{Z}/12)[x].
An element u of R is a unit when there is an element v with uv = 1. The units of \mathbb{Z} are 1 and -1, and the units of k[x] for a field k are the nonzero constants. The units form a group under multiplication, written R^\times.
In \mathbb{Z}/12, the ring of residues modulo 12, the units are the residues prime to 12: 1, 5, 7 and 11. For example, 5 \cdot 5 = 25 = 1 in \mathbb{Z}/12.
The figure draws multiplication by a on \mathbb{Z}/12 as arrows from x to ax. When a is a unit, multiplication by a^{-1} undoes multiplication by a, so the arrows end at different residues. When a is not a unit, two arrows end at the same residue and some residue receives no arrow.
A nonzero element a is a zero divisor when ab = 0 for some nonzero b. In \mathbb{Z}/12 we have 3 \cdot 4 = 0, so 3 and 4 are zero divisors. A zero divisor is never a unit: if uv = 1 and ub = 0, then b = vub = 0.
Zero divisors also appear among functions. In the ring of continuous functions on an interval, take f and g that are nonzero only on two separate parts of the interval. At every point one of them is 0, so fg = 0 although neither f nor g is 0.
In the figure the two bumps move toward each other and apart again. While their nonzero parts overlap, the product fg is nonzero, and once they separate, fg is the zero function.
A commutative ring is an integral domain when 1 \neq 0 and it has no zero divisors. In an integral domain we can cancel nonzero factors: if ab = ac and a \neq 0, then a(b - c) = 0, so b = c.
The integers, the polynomial ring k[x] over a field k, and the Gaussian integers \mathbb{Z}[i] = \{a + bi \mid a, b \in \mathbb{Z}\} are integral domains. A subring of the field \mathbb{C} has no zero divisors, because \mathbb{C} has none.
The figure multiplies the Gaussian integers by numbers moving from 1 to 2 + i. Multiplication by 2 + i rotates the plane and stretches it by \sqrt{5}, so different points stay different. The image is a coarser square lattice, the multiples of 2 + i.
A commutative ring is a field when 1 \neq 0 and every nonzero element is a unit. The rational numbers, the real numbers and the complex numbers are fields, and so is \mathbb{Z}/p for every prime p.
Every finite integral domain is a field. If a \neq 0, multiplication by a is injective by cancellation, and an injective map from a finite set to itself is surjective, so ab = 1 for some b [2].
The figure joins each residue to its inverse. In \mathbb{Z}/7 every nonzero residue has a partner: 2 \cdot 4 = 1 and 3 \cdot 5 = 1, while 1 and 6 are their own inverses. In \mathbb{Z}/8 the residues 2, 4 and 6 have no partner, because \mathbb{Z}/8 has zero divisors such as 2 \cdot 4 = 0.
A subring of R is a subset that contains 1 and is closed under addition, subtraction and multiplication. Examples are \mathbb{Z} \subset \mathbb{Z}[i] \subset \mathbb{C} and the even polynomials \mathbb{Z}[x^2] \subset \mathbb{Z}[x].
The fractions whose denominator is a power of 2 form a subring \mathbb{Z}[\frac{1}{2}] of \mathbb{Q}: sums and products of such fractions again have a power of 2 as denominator. But \frac{1}{3} is not in \mathbb{Z}[\frac{1}{2}], so a subring does not have to be closed under division.
The figure adds the ticks for the denominators 2, 4, 8 and 16 between 0 and 1. The product \frac{1}{2} \cdot \frac{3}{4} = \frac{3}{8} and the sum \frac{1}{4} + \frac{3}{8} = \frac{5}{8} land on ticks, while \frac{1}{3} lies strictly between \frac{5}{16} and \frac{6}{16}, and no finer tick ever reaches it.
A ring homomorphism \varphi\colon R \to S is a map with \varphi(a + b) = \varphi(a) + \varphi(b), \varphi(ab) = \varphi(a)\varphi(b) and \varphi(1) = 1. Taking residues gives a homomorphism \mathbb{Z} \to \mathbb{Z}/n, and substituting a value for x gives a homomorphism from a polynomial ring.
Substituting x = i gives the homomorphism \mathbb{R}[x] \to \mathbb{C}, f \mapsto f(i). In the figure, f(i) = a_0 + a_1i + a_2i^2 + a_3i^3 is drawn as a path of arrows: each power of i turns the direction by 90 degrees, and the path ends at f(i).
The polynomials sent to 0 form the kernel. Since i^2 + 1 = 0, every multiple of x^2 + 1 is in the kernel, and when f = (x^2 + 1)(1 + x) the path returns to the origin. Conversely, a real polynomial with f(i) = 0 also has f(-i) = 0, so the kernel consists exactly of the multiples of x^2 + 1. The kernel is closed under addition and under multiplication by any polynomial, and such a subset of a ring is called an ideal.