Simpler way to compute cosine basis functions