import math


def calc_vo2(distance, time):
    """Calculate VO2 max based on a race result.

    Taken from Daniels and Gilbert. See, for example:
    * http://www.simpsonassociatesinc.com/runningmath1.htm
    * "The Conditioning for Distance Running -- the Scientific Aspects"

    Parameters
    ----------
    distance : float
        Race distance in meters.
    time : float
        Race result in seconds.

    Returns
    -------
    vo2_max : float
        Estimated VO2 max.
    """
    minutes = time/60.0
    velocity = distance/minutes
    percent_max = (0.8 + 0.1894393*math.exp(-0.012778*minutes) +
                   0.2989558*math.exp(-0.1932605*minutes))
    vo2 = (-4.60 + 0.182258*velocity + 0.000104*pow(velocity, 2))
    return vo2/percent_max