numpy / numpy-financial

Standalone package of the NumPy financial functions
BSD 3-Clause "New" or "Revised" License
340 stars 80 forks source link

BUG: irr function inconsistent behavior on different cpu architecture #131

Open siqi-he opened 1 week ago

siqi-he commented 1 week ago

Describe the issue:

Hi, I noticed that npf.irr function could return different results on different cpus in some cases. The results would match if i run irr function more than once. Please see example below.

Reproduce the code example:

python -c "import numpy_financial as npf; amount = 37155; month_count = 144; monthly_payment = 560; npf.irr([-amount] + [monthly_payment] * int(month_count));  print(npf.irr([-amount] + [monthly_payment] * int(month_count)))"

python -c "import numpy_financial as npf; amount = 37155; month_count = 144; monthly_payment = 560; print(npf.irr([-amount] + [monthly_payment] * int(month_count)))"

Error message:

On aws ec2 6i instance with Intel Ice Lake, I got the following:
0.01258179635558565
0.01258179635558565

On aws ec2 7i instance with Intel Sapphire Rapids, I got the following:
0.01258179635558565
0.006850691458678115

Runtime information:

1.23.5 3.10.14 | packaged by conda-forge | (main, Mar 20 2024, 12:45:18) [GCC 12.3.0]

Context for the issue:

No response

TCYTseven commented 1 week ago

Fixed this in Pull Request 132