Given function is $$f(x)=|x|, x\in(-\pi,\pi)$$ We have to make a Fourier series.
I have found $$\frac{a_0}{2}=\frac{1}{\pi}\left[{\int_{-\pi}^{0}(-x)\space dx+\int_{0}^{\pi}x\space dx}\right]=\frac{\pi}{2}\\ \\ a_n=\frac{1}{\pi}\left[{\int_{-\pi}^{0}(-x)\cos nx\space dx+\int_{0}^{\pi}x \cos nx\space dx}\right] =\frac{2}{\pi.n^2}.[(-1)^n-1].$$
But not sure what $b_n$ will be. If I consider $$b_n=\frac{1}{\pi}{\int_{-\pi}^{\pi}|x|\sin nx\space dx}$$ then $b_n=0$.
But considering $$b_n=\frac{1}{\pi}{\int_{-\pi}^{0}(-x)\sin nx\space dx\int_{0}^{\pi}x \sin nx\space dx}$$ I get $b_n=(-2).\frac{(-1)^n}{n}$.
What is the correct value of $b_n$ here? any help or explanation is highly appreciated.
One more question - if $f(x)$ is given $|x|, \space x\in(-\pi,\pi)$, then it is $2\pi$ range fourier series but does the series become half-range Fourier series when $f(x)$ is defined as $$f(x)={-x, \space x\in(-\pi,0)\\ x, \space x\in(0,\pi)}$$
Any help please.
The problem is that the first integration gives you a positive sign, not a negative sign.
$b_n = \frac{1}{\pi}(\int_{-\pi}^0 -x\sin nx \ dx + \int_{0}^{\pi} x\sin nx \ dx) $
$= -\frac{1}{\pi}\int_{-\pi}^0 x\sin nx \ dx + \frac{1}{n}\int_{0}^{\pi} x\sin nx \ dx$
Evaluating $\int x\sin nx \ dx$ using integration by parts:
$\int x\sin nx \ dx = -\frac{1}{n}x\cos nx + \frac{1}{n^2}\sin nx + C$
while $C$ is an arbitrary constant. Substitute back to $b_n$, we found that the first term gives
$\int_{-\pi}^0 x\sin nx \ dx = -\frac{1}{n}(0-(-\pi)(-1)^n)) + 0 = \frac{\pi}{n}(-1)^n$
while the second term gives
$\int_{0}^\pi x\sin nx \ dx = -\frac{1}{n}((\pi)(-1)^n)-0) + 0 = -\frac{\pi}{n}(-1)^n$
Adding this two terms gives you $b_n = 0$.
For the second question: yes you can compute Fourier series using the newly defined $f(x)$, but beware of the symmetry of the trigonometric functions, as the centre points are now defined at $x = \pm \pi / 2$ respectively, rather than $x=0$.