# Identifying Infinity, Indeterminate, etc

I am doing a calculation and sometimes in the middle of the calculation a parameter evaluates to the following

ft = 3/2 (Interval[{-∞, ∞}] -
0.18226983662149658132946008991930705044657150172224622293432. \
(Interval[{Indeterminate, Indeterminate}] +
Interval[{-∞, ∞}]) -
0.050952185949403638635667316344137015057032783368974382857632. \
(Interval[{Indeterminate, Indeterminate}] +
Interval[{-∞, ∞}]));


I am trying to identify the "Infinity" "Interval" "Indeterminate" so I can stop the calculation and warn the user. I do the following

Print[MemberQ[N[uSolz],ComplexInfinity]];
Print[MemberQ[N[uSolz],Infinity]];
Print[MemberQ[N[uSolz],Indeterminate]];
Print[MemberQ[N[uSolz],Indeterminate]];


or

Print[StringMemberQ[ToString[uSolz],"Indeterminate"]]


or I evaluated my function in some points because normally uSolz has r as a variable.

rrange=N[Range[0,2,(0-2)/1000]];
Print[N[uSolz/.r->rrange]];


From above I was hoping to get some infinity etc.

None of them worked for me. Any ideas?

• maybe Not@FreeQ[#, DirectedInfinity[_] | Indeterminate, {0, Infinity}] &@N[uSolz]?
– kglr
Commented Oct 12, 2018 at 12:10
• I'd replace DirectedInfinity[_] with _DirectedInfinity in @kglr's pattern, so that ComplexInfinity is caught as well. Commented Oct 12, 2018 at 12:16
• @J.M. good point. DirectedInfinity[___] works as well but is longer.
– kglr
Commented Oct 12, 2018 at 12:21
• @kglr @ J.M It looks like it is working :) , thank you. Commented Oct 12, 2018 at 12:41

f = Not[FreeQ[#, _DirectedInfinity | Indeterminate, {0, ∞}]]&
f @ ft


True

Note that Infinity, Indeterminate etc. are not numbers:

NumberQ[Infinity]
NumberQ[Indeterminate]
NumberQ[ComplexInfinity]


False

False

False

So, you can define a predicate to identify Interval objects with a non-number element:

badIntervalQ[Interval[a__]] := AnyTrue[Flatten @ a, Not@*NumberQ]


Check:

FreeQ[ft, _Interval?badIntervalQ]


False

meaning that ft contains a bad interval.