Hardy-Weinberg Calculator
Solve all Hardy-Weinberg equations — p, q, p², 2pq, and q² — from any single known value or observed counts, with complete step-by-step working. The fastest Hardy-Weinberg equilibrium calculator online.
| Genotype | Observed Count | Observed Freq. | HW Expected Freq. | Difference |
|---|
Allele frequencies derived from observed counts: p = (2×AA + Aa)/(2N), q = (2×aa + Aa)/(2N). HW expected frequencies use these observed p and q values.
Enter either p or q to instantly calculate all three genotype frequencies (p², 2pq, q²) and see a visual stacked bar.
Stacked Genotype Bar
Enter observed allele counts to calculate p and q. Example: out of 200 total alleles, 140 are A → p = 0.70, q = 0.30.
Enter p or q to find the expected phenotype frequencies. Recessive phenotype = q². Dominant phenotype = p² + 2pq.
Our companion guide covers when Hardy-Weinberg applies, all five equilibrium conditions in detail, and 15 fully solved practice problems.
The Hardy-Weinberg Equations Explained
This Hardy-Weinberg calculator solves both fundamental Hardy-Weinberg equations simultaneously from any single known value — giving you p, q, p², 2pq, and q² in one click. Named after G.H. Hardy and Wilhelm Weinberg (1908), the Hardy-Weinberg principle describes the allele and genotype frequency distribution in a non-evolving population.
The Hardy-Weinberg principle rests on two equations that must both hold true simultaneously:
What Each Variable Means
| Symbol | Meaning | Genotype / Phenotype | Range |
|---|---|---|---|
| p | Frequency of the dominant allele (A) | Allele frequency | 0 to 1 |
| q | Frequency of the recessive allele (a) | Allele frequency | 0 to 1 |
| p² | Frequency of homozygous dominant genotype | AA individuals | 0 to 1 |
| 2pq | Frequency of heterozygous genotype | Aa individuals (carriers) | 0 to 0.5 |
| q² | Frequency of homozygous recessive genotype | aa individuals (show recessive trait) | 0 to 1 |
What Is Hardy-Weinberg Equilibrium in Plain Language?
A population is in Hardy-Weinberg equilibrium when its allele frequencies stay exactly the same from generation to generation — it is not evolving. Think of it as a genetic "null hypothesis": if the Hardy-Weinberg equation holds, nothing is driving evolution in that population.
The Five Hardy-Weinberg Conditions
If any of the five Hardy-Weinberg conditions is violated, allele frequencies will change and the population is evolving. Real populations rarely satisfy all five conditions perfectly — but the Hardy-Weinberg equation provides an essential baseline for detecting evolutionary forces.
All 5 conditions explained with real examples, plus 15 fully solved Hardy-Weinberg practice problems.
How to Use the Hardy-Weinberg Equation — Step-by-Step
The method you use depends on what information is given. Here is the complete four-mode approach used in this Hardy-Weinberg equilibrium calculator:
Mode A — Starting From q² (Most Common Exam Problem)
- Identify q² from the problem: "X% of the population shows the recessive phenotype" → q² = X/100
- Calculate q = √(q²) using a square root
- Calculate p = 1 − q (from p + q = 1)
- Calculate p² = p × p (homozygous dominant frequency)
- Calculate 2pq = 2 × p × q (heterozygous/carrier frequency)
- Verify: p² + 2pq + q² = 1 ✓
Mode B — Starting From p (Dominant Allele Frequency Known)
- Use p + q = 1 → q = 1 − p
- Calculate p² = p × p
- Calculate 2pq = 2 × p × q
- Calculate q² = q × q
Mode C — Starting From q (Recessive Allele Frequency Known)
- Use p + q = 1 → p = 1 − q
- Continue as Mode B
Mode D — Starting From Observed Counts (AA, Aa, aa)
- Total N = AA + Aa + aa
- Total alleles = 2N (each individual carries 2 alleles)
- p = (2×AA + Aa) / (2N) — count all A alleles, divide by total alleles
- q = (2×aa + Aa) / (2N) — count all a alleles, divide by total alleles
- Expected: p², 2pq, q² — compare to observed q²=aa/N, 2pq=Aa/N, p²=AA/N
- Note: observed q² = aa/N (divided by total individuals, not total alleles)
Worked Example 1 — Classic q² Problem (Mode A)
Problem: 9% of a population shows the recessive phenotype. Find all allele and genotype frequencies.
- q² = 0.09 (9% = 0.09)
- q = √0.09 = 0.30
- p = 1 − 0.30 = 0.70
- p² = 0.70 × 0.70 = 0.49 (49% AA)
- 2pq = 2 × 0.70 × 0.30 = 0.42 (42% Aa carriers)
- Verify: 0.49 + 0.42 + 0.09 = 1.00 ✓
Worked Example 2 — Given p (Mode B)
Problem: The dominant allele frequency is p = 0.6. Find all frequencies.
- p = 0.6 (given)
- q = 1 − 0.6 = 0.4
- p² = 0.6² = 0.36 (36% AA)
- 2pq = 2 × 0.6 × 0.4 = 0.48 (48% Aa)
- q² = 0.4² = 0.16 (16% aa)
- Verify: 0.36 + 0.48 + 0.16 = 1.00 ✓
Worked Example 3 — Observed Counts (Mode D)
Problem: In a sample of 1000 individuals: 640 AA, 320 Aa, 40 aa. Are they in Hardy-Weinberg equilibrium?
- N = 640 + 320 + 40 = 1000
- Total alleles = 2 × 1000 = 2000
- p = (2×640 + 320) / 2000 = 1600/2000 = 0.80
- q = (2×40 + 320) / 2000 = 400/2000 = 0.20
- HW Expected: p²=0.64, 2pq=0.32, q²=0.04
- Observed: AA/N=0.64, Aa/N=0.32, aa/N=0.04
- Difference: 0% — population IS in Hardy-Weinberg equilibrium ✓
What Does p Represent in the Hardy-Weinberg Principle?
In the Hardy-Weinberg equation, p represents the frequency of the dominant allele in the gene pool of a population. It is a proportion between 0 and 1, where p = 1 means every allele in the population is dominant (A), and p = 0 means no dominant alleles exist.
For a gene with two alleles (A dominant, a recessive), p counts the fraction of all alleles in the population that are the A version:
- p = (number of A alleles) / (total number of alleles) = (2×AA + Aa) / (2N)
- Each AA individual contributes 2 A alleles; each Aa individual contributes 1 A allele
- p is related to q by the Hardy-Weinberg allele equation: p + q = 1
p is an allele frequency, not a genotype frequency. The genotype frequency of AA individuals is p² (not p). This distinction is one of the most common sources of confusion in Hardy-Weinberg problems.
What Does q Represent in Hardy-Weinberg?
In the Hardy-Weinberg equation, q represents the frequency of the recessive allele in the population. Like p, it is a proportion between 0 and 1. When you know q, you can find p instantly using p = 1 − q, because p + q = 1.
- q = (number of a alleles) / (total number of alleles) = (2×aa + Aa) / (2N)
- The most common Hardy-Weinberg starting point: q² is observable (recessive phenotype), q = √(q²)
- q² is the genotype frequency of homozygous recessive (aa) individuals — the ones who show the recessive trait
Worked Examples — Six Full Solutions
Example 1 — Cystic Fibrosis Style: q² = 0.09
- q² = 0.09 → q = √0.09 = 0.30
- p = 1 − 0.30 = 0.70
- p² = 0.49 | 2pq = 0.42 | q² = 0.09
- In 10,000 individuals: 4,900 AA, 4,200 Aa, 900 aa
- Verify: 0.49 + 0.42 + 0.09 = 1 ✓
Example 2 — Given p = 0.6 (Mode B)
- p = 0.6, q = 0.4 (via p + q = 1)
- p² = 0.36 | 2pq = 0.48 | q² = 0.16
- In 10,000: 3,600 AA, 4,800 Aa, 1,600 aa
- Verify: 0.36 + 0.48 + 0.16 = 1 ✓
Example 3 — Given q = 0.3 (Mode C)
- q = 0.3, p = 1 − 0.3 = 0.7
- p² = 0.49 | 2pq = 0.42 | q² = 0.09
- Same result as Example 1 — q=0.3 and q²=0.09 are equivalent starting points
- Verify: 0.49 + 0.42 + 0.09 = 1 ✓
Example 4 — Rare Recessive: q² = 0.01
- q² = 0.01 → q = √0.01 = 0.10
- p = 1 − 0.10 = 0.90
- p² = 0.81 | 2pq = 0.18 | q² = 0.01
- Key insight: 18% are carriers (Aa) but only 1% show the recessive phenotype (aa)
- Verify: 0.81 + 0.18 + 0.01 = 1 ✓
Example 5 — Observed Counts: 640 AA, 320 Aa, 40 aa (Mode D)
- N = 1000, total alleles = 2000
- p = (1280 + 320)/2000 = 0.80
- q = (80 + 320)/2000 = 0.20
- HW Expected: p²=0.64, 2pq=0.32, q²=0.04
- Observed: 0.640, 0.320, 0.040 — Difference ≈ 0% → In equilibrium ✓
Example 6 — Given p² Only: p² = 0.49
- p = √0.49 = 0.70
- q = 1 − 0.70 = 0.30
- p² = 0.49 | 2pq = 2×0.7×0.3 = 0.42 | q² = 0.09
- Verify: 0.49 + 0.42 + 0.09 = 1 ✓
Frequently Asked Questions
Related Calculators
Master Hardy-Weinberg with 15 fully solved problems, detailed explanations of all 5 equilibrium conditions, and exam-ready tips.
Share This Tool
Share the Hardy-Weinberg Calculator with students!