A guide with practice problems
The Hardy–Weinberg equation
What p² + 2pq + q² = 1 means, the four kinds of problem it solves plus the test, and as many practice problems as you want, each with its working.
On this page
The Hardy–Weinberg equation is p² + 2pq + q² = 1. It says that if a gene has two alleles, A with frequency p and a with frequency q, then in a randomly mating population with no other force acting, the three genotypes occur in the shares p² (AA), 2pq (Aa) and q² (aa). It is the expansion of (p + q)², and the reason is that a new individual is two independent draws from the population’s pool of gene copies[1][2]. This page is the working guide: what each symbol means, the four kinds of problem it answers (plus the chi-square test of whether a sample fits), and a problem generator to practise on. The full argument, with real blood-group data, is in Chapter 1.
The two equations and what each symbol means
p and q are allele frequencies: the share of all gene copies in the population that are A, and that are a. They add to 1 because there are only two alleles. p², 2pq and q² are genotype frequencies: the share of individuals that are AA, Aa and aa. They add to 1 because every individual is one of the three.
The squaring comes from probability. Picking two gene copies at random, both are A with probability p × p and both are a with probability q × q. One of each can happen in two orders, A then a or a then A, which is why the middle term has a 2. Nothing else goes in; that is the whole derivation, and it holds whatever the parents’ genotypes were, after one generation of random mating. established
Solving a problem: always find q first when there is dominance
Most textbook problems give one number and ask for another. The safe method has three steps.
- Find a number you can trust. If you are given genotype counts, count alleles: p = (2 × AA + Aa) / 2n. If one allele is dominant, you cannot tell AA from Aa, so the only class you can count is the recessive one, aa, whose share is q².
- Get q, then p. q = √(share of aa); p = 1 − q.
- Use the equation. Carriers are 2pq, dominant homozygotes p². Multiply by the population size to get numbers of individuals.
A worked example. A recessive trait shows up in 1 in 2,500 individuals. Then q² = 1/2,500 = 0.0004, so q = 0.02 and p = 0.98. Carriers: 2pq = 2 × 0.98 × 0.02 = 0.0392, about 1 in 26. Carriers outnumber affected individuals by nearly 100 to 1, which is why selection against a rare recessive is so slow (Chapter 2 shows it).
The commonest mistake goes the other way: told that 84 % show a dominant trait, students set p² = 0.84. But heterozygotes show the trait too. The right start is q² = 1 − 0.84 = 0.16, so q = 0.4 and p = 0.6.
Hardy–Weinberg calculator
Enter whichever number you have: the share of people with a recessive trait (as q², a percentage or 1 in X), the share with a dominant trait, p, q, or genotype counts. The calculator finds q first, as above, and shows each step. It also has its own page, with the chi-square test underneath.
Hardy–Weinberg practice problems
Choose a kind of problem, type your answer and press Check. Show the working gives the solution step by step. New problem draws fresh numbers, so you can practise as long as you like, and Share gives a link to the exact problem on your screen.
Testing whether a sample fits
The equation also gives a test. Count the genotypes in a sample, estimate p from them, compute the expected counts p²n, 2pqn and q²n, and add (observed − expected)²/expected over the three classes. That is the chi-square statistic, with one degree of freedom (three classes, minus one because they add to n, minus one because p was estimated from the same data). Above 3.84, the departure would occur less than 5 % of the time by sampling alone[2]. For small samples the exact test of Wigginton and colleagues is better[3]. The test calculator below runs both, on your counts or on real MN blood-group samples. established
When the equation does not apply
The equation describes a population with random mating, no selection, no mutation, no migration and a size large enough that chance can be ignored. Each assumption that fails is a force with its own chapter: Natural selection, Genetic drift, Gene flow. Non-random mating (inbreeding, or a sample that pools two groups) changes the genotype shares without changing p, and shows up as too few heterozygotes. In practice the equation is a null model: the interesting question is usually which assumption a real population breaks, and by how much.