Repository: sympy/sympy

Issue:
LCM gives ZeroDivisionError
When utilizing the `lcm` function for polynomials, there is unxpected behavior in that:
```
from sympy.abc import x
from sympy import  lcm, Poly

f = Poly(0, x, domain="QQ")
g = Poly(0, x, domain="QQ")

lcm(f,g)
```
returns a `ZeroDivisionError`, but **should** return 0. 

This doesn't happen in Sage. There
```
R.<x> = PolynomialRing(QQ)  
f = R(0)
g = R(0)

lcm_polynomial = lcm(f, g)
print(lcm_polynomial)
```
returns 0 as expected. 

Is this a bug? If so, is it worthwhile to fix?

Discussion:

Patch:
diff --git a/sympy/polys/euclidtools.py b/sympy/polys/euclidtools.py
index d16a1402ac..a0bf6d147f 100644
--- a/sympy/polys/euclidtools.py
+++ b/sympy/polys/euclidtools.py
@@ -1639,6 +1639,9 @@ def dup_rr_lcm(f, g, K):
     x**3 - 2*x**2 - x + 2
 
     """
+    if not f and not g:
+        return K.zero
+
     fc, f = dup_primitive(f, K)
     gc, g = dup_primitive(g, K)
 


Test patch:
diff --git a/sympy/polys/tests/test_polytools.py b/sympy/polys/tests/test_polytools.py
index 17c59243ec..499c338b53 100644
--- a/sympy/polys/tests/test_polytools.py
+++ b/sympy/polys/tests/test_polytools.py
@@ -2078,6 +2078,10 @@ def test_gcd():
     raises(TypeError, lambda: gcd(x))
     raises(TypeError, lambda: lcm(x))
 
+    f = Poly(0, x)
+    g = Poly(0, x)
+    assert lcm(f, g) == 0
+
 
 def test_gcd_numbers_vs_polys():
     assert isinstance(gcd(3, 9), Integer)