import math


def _guess_alpha_from_vol_atm(underlying, vol_atm, beta):
    """_guess_alpha_from_vol_atm_
    guess alpha from volatility at the money
    by using Hagan's approximated atm implied volatility.

    .. math::
        \ln\sigma(F, F)
            \\approx \ln \\alpha - (1 - \\beta) \ln F

    :param float underlying: must be positive.
    :param float vol_atm: volatility at the money. This must be positive.
    :param float beta:

    :return: alpha.
    :rtype: float.
    """
    assert(underlying > 0.0)
    assert(vol_atm > 0.0)
    ln_underlying = math.log(underlying)
    ln_vol_atm = math.log(vol_atm)
    one_minus_beta = 1.0 - beta
    ln_alpha = ln_vol_atm + one_minus_beta * ln_underlying
    return math.exp(ln_alpha)