Assignment 7 – R Review, Debugging, Polynomials and Derivatives

advertisement
Assignment 7 – R Review, Debugging, Polynomials and Derivatives
Due Date: October 18, 2011
1. Turn in your R command cheat sheet that you created in the lab 7. This will be graded on
completion.
2. Imagine you want to write code to plot the function w(x)=2*sin(x)+1 from -3 to 3. You want to
write two versions of code to do this. In version a, you want to define w as a function in R. In
version b, you want to define w as a vector. Below are codes that are incorrect. Identify the
errors in the code below and describe how to fix it.
a. 2 ERRORS
#Code to plot w(x)=2*sin(x)+1 from -3 to 3 defining w as a function
w = function(m){2*sin(m)+1}
plot(x,w)
b. 2 ERRORS
#Code to plot w(x)=2*sin(x)+1 from -3 to 3 defining w as a vector
w = 2*sin(x)+1
x = -3:3
plot(w,x)
3. Consider the polynomials series that you plotted in the assignment. Plot the derivatives of
through
on the same graph and describe how they compare to the original figure
you made in the lab. Include both figures in your assignment and be sure to label them! HINT:
compute the derivatives of the polynomials by hand and it should help you understand what is
happening.
BONUS: Can you guess what function these polynomials are approaching? In other words,
what function is given by the series
?
Download