Coefficient of $x^n$ in logarithmic series What is the co-efficient of $x^n $ in the expansion of $$\log(1-x+x^2)?$$
So, my book simplifies it in this way,\begin{align*}\log(1-x+x^2) & =\log\left(\frac{1+x³}{1+x}\right)\\ & =\log\left({1+x^3}\right)-\log\left({1+x}\right) \\ &=\left({x^3}-\frac{x^6}{2}+\frac{x^9}{3}-\ldots +(-1)^{r+1}\frac{x^{3r}}{r}+\ldots\right)\\ &\qquad-\left({x}-\frac{x^2}{2}+\frac{x^3}{3}-\ldots+(-1)^{r+1}\frac{x^{r}}{r}+\ldots\right).\end{align*}Then what my book provides is two results according to their conditions.
a) $n$ is a multiple of $3$, $3r$.
Then the coefficient of $x^n$ would be $(-1)^{r+1}\frac{1}{r}$ in the 1st expansion and $-(-1)^{3r+1}\frac{1}{3r}$ in the 2nd expansion, thus substracting these two will lead us to the result.
b) $n$ is not multiple of $3$, in that case the 1st expansion doesn't contain any coefficient of $x^n$ and the 2nd expansion provides us $\frac{(-1)^n}{n}$.
$$-------------$$
$1)$ I don't understand why we have to go through $r$, why can't we just put $n$ in place of $r$, and hence get the $n+1$th term which will give us the coefficient of $x^n$ directly?
$2)$Even if, $r$ replaced by $n$, it doesn't result the same. (In b) we got different answer.)
 A: To answer your first question, the Maclaurin expansion is as follows:
$\ln(x + 1) = x - \frac{x^2}{2} + \frac{x^3}{3}...$
Now, your book has expanded the series by expressing it in 2 log terms:
$\ln (1 + x^3) - \ln (1 + x)$
which can be appropriately expanded as they follow the same $\ln (1 + x)$ form using the expansion formula but replacing $x$ with $x^3$ in the first case and replacing $x$ with $x$ in the second.
Now, coming to your first question, on expanding both logarithms, we get a general term in the form
$(-1)^{r - 1} \frac{f(x)^r}{r}$ where f(x) is $x^3$ in the first expansion and f(x) is $x$ in the second expansion.
What we need is coefficients of $x^n$. On comparing powers of x from both expansions, these terms are given when $3r = n$ and when $r = n$ this is because both expansions give infinitely many terms with the respective general forms so at any point where the powers of x in the general forms of each expansion is equal to  n (the required power) the terms that are formed are the required terms.
When $r = n$, the coefficient of $x^n$ is taken from the $\ln (1 + x)$ series and that term is $(-1)^n \frac{1}{n}$. And, when $r = \frac{n}{3}$ then we get another term from the other expansion. Now, this term is only possible if n is a multiple of 3 as all powers are integral in nature.
So, we have two cases:

*

*If n is a multiple of 3:

Here, we have two appropriate coefficients which we add to get the final answer (when r = n and r = $\frac{n}{3}$):
$(-1)^\frac{n - 3}{3} \frac{3}{n} - (-1)^{n - 1} \frac{1}{n}$


*If n is not a multiple of three, only the first expansion provides us with a term that is the coefficient of $x^n$:

$(-1)^{n - 1} \frac{1}{n}$
In summary, we are looking for cases in which r (the index number of the term in the expansion) which is what the power of the $x$ term depends on gives a power of x that is = n. Now this relation between r and the power of x can vary between series and all we're looking for is cases where the power (in terms of r) = n.
Hence, we can replace r by n in the first series (where the power of x = r which we need to be = n) but in the second series, the power of x = 3r which should be = n so we need to replace 3r by n or when $r = \frac{n}{3}$.
[Side Note: I believe the expansion formula's general term as described by you [in the b part of your question] is slightly inaccurate considering that the power of -1 is r - 1 and not r as the general expansion has the 1st term with a +1 ahead of it and the second term with a -1 ahead of it and so on. So the rth term will have a $(-1)^{r - 1}$ ahead of it]
[Side Note 2: The power of -1 can be expressed as r - 1 or r + 1 because we just need to change the sign based on the index]
