Tutorial 8: Polynomials are the coolest! (October 31-November 2, 2007)Today's tutorial covers material from lecture module 8 in the course notes, on simultaneous list processing. To practice this, we'll be computing with polynomials represented by a list of terms. A term is a pair of nonzero coefficient and exponent representing a single monomial such as 5x^{2}. A single term in Scheme is represented by a where the coefficient is not zero. A polynomial is represented by a list of terms sorted in order of increasing exponents.So for example the polynomial f(x) = 2x^{99} - 3x^{88} + 5x^{80} - x^{7}would be represented by the Scheme expression (list (make-term -1 7) (make-term 5 80) (make-term -3 88) (make-term 2 99))
Write a function Without using the We know two polynomials are exactly equal iff they have all the same terms. But we might just want to know how many identical terms two polynomials have. For this, write a function Write a function To evaluate a polynomial f(x) at a point, we simply replace the value of the point for x in the expression (just like evaluating a Scheme function). So write a function For this question, you may not use the built-in Scheme function The composition of two polynomials (or any two functions) is simply the first function applied to the result of the second. So the composition of two polynomials f(x) and g(x) is just f(g(x)), for example. Write a function As a bonus, write a function Warning: it may be difficult to write this function, as no one in the world knows how to accomplish this in a reasonable amount of time when polynomials are given in our chosen representation. If you come up with a fast solution, please email it to Dan Roche so that I can take credit for your work and become famous. |
This file generated Monday, December 17th, 2007 using PLT Scheme and WebIt!