# Thread:

1. ## Question invloving Fourier Series

Hi All,

I have a question that I need to do a bit of catching-up work before I can answer it. I'd like to be able to have a go at it myself before anybody puts an answer up but then check an answer for it later in the week. So if anybody can provide me with an answer to the following that would be great. Thanks.

Q. Evaluate

$\int x^N cos(\alpha x) dx$ and $\int x^N sin(\alpha x) dx$ using integration by parts, for N=1,2.

Sketch the function defined by

$f(x) = 2x - x^2$, $0 \leq x < 1$;

$f(x + 1) = x$, $-\infty < x < \infty$

and find the corresponding Fourier Series.

By considering $f(x)$ at $x = 0$ and $x = \frac{1}{2}$ deduce that

$\sum_{n = 1}^{\infty} \frac{1}{n^2} = \frac{\pi^2}{6}$

and

$\sum_{n = 1}^{\infty} \frac{(-1)^{(n+1)}}{n^2} = \frac{\pi^2}{12}$

2. For the first part I got

For $N = 1 \Longrightarrow$

$\int x^1 \ cos(\alpha x) \ dx = \frac{1}{\alpha} \ x \ sin(\alpha x) + \frac{1}{\alpha^2} \ cos(\alpha x)+ C$

$\int x^1 \ sin(\alpha x) \ dx = -\frac{1}{\alpha} \ x \ cos(\alpha x) + \frac{1}{\alpha^2} \ sin(\alpha x)+ C$

For $N = 2 \Longrightarrow$

$\int x^2 \ cos(\alpha x) \ dx = \frac{1}{\alpha} \ x^2 \ sin(\alpha x) + \frac{1}{\alpha^2} \ 2x \ cos(\alpha x) - \frac{1}{\alpha^3} \ 2 \ sin(\alpha x)+ C$

$\int x^2 \ sin(\alpha x) \ dx = -\frac{1}{\alpha} \ x^2 \ cos(\alpha x) + \frac{1}{\alpha^2} \ 2x \ sin(\alpha x)+ \frac{1}{\alpha^3} \ 2 \ cos(\alpha x)+ C$

3. Originally Posted by woody198403
Sketch the function defined by

$f(x) = 2x - x^2$, $0 \leq x < 1$;

$f(x + 1) = x$, $-\infty < x < \infty$
I think you mean $f(x+1)=f(x)$.

Now expand $f$ into a Fourier series.
Evaluate the series at $x=0$ and compare sides.

4. Yes, I did mean $f(x+1)=f(x)$ oops

Im still working on it but is

$a_0 = \frac{2}{3}$

and in determining $a_n \ \mbox{and} \ b_n$, would the following give me the correct values?

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

$b_n = 4 \int_{0}^{1} x \ sin(2 n\pi x) dx - \int_{0}^{1} x^2 \ sin(2 n\pi x) dx$

5. Can someone PLEASE tell me if my calculation is correct? and if not, can someone please show me where I went wrong? Thanks

$a_n =- \frac{2 \ cos(n\pi)^2}{n^2\pi^2} + \frac{2 \ sin(n\pi)}{n^3\pi^3}$

and

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

6. Originally Posted by woody198403
Can someone PLEASE tell me if my calculation is correct? and if not, can someone please show me where I went wrong? Thanks

$a_n =- \frac{2 \cos^2(n\pi)}{n^2\pi^2} + \frac{2 \sin(n\pi)}{n^3\pi^3}$

and

$b_n = \frac{2 \cos^2(n\pi) - 2}{n^3\pi^3} + \frac{2 \sin(n\pi) \cos(n\pi)}{n^2\pi^2}$
I don't have the patience to go through the whole calculation, but you should know that $\sin(n\pi)=0$ and $\cos(n\pi)=(-1)^n$. That simplifies the first formula to $a_n =- \frac{2}{n^2\pi^2}$. To check whether this is correct, see what happens at x=0. The periodic function has a jump from 1 to 0 at this point, and the theory tells you that the Fourier series ought to converge to a point halfway up the jump, namely 1/2. The Fourier series is ${\textstyle\frac12}a_0 + \sum_{n=1}^\infty (a_n\cos(2\pi nx) + b_n\sin(2\pi nx))$. When you put x=0 that gives $\frac12 = \frac13 - \sum_{n=1}^\infty \frac2{n^2\pi^2}$. This is in the right ballpark for showing that $\sum_{n=1}^\infty \frac1{n^2} = \frac{\pi^2}6$, but it isn't quite right.

