# $Source: /u/maple/research/lib/algcurves/src/RCS/genus,v $ # $Notify: hoeij@sci.kun.nl $ macro( genus=`algcurves/genus` ): macro( g_normal=`algcurves/g_normal` ): # f is a polynomial in x and y genus:=proc(f,x,y) local F,d,v,i; options remember, `Copyright (c) 1996 Waterloo Maple Inc. All rights reserved.`; if args[nargs]=`irr check` then F:=evala(AFactors(args[1])); if nops(F[2])>1 or F[2][1][2]>1 then RETURN(args[1],`factored as`,F) fi; RETURN(procname(args[1..nargs-1])) fi; if nargs<3 or (not type(x,name)) or (not type(y,name)) or (not type(f,polynom(anything,[x,y]))) then ERROR(`wrong number or type of arguments`) fi; readlib(`algcurves/g_expand`): # to load g_normal # The following is to ensure that degree(..) gives the right answer. F:=collect(numer(f),{x,y},'distributed',g_normal); if degree(F,{x,y})=0 then ERROR(`degree is zero`) elif (degree(F,x)=1 and not has(evala(Content(f,x)),y)) or (degree(F,y)=1 and not has(evala(Content(f,y)),x)) then 0 elif degree(F,x)*degree(F,y)=0 then ERROR(`Input has degree >1 in one variable and degree 0 in the other`) elif degree(F,y)=2 then # We could call `algcurves/singularities` but the following is # likely to be faster: F:=collect(F/lcoeff(F,y),y,g_normal); F:=collect(subs(y=y-coeff(F,y,1)/2,F),y,g_normal); F:=coeff(F,y,0); # Take the factors with odd multiplicity F:=numer(F)*denom(F); floor(convert([-1,seq(`if`(irem(i[2],2)=0,0, degree(collect(i[1],x),x)), i=evala(Sqrfree(F),'expanded')[2])],`+`)/2) elif degree(F,x)=2 or degree(F,x)+degree(lcoeff(F,x),y)