compute local derivatives