gcd - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

Online Help

All Products    Maple    MapleSim


gcd

greatest common divisor of polynomials

lcm

least common multiple of polynomials

 

Calling Sequence

Parameters

Description

Examples

Calling Sequence

gcd(a, b, 'cofa', 'cofb')

lcm(a, b,...)

Parameters

a, b

-

multivariate polynomials over an algebraic number field or an algebraic function field.

cofa, cofb

-

(optional) unevaluated names

Description

• 

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 agcda,b.

• 

The optional fourth argument cofb is assigned the cofactor bgcda,b.

Examples

gcd6,8,a,b

2

(1)

a

3

(2)

b

−4

(3)

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.

lcm6,8,3,4,12

24

(4)

gcdx2y2,x3y3,c,d

y+x

(5)

c

x+y

(6)

d

x2+xy+y2

(7)

lcmx2y2,x3y3

x+yx3y3

(8)

gcdx2x312212x+212312,x22

x2

(9)

gcdsinx22,RootOfx22sinx

RootOf_Z22+sinx

(10)

Note that the arguments must be polynomials in all the indeterminates, otherwise an error is returned:

gcdy21x2,y1x

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:

gcdy21x,y1sqrtx

y1x

(11)

See Also

GaussInt[GIgcd]

Gcd

gcdex

igcd

ilcm