gradient for sigmoid function
finished ex4, starting ex5