```python
import sympy as sym
from sympy.polys.multivariate_resultants import MacaulayResultant

sym.init_printing()
```

Macaulay Resultant
------------------

The Macauly resultant is a multivariate resultant. It is used for calculating the resultant of $n$ polynomials
in $n$ variables. The Macaulay resultant is calculated as the determinant of two matrices,

$$R = \frac{\text{det}(A)}{\text{det}(M)}.$$

Matrix $A$
-----------

There are a number of steps needed to construct matrix $A$. Let us consider an example from https://dl.acm.org/citation.cfm?id=550525 to 
show the construction.


```python
x, y, z = sym.symbols('x, y, z')
```


```python
a_1_1, a_1_2, a_1_3, a_2_2, a_2_3, a_3_3 = sym.symbols('a_1_1, a_1_2, a_1_3, a_2_2, a_2_3, a_3_3')
b_1_1, b_1_2, b_1_3, b_2_2, b_2_3, b_3_3 = sym.symbols('b_1_1, b_1_2, b_1_3, b_2_2, b_2_3, b_3_3')
c_1, c_2, c_3 = sym.symbols('c_1, c_2, c_3')
```


```python
variables = [x, y, z]
```


```python
f_1 = a_1_1 * x ** 2 + a_1_2 * x * y + a_1_3 * x * z + a_2_2 * y ** 2 + a_2_3 * y * z + a_3_3 * z ** 2
```


```python
f_2 = b_1_1 * x ** 2 + b_1_2 * x * y + b_1_3 * x * z + b_2_2 * y ** 2 + b_2_3 * y * z + b_3_3 * z ** 2
```


```python
f_3 = c_1 * x + c_2 * y + c_3 * z
```


```python
polynomials = [f_1, f_2, f_3]
mac = MacaulayResultant(polynomials, variables)
```

**Step 1** Calculated $d_i$ for $i \in n$. 


```python
mac.degrees
```

**Step 2.** Get $d_M$.


```python
mac.degree_m
```

**Step 3.** All monomials of degree $d_M$ and size of set.


```python
mac.get_monomials_set()
```


```python
mac.monomial_set
```


```python
mac.monomials_size
```

These are the columns of matrix $A$.

**Step 4** Get rows and fill matrix.


```python
mac.get_row_coefficients()
```

Each list is being multiplied by polynomials $f_1$, $f_2$ and $f_3$ equivalently. Then we fill the matrix
based on the coefficient of the monomials in the columns.


```python
matrix = mac.get_matrix()
matrix
```

Matrix $M$
-----------

Columns that are non reduced are kept. The rows which contain one if the $a_i$s is dropoed.
$a_i$s are the coefficients of $x_i ^ {d_i}$.


```python
mac.get_submatrix(matrix)
```

Second example
-----------------
This is from: http://isc.tamu.edu/resources/preprints/1996/1996-02.pdf


```python
x, y, z = sym.symbols('x, y, z')
```


```python
a_0, a_1, a_2 = sym.symbols('a_0, a_1, a_2')
b_0, b_1, b_2 = sym.symbols('b_0, b_1, b_2')
c_0, c_1, c_2,c_3, c_4 = sym.symbols('c_0, c_1, c_2, c_3, c_4')
```


```python
f = a_0 * y -  a_1 * x + a_2 * z
g = b_1 * x ** 2 + b_0 * y ** 2 - b_2 * z ** 2
h = c_0 * y - c_1 * x ** 3 + c_2 * x ** 2 * z - c_3 * x * z ** 2 + c_4 * z ** 3
```


```python
polynomials = [f, g, h]
```


```python
mac = MacaulayResultant(polynomials, variables=[x, y, z])
```


```python
mac.degrees
```


```python
mac.degree_m
```


```python
mac.get_monomials_set()
```


```python
mac.get_size()
```


```python
mac.monomial_set
```


```python
mac.get_row_coefficients()
```


```python
matrix = mac.get_matrix()
matrix
```


```python
matrix.shape
```


```python
mac.get_submatrix(mac.get_matrix())
```


```python

```


```python

```

b6ecd4a4e650f9cfdf372e25658630814f1d4193
ipynb
Jupyter Notebook
examples/notebooks/Macaulay_resultant.ipynb
utkarshdeorah/sympy
dcdf59bbc6b13ddbc329431adf72fcee294b6389
BSD-3-Clause
2015-01-02T15:51:43.000Z
2022-03-31T13:13:19.000Z
examples/notebooks/Macaulay_resultant.ipynb
utkarshdeorah/sympy
dcdf59bbc6b13ddbc329431adf72fcee294b6389
BSD-3-Clause
2015-01-01T01:33:17.000Z
2022-03-31T22:53:13.000Z
examples/notebooks/Macaulay_resultant.ipynb
utkarshdeorah/sympy
dcdf59bbc6b13ddbc329431adf72fcee294b6389
BSD-3-Clause
2015-01-01T17:48:07.000Z
2022-03-31T17:24:05.000Z
Qwen/Qwen-72B
1. YES
2. YES