Demystify integration of $\int \frac{1}{x} \mathrm dx$

I’ve learned in my analysis class, that

$$ \int \frac{1}{x} \mathrm dx = \ln(x). $$

I can live with that, and it’s what I use when solving equations like that.
But how can I solve this, without knowing that beforehand.

Assuming the standard rule for integration is

$$ \int x^a \, \mathrm dx = \frac{1}{a+1} \cdot x^{a+1} + C .$$

If I use that and apply this to $\int \frac{1}{x} \,\mathrm dx$:

$$ \begin{align*}
\int \frac{1}{x}\mathrm dx &= \int x^{-1} \,\mathrm dx \\
&= \frac{1}{-1+1} \cdot x^{-1+1} \\
&= \frac{x^0}{0}
\end{align*} $$

Obviously, this doesn’t work, as I get a division by $0$. I don’t really see, how I can end up with $\ln(x)$. There seems to be something very fundamental that I’m missing.

I study computer sciences, so, we usually omit things like in-depth math theory like that. We just learned that $\int \frac{1}{x} dx = \ln(x)$ and that’s what we use.

Solutions Collecting From Web of "Demystify integration of $\int \frac{1}{x} \mathrm dx$"

If you want to try to prove $\int\frac{\mathrm dx}x=\ln x + C $ (for $x \gt 0$), try the substitution

$$ \begin{align}
x &= e^u \\
\mathrm dx &= e^u \mathrm du
\end{align} $$

This substitution is justified because the exponential function is bijective from $\mathbb{R}$ to $(0,\infty)$ (hence for every $x$ there exists a $u$) and continuously differentiable (which allows an integration by substitution).

$$\int\frac{\mathrm dx}x=\int\frac{e^u\mathrm du}{e^u}=u+C$$

Now just use the fact that natural log is the inverse of the exponential function. If $x=e^u,u=\ln x$.

Let’s use your result :
$$\int x^a \, dx = \frac{x^{a+1}}{a+1} + C=\frac{x^{a+1}-1}{a+1} +C’$$
and take the limit as $\,a\to -1\,$ (since $\;x^{a+1}=e^{(a+1)\ln(x)}$) :
$$\lim_{a\to\,-1}\int x^a \, dx = C’+\lim_{a\to\,-1}\frac{e^{(a+1)\ln(x)}-1}{a+1}=C’+\ln(x)$$
Hoping this will help your intuition,

Logarithms are all about solving exponential equations right? For example, logarithms are useful if you want to solve $2^x=3$. Maybe you are really confused about how in the world finding the area under $y=\frac{1}{x}$ has anything to do with solving such equations. Hopefully this post will illuminate that – but it may be a bit long winded.

Say you wanted to solve $2^x=3$ and you are a 16th century mathematician. So, no calculator. You could just use bisection method, getting closer and closer approximations, but this involves the very laborious process of computing roots, and you wouldn’t want to have to do this every time you have an exponential equation to solve. So here is the genius idea. You will pay someone to calculate $1.0001^n$ for you for $n=1$ to $1000000$. You can teach them the mechanical skill of multiplying these numbers in a week because you only have to shift and add (see what I mean by computing the first few!). Then you look in your table to find that $1.0001^{6931} \approx 2$ and $1.0001^{10986} \approx 3$.

This helps you because now $2^n = 3$ can be rewritten as $1.0001^{6931n} = 1.0001^{10986}$, so $n = 10986/6931 \approx 1.585$. Just to double check ourselves, $2^{1.585} \approx 3.00007798$, so it pretty much worked.

This same table allows you to approximate the solutions to a huge number of exponential equations, in exactly the same manner. The upfront investment of labor is worth the time, because now you and your buddies can all solve these equations just by table lookups.

Later on, you want more precision, so you pay a whole group of laborers to calculate the powers of $1.000001$. You notice that in the old table for $1.0001$, the entry for $1.0001^{10000} = 2.71814593$, and the entry for $1.000001^{1000000} = 2.71828047$. Seems like a pretty special number to be coming up in these exponential tables, so you call it $e$ for exponential.

