Estimating Fourier parameters using least squar emethod

I'm given that

$$\sum_{t=1}^N \epsilon^2(t) = \sum_{t=1}^N\left[y(t) - \sum_{n=0}^{N/2}\left\{a_n\cos\left(\frac{2\pi nt}{N}\right) + b_n\sin\left(\frac{2\pi nt}{N}\right)\right\}\right]^2$$

and am required to derive $$\hat{a}_0$$, $$\hat{a}_{N/2}$$, $$\hat{b}_0$$, $$\hat{b}_{N/2}$$ and $$\hat{a}_n$$, $$\hat{b}_n$$ for $$n = 1, \cdots (N/2)-1$$.

So far, I've derived these expressions for $$a$$

$$0 = \sum_{t=1}^N\left[-2\sum_{n=0}^{N/2}\cos\left(\frac{2\pi nt}{N}\right)\left(y(t) - \sum_{n=0}^{N/2}a_n\cos\left(\frac{2\pi nt}{N}\right)-\sum_{n=0}^{N/2}b_n\sin\left(\frac{2\pi nt}{N}\right)\right)\right]$$

Which gives $$\hat{a}_0 = \bar{y}$$ for $$n=0$$ which is correct, but for $$n = N/2$$ it gives $$\hat{a}_{N/2} = \sum_{t=1}^N y(t)\cos(\pi t)$$ but it should be $$\hat{a}_{N/2} = \sum_{t=1}^N (-1)^t/N$$ which I'm not arriving at.

For $$b$$

$$0 = \sum_{t=1}^N\left[-2\sum_{n=0}^{N/2}\sin\left(\frac{2\pi nt}{N}\right)\left(y(t) - \sum_{n=0}^{N/2}a_n\cos\left(\frac{2\pi nt}{N}\right)-\sum_{n=0}^{N/2}b_n\sin\left(\frac{2\pi nt}{N}\right)\right)\right]$$

Which, for $$n=0$$ and $$n=N/2$$ caused the whole expression to go to $$0$$, which I guess it okay since $$\hat{b}_0$$ and $$\hat{b}_{N/2}$$ are $$0$$.

The expressions for the parameters are $$\hat{a}_0 = \bar{y}$$, $$\hat{a}_{N/2} = \sum_{t=1}^N (-1)^t/N$$, $$\hat{b}_0 = 0 = \hat{b}_{N/2}$$ and

$$\hat{a}_n = \frac{2}{N}\sum_{t=0}^Ny(t)\cos(2\pi nt/N)$$ $$\hat{b}_n = \frac{2}{N}\sum_{t=0}^Ny(t)\sin(2\pi nt/N)$$

• Use $\cos(\pi t)=(-1)^t$ for integral $t.$ – whuber Nov 21 '18 at 19:48
• but it still leaves $\sum_{t=1}^N y(t)$ in $\hat{a}_{N/2}$ expression – Syed Ali Nov 23 '18 at 16:51
• Since you haven't made any assumptions about $y,$ we must presume that all coefficients really do depend on $y.$ You should therefore suspect typographical errors in the "correct" formula. – whuber Nov 23 '18 at 16:53