Skip to main content

Ultra-accurate and fast FM function evaluator with <4.5e-16 relative error

Project description

AccurPy

Ultra-accurate and fast FM function evaluator with <4.5e-16 relative error (~2x machine epsilon).

Installation

pip install accurpy

Usage

from accurpy import syncF, fm_scaled

# Compute FM(x) * exp(x) - the numerically stable form
result = syncF(1.0)

# Compute FM(x) = exp(-x) * integral of t^(-1/2) * exp(-t) / (1 + t/x) dt
result_scaled = fm_scaled(1.0)

# Works with numpy arrays
import numpy as np
x = np.linspace(0.001, 100, 1000)
y = syncF(x)

Performance

The C extension uses METH_O calling convention with PyFloat_AS_DOUBLE for minimal overhead:

x range syncF(x) time Notes
Small (1e-8) ~38 ns Cube-root expansion
Wide (1.0) ~45 ns Rational approximation
Large (1e10) ~32 ns Asymptotic expansion

Comparable to math.sin (~38 ns) - only ~20 ns above the minimum possible CPython C-extension overhead (~16 ns for extract+create).

Array throughput: ~10 ns/element.

Accuracy

  • Relative error < 4.5e-16 across entire domain (x > 0)
  • Three-region algorithm:
    • Small x (< 1e-7): Cube-root expansion
    • Wide domain (1e-7 to 1e6): 63-segment rational approximation
    • Large x (> 1e6): Asymptotic expansion

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

accurpy-0.2.3.tar.gz (21.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

accurpy-0.2.3-cp313-cp313-win_amd64.whl (36.5 kB view details)

Uploaded CPython 3.13Windows x86-64

File details

Details for the file accurpy-0.2.3.tar.gz.

File metadata

  • Download URL: accurpy-0.2.3.tar.gz
  • Upload date:
  • Size: 21.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for accurpy-0.2.3.tar.gz
Algorithm Hash digest
SHA256 54dfa0512c2fcc731a4ff7a9d10d8cdea3f6dd4b96ec59e4a0866006bb98162c
MD5 ba2658f5af1c18a1ceb24c7e7375271a
BLAKE2b-256 21796ea0dc4251a14eec7cd4782f222910e0c9a320db067bd48294670774b645

See more details on using hashes here.

File details

Details for the file accurpy-0.2.3-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: accurpy-0.2.3-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 36.5 kB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for accurpy-0.2.3-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 2d649c8b058a6ec99010ce7ba371b76ca083ecbec3ffc0245d0e69d2fc718067
MD5 d3ffab85567b8459d910b4f476821a2d
BLAKE2b-256 7c7aad1e21f708c38efb424cdc5f12b9e66dac62c0c92a7ad4316403a5f671aa

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page