If you're seeing this message, it means we're having trouble loading external resources on our website.

If you're behind a web filter, please make sure that the domains *.kastatic.org and *.kasandbox.org are unblocked.

Main content

Indefinite integral of 1/x

In differential ​calculus we learned that the derivative of ln(x) is 1/x. Integration goes the other way: the integral (or antiderivative) of 1/x should be a function whose derivative is 1/x. As we just saw, this is ln(x). However, if x is negative then ln(x) is undefined! The solution is quite simple: the antiderivative of 1/x is ln(|x|). Created by Sal Khan.

Want to join the conversation?

  • leaf red style avatar for user Inutaki
    What is the antiderivative of a constant to the power of negative one? Like 2^-1? Is it ln( l2l ) or something similar?
    (14 votes)
    Default Khan Academy avatar avatar for user
    • male robot hal style avatar for user Cameron
      A constant to the power of a constant, a constant divided or multiplied by a constant, a constant added to or subtracted from a constant, etc. is still just a constant.

      If the value doesn't change, when you change x, you have a constant.

      The graph of 2^-1 (which is 1/2 or 0.5) just like all constants is a straight horizontal line (It doesn't change with x).

      The antiderivative of a straight horizontal line is a line with a slope.
      i.e. integral(k dx)= k * x+C

      Just to prove it works here:
      remember d/dx(0.5x+c) = 0.5 = 2^-1

      Hope this makes sense
      (92 votes)
  • spunky sam blue style avatar for user Chunmun
    What is the difference between lnx and ln|x| ?
    Please explain.
    Thank you .
    (12 votes)
    Default Khan Academy avatar avatar for user
    • leaf grey style avatar for user Qeeko
      Suppose x is a real number. We denote by |x| the absolute value of x. If x ≥ 0, we have |x| = x, and if x < 0, we have |x| = -x.

      Denote the natural logarithm of a positive real number x by log(x). The function defined by log(|x|) is the composition of the logarithm function with the absolute value function. In other words, it is the function defined by log(|x|) = log(x) if x > 0, and log(|x|) = log(-x) if x < 0.
      (32 votes)
  • blobby green style avatar for user MAnastos98
    Why is ∫ 1/x dx not equal to, say, ln |2x|, or ln |3x|? For both of these, d/dx = 1/x, right?
    (10 votes)
    Default Khan Academy avatar avatar for user
  • mr pants teal style avatar for user Wiebke Janßen
    At : Why do we search for ln |x|? at that moment?
    (7 votes)
    Default Khan Academy avatar avatar for user
  • blobby green style avatar for user vinay2403
    Is absolute value same as mod function?
    (3 votes)
    Default Khan Academy avatar avatar for user
    • piceratops ultimate style avatar for user Just Keith
      No. They are not the same.
      Absolute value means the same thing the distance from 0.
      Mod is short for modulo. The modulo operation means the remainder of a division.
      Thus:
      6 mod 3 = 0
      7 mod 3 = 1
      8 mod 3 = 2
      9 mod 3 = 0

      Whereas
      | - 9 | = 9
      and
      | 2 + 3 𝑖 | = √13

      NOTE: Your confusion is coming from the fact that the absolute value is also called the modulus. But that is not the same as the modulo (which is what mod stands for). Also note that the term modulus has other uses in mathematics.
      (13 votes)
  • purple pi purple style avatar for user Yubin
    I've searched the antiderivative of x^-1, and it says it is log(x)+c not ln(x)+c. Why is this so?
    (1 vote)
    Default Khan Academy avatar avatar for user
    • piceratops ultimate style avatar for user Just Keith
      Professional mathematicians use the natural log, not the common log, as the assumed log. Most professional mathematicians do not use the notation "ln" for the natural log. Thus, at this level of study "log" without a base specified means the natural log.

      Therefore, log (x) + C and ln (x) + C mean the same thing.

      Note: it is very unusual to use any other base for a log in calculus than base e. There are a few areas of study where the binary (base 2) log is used, but other than those we nearly always we base e -- the math is just much easier with e as the base.
      (12 votes)
  • duskpin ultimate style avatar for user Avinash Suresh
    If my x is negative for 1/x, can't I just factor out -1 and find the integral of 1/x, which is log(x)
    (3 votes)
    Default Khan Academy avatar avatar for user
  • piceratops ultimate style avatar for user Gladwin
    AT Sal says the derivative of ln|x| is 1/x for all except o but we can clearly see that the derivative are varied, for x> 0 its 1/x and for x<0 its -(1/x). But how does Sal say its the same derivative ?
    (2 votes)
    Default Khan Academy avatar avatar for user
  • piceratops seedling style avatar for user Sharjeel Ahmad
    what does absolute value of x mean?
    (3 votes)
    Default Khan Academy avatar avatar for user
    • duskpin ultimate style avatar for user Debanil
      In Simple Language-
      Its the magnitude of x regardless of its sign
      if x= -2 then |x| =2
      if x= 1 then |x| = 1
      In Mathematical language-
      |x| = -x if x<0 and x if x>0
      This means that when x<0(i.e. negative) we take its negative and since its already negative it becomes positive.
      If x>0 then we take its positive and since its already a positive no. it still remains positive.
      I hope that was helpful.
      (3 votes)
  • spunky sam blue style avatar for user Bundi Bedu
    At , why is the domain only positive numbers? Can't we take the log of negative numbers?
    (2 votes)
    Default Khan Academy avatar avatar for user
    • piceratops ultimate style avatar for user Just Keith
      Yes, we can take the log of negative numbers, but it is a bit difficult and involves nonreal complex numbers. Thus, depending on what we are using the integral to represent, it often makes sense to place the absolute value around the argument as Sal did. But, that is not a strict requirement DEPENDING on what you are modeling with the integral or what your purposes might be.

      log|x| is equivalent to saying Re{log (x)} (where Re represents the real portion of...)

      However, if you have some application where the imaginary portion has meaning and significance, you don't have to put in the restriction.

      For reference sake, here is the basics of the log of a negative number:
      Given that b > 0
      log (-b) = log(b) + iπ

      The base is, of course, e. For other bases:
      Given that b > 0 and k≠0 and k≠1
      logₖ(-b) = logₖ(b) + iπ logₖ(e)
      (5 votes)

Video transcript

What I want to do in this video is think about the antiderivative of 1/x. Or another way of thinking about it, another way of writing it , is the antiderivative of x to the negative 1 power. And we already know, if we somehow try to apply that anti-power rule, that inverse power rule over here, we would get something that's not defined. We would get x to the 0 over 0, doesn't make any sense. And you might have been saying, OK, well, I know what to do in this case. When we first learned about derivatives, we know that the derivative-- let me do this in yellow-- the derivative with respect to x of the natural log of x is equal to 1 over x. So why can't we just say that the antiderivative of this right over here is equal to the natural log of x plus c? And this isn't necessarily wrong. The problem here is that it's not broad enough. When I say it's not broad enough, is that the domain over here, for our original function that we're taking the antiderivative of, is all real numbers except for x equals 0. So over here, x cannot be equal to 0. While the domain over here is only positive numbers. So over here, x, so for this expression, x has to be greater than 0. So it would be nice if we could come up with an antiderivative that has the same domain as the function that we're taking the antiderivative of. So it would be nice if we could find an antiderivative that is defined everywhere that our original function is. So pretty much everywhere except for x equaling 0. So how can we rearrange this a little bit so that it could be defined for negative values as well? Well, one one possibility is to think about the natural log of the absolute value of x. So I'll put little question mark here, just because we don't really know what the derivative of this thing is going to be. And I'm not going to rigorously prove it here, but I'll I will give you kind of the conceptual understanding. So to understand it, let's plot the natural log of x. And I had done this ahead of time. So that right over there is roughly what the graph of the natural log of x looks like. So what would the natural log of the absolute value of x is going to look like? Well, for positive x's, it's going to look just like this. For positive x's you take the absolute value of it, it's just the same thing as taking that original value. So it's going to look just like that for positive x's. But now this is also going to be defined for negative x's. If you're taking the absolute value of negative 1, that evaluates to just 1. So it's the natural log of 1, so you're going to be right there. As you get closer and closer and closer to 0 from the negative side, you're just going to take the absolute value. So it's essentially going to be exactly this curve for the natural log of x, but the left side of the natural log of the absolute value of x is going to be its mirror image, if you were to reflect around the y-axis. It's going to look something like this. So what's nice about this function is you see it's defined everywhere, except for-- I'm trying to draw it as symmetrically as possible-- except for x equals 0. So if you combine this pink part and this part on the right, if you combine both of these, you get y is equal to the natural log of the absolute value of x. Now let's think about its derivative. Well, we already know what the derivative of the natural log of x is, and for positive values of x. So let me write this down. For x is greater than 0, we get the natural log of the absolute value of x is equal to the natural log of x. Let me write this. Is equal to the natural log of x. And we would also know, since these two are equal for x is greater than 0, the derivative of the natural log of the absolute value of x is going to be equal to the derivative of the natural log of x. Which is equal to 1/x for x greater than 0. So let's plot that. I'll do that in green. It's equal to 1/x. So 1/x, we've seen it before. It looks something like this. So let me do my best attempt to draw it. It has both vertical and horizontal asymptotes. So it looks something like this. So this right over here is 1/x x is greater than 0. So this is 1/x when x is greater than 0. So all it's saying here, and you can see pretty clearly, is the slope right over here, the slope of the tangent line is 1. And so you see that when you look at the derivative, the slope right over here, the derivative should be equal to 1 here. When you get close to 0, you have a very, very steep positive slope here. And so you see you have a very high value for its derivative. And then as you move away from 0, it's still steep. But it becomes less and less and less steep all the way until you get to 1. And then it keeps getting less and less and less steep. But it never quite gets to absolutely flat slope. And that's what you see its derivative doing. Now what is the natural log of absolute value of x doing right over here? When we are out here, our slope is very close to 0. It's symmetric. The slope here is essentially the negative of the slope here. I could do it maybe clearer, showing it right here. Whatever the slope is right over here, it's the exact negative of whatever the slope is at a symmetric point on the other side. So if on the other side, the slope is right over here, over here it's going to be the negative of that. So it's going to be right over there. And then the slope it just gets more and more and more negative. Right over here, the slope is a positive 1. Over here it's going to be a negative 1. So right over here our slope is a negative 1. And then as we get closer and closer to 0, it's just going to get more and more and more negative. So the derivative of the natural log of the absolute value of x, for x is less than 0, looks something like this. And you see, and once again, it's not a ultra rigorous proof, but what you see is that the derivative of the natural log of the absolute value of x is equal to 1/x for all x's not equaling 0. So what you're seeing, or hopefully you can visualize, that the derivative-- let me write it this way-- of the natural log of the absolute value of x is indeed equal to 1/x for all x does not equal 0. So this is a much more satisfying antiderivative for 1/x. It has the exact the same domain. So when we think about what the antiderivative is for 1/x-- and I didn't do a kind of a rigorous proof here, I didn't use the definition of the derivative and all of that. But I kind of gave you a visual understanding, hopefully, of it. We would say it's the natural log of the absolute value of x plus c. And now we have an antiderivative that has the same domain as that function that we're taking the antiderivative of.