Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm running a sum, the elements of which are calculated by calling functions that I wrote. The only issue is, I've implemented this pretty stupid solution where I have 4 or 5 (nested!) if statements to handle cases where mathematica returns Indeterminate when it should be returning "0". What I'm essentially looking for is some kind of "If" statement that returns either 0 if Mathematica returns Indeterminate, and evaluates to something I have implemented already otherwise.

Any ideas? I've tried using combinations of the If/ Check functions, without too much luck.

Summary: I'm trying to write an If statement that checks for Indeterminate values, and returns one of two values. Any ideas?

share|improve this question
Indeterminate is a special head. When you use If, you need to use === or SameQ instead of == or Equal to test if something is Indeterminate. All of this is in the documentation for Indeterminate. – R. M. Sep 23 '12 at 4:43
Btw, welcome to Mathematica.SE! Could you try to invent a more memorable user name? All those userxxxxxs are no fun. – Sjoerd C. de Vries Sep 23 '12 at 7:19

Perhaps you just need a replace operation?

0 / {3, 2, 1, 0}
{0, 0, 0, Indeterminate}
% /. Indeterminate -> 0
{0, 0, 0, 0}
share|improve this answer

If has a 4-argument version in which the fourth argument is returned in cases where the condition yield Indeterminate.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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