import math


def min_cosine(sequence):
    """
    Returns the index of the item in the sequence whose cosine
    is smallest.

    Precondition: the sequence is a non-empty sequence of numbers.
    """
    # ------------------------------------------------------------------
    # Very similar to   min_index   above.  Just compare the COSINES
    #   of the numbers instead of the numbers themselves.
    # ------------------------------------------------------------------
    index_of_min = 0
    for k in range(1, len(sequence)):
        if math.cos(sequence[k]) < math.cos(sequence[index_of_min]):
            index_of_min = k

    return index_of_min