# Homework Help: Fourier approximation with polynomial

1. Feb 21, 2012

### kottur

1. The problem statement, all variables and given/known data

Approximate the function $f(x)=sin(\pi x)$ on the interval $[0,1]$ with the polynomial $ax^{2}+bx+c$ with finding a, b and c.

2. Relevant equations

$f(x)=a_{0}+\sum^{\infty}_{n=1}(a_{n}cos(nx)+b_{n}sin(nx))$

$a_0=\frac{1}{2\pi}\int^{\pi}_{-\pi}f(x)dx$

$a_n=\frac{1}{\pi}\int^{\pi}_{-\pi}f(x)cos(nx)dx , (n\geq1)$

$b_n=\frac{1}{\pi}\int^{\pi}_{-\pi}f(x)sin(nx)dx , (n\geq1)$

3. The attempt at a solution

I understand that this is just a matter of filling in the equations but I just don't seem to get it right. I get:

$a_{0}=0$

$a_{n}=-cos(\pi\pi)cos(\pi n)-\frac{n}{\pi}sin(\pi\pi)sin(\pi n)$

$b_{n}=-cos(\pi\pi)sin(\pi n)-\frac{n}{\pi}sin(\pi\pi)cos(\pi n)$

I think I need to simplify this and I don't know how to, plus then I'm not sure how to use it.

Last edited: Feb 21, 2012
2. Feb 21, 2012

### HmBe

If n is in the natural numbers, what is sin(n*pi) equal to?

Equally, what is cos(n*pi) equal to?

Although I'm not entirely sure why you want to use a fourier series here.

Last edited: Feb 21, 2012
3. Feb 21, 2012

### kottur

Okay so now I get:

$a_{n}=\pm cos(\pi^{2})$
$b_{n}=\pm \frac{n}{\pi}sin(\pi^{2})$

And this will give me:

$f(x)=0+\sum^{\infty}_{n=1}(\pm cos(\pi^{2})cos(nx)+(\pm \frac{n}{\pi}sin(\pi^{2})sin(nx)))$

And when do I use the interval $[0,1]$ and how?

Thank you for the help!

Ps. The assignment was to Fourier approximate. I forgot to mention that in the original post.

4. Feb 21, 2012

### Ray Vickson

Your formulas are incorrect. If you want a Fourier series on [0,1] all your integrals must go from x = 0 to x = 1 and the series will involve sin(2nπx), cos(2nπx), not sin(nx) and cos(nx). That said: why do you want to use Fourier series? But, a more fundamental question is: how do you measure the quality of an approximation? When can you say that one approximation is better than another? How can you define a "best" approximation?

RGV

5. Feb 21, 2012

### LCKurtz

And, to add to that, you aren't asked to approximate your $\sin(\pi x)$ with sines and cosines. You want $\sin(\pi x)\doteq ax^2+bx+c$.

6. Feb 21, 2012

### kottur

The assignment is to Fourier approximate.

I've got these formulas in my notes:

For a function with period T and T=2L we have:

$f(x)=a_{0}+\sum^{\infty}_{n=1}(a_{n}cos(\frac{n\pi x}{L})+b_{n}sin(\frac{n\pi x}{L}))$

$a_{0}=\frac{1}{2L}\int^{L}_{-L}f(x)dx$

$a_{n}=\frac{1}{L}\int^{L}_{-L}f(x)cos(\frac{n\pi x}{L})dx , (n\geq1)$

$b_{n}=\frac{1}{L}\int^{L}_{-L}f(x)sin(\frac{n\pi x}{L})dx , (n\geq1)$

So I just plugged in $L=\pi$ because $T=2L=2\pi$.

Is that incorrect? To be fair I don't understand how to use the interval $[1,0]$ so am I supposed to integrate with it? Then why do I have the formulas from above if they are incorrect?
Thank you!

7. Feb 21, 2012

### Ray Vickson

Your general formulas are correct, but you are using them incorrectly in your example. If you have f(x) for x in the interval [0,1] you can look instead at g(z) = f(z + 1/2) for z in [-1/2,1/2]. Now take L = 1/2 in your Fourier formulas, applied to g(z). You will have a series containing sin(nπz/L) = sin(2nπx - πn) = +-sin(2πnx) and cos(nπz/L) = +-cos(2πnx).

Anyway: you still have not explained why, in your first posting, you said you want to approximate f(x) "with the polynomial ax^2+bx+c with finding a, b and c" (you did use the word "Fourier" but I really don't understand why). The expression ax^2+bx+c is not a Fourier series; it is a polynomial.

RGV

8. Feb 21, 2012

### kottur

Hmm okay, well I'm supposed to approximate f(x) with the polynomial with a method called least sum of squares or something like that. It's hard to translate it.

Okay I will try to do it with g(z) now.

9. Feb 21, 2012

### LCKurtz

Why? Do you have a lot of extra time on your hands and just want to practice getting Fourier Coefficients even though it has nothing to do with your problem? Do you understand that you are working on a "solution" that has nothing to do with your stated problem?

10. Feb 21, 2012

### kottur

Okay I thought about what you said with g(z) but I just used f(x) and L=1/2. I hope that was okay.

So this is what I got:

$a_{0}=0$

$a_{n}=\frac{-cos(\pi-2\pi n)}{(\pi-2\pi n)}-\frac{cos(\pi+2\pi n}{(\pi+2\pi n)}=\frac{cos(2\pi n)}{(\pi-2\pi n)}+\frac{cos(2\pi n}{(\pi+2\pi n)}$

$b_{n}=\frac{sin(2\pi n)}{(\pi-2\pi n)}+\frac{sin(2\pi n)}{(\pi+2\pi n)}$

Which gives me:

$f(x)=\sum^{\infty}_{n=1}((\frac{1}{\pi(1-2n)}+\frac{1}{\pi(1+2n)})(cos(2\pi nx)(cos(2\pi n)+sin(2\pi nx)sin(2\pi n))=\sum^{\infty}_{n=1}(\frac{1}{\pi(1-2n)}+\frac{1}{\pi(1+2n)})(cos(2\pi nx-2\pi n))$

Does this make any sense?

11. Feb 21, 2012

### LCKurtz

IF your problem was to express $\sin(\pi x)$ as a Fourier Series on [0,1] you would try to find $a_n$ and $b_n$ to get$$\sin(\pi x) = a_{0}+\sum^{\infty}_{n=1}(a_{n}cos(n\pi x)+b_{n}sin(n\pi x))$$and if you worked it correctly you would get $a_n=0$ and $b_n=0$ except for $b_1=1$, which would give an identity for $\sin(\pi x)$. It is its own finite Fourier Series.

But that has nothing to do with your problem. You have never stated it fully, but I'm guessing you are supposed to minimize$$\int_0^1(\sin(\pi x) - ax^2-bx-c)^2\, dx$$by choosing the appropriate values for $a,b,c$.

12. Feb 22, 2012

### kottur

LCKurtz thank you for your help.

I used a totally different method after all this, finding a, b and c with linear algebra.