import math


def CalculateRelativeChange(before, after):
  """Returns the relative change of before and after, relative to before.

  There are several different ways to define relative difference between
  two numbers; sometimes it is defined as relative to the smaller number,
  or to the mean of the two numbers. This version returns the difference
  relative to the first of the two numbers.

  Args:
    before: A number representing an earlier value.
    after: Another number, representing a later value.

  Returns:
    A non-negative floating point number; 0.1 represents a 10% change.
  """
  if before == after:
    return 0.0
  if before == 0:
    return float('nan')
  difference = after - before
  return math.fabs(difference / before)