If I enter x/x
, I get 1
. Such behavior leads to this:
Simplify[D[Sqrt[x^2], x, x]]
0
The same would be even if I use Together
instead of Simplify
.
One could then think that $\sqrt{x^2}$ is doubly differentiable at least $\forall x\in\mathbb R$, but if we remove Simplify
call, we would reveal that it's not:
D[Sqrt[x^2], x, x]
-(x^2/(x^2)^(3/2)) + 1/Sqrt[x^2]
Even more ridiculous is this (which I guess is because x/x
is simplified before feeding to Assuming
):
Assuming[x == 0, x/x]
1
Why does Mathematica assume $x\ne0$? Is there a way to make it not cancel out such terms?
-(x^2/(x^2)^(3/2)) + 1/Sqrt[x^2]
is exactly zero, except atx=0
. But From a mathematical standpoint the problem is more like why does mathematicas differential operatorD
not excludex=0
in this case. $\endgroup$D
gives an expression, which is undefined for $x=0$. It's quite a correct result for function, which isn't differentiable at $x=0$. But then simplifying it to $0$ makes it defined at $x=0$ too, which is incorrect. $\endgroup$Simplify
to be a generic complex number. By generic, I mean not having any isolated special value, such as0
. You have to useAssumptions
to change this default. $\endgroup$Assumptions
for this? See update of the question. $\endgroup$