> print(`This is Project 1.txt`); > print(`by Rachel Adelman, Sophie Droppa, Anna Janik, and Sydney Yao`); > Help := proc() if _npassed = 0 then print("Table of Contents"); elif _npassed = 1 and _passed[1] = HW then print(`HW(u,v): The classical Hardy-Weinberg underlying transformation`); print(`with genotype frequencies (u,v,w) using w = 1 - u - v.`); print(`Try:`); print(`HW(u,v);`); elif _npassed = 1 and _passed[1] = HWg then print(`HWg(u,v,M): The generalized Hardy-Weinberg transformation`); print(`that uses a positive 3×3 mating/survival matrix M.`); print(`Based on the full three-type system (u,v,w).`); print(`Try:`); print(`HWg(u,v, [[1,1,1],[1,1,1],[1,1,1]]);`); end if; end proc; > HW := proc(u, v, w) [u^2 + v*u + 1/4*v^2, v*u + 2*u*w + 1/2*v^2 + v*w, 1/4*v^2 + v*w + w^2]; end proc; > HW := proc(u, v) local w; w := 1 - u - v; expand([u^2 + v*u + 1/4*v^2, v*u + 2*u*w + 1/2*v^2 + v*w]); end proc; > HWg := proc(u, v, w, M) local LI, tot; LI := [M[1][1]*u^2 + (1/2*M[1][2] + 1/2*M[2][1])*u*v + 1/4*M[2][2]*v^2, (1/2*M[1][2] + 1/2*M[2][1])*u*v + (M[1][3] + M[3][1])*u*w + 1/2*M[2][2]*v^2 + (1/2*M[2][3] + 1/2*M[3][2])*v*w, 1/4*M[2][2]*v^2 + (1/2*M[2][3] + 1/2*M[3][2])*v*w + M[3][3]*w^2]; tot := LI[1] + LI[2] + LI[3]; [LI[1]/tot, LI[2]/tot, LI[3]/tot]; end proc; > HWg := proc(u, v, M) local w, LI; w := 1 - u - v; LI := HW3g(u, v, w, M); normal([LI[1], LI[2]]); end proc;