Simple cost derivative func