Check gradient using relative error