Group Abstract Group Abstract

Message Boards Message Boards

0
|
2.9K Views
|
6 Replies
|
6 Total Likes
View groups...
Share
Share this post:

Infinite expression 1/0 encountered when evaluating a non-singular polynomial

Posted 1 year ago

Hey there,

I am relatively new to Mathematica and used it only for basic mathematical manipulations. So I was playing around with Mathematica a little when I encountered the following strange behavior:

I defined a polynomial function, which at first seems to be singular in x=1. When properly writing the function, however, one can easily see that this is not the case since the denominator cancels out nicely. (As a background, the polynomial arises by differentiation of a sum of weighted Chebyshev polynomials, so one can also expect a non-singular polynomial.)

Now trying to evaluate the Polynomial at 1 raises the 'infinite expression 1/0 encountered' error. The only way I was able to evaluate the Polynomial correctly, was by rewriting it, evaluate it at some variable y and then substituting y with 1. Please see the attached Notebook for a minimal working example.

Now, I somehow can understand that the evaluation of the first polynomial fails (I don't think it should, though), but I do not understand how the evaluation of the second polynomial can fail. Why doesn't Mathematica properly evaluate the first polynomial? Expanding and simplifying costs a lot of time (this is just a mwe, the target-polynomial is of degree 50+) and the evaluation workaround is bulky. Is there a better/saver way to implement this functionality?

Glad about any advice, Mathias

6 Replies

Thanks, maybe the cleanest way up to now. I have some doubts about efficiency, but I will dig into this the next days!

Thanks, that seems to somehow 'simplify' the equation at least. But testing it at the example

f[x_]:=Together[x/x]

the direct evaluation at f[0] still is Indeterminate, which now seems really strange to me.

Thank you, that is an excellent minimal example that points exactly to the problem.

Just one more approach:

Limit[f[x], x -> 1]
(* Out:    8 a[2]    *)
POSTED BY: Henrik Schachner

Might want to use Together.

In[3]:= Together[f[x]]

(* Out[3]= 1/4 (1 + x) (a[1] + 2 x a[1] - 2 x^3 a[1] - x^4 a[1] - 
   a[1]^3 - 2 x a[1]^3 + 2 x^3 a[1]^3 + x^4 a[1]^3 + 7 a[2] + 
   4 x a[2] + 6 x^2 a[2] - x^4 a[2] + 3 a[1]^2 a[2] - 
   6 x^2 a[1]^2 a[2] + 3 x^4 a[1]^2 a[2] - 3 a[1] a[2]^2 + 
   6 x a[1] a[2]^2 - 6 x^3 a[1] a[2]^2 + 3 x^4 a[1] a[2]^2 + a[2]^3 - 
   4 x a[2]^3 + 6 x^2 a[2]^3 - 4 x^3 a[2]^3 + x^4 a[2]^3) *)
POSTED BY: Daniel Lichtblau

It is the order of evaluation. Try this simpler example:

f[x_] := x/x
f[0]
f[x] /. x -> 0

If you call f[0], it will replace x with 0 in the expression x/x., giving 0/0, which is Indeterminate.

If you call first f[x], this will simplify to 1, and the replacement of x with 0 will leave the result as 1.

The simplification of expressions gives sometimes rise to this kind of inconsistencies.

POSTED BY: Gianluca Gorni
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard