def RF(a,b,c):
    """
    Compute Carlson's elliptic integral RF(a, b, c).

                   1  /\oo              dx
    RF(a, b, c) =  -  |   ------------------------------
                   2  |          1/2       1/2       1/2
                     \/0  (x + a)   (x + b)   (x + c)

    The parameters a, b, and c may be complex numbers.
    """
    A, B, C = a, b, c
    for k in range(5):
        gms = (A**0.5)*(B**0.5) + (A**0.5)*(C**0.5) + (B**0.5)*(C**0.5)
        A, B, C = (A+gms)/4, (B+gms)/4, (C+gms)/4
    avg0, avg = (a+b+c)/3., (A+B+C)/3
    X = (avg0 - a)/(avg * 4**5)
    Y = (avg0 - b)/(avg * 4**5)
    Z = -X - Y
    E2, E3 = X*Y - Z*Z, X*Y*Z
    return avg**-0.5 * (1. - E2/10. + E3/14. + E2*E2/24. - E2*E3*3./44.)