Smatchcube's website 🌍


Exercise 2.95

Indeed the result is not the same as \(P_1\). \ Let’s trace the GCD algorithm for \(Q_1\) and \(Q_2\):

Now we can compute the remainder-terms by hand and we quickly see that the first coefficient of the quotient is \(\), this is not an integer and we can see that the remainder is not a polynomial with integer coefficients breaking the GCD algorithm.\ I just learned from the documentation that mit-scheme has a trace procedure built in. We just need to add (trace gcd-terms) to display the calls of gcd-terms, the arguments used and the returned value.\ Here is the complete trace of the gcd-terms procedure.

After a quick check in the book I can see that tracing is only concretely defined in the part 5.2.4. I feel like the trace procedure should be explained earlier in the book, debugging skills are really important and it can really help solving complex exercises.\ You can learn more about the trace procedure here.