# How do I plot the Fourier series for a square wave? [closed]

f (t) = (4/pi) Sum[(1/n) sin (2 pi (f (t))), {n, 1, Infinity}]


## closed as off-topic by m_goldberg, corey979, bbgodfrey, Artes, J. M. will be back soon♦Nov 1 '17 at 2:52

This question appears to be off-topic. The users who voted to close gave this specific reason:

• "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – m_goldberg, corey979, Artes, J. M. will be back soon
If this question can be reworded to fit the rules in the help center, please edit the question.

Once you have the function and its Fourier representation, you can try with this:

f[t_] = (4/Pi) Sum[(1/n) Sin[2 Pi n t], {n, 1, \[Infinity], 2}];
fserf[t_,nmax_] := (4/Pi) Sum[(1/n) Sin[2 Pi n t], {n, 1, 2*nmax-1, 2}];
GraphicsGrid[
Partition[
Plot[{f[t], fserf[t, #]}, {t, 0, 3}, PlotLabel -> ToString[#] <> " Terms"]
&/@ {3, 5, 10, 20}, 2],
ImageSize -> Large]


Even use Manipulateto interactively see how the series works:

f[t_] = (4/Pi) Sum[(1/n) Sin[2 Pi n t], {n, 1, \[Infinity], 2}];
fserf[t_, nmax_] := (4/Pi) Sum[(1/n) Sin[2 Pi n t], {n, 1, 2*nmax-1, 2}];
Manipulate[
Plot[{f[t], fserf[t, nmax]}, {t, 0, scale},PlotLabel-> ToString[nmax] <> " Terms", PlotRange -> {-1.5, 1.5}],
{{nmax, 1, "Nº of Terms"}, 1, 50, 1, Appearance -> "Labeled"},
{{scale, 1, "x-axis length"}, 1, 5, 1, Appearance -> "Labeled"}
]


First you need to learn the proper syntax for writing Mathematica expressions. When the sum is written properly as

f[t_] = (4/Pi) Sum[(1/n) Sin[2 Pi n t], {n, 1, ∞, 2}]


(2 I (ArcTanh[E^(-2 I π t)] - ArcTanh[E^(2 I π t)]))/π

then the plot is simple:

Plot[f[t], {t, 0, 3}]


plot