Staircase curve by integration of cosine sums


NN = 12
xmax = 35;
ListLinePlot[
Table[Sum[Cos[x*(k - 1)/NN*2*Pi], {k, 1, NN}], {x, 0, xmax, 0.1}],
PlotRange -> {-4, NN + 1/2}]
ListLinePlot[
Table[Sum[Cos[x*(k)/NN*2*Pi], {k, 1, NN}], {x, 0, xmax, 0.1}],
PlotRange -> {-4, NN + 1/2}]
a = Table[
Sum[(Cos[x*(k)/NN*2*Pi] + Cos[x*(k - 1)/NN*2*Pi])/2, {k, 1,
NN}], {x, 0, xmax, 0.1}];
N[Max[a], 40]
ListLinePlot[
Table[Sum[(Cos[x*(k)/NN*2*Pi] + Cos[x*(k - 1)/NN*2*Pi])/2, {k, 1,
NN}], {x, 0, xmax, 0.1}], PlotRange -> {-4, NN + 1/2}]
ListLinePlot[Accumulate[a]]

By integration:

(*program start*)NN = 12
xmax = 35;
ListLinePlot[
Table[Sum[(Cos[x*(k)/NN*2*Pi] + Cos[x*(k – 1)/NN*2*Pi])/2, {k, 1,
NN}], {x, 0, xmax, 0.1}], PlotRange -> {-4, NN + 1/2}]

ListLinePlot[
Table[Sum[(3 Sin[
1/6 (-1 + k) \[Pi] x])/((-1 + k) \[Pi]) + (3 Sin[(k \[Pi] x)/
6])/(k \[Pi]), {k, 1.000001, NN}], {x, 0, xmax*2, 0.1}],
PlotRange -> {-4, NN*3}, DataRange -> {0, 250}, ImageSize -> Full,
GridLines -> Automatic]
(*program end*)

Advertisements
This entry was posted in Uncategorized. Bookmark the permalink.