# # Written by: # -- # John L. Weatherwax 2009-04-21 # # email: wax@alum.mit.edu # # Please send comments and especially bug reports to the # above email address. # #----- #postscript("../WriteUp/Graphics/exercise_5_1_plot.eps", onefile=FALSE, horizontal=FALSE) xs = seq( -2, +2, length.out=200 ) y1 = xs plot( xs, y1, type='l', col='red' ) y2 = xs^2 lines( xs, y2, col='green' ) y3 = xs^3 lines( xs, y3, col='black' ) y4 = 1/xs lines( xs, y4, col='blue' ) y5 = xs^(-2) lines( xs, y5, col='cyan' ) inds = xs > 0 y6 = sqrt(xs[inds]) lines( xs[inds], y6, col='orange' ) grid() legend(+0.5, -1, c("x", "x^2", "x^3", "1/x", "1/x^2", "sqrt(x)"), col = c('red','green','black','blue','cyan','orange'), lty = rep( 1, 6 ) ) #dev.off()