Solution (source code)

= Solution

The <Elston-Stewart algorithm> first sums over the child:
$$
L=\sum_{g=0}^1a_gp_g\left(b_0t_{0\mid g}+b_1t_{1\mid g}\right).
$$
For each of the two parent states, the inner message requires two multiplications and one addition, totaling four multiplications and two additions. Multiplying each message by its two parent factors takes two further multiplications per parent state, totaling four. The final sum uses one addition. Therefore
$$
\boxed{8\text{ multiplications},\qquad3\text{ additions}.}
$$
Moving the sum inward saves four multiplications because the factors independent of the child <genotype> are evaluated only once per parent state.