# Frustrated by Fourier series

1. Sep 20, 2011

### estro

I'm trying to get fourier series for some function however I get the same nonsense series each time:

$$f(x)=\begin{cases} 0, & \mbox{if x \in [-\pi,0]}\\ x, & \mbox{if x \in (0,\pi)} \end{cases}$$

$$\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$$

$$=\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}$$

$$a_n=\frac{1-(-1)^n}{\pi n^2}$$

$$\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}$$

$$b_n=-\frac{(-1)^n}{n}$$

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' \cdot F_2...$$
You can also see the same on this picture:

Last edited: Sep 20, 2011
2. Sep 20, 2011

### glebovg

3. Sep 20, 2011

### glebovg

4. Sep 20, 2011

### LCKurtz

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

5. Sep 20, 2011

### estro

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'(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}$$

6. Sep 20, 2011

### LCKurtz

That formula is incorrect. That + should be a -.

7. Sep 20, 2011

### LCKurtz

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'(x)F(x)\, dx$$

Last edited: Sep 20, 2011
8. Sep 20, 2011

### estro

Oh this is embarrassing mistake...

Thanks [again]!