chapel-lang / chapel

a Productive Parallel Programming Language
https://chapel-lang.org
Other
1.79k stars 420 forks source link

Math module - exp and expm1 should indicate they use e in their name #19014

Closed lydia-duncan closed 1 year ago

lydia-duncan commented 2 years ago

My expectation is that exp refers just to exponent. exp2 is 2 to the power of the argument, I think exp should similarly have e in its name, e.g. expE and expEM1 or something.

Michael also pointed out that we should have the documentation for these functions link to e. He also suggested pow, powE, pow2 as alternative names.

Should we rename these functions? What should we rename them to?

damianmoz commented 2 years ago

I cannot see what is achieved by renaming functions which have had the same name for decades. Note that exp in this case does not refer to exponent, but rather exponential. The function ex is strictly the natural exponential function.

The quite rigorous syntax of the set of three pairs of routines defined by the IEEE 754 standard is

exp[B][m1]

where B is a base which defaults to Napier's constant (or e which is sequence A001113 in the OEIS) if B is omitted and can be either 2 or 10 if written explicitly, i.e. exp(), exp2() and exp10(). There are variants of those routine which end with m1 , i.e. expm1(), exp2m1() and exp10m1() which are more accurate under certain conditions.

The naming convention is rigorous and defined by standards and covered in textbooks. Why reinvent the wheel? Those names have been around for decades although those of the form ...m1 only made it into the second release of the IEEE 754 standard in 2008. Also, if I had a student coming to me who did not realize that the function exp(x) involved e, I would be telling that person to go and do a lot more reading.

The most common abbreviation for exponent is expt although EXP_... is used in the C standard for some exponent names. Why that was done is lost in history although I can probably find out.