def u_b97(x, gamma, polarized=False):
  """Evaluates auxiliary quantity u for B97-based functionals.

  10.1063/1.475007.
  Args:
    x: Float numpy array with shape (num_grids,), the reduced density gradient.
    gamma: Float, parameter.
    polarized: Boolean, whether the system is spin polarized.

  Returns:
    Float numpy array with shape (num_grids,), the auxiliary quantity u.
  """
  spin_factor = 1 if polarized else (1 / 2) ** (-2 / 3)
  s2 = spin_factor * x ** 2
  return gamma * s2 / (1 + gamma * s2)