# Why do some integrals and derivatives have absolute values?

I have noticed that some integrals and derivatives have absolute value. For example: $$\int\frac 1 x \, dx=\ln|x|+c$$ for $x$ is not equal to zero. So, the point is why is there the absolute value of $x$?

• I'd prefer $\ln|x|+c_1+c_2\operatorname{sgn}x$ Dec 11, 2016 at 18:53
• @HagenvonEitzen Can you elaborate on that please?
– Ovi
Dec 12, 2016 at 5:16
• @Ovi The function is not defined at $0$, so the antiderivative is defined on two distinct intervals -- the interval for $x > 0$, and the interval for $x < 0$. The constant ($+ c$) can be different on the two intervals, so there should really be two constants. This is the effect of Hagen's suggestion of adding $+ c_2 \operatorname{sgn} x$. It may be conceptually cleaner to instead say that the indefinite integral is $\ln x + c_1$ for $x > 0$, and $\ln (-x) + c_2$ for $x < 0$.
– 6005
Dec 12, 2016 at 10:08
• @6005 Oh that's very clever, this way we have a system of two equations with 2 unknowns $$c_1 + c_2 = C_{x>0}$$ $$c_1 - c_2 = C_{x<0}$$
– Ovi
Dec 12, 2016 at 16:51

Because if $x < 0$, $\log x$ is not defined, so certainly it's derivative it's not equal to $\frac 1x$; on the other hand $\log -x$ works just fine (check it!)
So one should write $\int \frac 1x$ equal to $\log x$ if $x > 0$ and equal to $\log -x$ if $x<0$. We summarize this by putting the absolute value of logarithm, even though in $0$ the function is not defined and not differentiable
• But we don't use the absolute value for Square Roots? if $x<0, {\sqrt{x} is also not defined??? or am i wrong here??? Dec 11, 2016 at 18:44 • @SarmadRafique: If you take the derivative of$\sqrt{|x|}$you get something which still has absolute values in it, so it's not something that you're likely to run into “by accident” when computing antiderivatives. On the other hand, it's a very common situation to have to take the antiderivative of$1/x$(or similar functions like$1/(x-a)$), and then you need to know what the answer is, not just for$x>0$but also for$x<0$. Dec 11, 2016 at 19:27 • @SarmadRafique both have solution in complex numbers. But for real numbers an integration for 1/x is quite common. And the derivative (or integral) of sqrt(x) are straight forward (just modifications of the formula similar to x^2) while ln(x) is very special. Dec 12, 2016 at 14:11 The antiderivative of$f(x)$is a function$F(x)$such that$F'(x)=f(x)$for all$x$in the domain of$f$. Thus$\ln|x|$is an antiderivative of$\frac{1}{x}$because • if$x>0$,$\frac{d}{dx}(\ln|x|)=\frac{d}{dx}(\ln(x))=\frac{1}{x}$• if$x<0$,$\frac{d}{dx}(\ln|x|)=\frac{d}{dx}(\ln(-x))=\frac{1}{-x} \cdot \frac{d}{dx}(-x)=\frac{1}{-x}\cdot (-1)=\frac{1}{x}.$It would be wrong to say that$\ln(x)$is an antiderivative for$\frac{1}{x}$, because it is not defined when$x<0$. Hence$\frac{d}{dx}\ln(x)$is not defined when$x<0$, so it cannot be equal to$\frac{1}{x}$(which is defined for$x<0$). • and why don't we use the absolute in the square root? Dec 11, 2016 at 18:55 • @SarmadRafique the square root of what exactly? Dec 11, 2016 at 18:56 • Are you asking why$\int\sqrt{x} \ dx = \frac{2}{3}x^{3/2}+C$and not$\frac{2}{3}|x|^{3/2}+C$? The reason is that$\sqrt{x}$and$x^{3/2}$are both only defined for$x \geq 0$. – kccu Dec 12, 2016 at 2:38 Simply because taking the derivative of those functions with absolute values will yield the original integrand. Suppose we know that$\dfrac d {dx}\ln x = \dfrac 1 x,$and that that of course presupposes that$x$is positive. Now suppose we want an antiderivative of$1/x$on the interval$(-\infty,0)$, i.e. all negative values of$x.$$$f'(x) = \frac 1 x, \quad x<0.$$ For$a<b<0$we have $$\int_a^b \frac 1 x \, dx = f(b) - f(a).$$ Let$u = -x$, so$du = -dx$. As$x$goes from$a$(which is negative) to$b$(which is negative), then$u$goes from$-a$(which is positive) to$-b$(which is positive), and we have $$\int_a^b \frac 1 x \, dx = \int_{-a}^{-b} \frac 1 {(-u)}\, (-du) = \int_{-a}^{-b} \frac 1 u \, du = \ln(-b) - \ln(-a) = \ln|b| - \ln|a|.$$ Differentiating with respect to$b$yields $$\frac d {db} (\ln |b| - \ln |a|) = \frac d {db} \int_a^b \frac 1 x \, dx = \frac 1 b.$$ And this is with$b<0$. Another way to see this is by looking at the graph of$f(x) = \frac 1 x$which has two, not connected parts, as 0 is not part of the domain. The same way but more obviously, the function (with the same domain) and definition:$ F(x) = lnx + c $(when x>0),$ ln(-x) + c $(when x<0) has two, non connected parts. But we can rewrite it more compactly as$ F(x) = ln |x| + c $. • Actually, you can choose different constants for each connected component. This shows show a first order equation$xy'=1\$ may have a two dimensional space of solutions because of a singularity.