abstract algebra25 min

Subgroups and Cosets

Subgroups live inside groups, and cosets partition groups into equal-sized pieces — leading to Lagrange theorem

0/9Not Started

Why This Matters

Once you know what a group is, the next question is: what structure lives inside it? A subgroup is a group hiding inside a larger group — a subset that is itself a group under the same operation. Finding subgroups reveals the internal architecture of an algebraic structure.

Cosets are what you get when you "shift" a subgroup by an element. They partition the entire group into equal-sized pieces with no overlap, like dividing a deck of cards into piles of the same size. This leads directly to Lagrange theorem, one of the most important results in group theory: the order (size) of every subgroup must divide the order of the group.

Lagrange theorem has immediate consequences. If a group has 12 elements, its subgroups can only have 1, 2, 3, 4, 6, or 12 elements — never 5, 7, 8, 9, 10, or 11. This constraint is used in cryptography to choose secure key sizes, in coding theory to design error-correcting codes, and in algorithm design to analyze symmetry-based optimizations.

Define Terms

Visual Model

Group GOrder |G| = 12
Subgroup HOrder |H| = 3
Coset 0+H{0, 4, 8}
Coset 1+H{1, 5, 9}
Coset 2+H{2, 6, 10}
Coset 3+H{3, 7, 11}
Lagrange Theorem|H| divides |G|
Index [G:H]Number of cosets = 4

The full process at a glance. Click Start tour to walk through each step.

Cosets of a subgroup partition the group into equal-sized pieces, proving Lagrange theorem.

Code Example

Code
// Subgroups and cosets in Z_n
const n = 12;

// Addition mod n
function addMod(a, b) {
  return ((a + b) % n + n) % n;
}

// Check if a subset is a subgroup of Z_n
function isSubgroup(subset) {
  // Must contain identity (0)
  if (!subset.includes(0)) return false;
  
  // Closure: a + b mod n must be in subset
  for (const a of subset) {
    for (const b of subset) {
      if (!subset.includes(addMod(a, b))) return false;
    }
  }
  
  // Inverses: for each a, (n - a) mod n must be in subset
  for (const a of subset) {
    if (!subset.includes(addMod(n - a, 0))) return false;
  }
  
  return true;
}

console.log("Is {0,4,8} a subgroup of Z_12?", isSubgroup([0, 4, 8]));
console.log("Is {0,3,6,9} a subgroup of Z_12?", isSubgroup([0, 3, 6, 9]));
console.log("Is {0,1,5} a subgroup of Z_12?", isSubgroup([0, 1, 5]));

// Compute the left coset g + H
function leftCoset(g, H) {
  return H.map(h => addMod(g, h)).sort((a, b) => a - b);
}

// Show all distinct cosets of H = {0, 4, 8}
const H = [0, 4, 8];
console.log("\nCosets of {0,4,8} in Z_12:");
const seen = new Set();
for (let g = 0; g < n; g++) {
  const coset = leftCoset(g, H);
  const key = coset.join(",");
  if (!seen.has(key)) {
    seen.add(key);
    console.log(`  ${g} + H = {${coset.join(", ")}}`);
  }
}

// Verify Lagrange theorem
console.log(`\nLagrange: |G|=${n}, |H|=${H.length}, cosets=${seen.size}`);
console.log(`  ${n} = ${H.length} * ${seen.size}? ${n === H.length * seen.size}`);

Interactive Experiment

Try these exercises:

  • Find all subgroups of Z_6. There should be subgroups of order 1, 2, 3, and 6. Verify each satisfies the subgroup test.
  • For Z_8, list the cosets of the subgroup consisting of 0 and 4. How many are there? Does the order of G divided by the order of H match?
  • Try to find a subgroup of Z_7 with 3 elements. Why is it impossible? (Hint: Lagrange theorem.)
  • Compute all subgroups of Z_12. Which orders appear? Do they match the divisors of 12?
  • Take the subgroup of even elements (0, 2, 4, 6, 8, 10) in Z_12. How many cosets does it have? What is the index?

Quick Quiz

Coding Challenge

Find All Subgroups and Verify Lagrange Theorem

Write a function called `findSubgroups` that takes an integer n and returns an array of all subgroups of Z_n (under addition mod n). Each subgroup should be an array of integers sorted in ascending order. The result array should be sorted by subgroup size (ascending). Then verify that every subgroup order divides n.

Loading editor...

Real-World Usage

Subgroups and cosets appear in many practical settings:

  • Cryptography: The security of elliptic curve cryptography depends on working within subgroups of specific orders. Lagrange theorem constrains which subgroup sizes are possible.
  • Error-correcting codes: Linear codes are subgroups of vector spaces. Cosets represent error patterns — decoding means finding which coset a received word belongs to.
  • Hash functions: Hash tables with a prime number of buckets relate to the structure of subgroups in Z_p.
  • Signal processing: The Discrete Fourier Transform exploits the subgroup structure of roots of unity in the complex numbers.
  • Chemistry: Molecular symmetry groups have subgroups corresponding to partial symmetries. Cosets organize symmetry transformations.

Connections