Here is my
remainder-terms procedure and the modified version of
gcd-terms to use it.
(define (pseudoremainder-terms P Q) (let ((c (coeff (first-term Q))) (O1 (order (first-term P))) (O2 (order (first-term Q)))) (let ((integerizing-factor (exp c (- O1 O2 -1)))) (cadr (div-terms (mul-term-by-all-terms (make-term 0 integerizing-factor) P) Q))))) (define (gcd-terms a b) (if (empty-termlist? b) a (gcd-terms b (pseudoremainder-terms a b))))
We can see that now the coefficients are only integers.
I’m using the
accumulate procedure to compute the GCD of the coefficients, then I can divide the polynomial by this GCD.
Now we can find the simplified GCD of \(Q_1\) and \(Q_2\):