Solution (source code)

= Solution

Let $u$ be the <allele frequency> of $A$, with <random mating> and sufficiently large population size to neglect <genetic drift>. The <Hardy-Weinberg proportions> before selection are $u^2,2u(1-u),(1-u)^2$. Write the three <genotype fitnesses> as $w_{AA},w_{Aa},w_{aa}$, with $w_{Aa}$ smaller than either <homozygote> value. After one viability-selection generation,
$$
u'=\frac{w_{AA}u^2+w_{Aa}u(1-u)}{\bar w},
\qquad \bar w=w_{AA}u^2+2w_{Aa}u(1-u)+w_{aa}(1-u)^2.
$$
Consequently
$$
u'-u=\frac{u(1-u)}{\bar w}
\left[(w_{AA}-w_{Aa})u-(w_{aa}-w_{Aa})(1-u)\right].
$$
Put $a=w_{AA}-w_{Aa}>0$, $b=w_{aa}-w_{Aa}>0$. The <underdominant allele-frequency dynamics> has stable fixation states zero and one, separated by the unstable threshold
$$
\boxed{u_c=\frac b{a+b}.}
$$
Below it $A$ decreases to <allele fixation> of $a$; above it $A$ increases to fixation. Exactly at the threshold the deterministic frequency remains balanced, but any perturbation selects a side. This is <underdominance>, or <heterozygote disadvantage>, rather than balancing selection from <heterozygote advantage>.

In a continuous-time weak-selection or selection-rate convention, the corresponding equation is $\dot u=u(1-u)[(a+b)u-b]$. Equal <homozygote> fitness gives $\dot u=su(1-u)(2u-1)$ for a positive selection strength $s$. The next part uses this explicitly stated continuous-time convention; $s$ and migration then have the same time units.