This question is just a soft question, about can we compute a general formula for everything? Or it has some restrictions?
Like $\int x^ndx=\frac{x^{n+1}}{n+1}+C$.
I am not able to deduce a formula for both.
I dont know where to start, so please guide me?

- 4,595
1 Answers
There is not a useful anti-derivative (i.e., an anti-derivative in terms of standard mathematical functions) for all integrable functions. For example
$$F(x)=\int x^x\,dx$$
cannot be written in terms of standard functions as discussed here.
However, the OP mentioned two specific functions of interest, $(1)$ $\frac{1}{x^n+1}$ and $(2)$ $\cos^n x$. For those functions, we will now give rough outlines for solutions.
$(1)\,\,\,$ $\frac{1}{x^n+1}$
Note that for integer $n$, $x^n+1=0$ implies that $e^{i{2m+1}\pi/n}$ for $m=0, 1,2, \cdots, n-1$. Therefore, we can write
$$\frac{1}{x^n+1}=\prod_{m=1}^{n-1}\frac{1}{x-e^{i(2m+1)\pi/n}} \tag 1$$
and we can use partial fraction expansion to write Equation $(1)$ in terms of the sum of $n$ terms, each having the general form $\frac{1}{x-e^{i(2m+1)\pi/n}}$.
$$\begin{align} \frac{1}{x^n+1}&=\sum_{m=1}^{n-1}\frac{1}{nx_m^{n-1}(x-x_m)}\\\\ &=\sum_{m=1}^{n-1}\frac{-x_m}{n(x-x_m)} \end{align}$$
where $x_m=e^{i(2m+1)\pi/n}$.
The integration of each of the $n$ terms is trivial (i.e., in terms of the natural logarithm with complex arguments) although combining terms will be tedious for large $n$.
In this answer here, I show that
$$\bbox[5px,border:2px solid #C0A000]{\int\frac{1}{x^n+1}dx=-\frac1n\sum_{k=1}^n\left(\frac12 x_{kr}\log(x^2-2x_{kr}x+1)-x_{ki}\arctan\left(\frac{x-x_{kr}}{x_{ki}}\right)\right)+C'} $$
where $x_{kr}$ and $x_{ki}$ are the real and imaginary parts of $x_k$, respectively, and are given by
$$x_{kr}=\text{Re}\left(x_k\right)=\cos \left(\frac{(2k-1)\pi}{n}\right)$$
$$x_{ki}=\text{Im}\left(x_k\right)=\sin \left(\frac{(2k-1)\pi}{n}\right)$$
It is interesting to remark that one can also express the integral in terms of the hypergeometric function $_2F_1$ as
$$\int\,\frac{1}{x^n+1}\,dx=x\left(_2F_1\left(1,\frac{1}{n};1+\frac{1}{n};-x^n\right)\right)+C$$
$(2)\,\,\,$ $\cos^n x$
The integral of $\cos^n x$ has been discussed in this answer in which straightforward integration by parts yields the recursive relationship
$$\int\,\cos^nx\,dx=\frac{\sin x\,\cos^{n-1}x}{n}+\frac{n-1}{n}\int\,\cos^{n-2}\,dx$$
The integration by parts scheme is simply to let $u=\cos^{n-1}x$ and $dv=\cos x\,dx$. Then,
$$\begin{align} \int\,\cos^nx\,dx&=\sin x\cos^{n-1}x+(n-1)\int\,\cos^{n-2}x\,\sin^2x\,dx\\\\ &=\sin x\cos^{n-1}x+(n-1)\int\,(\cos^{n-2}x-\cos^nx)\,dx\\\\ n\,\int\,\cos^nx\,dx&=\sin x\cos^{n-1}x+(n-1)\int\,\cos^{n-2}x\,dx\\\\ \int\,\cos^nx\,dx&=\frac{\sin x\cos^{n-1}x}{n}+\frac{n-1}{n}\int\,\cos^{n-2}x\,dx+C \end{align}$$
as was to be shown!

- 179,405
-
It's not clear whether a recursive formula actually answers the question entirely. The answer should probably be written as a sum. An alternative would be to expand $\cos^n x = (e^{ix} + e^{-ix})^n/2^n$ using the binomial theorem. – Keith Jul 05 '15 at 07:33
I gave you a counterexample, essentially saying no.
– Panglossian Oporopolist Jul 05 '15 at 03:35