When I input \[Integral]1/x \[DifferentialD]x in Mathematica, I get Log[x]. How can I make the result of the integral $\displaystyle \int\dfrac{1}{x}dx$ to be $\ln|x|$?
|
|
|||||
|
|
The result you're after is only correct in the reals. Since Mathematica generally assumes that everything is complex, I'm not sure if there is a simple way to make it return the result you want. You can go backwards and check that, for $x\in\mathbb{R}$, $\frac{d}{dx}\log|x|=\frac1x$:
(aside: However, in general, the antiderivative of $x^{-1}$ is defined to be $\log(x)$
Note that $\log(x) = \log|x| + i\arg(x) = \log|x| + i(\theta+2n\pi)$, where $n$ is the winding number (see [1]) and for real $x$, $\arg(x)=m\pi$ is "locally constant". That is, if you assume that $x$ is real and non-zero, then the only difference between $\log(x)$ and $\log(-x)$ is a purely imaginary constant ($\pm i \pi$):
There was an interesting discussion about this (mainly focused on pedagogy) at the n-Category Café earlier this year. So, in summary, I don't think there is a good way or a good reason to force the absolute value into |
|||||||
|
|
|
We can 'hack' Mathematica to get what we want.
Edit Here's a more general example:
|
||||
|
|
