Integrals

Integral of ln(x): x ln x − x + C (Integration by Parts)

Integral of ln(x): x ln x − x + C (Integration by Parts) — CalculusCalc cover image

Quick answer:

$$\int\ln x\,dx = x\ln x - x + C$$

The integral of ln x is a classic because \( \ln x \) is not on any basic antiderivative table, yet one clever application of integration by parts finishes it in two lines. Below you’ll find the derivation, a geometric picture that explains the answer, worked definite integrals, the most common variations and practice problems with answers.

Derivation by integration by parts

There’s no obvious antiderivative of \( \ln x \), but its derivative \( \frac1x \) is simple. That is the signal for integration by parts: \( \int u\,dv = uv - \int v\,du \).

Choose

$$u = \ln x, \quad dv = dx \qquad\Longrightarrow\qquad du = \frac1x\,dx, \quad v = x$$

Then

$$\begin{aligned} \int\ln x\,dx &= x\ln x - \int x\cdot\frac1x\,dx \\ &= x\ln x - \int 1\,dx \\ &= x\ln x - x + C \end{aligned}$$

The trick is to see \( \ln x \) as \( \ln x\cdot 1 \) and let the “1” be \( dv \). Why does this choice work? Differentiating \( \ln x \) turns it into \( \frac1x \), an algebraic function, and the \( x \) that comes from integrating \( dv \) cancels it exactly. The new integral is just \( \int 1\,dx \). This is the “L” (logarithm) in the LIATE rule: logs almost always make the best choice for \( u \).

Check by differentiating

Use the product rule on \( x\ln x \), together with \( \frac{d}{dx}\ln x = \frac1x \):

$$\frac{d}{dx}\left(x\ln x - x\right) = \ln x + x\cdot\frac1x - 1 = \ln x \checkmark$$

The \( -x \) is essential: it cancels the \( +1 \) that the product rule produces.

Why it works: a picture with areas

There is a nice geometric way to see the answer. The graphs of \( y = \ln x \) and \( x = e^y \) are the same curve. For \( b > 1 \), the rectangle with corners \( (0, 0) \) and \( (b, \ln b) \) has area \( b\ln b \). The curve splits that rectangle into two pieces:

  • the area under \( y = \ln x \) from \( x = 1 \) to \( x = b \), which is the integral you want, and
  • the area to the left of the curve, which is \( \int_0^{\ln b} e^y\,dy = b - 1 \).

So the area under the log curve is the rectangle minus the exponential piece:

$$\int_1^b\ln x\,dx = b\ln b - (b - 1)$$

That is exactly \( \left[x\ln x - x\right]_1^b \). For \( b = e \) the rectangle has area \( e \), the exponential piece has area \( e - 1 \), and the difference is 1. The same idea works for the integral of any inverse function, which is why \( \int\arctan x\,dx \) and \( \int\arcsin x\,dx \) are solved with the same “\( dv = dx \)” trick.

Definite integral examples

1. \( \int_1^e\ln x\,dx = \left[x\ln x - x\right]_1^e = (e - e) - (0 - 1) = 1 \)

2. \( \int_0^1\ln x\,dx \) is an improper integral because \( \ln x \to -\infty \) at 0. Since \( x\ln x \to 0 \) as \( x \to 0^{+} \),

$$\int_0^1\ln x\,dx = (0 - 1) - \lim_{x\to0^+}(x\ln x - x) = -1$$

It converges even though the function is unbounded: the spike near 0 is so thin that its area stays finite. The answer is negative because \( \ln x < 0 \) on \( (0, 1) \), so all the area lies below the axis.

3. \( \int_1^2\ln x\,dx \). Evaluate the antiderivative at both ends:

$$\left[x\ln x - x\right]_1^2 = (2\ln 2 - 2) - (0 - 1) = 2\ln 2 - 1$$

That is about 0.386. A quick sanity check: \( \ln x \) runs from 0 to about 0.693 on this interval, so an area a bit under half of 0.693 times the width 1 is reasonable, since the curve is concave down.

