When learning the derivative, the teacher explains this, assuming y=f (x), the derivative process of the point (X0,Y0) is as follows:
Set DX is a very small number
= Y0+dy=f (X0+DX)
= Dy=f (X0+DX)-y0
Then at this point the derivative a=dy/dx
This assumes that the DX is very small, so x0 to (X0+DX) is short, can be approximated to a straight line, then DY/DX can be regarded as the slope of the point (X0,y0) and the point (X0+dx,y0+dy) connected to a straight line
So the meaning of the derivative of a point can also be interpreted as the rate of change at that point
Here is a simple example using the R language:
Hypothesis: y=1/x, the derivative of the point (
X<-seq (0,3,by=0.0001)
y<-1/x # #生成模拟数据
D_point<-data.frame (x, y)
X0<-1
Y0<-1/x0 # #点 (a)
DX=0.0001 # #dx很小
dy<-1/(X0+DX)-y0
A<-DY/DX # #导数
B<-y0-a*x0 # #直线与y抽的截距
Library (GGPLOT2) # #画图
P<-ggplot (Subset (D_POINT,Y<=3), AES (x, y))
P+geom_line () +geom_abline (intercept=b, slope=a,linetype=2) +geom_point (Data=data.frame (X=1,y=1), AES (colour= "Red" ))
# #结果:
A simple example of using r language to achieve a derivative