<jupyter_start><jupyter_text>Macaulay Resultant------------------ The Macauly resultant is a multivariate resultant. It is used for calculating the resultant of $n$ polynomialsin $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.<jupyter_code>x, y, z = sym.symbols('x, y, z')
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')
variables = [x, y, z]
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
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
f_3 = c_1 * x + c_2 * y + c_3 * z
polynomials = [f_1, f_2, f_3]
mac = MacaulayResultant(polynomials, variables)<jupyter_output><empty_output><jupyter_text>**Step 1** Calculated $d_i$ for $i \in n$.<jupyter_code>mac.degrees<jupyter_output><empty_output><jupyter_text>**Step 2.** Get $d_M$.<jupyter_code>mac.degree_m<jupyter_output><empty_output><jupyter_text>**Step 3.** All monomials of degree $d_M$ and size of set.<jupyter_code>mac.get_monomials_set()
mac.monomial_set
mac.monomials_size<jupyter_output><empty_output><jupyter_text>These are the columns of matrix $A$. **Step 4** Get rows and fill matrix.<jupyter_code>mac.get_row_coefficients()<jupyter_output><empty_output><jupyter_text>Each list is being multiplied by polynomials $f_1$, $f_2$ and $f_3$ equivalently. Then we fill the matrixbased on the coefficient of the monomials in the columns.<jupyter_code>matrix = mac.get_matrix()
matrix<jupyter_output><empty_output><jupyter_text>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}$.<jupyter_code>mac.get_submatrix(matrix)<jupyter_output><empty_output><jupyter_text>Second example-----------------This is from: http://isc.tamu.edu/resources/preprints/1996/1996-02.pdf<jupyter_code>x, y, z = sym.symbols('x, y, z')
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')
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
polynomials = [f, g, h]
mac = MacaulayResultant(polynomials, variables=[x, y, z])
mac.degrees
mac.degree_m
mac.get_monomials_set()
mac.get_size()
mac.monomial_set
mac.get_row_coefficients()
matrix = mac.get_matrix()
matrix
matrix.shape
mac.get_submatrix(mac.get_matrix())<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.16407307171853858, 'fraction_numerical': 0.05277401894451962, 'mean_word_length': 4.547842401500938, 'pattern_counts': {'":': 0, '<': 33, '<?xml version=': 0, '>': 33, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '8', 'dir': 'jupyter-structured-clean-dedup', 'id': '4665', 'license': 'MIT', 'n_tokens_mistral': 1350, 'n_tokens_neox': 1298, 'n_words': 318, 'path': 'examples/notebooks/Macaulay_resultant.ipynb', 'repo_name': 'Michal-Gagala/sympy', 'size': '2956'}