y(x)=x3-2x+1;
y(x+h)=(x+h)3-2(x+h)+1=x3+3hx2+3h2x-2x-2h+1;
y(x+h)-y(x)=3hx2+3h2x-2h.
The gradient or slope between x and x+h is (3hx2+3h2x-2h)/(x+h-x)=3x2+3hx-2.
As h→0 this expression becomes 3x2-2, which is the differential of x3-2x+1 with respect to x.