Let’s plot the sine curve.

To do this we need to vectors, x and y. We will say that y is a function of x, thus

\[ y = sin(x) \]

The x values are the input and the y-values are the output.
I will use the seq command to generate a sequence of x values from 0 to 2pi that increment by 0.01..

I then set y = sin(the values that are stored in the vector x), this will create a vector of the same size as x.

 x=seq(0,2*pi,0.01)
 y=sin(x)
 plot(x,y,type='l', main = "Plot of y = sin(x)")

\[ y' = cos(x) \]

 x1=seq(0,2*pi,0.01)
 y1=cos(x1)

 plot(x1,y1,type='l', main = "Plot of y' = cos(x)")
abline(h = 0, col = "red")

The derivative is at 0 when the cosine function intersects with the red line.