sympy/sympy — pull request #1509 by mattpap (2012-08-25 15:42:40+00:00)
Title: Unified the way gcd() and lcm() are implemented across SymPy 

1. Now there is only one place to define high-level behavior of gcd() and lcm(). This belongs to sympy.polys.domains. f.gcd(g) and f.lcm(g) are now only wrappers over gcd() and lcm() functions from polys.

2. This pull request also fixes issue #3373 as it was related to gcd()/lcm() topic.

3. Poly(x**2 + 1, domain=EX) now fails gracefully. Generators must be provided to make it work. Without generators it doesn't make sense and it failed previously but with less meaningful error message).

If you want to alter behavior of gcd()/lcm() of RR domain, then apply this patch:
```
diff --git a/sympy/polys/domains/realdomain.py b/sympy/polys/domains/realdomain.py
index 66d39ac..791c8a9 100644
--- a/sympy/polys/domains/realdomain.py
+++ b/sympy/polys/domains/realdomain.py
@@ -112,11 +112,20 @@ def div(self, a, b):

def gcd(self, a, b):
"""Returns GCD of ``a`` and ``b``. """
- return self.one
+ if a and b:
+ if b < 0:
+ b = -b
+
+ while b:
+ a, b = b, a % b
+ else:
+ a = abs(a or b)
+
+ return a

def lcm(self, a, b):
"""Returns LCM of ``a`` and ``b``. """
- return a*b
+ return a*b/self.gcd(a, b)
```
There will be two test failures in response to this change of behavior.