4. Average value. The average value of \( \ln x \) on \( [1, e] \) is the integral divided by the length of the interval, \( \frac{1}{e - 1} \approx 0.582 \).

Variations

\( \ln(2x) \): \( x\ln(2x) - x + C \) (same method, or note \( \ln 2x = \ln 2 + \ln x \)).

\( \ln(x + 1) \): take \( u = \ln(x + 1) \) and \( dv = dx \), but choose \( v = x + 1 \) instead of \( v = x \). Any antiderivative of \( dv \) is allowed, and this one cancels the denominator exactly:

$$\int\ln(x + 1)\,dx = (x + 1)\ln(x + 1) - x + C$$

\( x\ln x \): parts with \( u = \ln x \), \( dv = x\,dx \):

$$\int x\ln x\,dx = \frac{x^2\ln x}{2} - \frac{x^2}{4} + C$$

More generally, for \( n \neq -1 \),

$$\int x^n\ln x\,dx = \frac{x^{n+1}\ln x}{n + 1} - \frac{x^{n+1}}{(n+1)^2} + C$$

\( (\ln x)^2 \): parts twice. This is a common exam question, so here it is in full. Let \( u = (\ln x)^2 \) and \( dv = dx \). By the chain rule, \( du = \frac{2\ln x}{x}\,dx \), and \( v = x \). The \( x \) from \( v \) cancels the \( x \) in the denominator of \( du \), leaving

$$\int(\ln x)^2dx = x(\ln x)^2 - 2\int\ln x\,dx$$

The integral that remains is the one you just learned, so substitute \( x\ln x - x \) for it and distribute the \( -2 \):

$$\int(\ln x)^2dx = x(\ln x)^2 - 2x\ln x + 2x + C$$

Notice the pattern: each round of parts lowers the power of the logarithm by one. The same idea handles \( (\ln x)^3 \), which takes three rounds:

$$\int(\ln x)^3dx = x(\ln x)^3 - 3x(\ln x)^2 + 6x\ln x - 6x + C$$

Keeping track of the alternating signs is the only hard part, so work slowly and check the final answer by differentiating.

\( \frac{\ln x}{x^2} \): parts with \( u = \ln x \) and \( dv = x^{-2}dx \), so \( v = -\frac1x \):

$$\int\frac{\ln x}{x^2}\,dx = -\frac{\ln x}{x} - \frac1x + C$$

\( \frac{\ln x}{x} \): this one is u-substitution, not parts. With \( u = \ln x \), \( du = \frac{dx}{x} \):

$$\int\frac{\ln x}{x}\,dx = \frac{(\ln x)^2}{2} + C$$

What about negative x?

The formula only makes sense for \( x > 0 \), because \( \ln x \) is undefined otherwise. If a problem involves \( \ln|x| \) on negative numbers, the answer is \( x\ln|x| - x + C \). You can confirm it by differentiating: the product rule gives \( \ln|x| + x\cdot\frac1x - 1 \), which is \( \ln|x| \) for every nonzero \( x \). In practice, most textbook problems stay on positive \( x \), but it is worth knowing that the same shape of answer works on both sides of zero.

Log with another base

\( \log_a x = \frac{\ln x}{\ln a} \), so \( \int\log_a x\,dx = \frac{x\ln x - x}{\ln a} + C \). For base 10, divide the usual answer by \( \ln 10 \).

How to choose u and dv for log integrals

Almost every integral that contains a logarithm multiplied by a power of \( x \) follows the same recipe, and it helps to know why.

  1. Put the log in \( u \). Differentiating a log removes it and leaves a simple power of \( x \). Integrating a log is exactly the problem you are trying to solve, so it cannot go in \( dv \).
  2. Put everything else in \( dv \). That is usually a power \( x^n\,dx \), which is easy to integrate.
  3. Simplify before integrating again. After one step, the new integrand is a power of \( x \) times a constant, because the \( \frac1x \) from \( du \) cancels one power of \( x \) from \( v \).

