Computing an indefinite integral: $\int \frac{2n!\sin x + x^n }{e^x + \sin x + \cos x + P_n (x)}\, dx $
Solution 1:
This is a tricky integral!
Let's prove that
$$ \begin{align} \int \frac{2n!\sin x + x^n }{e^x + \sin x + \cos x + P_n (x)} {\rm d} x & = n! \:x-n!\:\log |e^x+\cos x+\sin x+P_n(x)| +C, \end{align} $$
where $C$ is any constant (depending on $n$).
Observe that $$ P_n (x) = 1 + \frac{x}{1!} + \frac{x^2 }{2!} + \cdots + \frac{x^n }{n!} $$ is such that $$ P_n '(x) = 1 + \frac{x}{1!} + \frac{x^2 }{2!} + \cdots + \frac{x^{n-1} }{(n-1)!}= P_n (x) -\frac{x^n}{n!}. $$ Setting $$ f(x):=e^x+\cos x+\sin x+P_n(x) $$ we then have $$ f'(x)=e^x-\sin x+\cos x+P_n(x)-\frac{x^n}{n!} $$ and $$ f(x)-f'(x)=2\sin x+\frac{x^n}{n!} $$ Hence your integral may be rewritten as $$ \begin{align} \int \frac{2n!\sin x + x^n }{e^x + \sin x + \cos x + P_n (x)} {\rm d} x &= n! \int \frac{f(x)-f'(x) }{f(x)}{\rm d} x \\\\ &= n! \int {\rm d} x-n! \int \frac{f'(x) }{f(x)}{\rm d} x \\\\ & = n! \:x-n!\:\log |f(x)| +C \\\\ & = n! \:x-n!\:\log |e^x+\cos x+\sin x+P_n(x)| +C, \end{align} $$ where $C$ is a constant (depending on $n$).