python / cpython

The Python programming language
https://www.python.org/
Other
60.55k stars 29.26k forks source link

Add gamma function, error functions and other C99 math.h functions to math module #47616

Closed terryjreedy closed 14 years ago

terryjreedy commented 15 years ago
BPO 3366
Nosy @tim-one, @rhettinger, @terryjreedy, @mdickinson, @ned-deily, @stevendaprano
Files
  • math_private.h: header for erf, erfc, lgamma and tgamma
  • pymath.c.diff
  • mathmodule.c.diff
  • pymath.h.diff
  • test_math.py.diff
  • math.rst.diff
  • mathmodule.diff: patch for erf, erfc, lgamma and gamma
  • pymath.c.diff: erf and gamma patches without math_private.h
  • gamma.patch
  • gamma3.patch: Implementation of math.gamma
  • gamma4.patch
  • gamma5.patch
  • lgamma1.patch
  • gamma-failures.txt
  • pymath.h.diff: Euler constant
  • mathmodule.c.diff: expm1
  • erf.py: error function
  • mathmodule.c.diff
  • erf.patch
  • erf_c.patch: Add erf and erfc functions to math module.
  • expm1.patch
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields: ```python assignee = 'https://github.com/mdickinson' closed_at = created_at = labels = ['type-feature', 'library'] title = 'Add gamma function, error functions and other C99 math.h functions to math module' updated_at = user = 'https://github.com/terryjreedy' ``` bugs.python.org fields: ```python activity = actor = 'mark.dickinson' assignee = 'mark.dickinson' closed = True closed_date = closer = 'mark.dickinson' components = ['Library (Lib)'] creation = creator = 'terry.reedy' dependencies = [] files = ['10955', '10973', '10974', '10975', '10976', '10977', '10982', '11005', '14844', '14927', '14940', '14943', '15008', '15152', '15488', '15489', '15490', '15491', '15539', '15540', '15574'] hgrepos = [] issue_num = 3366 keywords = ['patch', 'needs review'] message_count = 54.0 messages = ['69698', '70106', '70108', '70120', '70125', '70128', '70131', '70232', '70233', '70241', '70262', '70266', '70267', '70270', '70361', '70412', '77075', '92294', '92844', '92928', '92935', '92936', '92939', '92944', '92948', '93228', '93370', '93373', '94165', '94166', '94168', '94169', '94170', '94171', '94172', '94175', '94224', '96108', '96109', '96110', '96111', '96266', '96267', '96268', '96332', '96333', '96485', '96497', '96599', '96600', '97127', '97131', '97133', '97160'] nosy_count = 8.0 nosy_names = ['tim.peters', 'rhettinger', 'terry.reedy', 'mark.dickinson', 'ned.deily', 'stutzbach', 'nirinA', 'steven.daprano'] pr_nums = [] priority = 'normal' resolution = None stage = 'commit review' status = 'closed' superseder = None type = 'enhancement' url = 'https://bugs.python.org/issue3366' versions = ['Python 2.7', 'Python 3.2'] ```

    mdickinson commented 14 years ago

    The last two functions to consider adding are exp2 and log2. Does anyone care about these?

    cfc9f3e0-e33f-4ecd-9ddd-4123842d6c1e commented 14 years ago

    Any time I've ever needed log2(x), log(x)/log(2) was sufficient.

    In Python, exp2(x) can be spelled 2.0**x. What would exp2(x) gain us?

    mdickinson commented 14 years ago

    In Python, exp2(x) can be spelled 2.0**x. What would exp2(x) gain us?

    Not much, I suspect. :)

    I'd expect (but am mostly guessing) exp2(x) to have better accuracy than pow(2.0, x) for some math libraries; I'd further guess that it's somewhat more likely to give exact results for (small) integral x.

    Similarly for log2: log2(n) should be a touch more accurate than log(n)/log(2), and the time you're most likely to notice the difference is when n is an exact power of 2.

    But we've already got the 'bit_length' method for integers, which fills some of the potential uses for log2. So unless there's a feeling that these functions are needed, I'd rather leave them out.

    mdickinson commented 14 years ago

    Will close this unless there's an outcry of support for exp2 and log2. nirinA, if you're still interested in adding the euler constant, please open another issue.