# Solving a Differential Equation with a Fourier Series

1. Jun 7, 2005

### VinnyCee

I am not sure I am doing this correctly, so here it is.

Problem:

Find the Fourier Series

$$f(s)\,=\,\left\{\begin{array}{ccc}x^2&-\pi\,<\,x\,<\,0\\0 &0\,<x\,<\,\pi \\}\end{array}\right$$

$$a_0\,=\,\frac{\pi^3}{3}$$

$$a_n\,=\,-\frac{2}{n^2}$$

$$b_n\,=\,\frac{4\,-\,n^2\,\pi^2}{n^3\,\pi}$$

Does that look right? If so, where do I gofrom here?

$$f(s)\,\approx\,\frac{\pi^3}{3}\,+\,\sum_{n\,=\,1}^{\infty}\,\left[-\frac{2}{n^2}\,cos(n\,x)\,+\,\frac{4\,-\,n^2\,\pi^2}{n^3\,\pi}\,sin(n\,x)\right]$$

2. Jun 7, 2005

### VinnyCee

Can anyone type this into mathematica?

3. Jun 7, 2005

### VinnyCee

Here is how I got the a0, an and bn factors

$$a_0\,=\,\frac{1}{\pi}\,\int_{-\pi}^{0}\,x^2\,dx\,=\,\frac{\pi^2}{3}$$

$$a_n\,=\,\frac{1}{\pi}\,\int_{-\pi}^{0}\,x^2\,cos\,(n\,x)\,dx$$

$$a_n\,=\,\frac{1}{\pi}\,\left[\frac{x^2\,sin\,(n\,x)}{n}\,+\,\frac{2\,x\,cos\,(n\,x)}{n^2}\,-\,\frac{2\,sin\,(n\,x)}{n^3}\right]_{-\pi}^{0}$$

Right? Then:

$$a_n\,=\,-\frac{2}{n^2}$$

Am I on the right track here? or am i completely missing something?

Last edited: Jun 7, 2005
4. Jun 7, 2005

### VinnyCee

Or is this how to solve a_n?

$$a_n\,=\,\frac{1}{\pi}\,\int_{-\pi}^{0}\,x^2\,cos\,(n\,x)\,dx\,=\,\frac{1}{\pi}\,\left[\frac{n^2\,x^2\,sin\,(n\,x)\,-\,2\,sin\,(n\,x)\,+\,2\,n\,x\,cos\,(n\,x)}{n^3}\right]_{-\pi}^{0}$$

$$a_n\,=\,\frac{1}{\pi}\,\left[\frac{(-\pi)^2\,n^2\,sin\,(-\pi\,n)\,-\,2\,sin\,(-\pi\,n)\,-\,2\,\pi\,n\,cos\,(-\pi\,n)}{n^3}\right]\,=\,\frac{1}{\pi}\,\left[\frac{2\,\pi\,n\,cos\,(-\pi\,n)}{n^3}\right]$$

$$a_n\,=\,\frac{1}{\pi}\,\left[\frac{-2\,\pi\,n\,(-1)^n}{n^3}\right]\,=\,\frac{-2\,n\,(-1)^n}{n^3}$$

Which one is correct?

5. Jun 8, 2005

### OlderDan

I think I see several sign mistakes, with the last sign being wrong. Why not reduce the last expression n/n^3??

6. Jun 8, 2005

### Justin Lazear

You need to revisit your bn with your newly refound knowledge of the behavior of sine and cosine.

The sign of your an term is indeed incorrect.

Why do I let myself get dragged into other people's problems? *sighs* Back to finals! Work, damn me!

--J

7. Jun 8, 2005

### VinnyCee

Is this the correct an then?

Is the term below right for an?

$$a_n\,=\,\frac{1}{\pi}\,\left[\frac{-2\,\pi\,n\,(-1)^n}{n^3}\right]\,=\,\frac{-2\,n\,(-1)^n}{n^3}\,=\,-\frac{2\,(-1)^n}{n^2}$$

Thanks again!

8. Jun 8, 2005

### Justin Lazear

You got an extra negative. $\cos{n\pi} = (-1)^n$, which we can verify by noting that when n = 0, $n\pi = 0$, so $\cos{n\pi} = 1$. Additionally, when n = 1, we just have cosine of pi, which is -1. So we must have (-1)n instead of (-1)n-1.

--J

9. Jun 8, 2005

### VinnyCee

So, the an is:

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

Right?

10. Jun 8, 2005

### Justin Lazear

Looks good. Now go have another look at those b coefficients.

--J

Just one final left... Yay me!

11. Jun 8, 2005

### VinnyCee

Now for the bn!

$$b_n\,=\,\frac{1}{\pi}\,\int_{-\pi}^{0}\,x^2\,sin\,(n\,x)\,dx\,=\,\frac{1}{\pi}\,\left[\frac{-n^2\,x^2\,cos\,(n\,x)\,+\,2\,cos\,(n\,x)\,2\,n\,x\,sin\,(n\,x)}{n^3}\right]_{-\pi}^{0}$$

$$b_n\,=\,\frac{1}{\pi}\,\left[\frac{2}{n^3}\,+\,\frac{\pi^2\,(-1)^n}{n}\,-\,\frac{2\,(-1)^n}{n^3}\right]$$

$$b_n\,=\,\frac{2}{\pi\,n^3}\,+\,\frac{\pi\,(-1)^n}{n}\,-\,\frac{2\,(-1)^n}{\pi\,n^3}$$

Does that look right also?

Good luck on the final! I feel for you man.

12. Jun 8, 2005

### Justin Lazear

Looks like you got it.

And just in case you were interested, here's some plots of the fourier series truncated to 5, 15, 50, and 500 terms. Can't even tell it's not the function itself in the 500 one, can ya'?

Good job.

--J

#### Attached Files:

• ###### Fourier.JPG
File size:
12.8 KB
Views:
66
13. Jun 8, 2005

### VinnyCee

Awesome plots.

Thanks alot for the help.