What's the nth integral of $\frac1{x}$?

As Isaac noted, repeated integration seems to give the following pattern

$$ \frac{x^{n-1} \log x}{(n-1)!} - C_n x^{n-1}$$

Note that the value of $\displaystyle C_n$ does not really matter, as differentiating $n$ times nukes it. Also, note that, we can add any arbitrary $\displaystyle (n-1)^{th}$ degree polynomial to this, without changing the $\displaystyle n^{th}$ derivative.

In order to prove that the $\displaystyle n^{th}$ derivative of $\displaystyle \frac{x^{n-1} \log x}{(n-1)!}$ is $\displaystyle \frac{1}{x}$, we can use induction.

$$ \frac{1}{(n-1)!} \frac{d (x^{n-1} \log x)}{dx} = \frac{x^{n-2}}{(n-1)!} + \frac{x^{n-2} \log x}{(n-2)!}$$

Since adding an arbitrary $\displaystyle (n-2)^{th}$ degree polynomial does not change the $\displaystyle (n-1)^{th}$ derivative of $\displaystyle \frac{x^{n-2} \log x}{(n-2)!}$ we are done using induction.

Note that if $\displaystyle f(x)$ is another function such that $\displaystyle \frac{d^n f}{dx} = \frac{1}{x}$, then we have that $\displaystyle \phi(x) = f(x) - \frac{x^{n-1} \log x}{(n-1)!}$ has it's $\displaystyle n^{th}$ derivative to be zero, and hence it is a polynomial of degree $\displaystyle n-1$ or lower (can be proved using induction, again).

Thus all the functions you are looking for are of the form

$$\frac{x^{n-1} \log x}{(n-1)!} + \sum_{j=0}^{n-1} c_j x^j$$

where $\displaystyle c_j$ are arbitrary constants.


If we use the repeated integral formula on the reciprocal function, with $1$ as the lower limit, we get

$$\begin{align*} \underbrace{\int_1^x\int_1^{t_{n-1}}\cdots\int_1^{t_1}}_{n} \frac1{t}\;\mathrm dt\cdots\mathrm dt_{n-2}\mathrm dt_{n-1}&=\frac1{(n-1)!}\int_1^x\frac{(x-t)^{n-1}}{t}\mathrm dt\\ &=(-1)^n \frac{x^{n-1}}{(n-1)!}B_{1-x}(n,1-n) \end{align*}$$

where $B_x(a,b)$ is the incomplete beta function.

Letting

$$g_n(x)=(-1)^n \frac{x^{n-1}}{(n-1)!}B_{1-x}(n,1-n)$$

the following more "elementary" representation can be derived:

$$g_n(x)=\frac{x^{n-1}}{(n-1)!}(\ln\,x-H_{n-1})-\sum_{j=1}^{n-1}\frac{(-1)^j}{j\cdot j!}\frac{x^{n-j-1}}{(n-j-1)!}$$

where $H_n=\sum\limits_{j=1}^n\frac1{j}$ is a harmonic number.

As Aryabhata mentions in his answer,

$$\frac{\mathrm d^n}{\mathrm dx^n}\left(\frac{x^{n-1}}{(n-1)!}\ln\;x+p_{n-1}(x)\right)=\frac1{x}$$

where $p_{n-1}(x)$ is any polynomial of degree $n-1$; $g_n(x)$, however, has the special property (by virtue of how it was constructed) that

$$\left.\frac{\mathrm d^k}{\mathrm dx^k}g_n(x)\right|_{x=1}=0\quad \text{if}\quad k < n$$


We can solve this problem by the use of fractional derivatives.

$\forall q < 0$, using the Riemann Liouville formula and substituting $v = \frac{x-y}{x}$:

$$ \frac{d^q}{dx^q}\log x = \\ \frac{1}{\Gamma(-q)} \int_0^x \frac{\log (y)}{(x-y)^{q+1}}\, dy=\\ \frac{x^{-q} \log x}{\Gamma(-q)}\int_0^1 \frac{dv}{v^{q+1}} + \frac{x^{-q}}{\Gamma(-q)}\int_0^1 \frac{\log(1-v)}{v^{q+1}}\, dv $$

The first integral equals $-\frac{1}{q}$, while the second one is evaluated by parts:

$$\int_0^1 \frac{\log(1-v)}{v^{q+1}}\, dv = \\ \frac{1}{q} \int_0^1 \log(1-v)\,d(1-v^{-q}) = \\ \frac{\log(1-v^{-q}) \log(1-v)}{q}\big|_0^1 - \frac{1}{q} \int_0^1 \frac{1-v^{-q}}{1-v}\, dv = \\ \frac{\psi(1-q)+\gamma}{q} $$

Then

$$\frac{d^q}{dx^q}\log x = \frac{x^{-q}}{\Gamma(1-q)}(\log x - \gamma - \psi(1-q))$$

Letting $q \mapsto -q$ and letting $q$ be an integer, and differentiating once we obtain:

$$\boxed{I^q \frac{1}{x} = \frac{x^{q-1}}{q!}\left(q\log x + q\sum_{n=1}^q \frac{1}{n}+1\right)+P_{n-1}(x)}$$

where $I^q$ represents the $q^{th}$ integral and $P_{n-1} (x)$ represents a polynomial of degree $n-1$. Note that the sum above is for the $n^{th}$ harmonic number.

Reference: The Fractional Calculus (Oldham & Spanier)