# Homework Help: Solving the coefficients of fourier series

1. May 31, 2009

### jianxu

1. The problem statement, all variables and given/known data
f(x) = |cos x| if -$$\pi$$ $$\leq$$ x $$\leq\$$ $$\pi$$

The fourier series answer we should end up with is the following:

2/$$\pi$$ - 4/$$\pi$$$$\sum$$$$\frac{-1^{k}}{(2k)^{2}-1}$$cos(2kx)

where for the summation, k = 1 and goes to infinity.

What I need to do is to actually go an solve for the fourier series and show that we get the same series when we derive it given f(x)

2. Relevant equations

f(x) = $$a_{0}$$ + $$\sum$$$$a_{k}$$coskx + $$b_{k}$$sinkx where k =1 and goes to infinity

$$a_{0}$$ = 1/2$$\pi$$$$\int$$f(x)dx

$$a_{k}$$ = 1/$$\pi$$$$\int$$f(x)coskxdx

$$b_{k}$$ = 1/$$\pi$$$$\int$$f(x)sinkxdx

where we integrate all the above integrals from -$$\pi$$ to $$\pi$$

Lastly, the properties of even functions are also considered.

3. The attempt at a solution

So, to start out, since $$b_{k}$$ = 1/$$\pi$$$$\int$$f(x)sinkxdx, cosx is even and the sinkx is odd,
$$b_{k}$$ = 0

for
$$a_{0}$$ = 1/2$$\pi$$$$\int$$f(x)dx

due to the properties of an even function I have:
= 1/$$\pi$$$$\int$$f(x)dx integrated from 0 to $$\pi$$

= 1/$$\pi$$($$\int$$cosxdx + $$\int$$-cosxdx)
where the first integral is from 0 to $$\pi$$/2} and the second integral is from $$\pi$$/2 to $$\pi$$,

solving this gives me

$$a_{0}$$ = 1/$$\pi$$(1 - (-1)) = 2/$$\pi$$

For $$a_{k}$$:

using even function properties again I have,
$$a_{k}$$ = 2/$$\pi$$$$\int$$f(x)coskxdx
= 2/$$\pi$$$$\int$$cosx*coskx dx
where integral goes from 0 to $$\pi$$.

Maybe I'm just rusty with integration, but I just want to make sure I'm heading into the right direction and how do I integrate that? ( meaning $$\int$$cosx*coskx dx)

Thanks

2. May 31, 2009

### tiny-tim

Last edited by a moderator: Apr 24, 2017
3. May 31, 2009

### jianxu

Last edited by a moderator: Apr 24, 2017
4. Jun 1, 2009

### jianxu

sorry for double post but this is what I got after integrating,

$$a_{k}$$=(8/$$\pi$$)*(sin((1/2)*(k+1)*$$\pi$$)/(k+1)+sin((1/2)*(k-1)*$$\pi$$)/(k-1))

does that look like I'm headed in the right direction? Thanks

5. Jun 2, 2009

### tiny-tim

Hi jianxu!

(what happened to that π i gave you? )
It's a little difficult to check when you haven't shown your working, but that looks roughly right, except I don't see where the (1/2) comes from.

6. Jun 2, 2009

### jianxu

woops, here's my work:P

so after the trig identity, I have for $$a_{k}$$:

$$a_{k}$$ = 1/$$\pi$$*($$\int$$cos(kx+x)dx+$$\int$$cos(kx-x)dx) where we integrate from 0 to $$\pi$$

now for each integral, I split it in two where we integrate
$$\int$$(cos(k$$\pm$$1)x)dx) where this integral is evaluated from 0 to $$\pi$$/2

then the next integral would be $$\int$$(-cos(k$$\pm$$1)x)dx) from $$\pi$$/2 to $$\pi$$.

I split it due to the function being |cosx|

so after integrating the four terms I get,
=(1/$$\pi$$)*(sin(k$$\pm$$1)x/(k$$\pm$$1) (evaluated from 0 to $$\pi$$/2) + -sin(k$$\pm$$1)x/(k$$\pm$$1)) (evaluated from $$\pi$$/2 to $$\pi$$)

after evaluating I get,
=(1/$$\pi$$)*(sin((k+1)*$$\pi$$/2)/(k+1)+sin((k+1)*$$\pi$$/2)/(k+1) + sin((k-1)*$$\pi$$/2)/(k-1)+sin((k-1)*$$\pi$$/2)/(k-1))

I simplified it because there are doubles and so:

$$a_{k}$$ = (2/$$\pi$$)*(sin((k+1)*$$\pi$$/2)/(k+1)+ sin((k-1)*$$\pi$$/2)/(k-1))

(I found a mistake I had made while writing my work down here :P....was (8/$$\pi$$) before, but it's actually (2/$$\pi$$))

so that's my work for $$a_{k}$$

please let me know if that looks good? :P thanks so much!

7. Jun 2, 2009

### gabbagabbahey

Yikes....what an eyesore!:yuck:

You need to work on your LaTeX a little. For starters, it's much easier to read if you write entire expressions in between a single set of tex tags. Also, you can use itex & /itex instead of tex & tex when you want an expression to occur on the same line as some written text and not look out of place. Click on the edited quote below to see the code used to make your last post readable:

Splitting up the integral into two intervals to deal with the absolute value is the right idea, but to correctly apply the idea you need to split it up before you use the trig identity:

$$a_k= \frac{1}{\pi} \int_{-\pi}^{\pi} |\cos{x}|\cos{kx} dx= \frac{2}{\pi} \int_{0}^{\pi} |\cos{x}|\cos{kx} dx =\frac{2}{\pi} \left( \int_0^{\pi/2} \cos{x}\cos{kx} dx - \int_{\pi/2}^{\pi} \cos{x}\cos{kx} dx \right)$$

However, you seem to be doing it correctly in your head, because your separated integrals are correct.

This looks correct to me!

You can however simplify it a little more by putting each term over the common denominator $(k+1)(k-1)$ and using the trig identity $\sin (a \pm b) =\sin(a)\cos(b) \pm \cos(a)\sin(b)$

You should get something like

$$a_k=\frac{-4\cos\left( \frac{k\pi}{2}\right)}{(k^2-1)\pi}$$

which is only non-zero for even values of $k$.

Last edited: Jun 2, 2009
8. Jun 2, 2009

### jianxu

Thanks! yea the quotient tag was giving me errors before for some reason...said like invalid image or something so I took all the quotient stuff out. Sorry for the poor post:(

Thanks again, tiny-tim and gabbagabbahey! :)