[Cfp-interest 2994] about C26 Issue 1

Jim Thomas jaswthomas at sbcglobal.net
Mon Feb 5 09:49:10 PST 2024


Some thoughts related to Issue 1 in https://wiki.edg.com/pub/CFP/WebHome/C26C.HTM ...

Back to the definitions of errors. 7.12.1 says:

… a domain error occurs if and only if an input argument is outside the domain over which the mathematical function is defined. 

and 

… a pole error (also known as a singularity or infinitary) occurs if and only if the mathematical function has an exact infinite result as the finite input argument(s) are approached in the limit (for example, log(0.0)).

Domain and pole errors are defined in terms of mathematical functions. The pole error definition obscures this fact by referring to “an exact infinite result”, though “exact” isn’t applicable to mathematical function results. (Note that  log(0.0) is in program font, which is appropriate: a pole error occurs for the execution of log(0.0) because the mathematical function log(x) has a pole at 0.)

Does the mathematical function’s range include an infinity? The domain error definition doesn’t say, but if an infinity were not included, a domain error would occur for log(0.0). The pole error definition implies the mathematical function’s range does include an infinity, and the parenthetical example says a pole error occurs for log(0.0). 

I think the mathematical functions should have the range of the extended real numbers, i.e. of the real numbers together with infinity. Then poles are at points within the domain, and log(0.0) causes a pole error and not a domain error, as I believe is the general understanding.

Unlike domain and pole errors, range errors are defined in terms of implementation limitations. This seems right, because range errors are about limitations of the approximation, not about the mathematical function.

For some math library functions, it’s may not be clear what the mathematical function is, e.g. atan2, and logb. For pow the mathematical function might appear to be x^y but IEC 60559 defines pow for some cases where x^y is undefined, e.g. pow(0, 0) = 1, thus the mathematical function corresponding to pow is a piecewise function. 

7.12.1 says “The description of each function lists any required domain/pole/range errors”. I think CFP agreed that this means these are the errors that are required to be reported (via errno or exceptions), but his meaning is not clear in the standard. We should consider proposing a clarification.

7.12.1 says the implementation is free to report domain/pole/range errors in other cases, provided the definition of the error fits. Given this, what is the intended meaning of, “a domain/pole/range error may occur” in a function description? It might just note a case that fits the definition of the error for which the implementation may (but is not required to) report the error. Or it might mean the definition fits for some implementations but not for others. Or it might mean that the implementation can determine whether the definition fits. 

An error can't be required unless IEC 60559 allows a corresponding floating-point exception. For example, a non-IEC 60559 implementation might regard atan2(0, 0) to be a domain error. However, IEC 60559 defines the result and does not allow an “invalid” floating-point exception in this case. Thus, IEC 60559 implementations can not be allowed to report atan2(0, 0) as a domain error. 

These are not “easy” issues.

I suggest CFP defer discussion of Issue 1, and first clarify the broader issues.

- Jim Thomas

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.oakapple.net/pipermail/cfp-interest/attachments/20240205/9724b907/attachment.htm>


More information about the Cfp-interest mailing list