Skip to content

Commit

Permalink
fixed a symbol conflict involving resultants and discriminants
Browse files Browse the repository at this point in the history
  • Loading branch information
mahrud committed Jan 10, 2024
1 parent 8ab75c6 commit a891a9b
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 36 deletions.
8 changes: 4 additions & 4 deletions M2/Macaulay2/packages/Elimination.m2
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,12 @@ sylvesterMatrix(RingElement,RingElement,RingElement) := (f,g,x) -> (
m = transpose m;
substitute(m, x=>0)))

resultant = method()
resultant(RingElement, RingElement, RingElement) := (f,g,x) ->
resultant = method(Options => { Algorithm => null })
resultant(RingElement, RingElement, RingElement) := RingElement => o -> (f,g,x) ->
det sylvesterMatrix(f,g,x)

discriminant = method()
discriminant(RingElement, RingElement) := (f,x) -> resultant(f, diff(x,f), x)
discriminant = method(Options => { Algorithm => null })
discriminant(RingElement, RingElement) := RingElement => o -> (f,x) -> resultant(f, diff(x,f), x, o)

-----------------------------------------------
-- documentation and tests
Expand Down
54 changes: 28 additions & 26 deletions M2/Macaulay2/packages/Resultants.m2
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ newPackage(
Authors => {{Name => "Giovanni Staglianò", Email => "[email protected]"}},
Headline => "resultants, discriminants, and Chow forms",
Keywords => {"Commutative Algebra"},
PackageExports => { "Elimination" },
Certification => {
"journal name" => "The Journal of Software for Algebra and Geometry",
"journal URI" => "http://j-sag.org/",
Expand All @@ -31,8 +32,9 @@ newPackage(
)

export{
"resultant",
"discriminant",
-- these two come from Elimination
--"resultant",
--"discriminant",
"affineResultant",
"affineDiscriminant",
"genericPolynomials",
Expand Down Expand Up @@ -61,25 +63,24 @@ export{
----------------------------------------------------------------------------------
----------------------- MultipolynomialResultats ---------------------------------
----------------------------------------------------------------------------------

resultant = method(TypicalValue => RingElement, Options => {Algorithm => "Poisson"});

resultant (Matrix) := o -> (F) -> (

resultant Matrix := RingElement => opts -> F -> (
if numgens target F != 1 then error "expected a matrix with one row";
if not isPolynomialRing ring F then error "the base ring must be a polynomial ring";
n := numgens source F -1;
if n+1 != numgens ring F then error("the number of polynomials must be equal to the number of variables, but got " | toString(numgens source F) | " polynomials and " | toString(numgens ring F) | " variables");
if o.Algorithm =!= "Poisson" and o.Algorithm =!= "Poisson2" and o.Algorithm =!= "Macaulay" and o.Algorithm =!= "Macaulay2" then error "bad value for option Algorithm; possible values are \"Poisson\", \"Poisson2\", \"Macaulay\", and \"Macaulay2\"";
algorithm := if opts.Algorithm === null then "Poisson" else opts.Algorithm;
if not member(algorithm, {"Poisson", "Poisson2", "Macaulay", "Macaulay2"}) then error "bad value for option Algorithm; possible values are \"Poisson\", \"Poisson2\", \"Macaulay\", and \"Macaulay2\"";
K := coefficientRing ring F;
x := local x;
Pn := K[x_0..x_n];
F = sub(F,vars Pn); F' := F;
d := apply(flatten entries F,ee->first degree ee);
if not isField K then (K' := frac K; Pn' := K'[x_0..x_n]; F' = sub(F,Pn'));
if not isHomogeneous ideal F' then error("expected homogeneous polynomials");
if o.Algorithm === "Macaulay" then (if (min d > -1 and sum(d) > n) then return MacaulayResultant(F,false) else <<"--warning: ignored option Algorithm=>\"Macaulay\""<<endl);
if o.Algorithm === "Poisson2" then return interpolateRes(F,"Poisson");
if o.Algorithm === "Macaulay2" then return interpolateRes(F,"Macaulay");
if algorithm === "Macaulay" then (if (min d > -1 and sum(d) > n) then return MacaulayResultant(F,false) else <<"--warning: ignored option Algorithm=>\"Macaulay\""<<endl);
if algorithm === "Poisson2" then return interpolateRes(F,"Poisson");
if algorithm === "Macaulay2" then return interpolateRes(F,"Macaulay");
R := PoissonFormula F';
if R != 0 then (
if isField K then return R;
Expand All @@ -88,7 +89,7 @@ resultant (Matrix) := o -> (F) -> (
if dim ideal F' > 0 then sub(0,K) else resultant(wobble F,Algorithm=>"Poisson")
);

resultant (List) := o -> (s) -> resultant(matrix{s},Algorithm=>o.Algorithm);
resultant List := RingElement => opts -> s -> resultant(matrix {s}, opts);

PoissonFormula = method();
PoissonFormula (Matrix) := (F) -> (
Expand Down Expand Up @@ -228,15 +229,13 @@ Res222 = (F) -> (
sub(W,apply(20,j -> g_j => mm_j))
);

discriminant = method(TypicalValue => RingElement, Options => {Algorithm => "Poisson"});

discriminant RingElement := o -> (G) -> (
discriminant RingElement := RingElement => opts -> G -> (
if not (isPolynomialRing ring G) then error "expected a homogeneous polynomial";
-- if not (isHomogeneous G) then error "expected a homogeneous polynomial";
n := numgens ring G;
d := first degree G;
a := lift(((d-1)^n - (-1)^n)/d,ZZ);
resG := resultant(transpose jacobian matrix{{G}},Algorithm=>o.Algorithm);
resG := resultant(transpose jacobian matrix{{G}}, opts);
try return lift(resG/(d^a),ring resG) else (try (q := first quotientRemainder(resG,d^a); assert(resG == q*d^a); return q) else (<<"--warning: the returned discriminant value is only correct up to a non-zero multiplicative constant"<<endl; return resG;));
);

Expand Down Expand Up @@ -849,7 +848,7 @@ beginDocumentation()
document {
Key => Resultants,
Headline => "resultants, discriminants, and Chow forms",
PARA{"This package provides methods to deal with resultants and discriminants of multivariate polynomials, and with higher associated subvarieties of irreducible projective varieties. The main methods are: ", TO "resultant",", ",TO "discriminant",", ", TO "chowForm",", ",TO "dualVariety",", and ",TO "tangentialChowForm",". For the mathematical theory, we refer to the following two books: ", HREF{"http://link.springer.com/book/10.1007%2Fb138611","Using Algebraic Geometry"},", by David A. Cox, John Little, Donal O'shea; ", HREF{"http://link.springer.com/book/10.1007%2F978-0-8176-4771-1","Discriminants, Resultants, and Multidimensional Determinants"},", by Israel M. Gelfand, Mikhail M. Kapranov and Andrei V. Zelevinsky. Other references for the theory of Chow forms are: ", HREF{"https://projecteuclid.org/euclid.dmj/1077305197","The equations defining Chow varieties"}, ", by M. L. Green and I. Morrison; ", HREF{"http://link.springer.com/article/10.1007/BF02567693","Multiplicative properties of projectively dual varieties"},", by J. Weyman and A. Zelevinsky; and ",HREF{"https://www.sciencedirect.com/science/article/abs/pii/S0747717119301506","Coisotropic hypersurfaces in Grassmannians"}, ", by K. Kohn."},
PARA{"This package provides methods to deal with resultants and discriminants of multivariate polynomials, and with higher associated subvarieties of irreducible projective varieties. The main methods are: ", TO (resultant,Matrix),", ",TO (discriminant,RingElement),", ", TO "chowForm",", ",TO "dualVariety",", and ",TO "tangentialChowForm",". For the mathematical theory, we refer to the following two books: ", HREF{"http://link.springer.com/book/10.1007%2Fb138611","Using Algebraic Geometry"},", by David A. Cox, John Little, Donal O'shea; ", HREF{"http://link.springer.com/book/10.1007%2F978-0-8176-4771-1","Discriminants, Resultants, and Multidimensional Determinants"},", by Israel M. Gelfand, Mikhail M. Kapranov and Andrei V. Zelevinsky. Other references for the theory of Chow forms are: ", HREF{"https://projecteuclid.org/euclid.dmj/1077305197","The equations defining Chow varieties"}, ", by M. L. Green and I. Morrison; ", HREF{"http://link.springer.com/article/10.1007/BF02567693","Multiplicative properties of projectively dual varieties"},", by J. Weyman and A. Zelevinsky; and ",HREF{"https://www.sciencedirect.com/science/article/abs/pii/S0747717119301506","Coisotropic hypersurfaces in Grassmannians"}, ", by K. Kohn."},
}
document {
Key => {[resultant,Algorithm],[discriminant,Algorithm],[affineResultant,Algorithm],[affineDiscriminant,Algorithm]},
Expand All @@ -868,10 +867,10 @@ document {
"time resultant(F,Algorithm=>\"Macaulay\")",
"assert(o3 == o4 and o4 == o5 and o5 == o6)"
},
SeeAlso => {discriminant,resultant}
SeeAlso => {(discriminant,RingElement),(resultant,Matrix)}
}
document {
Key => {resultant,(resultant,Matrix),(resultant,List)},
Key => {(resultant,Matrix),(resultant,List)},
Headline => "multipolynomial resultant",
Usage => "resultant F",
Inputs => { "F" => Matrix => {"a row matrix whose entries are ", TEX///$n+1$///," homogeneous polynomials ", TEX///$F_0,\ldots,F_n$///," in ", TEX///$n+1$///," variables (or a ", TO2{List,"list"}," to be interpreted as such a matrix)"}},
Expand All @@ -892,15 +891,18 @@ document {
"F = genericPolynomials({2,2,2},ZZ)",
"time # terms resultant F"
},
SeeAlso => {chowForm,discriminant}
SeeAlso => {chowForm,(discriminant,RingElement)}
}
document {
Key => {discriminant,(discriminant,RingElement)},
Key => {(discriminant,RingElement)},
Headline => "resultant of the partial derivatives",
Usage => "discriminant F",
Inputs => { "F" => RingElement => {"a homogeneous polynomial"}},
Outputs => {RingElement => {"the discriminant of ",TT "F"}},
PARA{"The discriminant of a homogeneous polynomial is defined, up to a scalar factor, as the ",TO resultant," of its partial derivatives. For the general theory, see one of the following: ",HREF{"http://link.springer.com/book/10.1007%2Fb138611","Using Algebraic Geometry"},", by David A. Cox, John Little, Donal O'shea; ", HREF{"http://link.springer.com/book/10.1007%2F978-0-8176-4771-1","Discriminants, Resultants, and Multidimensional Determinants"},", by Israel M. Gelfand, Mikhail M. Kapranov and Andrei V. Zelevinsky."},
PARA{"The discriminant of a homogeneous polynomial is defined, up to a scalar factor, as the ",
TO (resultant,Matrix)," of its partial derivatives. For the general theory, see one of the following: ",
HREF{"http://link.springer.com/book/10.1007%2Fb138611","Using Algebraic Geometry"},", by David A. Cox, John Little, Donal O'shea; ",
HREF{"http://link.springer.com/book/10.1007%2F978-0-8176-4771-1","Discriminants, Resultants, and Multidimensional Determinants"},", by Israel M. Gelfand, Mikhail M. Kapranov and Andrei V. Zelevinsky."},
EXAMPLE {
"ZZ[a,b,c][x,y]; F = a*x^2+b*x*y+c*y^2",
"time discriminant F",
Expand All @@ -917,7 +919,7 @@ document {
"time D=discriminant pencil",
"factor D"
},
SeeAlso => {dualVariety,resultant}
SeeAlso => {dualVariety,(resultant,Matrix)}
}
document {
Key => {affineResultant,(affineResultant,Matrix),(affineResultant,List)},
Expand All @@ -930,7 +932,7 @@ document {
"f = {3*t*y*z-u*z^2+1, -y+t+3*u-1, u*z^4-t*y^3+t*y*z}",
"affineResultant f"
},
SeeAlso => {resultant,affineDiscriminant}
SeeAlso => {(resultant,Matrix),affineDiscriminant}
}
document {
Key => {affineDiscriminant,(affineDiscriminant,RingElement)},
Expand All @@ -944,7 +946,7 @@ document {
"ZZ[a,b,c,d][x]; f = a*x^3+b*x^2+c*x+d",
"affineDiscriminant f",
},
SeeAlso => {discriminant,affineResultant}
SeeAlso => {(discriminant,RingElement),affineResultant}
}
document {
Key => {genericPolynomials,(genericPolynomials,VisibleList,Ring),(genericPolynomials,List)},
Expand Down Expand Up @@ -976,7 +978,7 @@ document {
"time (D,D') = macaulayFormula F",
"assert(det D == (resultant F) * (det D'))"
},
SeeAlso => {resultant}
SeeAlso => {(resultant,Matrix)}
}
document {
Key => {veronese,(veronese,ZZ,ZZ,Ring),(veronese,ZZ,ZZ)},
Expand Down Expand Up @@ -1238,7 +1240,7 @@ document {
"time Z = dualVariety(veronese(2,3,ZZ/3331),AssumeOrdinary=>true);",
"discF == sub(Z,vars ring discF) and Z == sub(discF,vars ring Z)"
},
SeeAlso => {conormalVariety,discriminant}
SeeAlso => {conormalVariety,(discriminant,RingElement)}
}
document {
Key => {[conormalVariety,Strategy],[dualVariety,Strategy]},
Expand Down
7 changes: 1 addition & 6 deletions M2/Macaulay2/packages/SpecialFanoFourfolds.m2
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ map HodgeSpecialSurface := o -> S -> (
);
curve = method();
curve HodgeSpecialSurface := U -> first U#"CurveContainedInTheSurface";
discriminant HodgeSpecialSurface := o -> S -> (
discriminant HodgeSpecialSurface := ZZ => o -> S -> (
if S.cache#?(curve S,"discriminantSurface") then return last S.cache#(curve S,"discriminantSurface");
if not member(o.Algorithm, {"Poisson", 1, 2}) then error "the Algorithm option accepts the values 1 and 2";
C := curve S;
Expand Down Expand Up @@ -3161,9 +3161,6 @@ PARA{"The general type of Gushel-Mukai fourfold (called ",EM "ordinary",") can b
PARA{"An object of the class ", TO SpecialGushelMukaiFourfold, " is basically represented by a couple ", TEX///(S,X)///, ", where ", TEX///$X$///, " is a Gushel-Mukai fourfold and ", TEX///$S$///, " is a surface contained in ", TEX///$X$///, ". The main constructor for the objects of the class is the function ", TO specialGushelMukaiFourfold,"."},
SeeAlso => {(discriminant,SpecialGushelMukaiFourfold)}}

typValDisc := typicalValues#discriminant;
typicalValues#discriminant = ZZ;

document {Key => {(discriminant, SpecialCubicFourfold), (discriminant, HodgeSpecialFourfold)},
Headline => "discriminant of a special cubic fourfold",
Usage => "discriminant X",
Expand All @@ -3182,8 +3179,6 @@ PARA{"This function applies a formula given in Section 7 of the paper ", HREF{"h
EXAMPLE {"X = specialGushelMukaiFourfold \"tau-quadric\";", "time discriminant X"},
SeeAlso => {(discriminant, SpecialCubicFourfold)}}

typicalValues#discriminant = typValDisc;

undocumented{(expression, SpecialGushelMukaiFourfold), (describe, SpecialGushelMukaiFourfold)}

document {Key => {Verbose, [specialCubicFourfold, Verbose], [specialGushelMukaiFourfold, Verbose], [mirrorFourfold, Verbose], [specialFourfold, Verbose], [parameterCount, Verbose], [associatedK3surface, Verbose], [associatedCastelnuovoSurface, Verbose], [detectCongruence, Verbose], [trisecantFlop, Verbose]},
Expand Down

0 comments on commit a891a9b

Please sign in to comment.