ln and rational function using contour integration I was playing around with $\displaystyle \int_{0}^{1}\frac{\ln^{2}(x)}{x^{2}-x+1}dx=\frac{1}{2}\int_{0}^{\infty}\frac{\ln^{2}(x)}{x^{2}-x+1}dx$ and managed to solve it using real methods via digamma and what not.
It evaluates to $\frac{10{\pi}^{3}\sqrt{3}}{243}$
But, how would one go about evaluating this using contour integration?.
The roots of $x^{2}-x+1=0$ are at $x=e^{\pm\frac{\pi i}{3}}$
Would a semi-annulus work or would a keyhole contour be better?. 
For the semi-annulus contour, the only pole that would lie in it would be $e^{\frac{\pi i}{3}}$
Unless I made a mistake, The residue there is $ 2\pi i Res\left(z=e^{\frac{\pi i}{3}}\right)=\frac{-2{\pi}^{3}\sqrt{3}}{27}$
$\ln^{2}(z)$ has a discontinuity at $z=0$, so I think we can avoid it by using a semicircle around it of radius $\epsilon$. I don't know. I am probably going the wrong direction. My contour integration isn't the greatest anyway. At least with these types of problems. Would appreciate some input if anyone finds time.  Thanks very much.  
 A: You should use a keyhole contour, but also consider the integral
