[cfp-interest 3387] Math Functions in Programming Languages Standards
David Hough CFP
pcfp at oakapple.net
Thu Feb 13 15:18:42 PST 2025
Here is a draft of a response to my very long-standing action item for
recommendations to C about C++ midpoint and linear interpolation.
https://754r.ucbtest.org/background/math-functions-languages.txt
Math Functions in Programming Languages Standards
Question:
C++ proposes to standardize midpoint and linear interpolation functions.
Should C follow?
General comments:
Programming language standards are big and getting bigger. It seems likely
that not all standards groups have equal expertise in what functions
applications require.
If they are going to put additional functions in programming language
standards, how do they decide which ones are worthwhile?
Perhaps they should limit themselves to new functions that can be
implemented in a single instruction no more complex than an FMA.
Or to new functions that are the solutions to very simple differential
equations (e.g. exp/sin/cos), and their inverses - especially avoiding new
transcendental functions - note that in floating-point arithmetic,
the results of x**y and kindred functions are always algebraic numbers
rather than transcendental numbers.
LAPACK, or even the BLAS, are very widely used, but that doesn't make them
good candidates for language standardization. There are other groups
better equipped to do that work.
Specific comments:
If I had been present at Creation, I would have advised putting gamma or
lgamma or bessel functions in C. But here they are, and there's little to
be gained by taking them out.
Note that midpoint, in binary, is hardly different from a normal subtraction,
and would easily make a simple machine instruction. But that ease does
not apply to any other radix, 10 or 16 in particular.
That case against linear interpolation is even stronger.
One benefit of standardization is uniformity of syntax. But uniformity of
semantics is even more important, especially for exceptions. But different
application areas have vastly different requirements for exceptions. Perhaps
the semantics are best specified by application-oriented groups rather than
language committees.
Conclusion:
My suggestion for C would be to not standardize midpoint and linear
interpolation, but if it is done, limit the specification to syntax and
just those semantics that all stakeholders can agree on.
More information about the cfp-interest
mailing list