My guess is that you should look more carefully at those terms $\cos^2(n\pi)$ and $\sin(n\pi) \cos(n\pi)$ in your formulas for a_n and b_n. There is nothing in the integration-by-parts formulas that you gave earlier to suggest that there should be any products of trig functions in these formulas.

7. Letting $f(x)=2x-x^2,\;0\leq x \leq 1$ with $f(1+x)=f(x)$, I get:

$a_0=2\int_0^1 f(x)dx=4/3$

$a_n=2\int_0^1 f(x)\cos(2n\pi x)dx=\frac{-2n\pi+(1+2n^2\pi^2)\sin(2n\pi)}{2n^3\pi^3};\quad n\geq 1$

$b_n=2\int_0^1 f(x)\sin(2n\pi x)dx=\frac{1-(1+2n^2\pi^2)\cos(2n\pi)}{2n^3\pi^3}$

The plot below is the first 20 terms in the interval $(0,3)$. Red is the function $f(x)$, Gray is the Fourier series for this function. I'm not real familiar with Fourier Series so not sure about this. Also, as Opalg stated above, at the points of discontinuities, the Fourier series converges to the average of the end points. The plot however, only shows a sharp vertical line due to plotting limitations. If I drew only a set of points for the plot, a single point would be between the upper and lower limits at the points of discontinuities.
Attached Thumbnails

8. Originally Posted by shawsend
The plot below is the first 20 terms in the interval $(0,3)$. Red is the function $f(x)$, Gray is the Fourier series for this function.
That plot shows a nice illustration of the Gibbs phenomenon, with the Fourier series overshooting on either side of the discontinuity.

9. but you should know that $\sin(n\pi)=0$ and $\cos(n\pi)=(-1)^n$. That simplifies the first formula to $a_n =- \frac{2}{n^2\pi^2}$.
Ahhhhh, of course! I am so embarrassed that I missed that

Thank-you both for the replies, but shawsend maybe its because Im tired but isnt $a_0 = \frac{2}{3} \$ ? I am almost certain of it but since you've posted it here I am paranoid I've left something out.

$a_0 = \frac{1}{2L} \ \int_{-L}^{L} f(x) \ dx$

10. Originally Posted by woody198403
Ahhhhh, of course! I am so embarrassed that I missed that

Thank-you both for the replies, but shawsend maybe its because Im tired but isnt $a_0 = \frac{2}{3} \$ ? I am almost certain of it but since you've posted it here I am paranoid I've left something out.

$a_0 = \frac{1}{2L} \ \int_{-L}^{L} f(x) \ dx$
I'm not sure. As I said, I'm not real good with these and also I was unable to obtain the two summation formulas you posed using my results.

11. Originally Posted by woody198403
isnt $a_0 = \frac{2}{3} \$ ? I am almost certain of it but since you've posted it here I am paranoid I've left something out.

$a_0 = \frac{1}{2L} \ \int_{-L}^{L} f(x) \ dx$ Really? I would have thought it was $\color{red} a_0 = \frac{1}{L} \ \int_{-L}^{L} f(x) \ dx$
The constant term in the Fourier series should always be the average value of the function over the interval, in this case $\int_0^1(2x-x^2)dx = 2/3$. The constant term is also (1/2)a_0, which suggests that a_0 should be 4/3 here.

12. Thank you all for your help but I have one last question.

So finally,

$a_0 = \frac{2}{3} \ , \ a_n = -\frac{1}{\pi^2n^2} \ ,\ b_n = -\frac{1}{2\pi n}$

so my Fourier Series is

$f(x) = \frac{2}{3} - \frac{1}{\pi^2} * \sum_{n=1}^{\infty} \ \frac{1}{n^2} cos(2\pi n x) - \frac{1}{\pi} * \sum_{n=1}^{\infty} \ \frac{1}{n^2} sin(2\pi n x)$

which I know is correct because I was able to prove that at x=0,

$\sum_{n=1}^{\infty} \ \frac{1}{n^2} = \frac{\pi^2}{6}$

(since the series converges at a $\frac{1}{2}$)

but can someone show me how to prove that at x= 1/2,

$\sum_{n=1}^{\infty} \ \frac{(-1)^{n + 1}}{n^2} = \frac{pi^2}{12}$

I dont know what it is that Im doing wrong but I keep getting the wrong answer

