def frohner_cor_3rd_order(sig1,sig2,sig3,n1,n2,n3):
    """
    Takes cross-sections [barns] and atom densities [atoms/barn] for 
    three thicknesses of the same sample, and returns extrapolated 
    cross section according to Frohner.

    Parameters
    ----------
    sig1 : array_like
        Cross section of the thinnest of the three samples.
    sig2 : array_like
        Cross section of the mid-thickness of the three samples.
    sig3 : array_like
        Cross section of the thickest of the three samples.
    n1 : float
        Atom density of the thinnest sample
    n2 : float 
        Atom density of the mid-thickness sample
    n3 : float
        Atom density of the thickest sample

    Returns
    -------
    sig0 : array_like
        The extrapolated cross section from sig1, sig2, and sig3
    """

    # two terms in the numerator
    numer1 = (n1*sig2-n2*sig1)*(n3**2-n1**2-(n1-n3)/(n1-n2)*(n2**2-n1**2))
    numer2 = (n1*n2**2-n1**2*n2)*(sig3-sig2-(n1-n3)/(n1-n2)*(sig2-sig1))
    denom = (n1-n2)*(n3**2-n1**2) - (n1-n3)*(n2**2-n1**2)
    
    return (numer1-numer2)/denom