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?


Solution 1:

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.

Solution 2:

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.