I'm doing complex analysis and I have the following $$\int_{C}\frac{2dz}{(2i+1)z^2+6iz+2i-1}$$ where $C$ is the unit circle. I tried factorizing this polynomial and find the residues but I really can't solve this.
This is my work: $$z_{1,2} = \frac{-3i\pm \sqrt{-9-(-4-1)} }{2i+1}=\frac{-3i\pm 2i}{1+2i} \cdot \frac{1-2i}{1-2i}= \frac{-3i-6\pm 2i\pm 4}{5}$$ which gives $z_1 = -\frac{2}{5}-\frac{i}{5}$ and $z_2 = -2-i$. Now clearly $z_2$ is outside the unit circle so I just have to consider the residue of $z_1$.
However I think I'm either making a factorisation mistake or a mistake in the roots. Indeed if we check the roots, I don't get the same polynomial! $$(z+2+i)\left(z+\frac{2}{5}+\frac{i}{5}\right) = z^2 +z\left(\frac{12}{5}+\frac{6i}{5}\right)+\frac{4i}{5}+\frac{3}{5}$$ which is clearly not the same polynomial I started with. Also if I try to calculate the residue using the limit, I don't get the correct one. Where's my mistake?
EDIT
As requested, I'll add some more calculations. To calculate the residue I did the following: $$\lim_{z\to z_1}(z+\frac{2}{5}+\frac{i}{5})\frac{2}{(z+2+i)\left(z+\frac{2}{5}+\frac{i}{5}\right)} = \frac{2}{\frac{8}{5}+\frac{4i}{5}} = \frac{5}{4+2i} = \frac{20-10i}{20}=1-\frac{i}{2}$$ which is clearly wrong as this integral is the mapping of a real integral of the first type (rational function in sine and cosine). Indeed by Cauchy's Residue Theorem this should give that the value of the initial real integral is $2\pi i (1-\frac{i}{2}) = 2\pi i+\pi$ which is a complex value, so this is wrong
Let's start with the factorization question. The given integrand is a fraction, and to use the residue theorem, we must find the roots of the denominator, i.e., the roots of $$ (2i+1)z^2+6iz+(2i-1). $$ To find the roots of this polynomial, it's easiest to use the quadratic formula to get that the roots are \begin{align*} \frac{-6i\pm\sqrt{(6i)^2-4(2i+1)(2i-1)}}{2(2i+1)}&=\frac{-6i\pm\sqrt{-36+20}}{4i+2}\\ &=\frac{-6i\pm\sqrt{(6i)^2-4(2i+1)(2i-1)}}{2(2i+1)}\\ &=\frac{-6i\pm\sqrt{-16}}{4i+2}\\ &=\frac{-6i\pm4i}{4i+2} \end{align*} Therefore, the roots are $\frac{-2i}{4i+2}=\frac{-i}{2i+1}$ and $\frac{-5i}{2i+1}$. Multiplying through by the conjugate of the denominator, $(1-2i)$ gives that the roots are $\left(-\frac{2}{5}-\frac{1}{5}i\right)$ and $(-2-i)$.
As the OP observes, the polynomial $$ \left(z-\left(-\frac{2}{5}-\frac{1}{5}i\right)\right)(z-(-2-i))=z^2+\left(\frac{12}{5}+\frac{6}{5}i\right)z+\left(\frac{3}{5}+\frac{4}{5}i\right) $$ is not the original denominator. This is another polynomial with the same roots, as the original polynomial. To make the polynomials the same, we should multiply by $(1+2i)$ to correct the coefficient of $z^2$. In fact $$ (1+2i)\left(z^2+\left(\frac{12}{5}+\frac{6}{5}i\right)z+\left(\frac{3}{5}+\frac{4}{5}i\right)\right)=(2i+1)z^2+6iz+(2i-1), $$ the original polynomial.
Therefore, the original polynomial factors as $$ (2i+1)z^2+6iz+(2i-1)=(2i+1)\left(z-\left(-\frac{2}{5}-\frac{1}{5}i\right)\right)(z-(-2-i)). $$
To deal with the residues, the OP correctly determines that $-2-i$ is outside the unit circle, so it doesn't matter for the integral (although it could be used to calculate the integral, but that is a story for another time).
Therefore, the value of the given integral is $2\pi i$ times the residue at $\left(-\frac{2}{5}-\frac{1}{5}i\right)$. Rewriting the integral as $$ \int_\gamma \frac{2}{(1+2i)(z-(-2-i))}\cdot\frac{1}{z-\left(-\frac{2}{5}-\frac{1}{5}i\right)}dz, $$ the value of the residue can be calculated by substituting $\left(-\frac{2}{5}-\frac{1}{5}i\right)$ for $z$ in $\frac{2}{(1+2i)(z-(-2-i))}$. This substitution results in $-\frac{1}{2}i$ and Cauchy's residue theorem gives that the integral is $\pi$.
The only mistake that the OP seems to make throughout is forgetting the factor of $(1+2i)$ when factoring the denominator. When that is included, all of the answers (and the limit approach in the question) agree.