Expanding Function f(x)= x^2+xcosx in Fourier Series

rayman123
Messages
138
Reaction score
0
1. Homework Statement [/b
expand the function in Fourier seriesf(x)= x^2+xcosx
I divided the function in separate part and try to expand it in Fourier series separately
i have started with
x^2
a_{0}= \frac{1}{2\pi}\int_{-\infty}^{\infty}x^2dx=\frac{\pi^2}{3}

a_{n}= \frac{2}{\pi}\int_{0}^{\pi}x^2cosnxdx=\frac{2}{\pi}[\frac{x^2}{n}sinnx-2\int_{0}^{\pi}x\frac{sinx}{n}]dx=\frac{2}{\pi}[\frac{2\pi(-1)^n}{n^2}]=4\cdot\frac{(-1)^n}{n^2}\Rightarrow x^2= 4 \sum_{n=1}^{\infty}\frac{(-1)^n}{n^2}cosnx
x^2 if even function thenb_{n}=0

function f(x)=x is an odd function a_{n}= 0
b_{n}= \frac{2}{\pi}\int_{0}^{\pi}xsinnxdx=\frac{2}{\pi}[-\frac{x}{n}cosnx+\frac{1}{n}\int_{0}^{\pi}cosnxdx]=\frac{2}{\pi}[-\frac{\pi}{n}(-1)^n]=2 \sum_{n=1}^{\infty}\frac{(-1)^{n+1}}{n}sinnx
is this correct so far?
can someone help me and show me how to calculate the rest? I mean how to connect everything together with cosx?





Homework Equations





The Attempt at a Solution



 
Last edited:
Physics news on Phys.org
It would be handy if you tell us what the period of that function needs to be. From the looks of it you want it to have a period of 2\pi.

You're integrating the wrong function in every integral. You're supposed to integrate f(x)=x^2+x\cos x. Secondly some of your integrands are odd, therefore you can't just say that evaluating the integral between -pi and pi is the same as 2 times the integral between 0 and pi.
 
for |x|<\pi
my teacher did it in almost the same way but at the end he did something else with the xcosx part...
 
It doesn't matter what your teacher did. What does matter is that you're doing it wrong. I suspect that your teacher makes good use of his knowledge how even and odd functions behave when integrated over a symmetrical interval. It is not smart to try and copy a method that you don't understand.

For example you get the correct answer for a_0 by pure coincidence. In fact your integral for a_0 doesn't even converge.

This is the integral you should have calculated:

<br /> a_0=\frac{1}{2 \pi}\int_{-\pi}^\pi f(x)dx
 
well i calculated this integral once again and i get \frac{\pi^2}{3}
 
That is correct, but you calculated a different integral in your OP, which had the same answer by coincidence.

This is why it gave the same answer.

<br /> \begin{align*}<br /> a_0 &amp; =\frac{1}{2 \pi}\int_{-\pi}^\pi x^2+x \cos x dx \\<br /> &amp; = \underbrace{\frac{1}{2 \pi} \int_{-\pi}^\pi x^2 dx}_\text{even integrand}+\underbrace{\frac{1}{2 \pi}\int_{-\pi}^\pi x \cos x dx}_\text{odd integrand}<br /> \end{align*}<br />

The second integral goes to zero.
 
Last edited:
okej, i see it now.
but how to calculate coefficients a_{n} , b_{n} then?
the problem is that i am not able to say whether the function is odd or even...x^2 is even but xcosx is odd...but the whole function?
 
You can calculate the other coefficients in a similar way. Read post #6 again, because I just fixed the latex.

the problem is that i am not able to say whether the function is odd or even...LaTeX Code: x^2 is even but LaTeX Code: xcosx is odd...but the whole function?

If a function is even then f(-x)=f(x). If a function is odd then f(-x)=-f(x). You can use this to check that f(x) is neither even nor odd.
 
Last edited:
okej
so i started with a_{n}=\frac{1}{\pi}\int_{-\pi}^{\pi}x^2cos(nx)dx+\frac{1}{\pi}\int_{-\pi}^{\pi}xcosxcos(nx)dx

the first integral gave me
\frac{2}{n^2}[xcos(nx)]_{-\pi}^{\pi}]=\frac{4\pi}{n^2}(-1)^n hope its correct
how would you calculate the second one?
 
  • #10
The \pi shouldn't be there. As for the second integral. Is the integral even or odd?
 
  • #11
i would say the second integral is odd, should it give 0 then?
is the final substitution wrong in the first integral? whe \pi should not be there?
 
  • #12
Correct. The integrand is odd, and the integration interval is symmetric therefore the integral is 0. You have a \pi in there because you forgot the factor 1/ \pi in front of the integral.

Notice how you got the same answer again, this time however without luck.
 
  • #13
oh...again, right

\frac{2}{n^2}[xcos(nx)]_{-\pi}^{\pi}]=\frac{4\pi}{n^2}(-1)^n

a_{n}=\frac{4}{n^2}(-1)^ncosnx

