I am trying to calculate the fourier series of $f(x)=\sin x$ for $0<x<\pi$ and $f(x)=0$ for $-\pi<x<0$ and make the plots. I tried
f[x_] = If[x > 0, Sin[x], 0];
a[n_] := (2/L)*Integrate[f[x]*Cos[2 n*Pi*x/L], {x, -L/2, L/2}]
a[0] = (1/L)*Integrate[f[x], {x, -L/2, L/2}]
b[n_] := (2/L)*Integrate[f[x]*Sin[2 n*Pi*x/L], {x, -L/2, L/2}]
F[x_, N_] :=
a[o] + Sum[a[n]*Cos[2 n*Pi*x/L] + b[n]*Sin[2 n*Pi*x/L], {n, 1, N}]
p[N_, a_] :=
Plot[Evaluate[F[x, N]], {x, -a, a}, PlotRange -> All,
PlotPoints -> 200]
L = 2Pi;
a[n]
a[0]
b[n]
p[20, 1]
`
but the Plot doesn't seems correct. Then, for $f(x)=0?.$ What about the converge of the series?
L = 2Pi;
from the bottom of your code to the top and in your definition ofF[x_,N_]
changea[o]
toa[0]
and that will fix two of your problems. $\endgroup$FourierSeries
andFourierCoefficient
? $\endgroup$