Geometric description of the derivative

use the curve function to draw the function y = x^2

curve( x^2, from = -1, to = 5, main = expression(paste('plot of ',' ', x^2)), ylab = 'y') 

#labels the x and y axes, and specifies the x, values for which the plot should be displayed
#now create some vectors to store your point values for the triangle you want
x<-c(2,4,4) 
y<-c(4,4,16)
curve( x^2, from = -1, to = 5, main = expression(paste('plot of ',' ', x^2)), ylab = 'y') 
polygon(x,y) #draws a triangle based upon the values saved in x and y

x<-c(2,4,4) 
y<-c(4,4,16)
curve( x^2, from = -1, to = 5, main = expression(paste('plot of ',' ', x^2)), ylab = 'y') 
polygon(x,y)
text(1.5, 4.4174806,expression(paste('P = (',x[0],',',y[0],')') ), cex = 0.75) 
text(3.3, 15.812544,expression(paste('Q = (',x[0], '+', Delta,'x',',',y[0], '+', Delta,'y',')') ),cex = 0.75)

points(x,y,pch = 19) 

#text() adds text to plot (first you need the point you want to plot it at, in this case you use the locator function which positions the function based on mouse click, the you use the expression function to write mathematical notation, and finally you use the cex command to specify that the text should be 3/4 the size of the normal text )
#paste() within the expression converts all of the symbols into characters
#points() adds points
x<-c(2,4,4) 
y<-c(4,4,16)
curve( x^2, from = -1, to = 5, main = expression(paste('plot of ',' ', x^2)), ylab = 'y') 
polygon(x,y)
text(1.5, 4.4174806,expression(paste('P = (',x[0],',',y[0],')') ), cex = 0.75) 
text(3.3, 15.812544,expression(paste('Q = (',x[0], '+', Delta,'x',',',y[0], '+', Delta,'y',')') ),cex = 0.75)

#add label for R, delta x and delta y
points(x,y,pch = 19) 
text(4.2,4,'R',cex = 0.75) 
text(3,3,expression(paste(Delta,'x')),cex=0.75)
text(4.1,11,expression(paste(Delta,'y')),cex=0.75)