Roundoff error analysis of the fast cosine transform and its application to the Chebyshev pseudospectral method