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 terry.reedy
Recipients belopolsky, docs@python, mark.dickinson, rhettinger, serhiy.storchaka, stutzbach, terry.reedy, tim.peters
Date 2017-04-09.19:11:49
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1491765109.76.0.383355573777.issue29956@psf.upfronthosting.co.za>
In-reply-to
Content
To include corner cases, I should have asked 'at least as accurate' rather than 'more accurate'.  It would be a sad libm that had specialized functions worse than pow, since the specialized functions could, at worse, use pow.

For an expert point of view, the reason for math to have the specialized functions is to give access to functions in the libm of the compiler used. A beginner ignorant of such things might wonder whether exp and sqrt are just trivial abbreviations, and if not, which to use.  I believe this question has appeared on python-list.  It definitely has on StackOverflow.

For e**x, there is, for instance,
https://stackoverflow.com/questions/30756983/difference-between-math-exp2-and-math-e2
with this comment "Voting to reopen. There's more going on here than simply "floating-point is inaccurate". In particular, as the two answers explain, there are good reasons to expect exp(x) to be more accurate than e**x. – Mark Dickinson " ;-).

Searching "[python] math.sqrt pow" gets more hits.
https://stackoverflow.com/questions/18965524/exponentiation-in-python-should-i-prefer-operator-instead-of-math-pow-and-m
https://stackoverflow.com/questions/33684948/difference-between-1-2-math-sqrt-and-cmath-sqrt
and multiple questions about relative speed.

So I am inclined to add "This is generally better than math.e ** x and math.pow(e, 0.5)." (for math.exp) and "than x ** 0.5 and math.pow(x, 0.5)" for math.sqrt, and similarly for cmath.sqrt).
History
Date User Action Args
2017-04-09 19:11:49terry.reedysetrecipients: + terry.reedy, tim.peters, rhettinger, mark.dickinson, belopolsky, stutzbach, docs@python, serhiy.storchaka
2017-04-09 19:11:49terry.reedysetmessageid: <1491765109.76.0.383355573777.issue29956@psf.upfronthosting.co.za>
2017-04-09 19:11:49terry.reedylinkissue29956 messages
2017-04-09 19:11:49terry.reedycreate