For the input (mine is much more complicated, this is a toy example):
x/x /. x -> 0
the output of 1 (as opposed to
Indeterminate) is understood (although I cannot say I am happy about it), when looking at the
Trace, which shows that the
x/x is simplified to
1, before the
One way around this problem, is to define the function:
f indeed produces
However, if I then invoke
FunctionDomain[f[x],x], I get
FunctionDomain also receives a simplified form of the function, prior to calculating the domain.
The workaround for this was suggested to me by @Szabolcs, and originally from @ChipHurst, as can be seen here, by wrapping the first argument of
FunctionDomain in a
However, this continues to bite, when solving equations. E.g., with the following definition:
g[x] := x/Sqrt[x^2]
I am okay with:
Solve[g[x] == 0, x, Reals]
Reduce[g[x] == 0, x]
False. But if I give
Reduce a bit more info, it simplifies
x, and for:
Reduce[g[x] == 0, x, Reals]
x == 0.
@Szabolcs pointed out that similar results are obtained if the right hand side of the equation is 1, the former form of
Reduce producing a correct answer, and the latter, an incorrect one.
One possible (ugly) workaround, would be to "remind"
Reduce of the possible values of
Reduce[g[x] == 0 \[And] FunctionDomain[g[x], x], x, Reals]
Producing the correct answer.
However, I'd be most pleased to hear of explanations of this phenomenon, and better solutions.