If $p$ and $q$ are solutions of the equation $x \tan x = 1$, show the integral of $\cos^2 px$ entirely in terms of $p$ I am working through a pure maths text book out of interest. I have finished the chapter on integration and differentiation of trigonometric functions and am  doing the end of chapter questions. This is causing me a problem:
Given that $p$ and $q$ are solutions of the equation  $x \tan x = 1$,
Find an expression for $\int^1_0 \cos^2 px \ dx$ entirely in terms of $p$, not involving any trigonometric functions.
This is my working so far:
if $p$ and $q$ are solutions of $x \tan x = 1$,
$$p\frac{\sin p}{\cos p} = 1$$
$$\cos^2px = \frac{1 + \cos 2px}{2}$$
$$\int \cos^2px ~dx = \frac{1}{2}(x + \frac{\sin 2px}{2p})$$
$$= \frac{1}{2}(\frac{2px + \sin 2px}{2p})$$
I need to find
$$\left[ 
    \frac{1}{2}((\frac{2px + \sin 2px}{2p})
   \right]_{0}^1$$
But I cannot arrive at the answer in the book which is:
$$\frac{2 + p^2}{2(1 + p^2)}$$

$$I=\int_0^1 \cos ^2(p x) \, dx=\frac{\sin (2 p)}{4 p}+\frac{1}{2}$$
it is given that $\tan p=\frac{1}{p}$
From the formula
$$\sin \alpha=\frac{2t}{1+t^2};\;t=\tan\frac{\alpha}{2}$$
we get
$$\sin 2p=\frac{2\tan p}{1+\tan^2 p}=\frac{2\cdot\frac{1}{p}}{1+\left(\frac{1}{p}\right)^2}=\frac{2 p}{p^2+1}$$
and finally
$$I=\frac{\frac{2 p}{p^2+1}}{4p}+\frac{1}{2}=\frac{p^2+2}{2 p^2+2}$$
