# Maximum number of Fourier terms in forecast package

I am using the forecast package in R to get some Fourier components - namely, function fourier(ts, K, ..). For a time series ts, K controls the maximum number of the Fourier terms one gets (sines + cosines of with different frequencies).

However, if the period of the time series is specified as 7, K is automatically capped at 3 maximum, or for other periods, $$\#\textrm{terms} = \frac{\textrm{Period}}{2}$$.

Why is that? I thought Fourier series can be represented by an infinite number of components. Is there some practical issue?

You are observing a discrete series. With a period of $$k$$ and a constant term already fitted, there are only $$k-1$$ degrees of freedom for the seasonal terms (there's only $$k$$ different means you can have in a period with $$k$$ times, but one is accounted for by the constant). This is the same df you get if you used seasonal dummies.
Because you have both $$\sin$$ and $$\cos$$ terms, you normally get two terms each harmonic. So with $$k=7$$, you get $$(k-1)/2=3\,$$ $$\sin$$ terms and $$(k-1)/2=3\,$$ $$\cos$$ terms. (With even $$k$$, you get one term at the end rather than two, because one - the highest order $$\sin$$ term - doesn't contribute anything.)