13. Originally Posted by woody198403

so my Fourier Series is

$f(x) = \frac{2}{3} - \frac{1}{\pi^2} * \sum_{n=1}^{\infty} \ \frac{1}{n^2} cos(2\pi n x) - \frac{1}{\pi} * \sum_{n=1}^{\infty} \ \frac{1}{n^2} sin(2\pi n x)$
Have I mis-understood what the function is? When I plot the first 50 terms of your expression above I get the plot below which I've superimposed over what I thought the original function is. That does not seem to be converging to it in the way one normally thinks of a Fourier series converging (with Gibbs phenomenon) to a function. Here's my Mathematica code in case some are interested:

Code:
```f[x_] := 2*x - x^2; 
h[x_] := 2/3 - (1/Pi^2)*
    Sum[Cos[2*Pi*n*x]/n^2, {n, 1, 150}] - 
   (1/Pi)*Sum[Sin[2*Pi*n*x]/n^2, {n, 1, 150}]
fplot1 = Plot[f[x], {x, 0, 1}, 
   PlotStyle -> {Thickness[0.001], Red}]
fplot2 = Plot[f[x - 1], {x, 1, 2}, 
   PlotStyle -> {Thickness[0.001], Red}]
fplot3 = Plot[f[x - 2], {x, 2, 3}, 
   PlotStyle -> {Thickness[0.001], Red}]
p2 = Plot[h[x], {x, 0, 3}]
Show[{fplot1, fplot2, fplot3, p2}, 
  PlotRange -> {{0, 3}, {0, 1}}]```
Attached Thumbnails

14. Woody, I think you made a typo up there. Should it not be:

$f(x) = \frac{2}{3} - \frac{1}{\pi^2} * \sum_{n=1}^{\infty} <br /> \frac{1}{n^2} cos(2\pi n x) - \frac{1}{\pi} * \sum_{n=1}^{\infty} <br /> \frac{1}{n} sin(2\pi n x)<br />$

and the deal with the constant term is I'm using $a_0/2$ which is your $2/3$ term. I now believe this expression is correct. The code above with 150 terms is converging nicely to the periodic extension of the function.

15. Originally Posted by woody198403
So finally,

$a_0 = \frac{2}{3} \ , \ a_n = -\frac{1}{\pi^2n^2} \ ,\ b_n = -\frac{1}{2\pi n}$

so my Fourier Series is

$f(x) = \frac{2}{3} - \frac{1}{\pi^2} * \sum_{n=1}^{\infty} \ \frac{1}{n^2} cos(2\pi n x) - \frac{1}{\pi} * \sum_{n=1}^{\infty} \ \frac{1}{n^2} sin(2\pi n x)$ If your formula for b_n is correct, that should be $\color{red}\frac{1}{n} sin(2\pi n x)$.

which I know is correct because I was able to prove that at x=0,

$\sum_{n=1}^{\infty} \ \frac{1}{n^2} = \frac{\pi^2}{6}$

(since the series converges at a $\frac{1}{2}$)

but can someone show me how to prove that at x= 1/2,

$\sum_{n=1}^{\infty} \ \frac{(-1)^{n + 1}}{n^2} = \frac{pi^2}{12}$

I dont know what it is that Im doing wrong but I keep getting the wrong answer
(The value of b_n won't affect this answer because the sin terms will all be 0 at x=1/2.)

Put x=1/2 in the equation $2x-x^2 = \frac{2}{3} - \frac{1}{\pi^2} * \sum_{n=1}^{\infty} \ \frac{1}{n^2} \cos(2\pi n x) - \frac{1}{\pi} * \sum_{n=1}^{\infty} \ \frac{1}{n} \sin(2\pi n x)$:

$1-\frac14 = \frac{2}{3} - \frac{1}{\pi^2} * \sum_{n=1}^{\infty} \ \frac{1}{n^2}(-1)^n - 0$.

That simplifies to $\frac{1}{\pi^2} * \sum_{n=1}^{\infty} \ \frac{(-1)^n}{n^2} = \frac23-\frac34 = -\frac1{12}$.

Now all you have to do is to multiply both sides by $-\pi^2$.
{"extraction_info": {"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 80, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0}, "config": {"markdown_headings": true, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.3, "absolute_threshold": 10, "end_threshold": 15, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "github"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "english_confidence": 0.9555311799049377, "perplexity_flag": "head"}