# g(x)=x odd and even expansions

I'm studying book about digital filter by Richard Hamming. And there is exercise to get odd and even expansion of g(x)=x where x is from 0 to $\pi$. I understood even expansion, but can't get into odd expansion: $\pi$ - $2$*(${\rm sin} x$ + $\frac{1}{2}$${\rm sin} 2x + \frac{1}{3}$${\rm sin} 3x$...)

Can anybody explain odd expansion of this function g(x)=x?

UPDATE: Let me be more clear. The exersise is: show that g(x) = x has two expansions (0 < x < $\pi$)

$x$ =$\begin{cases}\pi - 2*(\sin(x)+\sin(2x)/2+\sin(3x)/3+...) \\\pi/2 - 4/\pi*(\cos(x)+\cos(3x)/3^2+\cos(5x)/5^2+...)\end{cases}$

I merely understand cosine expansion, but I don't understand sine expansion...

• Perhaps you can include what Richard Hamming means by odd and even expansion for the benefit of those readers who do not have access to the book? Nov 23, 2013 at 14:48
• According to book: to get cosine expansion you extend the function about origin as an even function g(x)=(-x); and for only sines as an odd function g(x)=-g(-x). Nov 23, 2013 at 18:34
• There is something wrong. If the odd expansion of $g(x) =\begin{cases}x,&0 \leq x \leq \pi,\\0,&\text{otherwise,}\end{cases}$ is the odd function $g(x) =\begin{cases}x,& |x| \leq \pi,\\0,&\text{otherwise,}\end{cases}$, then its Fourier series cannot have a DC term: odd functions have a DC term $0$, not $\pi$ as you have it. On the other hand, the even function $p(x) =\begin{cases}|x|,&-\pi \leq x \leq \pi,\\0,&\text{otherwise,}\end{cases}$ does indeed have a DC term of $\pi$ but the coefficients of the $\sin$ functions are all $0$. Please check that you have copied things correctly Nov 23, 2013 at 21:23
• That is why I'm asking this question... I guess in order to make function odd, we extend it with $\pi$ - x (or x - $\pi$) on interval from -$\pi$ to 0. There is another excersice where g(x) = x needed to be expanded on [0,$\pi$) he notes that if you substract $\pi$ from x you get odd function. Nov 23, 2013 at 22:26

We want to find a representation in terms of sines and cosines for the function $g(x)$ which has value $x$ for $x \in [0,\pi]$. We don't really care if this representation does not work well outside the interval $[0,\pi]$, but inside the interval, the representation better work perfectly. This seems to be crying out for a Fourier series approach, and so that's what we will use. The standard approach begins with functions that are periodic with period $2\pi$ and so let us extend the definition of $g(x)$ to cover one period $[0,2\pi]$.
• If we choose $g(x)$ to have value $2\pi-x$ for $x \in [\pi, 2\pi]$, then, when repeated periodically, this extended $g(x)$ is an even function of $x$ with average value $\pi/2$. Furthermore, as is the case with all even functions, the sine terms all have $0$ coefficients. Thus, the Fourier series works out to have only cosines in it, and the DC term is $\pi/2$.
• If we choose $g(x)$ to have value $x$ for $x \in [\pi, 2\pi]$, then when repeated periodically, this extended $g(x)$ is not an odd function of $x$, but nonetheless it is true that all the cosine terms in the Fourier series turn out to be $0$ except the DC term which has value $\pi$.
• Thank you so much, Dilip! Very clear! The last question: why extended $g(x)$ is not an odd function? I guess it is truly odd function... Nevertheless, thank you very very much. Nov 27, 2013 at 19:20
• @Sharov If $g(x) = x, 0 \leq x < 2\pi$ is extended periodically with period $2\pi$, then for $-2\pi \leq x < 0$, the extended $g(x)$ equals $2\pi+x$, having value $0$ when $x = -2\pi$ and approaching $2\pi$ as $x$ approaches $0$. So, the extended $g(x)$ is not an odd function. If you subtract off the DC value $\pi$ and shift the function to the right by $\pi$, then it is an odd function, being given by $x$ for $-\pi < x < \pi$ Nov 27, 2013 at 20:04