f(x)=x2-12x+1; f(x+h)=(x+h)2-12(x+h)+1. Expanding this we get x2+2xh+h2-12x-12h+1.
f(x) has a point (x,f(x)) on the curve when f(x) is graphed. If h is small, f(x+h) is the value of the function at a nearby point (x+h,f(x+h)). If the two points are joined, they form the hypotenuse of a right triangle and the horizontal leg has length h (a horizontal displacement of h from the original point), while the vertical leg has length f(x+h)-f(x). The gradient or slope (the average rate of change) is (vertical displacement)/(horizontal displacement). We know the horizontal displacement is h, and the vertical displacement is:
(x2+2xh+h2-12x-12h+1)-(x2-12x+1)=2xh+h2-12h. Divide this by h and we get: 2x+h-12. If h is very small, it can be ignored in comparison to the other terms. Normally h→0 and as it does so this expression (the derivative) becomes 2x-12.