The one exception is when the power is exactly \( x^{-1} \), as in \( \frac{\ln x}{x} \). Then the factor \( \frac1x \) is the derivative of the log, and a substitution is quicker than parts. Recognizing that case at a glance saves you a page of work.

Common mistakes

  • Answering \( \frac1x \). That is the derivative of \( \ln x \), not its integral.
  • Forgetting the \( -x \). \( x\ln x \) alone differentiates to \( \ln x + 1 \).
  • Choosing \( u = 1 \), \( dv = \ln x\,dx \). That requires already knowing the integral of \( \ln x \), so you go in a circle.
  • Evaluating \( 0\cdot\ln 0 \) directly. At the endpoint 0 you need a limit; \( x\ln x \to 0 \) as \( x \to 0^+ \).
  • Mixing up \( \ln(x)/x \) and \( \ln(x)/x^2 \). The first is a substitution, the second needs parts.

Where it’s used

The integral of \( \ln x \) shows up whenever logarithms are summed. The sum \( \ln 1 + \ln 2 + \cdots + \ln n \) equals \( \ln(n!) \), and comparing it with \( \int_1^n\ln x\,dx \), just like a Riemann sum, gives the approximation \( \ln(n!) \approx n\ln n - n \). The same integral appears in entropy formulas in physics and information theory, and it is a standard stepping stone to the integral of 1/x and other log integrals.

Try it yourself

Step-by-step solverExact symbolic engine

Interactive Calculus Problem Solver

Derivatives, antiderivatives, definite and improper integrals, and limits. Every answer comes with the rules used, and antiderivatives are verified by differentiating them back.

Try:
Input syntax
  • Powers x^2, roots sqrt(x), cbrt(x), absolute value |x|
  • Implicit multiplication works: 3x sin(2x)
  • sin cos tan sec csc cot, asin acos atan, sinh cosh tanh
  • e^x or exp(x); ln(x) and log(x) are both the natural log
  • Constants pi and e; bounds accept inf and -inf
Enter a function and press Solve to see a full worked solution.

The integral calculator shows the integration by parts steps for any of the variations above.

Practice problems

Try these before checking the answers.

  1. \( \int\ln(3x)\,dx \)
  2. \( \int_1^{e^2}\ln x\,dx \)
  3. \( \int x^2\ln x\,dx \)
  4. \( \int x^3\ln x\,dx \)
  5. \( \int\frac{\ln x}{x^2}\,dx \)
  6. \( \int_1^e x\ln x\,dx \)

Answers: (1) \( x\ln(3x) - x + C \); (2) \( e^2 + 1 \); (3) \( \frac{x^3\ln x}{3} - \frac{x^3}{9} + C \); (4) \( \frac{x^4\ln x}{4} - \frac{x^4}{16} + C \); (5) \( -\frac{\ln x}{x} - \frac1x + C \); (6) \( \frac{e^2 + 1}{4} \).

FAQ

Why isn’t the integral of ln x equal to 1/x?

That’s the derivative. Integration goes the other way, which is why we need parts.

Is the integral of ln x the same as x ln x?

Almost, but you must subtract \( x \). Differentiating \( x\ln x \) alone gives \( \ln x + 1 \), not \( \ln x \).

What is the integral of ln x from 0 to 1?

It equals \( -1 \). The integral is improper at 0, but it converges because \( x\ln x \to 0 \) there.

Can you integrate ln x without integration by parts?

Yes, with the area picture above, or by the inverse-function formula. Both are integration by parts in disguise, but they explain where the answer comes from.

Why is there a + C?

Any function that differs from \( x\ln x - x \) by a constant has the same derivative, \( \ln x \). The \( C \) records that whole family. For definite integrals the constant cancels, so you can leave it out.

What is the integral of log base 10 of x?

Divide by \( \ln 10 \): \( \frac{x\ln x - x}{\ln 10} + C \).

Further reading

Related: derivative of ln x, integral of 1/x.

Calculators for this topic

Leave a comment

Your email address will not be published. Required fields are marked *