$$\oint_C dz \frac{\log^3{z}}{z^2-z+1}$$
Evaluating this contour integral, it will turn out (proof left to reader) that the integrals along the circular arcs out to infinity and down to zero near the origin vanish.  That leaves the integrals up and back along the real line:
$$\oint_C dz \frac{\log^3{z}}{z^2-z+1} = \int_0^{\infty} dx \frac{\log^3{x}}{x^2-x+1} - \int_0^{\infty} dx \frac{(\log{x}+i 2 \pi)^3}{x^2-x+1} $$
Combine the expression on the right and get
$$\oint_C dz \frac{\log^3{z}}{z^2-z+1} = i \left [-6 \pi \int_0^{\infty} dx \frac{\log^2{x}}{x^2-x+1} + 8 \pi^3 \int_0^{\infty} dx \frac{1}{x^2-x+1}\right ] \\- 4 \pi^2 \int_0^{\infty} dx \frac{\log{x}}{x^2-x+1}$$
Now set this equal to $i 2 \pi$ times the sum of the residues at the poles.  The poles are at $z = e^{i \pi/3}$ and $z=e^{i 5 \pi/3}$.  Note that I am not saying that the latter pole is at $z=e^{-i \pi/3}$ because that would be inconsistent with the branch I chose in defining the argument of the values just below the real line to be $2 \pi$.
The residues are, at $z = e^{i \pi/3}$:
$$\frac{-i \pi^3/27}{2 e^{i \pi/3}-1}$$
and at $z=e^{i 5 \pi/3}$:
$$\frac{-i 125 \pi^3/27}{2 e^{i 5\pi/3}-1}$$
The contour integral is then $i 2 \pi$ times the sum of these residues:
$$\oint_C dz \frac{\log^3{z}}{z^2-z+1} = i 2 \pi \frac{124 \pi^3}{27 \sqrt{3}}$$
The real part is zero, which makes sense in light of the 1st line in your post.  For the imaginary part, however, we have two integrals, one of which we want, the other of which is in our way and we have to determine.  Fortunately, the evaluation follows exactly the same pattern as above, for an even simpler integral:
$$\oint_C dz \frac{\log{z}}{z^2-z+1}$$
which, when analyzed as above, spawns
$$\int_0^{\infty} dx \frac{1}{x^2-x+1} = \frac{4 \pi}{3 \sqrt{3}}$$
I leave it to the reader to verify this.  The problem is then a simple one in algebra and arithmetic which I also leave to the reader.  I get
$$\int_0^{\infty} dx \frac{\log^2{x}}{x^2-x+1} = \frac{20 \pi^3}{81 \sqrt{3}}$$
which implies that
$$\int_0^{1} dx \frac{\log^2{x}}{x^2-x+1} = \frac{10 \pi^3}{81 \sqrt{3}}$$
ADDENDUM
I realize that I didn't fully answer the OP's question.  You do not want to use semicircular contours for integrals of the form
$$\int_0^{\infty} dx\: f(x)$$
when $f$ is not even.  The reason for this is that the integral over the negative real line is not the same that the integral over the positive real line.  For example, let's try again to attack the integral
$$\int_0^{\infty} dx \frac{1}{x^2-x+1}$$
in this manner.  This is emphatically not the same as 
$$\int_{-\infty}^{\infty} dx \frac{1}{x^2-x+1}$$
which is what would result from a semicircular contour.  Such problems are not alleviated by avoiding branch points at the origin. In this case, the trick of using a keyhole contour on the integral
$$\oint_C dz \: f(z) \, \log{z}$$
works best, so long as you are careful about using a consistent branch of the log as I demonstrated above.  In some cases, such as 
$$\int_0^{\infty} \frac{dx}{x^3+1}$$
you can get away with a wedge contour instead of a keyhole.  This is because the denominator is invariant upon rotation by $2 \pi/3$.
ADDENDUM II
I just realized that I solved a very similar problem here.
A: Sure Ron, it's the least I can do. 
We have $\displaystyle \int_{0}^{1}\frac{\ln^{2}(x)}{x^{2}-x+1}dx=\int_{0}^{1}\frac{\ln^{2}(2)}{1+x^{3}}dx+\int_{0}^{1}\frac{x\ln^{2}(x)}{1+x^{3}}dx$......[1]
Now, begin with a definition of the Beta function:
$\displaystyle \beta(a)=\int_{0}^{1}\frac{x^{a-1}}{1+x}dx$
Which gives $\displaystyle \int_{0}^{1}\frac{x^{a-1}}{1+x^{3}}dx=\frac{1}{3}\beta(a/3)$
Differentiating twice w.r.t 'a' gives:
$\displaystyle \int_{0}^{1}\frac{x^{a-1}\ln^{2}(x)}{1+x^{3}}dx=\frac{1}{27}\beta''(a/3)$
Using the integrals from [1] and letting a=1 and a=2, we get $\displaystyle \frac{1}{27}\left(\beta''(1/3)+\beta''(2/3)\right)$
Now, using the identity $\displaystyle \beta(x)-\beta(1-x)=\frac{1}{2}\left(\psi(1/2+x/2)-\psi(x/2)+\psi(1-x/2)-\psi(1/2-x/2)\right)$, where $x=1/3$
arriving at $\displaystyle \frac{1}{216}\left(\psi''(2/3)-\psi''(1/3)+\psi''(5/6)-\psi''(1/6)\right)$
Now, note that $\displaystyle \psi(1-x)-\psi(x)=\pi\cot(\pi x)$, we get upon twice differentiating:
$\displaystyle \frac{\pi}{216}\left(\frac{d^{2}}{dx^{2}}\cot(\pi x)\right)$
$=\displaystyle \frac{\pi}{216}\left(\frac{2{\pi}^{2}\cos(\pi x)}{\sin^{3}(\pi x)}\right)$
evaluated at $x=1/3$ and $x=1/6$, respectively.
This gives:
$\displaystyle \frac{\pi}{216}\left(\frac{8{\pi}^{2}\sqrt{3}}{9}+8{\pi}^{2}\sqrt{3}\right)$
$=\displaystyle\boxed{\frac{10{\pi}^{3}\sqrt{3}}{243}}$
I agree. Using polygammas and polylogs, and other advanced 'real' methods can take some gymnastics. Besides being interesting, that is one reason I want to learn more about contours and residues. I am so-so with it, but would not have thought the way you did about it. 
On another note kind of like this. I managed to evaluate some log trig integrals using polylogs that come from complex ideas, but doing them the way Nick Strehle and you showed on the site would be beyond me.
It's interesting to note that $\displaystyle (-1)^{n-1}\int_{0}^{1-e^{i\theta}}\frac{\ln^{n-1}(z)}{1-z}dz=i\int_{0}^{\theta}\left(\ln(2\sin(x/2))-\frac{i}{2}(\pi-x)\right)^{n-1}dx$.  This is effective in evaluating some tough log sin integrals. 
A: Perhaps this should be a new thread. I can do that if necessary. But, I have a residue question regarding series you can probably answer if that's OK.
How does one evaluate the series $\displaystyle \sum_{n=1}^{\infty}\frac{1}{\sinh^{2}(\pi n)}=\frac{1}{6}-\frac{1}{2\pi}$.
I tried writing it as $\displaystyle \sum_{n=1}^{\infty}\frac{4e^{2\pi n}}{e^{4\pi n}-1}$ and noting now that the poles are at $n=\frac{ki}{2}$. 
Is this how one could go about it?. I think I may be onto something, but I am not entirely sure how to proceed. 
I also just wrote it as $\frac{\pi\cos(\pi z)}{\sin(\pi z)\sinh^{2}(\pi z)}$ and found the residue at $z=n$ to be $\sum_{n=1}^{\infty}\frac{1}{\sinh^{2}(\pi n)}$ and at $z=ni$ to be the same thing.
The residue at z=0 is $-2/3$.
So, I think we have $0=\frac{-2}{3}+4\sum_{n=1}^{\infty}\frac{1}{\sinh^{2}(\pi n)}$.
Which would give the 1/6 portion of the solution. But, in order to arrive at the required solution I would have to have a $\frac{2}{\pi}$ in there. Thus, dividing by 4 would give the $\frac{1}{2\pi}$ portion of the solution. I don't know. I am probably off kilter . :)
Cheers
