import math


def eq141d7(l, ryc, afc, d, fy, e):
    """Compression in extreme fibers of flexural members allowable stress
    
    AREMA 2018 Table 15-1-11 Row 7 Equations
    
    Compression in extreme fibers of flexural members symmertical about the
    principal axis in the plane of the web (other than box-type flexural 
    members) that are rolled beams or welded built-up members with solid
    rectangular flanges, the larger of the values computer by the following
    
    
    fa_bc1 = (0.55*fy - 0.55*math.pow(fy,2)/
           (6.3*math.pow(math.pi,2)*e)*math.pow(l/ryc,2)
           
    fa_bc2 = 0.131*math.pi*e/(l*d*math.sqrt(1+mu)/afc)
    
    fa_bc3 = 0.55*fy
    
    fa_bc = min(max(fa1, fa2), fa3)
    
    
    Args:
        l (float): distance bwteen points of lateral support for the
                   compression flange, unbraced length [inches]
        
        ryc (float): minimum radius of gyration of the compression flange and
                    that portion of the web area on the compression side of the
                    axis of bending, about an axis in the plane of the 
                    web [inches]
                    
        afc (float): area of the smaller flange excluding any portion of the 
                    web [inches^2]
        
        d (float): overall dpeth of the member [inches]
        
        fy (float): yield stress [psi]
        
        e (float): modulus of elasticity [psi]
        
    Returns:
        fa_bc (float): allowable compression stress in extreme fibers of 
                    flexural members [psi]
        
    Notes:
        1. Units are in lbs and inches.
        2. Poisson's ratio, mu, is taken as 0.3.
    
    """
    ref_text = "AREMA 2018 Section 1.4.1 Table 15-1-11 Row 7 \n\n"
    
    user_input = (f'l = {l:.2f}, ryc = {ryc:.2f}, afc = {afc:.2f}, ' +
                  f'd = {d:.2f}, Fy = {fy:.2f}, E = {e:.2f} \n\n')
    
    mu = 0.3
    
    fa_bc1 = (0.55*fy - 0.55*math.pow(fy,2)/
           (6.3*math.pow(math.pi,2)*e)*math.pow(l/ryc,2))
           
    fa_bc2 = 0.131*math.pi*e/(l*d*math.sqrt(1+mu)/afc)
    
    fa_bc3 = 0.55*fy
    
    fa_bc = min(max(fa_bc1, fa_bc2), fa_bc3)
    
    text1 = (f'fa_bc1 = 0.55*fy - 0.55*math.pow(fy,2)/' +
             f'(6.3*math.pow(math.pi,2)*e)*math.pow(l/ryc,2) \n' +
             f'fa_bc1 = 0.55*{fy:.1f} - 0.55*math.pow({fy:.1f},2)/' +
             f'(6.3*math.pow(math.pi,2)*{e:.1f})' +
             f'*math.pow({l:.2f}/{ryc:.2f},2) \n' +
             f"""fa_bc1 = {fa_bc1:.1f} \n\n""")
    
    text2 = (f'fa_bc2 = 0.131*math.pi*e/(l*d*math.sqrt(1+mu)/afc) \n' +
             f'fa_bc2 = 0.131*math.pi*{e:.1f}/' +
             f'({l:.2f}*{d:.2f}*math.sqrt(1+{mu:.2f})/{afc:.2f}) \n' +
             f'fa_bc2 = {fa_bc2:.1f} \n\n')
    
    text3 = (f'fa_bc3 = 0.55*fy \n' +
             f'fa_bc3 = 0.55*{fy:.2f} \n' +
             f'fa_bc3 = {fa_bc3:.1f} \n\n')
    
    text4 = (f'fa_bc = min(max(fa_bc1, fa_bc2), fa_bc3) \n' +
             f'fa_bc = min(max({fa_bc1:.2f}, {fa_bc2:.2f}), {fa_bc3:.2f}) \n' +
             f'fa_bc = min({max(fa_bc1, fa_bc2):.2f}, {fa_bc3:.2f}) \n' +
             f'fa_bc = {min(max(fa_bc1, fa_bc2), fa_bc3):.1f} \n')
    
    text = ref_text + user_input + text1  + text2 + text3 + text4
    
    return fa_bc, text