# Can ComplexInfinity output be trusted?

A quick question regarding evaluation of algebraic expressions at specific values. If for instance I enter

(x + 1) (x + 2)/((x + 2) (x + 3)) /. x -> -2


mathematica will output $$-1$$, automatically evaluating the limit at the removable singularity.

In another scenario, I have some complicated algebraic expression $$f$$ involving $$x$$'s and $$a$$'s , and entering

f/.x->1/a


returns ComplexInfinity'.

My question is, in general, if I evaluate some expression at a point in this manner, and get $$$$ComplexInfinity' as the output, can I be sure that the expression diverges at this point?

• It would be better to use Limit. In your first example, x+2 terms (probably) cancel before the substitution Commented May 4, 2019 at 6:11
• A simple counter-example is (1 + 2 x + x^2)/(x + 1) /. x -> -1, where you do need to use Limit. Automatic cancellation of factors only works when the factors are explicit, as in your example. Commented May 4, 2019 at 6:15
• thanks for the responses. The issue with using Limit on my f is that it doesnt seem to be able to produce an output, since the expression is quite complicated. Commented May 4, 2019 at 6:51
• Also I think it's worth noting that in the counterexample (1 + 2 x + x^2)/(x + 1) /. x -> -1, the output is 'indeterminate' rather than 'complexinfinity'. Maybe there is some distinction here Commented May 4, 2019 at 6:52
• This is an empty talk without your "some complicated algebraic expression " which makes no sense. Commented May 4, 2019 at 9:27

Does this mean I can be 100% confident that the expression $$f$$ does not converge at $$x=1/a$$?

No:

f = ((E + x)^2 - E^2 - x^2 - 2 E x)/(a x - 1);

f /. x -> 1/a
(*  ComplexInfinity  -- message omitted *)

Limit[f, x -> 1/a]
(*  0  *)


In fact, this $$f$$ is zero:

Simplify[f]
(*  0  *)

• Disagree with "In fact, this $f$ is zero": up to usual conventions, $f$ is not defined at $x= \frac 1 a$ (assuming, of course, $a\neq 0$). Commented May 4, 2019 at 14:01
• @user64494 That's obvious. Are you saying the function is not zero? Or are you disagreeing with something else? Commented May 4, 2019 at 14:03
• Because $\frac 1 a$ does not belong to the domain of $f$, the substitution x->1/a is incorrect, so its result is unpredictable. Commented May 4, 2019 at 14:07
• Let us put $a=2$. Then FunctionDomain[(-x^2 - 2 E x + (x + E)^2 - E^2)/(2 x - 1), x, Reals] performs $x<\frac{1}{2}\lor x>\frac{1}{2}$. Commented May 4, 2019 at 14:15
• @user64494 That seems both obvious, as I said before, since I constructed the function that way, and exceedingly trivial. Do you really feel it's necessary to add to any statement about the behavior of a function $f \colon A \rightarrow B$ the proviso "on its domain $A$"? Commented May 4, 2019 at 14:47

Mathematica does not evaluate limits unless explicitly asked to do so. What it does is simply evaluate the numerator, then evaluate the denominator, and then evaluate the resulting fraction. The only subtlety is that "evaluate the resulting fraction" means a simple syntactic evaluation, without bothering of possible zeros and thus returning an expression which is not fully equivalent to the input expression. Mathematica also doesn't try to factor the numerator/denominator to check for possible cancellations.

If the resulting fraction turns out to be 1/0, then it will evaluate to ComplexInfinity. If the resulting fraction is 0/0, then it will evaluate to Indeterminate.

Your first example is evaluated as follows:

1. Evaluate the numerator: (x + 1) (x + 2) => (x + 1) (x + 2);

2. Evaluate the denominator: (x + 2) (x + 3) => (x + 2) (x + 3);

3. Evaluate the fraction (Mathematica performs simple syntax cancellation of terms): (x + 1) (x + 2) / ((x + 2) (x + 3)) => (x + 1) / (x + 3);

4. Substitute -2 for x: (x + 1) / (x + 3) => -1 / -1 => 1.

For the example form the comments the evaluation chain is as follows:

1. Evaluate the numerator: (1 + 2 x + x^2) => (1 + 2 x + x^2);

2. Evaluate the denominator: (x + 1) => (x + 1);

3. Evaluate the fraction: (1 + 2 x + x^2) / (x + 1) => (1 + 2 x + x^2) / (x + 1);

4. Substitute -1 for x : (1 + 2 x + x^2) / (x + 1) => 0 / 0 => Indeterminate.

• Trace and TracePrint can be quite useful in such situations to see how the evaluation progresses through an expression. Commented May 4, 2019 at 13:12
• Unfortunately, $(x + 1) (x + 2)/((x + 2) (x + 3))$ is not defined at $x=-2$ up to traditional math. Therefore, the substitution $x=-2$ makes no sense. Commented May 4, 2019 at 14:25
• @user64494, that's what I meant by "not fully equivalent to the input expression". Commented May 4, 2019 at 14:49
• Do you answer the unclearly formulated question under consideration? Commented May 4, 2019 at 15:05