Calculate relative error (#597)