forked from Macaulay2/M2
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixed a symbol conflict involving resultants and discriminants
- Loading branch information
Showing
3 changed files
with
33 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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/", | ||
|
@@ -31,8 +32,9 @@ newPackage( | |
) | ||
|
||
export{ | ||
"resultant", | ||
"discriminant", | ||
-- these two come from Elimination | ||
--"resultant", | ||
--"discriminant", | ||
"affineResultant", | ||
"affineDiscriminant", | ||
"genericPolynomials", | ||
|
@@ -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; | ||
|
@@ -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) -> ( | ||
|
@@ -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;)); | ||
); | ||
|
||
|
@@ -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]}, | ||
|
@@ -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)"}}, | ||
|
@@ -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", | ||
|
@@ -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)}, | ||
|
@@ -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)}, | ||
|
@@ -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)}, | ||
|
@@ -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)}, | ||
|
@@ -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]}, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters