REDUCE

9.4 Working with Least Common Multiples

Greatest common divisor calculations can often become expensive if extensive work with large rational expressions is required. However, in many cases, the only significant cancellations arise from the fact that there are often common factors in the various denominators which are combined when two rationals are added. Since these denominators tend to be smaller and more regular in structure than the numerators, considerable savings in both time and space can occur if a full GCD check is made when the denominators are combined and only a partial check when numerators are constructed. In other words, the true least common multiple of the denominators is computed at each step. The switch LCM is available for this purpose, and is normally on.

In addition, the operator LCM, used with the syntax

        LCM(EXPRN1:polynomial,EXPRN2:polynomial):polynomial,

returns the least common multiple of the two polynomials EXPRN1 and EXPRN2.

Examples:

        lcm(x^2+2*x+1,x^2+3*x+2) ->  X**3 + 4*X**2 + 5*X + 2  
        lcm(2*x^2-2*y^2,4*x+4*y) ->  4*(X**2 - Y**2)