import math


def keg_psi(temp, co2):
    """
    Calculate require keg pressure to carbonate liquid at ``temp`` with
    ``co2`` volumes of CO2

    From http://www.wetnewf.org/pdfs/Brewing_articles/CO2%20Volumes.pdf

    V = (P + 14.695) * ( 0.01821 + 0.09011*EXP(-(T-32)/43.11) ) - 0.003342

    :arg temp: Temperature of liquid in keg in fahrenheit
    :arg co2: Volume of CO2 required
    :returns: The PSI value to set the regulator to
    """
    henry_coeff = 0.01821 + 0.09011 * math.exp(-(temp - 32) / 43.11)
    pressure = ((co2 + 0.003342) / henry_coeff) - 14.695
    return pressure