def phi_chain(n):
    """
    For each number in 1 to n, compute the Smolyak indices for the
    corresponding basis functions. This is the :math:`n` in
    :math:`\\phi_n`

    Parameters
    ----------
    n : int
        The last Smolyak index :math:`n` for which the basis polynomial
        indices should be found

    Returns
    -------
    aphi_chain : dict (int -> list)
        A dictionary whose keys are the Smolyak index :math:`n` and
        values are lists containing all basis polynomial subscripts for
        that Smolyak index

    """
    aphi_chain = {}
    aphi_chain[1] = [1]
    aphi_chain[2] = [2, 3]
    curr_val = 4
    for i in range(3, n + 1):
        end_val = 2 ** (i - 1) + 1
        temp = range(curr_val, end_val + 1)
        aphi_chain[i] = temp
        curr_val = end_val + 1
    return aphi_chain
