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.

classification
Title: expm1 missing
Type: enhancement Stage:
Components: Extension Modules Versions: Python 3.1, Python 2.7
process
Status: closed Resolution: duplicate
Dependencies: Superseder: Add gamma function, error functions and other C99 math.h functions to math module
View: 3366
Assigned To: mark.dickinson Nosy List: mark.dickinson, ms
Priority: normal Keywords:

Created on 2008-08-04 22:20 by ms, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (4)
msg70722 - (view) Author: Mike Speciner (ms) Date: 2008-08-04 22:20
The math module contains log1p but is missing expm1 (the inverse of
log1p). These functions are necessary to avoid loss of precision in
floating point calculations, and are part of the C99 standard math library.
msg70723 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2008-08-04 22:44
Mike,

Can you propose an implementation, for those platforms that haven't yet 
caught up with C99?  Something comparable to the implementation of log1p 
in Python/pymath.c would be appropriate.  Ideally, such an 
implementation would:

- be accurate to within a few ulps across the whole domain,
- be not too long, and not too slow
- have a decent chance of working with strange floating-point formats 
(Python doesn't assume IEEE 754)
- handle IEEE 754 values 'correctly' (i.e., as recommended by Annex F to 
the C99 standard)

It's too late to get this into Python 2.6/3.0, but patches aimed at 2.7 
or 3.1 would be welcome.
msg70724 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2008-08-04 23:07
A cheap trick would be to use the identity

  expm1(x) = 2*exp(x/2)*sinh(x/2)

This could also be used in Python as a
workaround, for now.  But I agree that
expm1 should go into the math library.
msg77076 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2008-12-05 21:44
I'm absorbing this issue into issue 3366.
History
Date User Action Args
2022-04-11 14:56:37adminsetgithub: 47751
2008-12-05 21:44:58mark.dickinsonsetstatus: open -> closed
resolution: duplicate
superseder: Add gamma function, error functions and other C99 math.h functions to math module
messages: + msg77076
2008-08-09 15:27:48mark.dickinsonsetpriority: normal
assignee: mark.dickinson
components: + Extension Modules, - None
versions: + Python 3.1, Python 2.7, - Python 3.0
2008-08-04 23:07:06mark.dickinsonsetmessages: + msg70724
2008-08-04 22:44:57mark.dickinsonsetnosy: + mark.dickinson
messages: + msg70723
2008-08-04 22:20:47mscreate