0
$\begingroup$

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?

$\endgroup$
8
  • 2
    $\begingroup$ It would be better to use Limit. In your first example, x+2 terms (probably) cancel before the substitution $\endgroup$
    – mikado
    May 4, 2019 at 6:11
  • $\begingroup$ 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. $\endgroup$
    – Roman
    May 4, 2019 at 6:15
  • $\begingroup$ 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. $\endgroup$ May 4, 2019 at 6:51
  • $\begingroup$ 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 $\endgroup$ May 4, 2019 at 6:52
  • 2
    $\begingroup$ This is an empty talk without your "some complicated algebraic expression " which makes no sense. $\endgroup$
    – user64494
    May 4, 2019 at 9:27

2 Answers 2

2
$\begingroup$

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  *)
$\endgroup$
7
  • $\begingroup$ 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$). $\endgroup$
    – user64494
    May 4, 2019 at 14:01
  • $\begingroup$ @user64494 That's obvious. Are you saying the function is not zero? Or are you disagreeing with something else? $\endgroup$
    – Michael E2
    May 4, 2019 at 14:03
  • $\begingroup$ Because $\frac 1 a $ does not belong to the domain of $f$, the substitution x->1/a is incorrect, so its result is unpredictable. $\endgroup$
    – user64494
    May 4, 2019 at 14:07
  • $\begingroup$ 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} $. $\endgroup$
    – user64494
    May 4, 2019 at 14:15
  • $\begingroup$ @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$"? $\endgroup$
    – Michael E2
    May 4, 2019 at 14:47
1
$\begingroup$

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.

$\endgroup$
4
  • 1
    $\begingroup$ Trace and TracePrint can be quite useful in such situations to see how the evaluation progresses through an expression. $\endgroup$
    – Roman
    May 4, 2019 at 13:12
  • $\begingroup$ 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. $\endgroup$
    – user64494
    May 4, 2019 at 14:25
  • $\begingroup$ @user64494, that's what I meant by "not fully equivalent to the input expression". $\endgroup$ May 4, 2019 at 14:49
  • $\begingroup$ Do you answer the unclearly formulated question under consideration? $\endgroup$
    – user64494
    May 4, 2019 at 15:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.