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 ReplaceAll.

One way around this problem, is to define the function:


then, f[0] indeed produces Indeterminate.

However, if I then invoke FunctionDomain[f[x],x], I get True. Apparently 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 Hold.

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]

producing {}, and:

Reduce[g[x] == 0, x]

gives me False. But if I give Reduce a bit more info, it simplifies g[x] to x, and for:

Reduce[g[x] == 0, x, Reals]

I get 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 x:

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.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.