Skip to content

Conversation

skirpichev
Copy link
Collaborator

@skirpichev skirpichev commented Apr 27, 2023

  • use math.erf, math.erfc, math.gamma
  • use math.atan2
  • use cmath.phase for fp.arg
  • reorganize input handling in e1() and ei()
  • remove unused code in math2.py
  • use constants, e.g. math.inf or math.nan
  • move most constants to the mpmath/ctx_fp.py
  • move mpmath/math2.py -> mpmath/libfp.py, closes Reorganization #211

@skirpichev skirpichev force-pushed the ctx_fp-stdlib branch 2 times, most recently from 0c96db8 to 638d484 Compare May 8, 2023 08:10
@skirpichev skirpichev mentioned this pull request May 8, 2023
@cbm755
Copy link
Contributor

cbm755 commented May 10, 2023

have not tested but reading over the changes, this LGTM

@skirpichev
Copy link
Collaborator Author

skirpichev commented May 10, 2023

There is a test failure for PyPy jobs, see changed doctest. It is due to using a custom erf/erfc implementations in PyPy (CPython uses libm's versions). But I think that CPython's value is better:

Python 3.9.2 (default, Feb 28 2021, 17:03:44) 
[GCC 10.2.1 20210110] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import math
>>> math.erfc(2.5)
0.0004069520174449589
$ pypy3
Python 3.7.10 (7.3.5+dfsg-2+deb11u2, Nov 01 2022, 20:16:36)
[PyPy 7.3.5 with GCC 10.2.1 20210110] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>> import math
>>>> math.erfc(2.5)
0.00040695201744495903
>>>> 
$ wolframscript 
Wolfram Language 13.2.0 Engine for Linux x86 (64-bit)
Copyright 1988-2022 Wolfram Research, Inc.

In[1]:= Erfc[2.5``21]

Out[1]= 0.0004069520174449589

In[2]:= Erfc[2.5``22]

Out[2]= 0.00040695201744495894

In[3]:= Erfc[2.5``25]

Out[3]= 0.00040695201744495893956

Perhaps, alternatively (wrt using ELLIPSIS option) we could use a different argument value, say 0.5...

@skirpichev
Copy link
Collaborator Author

@cbm755 is this better or worse?

@oscarbenjamin
Copy link

Looks good to me.

* use math.erf, math.erfc, math.gamma
* use math.atan2
* use cmath.phase for fp.arg
* reorganize input handling in e1() and ei()
* remove unused code in math2.py
* use constants, e.g. math.inf or math.nan
* move most constants to the mpmath/ctx_fp.py
The PyPy uses a different implementations for erf/erfc, while the
CPython per default uses coming with the libm (which answer is
better for 2.5).  Let's choose an argument value where both
versions do agree.
@skirpichev
Copy link
Collaborator Author

Ok, I did rebase (no changes). Then I'll merge this.

@skirpichev skirpichev merged commit 27bfab2 into mpmath:master May 19, 2023
@skirpichev skirpichev deleted the ctx_fp-stdlib branch May 19, 2023 15:03
@skirpichev skirpichev added this to the 1.4 milestone May 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Reorganization
3 participants