gcd
greatest common divisor of polynomials
lcm
least common multiple of polynomials
Calling Sequence
Parameters
Description
Examples
gcd(a, b, 'cofa', 'cofb')
lcm(a, b,...)
a, b
-
multivariate polynomials over an algebraic number field or an algebraic function field.
cofa, cofb
(optional) unevaluated names
The gcd function computes the greatest common divisor of two polynomials a and b.
If the coefficients of a and b are integers, then the product of the primitive unit normal greatest common divisor and the greatest common divisor of all coefficients is returned. The primitive normal greatest common divisor can be obtained from this by removing the icontent using %icontent(%).
If the coefficients of a or b are rational numbers or belong to an algebraic number or function field, then the monic greatest common divisor of a and b is computed. See type/algnum and type/algfun.
Algebraic numbers and functions may be represented by radicals (see type/radical) or with the RootOf notation (see evala).
Names occurring inside a RootOf or a radical are viewed as elements of the coefficient field, provided the RootOf defines an algebraic function. Therefore, they may occur in denominators as well. Other names are not allowed in denominators.
If a or b contains objects which are not algebraic numbers nor algebraic functions, these objects will be frozen before the computation proceeds. See frontend.
The RootOf and the radicals defining the algebraic numbers must form an independent set of algebraic quantities, otherwise an error is returned. Note that this condition does not need to be satisfied if the expression contains only algebraic numbers in radical notation (such as 2^(1/2), 3^(1/2), 6^(1/2)) since a basis over Q for the radicals can be computed by Maple in this case.
Since the ordering of the variables depends on the session, the result may also depend on the session when a and b have several variables.
The lcm function computes the least common multiple of an arbitrary number of polynomials.
The optional third argument cofa is assigned the cofactor agcd⁡a,b.
The optional fourth argument cofb is assigned the cofactor bgcd⁡a,b.
gcd⁡6,−8,a,b
2
a
3
b
−4
The lcm command will compute the least common multiple of an arbitrary number of polynomials, where the gcd command will compute the greatest common divisor of two polynomials.
lcm⁡6,−8,3,4,12
24
gcd⁡x2−y2,x3−y3,c,d
−y+x
c
x+y
d
x2+x⁢y+y2
lcm⁡x2−y2,x3−y3
x+y⁢x3−y3
gcd⁡x2−x⁢312−212⁢x+212⁢312,x2−2
x−2
gcd⁡sin⁡x2−2,RootOf⁡x2−2−sin⁡x
−RootOf⁡_Z2−2+sin⁡x
Note that the arguments must be polynomials in all the indeterminates, otherwise an error is returned:
gcd⁡y2−1x2,y−1x
Error, (in `gcd/Freeze`) arguments should be polynomials
However, when a name appears inside a radical or a RootOf representing an algebraic function, then it is considered as an element of the coefficient field. In the following example, a greatest common divisor in Q(x^(1/2))[y] is computed:
gcd⁡y2−1x,y−1sqrt⁡x
y−1x
See Also
GaussInt[GIgcd]
Gcd
gcdex
igcd
ilcm
Download Help Document