<jupyter_start><jupyter_text>Chapter: Groebner Bases Multivariate division algorithm<jupyter_code>from groebner.polynomials import PolynomialRing, Polynomial
R = PolynomialRing(labels=['x','y','z'])
x, y, z = R.get_vars()
f = 3*x+2/3*y**3-z
g = y*x+z
h = y + z
print(f,g,h)
# all algorithms are written into algorithms.py
from groebner.algorithms import _divide_terms, division_algorithm
first = _divide_terms(f.LT(),h.LT())
second = _divide_terms(f.LT(),g.LT())
first
second is None
[d1, d2], r = division_algorithm(f, [g,h])
d1*g + d2*h + r == f
type(d2)
# EX 2 IVT pp 63-4
f = x**2*y+x*y**2+y**2
g = x*y-1
h = y**2-1
[d1, d2], r = division_algorithm(f, [g,h])
print(f'({d1})({g}) + ({d2})({h}) + {r} = {f}')
d1*g + d2*h + r == f
# Check multidegrees satisfy the appropriate property (we've completed all division)
# ORDER MATTERS
for a,b in [(d1, g), (d2, h)]:
    assert f.LM() >= (a*b).LM()
# EX 4 IVT p 67
#(same as above with g and h reversed)
f = f = x**2*y+x*y**2+y**2
g = x*y-1
h = y**2-1
[d1, d2], r = division_algorithm(f, [h,g])
print(f'({d1})({h}) + ({d2})({g}) + {r} = {f}')
R.random()
R = PolynomialRing(labels=['x','y','z'])
x, y, z = R.get_vars()

f = R.random(max_deg=20)
g = R.random(max_deg=10)
h = R.random(max_deg=10)
k = R.random(max_deg=10)

[d1, d2, d3], r = division_algorithm(f, [g, h, k])

assert f == g*d1 + h*d2 + k*d3 + r
r
h
d1
d2
d3
r<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.22103004291845493, 'fraction_numerical': 0.0407725321888412, 'mean_word_length': 4.829166666666667, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 6, 'https://': 0, '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': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '543267', 'license': 'MIT', 'n_tokens_mistral': 690, 'n_tokens_neox': 664, 'n_words': 163, 'path': 'notebooks/multivariate_division_alg.ipynb', 'repo_name': 'NicoCourts/groebner', 'size': '1398'}