To differentiate from first principles, you need to consider two points on the curve that are very close to each other. To find the gradient between them, you would divide the difference in y by the difference in x.
Using yours, one point would be (k, k³ + 12k - 9) and the other would be (k + h, [k+h]³ + 12[k + h] - 9). {Different brackets used for clarity.}
Expanding the y-part of k+h gives k³ + 3k²h + 3kh² + h³ + 12k + 12h - 9.
That means that the difference in y is 3k²h + 3kh² + h³ + 12h and the difference in x is h, obviously.
The gradient is found by dividing the difference in y by the difference in x, which is 3k² + 3kh + h² + 12. The gradient at a point would be when k and k+h are in the same place and so h would be 0. Substituting h = 0 into the gradient gives dy/dx = 3k² + 12. Put x back in to get 3x² + 12.