Why Are My Fourier Series Calculations Giving Me Nonsense Results?

estro
Messages
239
Reaction score
0
I'm trying to get Fourier series for some function however I get the same nonsense series each time:

<br /> f(x)=\begin{cases}<br /> 0, &amp; \mbox{if x $\in [-\pi,0]$}\\<br /> x, &amp; \mbox{if x $\in (0,\pi)$} \end{cases}<br />

<br /> \pi a_n=\int_{-\pi}^\pi f(x)cos(nx)dx=\int_{-\pi}^0 0 \cdot cos(nx)dx+\int_0^\pi xcos(nx)dx=\left.\left[\frac{xsin(nx)}{n}-\frac{cos(nx)} {n^2}\right]\right|_0^\pi<br />

<br /> =\frac{\pi sin(n\pi)}{n}-\frac{cos(n\pi)} {n^2} - \frac{0 sin(0)}{n}+ \frac {cos(0)} {n^2}=\frac {1-(-1)^n}{n^2}<br />

<br /> a_n=\frac{1-(-1)^n}{\pi n^2}<br />

<br /> \pi b_n=\int_{-\pi}^\pi f(x)sin(nx)dx=\int_{-\pi}^0 0 \cdot sin(nx)dx+\int_0^\pi xsin(nx)dx=\left. \left[-\frac{xcos(nx)}{n}-\frac{sin(nx)}{n^2}\right] \right|_0^\pi=-\frac{\pi (-1)^n}{n}<br />

<br /> b_n=-\frac{(-1)^n}{n}<br />


WolframAlpha suggests that I wrongly calculated the integral, however I used well know theorem:
\int p(x)f(x)dx=p \cdot F_1+p&#039; \cdot F_2...
You can also see the same on this picture:
0.jpeg
 
Last edited:
Physics news on Phys.org
estro said:
<br /> \pi a_n=\int_{-\pi}^\pi f(x)cos(nx)dx=\int_{-\pi}^0 0 \cdot cos(nx)dx+\int_0^\pi xcos(nx)dx=\left.\left[\frac{xsin(nx)}{n}-\frac{cos(nx)} {n^2}\right]\right|_0^\pi<br />

That last minus should be a plus; that's all that is wrong.
 
LCKurtz said:
That last minus should be a plus; that's all that is wrong.

Sorry but I don't understand why.

if p(x) is polynomial and f(x) is continues in I then:
\int p(x)f(x)dx=p(x)F_1+p&#039;(x)F_2 where F_1 is integral of f(x) and F_2 is the integral of the integral of f(x)

p(x)=x, p'(x)=1
f(x)=cos(nx)
\int f(x)=F_1=\frac{sin(nx)}{n}
\int F_1=F_2=\frac{-cos(nx)}{n^2}

Thus: \int xcos(nx)=\frac{sin(nx)}{n}-\frac{cos(nx)}{n^2}
 
estro said:
Sorry but I don't understand why.

if p(x) is polynomial and f(x) is continues in I then:
\int p(x)f(x)dx=p(x)F_1+p&#039;(x)F_2 where F_1 is integral of f(x) and F_2 is the integral of the integral of f(x)

That formula is incorrect. That + should be a -.
 
LCKurtz said:
That formula is incorrect. That + should be a -.

Actually, there is more than that wrong with it. If F(x) is an antiderivative of f(x):

\int p(x)f(x)\, dx = p(x)F(x) -\int p&#039;(x)F(x)\, dx
 
Last edited:
Oh this is embarrassing mistake...

Thanks [again]!
 
Back
Top