Macaulay Resultant

175 views
Skip to first unread message

Candid Pleasure

unread,
Jun 1, 2022, 9:32:28 AM6/1/22
to Macaulay2
Hi,
I am new to the academic world and I'm trying to complete a project on using Macaulay's Resultant to solve polynomial systems. I get the error "Square Matrix expected" when I try to run a code. I don't understand this and I've tried to correct it. I would really appreciate any help.
Thank you very much.

Best,
Pleasure.

Tim Duff

unread,
Jun 3, 2022, 3:14:44 PM6/3/22
to Macaulay2
> I get the error "Square Matrix expected" when I try to run a code. I don't understand this and I've tried to correct it. I would really appreciate any help.

It is nearly impossible to provide advice on debugging anything without a minimal example illustrating the error you encountered. Would you please share the exact sequence of commands that lead to the error, so that others can provide accurate advice on how to debug it?

Candid Pleasure

unread,
Jun 4, 2022, 2:07:34 AM6/4/22
to Macaulay2
loadPackage "EliminationMatrices"
R=QQ[a,b,c,d,x,y,z]
f1 = a*x^2+b*y^2+c*z^2+d*x*y*z
f2 = 2*a*x+d*y*z
f3 = 2*a
f4 = 2
M = matrix{{f1,f2,f3,f4}}
det(eliminationMatrix({x,y,z},M,Strategy=>macaulayFormula))
loadPackage "EliminationMatrices"
R=QQ[a_0..a_5,b_0..b_5,c_0..c_5,x,y,z]
f1 = a_0*x^2+a_1*x*y+a_2*x*z+a_3*y^2+a_4*y*z+a_5*z^2
f2 = b_0*x^2+b_1*x*y+b_2*x*z+a_3*y^2+b_4*y*z+b_5*z^2
f3 = c_0*x^2+c_1*x*y+c_2*x*z+a_3*y^2+c_4*y*z+c_5*z^2
F = matrix{{f1,f2,f3}}
det(eliminationMatrix({x,y,z},F,Strategy=>macaulayFormula))

This is an example of some of the code I ran that generated the error, I want to know if my equations are the problem or I'm not getting the code right.
Thank you very much for your reply.

Michael Burr

unread,
Jun 4, 2022, 11:28:29 AM6/4/22
to Macaulay2
It might help to remove the determinant from the eliminationMatrix call to see a bit of what is going on here.  You'll see that in the first example, the eliminationMatrix command is returning an error.  In the second example, you'll see that eliminationMatrix is not returning a square matrix.

What's going on:

Looking at the source code of the eliminationMatrix command, it appears to accept two cases: (one variable and two polynomials) or (n variables and n polynomials).  Neither of these cases are satisfied in the first example.

The help file for the eliminationMatrix command states that "the gcd of its maximal minors is the Macaulay resultant" of the input polynomials.  This explains the non-square result in your second example.

Some general comments:

You might have more luck with needsPackage instead of loadPackage.  needsPackage won't reload your package if it has already been loaded.

Looking at the source code of the eliminationMatrix command with an input of a list and a matrix, it appears that the function ignores all options.  Therefore, the Strategy command is ignored.

Looking at the help file for the eliminationMatrix command, it states that the polynomials must be homogeneous in the variables, but the commands seem to run even when the polynomials are not homogeneous.  I don't know about the correctness of the results in this case, however.

If you just want to compute resultants (and the elimination matrix itself isn't needed), you might find the Resultants or SparseResultants packages to be helpful.  In your first example, with the Resultants package, you can use the ring QQ[a,b,c,d][x,y,z] and the command affineResultant {f1,f2,f3,f4}.

Laurent Buse

unread,
Jun 4, 2022, 3:34:21 PM6/4/22
to maca...@googlegroups.com
Dear Pleasure and Michael,

The problem in the code is that « macaulayFormula » is not a strategy of « eliminationMatrix », but a function of the package. Therefore, the command
eliminationMatrix({x,y,z},M,Strategy=>macaulayFormula) 
simply ignore the strategy argument and returns an elimination matrix, which is usually a singular matrix. Let me recall that such a matrix has the property that its rank drops if and only if the polynomials have a common root (in a suitable space). As a consequence, it can be used to solve polynomial systems by means of eigen-computations. 

If you want to get the Macaulay formula, use the command macaulayFormula. For instance, with the second example, do:
loadPackage "EliminationMatrices"
R=QQ[a_0..a_5,b_0..b_5,c_0..c_5,x,y,z]
f1 = a_0*x^2+a_1*x*y+a_2*x*z+a_3*y^2+a_4*y*z+a_5*z^2
f2 = b_0*x^2+b_1*x*y+b_2*x*z+a_3*y^2+b_4*y*z+b_5*z^2
f3 = c_0*x^2+c_1*x*y+c_2*x*z+a_3*y^2+c_4*y*z+c_5*z^2
F = matrix{{f1,f2,f3}}
(A,B)=macaulayFormula({x,y,z},F)

A is a 15x15 matrix and B is a 3x3 matrix. Moreover, det(B)*Res(F)=det(A). However, det(A) is not easy to expand… (don’t ask for it, or be patient).

Regarding your first example, it is not necessary to do computations to get the resultant. Indeed the two last equations are constant, so the resultant of the system is here equal to 2. As the resultant is universal (this is the beauty of this object!), this means that your system has no solution (in P^3, you need to homogenize) if and only if that characteristic of your ground field is not equal to 2. You can see this property on the elimination matrix (I homogenized the system with the new variable w):
loadPackage "EliminationMatrices"
R=QQ[a,b,c,d,x,y,z,w]
f1 = a*x^2*w+b*y^2*w+c*z^2*w+d*x*y*z
f2 = 2*a*x*w+d*y*z
f3 = 2*a
f4 = 2
M = matrix{{f1,f2,f3,f4}}
eliminationMatrix({x,y,z,w},M)
Observe that the rank of the 10x21-matrix you obtain is <10 if and only if the characteristic of your field is not equal to 2.

As Michaël pointed out, there are also other interesting, and very efficient, packages in M2 for computing resultants. Nevertheless, the methods that are used often lead to compute the resultant up to a multiplicative constant, so you are losing the universal property. For instance, if you call affineResultant {f1,f2,f3,f4} as suggested by Michaël, you will get that the resultant is equal to 1 (which is false). The point is that if you work in characteristic 0, this is not a big deal. 

Best regards,
Laurent.

--
You received this message because you are subscribed to the Google Groups "Macaulay2" group.
To unsubscribe from this group and stop receiving emails from it, send an email to macaulay2+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/macaulay2/1f66f26b-efa2-4ef9-9ddf-83f7bf5237a4n%40googlegroups.com.

Candid Pleasure

unread,
Jun 5, 2022, 3:29:17 AM6/5/22
to Macaulay2
Thank you very much, I understand now. I will use the other packages and compare my results. 

Candid Pleasure

unread,
Jun 5, 2022, 3:40:10 AM6/5/22
to Macaulay2
I appreciate your help. This really explains a lot,  I will implement these changes into my work.
Thank you very much.

Reply all
Reply to author
Forward
0 new messages