# Find $\int\frac{dx}{p\left(e^x\right)}$ where $p$ is a polynomial

Currently I'm facing a lot of integrals of the form $$I(p)=\int\frac{dx}{p\left(e^x\right)}$$ where $$p:\mathbb{R}\to\mathbb{R}$$ is a polynomial. For example, $$\begin{split}I(x+1)&=\int\frac{dx}{e^x+1} \\&=\int\frac{e^{-x}dx}{1+e^{-x}}\\&=\ln\left(1+e^{-x}\right)+C\end{split}$$ but for $$p(x)=x^2+x+1$$ the problem is already getting tricky. I'm trying to find a general method to this problem. I tried to make the Ansatz (where $$q$$ need not be a polynomial - it can be anything!) $$I(p)=\ln \left(q\left(e^x\right)\right)$$ which leads to (taking derivatives on both sides) $$\frac{1}{p\left(e^x\right)}=\frac{q'\left(e^x\right)e^x}{q\left(e^x\right)}$$ which is (almost) the same as the problem $$\frac{q'(x)}{q(x)}=\frac{1}{xp(x)}$$ which has a 'solution' (integrating both sides and taking exponentials) $$q(x)=\exp\left(\int\frac{dx}{xp(x)}\right),$$ but studying rational integrands hasn't really a general approach so it doesn't seem that this method is getting me anywhere! I hope another Ansatz - or maybe a completely different approach - exists to deal with this problem.

We have $$\int\frac{dx}{p(e^x)}=\int\frac{e^x\,dx}{e^xp(e^x)}.$$ Then substituting $$t=e^x$$ we arrive at $$\int\frac{dt}{q(t)},$$where $$q(t)=tp(t)$$ is also a polynomial. Then use the standard methods: partial fractions and so on.