1 // Greatest common denominator
44 if (isrational(p1
) && isrational(p2
)) {
51 if (car(p1
) == symbol(ADD
) && car(p2
) == symbol(ADD
)) {
56 if (car(p1
) == symbol(ADD
)) {
61 if (car(p2
) == symbol(ADD
)) {
66 if (car(p1
) == symbol(MULTIPLY
) && car(p2
) == symbol(MULTIPLY
)) {
71 if (car(p1
) == symbol(MULTIPLY
)) {
76 if (car(p2
) == symbol(MULTIPLY
)) {
83 if (car(p1
) == symbol(POWER
)) {
89 if (car(p2
) == symbol(POWER
)) {
100 // are both exponents numerical?
102 if (isnum(p3
) && isnum(p4
)) {
112 // are the exponents multiples of eah other?
124 // choose the smallest exponent
126 if (car(p3
) == symbol(MULTIPLY
) && isnum(cadr(p3
)))
131 if (car(p4
) == symbol(MULTIPLY
) && isnum(cadr(p4
)))
156 // can't be equal because of test near beginning
160 if (isnegativenumber(p5
))
168 // in this case gcd is used as a composite function, i.e. gcd(gcd(gcd...
173 if (length(p1
) != length(p2
)) {
250 gcd_term_factor(void)
264 gcd_factor_term(void)
332 "gcd(x^2*y^2,x^3*y^3)",
352 "gcd(4*x+4*y,6*x+6*y)",
355 "gcd(4*x+4*y+4,6*x+6*y+6)",
358 "gcd(4*x+4*y+4,6*x+6*y+12)",
361 "gcd(27*t^3+y^3+9*t*y^2+27*t^2*y,t+y)",
366 "gcd(2*a^2*x^2+a*x+a*b,a)",
369 "gcd(2*a^2*x^2+a*x+a*b,a^2)",
372 "gcd(2*a^2*x^2+2*a*x+2*a*b,a)",
377 "gcd(2*a^2*x^2+2*a*x+2*a*b,2*a)",
380 "gcd(2*a^2*x^2+2*a*x+2*a*b,3*a)",
383 "gcd(2*a^2*x^2+2*a*x+2*a*b,4*a)",
394 // multiple arguments
403 test(__FILE__
, s
, sizeof s
/ sizeof (char *));