The Fourier series express a periodic function in terms of sines and cosines, but with a precise relation between their periods. Let me explain.
If $f$ is a periodic function with period $T$ (i.e. $f(x+T) = f(x)$), then roughly speaking (I'll not worry about convergence issues) its Fourier series will be
\begin{equation*}
\begin{split}
\mathcal{F}(f)(x) & = \sum_{n=1}^{+\infty} a_n \sin\Big( \frac{2\pi n}{T}x\Big) + b_n \cos\Big( \frac{2\pi n}{T}x\Big) = \\
& = \underbrace{\Big( a_1 \sin\Big( \frac{2\pi}{T}x\Big) + b_1 \cos\Big( \frac{2\pi}{T}x\Big) \Big)}_{\text{First term, period } T_0} + \underbrace{\Big( a_2 \sin\Big( \frac{2\pi·2}{T}x\Big) + b_2 \cos\Big( \frac{2\pi· 2}{T}x\Big) \Big)}_{\text{Second term, period } 1/2·T_0} + \cdots
\end{split}
\end{equation*}
So the relation between the periods of each term of the series is that they decrease in $\frac{1}{n}$ at the $n$-th term with respect to the first one, the periods are related in a rational way.
In the case of the function $\cos(\pi x) + \sin(3 x)$, the periods of the terms are not related in a rational way (in fact the first one is rational, but not the second one), so you must compute its Fourier series, which will not be the same as the function itself (first you need to determine the period $T$ of such a function).