# How to evaluate $\int \frac{\left(2-z\left(u\right)\right)z'\left(u\right)}{\left(z\left(u\right)\right)^2-z\left(u\right)+2}du$?

I am trying to evaluate

$$\int \frac{\left(2-z\left(u\right)\right)z'\left(u\right)}{\left(z\left(u\right)\right)^2-z\left(u\right)+2}du \quad (1)$$

I think I've found a solution by using integration by substitution but I am having trouble with expressing the infinitesmall. You'll understand as you read.

My attempt

Lets re-write the integral more simply as:

$$\int \frac{(2-z) z'}{z^2-z+2}du$$

Since $$z$$ is not a variable but a function of $$u$$, the first basic composite integrals that come to mind are the following:

$$\int \frac{f(x)f'(x)}{f(x)^2+1} dx = \frac12 \ln\left|f^2(x)+1\right| +C \quad (2)$$ $$\int \frac{f'(x)}{f(x)^2+1} dx = \arctan\left|f(x)\right| +C\quad (3)$$

We can re-write the denominator of $$(1)$$ as

$$z^2-z-2 = \frac74\left[ \left( \frac{2}{\sqrt 7} (z-\frac12) \right)^2 +1 \right]$$

Hence. plugging it in $$(1)$$

$$\int \frac{(2-z) z'}{z^2-z+2}du = \int \frac{(2-z) z'}{\frac74\left[ \left( \frac{2}{\sqrt 7} (z-\frac12) \right)^2 +1 \right]}du = \frac47 \int \frac{(2-z) z'}{ \left( \frac{2}{\sqrt 7} (z-\frac12) \right)^2 +1 }du$$

It seems we are on the right way. Let's break the integral:

$$\frac87 \int\frac{z'}{ \left( \frac{2}{\sqrt 7} (z-\frac12) \right)^2 +1 }du - \frac47 \int\frac{zz'}{ \left( \frac{2}{\sqrt 7} (z-\frac12) \right)^2 +1 }du$$

If we could bring the integral in $$(2) \text{ and } (3)$$ forms then we would have had evaluated it, i.e:

Let $$h = \frac{2}{\sqrt 7}(z(u) - \frac12) \to$$ $$z(u) = \frac{\sqrt 7}{2}h+\frac12$$

All we need now is to find $$du$$, but that I am having trouble understanding how infinitesmall will change by this substitution. Note that $$z$$ is a function of $$u$$ and not a variable.

How can $$du$$ be expressed in terms of $$h$$?

I think we can write is as:

$$h = \frac{2}{\sqrt 7}(z(u) - \frac12) \iff dh = \frac{2}{\sqrt 7} z'(u) du$$

but I am unsure if this is correct.

\small \begin{aligned} \int \frac{2-z(u)}{z^2(u)-z(u)+2}\,z'(u)\,\text{d}u & = \frac{3}{2}\int \frac{1}{z^2(u)-z(u)+2}\,z'(u)\,\text{d}u - \frac{1}{2}\int \frac{2\,z(u)-1}{z^2(u)-z(u)+2}\,z'(u)\,\text{d}u \\ & = \frac{3}{2}\int \frac{1}{\left(z(u)-\frac{1}{2}\right)^2+\frac{7}{4}}\,z'(u)\,\text{d}u - \frac{1}{2}\int \frac{2\,z(u)-1}{z^2(u)-z(u)+2}\,z'(u)\,\text{d}u \\ & = \frac{6}{7}\int \frac{1}{1+\left[\frac{2}{\sqrt{7}}\left(z(u)-\frac{1}{2}\right)\right]^2}\,z'(u)\,\text{d}u - \frac{1}{2}\int \frac{2\,z(u)-1}{z^2(u)-z(u)+2}\,z'(u)\,\text{d}u \\ & = \frac{3\sqrt{7}}{7}\int \frac{\frac{2}{\sqrt{7}}}{1+\left[\frac{2}{\sqrt{7}}\left(z(u)-\frac{1}{2}\right)\right]^2}\,z'(u)\,\text{d}u - \frac{1}{2}\int \frac{2\,z(u)-1}{z^2(u)-z(u)+2}\,z'(u)\,\text{d}u \\ & = \frac{3\sqrt{7}}{7}\int \frac{1}{1+h^2(u)}\,h'(u)\,\text{d}u - \frac{1}{2}\int \frac{1}{k(u)}\,k'(u)\,\text{d}u \\ & = \frac{3\sqrt{7}}{7}\,\arctan(h(u)) - \frac{1}{2}\,\ln|k(u)| + c \\ & = \frac{3\sqrt{7}}{7}\,\arctan\left(\frac{2\,z(u)-1}{\sqrt{7}}\right) - \frac{1}{2}\,\ln\left(z^2(u)-z(u)+2\right) + c \,. \end{aligned}