# Thread: Integral of an Even Function

1. ## Integral of an Even Function

This is probably going to be one of those questions where I can't believe I was so dumb but...What I'm trying to do is calculate the fourier series of some function. This is okay, but I'm having a problem with my integral.

In the fourier series Ao is given by

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

The fourier series I'm attempting to calculate is for

$f(x) = 1 - |x|$ for $-2 \le x \le 2$

Let us note that this function is even

$f(-1)=0=f(1)$

So Ao should simplify to

$Ao = \frac {2}{L} \int_{0}^{L} f(x)dx$

We then plug in the values and obtain

$Ao = \int_{0}^{2} (1-|x|)dx$

$Ao = 2 - \frac {x^2}{2}$ evaluated from 0-->2

This of course yields

$Ao = 2 - 2 = 0$

Now, I was fiddling with this. And had I not changed my integral I get a different answer.

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

$Ao = \frac {1}{2} \int_{-2}^{2} (1-|x|)dx$

$Ao = \frac {1}{2} (4-\frac {x^2}{2} )$ evaluted from -2-->2

$Ao = \frac {1}{2} (4-[\frac {4}{2} - \frac {4}{2}]$

$Ao = 2$

I'm sure that I have violated some law in the second evaluation, i don't remember what is is though. Is this because the equation isn't valid on the left side of the XY domain and that the derivative at 0 doesn't exist? I think I vaguely remember something about this from first year.

2. Yes it's not continuous at $x=0$ and you can't just integrate it.

When dealing with $|x|$ type things usually you can split them up into...

$\int_{-L}^0 -x dx + \int_0^L x dx$

However since it's gonna be even in your case you can just do...

$2\int_0^L x dx$

(obviously with 1-x though)

3. Edit

Actually hold on a sec.

The answer should be 2 I think but your method is wrong...
My book has it as equal to 0. Which is what prompted me to think about it some more. I figured it had something to do with not being contious at 0, my simple brain just couldn't rationalize why :P

Let's work it out in full

$\int_{-2}^0 (1+x)dx + \int_{0}^{-2} (1-x)dx$

$2+ \frac {x^2}{2}$ evaluated from -2-->0 and

$-2 - \frac {x^2}{2}$ evaluated rom 0-->-2

Yeah that equals 0. Thanks mate for helping me think back. I should probably brush up on some definitions :P

5. Originally Posted by AllanCuz
My book has it as equal to 0. Which is what prompted me to think about it some more. I figured it had something to do with not being contious at 0, my simple brain just couldn't rationalize why :P

Let's work it out in full

$\int_{-2}^0 (1+x)dx + \int_{0}^{-2} (1-x)dx$

$2+ \frac {x^2}{2}$ evaluated from -2-->0 and

$-2 - \frac {x^2}{2}$ evaluated rom 0-->-2

Yeah that equals 0. Thanks mate for helping me think back. I should probably brush up on some definitions :P
Ya I edited that post cos I realized I was being stupid about 3 seconds after I posted it. Plot the graph and you'll see its 0.