Identifying Infinity, Indeterminate, etc
Clash Royale CLAN TAG#URR8PPP
up vote
5
down vote
favorite
I am doing a calculation and sometimes in the middle of the calculation a parameter evaluates to the following
ft = 3/2 (Interval[-âÂÂ, âÂÂ] -
0.182269836621496581329460089919307050446571501722246222934`32.
(Interval[Indeterminate, Indeterminate] +
Interval[-âÂÂ, âÂÂ]) -
0.0509521859494036386356673163441370150570327833689743828576`32.
(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?
pattern-matching
add a comment |Â
up vote
5
down vote
favorite
I am doing a calculation and sometimes in the middle of the calculation a parameter evaluates to the following
ft = 3/2 (Interval[-âÂÂ, âÂÂ] -
0.182269836621496581329460089919307050446571501722246222934`32.
(Interval[Indeterminate, Indeterminate] +
Interval[-âÂÂ, âÂÂ]) -
0.0509521859494036386356673163441370150570327833689743828576`32.
(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?
pattern-matching
2
maybeNot@FreeQ[#, DirectedInfinity[_] | Indeterminate, 0, Infinity] &@N[uSolz]
?
â kglr
4 hours ago
2
I'd replaceDirectedInfinity[_]
with_DirectedInfinity
in @kglr's pattern, so thatComplexInfinity
is caught as well.
â J. M. is somewhat okay.â¦
4 hours ago
@J.M. good point.DirectedInfinity[___]
works as well but is longer.
â kglr
4 hours ago
@kglr @ J.M It looks like it is working :) , thank you.
â Erdem
3 hours ago
add a comment |Â
up vote
5
down vote
favorite
up vote
5
down vote
favorite
I am doing a calculation and sometimes in the middle of the calculation a parameter evaluates to the following
ft = 3/2 (Interval[-âÂÂ, âÂÂ] -
0.182269836621496581329460089919307050446571501722246222934`32.
(Interval[Indeterminate, Indeterminate] +
Interval[-âÂÂ, âÂÂ]) -
0.0509521859494036386356673163441370150570327833689743828576`32.
(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?
pattern-matching
I am doing a calculation and sometimes in the middle of the calculation a parameter evaluates to the following
ft = 3/2 (Interval[-âÂÂ, âÂÂ] -
0.182269836621496581329460089919307050446571501722246222934`32.
(Interval[Indeterminate, Indeterminate] +
Interval[-âÂÂ, âÂÂ]) -
0.0509521859494036386356673163441370150570327833689743828576`32.
(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?
pattern-matching
pattern-matching
edited 2 mins ago
Carl Woll
60.5k279155
60.5k279155
asked 4 hours ago
Erdem
418210
418210
2
maybeNot@FreeQ[#, DirectedInfinity[_] | Indeterminate, 0, Infinity] &@N[uSolz]
?
â kglr
4 hours ago
2
I'd replaceDirectedInfinity[_]
with_DirectedInfinity
in @kglr's pattern, so thatComplexInfinity
is caught as well.
â J. M. is somewhat okay.â¦
4 hours ago
@J.M. good point.DirectedInfinity[___]
works as well but is longer.
â kglr
4 hours ago
@kglr @ J.M It looks like it is working :) , thank you.
â Erdem
3 hours ago
add a comment |Â
2
maybeNot@FreeQ[#, DirectedInfinity[_] | Indeterminate, 0, Infinity] &@N[uSolz]
?
â kglr
4 hours ago
2
I'd replaceDirectedInfinity[_]
with_DirectedInfinity
in @kglr's pattern, so thatComplexInfinity
is caught as well.
â J. M. is somewhat okay.â¦
4 hours ago
@J.M. good point.DirectedInfinity[___]
works as well but is longer.
â kglr
4 hours ago
@kglr @ J.M It looks like it is working :) , thank you.
â Erdem
3 hours ago
2
2
maybe
Not@FreeQ[#, DirectedInfinity[_] | Indeterminate, 0, Infinity] &@N[uSolz]
?â kglr
4 hours ago
maybe
Not@FreeQ[#, DirectedInfinity[_] | Indeterminate, 0, Infinity] &@N[uSolz]
?â kglr
4 hours ago
2
2
I'd replace
DirectedInfinity[_]
with _DirectedInfinity
in @kglr's pattern, so that ComplexInfinity
is caught as well.â J. M. is somewhat okay.â¦
4 hours ago
I'd replace
DirectedInfinity[_]
with _DirectedInfinity
in @kglr's pattern, so that ComplexInfinity
is caught as well.â J. M. is somewhat okay.â¦
4 hours ago
@J.M. good point.
DirectedInfinity[___]
works as well but is longer.â kglr
4 hours ago
@J.M. good point.
DirectedInfinity[___]
works as well but is longer.â kglr
4 hours ago
@kglr @ J.M It looks like it is working :) , thank you.
â Erdem
3 hours ago
@kglr @ J.M It looks like it is working :) , thank you.
â Erdem
3 hours ago
add a comment |Â
2 Answers
2
active
oldest
votes
up vote
3
down vote
f = Not[FreeQ[#, _DirectedInfinity | Indeterminate, 0, âÂÂ]]&
f @ ft
True
add a comment |Â
up vote
0
down vote
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.
add a comment |Â
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
3
down vote
f = Not[FreeQ[#, _DirectedInfinity | Indeterminate, 0, âÂÂ]]&
f @ ft
True
add a comment |Â
up vote
3
down vote
f = Not[FreeQ[#, _DirectedInfinity | Indeterminate, 0, âÂÂ]]&
f @ ft
True
add a comment |Â
up vote
3
down vote
up vote
3
down vote
f = Not[FreeQ[#, _DirectedInfinity | Indeterminate, 0, âÂÂ]]&
f @ ft
True
f = Not[FreeQ[#, _DirectedInfinity | Indeterminate, 0, âÂÂ]]&
f @ ft
True
answered 3 hours ago
kglr
165k8188388
165k8188388
add a comment |Â
add a comment |Â
up vote
0
down vote
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.
add a comment |Â
up vote
0
down vote
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.
add a comment |Â
up vote
0
down vote
up vote
0
down vote
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.
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.
answered 3 mins ago
Carl Woll
60.5k279155
60.5k279155
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f183681%2fidentifying-infinity-indeterminate-etc%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
2
maybe
Not@FreeQ[#, DirectedInfinity[_] | Indeterminate, 0, Infinity] &@N[uSolz]
?â kglr
4 hours ago
2
I'd replace
DirectedInfinity[_]
with_DirectedInfinity
in @kglr's pattern, so thatComplexInfinity
is caught as well.â J. M. is somewhat okay.â¦
4 hours ago
@J.M. good point.
DirectedInfinity[___]
works as well but is longer.â kglr
4 hours ago
@kglr @ J.M It looks like it is working :) , thank you.
â Erdem
3 hours ago