def mp_curl_ratio(gamma, a_tension, b_tension): # <<<
    """The curl ratio subroutine has three arguments, which our previous
    notation encourages us to call gamma, 1/alpha, and 1/beta. It is a somewhat
    tedious program to calculate
      [(3-alpha)alpha^2 gamma + beta^3] / [alpha^3 gamma + (3-beta)beta^2],
    with the result reduced to 4 if it exceeds 4. (This reduction of curl is
    necessary only if the curl and tension are both large.) The values of alpha
    and beta will be at most 4/3.

    See mp.pdf (items 365, 366)."""
    alpha = 1.0/a_tension
    beta = 1.0/b_tension
    return min(4.0, ((3.0-alpha)*alpha**2*gamma + beta**3) /
                    (alpha**3*gamma + (3.0-beta)*beta**2))