Why does my professor say that writing $\int \frac 1x \mathrm{d}x = \ln|x| + C$ is wrong?
My professor says that writing this is convenient $$\int \frac 1x \mathrm{d}x = \ln|x| + C\tag{1}$$ but wrong, since it should be written as: $$\int \frac 1x \mathrm{d}x = \begin{cases}\ln x + C &x > 0\quad(\star)\\[0.2em] \ln(-x) + C &x < 0\end{cases}$$
I was wondering why is that the case. I thought that the two were equivalent, as one can see by the definition of absolute value. In $(\star)$ the equality sign is dropped because the logarithm is not defined in $0$, but that would be the case with $(1)$ as well.
I don't see anything wrong with what you wrote there. I could only imagine a rigorous teacher commenting about the constant... it need not be the same in each interval, as in: $$\int \frac 1x \mathrm{d}x = \begin{cases}\ln x + C_1 &x > 0\\[0.2em] \ln(-x) + C_2 &x < 0\end{cases}$$
The notation $\int \frac 1x dx$ is already ambiguous. If $f$ is defined on some open set of the real numbers, the notation $$ \int f(x) dx = RHS$$ (without borns of integration) means that the primitives on $f$ in its open set of definition are the functions that are parametrized by the RHS.
If $f$ is defined on an inverval, this simply gives $$ \int f(x)dx = F(x) + C, C \in \mathbb{R}.$$ If $f$ is defined on a union of disjoint intervals, then you should be more precised. In my opinion, it is better in this case to write a sentence of the kind:
The primitives of $\frac 1x$ on $\mathbb{R}^\ast$ are the functions defined by $\ln(-x) + C_1$ for $x < 0$ and $\ln(x) + C_2$ for $x > 0$, where $C_1$ and $C_2$ are arbitrary real constants.