# $Source: /u/maple/research/lib/algcurves/src/RCS/genus,v $ # $Notify: mvanhoei@daisy.uwaterloo.ca $ macro( RAD={radical,nonreal}, genus=`algcurves/genus` ): # f is a polynomial in x and y genus:=proc(f,x::name,y::name) local F,d,X,Y,i; options remember, `Copyright (c) 1996 Waterloo Maple Inc. All rights reserved. Author: M. van Hoeij`; if nargs>3 and args[nargs]=`irr check` then F:=evala(AFactors(f)); if nops(F[2])>1 or F[2][1][2]>1 then args[1],"factored as",F else procname(f,x,y) fi elif not type(f,polynom(anything,[x,y])) then error "wrong type of arguments" elif indets(f,RAD)<>{} then procname(subs(radfield(f)[1],f),x,y) else # The following is to ensure that degree(..) gives the right answer. Normalizer:=`if`(has(f,RootOf),`evala/Normal`,normal); F:=collect(primpart(f,{x,y}),{x,y},'distributed',Normalizer); d,X,Y:=degree(F,{x,y}),degree(F,x),degree(F,y); i:=d-ldegree(F,{x,y}); if d<1 then error "degree is zero" elif d>1 and (i=0 or X*Y<1 or has(evala(Content(f,x)),y) or has(evala(Content(f,y)),x)) then WARNING( "curve failed simple reducibility test, returning -1" ); -1 elif d=2 or X=1 or Y=1 or i=1 then 0 elif Y>2 and i=2 then procname(subs(y=1,`algcurves/homogeneous`(F,x,y,z)),x,z) elif Y>2 and (X=2 or X+degree(lcoeff(F,x),y)