print(`This is Project 1.txt`); print(`by Rachel Adelman, Sophie Droppa, Anna Janik, and Sydney Yao`); Help := proc() if nargs = 0 then print("Table of Contents"); elif nargs = 1 and args[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 nargs = 1 and args[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: #Classical HW 3 Variable Transformation HW := proc(u,v,w) [u^2 + u*v + (1/4)*v^2, u*v + 2*u*w + (1/2)*v^2 + v*w, (1/4)*v^2 + v*w + w^2]; end proc: #HW 2 Variable transformation HW:= proc(u,v) local w; w := 1 - u - v; expand([ u^2 + u*v + (1/4)*v^2, u*v + 2*u*w + (1/2)*v^2 + v*w ]); end proc: # Generalized HW with 3 variable HWg := proc(u,v,w,M) local LI, tot; LI := [ M[1][1]*u^2 + (M[1][2] + M[2][1])/2 * u*v + M[2][2]*(1/4)*v^2, (M[1][2]+M[2][1])/2*u*v + (M[1][3]+M[3][1])*u*w + M[2][2]/2*v^2 + (M[2][3]+M[3][2])/2*v*w, M[2][2]*(1/4)*v^2 + (M[2][3]+M[3][2])/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: #HW Generalized 2 Variable 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: