I don't know why I get the simple Sobel wrong

It shouldn't affect anything though. It should be:

(f(x + h) - f(x - h)) / 2h

or

(f(x) - f(x - h)) / h