def AmOppCreditParts(exact, e87521, num, c00100, CR_AmOppRefundable_hc,
                     CR_AmOppNonRefundable_hc, c10960, c87668):
    """
    Applies a phaseout to the Form 8863, line 1, American Opportunity Credit
    amount, e87521, and then applies the 0.4 refundable rate.
    Logic corresponds to Form 8863, Part I.

    Notes
    -----
    Tax Law Parameters that are not parameterized:

        90000 : American Opportunity Credit phaseout income base

        10000 : American Opportunity Credit phaseout income range length

        1/1000 : American Opportunity Credit phaseout rate

        0.4 : American Opportunity Credit refundable rate

    Parameters
    ----------
        exact : whether or not to do rounding of phaseout fraction

        e87521 : total tentative American Opportunity Credit for all students,
                 Form 8863, line 1

        num : number of people filing jointly

        c00100 : AGI

        CR_AmOppRefundable_hc: haircut for the refundable portion of the
                               American Opportunity Credit

        CR_AmOppNonRefundable_hc: haircut for the nonrefundable portion of the
                                  American Opportunity Credit

    Returns
    -------
        c10960 : Refundable part of American Opportunity Credit

        c87668 : Tentative nonrefundable part of American Opportunity Credit
    """
    if e87521 > 0.:
        c87658 = max(0., 90000. * num - c00100)
        c87660 = 10000. * num
        if exact == 1:  # exact calculation as on tax forms
            c87662 = 1000. * min(1., round(c87658 / c87660, 3))
        else:
            c87662 = 1000. * min(1., c87658 / c87660)
        c87664 = c87662 * e87521 / 1000.
        c10960 = 0.4 * c87664 * (1. - CR_AmOppRefundable_hc)
        c87668 = c87664 - c10960 * (1. - CR_AmOppNonRefundable_hc)
    else:
        c10960 = 0.
        c87668 = 0.
    return (c10960, c87668)