# LogTo("/home/wdj/gapfiles/comp_forms1.log"); composition:=function(F1,F2) #buell's thrm 7.8 local d1,d2,m,D,a1,b1,c1,a2,b2,c2,n1,n2,L1,L2,exps1,exps2,sqrfreed1,sqrfreed2,B,eqn1,eqn2,eqn3; a1:=F1[1];b1:=F1[2];c1:=F1[3]; a2:=F2[1];b2:=F2[2];c2:=F2[3]; d1:=b1^2-4*a1*c1; d2:=b2^2-4*a2*c2; L1:=PrimePowersInt(d1); exps1:=List([1..(Length(L1)/2)],i->L1[2*i]); sqrfreed1:=Product(List([1..Length(exps1)],i->L1[2*i-1]^(exps1[i] mod 2))); n1:=Int(Sqrt(d1/sqrfreed1)); L2:=PrimePowersInt(d2); exps2:=List([1..(Length(L2)/2)],i->L2[2*i]); sqrfreed2:=Product(List([1..Length(exps2)],i->L2[2*i-1]^(exps2[i] mod 2))); n2:=Int(Sqrt(d2/sqrfreed2)); if d1/n1^2 <> d2/n2^2 then Print("discrimants must be same mod squares\n"); return; fi; D:=d1/n1^2; m:=Gcd(a1*n2,a2*n1,(b1*n2+b2*n1)/2); for B in [1..AbsoluteValue(4*a1*a2)] do eqn1:=(m*n1*B mod (2*a1)=m*b1 mod (2*a1)); eqn2:=(m*n2*B mod (2*a2)=m*b2 mod (2*a2)); eqn3:=(m*(b1*n2+b2*n1)*B mod (4*a1*a2)=m*(b1*b2+D*n1*n2) mod (4*a1*a2)); #Print(eqn1,eqn2,eqn3,B,"\n"); if (eqn1 and eqn2 and eqn3) then return [a1*a2/m^2,B,(B^2-D)*m^2/(4*a1*a2)]; fi; od; Print("no soln\n"); end;