You have done all you can with exponential equations for the time being, so you turn your attention to other matters. First you notice the curious fact that the number of faces plus the number of vertexes minus the number of edges of any polyhedron seems to always be 2. You struggle to find a proof of this, but are tormented to no end. Later you turn to predicting the motion of the planets. Some time later your patron wants you to design some kind of war machine. Finally, many years after your experiments with exponential equations, you turn your attention to the problem of finding areas bounded by hyperbolas. You know that there are classical solutions to the area under a parabola, but as far as you know, no one has tackled the area under $y = \frac{1}{x}$ from $x=1$ to $x=2$, for instance.

You set about attempting to calculate this area. Your first thought is just to carve the region up into a great number of rectangles, all of equal base. You choose cut up the interval $[1,2]$ at the points $1.0001, 1.0002, 1.0003, 1.0004, 1.0005 ,… 1.9999$ and sum the areas of all the rectangles you get. You find that the answer is about $.693122$. Gifted as you are with the supernatural recall of a 16th century mathematician, you remember that all those years ago, $1.0001^{6931} \approx 2$. What a great mystery! What could be at the bottom of this coincidence?

First of all, in your old tables you were repeatedly multiplying 1.001, which is not exactly how you cut up [1,2] in your area calculation. However, there is nothing wrong with cutting up the interval [1,2] at the points $1.001, 1.001^2, 1.001^3, 1.001^4,$ etc. These numbers are all still close to each other, so computing the area of the corresponding rectangles will give a good approximation to the area under your curve, and these rectangles at least have a chance at relating the two problems.

So what are the areas of these rectangles? The area of the first rectangle is $1 \cdot (1.001-1) = .001$. The area of the second rectangle is $\frac{1}{1.001} \cdot (1.001^2-1.001) = .001$. The area of the third rectangle is $\frac{1}{1.001^2} \cdot (1.001^3-1.001^2) = .001$! Hey! These are all the same area! So the total area under the curve is just going to be $A = .001n$, where n is the solution to $1.001^n=2$. This is only an approximation though. We would get a better approximation if we used our table for 1.000001. It would be handy to write our result in a way which was agnostic about which table we were using. Oh ya, that number e always appeared in our table. So, we could say

$1.001^n = 2 \implies (1.001^{1000})^{0.001n} = 2 \implies e^A = 2$

Wow! Carrying out the same reasoning for any other $t$, we find that the area $A_t$ from $x=1$ to $x=t$ under $\frac{1}{x}$ should satisfy $e^{A_t} = t$. In other words this area function is giving an inverse to the exponential function with base e.

Hopefully this little story helps you understand what finding $\displaystyle\int_1^t \frac{1}{x} dx$ has to do with solving exponential equations, and also why the number $e$ comes into the picture naturally. To summarize, you cut up the interval [1,t] at the points $1, 1.001^2, 1.001^3, …, 1.001^n$, where $n$ is the largest power of $1.001$ which is still less than $t$. To get from one rectangle to the next, the width gets multiplied by 1.001 and the height gets divided by 1.001, so the areas of all of these rectangles are the same. Thus the area under the rectangle $A$ is just $.001n$. But then $(1.001^{1000})^{.001n} \approx t$, and so $e^{.001n} \approx t$, which means $e^{A} \approx t$. This approximation gets better and better if you choose $1.000001$, or $1.00000000001$. So we actually have the equality $e^A =t$. Using the definition of natural logarithm as inverse of exponential function, we have $A = \ln(t)$.

I would recommend playing with this by writing a computer program to solve $a^n=b$ using the method we discussed (limit yourself to only addition, multiplication, and for loops). If you do not know how to program, just making a spreadsheet would be pretty informative: you can have your computer take the place of your laborer. Draw pictures of the area under the curve, partitioned in the way we have discussed, and see how that ties in. There is a lot to digest here.

The rule doesn’t work when $a = -1$. There is a nice way you can get at the derivative of an inverse function if you know the derivative of the function, by way of something called implicit differentiation. Thus if you are willing to grant that $\frac{d}{dx} e^x = e^x$, then I can show that $\frac{d}{dx} \ln x = 1/x$, which is the result that you want. Write $y = \ln x$, then $e^y = x$ so that by the chain rule, $$\frac{d}{dx} e^y = e^y\frac{dy}{dx}$$ thus $$1 = e^y \frac{dy}{dx}$$ thus $$1 = x \frac{dy}{dx}$$ thus $$\frac{dy}{dx} = 1/x$$ which by definition is equivalent to the equation $$ \int \frac{1}{x} dx = \ln x +c $$

