Computes the cosine function.