b_{n}= \frac{1}{\pi}\int_{-\pi}^{\pi}x^2sin(nx)dx+ \frac{1}{\pi}\int_{-\pi}^{\pi}xsin(nx)cos(nx)=<br /> \frac{1}{\pi}[-\frac{x^2}{n}cosnx+\frac{2x}{n^2}sinnx+\frac{2}{n^3}cosnx]_{-\pi}^{\pi}
is this correct so far?
i get from the first integral 0...the second integrand is even so it will give 0
 
Last edited:
  • #14
Why did you suddenly put a cosine in your expression for a_n? It shouldn't be there.

The first integral is zero yes, why? The second integral is even yes, but that does not mean the integral is zero.
 
  • #15
okej, I just got quite confused...I must admit that I am a real beginner when it comes to Fourier analysis...all this is quite difficult;)
i just calculated the value for the first integral
b_{n}= \frac{1}{\pi}[-\frac{x^2}{n}cosnx+\frac{2x}{n^2}sinnx+\frac{2}{n^ 3}cosnx]_{-\pi}^{\pi}=\frac{1}{\pi}[-\frac{\pi^2}{n}(-1)^n+\frac{2}{n^3}(-1)^n-(-\frac{\pi^2}{n}(-1)^n+\frac{2}{n^3}(-1)^n)]=}[-\frac{\pi^2}{n}(-1)^n+\frac{2}{n^3}(-1)^n+\frac{\pi^2}{n}(-1)^n-\frac{2}{n^3}(-1)^n=0

you are right with the second integral, i mixed it up with an odd function and I assumpted it should give 0...
however i do not have any clue how do solve the 2nd integral...
 
  • #16
The first integral is odd so you could have set it to zero saving you a lot of trouble.

For the second integral use the well known double angle formula \sin 2x=2\sin x \cos x.
 
Last edited:
  • #17
okej, i used it and i got
\frac{1}{2\pi}\int_{-\pi}^{\pi}xsin(2nx)dx=\frac{1}{2\pi}[-\frac{x}{2n}cos(2nx)+\frac{1}{4n^2}sin(2nx)]_{-\pi}^{\pi}=\frac{1}{2\pi}[-\frac{\pi}{2n}(1)^n-\frac{\pi}{2n}(-1)^n]
 
  • #18
You're almost there.

\frac{1}{2\pi}\int_{-\pi}^{\pi}xsin(2nx)dx<br /> =<br /> \underbrace{\frac{1}{2\pi}[-\frac{x}{2n}cos(2nx)+\frac{1}{4n^2}sin(2nx)]_{-\pi}^{\pi}}_\text{correct}<br /> =\underbrace{\frac{1}{2\pi}[-\frac{\pi}{2n}(1)^n}_\text{missing a factor}-\underbrace{\frac{\pi}{2n}(-1)^n}_\text{wrong}]

Also 1^n=...?
 
  • #19
should it be 2n
hm...the term with sin2nx will give 0 right?
for the rest i get :
{\frac{1}{2\pi}[-\frac{\pi}{2n}(1)^{2n}+\frac{\pi}{2n}(-1)^{2n}]
but according to what you have written it is still wrong,
 
  • #20
You found the correct primitive. Now all you have to do is plug in the limits of integration. You're nearly there, but don't get sloppy with simple arithmetic.

Yes the \sin 2 n \pi term is zero for every n \in \mathbb{Z}. Don't forget to answer my question in post #18.
 
Last edited:
  • #21
well i am not being sloppy, i am just very tired, have been studying all day long and i have still much left.
Right now i really do not se any other solution, maybe my head is just too tired. Will try to recalculate it again and find a correct answer.
your question in post #18 1^{n}=? the value depends on the factor n i suppose
 
  • #22
Plug in some numbers for n and see what you get.

I suggest you take a little break after you finish this problem!
 
  • #23
in fact i am not going to calculate any problems tonight, will continue tomorrow because i start making really stupid mistakes. Thank you very much for you help anyway, you have been very helpful.
I will continue with the problem tomorrow.
 
  • #24
={\frac{1}{2\pi} \left[-\frac{\pi}{2n}+\frac{-\pi}{2n}\right] = \frac{-1}{2n}

made correction here

\frac{\pi^2}{3}+\sum_{n=1}^{\infty}[\frac{4}{n^2}(-1)^ncos(nx)+\frac{-1}{2n}sin(nx)]
 
Last edited:
  • #25
It is almost correct.

<br /> ={\frac{1}{2\pi} \left[-\frac{\pi}{2n}+\frac{-\pi}{2n}\right] = \frac{-1}{2n}<br />

The part between brackets is zero, this should not be the case.

The x^2/3 in front of the sum isn't correct either, it should be a_0 instead.
 
  • #26
yes you are right it was a stupid mistake a_{0} should bea_{0}=\frac{\pi^2}{3}
\frac{\pi^2}{3}+\sum_{n=1}^{\infty}[\frac{4}{n^2}(-1)^ncos(nx)]
is it now correct?

are you sure that the part between the brackets is zero?
 
  • #27
No sorry about that. It is not zero and your result in post #24 is correct if you replace x^2/3 with a_0. Don't reply when you just got out of bed!

To clear it up:

b_n=-\frac{1}{2n}
 
  • #28
great:) Thank you very much. You relly helped me to understand the idea of this problem
 
Back
Top