Does $\int{\frac{x}{\cos(x)}dx}$ have an elementary solution? I need to solve the following integral: $\displaystyle\int\frac{x}{\cos(x)}\,dx$. My procedure is the following:
\begin{align*}\int\frac{x}{\cos(x)}\,dx &= \int x\sec(x)\,dx\\
&=x\ln(\tan(x)+\sec(x))-\int\ln(\tan(x)+\sec(x))\,dx.
\end{align*}
But, I'm stuck at this step, after using integration by parts I have $\ln(\tan(x)+\sec(x))$ inside the new integral and then I do not know how to solve it, I was trying using by parts again but it gets more complicated.
Any advice on how to continue? I looked for related questions to this problem here in math.stackexchange but did not find anything useful.
 A: Your integration by parts can be written
$$\begin{align*}\int\frac{x}{\cos(x)}\,dx &= \int x\sec(x)\,dx\\
&=x \ln \tan\left(\frac{\pi}{4}+\frac{x}{2}\right) -\int\ln \tan\left(\frac{\pi}{4}+\frac{x}{2}\right)\,dx.
\end{align*}$$
and the infinite series for $\ln \tan\left(\frac{\pi}{4}+\frac{x}{2}\right)$ is
$$\ln \tan\left(\frac{\pi}{4}+\frac{x}{2}\right)=2\sum_{k=1}^\infty \frac{2^{2k-1} \beta(2k-1)}{(2k-1)\pi^{2k-1}}x^{2k-1} \tag{1}$$
where $\beta(n)$ is the Dirichlet Beta Function.
Then you also can establish the Cosine Series for $\ln \tan\left(\frac{\pi}{4}+\frac{x}{2}\right)$ 
$$\ln \tan\left(\frac{\pi}{4}+\frac{x}{2}\right)=-2 \sum _{k=1}^{\infty } \frac{\cos \left(2 (2 k-1) \left(\frac{\pi }{4}+\frac{x}{2}\right)\right)}{2 k-1} \tag{2}$$
from the well known Cosine Series for $\ln \sin x$ and $\ln \cos x$.
Therefore using the approach above you should be able to calculate, for example, the integral $$\int_0^{\pi/3}\frac{x}{\cos(x)}\,dx=\frac{1}{3} \pi  \log \left(\tan \left(\frac{\pi }{4}+\frac{\pi }{6}\right)\right)-\frac{2 G}{3}$$ 
where $G$ is Catalans Constant and without simplification
$$\frac{2 G}{3}=2\sum_{k=1}^\infty \frac{2^{2k-1} \beta(2k-1)}{(2k-1)\,2k\, \pi^{2k-1}}\left(\frac{\pi}{3}\right)^{2k}$$
The pattern appears to be that directly integrating any of the functions $\ln \sin x$, $\ln \cos x$, $\ln \tan x$, $\ln \tan (\pi/4+x/2)$, $\ln \sinh x$, $\ln \cosh x$, $\ln \tanh x$ and $\ln \tanh (\pi/4+x/2)$ does not lead to a new elementary primitive. That associated definite integral closed forms can be evaluated using the above techniques, without introducing complex numbers, is worth remembering. 
[Note the infinite series for $\ln \tan x$ is different to (1) given above for $\ln \tan (\pi/4+x/2)$, since the phase shifted $\ln \tan \frac{x}{2}$ function appears when integrating the $\csc$ function, not the $\sec$ function as above. In the the equivalent notation
$\ln \tan x= \log x + \sum_{k=1}^\infty \frac{2^{2k} \,\eta{(2k)}}{k \,\pi^{2k}}x^{2k}$, where $\eta(k)$ is the Dirichlet Eta Function]
A: Wolfram Alpha returns
$$x (\log(1 - i e^{i x}) - \log(1 + i e^{i x})) + i (\text{Li}_2(-i e^{i x}) - \text{Li}_2(i e^{i x}))$$
which you can trust with closed eyes.
Alpha uses to return solutions valid in $\mathbb C$, which sometimes makes the expression look complicated. In the case on hand, maybe the logarithmic terms can be rewritten with reals only. But maybe not the dilogarithmic ones.
And you can be sure that no elementary solution is possible.
A: Perhaps the expanding of $e^x$ be useful, well
\begin{align}
\int\dfrac{x}{\cos x}dx
&= \int\dfrac{2xe^{-ix}}{1+e^{-2ix}}dx \\
&= \int 2xe^{-ix}\sum_{n\geq0}e^{-2inx}dx \\
&= \sum_{n\geq0}\int 2xe^{-i(2n+1)x}dx \\
&= \sum_{n\geq0}2e^{-i(2n+1)x}\left(\dfrac{ix}{2n+1}+\dfrac{1}{(2n+1)^2}\right) \\
\end{align}
