4.4 Handling numerical errors
By default, an error message is returned whenever calculations return values which are infinite, as in the case of 1/0, or when functions are evaluated outside the domain of parameter space in which they are defined, as in the case of besseli(-1,1). Sometimes this behaviour is desirable: it flags up to the user that a calculation has gone wrong, and exactly what the problem is. At other times, however, these error messages can be undesirable and may lead you to miss more genuine and serious errors buried in their midst.
set numeric errors quiet
Having done this, expressions such as
x = besseli(-1,1)
set numeric errors explicit
Having turned off the display of numerical errors, it may be useful to use the assert command to throw an error message if a calculation has failed in an unrecoverable way that the user really ought to know about:
assert x>0 "Cannot continue with negative x"
The assert command should be followed by an algebraic expression which must be true for execution to continue. If it is false, an error results. Optionally, an error message can be included, as above, to tell the user what the problem is.