# Why is $\frac{d}{dx}\ln(x) = \frac1x$ when the domain of $\frac1x$ includes $(-\infty,0)$?

On Khan Academy, they factor the derivative:

$$\frac{d}{dx}\frac{x^2 + x - 2}{x-1} = \frac{d}{dx}(x+2) = 1 \text { where x \ne 1}$$

Khan says:

Recall the derivative is equal to $$1$$ for all $$x$$ values where the function is defined. Since the function is undefined for $$x=1$$, so is the derivative.

I did some Google searching to see if this was really a rule, and I found this Quora question. One of the answers provides a seeming counterexample:

$$\ln(x) \text{ has a domain } (0,∞) \\ \frac{d}{dx}\ln(x)=\frac{1}{x} \\ \frac{1}{x} \text { has the domain} (-∞,0) \text{ and } (0,∞) \\$$

So is Khan stating an incorrect rule? Obviously it works in the case of his problem, but I'd like to understand what the accurate rule is here. Maybe the key question is what type of discontinuity we're dealing with?

• Factoring that rational function introduces a hole. Jan 1, 2022 at 23:32
• Indeed, hence the where $x\ne1$ part. My question is whether what he says in the blockquote is true, and why this is seemingly contradicted by the ln(x) case. Is it because holes have a different effect than the discontinuity for ln(x) where x <= 0? Jan 1, 2022 at 23:36
• The derivative of $\ln$ is not the expression "$1/x$", but rather the function $g:(0,\infty)\to\mathbb R$ defined by $g(x)=1/x$. The fact that "$1/x$" makes sense for negative values of $x$ is a distraction in this case.
– Joe
Jan 1, 2022 at 23:41
• Thanks Joe. Basically everyone answered my question here, though I think you did so most clearly. I also appreciate Jose showing this in the context of the limit definition of deriv. Will let the votes roll in for a bit longer before marking answered, etc Jan 1, 2022 at 23:44
• No problem @bgcode! The problem is that, in practice, it is very common to conflate functions with the algebraic expressions that define them. While this can be convenient when we are mechanically applying the rules of differentiation, in this case it leads to confusion. Basically, it is $f$ which is a function (not $f(x)$, which is just the value of $f$ at the point $x$), and $f'$ is the derivative. Therefore, strictly speaking, it does not make sense to speak of the derivative of $\ln(x)$, or $x^2$, etc.
– Joe
Jan 1, 2022 at 23:55

By definition,$$f'(a)=\lim_{x\to a}\frac{f(x)-f(a)}{x-a},$$and therefore $$f'(a)$$ being defined only makes sense if $$a$$ is in the domain of $$f$$.
In the example in which $$\log'(x)=\frac1x$$, what happens is that the analytic expression for $$\log'(x)$$ makes sense for numbers $$x$$ which don't belong to the domain of $$\log$$. But that does not mean that $$\log$$ is differentiable at those points.
Technically you should consider your function not just as a single expression, but also together with its domain and codomain. Since the log function is defined for every $$x>0$$, it has no sense to consider the analytic expression of its derivative only. You are deriving a function that is defined for strictly positive $$x$$, so the derivative has to be defined at most on this domain as well.
Even if the geometric meaning of the derivative is not always the best intuition, here it may help. Think about the derivative as the angular coefficient tangent line at a point for your function. It makes sense to be considered only at the points where the function itself is defined. Of course you can draw lines also on the negative $$x$$-axis, but you are no longer considering it as a derivative of your starting function.