Course CMPSCI 287 Assignment 2

Due 11:59 PM, 30 SEP 99 as hwk2.scm in your cs287 directory

The polynomial function p for which
    p(x) =  a0 +  a1 x +  a2 x2 ... an xn
can be represented by the Scheme list
    (a0 a1 a2 ... an)
For example the function p1, defined by p1(x) = 4 + 3x + 5x2 is represented by the list
          (4 3 5)

(1) Write a function eval_poly for which the application (eval_poly p v) evaluates a polynomial function represented as a Scheme list p with argument v For example:

    (eval_poly '(1 2 3) 4)
evaluates to 57.

(2) The derivative of the polynomial function p for which

    p(x) = a0 +  a1 x  a2 x2 ... ab  xn
is the polynomial function p' for which p'(x) = a1 + 2 a2 x2 + ... n an xn Write a Scheme function derivative for which the call (derivative p) converts a polynomial into its derivative. For example (derivative '(3 4 5 6)) evaluates to (4 10 18).