Write a function in R which uses Newton's method to find the solution for any 4th degree polynomial.  The inputs are vectors which give coefficients for f, f', and the initial iterate, x0.  The function should return an approximation to a root of f, up to 1e-6.

Example input:

f <- c(5, -2, 7, 1, -4); # 5x^4 — 2x^3 + 7x^2 + x — 4
df <- c(20, -6, 14, 1); # 20x^2 — 6*x^2 + 13x + 1

newtons_method <- function(f, df, x0){

} (This question is meant to test basic knowledge of a function: correct value returned, re-usability, etc.) (Alternative short answer was to implement a Caesar cipher, but that took me way longer than 5 minutes, unfortunately!) * Multiple choice:  I liked a question I remembered on scoping rules: www.stat.berkeley.edu/~statcur/Workshop2/Presentations/functions.pdf, page 24.  (As this tests the way that functions are self-contained.)  Will try to think of one of my own by tomorrow. Based on my concept map and that of Tim Namarra's.  (sp?)