SetDirectory[$HomeDirectory<>"/Documents/handouts/math467/FourierConv"]

PeriodicExtension[f_,L_][x_]:=f[Mod[x,2L,-L]]

EvenExtension[f_,L_][x_]:=PeriodicExtension[Piecewise[{{f[#],0≤#≤L},{f[-#],-L≤#≤0}}]&,L][x]

OddExtension[f_,L_][x_]:=PeriodicExtension[Piecewise[{{f[#],0≤#≤L},{-f[-#],-L≤#≤0}}]&,L][x]

Example 01

f[x_]:=Piecewise[{{x,-1≤x<0},{0,0≤x<1}}]

Show[Plot[PeriodicExtension[f,1][x],{x,-3,3},PlotStyle->Thick],ListPlot[Table[{x,-1/2},{x,-3,3,2}],PlotMarkers->{●}],AxesLabel->{"x","f(x)"},PlotRange->{-1,1}]

Export["example01fs.pdf",%,"PDF"]

Export["example01fs.eps",%%,"EPS"]

Example 02

Integrate[2x,{x,0,π}]/π

Integrate[2x Cos[n x],{x,0,π},Assumptions->{n∈Integers}]/π

Sum[1/(((2n-1))^2),{n,1,Infinity}]

Example 03

f[x_]:=Piecewise[{{-1,-π≤x<0},{0,x==0},{1,0≤x≤π}}]

f[x_]:=(x^4)

f[x_]:=Sin[x]/x

Integrate[f[x],{x,-π,π}]/π

Integrate[f[x] Cos[n x],{x,-π,π},Assumptions->{n∈Integers}]/π

Integrate[f[x]Sin[n x],{x,-π,π},Assumptions->{n∈Integers}]/π

2Integrate[Sin[n x],{x,0,π},Assumptions->{n∈Integers}]/π

Show[Plot[PeriodicExtension[f,π][x],{x,-3π,3π},PlotStyle->Thick],ListPlot[Table[{x,0},{x,-3π,3π,π}],PlotMarkers->{●}],AxesLabel->{"x","f(x)"},PlotRange->{-1,1}]

Export["example03fs.pdf",%,"PDF"]

Export["example03fs.eps",%%,"EPS"]

Sum[(((-1))^n)/(2n-1),{n,1,Infinity}]

fsim[n_][x_]:=4Sum[Sin[(2k-1)x]/(2k-1),{k,1,n}]/π

Plot[Evaluate[Table[fsim[n][x],{n,5,20,5}]],{x,-π,π},AxesLabel->{"x","y"},PlotLegends->{"N=5","N=10","N=15","N=20"}]

Export["gibbs.pdf",%,"PDF"]

Export["gibbs.eps",%%,"EPS"]

Plot[Evaluate[Table[fsim[n][x],{n,5,20,5}]],{x,0,1/2},AxesLabel->{"x","y"},PlotLegends->{"N=5","N=10","N=15","N=20"},Epilog->{Black,Line[{{0,1},{1/2,1}}]}]

Export["gibbsdetail.pdf",%,"PDF"]

Export["gibbsdetail.eps",%%,"EPS"]

Uniform Convergence

g[n_][x_]:=(x^n)Exp[-n x]

Plot[Evaluate[Table[g[n][x],{n,1,5}]],{x,0,2},AxesLabel->{"x","y"},PlotLegends->"Expressions"]

Export["uniform.pdf",%,"PDF"]

Export["uniform.eps",%%,"EPS"]

g[n]'[x]

Solve[%==0,x]