# Help with correcting a simple example on FourierCoefficient

I am learning FourierCoefficient and trying to plot Cos with it.

1. Let us find it Fourier coefficients with FourierCoefficient[Cos[x], x, n]

$$\begin{array}{cc} \{ & \begin{array}{cc} \frac{1}{2} & n=-1\lor n=1 \\ 0 & \text{True} \\ \end{array} \\ \end{array}$$

2. I want to use 16 Fourier modes to approximate Cos:

nn = 16;

FTcoeffTab = Table[FTcoeff[m] == (KroneckerDelta[m, 1] + KroneckerDelta[m, -1])/2, {m, -nn/2, nn/2-1, 1}]

3. Construst the Fourier expansion of Cos and plot:

FT[x_] := Sum[FTcoeff[k]*Exp[I k x], {k, -nn/2, nn/2-1}]

Plot[FT[x], {x, -Pi, Pi}, PlotRange -> All]


• FTcoeff[m_] := (KroneckerDelta[m, 1] + KroneckerDelta[m, -1])/2, no need for Table. Then FT[x_]:=... and Plot. – Alx Aug 4 at 7:51
• Thanks. Your comment is actually the same as the answer by @Ulrich Neumann. – Nobody Aug 4 at 13:57

FTcoeff[m_] := (KroneckerDelta[m, 1] + KroneckerDelta[m, -1])/2

FT[x_, n _] := Sum[FTcoeff[k]*Exp[I k x], {k, -n /2, n /2 }]