Solving a Differential Equation with a Fourier Series

AI Thread Summary
The discussion focuses on solving a differential equation using Fourier series, specifically finding the coefficients a_n and b_n for the function defined piecewise. The calculated coefficients are a_0 = π^3/3, a_n = 2(-1)^n/n^2, and b_n = 2/(πn^3) + π(-1)^n/n - 2(-1)^n/(πn^3). Participants verify the correctness of these coefficients and discuss potential sign errors in the calculations. The thread concludes with encouragement and sharing of plots demonstrating the Fourier series approximation of the function.
VinnyCee
Messages
486
Reaction score
0
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

Answer(supposedly):

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]

Is this the final answer?
 
Physics news on Phys.org
Can anyone type this into mathematica?

Please double check :biggrin:
 
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:
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?
 
I think I see several sign mistakes, with the last sign being wrong. Why not reduce the last expression n/n^3??
 
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
 
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!
 
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
 
So, the an is:

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

Right?
 
  • #10
Looks good. Now go have another look at those b coefficients.

--J

Just one final left... Yay me!
 
  • #11
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
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
 

Attachments

  • Fourier.JPG
    Fourier.JPG
    12.8 KB · Views: 508
  • #13
Awesome plots.

Thanks a lot for the help.
 
Back
Top