There are several approaches. One is based on the limit
By adjusting the constant of integration, we have
\int x^n\,\mathrm{d}x=\frac1{n+1}\left(x^{n+1}-1\right)+C\tag{2}
Taking the limit of $(2)$ as $n\to-1$ and using $(1)$ yields
\int x^{-1}\,\mathrm{d}x=\log(x)+C\tag{3}
$(1)$ is essentially a rewrite of the standard limit
\lim_{n\to\infty}\left(1+\frac xn\right)^n=e^x\tag{4}

Actually your first equation should read

$$ \ln(x) = \int_{1}^{x}\frac{1}{t} dt$$

Now we show this.

Here is an approach that starts from the basics.

Define the exponential map by the power series in the usual way. Then $\exp: \mathbb{R} \to \mathbb{R}_{+}$ is an increasing bijective map. Thus, it has an increasing inverse function

$$ \ln: \mathbb{R}_{+} \to \mathbb{R} $$

We know that $\exp$ is a differentiable function such that

$$ \exp^{\prime}(x) = \exp(x) \qquad \forall \; x \in \mathbb{R}$$

Now we use the followgin theorem:

Theorem: Let $U \subset \mathbb{R}$ and suppose $f : U \to \mathbb{R}$ is an injective function, differentiable at some $a \in U$. In addition, suppose that $f^{-1}: f(U) \to U$ is continuous at $b = f(a)$. Then $f^{-1}$ is differentiable at $b$ if and only if $f^{\prime}(a) \neq 0$ and in that case,

$$ (f^{-1})^{\prime}(b) = \frac{1}{f^{\prime}(a)}$$

So we get that $\ln(x)$ is differentiable for all $y \in \mathbb{R}_{+}$ (since $\exp(x) \neq 0$) and (assuming $ y = \exp(x)$)

$$ \ln^{\prime}(y) = \frac{1}{\exp(x)} = \frac{1}{y}$$

Now use Fundamental Theorem of Calculus to get the first equation.

Along with the other fine responses, I would also like to point out you could reason this through limits.

The regular formula for integral of $x^n$ actually still works, only that it adds a huge constant to it as $n$ goes towards $-1$. That’s because $\frac{x^{n+1}}{n+1}$ can be well approximated as $\ln x+\frac{1}{1-n}$ as $n$ goes to $-1$.

$$\begin{array}{rcl} \lim_{\alpha \to 1}\int x^{-\alpha}dx &=& \lim_{\alpha \to 1} \frac{x^{1-\alpha}}{1-\alpha}+C \\
&=& \lim_{\alpha \to 1} \frac{x^{1-\alpha}-1}{1-\alpha}+C+\frac{1}{1-\alpha} \\
&=&\lim_{\beta \to 0} \frac{x^{\beta}-1}{\beta}+C+\frac{1}{1-\alpha}\\
&=&\ln x+\left(C+\frac{1}{1-\alpha}\right)\\

To show $\int\frac{dx}{x}=\ln{x}+C$ for positive $x$, we can show that the derivative of $\ln{x}$ is $\frac{1}{x}$. This can be done using the standard limit
and the definition of the derivative. We have
which is what we wanted to show.

I did sign up just to say some answers here are misleading.

$$\int \frac{1}{x} dx = \ln(x). $$

is not a calculation but a definition. This is how ln(x) is defined. ln(x) is defined before exp(x)

One must not intermingle, what is definition and what is theorem. Before handling the given question, one should clearly state what we mean by exponential function, and what we mean by logarithmic function. There are a lot of theorems in between the definition and the final result. For a nice and accurate answer one should go through W Rudin’s Pr of Math Analysis. A little known book “Beardon’s Complex analysis is marvelous in this respect.

In my opinion, the primitive of the function $1/x$ has to be studied without mentioning the exponential function $e^x$. Indeed, the exponential function is the inverse function of the primitive of $1/x$ function. This recalls the story of the chicken and the egg: what we consider as known, $e^x$ or $\ln (x)$ ?