This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Gideon
Recipients Gideon
Date 2021-11-28.17:47:29
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1638121649.37.0.378311866468.issue45917@roundup.psfhosted.org>
In-reply-to
Content
Dear Python Support Team,

I was looking through Python’s list of supported methods in the math module, and I noticed that C99’s exp2 method was not implemented. This method raises 2 to the power of the supplied argument. I understand that it’s pretty trivial to so this in Python using 2**x or math.pow(x, 2), but I think there are a few reasons why we might want to incorporate it:

Uniformity: This method exists most other programming languages and libraries, including numpy.

Consistency: Every math method from C99 except exp2 is in python’s math or cmath module (math.cbrt will be added as of python 3.11).

Triviality: this method is a part of C99 and is also supported by Visual Studio, so it’s very easy to implement. 

Accuracy(?): a libm exp2 is supposedly more accurate than pow(2.0, x), though I don’t really see how this would be the case (See https://bugs.python.org/issue31980)


That said, this method is a little redundant, so I completely understand if this request is rejected

Non-exhaustive list of other languages / libraries that use this method:

Rust: https://docs.rs/libm/0.1.1/libm/fn.exp2.html
Javascript: https://github.com/stdlib-js/math-base-special-exp2
Numpy: https://numpy.org/doc/stable/reference/generated/numpy.exp2.html
C++: https://en.cppreference.com/w/cpp/numeric/math/exp2 (Not authoritative)
Ruby: https://www.rubydoc.info/gems/ruby-mpfi/MPFI%2FMath.exp2

Similar Issues:
https://bugs.python.org/issue44357
https://bugs.python.org/issue31980
History
Date User Action Args
2021-11-28 17:47:29Gideonsetrecipients: + Gideon
2021-11-28 17:47:29Gideonsetmessageid: <1638121649.37.0.378311866468.issue45917@roundup.psfhosted.org>
2021-11-28 17:47:29Gideonlinkissue45917 messages
2021-11-28 17:47:29Gideoncreate