Die Funktion lcm() bietet die direkte Möglichkeit, das kleinste gemeinsame Vielfache für Polynome zu berechnen. Das heißt, für die Polynome f und g wird LCM berechnet.
Syntax: sympy.lcm(f, g)

Return: LCM of given polynomials

Beispiel 1:

# import sympy  
from sympy import * f = x * y**2 + x**2 * y
g = x**2 * y**2
  
# Using sympy.lcm() method 
gfg = lcm(f, g)
  
print(gfg)

Ausgabe:

x**3*y**2 + x**2*y**3

Beispiel #2:

# import sympy  
from sympy import * f = x * y / 2 + y**2
g = 3 * x + 6 * y
  
# Using sympy.lcm() method 
gfg = lcm(f, g)
  
print(gfg)

Ausgabe:

x*y + 2*y**2