 gcd - Maple Programming Help

# Online Help

###### All Products    Maple    MapleSim

gcd

greatest common divisor of polynomials

lcm

least common multiple of polynomials

 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 $\frac{a}{\mathrm{gcd}\left(a,b\right)}$.
 • The optional fourth argument cofb is assigned the cofactor $\frac{b}{\mathrm{gcd}\left(a,b\right)}$.

Examples

 > $\mathrm{gcd}\left(6,-8,a,b\right)$
 ${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.

 > $\mathrm{lcm}\left(6,-8,3,4,12\right)$
 ${24}$ (4)
 > $\mathrm{gcd}\left({x}^{2}-{y}^{2},{x}^{3}-{y}^{3},c,d\right)$
 ${-}{y}{+}{x}$ (5)
 > $c$
 ${x}{+}{y}$ (6)
 > $d$
 ${{x}}^{{2}}{+}{x}{}{y}{+}{{y}}^{{2}}$ (7)
 > $\mathrm{lcm}\left({x}^{2}-{y}^{2},{x}^{3}-{y}^{3}\right)$
 $\left({x}{+}{y}\right){}\left({{x}}^{{3}}{-}{{y}}^{{3}}\right)$ (8)
 > $\mathrm{gcd}\left({x}^{2}-x{3}^{\frac{1}{2}}-{2}^{\frac{1}{2}}x+{2}^{\frac{1}{2}}{3}^{\frac{1}{2}},{x}^{2}-2\right)$
 ${x}{-}\sqrt{{2}}$ (9)
 > $\mathrm{gcd}\left({\mathrm{sin}\left(x\right)}^{2}-2,\mathrm{RootOf}\left({x}^{2}-2\right)-\mathrm{sin}\left(x\right)\right)$
 ${-}{\mathrm{RootOf}}{}\left({{\mathrm{_Z}}}^{{2}}{-}{2}\right){+}{\mathrm{sin}}{}\left({x}\right)$ (10)

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

 > $\mathrm{gcd}\left({y}^{2}-\frac{1}{{x}^{2}},y-\frac{1}{x}\right)$

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:

 > $\mathrm{gcd}\left({y}^{2}-\frac{1}{x},y-\frac{1}{\mathrm{sqrt}\left(x\right)}\right)$
 ${y}{-}\frac{{1}}{\sqrt{{x}}}$ (11)

 See Also