Is the Fourier Series correct?

146 Views Asked by At

Could you tell me if the following Fourier series of the function $f(x)=x^2, -\frac{L}{2} \leq x \leq \frac{L}{2}$ is correct?? $$$$ $$a_0=\frac{2}{L} \int_{-\frac{L}{2}}^{\frac{L}{2}}{x^2}dx=\frac{L^2}{6}$$ $$a_n=\frac{2}{L} \int_{-\frac{L}{2}}^{\frac{L}{2}}{x^2 \cos(\frac{2 n \pi x }{L})}dx=\frac{L^2}{n^2 \pi^2}(-1)^n$$ $$b_n=\frac{2}{L} \int_{-\frac{L}{2}}^{\frac{L}{2}}{x^2 \sin(\frac{2 n \pi x }{L})}dx=0$$

So the Fourier series is: $$f(x) \sim \frac{L^2}{12}+\frac{L^2}{\pi^2} \sum_{n=1}^{\infty}{\frac{(-1)^n}{n^2} \cos(\frac{2 n \pi x}{L})}$$

1

There are 1 best solutions below

1
On BEST ANSWER

The gnuplot command sequence (for $L=1$)

c(n,x)=((n%2==0)?1:-1)*cos(2*pi*n*x)/(pi**2*n**2)
f(n,x)=(n==0)?(1.0/12):c(n,x)+f(n-1,x)

set zeroa
set samp 250

pl [-1:2][-0.1:0.5]  f(3,x), f(7,x), f(15,x), x**2

set term push
set term png
set outp 'fourier-xx.png'
replot
unset outp
set term pop

results in the plot

Fourier sums for x^2

which looks right.