Compare commits

...

1147 Commits

Author SHA1 Message Date
Sergey B Kirpichev 5fa2b9c793 Merge pull request #1160 from skirpichev/misc
Misc fixes
2026-08-22 03:23:58 +03:00
Sergey B Kirpichev d3812b1194 Amend bc96a889 2026-08-21 08:25:46 +03:00
Sergey B Kirpichev d8c4597a7d Merge pull request #1159 from skirpichev/misc
v1.5.0a1
2026-08-21 05:28:28 +03:00
Sergey B Kirpichev f3751eb87f Update CHANGES 2026-08-21 05:15:07 +03:00
Sergey B Kirpichev bcc67d3e55 Enable cancel-in-progress in CI 2026-08-21 04:37:44 +03:00
Sergey B Kirpichev 27a1fe7f6d Merge pull request #1115 from skirpichev/shortest-repr/1028
Use shortest decimal representations for str/repr
2026-08-21 04:34:47 +03:00
Ayush Baranwal ffcaef924a Add fft()/invfft() functions for DFT calculation (#1152)
Addresses #707

Implements the Radix-2 Cooley-Tukey Fast Fourier Transform (FFT) algorithm to
compute the discrete fourier transform and inverse discrete fourier transform of a signal.

Inputs are currently restricted to lengths of powers of 2.
2026-08-21 04:23:58 +03:00
Sergey B Kirpichev bc96a88926 Apply naive algorithm for huge exponents 2026-08-21 04:14:33 +03:00
Sergey B Kirpichev 0d2af59d5d Speedup exponent computation 2026-08-20 12:46:40 +03:00
Sergey B Kirpichev 70b722800f Use shortest decimal representations for str/repr
Was:
```
$ python -m mpmath
>>> 0.1
0.10000000000000001
```

Now:
```
$ python -m mpmath --shortest-str
>>> 0.1
0.1
```

Closes #1028
2026-08-20 12:46:40 +03:00
Sergey B Kirpichev d271b8312a Merge pull request #1157 from HeskethGD/omega-period-optimize-pr
Optimize conversion from Weierstrass invariants to half-periods
2026-08-19 04:31:41 +03:00
HeskethGD 49c7eeb43c Normalize Weierstrass parameter conversions 2026-08-16 16:01:54 +03:00
Sergey B Kirpichev bf6459d6be Merge pull request #1155 from userfypp/codex/fix-cplot-points-379
Fix cplot points rounding (#379)
2026-08-16 02:30:58 +03:00
HeskethGD f72b86ca17 Optimize Weierstrass period conversion 2026-08-15 20:09:07 +03:00
alexfyp 0abd5de3f0 Fix cplot points rounding (#379) 2026-08-11 15:10:35 +02:00
Sergey B Kirpichev 017cc473fb Merge pull request #1154 from skirpichev/document-pretty_dps
Document pretty_dps context's option
2026-08-06 06:32:14 +03:00
Sergey B Kirpichev bfaf6a7a31 Merge pull request #1153 from skirpichev/use-n-rounding-in-repr/1129
Use round_nearest in repr/str and as default mpf's rounding mode
2026-08-06 06:31:37 +03:00
Sergey B Kirpichev 24538751aa Document pretty_dps context's option
This amends a14901da.
2026-08-06 05:07:36 +03:00
Sergey B Kirpichev 4a3af8ef2b Use round_nearest in repr/str and as default mpf's rounding mode
Better alternative to #1137 (which was partially reverted).

Closes #1129
2026-08-05 09:47:43 +03:00
Sergey B Kirpichev e5142170db Merge pull request #1127 from skirpichev/use-explicit-kwargs/1056
Use explicit kwargs in public API, where possible
2026-08-05 04:32:15 +03:00
Sergey B Kirpichev fb69943530 Use explicit kwargs in public API, where possible
Following functions kept:
```pycon
>>> import inspect
... with_args = []
... with_kwargs = []
... for n in dir(mpmath):
...     m = getattr(mpmath, n)
...     try:
...         s = inspect.signature(m)
...     except:
...         continue
...     if any(_.kind == inspect._ParameterKind.VAR_POSITIONAL for _ in s.parameters.values()):
...         for name in s.parameters:
...             if s.parameters[name].kind == inspect._ParameterKind.VAR_POSITIONAL and name == 'args':
...                 with_args.append(n)
...                 break
...     if any(_.kind == inspect._ParameterKind.VAR_KEYWORD for _ in s.parameters.values()):
...         with_kwargs.append(n)
... print(with_args)
... print(with_kwargs)
...
['arange', 'ellipe', 'ellippi', 'linspace', 'matrix', 'ones', 'timing', 'zeros']
['multiplicity', 'timing']
```

We need support for multiple signatures in the first case.  In the
second - it's impossible to implement these functions without kwargs.

Closes #1056
2026-08-04 06:40:53 +03:00
Sanjay Santhanam c90e242741 Avoid spurious overflow in fp gammaprod (#1150)
* Avoid spurious overflow in fp gammaprod

fp.binomial(1100, 1) raised OverflowError even though the result is
exactly 1100: gammaprod multiplies the individual gamma values, and
gamma(1101) exceeds the double range although the quotient does not.

Fall back to evaluating the regular numerator/denominator in log space
when a term overflows, so the quotient is computed whenever it is
representable. Genuinely out-of-range results, such as
fp.binomial(1100, 550), still raise OverflowError.

Closes #493
2026-08-03 07:09:31 +03:00
Sergey B Kirpichev 255d98ff98 Merge pull request #1151 from mpmath/dependabot/github_actions/actions-deps-696b649f44
Bump actions/setup-python from 6 to 7 in the actions-deps group
2026-08-02 03:08:49 +03:00
dependabot[bot] da14fb3a42 Bump actions/setup-python from 6 to 7 in the actions-deps group
Bumps the actions-deps group with 1 update: [actions/setup-python](https://github.com/actions/setup-python).


Updates `actions/setup-python` from 6 to 7
- [Release notes](https://github.com/actions/setup-python/releases)
- [Commits](https://github.com/actions/setup-python/compare/v6...v7)

---
updated-dependencies:
- dependency-name: actions/setup-python
  dependency-version: '7'
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: actions-deps
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-08-01 22:55:26 +00:00
catalin-hanga 4f58dcd947 Added 2 new expceptions to Rosser's Rule (#1148)
closes #1147
2026-07-31 11:21:22 +03:00
Sergey B Kirpichev 3e73240699 Merge pull request #1146 from HeskethGD/g2-g3-omega-from
test / linter (push) Failing after 1s
test / coverage (push) Failing after 0s
test / docs (push) Failing after 0s
Publish on PyPI / Build distributions (push) Has been cancelled
test / frozen-version (push) Has been cancelled
Publish on PyPI / Publish distributions to PyPI (push) Has been cancelled
test / tests (false, false, 3.10) (push) Has been cancelled
test / tests (false, false, 3.11) (push) Has been cancelled
test / tests (false, false, 3.12) (push) Has been cancelled
test / tests (false, false, 3.13) (push) Has been cancelled
test / tests (false, false, 3.14) (push) Has been cancelled
test / tests (false, false, 3.14t) (push) Has been cancelled
test / tests (false, false, 3.15) (push) Has been cancelled
test / tests (false, false, 3.15t) (push) Has been cancelled
test / tests (true, pypy3.11) (push) Has been cancelled
test / tests (true, 3.x) (push) Has been cancelled
Standardise Weierstrass from param functions
2026-07-27 03:54:00 +03:00
Sergey B Kirpichev 460c289f90 Update repo link (git -> https)
Publish on PyPI / Build distributions (push) Has been cancelled
test / frozen-version (push) Has been cancelled
Publish on PyPI / Publish distributions to PyPI (push) Has been cancelled
test / tests (false, false, 3.10) (push) Has been cancelled
test / tests (false, false, 3.11) (push) Has been cancelled
test / tests (false, false, 3.12) (push) Has been cancelled
test / tests (false, false, 3.13) (push) Has been cancelled
test / tests (false, false, 3.14) (push) Has been cancelled
test / tests (false, false, 3.14t) (push) Has been cancelled
test / tests (false, false, 3.15) (push) Has been cancelled
test / tests (false, false, 3.15t) (push) Has been cancelled
test / tests (true, pypy3.11) (push) Has been cancelled
test / coverage (push) Failing after 1s
test / docs (push) Failing after 0s
test / linter (push) Failing after 1s
test / tests (true, 3.x) (push) Has been cancelled
Closes #1145
2026-07-26 03:07:07 +03:00
HeskethGD 1f3e9bf593 Rename Weierstrass parameter converters 2026-07-25 17:32:21 +01:00
HeskethGD 534dd479f0 Expand Weierstrass parameter conversions 2026-07-25 17:32:06 +01:00
Sergey B Kirpichev 3481440ce5 Merge pull request #1141 from HeskethGD/simplified-omega
test / coverage (push) Failing after 0s
test / docs (push) Failing after 0s
test / linter (push) Failing after 1s
Publish on PyPI / Build distributions (push) Has been cancelled
test / frozen-version (push) Has been cancelled
Publish on PyPI / Publish distributions to PyPI (push) Has been cancelled
test / tests (false, false, 3.10) (push) Has been cancelled
test / tests (false, false, 3.11) (push) Has been cancelled
test / tests (false, false, 3.12) (push) Has been cancelled
test / tests (false, false, 3.13) (push) Has been cancelled
test / tests (false, false, 3.14) (push) Has been cancelled
test / tests (false, false, 3.14t) (push) Has been cancelled
test / tests (false, false, 3.15) (push) Has been cancelled
test / tests (false, false, 3.15t) (push) Has been cancelled
test / tests (true, pypy3.11) (push) Has been cancelled
test / tests (true, 3.x) (push) Has been cancelled
Simplify and standardise weierhalfperiods
2026-07-25 06:04:39 +03:00
Sergey B Kirpichev 28e36ca652 Merge pull request #1144 from skirpichev/ulp
test / linter (push) Failing after 0s
test / coverage (push) Failing after 0s
test / docs (push) Failing after 1s
Publish on PyPI / Build distributions (push) Has been cancelled
test / frozen-version (push) Has been cancelled
test / tests (true, 3.x) (push) Has been cancelled
Publish on PyPI / Publish distributions to PyPI (push) Has been cancelled
test / tests (false, false, 3.14t) (push) Has been cancelled
test / tests (false, false, 3.15) (push) Has been cancelled
test / tests (false, false, 3.10) (push) Has been cancelled
test / tests (false, false, 3.11) (push) Has been cancelled
test / tests (false, false, 3.12) (push) Has been cancelled
test / tests (false, false, 3.13) (push) Has been cancelled
test / tests (false, false, 3.14) (push) Has been cancelled
test / tests (false, false, 3.15t) (push) Has been cancelled
test / tests (true, pypy3.11) (push) Has been cancelled
Add ulp(), see #1009
2026-07-24 13:37:18 +03:00
Sergey B Kirpichev b9fd43cc42 Add ulp(), see #1009 2026-07-24 01:31:54 +03:00
Sergey B Kirpichev 8d0190ad6d Merge pull request #1143 from skirpichev/fix-1142
test / docs (push) Failing after 0s
test / coverage (push) Failing after 0s
test / linter (push) Failing after 0s
Publish on PyPI / Build distributions (push) Has been cancelled
Publish on PyPI / Publish distributions to PyPI (push) Has been cancelled
test / tests (false, false, 3.10) (push) Has been cancelled
test / tests (false, false, 3.11) (push) Has been cancelled
test / tests (false, false, 3.12) (push) Has been cancelled
test / tests (false, false, 3.13) (push) Has been cancelled
test / tests (false, false, 3.14) (push) Has been cancelled
test / tests (false, false, 3.14t) (push) Has been cancelled
test / tests (false, false, 3.15) (push) Has been cancelled
test / tests (false, false, 3.15t) (push) Has been cancelled
test / tests (true, pypy3.11) (push) Has been cancelled
test / frozen-version (push) Has been cancelled
test / tests (true, 3.x) (push) Has been cancelled
Correct definitions for spherical Bessel functions
2026-07-23 04:04:44 +03:00
Sergey B Kirpichev afdb228884 Correct definitions for spherical Bessel functions
Closes #1142
2026-07-23 03:24:33 +03:00
Vincent Gao 2de2d509ec Widen to_str's digit window so str/nstr rounds near-boundary values correctly (#1139)
to_str extracted only dps+10 digits, narrower than format_scientific and
format_fixed which cover the whole mantissa.  A value just above a decimal
boundary was then extracted as "...99999" one ULP low, so directed rounding
through str/nstr fell one ULP short of the 'e' format and the exact value.
Widen the base-10 window to match the sibling formatters.

Also fixed test for from_str(), coming from 30e8001e
2026-07-22 00:05:32 +03:00
HeskethGD 55aefa6f82 Simplified and standardised weierhalfperiods 2026-07-21 16:45:46 +01:00
Sergey B Kirpichev 7eb6f23063 Merge pull request #1138 from skirpichev/fix-1135
Use CoW pattern to manage constant_memo() cache
2026-07-19 15:06:33 +03:00
Sergey B Kirpichev 65dca57ca7 Use CoW pattern to manage constant_memo() cache
Closes #1135
2026-07-19 10:28:41 +03:00
Sergey B Kirpichev 6309ea0550 Merge pull request #1137 from skirpichev/fix-repr-roundtrip/1129
Use reversed rounding mode for repr
2026-07-19 07:16:33 +03:00
Sergey B Kirpichev d30d632c39 Use reversed rounding mode for repr
Closes #1129
2026-07-19 04:59:27 +03:00
Sergey B Kirpichev d8c9fd2ea3 Refactor round_digits()
* add exponent argument
* pass original number
* make inexact flag local
2026-07-19 04:07:42 +03:00
Vincent Gao 101a8379a8 Fix last-digit rounding of the "f" format type (#1132)
format_fixed() extracts a handful of guard digits and lets round_digits()
decide, so a nonzero remainder lying past them was invisible: directed and
nearest rounding truncated the last digit instead of rounding it up.  The
value is dyadic, so its exactness at the extracted digits is decidable;
pass that as a inexact flag and round on it.  The "e" path and MPFR already
round these correctly.

Values whose leading digit falls past the last requested place skipped
round_digits() altogether and always printed zeros, even under rounding
away from zero; round them to one unit in the last place in that case.

Closes #1131

Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
2026-07-18 07:33:23 +03:00
Sergey B Kirpichev ead1a61d09 Merge pull request #1134 from skirpichev/fix-1130
Better document None return value of the pslq()
2026-07-16 10:25:38 +03:00
Sergey B Kirpichev 9e85fabc1d Better document None return value of the pslq()
Closes #1130
2026-07-16 09:15:25 +03:00
Sergey B Kirpichev 6d356df80f Merge pull request #1117 from HeskethGD/enhance-kleinj-tau
Add kleinjinv and support g and omega in taufrom
2026-07-13 20:41:50 +03:00
HeskethGD b747a30db1 Support Weierstrass data in elliptic parameter helpers 2026-07-13 16:11:02 +01:00
HeskethGD 6f2a553551 Add inverse Klein j-function 2026-07-13 16:08:46 +01:00
Sergey B Kirpichev 52c1546a0c Merge pull request #1124 from skirpichev/explicit-kwargs-for-libmp-funcs
Change signature for wrapped libmp's functions
2026-07-11 09:30:56 +03:00
Sergey B Kirpichev 573549a39f Merge pull request #1126 from skirpichev/fix-docs-ci
Fix docs CI job
2026-07-11 09:26:26 +03:00
Sergey B Kirpichev ed63e50a8a Fix weierp/weierpinv() docstrings
Closes #1125
2026-07-11 09:18:32 +03:00
Sergey B Kirpichev a2333847a8 Fix docs CI job 2026-07-11 09:16:26 +03:00
Sergey B Kirpichev c328efcd37 Change signature for wrapped libmp's functions
See #1056
2026-07-11 07:17:59 +03:00
Apoorv Darshan 86978167e1 Close leftover figure in plot/cplot/splot on error (#1123)
Fixes #1007
2026-07-10 04:57:23 +03:00
Warren Weckesser 8d21910bba Implement the modified spherical bessel functions spherical_in() and spherical_kn(). (#1121) 2026-07-08 04:13:53 +03:00
Sergey B Kirpichev 76d91a4fa5 Merge pull request #1120 from skirpichev/theta-apply-qperiodicy
Use quasi-periodicity property (DLMF, §20.2(ii)) to compute jtheta()
2026-07-07 07:44:49 +03:00
Sergey B Kirpichev cc198d4ecd Use quasi-periodicity property (DLMF, §20.2(ii)) to compute jtheta()
*_theta2/3a() helpers now not needed
2026-07-05 09:24:26 +03:00
Sergey B Kirpichev 5688722737 Merge pull request #1119 from mpmath/dependabot/github_actions/actions-deps-640176b5ab
Bump actions/checkout from 6 to 7 in the actions-deps group
2026-07-02 04:10:57 +03:00
Sergey B Kirpichev 40cf9ba085 Merge pull request #1118 from skirpichev/fix-repr_dps/1116
Fix repr_dps() to produce a correct estimate
2026-07-02 04:07:27 +03:00
dependabot[bot] b20d7c530a Bump actions/checkout from 6 to 7 in the actions-deps group
Bumps the actions-deps group with 1 update: [actions/checkout](https://github.com/actions/checkout).


Updates `actions/checkout` from 6 to 7
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v6...v7)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: '7'
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: actions-deps
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-07-01 22:55:58 +00:00
Sergey B Kirpichev f12743f60f Remove dead code in secondzeta_exp_term() 2026-07-01 08:31:40 +03:00
Sergey B Kirpichev c44efa2ca2 Remove py2 remnants (cast round() to int) 2026-07-01 08:08:19 +03:00
Sergey B Kirpichev 6f1fbd275d Fix repr_dps() to produce a correct estimate
That should work at lest for 32-bit integers.  Though, I think that
the repr/str representation loses all sence for precisions much
less than that ;-)

Closes #1116
2026-07-01 05:36:13 +03:00
Graham Hesketh aa205a2821 Add Weierstrass elliptic functions (#1113)
* Weierstrass $\wp$: `weierp`
* inverse Weierstrass $\wp$: `weierpinv`
* derivative of Weierstrass $\wp$: `weierpprime`
* Weierstrass zeta: `weierzeta`
* Weierstrass sigma: `weiersigma`

Also adds parameter conversion functions:

* Weierstrass invariants $g_2, g_3$: `weierinvariants`
* half-periods $\omega_1, \omega_2$: `weierhalfperiods`

The idea for this PR was inspired by the `pyweierstrass` package by @stla / Stéphane Laurent:

* https://pyweierstrass.readthedocs.io/en/latest/
* https://github.com/stla/pyweierstrass

The code implementation in this PR is different to that in `pyweierstrass` although both packages derive from similar well known mathematical formulas. Differences between `pyweierstrass` and this `mpmath` implementation include but are not limited to:

* function names adapted to `mpmath` conventions;
* tau normalization: `tau` specifies the normalized period lattice `(1, tau)`, corresponding to half-periods `(1/2, tau/2)`; this differs from `pyweierstrass`, where `tau` denotes half-periods `(1, tau)`;
* support for disambiguating inverse values of Weierstrass $\wp$ by optionally passing the corresponding derivative value;
* internal refactoring of helper functions for integration with `mpmath`.

Dedicated to Stéphane Laurent who opened the original PR to request this functionality in `mpmath` and whose `pyweierstrass` package provided great utility to the author of this PR in the years since.

Co-authored-by: Stéphane Laurent <stla@users.noreply.github.com>

Closes #612
2026-06-30 03:43:58 +03:00
Sergey B Kirpichev a686b903ae Merge pull request #1111 from skirpichev/jtheta-modular/930
Use generic modular transformations to compute jtheta() with |q| ~ 1
2026-06-29 14:12:08 +03:00
Sergey B Kirpichev 2a2de4e7ca Drop mp.THETA_Q_LIM 2026-06-29 03:19:33 +03:00
Sergey B Kirpichev 8e31d10120 Use generic modular transformations to compute jtheta() with |q| ~ 1
See https://fungrim.org/topic/Lattice_transformations_for_Jacobi_theta_functions/#General_modular_transformations

Closes #930

Co-Authored-By: Jam Balaya <jambalaya.pyoncafe@outlook.jp>
2026-06-29 03:19:33 +03:00
Sergey B Kirpichev 90e1cff769 Reapply "Revert testing of GMP-backends for PyPy, see #1013"
This reverts commit 390972e250.
2026-06-26 13:38:01 +03:00
Vincent Gao ba2a0da3a1 Fix chebyfit IndexError when N <= 0 (#1114)
chebyfit(f, interval, N) support only positive integer N.  Add an explicit ValueError.
2026-06-26 05:13:49 +03:00
Sergey B Kirpichev c4f9187805 Merge pull request #1021 from skirpichev/test-pypy-on-gmpy/1013
Re-enable testing with GMP backends on PyPy
2026-06-26 04:50:05 +03:00
Sergey B Kirpichev 390972e250 Revert "Revert testing of GMP-backends for PyPy, see #1013"
This reverts commit f580874a54.

Closes #1013
2026-06-25 03:13:21 +03:00
Sergey B Kirpichev 1626936cca Merge pull request #1112 from skirpichev/misc
Misc fixes
2026-06-25 03:06:45 +03:00
Sergey B Kirpichev 1aff951d93 Fix fp.hypsum() to exit if ZeroDivisionError occurs and t==0
Closes #496
2026-06-24 16:19:06 +03:00
Sergey B Kirpichev 92f61841bf Merge pull request #1110 from skirpichev/prepare-v1.5.0a0
test / linter (push) Failing after 1s
test / coverage (push) Failing after 0s
test / docs (push) Failing after 0s
Publish on PyPI / Build distributions (push) Has been cancelled
Publish on PyPI / Publish distributions to PyPI (push) Has been cancelled
test / frozen-version (push) Has been cancelled
test / tests (false, false, 3.10) (push) Has been cancelled
test / tests (false, false, 3.11) (push) Has been cancelled
test / tests (false, false, 3.12) (push) Has been cancelled
test / tests (false, false, 3.13) (push) Has been cancelled
test / tests (false, false, 3.14) (push) Has been cancelled
test / tests (false, false, 3.14t) (push) Has been cancelled
test / tests (false, false, 3.15) (push) Has been cancelled
test / tests (false, false, 3.15t) (push) Has been cancelled
test / tests (true, pypy3.11) (push) Has been cancelled
test / tests (true, 3.x) (push) Has been cancelled
Prepare v1.5.0a0
2026-06-24 04:43:20 +03:00
Sergey B Kirpichev bf99017677 Allow gmpy2 for CPython v3.15 2026-06-24 04:27:00 +03:00
Sergey B Kirpichev 5a4116a13e Update CHANGES 2026-06-24 04:18:33 +03:00
Sergey B Kirpichev b5e38772b1 Merge pull request #1109 from skirpichev/fix-integral-path-for-lerchphi/252
Change integral path of the lerchphi() to use Laplace transform integral
2026-06-24 03:43:34 +03:00
Sergey B Kirpichev 085f181126 Change integral path of the lerchphi() to use Laplace transform integral
Current formula ignores some constraints: https://dlmf.nist.gov/25.14#E6

Implementation follows to lerch_hankel():
https://fredrikj.net/blog/2022/02/computing-the-lerch-transcendent/#section6

Closes #252
2026-06-23 13:17:01 +03:00
Sergey B Kirpichev 60cf796714 Merge pull request #1107 from skirpichev/fix-1104
Improve fixed-precision computation paths for jtheta()
2026-06-23 08:11:34 +03:00
Sergey B Kirpichev 3f3d3ec9a3 Merge pull request #1108 from skirpichev/add-jacobi_symbol
Add jacobi_symbol() to libintmath
2026-06-23 08:01:22 +03:00
Sergey B Kirpichev 1d89343973 Add jacobi_symbol() to libintmath 2026-06-23 07:16:42 +03:00
Sergey B Kirpichev 9e890f67cd Drop _jacobi_theta2() 2026-06-23 04:58:49 +03:00
Sergey B Kirpichev 1cfd36f49e Drop _jacobi_theta3() 2026-06-23 04:58:49 +03:00
Sergey B Kirpichev 0fe9033f18 Use prec kwarg for cos_sin in theta helpers 2026-06-23 04:58:49 +03:00
Sergey B Kirpichev c8a17b495d Amend dca2abd6 2026-06-23 04:58:49 +03:00
Sergey B Kirpichev 3e6e7967ad Reorganize fixed-precision computations for theta3
θ₃(z) ~ 1 + 2q¹cos(2z) + 2q⁴cos(4z) + ..., and we
are in |Im(z)| < |Re(log(q))|/2 domain.

To avoid severe cancellation we compute in fixed-point
only s ~ 2(cos(2z) + q³ cos(4z) + ...), then
return 1 + s*q.

Closes #1104
2026-06-23 04:58:48 +03:00
Sergey B Kirpichev 5e683847c7 Fix test_compatibility()
Avoid using of private numpy API
2026-06-23 03:42:46 +03:00
Sergey B Kirpichev 6dfd359ed6 Merge pull request #1106 from skirpichev/misc
Misc fixes
2026-06-21 12:39:33 +03:00
Sergey B Kirpichev 7a1aaff95a Add debug info to random tests in mpmath/tests/test_elliptic.py
Also some cleanup for assert statements and comments
2026-06-21 12:16:06 +03:00
Sergey B Kirpichev dca2abd6ca Cleanup jtheta()
* normalize result
* use extraprec context manager
* add error message
2026-06-21 12:16:06 +03:00
Sergey B Kirpichev a8a614c5f0 Drop _djtheta() helper method 2026-06-21 11:14:17 +03:00
Sergey B Kirpichev e002cb4488 Allow python-gmp for CPython v3.15 2026-06-21 10:59:32 +03:00
Sergey B Kirpichev b62c4173d1 Support CPython v3.15 2026-06-20 09:10:21 +03:00
Sergey B Kirpichev 12e7e74251 Fix test_sn_cn_dn_identities()
Closes #1105
2026-06-20 09:10:21 +03:00
Sergey B Kirpichev 11a5afe7b6 Remove --durations=20 from default pytest options 2026-06-20 07:01:58 +03:00
Ayush Baranwal a2e0351345 Add Brent root-finding algorithm (#1103)
Closes #1095
2026-06-19 03:31:16 +03:00
Vincent Gao 29c496bf14 Fix gegenbauer() failing to converge for odd integer n at z=0
Used parity identity:
https://functions.wolfram.com/Polynomials/GegenbauerC3/04/02/01/

Closes #1077.
2026-06-18 17:37:29 +03:00
Sergey B Kirpichev e45f046a02 Merge pull request #1100 from skirpichev/lerchphi-series/1099
Implement direct series for lerchphi() base case with |z| < 0.5
2026-06-18 06:12:47 +03:00
Sergey B Kirpichev d742930573 Implement direct series for lerchphi() base case with |z| < 1
Closes #1099
2026-06-18 05:55:12 +03:00
Sergey B Kirpichev 9b71ea0595 Merge pull request #1102 from skirpichev/misc
Misc fixes
2026-06-18 05:34:42 +03:00
Sergey B Kirpichev f736ab6096 Drop _jacobi_theta2a/3a() 2026-06-17 12:18:28 +03:00
Sergey B Kirpichev 41243c5438 Tune hypothesis settings (max_examples for default/ci profiles) 2026-06-17 11:22:37 +03:00
Sergey B Kirpichev b854af8d3e Unify jtheta() computations for n=1,2 and n=3,4 2026-06-17 11:22:27 +03:00
Sergey B Kirpichev 90684c4405 Correct exception message for THETA_Q_LIM
Also unify entry points for jtheta/_djtheta

Co-Authored-By: Jam Balaya <jambalaya.pyoncafe@outlook.jp>
2026-06-17 11:21:33 +03:00
Sergey B Kirpichev 3d2aa3ea17 Merge pull request #1098 from skirpichev/ai-policy/1090
Add AI-related policy
2026-06-10 00:57:26 +03:00
Sergey B Kirpichev 97a091279d Add AI-related policy
Closes #1090
2026-06-09 03:49:25 +03:00
Sergey B Kirpichev 6d10972d64 Revert "Set default solver for findroot() dynamically"
This reverts commit f25a56f132.
2026-06-09 01:46:26 +03:00
Sergey B Kirpichev e3dbcd0dd5 Merge pull request #1096 from skirpichev/misc
Misc fixes
2026-06-08 05:28:47 +03:00
Sergey B Kirpichev f25a56f132 Set default solver for findroot() dynamically
Closes #1097
2026-06-07 05:31:56 +03:00
Sergey B Kirpichev 429c1d5ec2 Set dynamic maxsteps value for the bisect method
Closes #285
Closes #339
2026-06-07 05:31:56 +03:00
Sergey B Kirpichev bce4dfb5b4 Correct interval update for Ridder's method
Closes #1094
2026-06-07 05:31:54 +03:00
Ayush Baranwal 44ad9908cc Add ModAB rootfinding algorithm (#1093)
closes #1075
2026-06-07 04:30:24 +03:00
Ayush Baranwal e10416f997 Raise ValueError when same sign at interval boundaries in bisection rootfinding algorithm (#1092) 2026-06-02 11:12:23 +03:00
Sergey B Kirpichev fcb99d97a4 Make CONTRIBUTING.rst more visible 2026-06-02 10:18:37 +03:00
Sergey B Kirpichev 35a1e33f02 Fix typo and function names for sin/cospi() 2026-05-28 07:27:04 +03:00
Sergey B Kirpichev 16d5fb332c Merge pull request #1091 from skirpichev/misc
Misc fixes
2026-05-26 08:39:00 +03:00
Sergey B Kirpichev db21709e9a Amend README.rst with 1.4.1 release 2026-05-26 08:18:30 +03:00
Sergey B Kirpichev 52e0daaaeb Drop private alias round_fast 2026-05-26 07:57:20 +03:00
Sergey B Kirpichev 44859bf6cd Change default rounding for private mpf/mpc_expj/jpi() 2026-05-26 07:57:20 +03:00
Sergey B Kirpichev 34691c49f8 Change default rounding mode for private formatting helpers 2026-05-26 07:57:20 +03:00
Sergey B Kirpichev f7579c0a0d Merge pull request #1089 from skirpichev/restrict-libmp-exports/704
Restrict libmp exports to public API
2026-05-26 04:53:45 +03:00
Sergey B Kirpichev 939efcdd88 Merge pull request #1088 from skirpichev/fix-mpf_hypot/1011
Add extra precision for summation in mpf_hypot()
2026-05-25 14:51:54 +03:00
Sergey B Kirpichev aa5cd5a9bf Add coverage tests 2026-05-25 08:31:19 +03:00
Sergey B Kirpichev 0e1bd9496d Restrict libmp exports to public API
This is following namespace:
```
{'BACKEND', 'ComplexResult', 'MPZ', 'MPZ_ONE', 'NoConvergence',
 'catalan_fixed', 'dps_to_prec', 'euler_fixed', 'fhalf', 'finf',
 'fnan', 'fninf', 'fnone', 'fone', 'from_float', 'from_int', 'from_man_exp',
 'from_rational', 'from_str', 'fzero', 'giant_steps', 'ifac', 'ifib',
 'int_types', 'isqrt', 'mpc_abs', 'mpc_exp', 'mpc_pow', 'mpc_pow_int',
 'mpc_pow_mpf', 'mpc_sqrt', 'mpf_abs', 'mpf_add', 'mpf_atan', 'mpf_atan2',
 'mpf_bernoulli', 'mpf_ceil', 'mpf_cmp', 'mpf_cos', 'mpf_cosh_sinh', 'mpf_div',
 'mpf_e', 'mpf_eq', 'mpf_exp', 'mpf_floor', 'mpf_ge', 'mpf_gt', 'mpf_le',
 'mpf_log', 'mpf_lt', 'mpf_mod', 'mpf_mul', 'mpf_neg', 'mpf_pi', 'mpf_pow',
 'mpf_pow_int', 'mpf_shift', 'mpf_sign', 'mpf_sin', 'mpf_sqrt', 'mpf_sub',
 'mpf_tan', 'normalize', 'phi_fixed', 'prec_to_dps', 'repr_dps',
 'round_nearest', 'sqrtrem', 'to_float', 'to_int', 'to_man_exp', 'to_rational',
 'to_str'}
```

Closes #704
2026-05-25 08:31:19 +03:00
Sergey B Kirpichev d1e52ed28d Adapt doctests
Was:
```pycon
>>> A = mp.matrix([[3, -1, 2], [2, 5, -5], [-2, -3, 7]])
>>> Q, R = mp.schur(A)
>>> mp.norm(Q.T*A*Q-R, inf)
1.8166878507717441e-15
```

Now:
```pycon
>>> A = mp.matrix([[3, -1, 2], [2, 5, -5], [-2, -3, 7]])
>>> Q, R = mp.schur(A)
>>> mp.norm(Q.T*A*Q-R, inf)
1.3322676295501878e-15
```
2026-05-25 04:05:28 +03:00
Sergey B Kirpichev b06b1f51ce Add extra precision for summation in mpf_hypot()
Also, respect rounding option.

Closes #1011
2026-05-25 03:32:24 +03:00
Sergey B Kirpichev e90a592c7a Merge pull request #1087 from skirpichev/adjust-to_float-docs/1085
Clarify to_float() docstring
2026-05-25 02:40:43 +03:00
Sergey B Kirpichev 1eb70ed3d8 Clarify to_float() docstring
Second paragraph rephrased to:
> If the magnitude of *rounded* number is too large to represent as
> a regular float, it will be converted to infinity.

Closes #1085
2026-05-24 05:50:52 +03:00
Sergey B Kirpichev 41981f868a Merge pull request #1086 from skirpichev/update-CHANGES
Misc fixes
2026-05-23 05:16:14 +03:00
Sergey B Kirpichev 7d00f0aaa5 Fix typo in fadd() docstring 2026-05-23 04:43:14 +03:00
Sergey B Kirpichev a5edf2e3e5 Track new release cycle 2026-05-23 04:41:31 +03:00
Sergey B Kirpichev a1a6db90f2 Add v1.4.1 release notes to the master branch 2026-05-23 04:41:31 +03:00
Sergey B Kirpichev cd8722ecbb Merge pull request #1082 from skirpichev/fix-to_float-for-subnormals/1078
Correct to_float() conversion for subnormals
2026-05-21 05:35:43 +03:00
Jam Balaya b5a075fa53 Fix qr_solve() failure on well-conditioned matrices with zero pivot (#1083)
* Fix qr_solve() failure on well-conditioned matrices with zero pivot

In householder(), the sign convention
    p[j] = -sign(Re(A[j,j])) * sqrt(s)
collapses to zero when A[j,j] is exactly zero, because ctx.sign(0) == 0.
A zero p[j] makes kappa = 1/(s - p[j]*A[j,j]) = 1/s instead of the
correct 2/||v||**2, corrupting the Householder reflection. The damage
propagates to subsequent columns and eventually trips the
"matrix is numerically singular" guard.

Default sign to ctx.one when A[j,j] is zero (matching LAPACK's dlarfg
convention) so the reflection is computed correctly. The existing
singularity check is left in place to catch genuinely zero column
slices.

Fixes #983.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-19 03:02:53 +03:00
Sergey B Kirpichev 87cfbc42a8 Correct to_float() conversion for subnormals
Closes #1078
2026-05-18 07:46:12 +03:00
Sergey B Kirpichev fbf61435bf Merge pull request #1081 from skirpichev/fix-frexp/1080
Support special numbers in mpf_frexp() like math.frexp()
2026-05-15 03:43:59 +03:00
Sergey B Kirpichev 5393b8d55e Support special numbers in mpf_frexp() like math.frexp()
Closes #1080
2026-05-14 06:10:42 +03:00
Sergey B Kirpichev d84dc68b9d Merge pull request #1079 from skirpichev/rounding-refine-docs/1076
Improve documentation about rounding in the mp context
2026-05-13 08:31:12 +03:00
Sergey B Kirpichev eefbdcb6ad Improve documentation about rounding in the mp context
See #1076

Also (small optimization) unify _normalize and normalize.
2026-05-13 07:55:29 +03:00
Sergey B Kirpichev 3a09694b91 Merge pull request #1074 from skirpichev/opt-trailing/1073
Speedup removal trailing zeros in _normalize/from_man_exp()
2026-04-20 02:32:41 +03:00
Sergey B Kirpichev 63304aee63 Add coverage test for _normalize (man == 1 and bc != 1 case) 2026-04-19 06:27:38 +03:00
Sergey B Kirpichev 8a965fe43b Speedup removal trailing zeros in _normalize/from_man_exp()
| Benchmark      | ref     | patch                   |
|----------------|:-------:|:-----------------------:|
| 2              | 404 ns  | 398 ns: 1.01x faster    |
| 2**3           | 403 ns  | 398 ns: 1.01x faster    |
| 2**10          | 1.96 us | 1.91 us: 1.03x faster   |
| 2**100         | 6.21 us | 2.52 us: 2.47x faster   |
| 2**10000       | 1.04 ms | 5.90 us: 175.48x faster |
| Geometric mean | (ref)   | 2.78x faster            |

Benchmark hidden because not significant (1): 2**10000 + 1

$ cat bench.py
import pyperf
from mpmath.libmp import from_int
runner = pyperf.Runner()
for s in ['2', '2**3', '2**10', '2**100',
          '2**10000', '2**10000 + 1']:
    i = eval(s)
    runner.bench_func(s, from_int, i)

Closes #1073

Co-authored-by: Fredrik Johansson <fredrik.johansson@gmail.com>
2026-04-19 06:27:32 +03:00
Sergey B Kirpichev 6e3d54ef7e Merge pull request #1072 from skirpichev/fix-root-sig/1067
Fix signature of root()
2026-04-17 15:36:13 +03:00
Sergey B Kirpichev 4118cfd0db Fix signature of root()
Closes #1067
2026-04-17 05:42:03 +03:00
Sergey B Kirpichev 3cbeab5ca3 Merge pull request #1071 from skirpichev/test-on-3.15
Test on CPython 3.15 (no GMP)
2026-04-03 11:34:11 +03:00
Sergey B Kirpichev f9822f0954 Test on CPython 3.15 (no GMP)
DeprecationWarning's are filtered out in pyexpect-enabled tests,
see pexpect/pexpect#827.
2026-04-03 11:11:36 +03:00
Sergey B Kirpichev 09178c95b3 Merge pull request #1070 from skirpichev/wa-1046-v2
Amend 1108318e (restrict fix to CPython < 3.14)
2026-03-31 05:34:00 +03:00
Sergey B Kirpichev 527d9d228c Amend 1108318e (restrict fix to CPython < 3.14)
Closes #1046
2026-03-31 05:11:56 +03:00
Doug Torrance 7b40a40cc6 Add executable bit to test_version_frozen.sh (#1066)
This fixes the "script-not-executable" warning in the Debian package.
2026-03-15 23:26:08 +03:00
Sergey B Kirpichev f8a7f426e4 Merge pull request #1061 from skirpichev/wa-for-s390x/1046
Add a workaround for test on s390x
2026-03-11 15:14:50 +03:00
Tim M f98636edf6 Added Moore-Penrose pseudoinverse. (#1030) 2026-03-10 18:37:22 +03:00
Sergey B Kirpichev 73ce23d164 Merge pull request #1063 from skirpichev/revert-backport-action
Revert "Add backport action"
2026-03-09 04:11:57 +03:00
Sergey B Kirpichev 5d48d2abd9 Revert "Add backport action"
This reverts commit 319703eafd.
2026-03-08 04:52:53 +03:00
Sergey B Kirpichev 1108318e0f Add a workaround for test on s390x
Closes #1046
2026-03-07 04:33:02 +03:00
flurin4 45f5adbb37 Test frozen package version (#1055)
Add bash script to test package version in a frozen application version and a separate CI job to run it.  Closes #1044.

Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
2026-03-07 04:32:29 +03:00
Sergey B Kirpichev 893bb431aa Merge pull request #1057 from skirpichev/drop-deprecated1
Remove deprecated behavior
2026-03-07 04:18:42 +03:00
Sergey B Kirpichev 8ffd139b16 Merge pull request #1059 from skirpichev/misc
Misc fixes
2026-03-07 04:17:26 +03:00
Sergey B Kirpichev c9c3946a9b Adapt test for a "wrong" tuple for mpf constructor 2026-03-07 03:39:34 +03:00
Sergey B Kirpichev 4b84174154 Fix typo in mpc_fibonacci() 2026-03-07 03:30:49 +03:00
Sergey B Kirpichev 3952417cd6 Ignore bc field of mpf's in few tests 2026-03-07 03:14:23 +03:00
Sergey B Kirpichev 22bbe9ad4c Amend 5ac8dcda 2026-03-07 03:01:50 +03:00
Sergey B Kirpichev 718a67cb8e Add 'import mpmath' to default imports in CLI 2026-03-06 06:04:10 +03:00
Sergey B Kirpichev 6665df00dd Correct fp._convert_param() to properly handle real and complex types
Remember, that the gmpy2 backend returns mpfr and mpc types
for mixed-mode arithmetics, when one operand is mpz or mpq.

Examples:

    >>> mpz(1) + 0.1
    mpfr('1.1000000000000001')
    >>> mpz(1) + 1j
    mpc('1.0+1.0j')

Also, mpfr type returned for true division of mpz's.
2026-03-06 05:58:10 +03:00
Sergey B Kirpichev 801a2e6955 Use ctx.isnpint() 2026-03-06 05:01:56 +03:00
Sergey B Kirpichev 3a454f6643 Use asc=True per default for polynomial functions 2026-03-04 07:28:50 +03:00
Sergey B Kirpichev ca0f67d9ab Use signed=True per default in to_man_exp() 2026-03-04 07:28:50 +03:00
Sergey B Kirpichev 82e0a49593 Drop DeprecationWarning for force_type kwarg for matrix()
(Note that kwargs now aren't used.)
2026-03-04 07:28:50 +03:00
Sergey B Kirpichev 81204d1105 Drop deprecated to/from_pickable() functions 2026-03-04 07:28:50 +03:00
Sergey B Kirpichev 754c073e7d Drop deprecated bitcount() function 2026-03-04 07:28:49 +03:00
Sergey B Kirpichev 3ba4132a93 Drop deprecated mp.mpnumeric 2026-03-04 07:28:49 +03:00
Sergey B Kirpichev 485fe73586 Drop deprecated fp.is_special() 2026-03-04 07:28:49 +03:00
Sergey B Kirpichev 60de9789bf Keep forever deprecated aliases for mpc/mpf_log() 2026-03-04 07:28:49 +03:00
Sergey B Kirpichev 6bc4fe86f3 Cleanup conftest.py 2026-03-04 07:28:49 +03:00
Sergey B Kirpichev cd25f9b536 Drop deprecated rational module 2026-03-04 07:28:49 +03:00
Sergey B Kirpichev 8f3e715b1e Drop deprecated math2 module 2026-03-04 07:28:49 +03:00
Sergey B Kirpichev b7728d8dbd Merge pull request #1058 from skirpichev/drop-py3.9
Drop support for CPython 3.9
2026-03-04 07:28:05 +03:00
Sergey B Kirpichev 9677a2a939 Amend docstring for round_digits() 2026-03-04 07:23:41 +03:00
Sergey B Kirpichev 2f6a5d52f3 Drop support for CPython 3.9
(Following https://github.com/sympy/sympy/pull/28816)
2026-03-04 07:14:17 +03:00
Sergey B Kirpichev 0669eb773f Merge pull request #1054 from skirpichev/update-dependabot-cfg
Improve dependabot settings
2026-03-02 13:17:31 +03:00
Sergey B Kirpichev e33d20e34b Merge pull request #1048 from skirpichev/file-version/1044
Use version_file option of setuptools-scm to keep version info
2026-03-02 12:58:28 +03:00
Sergey B Kirpichev 163096b16f Improve dependabot settings
* group multiple updates
* forbid auto rebase to reduce cost of CI (Use `@dependabot rebase` manually instead.)
2026-03-02 09:05:43 +03:00
Sergey B Kirpichev cf2ca665b4 Merge pull request #1051 from mpmath/dependabot/github_actions/actions/download-artifact-8
Bump actions/download-artifact from 7 to 8
2026-03-02 03:01:11 +03:00
Sergey B Kirpichev 14802e5d83 Merge pull request #1052 from mpmath/dependabot/github_actions/actions/upload-artifact-7
Bump actions/upload-artifact from 6 to 7
2026-03-02 03:00:47 +03:00
dependabot[bot] a0a3e580f3 Bump actions/upload-artifact from 6 to 7
Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 6 to 7.
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](https://github.com/actions/upload-artifact/compare/v6...v7)

---
updated-dependencies:
- dependency-name: actions/upload-artifact
  dependency-version: '7'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-03-01 22:57:12 +00:00
dependabot[bot] 3e345d62e1 Bump actions/download-artifact from 7 to 8
Bumps [actions/download-artifact](https://github.com/actions/download-artifact) from 7 to 8.
- [Release notes](https://github.com/actions/download-artifact/releases)
- [Commits](https://github.com/actions/download-artifact/compare/v7...v8)

---
updated-dependencies:
- dependency-name: actions/download-artifact
  dependency-version: '8'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-03-01 22:57:07 +00:00
Sergey B Kirpichev fee75dd985 Merge pull request #1049 from d-torrance/ctypes-sprintf
Set argtypes for sprintf from ctypes
2026-02-28 22:43:16 +03:00
Doug Torrance d74dff7e48 Set argtypes for sprintf from ctypes
Needed on some architectures (see the "Calling variadic functions" in
the ctypes documentation).
2026-02-28 14:11:34 -05:00
Sergey B Kirpichev ed57d4034d Use version_file option of setuptools-scm to keep version info
Closes #1044
2026-02-28 14:06:47 +03:00
Sergey B Kirpichev f3e9cf0706 Update CHANGES (free-threading support)
test / docs (push) Failing after 0s
test / linter (push) Failing after 0s
test / tests (false, false, 3.14t) (push) Has been skipped
test / coverage (push) Failing after 0s
test / tests (false, false, 3.10) (push) Has been skipped
test / tests (false, false, 3.11) (push) Has been skipped
test / tests (false, false, 3.12) (push) Has been skipped
test / tests (false, false, 3.13) (push) Has been skipped
test / tests (false, false, 3.9) (push) Has been skipped
test / tests (false, false, 3.13t) (push) Has been skipped
test / tests (false, false, 3.14) (push) Has been skipped
test / tests (true, pypy3.11) (push) Has been skipped
test / tests (true, 3.x) (push) Has been skipped
Publish on PyPI / Build distributions (push) Has been cancelled
Publish on PyPI / Publish distributions to PyPI (push) Has been cancelled
2026-02-23 06:22:10 +03:00
Sergey B Kirpichev 8a01b18638 Merge pull request #1032 from skirpichev/release-v1.4
v1.4.0
2026-02-23 05:29:18 +03:00
Sergey B Kirpichev acd4b569d4 Update CHANGES 2026-02-23 05:10:51 +03:00
Sergey B Kirpichev 2933f42ad5 Merge branch 'master' into release-v1.4 2026-02-23 04:26:21 +03:00
Sergey B Kirpichev 711d3c3681 Merge pull request #1043 from skirpichev/revert-949
Revert "Add isspecial() method for mp/fp contexts, deprecate isnormal()"
2026-02-23 04:25:43 +03:00
Sergey B Kirpichev 7cf16b7828 Revert "Add isspecial() method for mp/fp contexts, deprecate isnormal()"
This reverts commit e6aa3b46b1.

Subnormals are properly handled by fp.isnormal().  Deprecate
fp.is_special() method.

Fixes #946
2026-02-23 04:08:07 +03:00
Sergey B Kirpichev 34cc1f8147 Update CHANGES 2026-02-22 14:09:07 +03:00
Sergey B Kirpichev 1e0dc7b307 Merge branch 'master' into release-v1.4 2026-02-22 13:56:05 +03:00
Sergey B Kirpichev c7128a6ac5 Merge pull request #1041 from skirpichev/fix-459
polylog(n, nan) -> nan
2026-02-22 13:55:04 +03:00
Sergey B Kirpichev 81034e8648 Merge pull request #1042 from skirpichev/backport-action
Add backport action
2026-02-22 09:36:36 +03:00
Sergey B Kirpichev fa0da05a63 Merge pull request #1040 from skirpichev/cli-no-int-limits
Add option --int-limits for CLI
2026-02-22 09:32:51 +03:00
Sergey B Kirpichev 319703eafd Add backport action
Like for gmpy2/python-gmp
2026-02-22 08:56:41 +03:00
Sergey B Kirpichev 951a7303db And update Release history 2026-02-22 08:42:21 +03:00
Sergey B Kirpichev aed6aecdcd Fix year in conf.py 2026-02-22 08:40:58 +03:00
Sergey B Kirpichev a9f1273e68 Update year and version in CITATION.bib 2026-02-22 08:40:28 +03:00
Sergey B Kirpichev d7b9ddb23c polylog(n, nan) -> nan
closes #459
2026-02-22 08:28:04 +03:00
Sergey B Kirpichev 3c8119eeb2 Use pretty-printing in det() docstring 2026-02-22 08:08:10 +03:00
Sergey B Kirpichev 7c3252b14c Add option --int-limits for CLI
This enables *default* Python mechanism for integer string
conversion length limitation:
https://docs.python.org/3/library/stdtypes.html#integer-string-conversion-length-limitation

For the mpmath CLI it will be *off* by default.  Usually, it doesn't
matter, as these limits not affect the gmpy2/gmp backends and working
with mpmath's types (mpf/mpc).  Though, sometimes you want to play with
integers in the mpmath console and these limits are really annoying.

I consider this as a bugfix, despite it adds a new option.
2026-02-22 08:01:03 +03:00
Sergey B Kirpichev e95bf2a22a Fix some found formatting issues with docs 2026-02-22 07:42:46 +03:00
Sergey B Kirpichev 5348705040 Add workaround for sphinx-contrib/autoprogram#76 2026-02-22 06:09:51 +03:00
Sergey B Kirpichev b6b535bc72 Drop OpenSUSE note (looks outdated) 2026-02-22 05:18:47 +03:00
Sergey B Kirpichev 454ee97a83 Merge branch 'master' into release-v1.4 2026-02-22 04:44:37 +03:00
Sergey B Kirpichev e631d38cd5 Merge pull request #1039 from skirpichev/fix-545
Use erfc(z) to compute erf(z) with re(z) of large magnitude
2026-02-22 03:19:53 +03:00
Sergey B Kirpichev 0b9622a737 Polish CHANGES entry 2026-02-22 02:20:07 +03:00
Sergey B Kirpichev 932ed68c1f Use pytest.skip() in test_axes() 2026-02-21 16:19:22 +03:00
Sergey B Kirpichev 4478a0e33d Use 3.x instead of hardcoded CPython versions in CI 2026-02-21 16:19:22 +03:00
Sergey B Kirpichev 3d84b6f851 Skip installing gmpy2 deps (binary wheels are available) 2026-02-21 16:19:22 +03:00
Sergey B Kirpichev 612a34fbca Simplify gmp deps 2026-02-21 16:19:22 +03:00
Sergey B Kirpichev dcd282eb77 Require setuptools-scm>=8 2026-02-21 16:19:21 +03:00
Sergey B Kirpichev c5437d880b Get rid off debug print's 2026-02-21 16:19:17 +03:00
Sergey B Kirpichev c4176127b0 Use erfc(z) to compute erf(z) with re(z) of large magnitude
closes #545
2026-02-21 15:45:34 +03:00
Sergey B Kirpichev 3af3a60584 Update CHANGES 2026-02-21 10:40:09 +03:00
Sergey B Kirpichev ccb21aa6b4 Merge pull request #1038 from skirpichev/fix-486
Properly handle nan's elliprj()
2026-02-21 06:16:37 +03:00
Sergey B Kirpichev c8e1d276c7 Merge pull request #1017 from baranwalayush/fix/logm_zero_matrix_bug
Fix #1002: Raise ValueError when zero matrix is passed to logm()
2026-02-21 06:14:46 +03:00
Sergey B Kirpichev 69f9e55489 Properly handle nan's elliprj()
Closes #486
2026-02-21 05:40:37 +03:00
Sergey B Kirpichev 34f6e5700a Merge pull request #1037 from skirpichev/fix-1033
Fix special caze for +inf in polylog_continuation()
2026-02-21 04:01:31 +03:00
Sergey B Kirpichev d94ac5eeb3 Fix special caze for +inf in polylog_continuation()
See https://functions.wolfram.com/ZetaFunctionsandPolylogarithms/PolyLog/17/02/01/01/0008/

Closes #1033
2026-02-21 03:39:53 +03:00
Sergey B Kirpichev a1addfbc59 Merge pull request #1036 from skirpichev/fix-1035
Amend beb5029
2026-02-21 02:10:24 +03:00
Sergey B Kirpichev 90ccd8c40e Amend beb5029
Closes #1035
2026-02-21 01:50:50 +03:00
Sergey B Kirpichev dc207275a8 Merge pull request #1034 from cbm755/polylog_inf
polylog: z to positive infinity should return nan
2026-02-21 00:42:38 +03:00
Colin B. Macdonald 2aad193ce0 polylog: z to positive infinity should return nan
Fixes #1033.
2026-02-19 22:10:14 -08:00
Sergey B Kirpichev 1dfa0143f9 Merge pull request #1031 from skirpichev/demos-tests
Add tests for demo scripts
2026-02-19 22:32:36 +03:00
Sergey B Kirpichev eefdb4d0c4 Add tests for demo scripts
Closes #1029
2026-02-19 16:17:27 +03:00
Sergey B Kirpichev bb6cf209f4 Merge pull request #1026 from skirpichev/misc
test / coverage (push) Failing after 0s
test / docs (push) Failing after 0s
test / linter (push) Failing after 0s
test / tests (false, false, 3.14t) (push) Has been skipped
test / tests (false, false, 3.10) (push) Has been skipped
test / tests (false, false, 3.11) (push) Has been skipped
test / tests (false, false, 3.12) (push) Has been skipped
test / tests (false, false, 3.13) (push) Has been skipped
test / tests (false, false, 3.13t) (push) Has been skipped
test / tests (false, false, 3.14) (push) Has been skipped
test / tests (false, false, 3.9) (push) Has been skipped
test / tests (true, pypy3.11) (push) Has been skipped
test / tests (true, 3.14) (push) Has been skipped
Publish on PyPI / Build distributions (push) Has been cancelled
Publish on PyPI / Publish distributions to PyPI (push) Has been cancelled
Misc fixes
2026-02-08 07:02:14 +03:00
Sergey B Kirpichev c35b4d3b6d Require python-gmp>=0.5 2026-02-08 03:22:13 +03:00
Sergey B Kirpichev 012368a1d2 Update gmpy2 deps 2026-02-08 03:21:47 +03:00
Sergey B Kirpichev f3edc81705 Document python-gmp usage 2026-02-01 04:18:39 +03:00
Sergey B Kirpichev bfe0ffdb52 Change behavior of 'b' formatting type to mimic 'a'
This behavior is compatible with the gmpy2.

Closes #1027
2026-02-01 04:03:19 +03:00
Sergey B Kirpichev bd46aacf5d Correct mpc.__format__() docstring 2026-01-21 04:34:23 +03:00
Sergey B Kirpichev 6dbea12523 Merge pull request #1024 from mpmath/dependabot/github_actions/actions/checkout-6
Bump actions/checkout from 5 to 6
2026-01-02 02:19:57 +03:00
Sergey B Kirpichev 8def1a9e8e Merge pull request #1023 from mpmath/dependabot/github_actions/actions/upload-artifact-6
Bump actions/upload-artifact from 5 to 6
2026-01-02 01:48:25 +03:00
Sergey B Kirpichev 7cc4f6a022 Merge pull request #1022 from mpmath/dependabot/github_actions/actions/download-artifact-7
Bump actions/download-artifact from 6 to 7
2026-01-02 01:48:04 +03:00
dependabot[bot] bdba15bb79 Bump actions/checkout from 5 to 6
Bumps [actions/checkout](https://github.com/actions/checkout) from 5 to 6.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v5...v6)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: '6'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-01-01 22:21:25 +00:00
dependabot[bot] b474c9f60a Bump actions/upload-artifact from 5 to 6
Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 5 to 6.
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](https://github.com/actions/upload-artifact/compare/v5...v6)

---
updated-dependencies:
- dependency-name: actions/upload-artifact
  dependency-version: '6'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-01-01 22:21:18 +00:00
dependabot[bot] efd6d4ac4f Bump actions/download-artifact from 6 to 7
Bumps [actions/download-artifact](https://github.com/actions/download-artifact) from 6 to 7.
- [Release notes](https://github.com/actions/download-artifact/releases)
- [Commits](https://github.com/actions/download-artifact/compare/v6...v7)

---
updated-dependencies:
- dependency-name: actions/download-artifact
  dependency-version: '7'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-01-01 22:21:13 +00:00
Sergey B Kirpichev ffda440b4d Update copyright
test / linter (push) Failing after 0s
test / coverage (push) Failing after 0s
test / tests (false, false, 3.10) (push) Has been skipped
test / tests (false, false, 3.11) (push) Has been skipped
test / tests (false, false, 3.12) (push) Has been skipped
test / tests (false, false, 3.13) (push) Has been skipped
test / tests (false, false, 3.13t) (push) Has been skipped
test / tests (false, false, 3.14) (push) Has been skipped
test / docs (push) Failing after 0s
test / tests (false, false, 3.14t) (push) Has been skipped
test / tests (false, false, 3.9) (push) Has been skipped
test / tests (true, pypy3.11) (push) Has been skipped
test / tests (true, 3.14) (push) Has been skipped
Publish on PyPI / Build distributions (push) Has been cancelled
Publish on PyPI / Publish distributions to PyPI (push) Has been cancelled
2026-01-01 09:57:52 +03:00
Sergey B Kirpichev 510d3c8617 Don't require double_fac/fib from backend 2025-12-29 11:38:41 +03:00
Sergey B Kirpichev 4b35ad317f Quickly filter warning in CI for CPython v3.9
@pytest.mark.filterwarnings("ignore:datetime.datetime.utc.*:DeprecationWarning")
    def test_axes():
        try:
>           import matplotlib

mpmath/tests/test_visualization.py:15:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/opt/hostedtoolcache/Python/3.9.25/x64/lib/python3.9/site-packages/matplotlib/__init__.py:970: in <module>
    rcParamsDefault = _rc_params_in_file(
/opt/hostedtoolcache/Python/3.9.25/x64/lib/python3.9/site-packages/matplotlib/__init__.py:904: in _rc_params_in_file
    config[key] = val  # try to convert to proper type or raise
/opt/hostedtoolcache/Python/3.9.25/x64/lib/python3.9/site-packages/matplotlib/__init__.py:739: in __setitem__
    cval = self.validate[key](val)
/opt/hostedtoolcache/Python/3.9.25/x64/lib/python3.9/site-packages/matplotlib/rcsetup.py:427: in validate_font_properties
    parse_fontconfig_pattern(s)
/opt/hostedtoolcache/Python/3.9.25/x64/lib/python3.9/site-packages/matplotlib/_fontconfig_pattern.py:83: in parse_fontconfig_pattern
    parser = _make_fontconfig_parser()
/opt/hostedtoolcache/Python/3.9.25/x64/lib/python3.9/site-packages/matplotlib/_fontconfig_pattern.py:64: in _make_fontconfig_parser
    prop = Group((name + Suppress("=") + comma_separated(value)) | oneOf(_CONSTANTS))
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

args = ({'black': ('weight', 'black'), 'bold': ('weight', 'bold'), 'book': ('weight', 'book'), 'condensed': ('width', 'condensed'), ...},)
kwargs = {}

    @wraps(fn)
    def _inner(*args, **kwargs):
>       warnings.warn(
            f"{compat_name!r} deprecated - use {fn.__name__!r}",
            DeprecationWarning,
            stacklevel=2,
        )
E       DeprecationWarning: 'oneOf' deprecated - use 'one_of'

/opt/hostedtoolcache/Python/3.9.25/x64/lib/python3.9/site-packages/pyparsing/util.py:445: DeprecationWarning
2025-12-23 10:49:38 +03:00
Sergey B Kirpichev 4ae8195ad6 Freeze gmpy2 deps 2025-12-02 05:04:11 +03:00
Sergey B Kirpichev f444dac155 Use CPython v3.13 for coverage tests (v3.14 has no gmpy2 wheels) 2025-11-02 02:26:15 +03:00
Sergey B Kirpichev 13446c8004 Merge pull request #1018 from mpmath/dependabot/github_actions/actions/upload-artifact-5
Bump actions/upload-artifact from 4 to 5
2025-11-02 01:55:03 +03:00
Sergey B Kirpichev 2c2b8ed90b Merge pull request #1019 from mpmath/dependabot/github_actions/actions/download-artifact-6
Bump actions/download-artifact from 5 to 6
2025-11-02 01:54:40 +03:00
dependabot[bot] 2af313f354 Bump actions/download-artifact from 5 to 6
Bumps [actions/download-artifact](https://github.com/actions/download-artifact) from 5 to 6.
- [Release notes](https://github.com/actions/download-artifact/releases)
- [Commits](https://github.com/actions/download-artifact/compare/v5...v6)

---
updated-dependencies:
- dependency-name: actions/download-artifact
  dependency-version: '6'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-11-01 22:22:40 +00:00
dependabot[bot] 031616be33 Bump actions/upload-artifact from 4 to 5
Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 4 to 5.
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](https://github.com/actions/upload-artifact/compare/v4...v5)

---
updated-dependencies:
- dependency-name: actions/upload-artifact
  dependency-version: '5'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-11-01 22:22:37 +00:00
Sergey B Kirpichev 2fe20a3c83 Amend 6c51c9d8 (restore default context's mp.pretty behavior) 2025-10-29 09:25:05 +03:00
baranwalayush e8aa7a0bd9 Fix infinite loop in case of zero matrix in logm function 2025-10-22 15:14:30 +05:30
Sergey B Kirpichev 4a1475d7ec Amend 85fb02ab
test / tests (false, false, 3.13t) (push) Has been skipped
test / docs (push) Failing after 0s
test / linter (push) Failing after 0s
test / coverage (push) Failing after 0s
test / tests (false, false, 3.10) (push) Has been skipped
test / tests (false, false, 3.11) (push) Has been skipped
test / tests (false, false, 3.12) (push) Has been skipped
test / tests (false, false, 3.13) (push) Has been skipped
test / tests (true, 3.14) (push) Has been skipped
test / tests (false, false, 3.14) (push) Has been skipped
test / tests (false, false, 3.9) (push) Has been skipped
test / tests (true, pypy3.11) (push) Has been skipped
test / tests (false, false, 3.14t) (push) Has been skipped
Publish on PyPI / Publish distributions to PyPI (push) Has been cancelled
Publish on PyPI / Build distributions (push) Has been cancelled
2025-10-13 08:38:31 +03:00
Sergey B Kirpichev f580874a54 Revert testing of GMP-backends for PyPy, see #1013 2025-10-13 08:36:01 +03:00
Sergey B Kirpichev be2ba908dc Merge pull request #1010 from skirpichev/misc
Misc fixes
2025-10-12 16:53:15 +03:00
Sergey B Kirpichev e274405100 Test on CPython 3.14t 2025-10-12 15:51:25 +03:00
Sergey B Kirpichev 0039506d7b Run test.yml on schedule and allow workflow dispatch for all jobs 2025-10-12 15:13:12 +03:00
Sergey B Kirpichev 0bba53b955 Amend bb1087f6 2025-10-12 11:45:01 +03:00
Sergey B Kirpichev 1d92fce111 Update CHANGES 2025-10-12 11:28:44 +03:00
Sergey B Kirpichev 6215098fda Update credits 2025-10-12 11:09:14 +03:00
Sergey B Kirpichev 85fb02ab25 Remove broken codecov integration (see mpmath/mpmath#709) 2025-10-12 11:00:39 +03:00
Ayush Baranwal 0d8b0e0b8c Fix #1003: sinm and cosm can accept list as arguments, similar to expm and other functions (#1006) 2025-10-08 11:04:34 +03:00
Sergey B Kirpichev 47917f0d90 Merge pull request #1005 from baranwalayush/fix/matrix_ValueError
Fix #1004: Matrix should raise ValueError in case of negative dimensions
2025-10-05 05:06:56 +03:00
baranwalayush de1e15d49f Fix matrix should raise ValueError and Add unit tests 2025-10-03 19:21:30 +05:30
Sergey B Kirpichev 23b8bbfd79 Unpin pytest-cov, see pytest-dev/pytest-cov#720 2025-10-03 05:07:36 +03:00
Sergey B Kirpichev 33eace1005 Merge pull request #1000 from skirpichev/wa-996
Workaround support for multiple statements in CLI
2025-10-02 09:00:59 +03:00
Sergey B Kirpichev 4247f6a7ea Pin pytest-cov (<7)
See pytest-dev/pytest-cov#720
2025-10-02 08:43:42 +03:00
Sergey B Kirpichev 57147a724a Workaround support for multiple statements in CLI
Closes #996
2025-10-02 07:44:36 +03:00
Sergey B Kirpichev 760227b06c Merge pull request #998 from WarrenWeckesser/function-names
Ensure exp, sin, tan, etc have a correct __name__ attribute
2025-09-07 07:02:31 +03:00
Warren Weckesser 82e72a72d7 Ensure exp, sin, tan, etc have a correct __name__ attribute 2025-09-06 16:32:42 -04:00
Sergey B Kirpichev df11c35fa0 Merge pull request #995 from mpmath/dependabot/github_actions/actions/setup-python-6
test / linter (push) Failing after 1s
test / coverage (push) Failing after 0s
test / tests (false, false, 3.10) (push) Has been skipped
test / tests (false, false, 3.11) (push) Has been skipped
test / tests (false, false, 3.12) (push) Has been skipped
test / tests (false, false, 3.13) (push) Has been skipped
test / tests (false, false, 3.13t) (push) Has been skipped
test / tests (false, false, 3.14) (push) Has been skipped
test / tests (false, false, 3.9) (push) Has been skipped
test / tests (false, false, pypy3.11) (push) Has been skipped
test / docs (push) Failing after 0s
test / tests (true, 3.14) (push) Has been skipped
test / tests (true, pypy3.11) (push) Has been skipped
Publish on PyPI / Build distributions (push) Has been cancelled
Publish on PyPI / Publish distributions to PyPI (push) Has been cancelled
Bump actions/setup-python from 5 to 6
2025-09-05 07:38:54 +03:00
dependabot[bot] 1984ee7780 Bump actions/setup-python from 5 to 6
Bumps [actions/setup-python](https://github.com/actions/setup-python) from 5 to 6.
- [Release notes](https://github.com/actions/setup-python/releases)
- [Commits](https://github.com/actions/setup-python/compare/v5...v6)

---
updated-dependencies:
- dependency-name: actions/setup-python
  dependency-version: '6'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-09-05 04:21:14 +00:00
Sergey B Kirpichev 8b172a6ec4 Merge pull request #962 from skirpichev/v1.14-beta1
v1.14 beta1
2025-09-05 07:20:27 +03:00
Sergey B Kirpichev a03719f2fe Drop outdated reference to Sage's Cython-based context 2025-09-03 07:51:28 +03:00
Sergey B Kirpichev a14f851414 Unpin numpy and matplotlib for CPython 3.14 and PyPy 2025-09-03 07:50:01 +03:00
Sergey B Kirpichev aee92a48e7 Allow gmpy2/gmp for PyPy 2025-09-03 07:43:34 +03:00
Sergey B Kirpichev c3c9849651 Test no-gmpy2 backends on CPython 3.14 2025-09-03 05:56:41 +03:00
hnb22 baaccb59aa Switch logarithm implementation to taylor series when input is close to 1 (#957)
This modifies the logarithm implementation for cases where taylor series
is more optimal (cancellation >= working precision), providing a faster
path for low precision cases depending on how close input is to 1.
2025-09-03 05:31:22 +03:00
Sergey B Kirpichev 49a7d7a8b8 Test without gmp/gmpy2 on CPython 2025-09-03 05:26:32 +03:00
Sergey B Kirpichev bb1087f6f1 Runner image: ubuntu-latest -> ubuntu-24.04 2025-09-02 13:14:20 +03:00
Sergey B Kirpichev 4cf6c37a73 Setup dependabot 2025-09-02 13:11:50 +03:00
Sergey B Kirpichev 362261271a Update actions 2025-09-02 13:10:09 +03:00
Sergey B Kirpichev 5aa61a25df Clarify deprecation of using mpmath.libmp's submodules
test / linter (push) Failing after 0s
test / docs (push) Failing after 0s
test / coverage (push) Failing after 1s
test / tests (false, 3.11) (push) Has been skipped
test / tests (false, 3.12) (push) Has been skipped
test / tests (false, 3.13) (push) Has been skipped
test / tests (false, 3.10) (push) Has been skipped
test / tests (true, 3.13) (push) Has been skipped
test / tests (false, 3.13t) (push) Has been skipped
test / tests (false, 3.14) (push) Has been skipped
test / tests (false, 3.9) (push) Has been skipped
test / tests (false, pypy3.11) (push) Has been skipped
Publish on PyPI / Build distributions (push) Has been cancelled
Publish on PyPI / Publish distributions to PyPI (push) Has been cancelled
2025-09-01 07:43:43 +03:00
Sergey B Kirpichev 96ec4a10b8 Merge pull request #993 from skirpichev/MPContext-docs/975
Document support for free-threading builds
2025-09-01 07:34:43 +03:00
Sergey B Kirpichev 4d75799077 Test on free-threading builds 2025-09-01 07:15:19 +03:00
Sergey B Kirpichev ad91359172 Use threading.local storage for global caches 2025-09-01 06:21:07 +03:00
Sergey B Kirpichev 8042d8eb95 Document support for free-threading builds
Closes #975
2025-09-01 05:24:36 +03:00
Sergey B Kirpichev e325306bc6 Require python-gmp>=0.4 2025-08-20 05:27:29 +03:00
Ferrangelo d9587127d5 Correct implementation of spherical bessel functions (#992)
Closes #991
2025-08-17 13:11:22 +03:00
Sergey B Kirpichev 97c45f21e3 Require python-gmp>=0.4.0b3
test / coverage (push) Failing after 0s
test / linter (push) Failing after 0s
test / docs (push) Failing after 0s
test / tests (false, 3.14) (push) Has been skipped
test / tests (false, 3.9) (push) Has been skipped
test / tests (false, pypy3.11) (push) Has been skipped
test / tests (false, 3.10) (push) Has been skipped
test / tests (false, 3.11) (push) Has been skipped
test / tests (false, 3.12) (push) Has been skipped
test / tests (false, 3.13) (push) Has been skipped
test / tests (true, 3.13) (push) Has been skipped
Publish on PyPI / Build distributions (push) Has been cancelled
Publish on PyPI / Publish distributions to PyPI (push) Has been cancelled
2025-08-06 13:07:44 +03:00
Sergey B Kirpichev 09fa9516ad Merge pull request #989 from skirpichev/misc
Misc fixes
2025-08-06 07:48:37 +03:00
Sergey B Kirpichev f5b3e07ce4 Drop pypy3.10 from testing matrix (not supported by upstream) 2025-08-06 07:31:42 +03:00
Sergey B Kirpichev 1ad7c87381 Fix "citation not referenced" warnings
Closes #979
2025-08-06 07:15:09 +03:00
Sergey B Kirpichev 8870f1d258 Add aliases for mpf/mpc_log() as mpf/mpc_ln()
Closes #988
2025-08-06 06:02:12 +03:00
Sergey B Kirpichev 2a89521f0d Fix typo (im -> conj)
Closes #987
2025-08-06 05:26:42 +03:00
Sergey B Kirpichev b6af936582 Make mpc_hash() compatible with complex hash
Closes #985
2025-08-06 05:26:42 +03:00
Sergey B Kirpichev 657ef46356 Cleanup docs/general.rst (use signatures from autofunction)
Closes #986
2025-08-06 04:30:39 +03:00
Hongren Zheng 9ac078ca7c Add Fox H-function with rational A and B parameters (#982)
Closes #980
2025-07-27 19:03:23 +03:00
Sergey B Kirpichev 890b7a6a5e Merge pull request #981 from skirpichev/misc
Misc fixes
2025-07-25 08:09:47 +03:00
Sergey B Kirpichev bf11729f64 Amend 5c719770a 2025-07-23 06:43:05 +03:00
Sergey B Kirpichev 2a91ca3c6f Cleanup pyproject.toml 2025-07-23 06:41:31 +03:00
Sergey B Kirpichev 5b68356a26 Require python-gmp>=0.4.0b2 2025-07-23 06:31:40 +03:00
Sergey B Kirpichev 3788ac7320 Merge pull request #978 from d-torrance/citation-warnings
Fix citation warning due to typo
2025-07-20 05:54:40 +03:00
Doug Torrance a28bcd5eec Fix citation warning due to typo
WARNING: citation not found: Homeier [ref.ref]
2025-07-19 22:21:17 -04:00
Sergey B Kirpichev 5d66b10f53 Use Fraction's with the python-gmp 2025-07-03 22:16:18 +03:00
David Walker 9b98a71476 Switch to anderson method to speed up zetazero (#959)
test / docs (push) Failing after 0s
test / coverage (push) Failing after 0s
test / linter (push) Failing after 0s
test / tests (false, 3.9) (push) Has been skipped
test / tests (false, pypy3.10) (push) Has been skipped
test / tests (false, pypy3.11) (push) Has been skipped
test / tests (false, 3.10) (push) Has been skipped
test / tests (false, 3.11) (push) Has been skipped
test / tests (false, 3.12) (push) Has been skipped
test / tests (false, 3.13) (push) Has been skipped
test / tests (false, 3.14) (push) Has been skipped
test / tests (true, 3.13) (push) Has been skipped
Publish on PyPI / Build distributions (push) Has been cancelled
Publish on PyPI / Publish distributions to PyPI (push) Has been cancelled
Closes #958
2025-06-20 05:44:34 +03:00
Sergey B Kirpichev 027bfd36ed Merge pull request #973 from skirpichev/references/224
Move references to docs/references.rst
2025-06-19 19:10:24 +03:00
Sergey B Kirpichev 57d341cf7d Merge pull request #972 from skirpichev/misc
Misc fixes
2025-06-19 06:36:19 +03:00
Sergey B Kirpichev 2cad89428e Move references to docs/references.rst
Closes #224
2025-06-18 18:03:46 +03:00
That's ¬a problem d5f370a68a Fix typo in mpf_gamma() docstring 2025-06-18 07:53:03 +03:00
Sergey B Kirpichev cd52b6da6b Cleanup ctx_mp_python.py (consistent argument naming) 2025-06-18 07:53:01 +03:00
Sergey B Kirpichev 1485493711 Merge pull request #969 from skirpichev/misc
Misc fixes
2025-06-10 05:16:29 +03:00
Sergey B Kirpichev 9ad6a13925 Fix from_man_exp to correctly reject non-integral mantissa
This partially reverts 25506567
2025-06-09 05:21:57 +03:00
Sergey B Kirpichev bad54feab6 Use context's rounding mode per default in the format() 2025-06-08 18:27:16 +03:00
Sergey B Kirpichev e8bc7ea1a8 More tests for zetazeros()
Taken from #959
2025-06-08 16:48:16 +03:00
Sergey B Kirpichev 2b72f9f3a0 Rename to_str() argument: rounding -> rnd 2025-06-08 15:28:06 +03:00
Sergey B Kirpichev 936039cd6c precision -> dps in formatting helpers 2025-06-08 13:42:27 +03:00
Sergey B Kirpichev ed1ad32051 Rename kwarg rounding -> rnd in new helpers 2025-06-08 12:59:50 +03:00
Sergey B Kirpichev 4b26ebf276 Rename argument rounding -> rnd in private *_besseljn() functions 2025-06-08 12:59:45 +03:00
Sergey B Kirpichev 8a2bed58a5 Merge pull request #966 from skirpichev/misc
Misc fixes
2025-06-04 15:33:55 +03:00
Sergey B Kirpichev cf22ea86be Amend 4582b137
Use mp._prec_rounding[1] instead of _rounding attribute
for compatibility with the custom MPContext context in
Diofant/SymPy (polys).
2025-06-03 22:00:37 +03:00
Sergey B Kirpichev 82e202a4f1 Clarify deprecation of direct access to _mpf_ tuples 2025-06-03 15:25:17 +03:00
Sergey B Kirpichev 08a7a2f92a Revert "Revert 849e185e and (partially) f4cef9c8 (same for with field)"
This reverts commit 5ad43bd837.

Closes #915
2025-06-03 14:59:47 +03:00
Sergey B Kirpichev 8b48864418 Fix mpf.__round__() to return int type per default (ndigits=None) 2025-06-03 11:24:13 +03:00
Sergey B Kirpichev 3e516d4fe3 Fix exception type for int(mp.inf) to OverflowError 2025-06-03 11:23:46 +03:00
David Walker 75b52a3aea Fix two small bugs. (#964)
The method could not be properly set for zeta().
kwargs didn't work fully for nstr() when applied to mpc types.

Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
2025-06-03 09:41:45 +03:00
Sergey B Kirpichev 8d487d15c8 Merge pull request #963 from skirpichev/rounding-prop
Support rounding property for the mp context
2025-06-02 17:30:57 +03:00
Sergey B Kirpichev e403511878 Clear other obsoleted XXX/FIXME marks 2025-06-01 13:33:02 +03:00
Sergey B Kirpichev 4582b13795 Support rounding property for the mp context 2025-06-01 13:28:51 +03:00
Sergey B Kirpichev 1c4bf6db68 Merge pull request #961 from skirpichev/misc
Misc fixes
2025-06-01 07:13:27 +03:00
Sergey B Kirpichev 9989ce5c1c Drop verify=False (True per default) in zetazeros.py/bessel.py 2025-05-31 07:04:11 +03:00
Sergey B Kirpichev 454ce15028 Cleanup findroot() calls in zetazeros.py 2025-05-31 05:27:20 +03:00
Sergey B Kirpichev c61d0345b3 Drop useless verify=False from doctest 2025-05-31 03:55:10 +03:00
Sergey B Kirpichev 065746d7de Cleanup optimization.rst 2025-05-30 06:05:03 +03:00
Sergey B Kirpichev 58859b9acf Fix Anderson docs 2025-05-30 06:04:23 +03:00
Sergey B Kirpichev 5e17d5611f Merge pull request #954 from skirpichev/bin/hex-literals-in-cli
Support bin/hex float literals in the CLI
2025-05-14 05:22:23 +03:00
Sergey B Kirpichev 84bddafd07 Support bin/hex float literals in the CLI
See skirpichev/peps#4 and python/cpython#114667.
2025-05-11 08:58:06 +03:00
Sergey B Kirpichev 2dc1682b98 Merge pull request #950 from skirpichev/changes/937
Update CHANGES
2025-05-10 08:40:04 +03:00
Sergey B Kirpichev b7276c1235 Update CHANGES
Closes #937
2025-05-09 13:29:57 +03:00
Sergey B Kirpichev 785a5288ff Merge pull request #955 from skirpichev/deprecate-bitcount
Deprecate bitcount()
2025-05-09 13:28:01 +03:00
Sergey B Kirpichev dd54732850 Deprecate bitcount() 2025-05-09 13:02:15 +03:00
Sergey B Kirpichev 8f87833c39 Workaround CLI testing on CPython 3.14 2025-05-09 10:08:09 +03:00
Sergey B Kirpichev fdcda9cef7 Merge pull request #952 from skirpichev/misc
Misc fixes
2025-05-02 08:17:28 +03:00
Sergey B Kirpichev c3c76f4d28 Don't use python-gmp on PyPy (lack of cache) 2025-05-01 12:51:26 +03:00
Sergey B Kirpichev 8778568951 Avoid using ";" in doctests, esp with side effects
The new CPython repl hide all output, except for the last statement.
See https://github.com/python/cpython/issues/131217.
2025-05-01 10:41:48 +03:00
Sergey B Kirpichev dbd8976e3f Merge pull request #951 from skirpichev/gmp-backend
test / docs (push) Failing after 0s
test / coverage (push) Failing after 0s
test / linter (push) Failing after 0s
test / tests (false, 3.10) (push) Has been skipped
test / tests (false, 3.11) (push) Has been skipped
test / tests (false, 3.12) (push) Has been skipped
test / tests (false, 3.13) (push) Has been skipped
test / tests (false, 3.14) (push) Has been skipped
test / tests (false, 3.9) (push) Has been skipped
test / tests (false, pypy3.10) (push) Has been skipped
test / tests (false, pypy3.11) (push) Has been skipped
test / tests (true, 3.13) (push) Has been skipped
Publish on PyPI / Build distributions (push) Has been cancelled
Publish on PyPI / Publish distributions to PyPI (push) Has been cancelled
Add python-gmp as optional backend (gmpy2 alternative)
2025-04-30 10:33:56 +03:00
Sergey B Kirpichev 0b523c0e7a Merge pull request #949 from skirpichev/isspecial/946
Add isspecial() method for mp/fp contexts, deprecate isnormal()
2025-04-29 07:56:56 +03:00
Sergey B Kirpichev 33eb8b787b Add python-gmp as optional backend (gmpy2 alternative)
Closes #895
2025-04-28 20:52:16 +03:00
Sergey B Kirpichev e6aa3b46b1 Add isspecial() method for mp/fp contexts, deprecate isnormal()
Closes #946
2025-04-28 08:36:15 +03:00
Sergey B Kirpichev 7a0b3f48b6 Merge pull request #948 from skirpichev/misc
Misc fixes
2025-04-28 07:00:24 +03:00
Sergey B Kirpichev beb5029ac5 Use mpf_log1p in acos_asin() helper (implementing Hull et al algorithm)
Closes #787
2025-04-26 19:10:44 +03:00
Sergey B Kirpichev 4edff338a2 Add exp2() and log2()
Closes #947
2025-04-26 19:10:40 +03:00
Sergey B Kirpichev cb74f50321 Use SPDX license value 2025-04-26 09:05:44 +03:00
Sergey B Kirpichev 7a8b98c6b3 Merge pull request #944 from skirpichev/fix-nospec-fmt/943
Fix new-style formatting without type specifier (repr_dps vs dps)
2025-04-24 13:48:32 +03:00
Sergey B Kirpichev 6c51c9d898 Fix new-style formatting without type specifier (repr_dps vs dps)
Closes #943
2025-04-23 07:04:24 +03:00
Sergey B Kirpichev fcf6e9650c Merge pull request #941 from skirpichev/use-pyrepl/938
Use PyREPL, as fallback (no IPython)
2025-04-17 07:35:07 +03:00
Sergey B Kirpichev c945b4d2b0 Use PyREPL, as fallback (no IPython)
Closes #938
2025-04-16 08:27:22 +03:00
Sergey B Kirpichev a0ba3a00c1 Merge pull request #940 from RonnyPfannschmidt/patch-1
use the intended setuptools_scm integration pattern
2025-04-15 06:43:28 +03:00
Sergey B Kirpichev 608cd99115 Merge pull request #939 from skirpichev/misc
Misc fixes
2025-04-15 06:43:04 +03:00
Ronny Pfannschmidt 499b44115f use the intended setuptools_scm integration pattern
as per https://setuptools-scm.readthedocs.io/en/latest/#with-setuptools

i'd appreciate details on how the usage of dynamic and get-version came to be
2025-04-14 16:38:07 +02:00
Sergey B Kirpichev 9d42919136 Use ast transformation in wrap_float_literals() 2025-04-13 12:37:30 +03:00
Sergey B Kirpichev 2c82152738 Fix source transformation in IPython, add tests 2025-04-13 12:37:27 +03:00
Sergey B Kirpichev 788f3a7fca Ensure mpf_bernoulli() returns normalized answer
Closes #928
2025-04-09 09:31:51 +03:00
Sergey B Kirpichev 609d09bb74 Merge pull request #936 from skirpichev/misc
Misc fixes
2025-04-08 07:50:01 +03:00
Sergey B Kirpichev 210a6a77da Fix wrap_float_literals() to detect all float/complex literals 2025-04-08 06:01:58 +03:00
Sergey B Kirpichev 798d929ace Move source transformations up in runsource() 2025-04-08 05:52:14 +03:00
Sergey B Kirpichev 91416abc82 Amend 950d654a (support '._f'-like cases, i.e. with default precision) 2025-04-07 11:17:29 +03:00
Sergey B Kirpichev c465c17c2b Revert rest of f4cef9c8
Python docs doesn't specify 0-padding behavior, when alignment is
specified.  Lets be more strict here as Fraction/Decimal's: just reject
0 flag in this case.

float's behavior is just odd:
>>> format(1.123, '<020f')
'1.123000000000000000'
2025-04-07 10:56:11 +03:00
Sergey B Kirpichev 17a3f61928 Test formatting with digit separators in the fractional part 2025-04-07 10:56:09 +03:00
Sergey B Kirpichev 5ad43bd837 Revert 849e185e and (partially) f4cef9c8 (same for with field)
While python/cpython#130662 being discussed, lets keep previous (more
strict) formatting specification.
2025-04-07 10:49:01 +03:00
Sergey B Kirpichev 551ab3224e CLI fixes for multi-line input
Processing in wrap_float_literals() can't work line-by-line, as the
tokenize.unparse() doesn't preserve indentation in this case.  E.g.:

$ python -m mpmath --no-ipython
>>> def f():
...     return 1.2
...
Traceback (most recent call last):
  ...
  File "<unknown>", line 2
    return mpf('1.2')
    ^^^^^^
IndentationError: expected an indented block after function definition on line 1
2025-04-07 10:49:01 +03:00
Sergey B Kirpichev f4af440eb3 Use itertools.product() in calculus 2025-04-07 10:49:01 +03:00
Sergey B Kirpichev 33bf8a48f4 Merge pull request #933 from skirpichev/repr_dps
Add pretty_dps context property to control number of printed digits
2025-04-05 06:53:18 +03:00
Sergey B Kirpichev d8277f07d2 Merge pull request #935 from skirpichev/sph-bessel/319
Support spherical Bessel functions (jn/yn)
2025-04-03 07:21:09 +03:00
Sergey B Kirpichev 5294dd9ddd Support spherical Bessel functions (jn/yn)
Naming scheme follows to SciPy.  Closes #319
2025-04-02 07:12:47 +03:00
Sergey B Kirpichev a14901da43 Add pretty_dps context property to control number of printed digits
Closes #921
2025-03-30 09:13:43 +03:00
Sergey B Kirpichev 8c6f6603ad Merge pull request #931 from skirpichev/fix-repl
Fix runsource() for incomplete input
2025-03-19 04:34:14 +03:00
Sergey B Kirpichev 23b9054b3f Fix runsource() for incomplete input 2025-03-18 16:26:22 +03:00
Sergey B Kirpichev 9ea52503dd Merge pull request #926 from skirpichev/fix-637
Use sum_accurately() in hankel1/2()
2025-03-09 02:24:50 +03:00
Sergey B Kirpichev 1a2bd24e5f Use sum_accurately() in hankel1/2()
Closes #637
2025-03-08 02:58:48 +03:00
Sergey B Kirpichev 18b83d144d Merge pull request #925 from skirpichev/frac-sep/918
Support thousands separators for formatting of fractional part
2025-03-06 05:37:24 +03:00
Sergey B Kirpichev 0661c36724 Cleanup handling of separators 2025-03-05 06:25:10 +03:00
Sergey B Kirpichev 950d654a22 Support thousands separators for formatting of fractional part
Closes #918
2025-03-05 03:34:06 +03:00
Sergey B Kirpichev 8f68766f75 Simplify handling of thousands_separators 2025-03-04 12:50:21 +03:00
Sergey B Kirpichev 1a0e1aea07 Simplify format_scientific/binary/hexadecimal() 2025-03-04 09:58:22 +03:00
Sergey B Kirpichev a06c90b884 Simplify format_fixed() 2025-03-04 08:51:41 +03:00
Sergey B Kirpichev ddd8c9d698 Drop base argument for format_scientific/fixed() 2025-03-04 07:36:44 +03:00
Sergey B Kirpichev de66a1cac7 Simplify sign handling in format() helpers 2025-03-04 07:12:02 +03:00
Sergey B Kirpichev 6f698709e1 Merge pull request #924 from skirpichev/sofa
Add moving sofa demo
2025-03-04 03:49:31 +03:00
Sergey B Kirpichev e6c5041498 Merge pull request #923 from skirpichev/misc
Misc fixes
2025-03-04 03:19:10 +03:00
Sergey B Kirpichev 8d2c851247 Add moving sofa demo
Closes #96
2025-03-03 12:12:17 +03:00
Sergey B Kirpichev d66b8f2536 Enable pretty-printing in CLI per default 2025-03-03 04:37:10 +03:00
Sergey B Kirpichev a0bd397484 Test on PyPy3.11 2025-03-03 04:37:10 +03:00
Sergey B Kirpichev 198fe541fc Test on stable PyPy3.10 2025-03-03 04:37:10 +03:00
Sergey B Kirpichev ac5dc65288 Merge pull request #922 from skirpichev/fix-917
Fix handling of zeropad flag
2025-03-03 04:22:03 +03:00
Sergey B Kirpichev 8a42c3f6a0 Fix handling of zeropad flag
Closes #917
2025-03-03 03:59:13 +03:00
Sergey B Kirpichev f816f92923 Merge pull request #920 from mpmath/revert-896-gmp-backend
Revert "Add python-gmp as optional backend (gmpy2 alternative)"
2025-03-01 05:30:05 +03:00
Sergey B Kirpichev 23b5d390bc Revert "Add python-gmp as optional backend (gmpy2 alternative)" 2025-03-01 05:29:44 +03:00
Sergey B Kirpichev 0805720944 Merge pull request #896 from skirpichev/gmp-backend
Add python-gmp as optional backend (gmpy2 alternative)
2025-03-01 05:29:38 +03:00
Sergey B Kirpichev 7c55d87ca9 Merge pull request #916 from skirpichev/misc
Misc fixes
2025-03-01 04:55:09 +03:00
Sergey B Kirpichev 4d166d8853 Add python-gmp as optional backend (gmpy2 alternative)
Closes #895
2025-02-28 08:48:32 +03:00
Sergey B Kirpichev f4cef9c83e Correct handling of zeropad and fill_char options 2025-02-28 08:48:11 +03:00
Sergey B Kirpichev 849e185ede Relax requirements on precision format, allow 0-prefixes
Closes #915
2025-02-28 08:48:11 +03:00
Sergey B Kirpichev 4c9a2ef9cd Simplify backend handling in libintmath.py/libmpf.py 2025-02-28 08:47:50 +03:00
Sergey B Kirpichev 5e57cb8039 Merge pull request #913 from dimbleby/build-publish-wheel
build and publish wheel
2025-01-31 06:46:58 +03:00
David Hotham e254e50428 build and publish wheel 2025-01-30 21:12:35 +00:00
Sergey B Kirpichev 861c1cd0d4 Add aliases for pure-python integer functions
test / linter (push) Failing after 0s
test / coverage (push) Failing after 0s
test / tests (3.10) (push) Has been skipped
test / tests (3.11) (push) Has been skipped
test / tests (3.12) (push) Has been skipped
test / tests (3.13) (push) Has been skipped
test / tests (3.14) (push) Has been skipped
test / tests (3.9) (push) Has been skipped
test / tests (pypy3.10-nightly) (push) Has been skipped
test / docs (push) Failing after 1s
Publish on PyPI / Build distribution (push) Has been cancelled
Publish on PyPI / Publish distribution to PyPI (push) Has been cancelled
2025-01-30 06:06:19 +03:00
Sergey B Kirpichev 65247c70df Merge pull request #911 from skirpichev/drop-3.8
Drop support for CPython 3.8
2025-01-30 05:24:54 +03:00
Sergey B Kirpichev 5a52ee2867 Update copyright years 2025-01-30 05:19:47 +03:00
Sergey B Kirpichev 085182d60c Merge pull request #912 from skirpichev/speedup-coverage
Speedup coverage tests (run less without gmpy2)
2025-01-30 05:15:00 +03:00
Sergey B Kirpichev bd1584671c Speedup coverage tests (run less without gmpy2) 2025-01-30 04:48:20 +03:00
Sergey B Kirpichev 5c719770ae Drop support for CPython 3.8
Closes #910
2025-01-29 10:35:48 +03:00
Sergey B Kirpichev 049321c80e Merge pull request #909 from skirpichev/misc
Misc fixes
2025-01-29 05:09:50 +03:00
Sergey B Kirpichev e0f88b3495 Use gmpy2.mpz.digits() method 2025-01-29 04:02:02 +03:00
Sergey B Kirpichev 2550656706 Make sure we pass MPZ mantissa to from_man_exp() 2025-01-29 04:00:25 +03:00
Sergey B Kirpichev 4fb7367100 Ignore missing ~/.python_history for default console
Closes #907
2025-01-29 03:43:08 +03:00
Sergey B Kirpichev 5d501de9e8 Correct case for integer n in besselj/besseli
Closes #908
2025-01-29 03:35:24 +03:00
Sergey B Kirpichev fa51d4c822 Merge pull request #898 from ricor07/fix_polylog
Increase working precision in polylog_general() for negative s
2025-01-22 15:26:00 +03:00
Sergey B Kirpichev 441fa3ee8d add test 2025-01-22 13:57:45 +03:00
Sergey B Kirpichev bfb4711bd0 restrict precision adjustment for finite numbers 2025-01-22 13:54:40 +03:00
Sergey B Kirpichev 09bdbbb28f Merge branch 'master' into fix_polylog 2025-01-22 13:50:36 +03:00
Sergey B Kirpichev 859eb36c6e Cleanup publish.yml 2025-01-22 11:01:11 +03:00
Sergey B Kirpichev 8f56d73d8d XXX publish.yml
test / linter (push) Failing after 1s
test / coverage (push) Failing after 0s
test / tests (3.10) (push) Has been skipped
test / tests (3.11) (push) Has been skipped
test / tests (3.12) (push) Has been skipped
test / tests (3.13) (push) Has been skipped
test / tests (3.14) (push) Has been skipped
test / tests (3.8) (push) Has been skipped
test / tests (3.9) (push) Has been skipped
test / tests (pypy3.10-nightly) (push) Has been skipped
test / docs (push) Failing after 0s
Publish on PyPI / Build distribution (push) Has been cancelled
Publish on PyPI / Publish distribution to PyPI (push) Has been cancelled
2025-01-22 10:59:13 +03:00
Sergey B Kirpichev b3e5ba638b Merge pull request #906 from skirpichev/simplify-docs
Cleanup docs for functions (using better signatures)
2025-01-22 10:10:22 +03:00
Sergey B Kirpichev 380f2f30d5 Cleanup docs for functions (using better signatures) 2025-01-22 09:17:21 +03:00
Sergey B Kirpichev 57e56592ea Merge pull request #905 from skirpichev/GA-refactor
Refactor Github Actions
2025-01-22 08:34:56 +03:00
Sergey B Kirpichev ab7055fdc7 Refactor Github Actions
Split out separate workflows for linting, documentation builds, coverage
tests and regular tests.
2025-01-22 07:42:26 +03:00
Riccardo Orsi af72f59566 Update zeta.py 2025-01-21 16:26:45 +01:00
Riccardo Orsi 3ac143b2e1 Update zeta.py
removed trailing whitespace
2025-01-21 16:21:10 +01:00
Riccardo Orsi 18ad9aed8c Update zeta.py 2025-01-21 16:04:50 +01:00
Sergey B Kirpichev 705dfcf9d3 Merge pull request #904 from skirpichev/polylog-inf/473
Add special case for ±inf in polylog_continuation()
2025-01-21 06:37:25 +03:00
Sergey B Kirpichev 9f37d84d29 Add special case for ±inf in polylog_continuation()
Closes #473
2025-01-21 06:01:44 +03:00
Sergey B Kirpichev 6560982f1f Merge pull request #903 from skirpichev/iv-minmax/258
Raise an exception if iv's comparison can't be decided
2025-01-21 05:57:57 +03:00
Sergey B Kirpichev c2b811b8f9 Merge pull request #902 from skirpichev/hypsum-poly/511
Special case in ctx.hypsum for infinite z
2025-01-21 05:57:12 +03:00
Sergey B Kirpichev 6ba8c276e6 Raise an exception if iv's comparison can't be decided
Closes #258
2025-01-20 08:57:31 +03:00
Sergey B Kirpichev 1c53162296 Merge pull request #900 from skirpichev/add-sig/899
Better introspection support for decorated functions
2025-01-20 08:28:14 +03:00
Sergey B Kirpichev 4a881c9f31 Special case in ctx.hypsum for infinite z
Closes #511
2025-01-19 15:25:29 +03:00
Sergey B Kirpichev b9ac31f5cd Better introspection support for decorated functions
Closes #899
2025-01-19 07:33:28 +03:00
Riccardo Orsi 9f9a1ae39b Update zeta.py
Tries to address error in polylog precision when abs(z) > 1 and s is close to an integer
2025-01-18 16:20:05 +01:00
Sergey B Kirpichev 04d79bd34c Merge pull request #897 from skirpichev/misc
Misc fixes
2025-01-18 11:02:19 +03:00
Riccardo Orsi 0671d642fd Support negative indexes in matrix
Made possible single extraction or assignment of values with negative
indexes.  Closes #835.

Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
2025-01-18 10:28:13 +03:00
Sergey B Kirpichev c9b0cc2fc6 Ignore .hypothesis/ in pytest 2025-01-16 12:03:26 +03:00
Sergey B Kirpichev 06d00fc53b Drop "4-tuple" note in docs, per #720 2025-01-06 05:04:46 +03:00
Sergey B Kirpichev 96c142c17e Merge pull request #893 from mo271/sign_error
sign error in machin formula (doc string only)
2024-12-28 04:07:46 +03:00
Moritz Firsching 9113cf5de8 sign error in machin formula (doc string only) 2024-12-27 20:33:34 +01:00
Sergey B Kirpichev 6523f9cade Merge pull request #892 from skirpichev/rounding-wrt-mpfr/890
Add MPFR-compatible aliases for rounding modes and documentation
2024-12-26 04:52:21 +03:00
Sergey B Kirpichev fc3f041b42 Add MPFR-compatible aliases for rounding modes and documentation
Closes #890
2024-12-25 04:50:35 +03:00
Sergey B Kirpichev 68ab06458b Update .readthedocs.yaml 2024-12-18 15:16:07 +03:00
Sergey B Kirpichev 0ed5868185 Amend 63e6e24 2024-12-06 20:07:28 +03:00
Sergey B Kirpichev 8c14792f26 Merge pull request #889 from skirpichev/use-besselik-parity-877
Use parity formula for besseli
2024-12-06 06:28:23 +03:00
Sergey B Kirpichev 63e6e24acc Use parity formula for besseli
See
https://functions.wolfram.com/Bessel-TypeFunctions/BesselI/04/02/01/0002/

Closes #877
2024-12-05 08:45:51 +03:00
Sergey B Kirpichev b600dbcabf Merge pull request #886 from skirpichev/fix-885
Reject invalid strings in from_str()
2024-11-06 07:36:25 +03:00
Sergey B Kirpichev 30e8001e27 Reject invalid strings in from_str()
Closes #885
2024-11-05 07:04:16 +03:00
Sergey B Kirpichev 5235f441db Merge pull request #881 from skirpichev/fix-880
Correct 'g' format type handling
2024-10-21 09:04:04 +03:00
Sergey B Kirpichev 0027b02fe9 Skip tests for g/G format types in CPython 3.8
$ python3.9
    Python 3.9.19+ (heads/3.9:3f5d9d12c7, Aug 29 2024, 13:17:09)
    [GCC 12.2.0] on linux
    Type "help", "copyright", "credits" or "license" for more information.
    >>> format(240605919345005.0, '.14g')
    '2.40605919345e+14'
    $ python3.8
    Python 3.8.19+ (heads/3.8:e319f774f9, Aug 29 2024, 12:59:09)
    [GCC 12.2.0] on linux
    Type "help", "copyright", "credits" or "license" for more information.
    >>> format(240605919345005.0, '.14g')
    '2.4060591934500e+14'
2024-10-20 12:57:47 +03:00
Sergey B Kirpichev 0aa50064a1 Correct 'g' format type handling
Closes #880
2024-10-20 05:03:40 +03:00
Sergey B Kirpichev 99e3b464af Merge pull request #879 from skirpichev/pin-setuptools
Skip matplotlib/numpy on 3.14
2024-10-19 11:19:11 +03:00
Sergey B Kirpichev af49b31e23 Skip matplotlib/numpy on 3.14 2024-10-18 17:25:55 +03:00
Sergey B Kirpichev 728db99cd9 Merge pull request #878 from d-torrance/numpy-2
Only check for NumPy array copy ValueError w/ NumPy >= 2.0
2024-10-18 07:50:12 +03:00
Doug Torrance 9dd08e59df Only check for NumPy array copy ValueError w/ NumPy >= 2.0
No such error is raised when using NumPy < 2.0.
2024-10-15 18:48:40 -04:00
Sergey B Kirpichev 8926a695f5 Merge pull request #876 from skirpichev/ctx-params
Add parameters for MPContext constructor
2024-10-15 07:32:23 +03:00
Sergey B Kirpichev 94b286a0c9 Add parameters for MPContext constructor
See e.g.
https://github.com/mpmath/mpmath/issues/683#issuecomment-1511107680
2024-10-13 20:07:36 +03:00
Sergey B Kirpichev 094feb22ca Merge pull request #875 from skirpichev/revert-fc474e1
Revert "fix ellippi to return an inf instead of raising an exception"
2024-10-12 07:34:25 +03:00
Sergey B Kirpichev cd57adf8c7 Revert "fix ellippi to return an inf instead of raising an exception (thanks to John Beyers)"
This reverts commit fc474e1069.

We don't have a concept of "complex infinity".  But real infinity (of
any sign) is clearly a wrong answer here (it has well defined finite
phase and infinite absolute value), e.g.:

```pycon
>>> ellippi(1-1e-15, 1-1e-15j)
mpc(real='915673653288978.88', imag='-530451596311157.62')
>>> ellippi(1-1e-15, 1+1e-15j)
mpc(real='915673653288978.88', imag='530451596311157.62')
```

Closes #268
2024-10-10 09:15:21 +03:00
Sergey B Kirpichev 6c8e7e0856 Merge pull request #873 from skirpichev/misc
test / build (false, false, false, 3.10) (push) Has been cancelled
test / build (false, false, false, 3.11) (push) Has been cancelled
test / build (false, false, false, 3.12) (push) Has been cancelled
test / build (false, false, false, 3.13) (push) Has been cancelled
test / build (false, false, false, 3.14) (push) Has been cancelled
test / build (false, false, false, 3.8) (push) Has been cancelled
test / build (false, false, false, 3.9) (push) Has been cancelled
test / build (false, false, false, pypy3.10-nightly) (push) Has been cancelled
test / build (true, true, 3.11) (push) Has been cancelled
test / build (true, true, 3.12) (push) Has been cancelled
Misc fixes
2024-10-07 13:46:23 +03:00
Sergey B Kirpichev 9580374595 Use convert(strings=False) in _mpc.mpc_convert_lhs() 2024-10-03 14:36:07 +03:00
Sergey B Kirpichev 677683efcc Implement _mpf.mpf_convert_rhs() with ctx.convert() 2024-10-03 13:53:19 +03:00
Sergey B Kirpichev d3fccbc52d Cleanup mpmath/ctx_mp_python.py 2024-10-03 12:35:34 +03:00
Sergey B Kirpichev 93c0647a8f Add special cases for infinities in mpc_*div()
Closes #805
2024-09-29 12:39:54 +03:00
Sergey B Kirpichev 82f6d62489 Use correct mixed-mode functions in fsub/fdiv 2024-09-29 12:39:13 +03:00
Sergey B Kirpichev 51872ef8a4 Implement mpf.__floordiv__() and mpf.__divmod__()
Closes #333
2024-09-29 12:38:46 +03:00
Sergey B Kirpichev d66c4fdb11 Merge pull request #871 from skirpichev/misc
Misc fixes
2024-09-28 10:18:20 +03:00
Sergey B Kirpichev 1df26ae33e Relax default timeout for tests 2024-09-25 10:42:40 +03:00
Sergey B Kirpichev 496fa104ff Gitignore .venv/ and venv/ 2024-09-25 09:59:31 +03:00
Sergey B Kirpichev 4bee0fc194 Merge pull request #870 from skirpichev/misc
Misc fixes
2024-09-25 07:09:43 +03:00
Sergey B Kirpichev 3280528df5 Put coverage report to build/coverage/html/ 2024-09-24 10:38:47 +03:00
Sergey B Kirpichev a217e4b111 Enable trap_complex for MDNewton
Closes #869
2024-09-24 09:17:20 +03:00
Sergey B Kirpichev e205922fad Don't use normalize() in format_* helpers 2024-09-24 07:53:21 +03:00
Sergey B Kirpichev 27bbf9892a Optimize format_hexadecimal() like format_binary()
Test code:
```py
import pyperf

from mpmath import pi
from mpmath.libmp.libmpf import format_hexadecimal as fd

runner = pyperf.Runner()
pi = pi._mpf_
runner.bench_func('fd(pi, -1)', fd, pi)
runner.bench_func('fd(pi, +5)', fd, pi, 5)
```

Results:
| Benchmark      | master  | patch                 |
|----------------|:-------:|:---------------------:|
| fd(pi, -1)     | 38.9 us | 17.1 us: 2.27x faster |
| fd(pi, +5)     | 39.7 us | 18.7 us: 2.13x faster |
| Geometric mean | (ref)   | 2.20x faster          |
2024-09-24 07:53:21 +03:00
Sergey B Kirpichev 236988d182 Properly support 'A' format option, amends 40c16e9 2024-09-24 07:53:15 +03:00
Sergey B Kirpichev 3c63d30a5a Merge pull request #867 from skirpichev/format-bin-866
Support 'b' (binary) format type for mpf/mpc
2024-09-23 08:03:58 +03:00
Sergey B Kirpichev c79cecf2a8 Simplify format_binary() 2024-09-23 07:50:40 +03:00
Sergey B Kirpichev ea87cafabe Support 'b' (binary) format type for mpf/mpc
Closes #866
2024-09-23 07:50:35 +03:00
Sergey B Kirpichev 53f319144b Merge pull request #868 from skirpichev/misc
Misc fixes
2024-09-23 07:48:54 +03:00
Sergey B Kirpichev b856953a3a Cleanup format_hexadecimal() helper 2024-09-23 07:32:40 +03:00
Sergey B Kirpichev a93b19dffe Amend d3c6428 2024-09-23 07:32:40 +03:00
Sergey B Kirpichev 1ef4691519 Merge pull request #864 from skirpichev/misc
Misc fixes
2024-09-16 07:15:06 +03:00
Sergey B Kirpichev 15238878b8 Remove remnants of fnzero 2024-09-16 07:01:09 +03:00
Sergey B Kirpichev 21fed47e6d Merge pull request #826 from skirpichev/round-455
mpf.__round__() returns mpf
2024-09-14 06:32:39 +03:00
Sergey B Kirpichev f6d7888007 Raise ValueError for complex infininity condition in zeta(s, a)
Closes #653
2024-09-12 09:10:13 +03:00
Sergey B Kirpichev b77d54fbb5 Merge pull request #861 from skirpichev/misc
Misc fixes
2024-09-10 11:52:30 +03:00
Sergey B Kirpichev 8f502b53ef Add for_complex option for fmt_str strategy 2024-09-09 10:59:01 +03:00
Sergey B Kirpichev 372b71de1b Drop PyPy workarounds (and test on nightly builds again) 2024-09-09 10:35:09 +03:00
Sergey B Kirpichev 83b32f84fc Drop testing on PyPy 3.9
It seems, there will be no bugfix releases anymore,
see https://github.com/pypy/pypy/issues/5028#issuecomment-2337104585
2024-09-09 10:00:58 +03:00
Sergey B Kirpichev 5fdae7bc12 Cleanup backend.py 2024-09-09 10:00:58 +03:00
Sergey B Kirpichev e8a53fab5c Merge pull request #855 from skirpichev/format-mpc-846
Add mpc.__format__()
2024-09-09 10:00:02 +03:00
Sergey B Kirpichev 4669219ed1 Add mpc.__format__()
Closes #846
2024-09-09 05:39:14 +03:00
Sergey B Kirpichev b39d61ea28 Merge pull request #862 from skirpichev/format-tests
Add common hypothesis-based bulk tests for format()
2024-09-09 05:37:48 +03:00
Sergey B Kirpichev fef7cab68b Add common hypothesis-based bulk tests for format() 2024-09-08 07:50:26 +03:00
Sergey B Kirpichev 1c76b021f2 Merge pull request #841 from skirpichev/format-hex
Implement 'a'/'A' formating types for mpf.__format__
2024-09-08 07:46:22 +03:00
Sergey B Kirpichev 40c16e98c1 Implement 'a'/'A' formating types for mpf.__format__ 2024-09-08 07:31:11 +03:00
Sergey B Kirpichev b4b3b9cd77 Merge pull request #857 from skirpichev/fix-empty-format-856
Fix formatting of mpf's when format type is missing
2024-09-08 06:33:48 +03:00
Sergey B Kirpichev a545ecbd9e mpf.__round__() returns mpf
Probably this will look non-intuitive, but underlying floating-point
arithmetic is binary, not decimal.  Thus, round(x, n) sometimes will pick
up a decimal representation with more than n digits.  This is something
common for CPython < 2.7 and < 3.1:

    Python 2.6.6 (r266:84292, Aug 12 2014, 07:57:07)
    [GCC 4.4.5] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>> round(0.42754287856598971, 2)
    0.42999999999999999

And with this patch as well:

    Python 3.12.5+ (heads/3.12:0181aa2e3e, Aug 29 2024, 14:55:08) [GCC 12.2.0] on linux
    Type "help", "copyright", "credits" or "license" for more information.
    >>> from mpmath import *
    >>> round(mp.mpf(0.42754287856598971), 2)
    mpf('0.42999999999999999')
    >>> mp.pretty = True
    >>> round(mp.mpf(0.42754287856598971), 2)
    0.43

See also python/cpython#45921

Closes #455
2024-09-07 07:32:59 +03:00
Sergey B Kirpichev 0cb9c7debc Fix formatting of mpf's when format type is missing
In this case it was incorrectly assumed, that this is an equivalent of
'g' formatting type.  It's not:
1) when no precision is specified - it should be equal to
   repr_deps(prec) to represent the given value faithfully.
2) when fixed-point is used to format the result, it always includes at
   least one digit past the decimal point.

Closes #856
2024-09-07 05:02:56 +03:00
Sergey B Kirpichev f36220e6c4 Merge pull request #859 from skirpichev/fix-858-and-tests
Add hypothesis-based formatting tests and workaround #858
2024-09-06 15:05:09 +03:00
Sergey B Kirpichev 15df470cf0 Add bulk tests for 'g' and 'G' format types 2024-09-03 11:28:11 +03:00
Sergey B Kirpichev 7da6ca9a23 Split out format_digits() and redo handling special numbers
Should be useful for formatting complex numbers
2024-09-03 11:27:26 +03:00
Sergey B Kirpichev ce77ba8b9d Simplify handling '%' format type 2024-09-03 11:27:26 +03:00
Sergey B Kirpichev 67cf49cbdc Add hypothesis-based formatting tests and workaround #858
Fix also few other minor issues, coming from tests.

Closes #858

Co-authored-by: Javier Garcia <javier.garcia.tw@hotmail.com>
2024-09-03 11:27:24 +03:00
Sergey B Kirpichev 9d9029a559 Merge pull request #854 from skirpichev/fix-log1p-853
Use correct constructor in series branch of log1p
2024-08-30 15:18:28 +03:00
Sergey B Kirpichev 515f2a2214 Use correct constructor in series branch of log1p
This amends 7596816

Closes #853
2024-08-30 11:25:15 +03:00
Sergey B Kirpichev 0a93ade965 Merge pull request #851 from skirpichev/sage-fixes
Misc fixes
2024-08-30 11:09:18 +03:00
Sergey B Kirpichev 51514a0103 Use force_series=True per default for chebyt/chebyu
Closes #852
2024-08-29 18:10:23 +03:00
Sergey B Kirpichev 41846b992a Claim support for CPython 3.13 and 3.14 2024-08-29 18:10:23 +03:00
Sergey B Kirpichev e42c111244 Enable testing on 3.14 2024-08-29 18:10:22 +03:00
Sergey B Kirpichev 4be9a0261e Reorder hasattr() checks in mpf.mpf_convert_arg() and mp.convert()
Taken from https://github.com/sagemath/sage/pull/38565#issuecomment-2311204724
2024-08-29 18:10:22 +03:00
Javier Garcia 9b99f418c7 Add documentation for mpf.__format__ (#850)
Adds a bit of documentation in the Utility Functions section.

Closes #337

Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
2024-08-28 04:48:15 +03:00
Javier Garcia 7afe9ac70c Support gmpy2-like rounding modes in to_str() (#830)
Closes #757
2024-08-26 09:28:13 +03:00
Sergey B Kirpichev ba7aac82c2 Merge pull request #849 from skirpichev/misc
Misc fixes
2024-08-26 09:13:33 +03:00
Sergey B Kirpichev 41fbde527b Fix mpf_div() for prec=0 2024-08-26 09:02:25 +03:00
Sergey B Kirpichev 399f973739 Amend 042133d 2024-08-26 07:32:55 +03:00
Sergey B Kirpichev cc4b30b6b0 Depend on pytest-timeout 2024-08-26 07:32:55 +03:00
Sergey B Kirpichev 09213907be Merge pull request #847 from skirpichev/fmt-percent
Support '%' presentation type for mpf
2024-08-24 11:45:43 +03:00
Sergey B Kirpichev 4b9ebf41f4 Support '%' presentation type for mpf
Closes #837
2024-08-22 13:41:45 +03:00
Sergey B Kirpichev 4f68bc328b Merge pull request #845 from skirpichev/misc
Misc fixes
2024-08-22 07:50:24 +03:00
Sergey B Kirpichev 14fe1b6049 fix: polyroots() ignored asc=False kwarg value 2024-08-21 10:10:58 +03:00
Sergey B Kirpichev e929803c53 numpy/matplotlib now support 3.13, drop pinning 2024-08-21 10:10:58 +03:00
Sergey B Kirpichev 144b69ff15 Fix DeprecationWarning coming with numpy>=2.1 2024-08-21 10:10:58 +03:00
Sergey B Kirpichev 08247152b4 Merge pull request #844 from WarrenWeckesser/fix-polyval-asc
BUG: polyval ignored 'asc=False'
2024-08-21 06:56:51 +03:00
Warren Weckesser 083737e14d BUG: polyval ignored 'asc=False' 2024-08-20 17:38:23 -04:00
Sergey B Kirpichev d5c8e0c617 Merge pull request #839 from skirpichev/misc
Misc fixes
2024-08-20 05:42:38 +03:00
Sergey B Kirpichev 135f1d8c10 Pin numpy (<2.1) 2024-08-20 05:21:23 +03:00
Sergey B Kirpichev 042133d72b Clarify gmpy2 support
Closes #840
2024-08-18 12:36:36 +03:00
Sergey B Kirpichev 5ac8dcda88 Skip special case in mpc_pow_int() for special numbers
Closes #472
2024-08-18 12:35:48 +03:00
Sergey B Kirpichev 958879588e Move up special cases in bernpoly()
Closes #471
2024-08-18 12:35:36 +03:00
Sergey B Kirpichev a580878336 Use mpf's in steffensen() doctest
Closes #838
2024-08-18 12:35:21 +03:00
Sergey B Kirpichev fc92ec7875 Normalize mpf in mp.npconvert() and lower precision in tests
On most systems np.float128 aren't IEEE 754 quadruples.

Closes #836
2024-08-18 12:35:12 +03:00
Sergey B Kirpichev be30018375 Fix MPZ_ONE import 2024-08-18 12:35:06 +03:00
Sergey B Kirpichev e365729b18 Drop special import for random
$ python -m pyperf timeit 'import random'
.....................
Mean +- std dev: 396 ns +- 5 ns

$ python -m pyperf timeit 'import math'
.....................
Mean +- std dev: 391 ns +- 4 ns
2024-08-18 12:34:57 +03:00
Sergey B Kirpichev f04fa498d9 Merge pull request #843 from skirpichev/pypy-stable
Test on stable pypy builds
2024-08-18 12:28:24 +03:00
Sergey B Kirpichev 112628c9e9 Don't test with matplotlib on PyPy 2024-08-18 10:01:04 +03:00
Sergey B Kirpichev 37a6271681 Test on stable pypy builds
The #772 was merged at Apr; new stable releases
dated 2024-04-23, which should include fixes for #762.
2024-08-18 10:01:04 +03:00
Javier Garcia cf98bcf07d Correct formatting for round_up rounding mode (#834)
This commit improves the code in `round_digits`: now the first digit in the `stddigits` list is excluded from the list of digits that must be rounded up when the `round_up` rounding mode is used. When rounding to a 0 digit, all the digits following it are looked up, and if one of them is different from 0, the 0 is rounded up.

This fixes some wrongfully formatted floats as, for example, when running the following code in the master branch
```python
>>> from gmpy2 import mpfr
>>> from mpmath import mp
>>> print('{:.2Uf}'.format(mpfr('0.25')))
0.25
>>> print('{:.2Uf}'.format(mp.mpf('0.25')))
0.26
>>>
```
2024-08-10 05:08:20 +03:00
Sergey B Kirpichev f9099fc195 Merge pull request #831 from skirpichev/misc
Misc fixes
2024-08-06 07:06:35 +03:00
Sergey B Kirpichev 90e535bdf0 Make format type optional and default to 'g'
Closes #833
2024-08-04 10:55:33 +03:00
javierelpianista f39a8c3aaa Amend aa6690b: add 'Y' rounding mode 2024-08-03 07:53:56 +03:00
Sergey B Kirpichev 0edac040c7 Drop empty mpmath/tests/__init__.py 2024-08-02 16:30:19 +03:00
Sergey B Kirpichev d0ca1a9154 Use ellipsis in fp.spherharm doctest
After python/cpython#121149 this was broken on CPython 3.14:

_______________ [doctest] mpmath.functions.orthogonal.spherharm ____________
EXAMPLE LOCATION UNKNOWN, not showing all tests of that example
??? >>> fp.chop(fp.quad(lambda t,p: Y1(t,p)*Y2(t,p)*dS(t,p), *sphere))
Expected:
    1.0000000000000007
Got:
    1.0000000000000004

This particular failure could be fixed by:
diff --git a/mpmath/ctx_base.py b/mpmath/ctx_base.py
index 3309bfa..2ca2fac 100644
--- a/mpmath/ctx_base.py
+++ b/mpmath/ctx_base.py
@@ -110,7 +110,8 @@ def fdot(ctx, xs, ys=None, conjugate=False):
             cf = ctx.conj
             return sum((x*cf(y) for (x,y) in xs), ctx.zero)
         else:
-            return sum((x*y for (x,y) in xs), ctx.zero)
+            return ctx.mpc(sum(((x*y).real for (x,y) in xs), ctx.zero),
+                           sum(((x*y).imag for (x,y) in xs), ctx.zero))

     def fprod(ctx, args):
         prod = ctx.one

But this is just one case for the whole test suite...
2024-08-02 09:45:32 +03:00
Sergey B Kirpichev 7596816fbe Improve accuracy of log1p() (#803)
Patch, ported from Tim Peters version at: https://github.com/mpmath/mpmath/issues/790#issuecomment-2084094631

Co-authored-by: Tim Peters <tim.peters@gmail.com>
2024-08-02 07:29:15 +03:00
Sergey B Kirpichev 716a750760 Merge pull request #829 from skirpichev/misc
Misc fixes
2024-08-02 07:28:21 +03:00
Sergey B Kirpichev 6d2767de8b Point to https://mpmath.readthedocs.io/ for recent docs 2024-08-02 06:25:45 +03:00
Sergey B Kirpichev 428f50054a Correct minimal gmpy2 version 2024-08-02 06:17:44 +03:00
Sergey B Kirpichev afc3bdba1b Update version in pip install example 2024-08-02 06:16:57 +03:00
Sergey B Kirpichev a18abb7ca9 Unshallow git clone on RTD build
This should fix incorrect development versions, see
https://docs.readthedocs.io/en/latest/build-customization.html#unshallow-git-clone
2024-08-02 06:13:57 +03:00
Javier Garcia aa6690b5fa Support rounding modes in mpf.__format__ (#823)
Adds support for rounding modes 'U', 'D', 'Z' and 'N', following the gmpy2 library.
2024-08-02 05:19:24 +03:00
Sergey B Kirpichev 0a79b5626c Merge pull request #828 from skirpichev/misc
Misc fixes
2024-08-01 12:46:02 +03:00
Sergey B Kirpichev 5a155f8e09 Drop sign from nstr(mpf('inf')) output
Closes #827
2024-08-01 12:27:58 +03:00
Sergey B Kirpichev bf27e80ae2 Ignore .hypothesis/ 2024-08-01 12:25:18 +03:00
Sergey B Kirpichev 90a42bcb4f Fix mp.convert (missing rounding mode for from_rational) 2024-08-01 12:25:08 +03:00
Sergey B Kirpichev b74bacfcd2 Merge pull request #821 from skirpichev/misc
Misc fixes
2024-07-31 07:04:02 +03:00
Sergey B Kirpichev caadde2575 Support conversion from scalar ndarray's
Closes #824
2024-07-31 06:39:11 +03:00
Sergey B Kirpichev eeba1ca9ab Drop test_mpf_fmt_special() 2024-07-25 07:27:14 +03:00
Sergey B Kirpichev 921d3338d9 Add hypothesis test deps 2024-07-25 06:55:40 +03:00
Sergey B Kirpichev fb9e4aeafc Move up blog2_10 constant 2024-07-25 06:49:05 +03:00
Javier Garcia cead3b2bf9 Implement mpf.__format__ (#819)
Implemented the `__format__` method for the `_mpf` type.

Currently, `f`, `F`, `g`, `G`, `e`, and `E` formats are implemented, following the same specifications as specified for regular floats [here](https://docs.python.org/3/library/string.html#formatspec).  Only nearest rounding is implemented.

A partial fix for #337.
2024-07-24 19:37:04 +03:00
Sergey B Kirpichev 65241d7fe2 Merge pull request #818 from skirpichev/misc
Misc fixes
2024-07-20 13:03:39 +03:00
Sergey B Kirpichev 5def5939c9 Consistently use "floating-point" 2024-07-20 12:51:08 +03:00
Sergey B Kirpichev 842cd42907 Amend d3c6428 (mp.prec default should match fp.prec) 2024-07-20 12:28:49 +03:00
Sergey B Kirpichev 2cf46c6ca5 Fix typos in docs, closes #817 2024-07-05 09:16:26 +03:00
Sergey B Kirpichev e9168a32aa Merge pull request #813 from skirpichev/misc
Misc fixes
2024-07-02 14:55:55 +03:00
Michał Górny 3651b78a71 Fix the comparison in test_compatibility for NumPy 2.0.0
The comparison in `mpmath/tests/test_convert.py::test_compatibility`
failed for `np.float16` in NumPy 2.0.0 since `2.0**-53` cannot be
represented in half-precision floating point type.  (NumPy 2
implicitly converts the second operand to the type of the first one.)

Explicitly convert it to `np.float64` to ensure that the comparison is
done in sufficiently precise type.

// edited by Sergey B Kirpichev
2024-07-02 14:36:14 +03:00
Sergey B Kirpichev 20fc46d253 Workaround np.core deprecation 2024-07-02 14:29:42 +03:00
Sergey B Kirpichev 21bc72a93c Update gmpy2 deps to >=2.2 2024-07-01 11:06:48 +03:00
Sergey B Kirpichev 8a4ce81f7f Merge pull request #812 from skirpichev/reduce-mem-foot-for-quad-811
Reduce memory usage for QuadratureRule cache
2024-06-25 07:28:00 +03:00
Sergey B Kirpichev 9a174a0806 Run CI also on schedule 2024-06-23 18:38:29 +03:00
Sergey B Kirpichev 80fed12e34 Freeze numpy deps 2024-06-22 16:04:39 +03:00
Sergey B Kirpichev c3a747cd85 Reduce memory usage for QuadratureRule cache
The interval_count seems to be redundant, transformed_cache has entries
from the standard_cache...  So, I believe a single dict is enough.

See #811.  This partially address mentioned issue.
2024-06-22 15:12:11 +03:00
Sergey B Kirpichev ee1a810266 Merge pull request #808 from skirpichev/gmpy2-deps
Update gmpy2 deps to >=2.2.0rc1
2024-06-14 08:22:45 +03:00
Sergey B Kirpichev d21bee0ee9 Merge pull request #806 from skirpichev/simplify-mpf
Simplify ctx_mp_python.py
2024-06-14 08:22:21 +03:00
Sergey B Kirpichev 3d600486fb Update gmpy2 deps to >=2.2.0rc1 2024-06-13 10:19:40 +03:00
Sergey B Kirpichev fdb8bc09f4 Add mpc_mpf_sub() 2024-06-05 10:40:32 +03:00
Sergey B Kirpichev b180c95c2b Move around mpc() methods... 2024-06-05 10:35:59 +03:00
Sergey B Kirpichev bfa51f7f1e Move string handling to _mpf.__new__() 2024-06-05 10:35:59 +03:00
Sergey B Kirpichev 08c55b7715 Drop special cases in arithmetic helpers of mpf 2024-06-05 10:35:59 +03:00
Sergey B Kirpichev 75a2ed37c4 Merge pull request #804 from skirpichev/misc2
Misc fixes
2024-05-09 11:08:43 +03:00
Sergey B Kirpichev 043a40f718 Merge pull request #795 from skirpichev/misc
Correct asin/acos for infinite arguments
2024-05-06 07:03:59 +03:00
Sergey B Kirpichev bb0fad9476 Improve test coverage for rational.py and calculus/approximation.py 2024-05-06 06:44:23 +03:00
Sergey B Kirpichev 698d97c7b6 Update codecov-action
Now coverage reports will be submitted for pr's (this doesn't require a
token).  But not for the master.

Not very helpful, as coverage diff will be wrt very outdated version of
the master, but...
2024-05-06 06:25:45 +03:00
Sergey B Kirpichev adafe85728 Merge pull request #802 from skirpichev/ae-inf-799
Support inf/nan's in ctx.almosteq()
2024-05-04 09:30:32 +03:00
Sergey B Kirpichev f690e847d4 Merge pull request #801 from skirpichev/revert-dcc591c
Revert dcc591c
2024-05-03 15:51:54 +03:00
Sergey B Kirpichev 2beeee2a9d Support inf/nan's in ctx.almosteq()
Closes #799
2024-05-02 10:22:51 +03:00
Sergey B Kirpichev 9246999058 Correct asin/acos for infinite arguments
Closes #793
2024-05-01 11:07:37 +03:00
Sergey B Kirpichev 2283c89611 Revert dcc591c
This uses per-function workarounds to fall through to ctx.hypercomb()
2024-05-01 09:16:45 +03:00
Sergey B Kirpichev d415dec5a2 Merge pull request #800 from skirpichev/sympy-fix
Temporary fix for SymPy, regression from #792
2024-04-30 19:54:39 +03:00
Sergey B Kirpichev b5c4dda969 Temporary fix for SymPy, regression from #792 2024-04-30 19:19:59 +03:00
Sergey B Kirpichev 7c957a2584 Merge pull request #798 from skirpichev/add-fp.hypot
Add fp.hypot
2024-04-30 07:28:39 +03:00
Sergey B Kirpichev 2c3f4f2cd3 Add fp.hypot
This partially address issue #355
2024-04-30 07:11:34 +03:00
Sergey B Kirpichev 08cbde4bfb Merge pull request #792 from skirpichev/inf-prec-520
Fallback to fixed precision if prec change is infinite
2024-04-30 06:28:54 +03:00
Sergey B Kirpichev ff73d54d21 Merge pull request #797 from skirpichev/misc2
Misc fixes
2024-04-28 11:06:21 +03:00
Sergey B Kirpichev c599eb6ec9 Workaround 1/z division for acot/asec/acsc/acoth
Closes #796
2024-04-27 15:50:31 +03:00
Sergey B Kirpichev 5d88099e00 Use diff-cover to test diff coverage 2024-04-27 14:32:05 +03:00
Sergey B Kirpichev 8a837a01a5 Document differences of mp vs fp contexts
Closes #786
2024-04-27 05:58:38 +03:00
Sergey B Kirpichev 94fc487078 Improve test coverage for mpmath/libmp/libmpc.py 2024-04-27 05:58:38 +03:00
Sergey B Kirpichev ef62c29e1f Drop unused helper mpc_mul_imag_mpf() 2024-04-27 05:58:38 +03:00
Sergey B Kirpichev e33a9aba22 Drop mpf.__complex__()
Closes #794
2024-04-24 14:28:54 +03:00
Sergey B Kirpichev dcc591cb67 Fallback to fixed precision if prec change is infinite
This will leave handling of special numbers to fewer
functions, e.g. to hypercomb().

Closes #520
Closes #522
2024-04-23 05:56:32 +03:00
Doug Torrance 4f3c60df81 Use sys.executable instead of "python" for test_cli (#789)
Some systems (e.g., Debian/Ubuntu) ship a "python3" command instead of
"python" per PEP 394.  But we may not be able to guarantee if
"python3" exists either, so we use sys.executable to determine the
name of the command.
2024-04-19 07:15:08 +03:00
Sergey B Kirpichev b8d90d9a04 Merge pull request #791 from d-torrance/float128
Skip np.float128 assertion in test_convert if type doesn't exist
2024-04-19 06:47:13 +03:00
Doug Torrance b76baa6f14 Skip np.float128 assertion in test_convert if type doesn't exist
It isn't available on all systems (e.g., 32-bit x86 machines).
2024-04-18 22:03:28 -04:00
Sergey B Kirpichev b94812a9d2 Merge pull request #769 from skirpichev/v1.4.0a1
test / build (false, false, false, 3.10) (push) Has been cancelled
test / build (false, false, false, 3.11) (push) Has been cancelled
test / build (false, false, false, 3.12) (push) Has been cancelled
test / build (false, false, false, 3.13) (push) Has been cancelled
test / build (false, false, false, 3.8) (push) Has been cancelled
test / build (false, false, false, 3.9) (push) Has been cancelled
test / build (false, false, false, pypy3.10-nightly) (push) Has been cancelled
test / build (false, false, false, pypy3.9-nightly) (push) Has been cancelled
test / build (true, true, 3.11) (push) Has been cancelled
test / build (true, true, 3.12) (push) Has been cancelled
v1.4.0a1
2024-04-16 12:40:59 +03:00
Sergey B Kirpichev a0dd78fd84 Ignore few files with DeprecationWarning during tests collection 2024-04-16 12:18:03 +03:00
Sergey B Kirpichev b62a2a9523 Add DeprecationWarning for mpmath.math2 2024-04-16 12:18:03 +03:00
Sergey B Kirpichev 59b57b08be Drop _MPMathModule from imports 2024-04-16 12:18:03 +03:00
Sergey B Kirpichev 1d6d240e04 Restore to/from_pickable() helper functions 2024-04-16 12:18:01 +03:00
Sergey B Kirpichev 6111ee9d12 Restore minimal compatibility wrapper for mpmath.rational.mpq
See sympy/sympy#26269 and sympy/sympy#26273
2024-04-16 12:16:35 +03:00
Sergey B Kirpichev 5ed78dac46 Merge pull request #773 from skirpichev/run-as-module
Run mpmath as a module for interactive work
2024-04-16 12:13:05 +03:00
Sergey B Kirpichev eac9809994 Merge pull request #783 from skirpichev/misc
Misc fixes
2024-04-16 09:23:44 +03:00
Sergey B Kirpichev 610fbeda33 Add signed option to to_man_exp()
Returning unsigned mantissa value per default is deprecated.
2024-04-16 09:00:58 +03:00
Sergey B Kirpichev b5bd545a09 Don't unpack mpf tuples directly in ctx_mp*.py 2024-04-16 09:00:39 +03:00
Sergey B Kirpichev 5f724296dd Run mpmath as a module for interactive work
Example:
```
$ python -m mpmath --prec 100 --no-ipython
>>> 10.9
mpf('10.899999999999999999999999999995')
>>> mpf(1090/100)
mpf('10.899999999999999999999999999995')
>>> mpf('10.9')
mpf('10.899999999999999999999999999995')
>>> mpf(109)/mpf(10)
mpf('10.899999999999999999999999999995')
>>> mpf(10.9)
mpf('10.899999999999999999999999999995')
```

Closes #677
Closes #765
2024-04-14 10:20:44 +03:00
Sergey B Kirpichev 8ac7e86389 Merge pull request #785 from skirpichev/fix-tan-781
Handle infinite arguments in tan/tanh
2024-04-14 06:25:22 +03:00
Sergey B Kirpichev 2a13a8c3a7 Handle infinite arguments in tan/tanh
See https://en.cppreference.com/w/c/numeric/complex/ctanh and
https://en.cppreference.com/w/c/numeric/complex/ctan

Closes #781
2024-04-13 17:37:57 +03:00
Sergey B Kirpichev 953acc43d7 Merge pull request #779 from skirpichev/rev-polyroots
Deprecate current (descending) order of coefficients in polyval(), etc
2024-04-10 06:09:07 +03:00
Sergey B Kirpichev 18fbda65e0 Merge pull request #782 from skirpichev/misc
Misc fixes
2024-04-09 06:39:42 +03:00
Sergey B Kirpichev 273864df5a More verbose coverage report 2024-04-09 06:22:22 +03:00
Sergey B Kirpichev 745b2420a1 Don't fail on coverage upload
See codecov/codecov-action#1359
2024-04-09 06:18:52 +03:00
Sergey B Kirpichev dffeaa6cd1 Merge pull request #778 from skirpichev/misc
Misc fixes
2024-04-08 09:37:14 +03:00
Sergey B Kirpichev fb46ed6191 Support more number syntaxes
* 'oo' and '-oo' for infinity
* '2+3*I' or '2+4I' (SymPy and Mathematica style imaginary unit)
* '2/3 + 4/5j' (rational parts for a complex number)

Closes #184
2024-04-07 11:15:07 +03:00
Sergey B Kirpichev db21f0a572 Fail test suite if xfail'ed test - pass 2024-04-06 11:35:25 +03:00
Sergey B Kirpichev 26cd54f6c0 Turn DeprecationWarning's into errors in CI 2024-04-06 11:34:19 +03:00
Sergey B Kirpichev 23606c69c3 Deprecate current (descending) order of coefficients in polyval(), etc
Affected functions: chebyfit(), polyval(), polyroots() and findpoly().

First step for #142

Please adapt your code to use asc=True (lowest degree - first) order of
polynomial coefficients.  This will be a new default for mpmath releases
*after* the next release, v1.4.
2024-04-06 11:12:36 +03:00
Sergey B Kirpichev 1d57719d19 Add type-cast for mantissa in _mpf_ 4-tuple (mpf constructor) 2024-04-06 06:20:48 +03:00
Sergey B Kirpichev d6925e7d18 Add missing type cast in from_npfloat() and test 2024-04-05 11:50:03 +03:00
Sergey B Kirpichev cc47ca13d4 Improve coverage 2024-04-05 11:50:03 +03:00
Sergey B Kirpichev 03d0973ea2 Use to_man_exp() in mpf.man_exp to raise exceptions 2024-04-05 11:50:03 +03:00
Sergey B Kirpichev 0d68ad52c9 Adjust nan's hashing for Python versions >= 3.10 2024-04-05 11:50:03 +03:00
Sergey B Kirpichev c0d694d66b Drop libmp.math_float_inf 2024-04-05 11:50:03 +03:00
Sergey B Kirpichev 2a52f5a59a Drop libmp.HASH_BITS 2024-04-05 11:50:02 +03:00
Sergey B Kirpichev ab17cd8856 Drop libmp.HASH_MODULUS 2024-04-05 11:50:02 +03:00
Sergey B Kirpichev 968154ed04 Use prec=0 in libmp/*.py 2024-04-05 11:50:02 +03:00
Sergey B Kirpichev d8798f4b7b Clear unused imports in mpmath/libmp/*.py 2024-04-05 11:50:00 +03:00
Sergey B Kirpichev 61512b0c08 Set defaults rnd=round_fast for mpf_bernoulli* 2024-04-05 11:42:07 +03:00
Sergey B Kirpichev d1493c9ce6 Make explicit rnd=round_fast for to_int() 2024-04-05 11:42:07 +03:00
Sergey B Kirpichev 1e92cb923f Adjust defaults for rnd: 'd' -> round_fast, 'f' -> round_floor 2024-04-05 11:42:07 +03:00
Sergey B Kirpichev fb035b9c55 Correct atan2(±inf, ±inf) (#775)
See https://en.cppreference.com/w/c/numeric/complex/clog and
https://en.cppreference.com/w/c/numeric/math/atan2

Closes #774

Co-authored-by: Pearu Peterson <pearu.peterson@gmail.com>
2024-04-05 11:31:21 +03:00
Sergey B Kirpichev 3779c7ec46 Merge pull request #777 from skirpichev/sqrt-imag-inf-fix-776
sqrt(z): special case for infinite z.imag
2024-04-04 10:29:08 +03:00
Sergey B Kirpichev 7039538f30 sqrt(z): special case for infinite z.imag
See https://en.cppreference.com/w/c/numeric/complex/csqrt

Close #776
2024-04-04 05:42:19 +03:00
Sergey B Kirpichev 0d287bf406 Merge pull request #772 from skirpichev/test-on-pypy-nighly
Test against PyPy nightly builds
2024-04-01 08:32:50 +03:00
Sergey B Kirpichev 2e6a1a6ff1 Test against PyPy nightly builds
This also drops testing against PyPy 3.8 (it's unmaintained).

Closes #762
2024-03-31 16:33:48 +03:00
Aharoni b6bbeb5413 Update README.rst (#771)
Added the mailing list Google group link
2024-03-30 16:24:19 +03:00
Sergey B Kirpichev aa1c0b9f4b Merge pull request #770 from ChefAharoni/patch-1
Update README.rst
2024-03-30 15:54:36 +03:00
Aharoni b4c1e67fe8 Update README.rst
Contributor email ending missed the letter "o" in .com
2024-03-30 08:32:33 -04:00
Sergey B Kirpichev 4c1b43513b Merge pull request #767 from skirpichev/misc
Misc fixes
2024-03-29 06:37:50 +03:00
Sergey B Kirpichev 73c2cda472 Pass additional kwargs to matplotlib functons, e.g. imshow()
Closes #203
2024-03-26 05:16:06 +03:00
Sergey B Kirpichev 4ca05b0132 Generate images in docs/plotting.rst with matplotlib's plot_directive
Closes #202
2024-03-25 17:37:20 +03:00
Sergey B Kirpichev 1111002895 Move fp.loggamma from __init__() 2024-03-25 16:19:26 +03:00
Sergey B Kirpichev d3c642816a Set fp.prec/dps from sys.float_info 2024-03-25 16:19:23 +03:00
Sergey B Kirpichev 6de3572840 Disable CPython limits for int<->str conversion in str_to_man_exp()
Better alternative to afc990b.  Remove warning in docs.
2024-03-25 10:53:58 +03:00
Sergey B Kirpichev b5e582649b Support matrix.__array__() dunder method 2024-03-04 10:05:40 +03:00
Sergey B Kirpichev 3512b74baa Merge pull request #763 from skirpichev/misc
Misc fixes
2024-03-03 09:20:20 +03:00
Sergey B Kirpichev d294c04d85 Merge pull request #761 from skirpichev/pickling
Improve pickling support
2024-03-02 11:33:13 +03:00
Sergey B Kirpichev 7b8f2230e8 Add CONTRIBUTING.rst
Closes #726
2024-03-01 07:36:48 +03:00
Sergey B Kirpichev 7a13848342 Run flake8 on mpmath/ dir only 2024-03-01 07:31:21 +03:00
Sergey B Kirpichev 3ac151e385 Use a different workaround for pickling mpf/mpc 2024-02-29 07:46:43 +03:00
Sergey B Kirpichev 816668dcb2 Support pickling for mpi
Closes #264
2024-02-29 07:46:43 +03:00
Sergey B Kirpichev 1acd3ef7c6 Support pickling for matrices
Closes #380
2024-02-29 07:46:43 +03:00
Sergey B Kirpichev afb829b4aa Merge pull request #759 from skirpichev/misc
Misc fixes
2024-02-28 07:55:40 +03:00
Sergey B Kirpichev 22859b0441 Merge pull request #711 from skirpichev/hex
Support binary/hexadecimal string output
2024-02-27 05:28:50 +03:00
Sergey B Kirpichev 0429f855f2 Revert update for codecov-action (v4 requires a token) 2024-02-26 13:02:43 +03:00
Sergey B Kirpichev 6ca30e8de4 Update _matrix.rows/cols 2024-02-26 12:38:20 +03:00
Sergey B Kirpichev 3b20d8a8dc Relax numpy reqs 2024-02-26 12:38:20 +03:00
Sergey B Kirpichev 9be82b2a39 Depend on the matplotlib (for testing), filter a warning 2024-02-26 12:38:20 +03:00
Sergey B Kirpichev 4345422802 Don't use private name mangling in the matrices.py 2024-02-26 12:38:20 +03:00
Sergey B Kirpichev 57a5ec0bc3 Drop globals row/colsep from the matrices module 2024-02-26 09:03:54 +03:00
Sergey B Kirpichev 57a9e0d49d Fix few more py2 remnants (__truediv__ vs __div__) 2024-02-26 08:57:27 +03:00
Sergey B Kirpichev 6932ee99f4 Cleanup test.yml, run no-gmpy tests on 3.11 2024-02-26 08:36:19 +03:00
Sergey B Kirpichev 10ca54e9e1 Add base kwarg for the mpf constructor 2024-02-25 10:47:45 +03:00
mart-mihkel 49e16e0bac Fix several issues with empty matrices
* make det of null matrix return 1, see e.g.
  https://en.wikipedia.org/wiki/Matrix_(mathematics)#Empty_matrix
* fix str/repr

Closes #745

Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
2024-02-24 14:11:47 +03:00
Sergey B Kirpichev 529daf5b8f Update versions for GA actions 2024-02-24 08:01:27 +03:00
Sergey B Kirpichev 5fa35e0096 Use cholesky_solve() for overdetermined complex linear systems
Closes #227
2024-02-24 06:29:45 +03:00
Sergey B Kirpichev 25d326c95a Use asserts in normalize(), drop MPMATH_STRICT
For production code this could be removed by -O optimization.
2024-02-24 06:28:44 +03:00
Sergey B Kirpichev 9ac75475eb Run tests on CPython 3.13 (no gmpy2) 2024-02-23 18:19:01 +03:00
Sergey B Kirpichev 0d9dde2e0d Run no-gmpy2 tests on pypy 2024-02-23 18:15:54 +03:00
Sergey B Kirpichev 85b16c61ab Change warning category for force_type to DeprecationWarning
Closes #156
2024-02-23 17:40:24 +03:00
Sergey B Kirpichev e7e9102cf6 Fix demos
Closes #216
2024-02-23 17:40:24 +03:00
Sergey B Kirpichev 9286fc5ebf Fix hang in polylog_general()
Closes #505
2024-02-23 17:40:24 +03:00
Sergey B Kirpichev d3d1608deb Update default version (to run coverage tests and for docs) 2024-02-23 17:40:24 +03:00
Gonzalo Tornaría ea3ec6b6b4 Do not build depend on pip and wheel (#758) 2024-02-23 17:29:46 +03:00
Sergey B Kirpichev 16e686d1b3 Merge pull request #694 from skirpichev/use-setuptools_scm
test / build (3.10) (push) Has been cancelled
test / build (3.11) (push) Has been cancelled
test / build (3.12) (push) Has been cancelled
test / build (3.8) (push) Has been cancelled
test / build (3.9) (push) Has been cancelled
test / build (pypy3.10) (push) Has been cancelled
test / build (pypy3.8) (push) Has been cancelled
test / build (pypy3.9) (push) Has been cancelled
Use setuptools_scm to update __version__
2024-02-23 05:49:22 +03:00
Sergey B Kirpichev 0ccc872827 Use setuptools_scm to update __version__ 2024-02-22 15:31:46 +03:00
Sergey B Kirpichev 2e63cda444 Support float.hex()-style output in the to_str()
Closes #345
2024-02-22 13:23:15 +03:00
Jonathan Warner 247ff6f115 Support binary/octal/hexadecimal string output
Adapted from #414.

Partial fix for #345

Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>

* this version doesn't touch argument names (dps->ps)
* no support for float.hex()-style binary exponents
2024-02-22 12:07:52 +03:00
Qiming Sun 8d91e11511 Fix choleksy_solve for complex matrix (#755) 2024-02-19 13:09:24 +03:00
Sergey B Kirpichev 370a42ffc1 Merge pull request #750 from skirpichev/fix-asinh-749
Misc fixes
2024-02-04 03:01:51 +03:00
Sergey B Kirpichev 2f19dae16d Document that gegenbauer() actually implements the Gegenbauer function
See https://dlmf.nist.gov/15.9#iii

Closes #461
Closes #494
2024-02-02 12:56:24 +03:00
Sergey B Kirpichev a56d12f533 Fix repr(mp.eps)
This make a special case for mp.eps, closes #638
2024-02-02 10:38:46 +03:00
Sergey B Kirpichev dde042ac4b acos_asin(): don't try to normalize special numbers
Closes #749
2024-02-01 06:13:30 +03:00
Sergey B Kirpichev fd04402466 Support asinh/acosh/atanh in the fp context 2024-02-01 05:08:22 +03:00
Sergey B Kirpichev c8155cf3df Merge pull request #747 from skirpichev/misc
Misc fixes
2024-01-20 05:59:25 +03:00
Sergey B Kirpichev 0f3cfb79ac Update copyright years 2024-01-19 10:49:12 +03:00
Sergey B Kirpichev 3f95fa422b Update splot() for recent matplotlib
Closes #541
Closes #746
2024-01-19 10:49:12 +03:00
Sergey B Kirpichev 48df2a77bf Cleanup docs/conf.py 2024-01-19 10:49:11 +03:00
Sergey B Kirpichev 76e8750282 Remove elliptic module from index, add Index to the toctree 2024-01-19 10:49:11 +03:00
Colin B. Macdonald b7ed1b82cd prevent erroneous setting of dps/prec on mpmath module (#678)
* Use sys.modules hacks to prevent setting dps/prec

Fixes Issue #657

---------

Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
Co-authored-by: Warren Weckesser <warren.weckesser@gmail.com>
2024-01-05 14:36:00 +03:00
Sergey B Kirpichev 31c0762db2 Merge pull request #744 from paulmasson/patch-1
Correct Dirichlet eta function definition
2024-01-01 06:31:56 +03:00
Paul Masson 962e1d2e6e Correct Dirichlet eta function definition 2023-12-30 19:04:51 -08:00
Sergey B Kirpichev a92d68878d Merge pull request #743 from skirpichev/misc
Misc fixes
2023-12-24 06:43:49 +03:00
Sergey B Kirpichev 5dd8c4eb35 Support mpc initialization from string
Closes #260
2023-12-21 05:16:25 +03:00
Sergey B Kirpichev b59b7c7546 Add regression test
Closes #251
2023-12-21 05:16:25 +03:00
Sergey B Kirpichev f13ea4dc92 Merge pull request #740 from skirpichev/misc
Misc fixes
2023-12-01 07:37:46 +03:00
Sergey B Kirpichev 6c98d697f6 Correct fp.gamma and fp.isnpint
Closes #521
2023-12-01 07:13:29 +03:00
Sergey B Kirpichev 2738563ae4 Guard "fast case" in _hyp2f1() to omit infinite z
Closes #469
2023-12-01 07:13:29 +03:00
Sergey B Kirpichev 2148e95b84 Pass proper kwargs to quadosc()
Closes #652
2023-12-01 07:12:36 +03:00
Sergey B Kirpichev 0806b14b21 Expose lower/upper_gamma functions
Closes #738
2023-12-01 07:12:36 +03:00
Sergey B Kirpichev 310e2ea740 Clarify tol and maxsteps options of findroot()
Closes #736
2023-12-01 07:12:36 +03:00
Sergey B Kirpichev 6e374368c9 Drop __nonzero__ dunder methods (py2) 2023-12-01 07:12:36 +03:00
Sergey B Kirpichev 05dc18acea Merge pull request #732 from skirpichev/no-sage
Remove sage backend
2023-11-18 06:32:27 +03:00
Sergey B Kirpichev 72ca21dd35 Merge pull request #735 from skirpichev/misc
Misc fixes
2023-11-02 12:12:46 +03:00
Sergey B Kirpichev 7abcec1571 Drop some redundant signatures in autofunction directives 2023-10-27 05:03:37 +03:00
Sergey B Kirpichev c3fad32845 Add derivative keyword argument for besselk()
See #734
2023-10-27 04:32:36 +03:00
Sergey B Kirpichev c593982366 Merge pull request #731 from skirpichev/misc
Misc fixes
2023-10-22 08:55:45 +03:00
Sergey B Kirpichev 3ced4929bf Simplify _mpf.__new__() 2023-10-19 13:12:33 +03:00
Sergey B Kirpichev 00e540c2b0 Support construction of mpf from Decimal objects 2023-10-19 09:01:28 +03:00
Sergey B Kirpichev 89d106ab23 Remove sage backend
Closes #705
Closes #574
2023-10-19 05:32:39 +03:00
Sergey B Kirpichev 4c51e2d16f Raise OverflowError for infs in to_rational
And more tests
2023-10-18 15:39:03 +03:00
Sergey B Kirpichev 5c9f270717 Add mpf.as_integer_ratio() method
Closes #417.  I think we can't do better: e.g. if we provide
the mpf._mpfr_ property - then in expressions like mpq(1,2)+mpf(1.0) -
second operand (and the whole expression) will be promoted to mpfr.

Also this corrects to_rational() private function to return a pair of
integers with same type.
2023-10-18 15:35:00 +03:00
Sergey B Kirpichev f6bda7d30c Fix disagreement fp.pow vs mp.pow
Handle special values as in the ISO C99 and IEEE 754 standards
for the pow function.

Closes #523
Closes #512
2023-10-18 15:34:25 +03:00
Sergey B Kirpichev 425ebd4e0e Avoid extra type-cast (int -> MPZ) in str_to_man_exp()
gmpy2 has fix for aleaxit/gmpy#381 only in the development
version, so I have added simple workaround for this.
2023-10-18 15:34:25 +03:00
Sergey B Kirpichev afc990bb63 Add note about new int/str conversion limits
Closes #716
2023-10-18 15:34:25 +03:00
Sergey B Kirpichev 19f96fa5ae Fix mpc() constructor to be compatible with complex()
Closes #730
2023-10-18 15:34:25 +03:00
Sergey B Kirpichev b94825ed93 Merge pull request #724 from skirpichev/bernoulli-plus
Add plus flag to select the B_1 sign convention for bernoulli/bernfrac
2023-10-18 07:21:04 +03:00
Sergey B Kirpichev 2b48905aca Rephrase note on gmpy2 detection 2023-10-16 05:46:25 +03:00
Sergey B Kirpichev 551f2ccb36 Remove obsoleted note on upgrade 2023-10-16 05:46:25 +03:00
Sergey B Kirpichev 6c0bb28e7d Merge pull request #725 from skirpichev/misc
Misc fixes
2023-10-10 13:30:36 +03:00
Sergey B Kirpichev 8ea4580f6f Add 'ci': optional dependencies for CI with GA 2023-10-08 15:11:56 +03:00
Sergey B Kirpichev b08bf05d50 Skip --force-reinstall option for upgrade pip/setuptools 2023-10-08 15:08:53 +03:00
Sergey B Kirpichev 643cbd382b Revert "Downgrade to ubuntu-20.04 for Py35 and Py36"
This reverts commit 967de83d51.
2023-10-08 06:48:30 +03:00
Sergey B Kirpichev d775ccf7c3 Add regression test
Closes #723
2023-10-08 06:28:43 +03:00
Sergey B Kirpichev 21f791e4b6 Add `plus` flag to select the B_1 sign convention for bernoulli/bernfrac 2023-10-07 09:45:21 +03:00
Sergey B Kirpichev 005da6a704 Use functools.lru_cache for fp.bernoulli 2023-10-07 09:45:21 +03:00
Parcly Taxel 9a2863abe6 Change bernoulli(1) to +1/2
This commit is part of the project at
https://github.com/sympy/sympy/pull/23926

Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>

Adapted from #639
2023-10-07 09:44:52 +03:00
Sergey B Kirpichev a1d9bcb9ce Merge pull request #722 from skirpichev/misc
Misc fixes
2023-09-27 05:04:01 +03:00
Sergey B Kirpichev 7b55518b75 Depend on gmpy2>=2.2.0a1 for CPython>=3.12 2023-09-25 06:59:33 +03:00
Sergey B Kirpichev 59d433236a Add giant_steps() to libmp (SymPy import this function) 2023-09-25 05:43:43 +03:00
Sergey B Kirpichev 9d710d7c83 Amend 425858e 2023-09-25 05:41:41 +03:00
Sergey B Kirpichev 94c74827df Use isprime() alternatives from backends 2023-09-25 05:41:41 +03:00
Sergey B Kirpichev 0efc599422 Use lru_cache() in ifib() and eulernum() 2023-09-25 05:41:41 +03:00
Sergey B Kirpichev d928abb9ee Merge pull request #721 from skirpichev/use-bit_length
Use bit_length() method instead of bitcount()
2023-09-25 05:37:34 +03:00
Sergey B Kirpichev bca6942097 Remove inaccessible code in log_int_fixed() 2023-09-24 06:01:09 +03:00
Sergey B Kirpichev 50184a1926 Remove inaccessible code in isqrt_small_python() 2023-09-24 05:40:21 +03:00
Sergey B Kirpichev 76378d2082 Improve test coverage for mpci_gamma() 2023-09-24 05:17:52 +03:00
Sergey B Kirpichev c4c12908b7 Use n.bit_length() internally 2023-09-23 11:13:33 +03:00
Sergey B Kirpichev a6c793155b Simplify bitcount/trailing() functions
I.e. use n.bit_length() for all backends.
2023-09-23 11:13:09 +03:00
Sergey B Kirpichev 2990ec6d10 Merge pull request #717 from skirpichev/misc
Misc fixes
2023-09-23 05:22:21 +03:00
Sergey B Kirpichev d39e283659 Add coverage tests 2023-09-23 05:02:50 +03:00
Sergey B Kirpichev 39a3c48e8c Freeze numpy deps
See:
https://github.com/mpmath/mpmath/actions/runs/6272311680/job/17033610179?pr=717
with 1.26.
2023-09-22 12:17:46 +03:00
Sergey B Kirpichev 101320e477 Change type(foo)(bar) -> aproppriate ctx.mpf/ctx.mpc(bar) calls 2023-09-22 12:04:45 +03:00
Yclept Nemo 7c228c8797 Fix typo
// taken from #621
2023-09-22 12:04:35 +03:00
Christian Clauss b0e4a55ebf GitHub Actions: Upgrade to actions/checkout@v4 (#715)
* upgrade to actions/checkout@v4
* test on pypy3.10
2023-09-05 09:49:23 +03:00
Sergey B Kirpichev 21fe1e6a9a Merge pull request #667 from skirpichev/fix-440-pickle
Drop to_pickable()/from_pickable() helpers
2023-09-05 07:28:45 +03:00
Sergey B Kirpichev 48eef31f0b Drop to_pickable()/from_pickable() helpers
Without gmpy2:
    >>> import mpmath, pickle
    >>> pi = mpmath.pi
    >>> mpmath.mp.dps=100
    >>> a = mpmath.mpf(pi)
    >>> len(pickle.dumps(a))  # vs 147
    105

Fixes #440
2023-09-05 06:15:33 +03:00
Sergey B Kirpichev 91ccdd4a80 Merge pull request #610 from jan-philipp-hoffmann/pre_master
(Update on PR #543) Fixed TypeError in `LU_comp`, updated `determinant` docs and added `rank` function for matrices
2023-08-06 12:28:52 +03:00
Sergey B Kirpichev e87897a708 Merge pull request #713 from skirpichev/fix-712
Skip eigenvectors if left=right=False for one-dimentional matrix
2023-07-26 11:43:36 +03:00
Sergey B Kirpichev c7331400d5 Skip eigenvectors if left=right=False for one-dimentional matrix
Closes #712
2023-07-25 09:36:56 +03:00
Sergey B Kirpichev 88f26061a5 Merge pull request #710 from skirpichev/misc
Misc fixes
2023-06-27 12:17:55 +03:00
Sergey B Kirpichev c89342528f Fix typo in to_str() docstring 2023-06-27 11:49:54 +03:00
Sergey B Kirpichev 90446b3dd4 Fix disagreement fp.mod vs mp.mod
Special values are handled as described in Section F.9.7.1 of the ISO
C99 standard, see
https://www.mpfr.org/mpfr-current/mpfr.html#index-mpfr_005ffmod
or
https://en.cppreference.com/w/c/numeric/math/fmod

Closes #490
2023-06-26 07:45:23 +03:00
Sergey B Kirpichev c3009d5449 Add regression test
Closes #491
2023-06-26 06:09:42 +03:00
Sergey B Kirpichev 2c201304b2 Add regression test
Closes #510
2023-06-26 06:09:42 +03:00
Sergey B Kirpichev f4205c9dea Skip numpy/gmpy2 deps on CPython 3.12 2023-06-26 06:09:42 +03:00
Sergey B Kirpichev 8c09a45025 Drop flake8 WA on CPython 3.12 2023-06-26 06:09:42 +03:00
Sergey B Kirpichev 42a77be52d Merge pull request #527 from MaxGaukler/randmatrix
Support randmatrix() for mp.iv and mp contexts
2023-06-26 05:12:56 +03:00
Maximilian Gaukler 4bad21dd3e Support randmatrix() for mp.iv and mp contexts
To make this work correctly, rand() now supports arbitrary precision:

>>> x = mpmath.iv.rand() * mpmath.iv.convert(2**53)
>>> x - int(x)
mpi('0.0', '0.0')
>>> mpmath.iv.prec=1234
>>> x = mpmath.iv.rand() * mpmath.iv.convert(2**53)
>>> x - int(x)
mpi('0.05786680052076454587 ...
2023-06-10 22:08:10 +02:00
Sergey B Kirpichev e745906eb3 Merge pull request #703 from skirpichev/misc
Misc fixes
2023-06-05 12:16:25 +03:00
Benjamin Fischer 91b0cecf2b improved hypsum non-convergence behaviour
This change includes two hypsum related fixes:

1) It turns the ValueError exception, raised in mp.hypsum when encountering
convergence problems, into a more appropriate NoConvergence exception - just as
fp.hypsum does already.

2) It properly handles this NoConvergence exception withing the "fast path" of
hyp2f1. The same behavior is already used in the "fast path"s of _hyp2f0,
_hypq1fq, and _hyp_borel - and was broken since hypsum never raised the
expected NoConvergence exception (in the mp context). Similar to _hyp2f0, this
behavior can be suppressed with the keyword argument force_series=True.

Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>

Coverage tests added.
2023-06-03 14:33:49 +03:00
Sergey B Kirpichev db7373c54b Add legacy import of private mpnumeric class to the ctx_mp module
Address #704
2023-06-03 14:33:49 +03:00
Sergey B Kirpichev 8f7810f845 Correct bin_to_radix() docstring
Co-authored-by: Jonathan Warner <warnerjon12@gmail.com>
2023-06-03 14:33:48 +03:00
Sergey B Kirpichev 560f81e5db Support base kwarg for from_str()
base=2**n and base=10 are supported so far.  float(), float.fromhex()
and MPFR's style (see mpfr_strtofr() function) string formats are
accepted.  to/from_bstr() undocumented helper functions were removed.

Partially taken from #414.

Co-authored-by: Jonathan Warner <warnerjon12@gmail.com>
2023-06-03 14:33:48 +03:00
sonntagsgesicht 7b59bb8248 rank function (with tests)
update imports in test_linalg.py

custom `iszerofunc` in rank determination

adding rank of matrix via counting eigenvalues form svd_r
2023-06-02 08:20:56 +02:00
sonntagsgesicht 0347d87598 determinant documentation 2023-06-01 08:37:42 +02:00
sonntagsgesicht b84cedebce use pytest.raises to test exception 2023-06-01 08:37:42 +02:00
sonntagsgesicht 1868261e8b fixing issue: Determinant issue inside of LU_decomp 2023-06-01 08:37:42 +02:00
sonntagsgesicht 556f34b47f add PyCharm files to .gitignore 2023-06-01 08:37:32 +02:00
sonntagsgesicht 79d99ff700 fixing: Determinant function raises TypeError on simple matrix #542 2023-06-01 08:36:55 +02:00
Sergey B Kirpichev 79f6d11c99 Merge pull request #706 from skirpichev/3.12
Enable testing on CPython 3.12-dev
2023-05-31 06:17:32 +03:00
Sergey B Kirpichev 319a2ac20c Enable testing on CPython 3.12-dev 2023-05-31 05:57:24 +03:00
Sergey B Kirpichev f81596935b Merge pull request #702 from skirpichev/no-meta-in-_mpf
Avoid dynamic method creation in _mpf
2023-05-21 07:36:14 +03:00
Sergey B Kirpichev 0f00f3b594 Restore 100% test coverage on mpmath/ctx_mp_python.py 2023-05-21 06:53:22 +03:00
Sergey B Kirpichev 4c5f0e47ac Merge branch 'master' into no-meta-in-_mpf 2023-05-21 06:50:02 +03:00
Sergey B Kirpichev f07b155ea0 100% test coverage for patch, simplify _mpf.__mod__() 2023-05-21 06:49:17 +03:00
Sergey B Kirpichev 27bfab2b00 Merge pull request #692 from skirpichev/ctx_fp-stdlib
Change FPContext to use more functions from the stdlib
2023-05-19 18:03:00 +03:00
Sergey B Kirpichev c11c4c9881 Use a different argument value for the fp.erfc example
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.
2023-05-19 17:28:16 +03:00
Sergey B Kirpichev f240905dde Rename mpmath/math2.py -> mpmath/libfp.py
Closes #211
2023-05-19 17:28:14 +03:00
Sergey B Kirpichev 6bd28250fd Change FPContext to use more functions from the stdlib
* 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
2023-05-19 17:27:17 +03:00
Sergey B Kirpichev 4477775d0f Merge pull request #691 from skirpichev/rationals-from-backend
Drop private mpq class, use Rational's, provided by backend
2023-05-19 07:22:38 +03:00
Sergey B Kirpichev 920d8ed3e7 Drop micro-optimizations for small rational constants 2023-05-19 07:03:11 +03:00
Sergey B Kirpichev 0efdfeb7cd Drop ctx._mpq 2023-05-19 07:03:11 +03:00
Sergey B Kirpichev ef8e49a2b5 ctx.mpq -> ctx._mpq 2023-05-19 07:03:11 +03:00
Sergey B Kirpichev 744d44483d Rename rational constants (to be private) 2023-05-19 07:03:11 +03:00
Sergey B Kirpichev 721e2571eb Drop private mpq class, use Rational's provided by backend 2023-05-19 07:03:11 +03:00
Sergey B Kirpichev 8c4256c0d2 Drop _mpc.__div__/__rdiv__ magic methods (py2) 2023-05-19 06:17:52 +03:00
Sergey B Kirpichev 16d5d393b3 Avoid runtime creation of _mpf.__pow__() 2023-05-19 06:17:52 +03:00
Sergey B Kirpichev 7b3b10438d Avoid runtime creation of _mpf.__mod__() 2023-05-19 06:17:52 +03:00
Sergey B Kirpichev 5e0230f268 Avoid runtime creation of _mpf.__truediv__() 2023-05-19 06:17:52 +03:00
Sergey B Kirpichev e6437c567e Avoid runtime creation of _mpf.__mul__() 2023-05-19 06:17:52 +03:00
Sergey B Kirpichev 5f55fc9f27 Avoid runtime creation of _mpf.__add/sub__() 2023-05-19 06:17:52 +03:00
Sergey B Kirpichev 7d2a2cfdfa Avoid runtime creation of _mpf.__eq__(), drop redundant __ne__() 2023-05-19 06:17:52 +03:00
Sergey B Kirpichev f6066b2683 Merge pull request #701 from skirpichev/misc
Misc fixes
2023-05-19 06:13:58 +03:00
Sergey B Kirpichev 0549c5c4b7 libmpf.py: avoid extra int() typecasts 2023-05-19 05:57:11 +03:00
Sergey B Kirpichev a482c223f2 Drop normalize1(), as for non-python backends 2023-05-19 05:57:11 +03:00
Sergey B Kirpichev 91d93009eb 100% test coverage for mpmath/ctx_mp_python.py 2023-05-19 05:57:11 +03:00
Sergey B Kirpichev 42730bbf97 Unfreeze setuptools deps 2023-05-18 14:25:27 +03:00
Sergey B Kirpichev d2978522be Drop PythonMPContext.isnan() (overriden) 2023-05-18 14:25:27 +03:00
Sergey B Kirpichev c95827c5eb Drop _mpc.__lt__() and friends (redundant) 2023-05-18 14:25:27 +03:00
Sergey B Kirpichev 68c01b251a Drop _mpf.__cmp__ magic (py2) 2023-05-18 14:25:27 +03:00
Sergey B Kirpichev df98a7d76b Drop redundant _mpc.__ne__() 2023-05-18 14:25:27 +03:00
Sergey B Kirpichev 96e66fc074 Default file encoding is utf-8 for py3... 2023-05-18 14:25:27 +03:00
Sergey B Kirpichev 1531f23a90 Drop pre-sphinx documentation stuff 2023-05-18 14:25:27 +03:00
Sergey B Kirpichev d94b33281e Drop namespace checks for old (<2) gmpy versions 2023-05-18 14:25:25 +03:00
Sergey B Kirpichev 337416b68c Unify gmpy_mpf_mul and python_mpf_mul (both use BACKEND-dependent bitcount) 2023-05-18 14:25:00 +03:00
Sergey B Kirpichev ec4f8f1e18 Enabled flake8 E501 2023-05-18 08:29:58 +03:00
Sergey B Kirpichev 3414c6ec51 Fix flake8 F401 in ctx_*.py (not for imports for mpf_binary_op) 2023-05-18 08:29:53 +03:00
Sergey B Kirpichev 598be4283f Fix flake8 F401 in tests (not for test_extra_gamma.py) 2023-05-18 08:29:46 +03:00
Sergey B Kirpichev b61482fa48 Merge pull request #700 from skirpichev/no-B_1-in-bernpoly-and-eulerpoly
Rewrite bernpoly/eulerpoly to avoid dependency on bernoulli(1) convention
2023-05-12 09:25:13 +03:00
Sergey B Kirpichev f46ce686a7 Rewrite bernpoly/eulerpoly to avoid dependency on bernoulli(1) convention
Also removed comment in the bernpoly (this "slow implementation"
is also imprecise).
2023-05-12 07:24:44 +03:00
Sergey B Kirpichev 8ed001c150 Merge pull request #697 from skirpichev/imath-backend
Use gcd() from the bigint' backend
2023-05-11 11:52:27 +03:00
Sergey B Kirpichev 80ed6b4504 Use ifac, ifac2 and ifib from the BACKEND
Apply caching with lru_cache of ifac for all backends.
2023-05-11 08:37:06 +03:00
Sergey B Kirpichev 47420963b5 Drop unused import 2023-05-11 07:05:47 +03:00
Sergey B Kirpichev 9f35e1407b Use backend's gcd(), e.g. math.gcd instead of pure-python Euclidean algorithm 2023-05-11 07:05:45 +03:00
haru-44 25c60dd91c Use math.isqrt, if the python version is 3.12 or higher (#695) 2023-05-10 15:00:21 +03:00
Sergey B Kirpichev 9f5ed60437 Merge pull request #699 from skirpichev/misc
Misc fixes
2023-05-10 13:42:39 +03:00
Sergey B Kirpichev 8bc087eea2 Drop workarounds for old gmpy versions in libintmath.py 2023-05-10 09:35:58 +03:00
Sergey B Kirpichev f4dba4a88d Fix few more py2 remnants
izip vs zip, next, str vs unicode, long vs int
2023-05-10 09:35:22 +03:00
Sergey B Kirpichev fe1efdf8c1 py3 nitpick: intern() was moved to the sys module 2023-05-10 09:13:52 +03:00
Sergey B Kirpichev 1327aafa82 Merge pull request #698 from skirpichev/no-star-imports
Avoid using star imports in tests and documentation
2023-05-10 09:04:11 +03:00
Sergey B Kirpichev 6390a47af2 Merge pull request #690 from skirpichev/nan-and-pow
Correct pow() for mpf's to be consistent with mpfr/float's
2023-05-10 08:47:24 +03:00
Sergey B Kirpichev c2f604d492 Avoid star-imports in the tutorial 2023-05-09 07:27:20 +03:00
Sergey B Kirpichev da36d96055 Reorganize imports in docs/ (no star imports) 2023-05-09 07:27:20 +03:00
Sergey B Kirpichev e96cf85130 Reorganize imports in demo/ (no star imports) 2023-05-09 07:27:20 +03:00
Sergey B Kirpichev 5ec9d07dee Reorganize imports in doctests (no star imports) 2023-05-09 07:27:20 +03:00
Sergey B Kirpichev 6d3b2bd8f0 Reorganize imports in mpmath/tests/test_extra_gamma.py (no star imports) 2023-05-09 07:27:20 +03:00
Sergey B Kirpichev 5a56e5c56a Reorganize imports in mpmath/tests/test_torture.py (no star imports) 2023-05-09 07:27:20 +03:00
Sergey B Kirpichev 040647d286 Reorganize imports in mpmath/tests/test_functions2.py (no star imports) 2023-05-09 07:27:20 +03:00
Sergey B Kirpichev b5df88b33b Reorganize imports in mpmath/tests/test_functions.py (no star imports) 2023-05-09 07:27:20 +03:00
Sergey B Kirpichev adf77b4b80 Reorganize imports in mpmath/tests/test_interval.py (no star imports) 2023-05-09 07:27:20 +03:00
Sergey B Kirpichev 6696e589d5 Reorganize imports in mpmath/tests/test_trig.py (no star imports) 2023-05-09 07:27:20 +03:00
Sergey B Kirpichev 9c4701c256 Reorganize imports in mpmath/tests/test_mpmath.py (no star imports) 2023-05-09 07:27:20 +03:00
Sergey B Kirpichev 74e9106c63 Reorganize imports in mpmath/tests/test_identify.py (no star imports) 2023-05-09 07:27:20 +03:00
Sergey B Kirpichev 1f877ca90e Reorganize imports in mpmath/tests/test_matrices.py (no star imports) 2023-05-09 07:27:20 +03:00
Sergey B Kirpichev 7b3c3e690f Reorganize imports in mpmath/tests/test_linalg.py (no star imports) 2023-05-09 07:27:19 +03:00
Sergey B Kirpichev c5a6278664 Reorganize imports in mpmath/tests/test_rootfinding.py (no star imports) 2023-05-09 07:27:19 +03:00
Sergey B Kirpichev 385a3c86ad Reorganize imports in mpmath/tests/test_summation.py (no star imports) 2023-05-09 07:27:19 +03:00
Sergey B Kirpichev a26d24ca74 Reorganize imports in mpmath/tests/test_power.py (no star imports) 2023-05-09 07:27:19 +03:00
Sergey B Kirpichev 74a34c4ec3 Reorganize imports in mpmath/tests/test_compatibility.py (no star imports) 2023-05-09 07:27:19 +03:00
Sergey B Kirpichev 1e7af36e76 Reorganize imports in mpmath/tests/test_convert.py (no star imports) 2023-05-09 07:27:19 +03:00
Sergey B Kirpichev 9ad8be0030 Reorganize imports in mpmath/tests/test_elliptic.py (no star imports) 2023-05-09 07:27:19 +03:00
Sergey B Kirpichev 90b373c7a7 Reorganize imports in mpmath/tests/test_quad.py (no star imports) 2023-05-09 07:27:19 +03:00
Sergey B Kirpichev faa48a590c Reorganize imports in mpmath/tests/test_fp.py (no star imports) 2023-05-09 07:27:19 +03:00
Sergey B Kirpichev cfbc8a442d Reorganize imports in mpmath/tests/test_gammazeta.py (no star imports) 2023-05-09 07:27:19 +03:00
Sergey B Kirpichev 0c72891aab Reorganize imports in mpmath/tests/test_special.py (no star imports) 2023-05-09 07:27:19 +03:00
Sergey B Kirpichev 84fd814a48 Reorganize imports in mpmath/tests/test_diff.py (no star imports) 2023-05-09 07:27:19 +03:00
Sergey B Kirpichev ea7afcec7c Reorganize imports in mpmath/tests/test_hp.py (no star imports) 2023-05-08 10:04:05 +03:00
Sergey B Kirpichev 6db5b89902 Reorganize imports in mpmath/tests/test_calculus.py (no star imports) 2023-05-08 10:04:05 +03:00
Sergey B Kirpichev 6153f3a96c Reorganize imports in mpmath/tests/test_bitwise.py (no star imports) 2023-05-08 10:04:05 +03:00
Sergey B Kirpichev 88a2deb7e2 Reorganize imports in mpmath/tests/test_basic_ops.py (no star imports) 2023-05-08 10:04:05 +03:00
Sergey B Kirpichev 84f5d55b56 Initial isort config 2023-05-08 10:04:05 +03:00
Sergey B Kirpichev 29b47ce9af Merge pull request #687 from skirpichev/misc
Misc fixes
2023-05-08 10:01:36 +03:00
Sergey B Kirpichev 8b49d02a2a Simplify pickling tests, test more protocols 2023-05-08 08:32:34 +03:00
Sergey B Kirpichev 5efb2d0272 Add regression tests
Closes #506
2023-05-07 10:37:37 +03:00
Sergey B Kirpichev 3e987b1ad6 Expose mpmath.lu_solve docstring in the sphinx docs
Closes #644
2023-04-30 08:54:51 +03:00
Sergey B Kirpichev fda71a8ee3 Drop doctest:+SKIP pragmas, where possible 2023-04-30 08:54:51 +03:00
Sergey B Kirpichev 945ca7c281 Add doctest:+ELLIPSIS 2023-04-30 08:54:49 +03:00
Sergey B Kirpichev 2ff65f5492 Drop useless doctest: +IGNORE_EXCEPTION_DETAIL (default) 2023-04-30 08:54:20 +03:00
Sergey B Kirpichev 0c1a5d4f44 Fix sphinx warnings with nitpicky=True
Closes #627
2023-04-30 08:54:20 +03:00
Sergey B Kirpichev d11bc6d12a Port extratest_gamma.py to pytest framework 2023-04-30 08:54:20 +03:00
Sergey B Kirpichev 82c2fc4c84 Test strict_normalize*() helpers 2023-04-30 08:54:20 +03:00
Sergey B Kirpichev 6313451edc Port extratest_zeta.py to pytest framework 2023-04-30 08:54:20 +03:00
Sergey B Kirpichev 1b1faae393 Port torture.py to pytest framework 2023-04-30 08:54:20 +03:00
Sergey B Kirpichev 2c754f7a5d Add --durations=20 for pytest 2023-04-30 08:54:18 +03:00
Sergey B Kirpichev fb7ff23c52 Drop workaround for old gmpy2<2.1.0a1 (mpz was a factory function) 2023-04-30 08:53:44 +03:00
Sergey B Kirpichev c492e80805 Drop workaround for gmpy 1.x (we require gmpy2>=2.1.0a4 anyway) 2023-04-30 08:53:44 +03:00
Sergey B Kirpichev e488fb2bef Add pytest_report_header() 2023-04-30 08:53:44 +03:00
Sergey B Kirpichev 088e27eca1 Drop runtests.py and doctests() function
We use pytest for tests, it has everything that runtests.py has,
including support for profiling (pytest-profiling plugin).

So, let's drop this legacy stuff to avoid bugs like #579.
2023-04-30 08:53:44 +03:00
Sergey B Kirpichev 035d9e33b1 Fix README.rst (mention GA instead of Travis CI) 2023-04-30 08:53:44 +03:00
Sergey B Kirpichev 240d31d988 Correct pow() for mpf's to be consistent with mpfr/float's
Before nan's were handled differently than described in
the IEEE 754 standard.  Now, as for float's or gmpy2.mpfr's:
  * pow(1, y) returns 1 for any y, even a nan
  * pow(x, 0) returns 1 for any x, even a nan

Closes #516

See also:
https://en.cppreference.com/w/c/numeric/math/pow
https://www.mpfr.org/mpfr-current/mpfr.html#index-mpfr_005fpow
https://docs.python.org/3/library/math.html#math.pow
2023-04-30 08:50:58 +03:00
Sergey B Kirpichev c161da2068 Merge pull request #693 from skirpichev/rtests
Add regression tests
2023-04-30 08:44:21 +03:00
Sergey B Kirpichev 832bac0491 Merge pull request #684 from skirpichev/pyproject
Use pyproject.toml, depend on flake518, update __version__
2023-04-30 08:41:45 +03:00
Sergey B Kirpichev ecc5cdc355 Update mpmath.__version__
Closes #682
2023-04-30 08:04:08 +03:00
Sergey B Kirpichev 558cc0e6c0 Add regression tests
Closes #508
2023-04-30 07:44:17 +03:00
Sergey B Kirpichev 232bd58aae Add regression tests
Closes #509
2023-04-30 07:44:17 +03:00
Sergey B Kirpichev 3cb24249c3 Add pyproject.toml, depend on flake518 instead of pycodestyle
* run flake8 only for python-version >= 3.9
* remove MANIFEST.in (not needed anymore)
2023-04-29 11:50:47 +03:00
Sergey B Kirpichev d6913249b9 Merge pull request #688 from skirpichev/fix-nan
Fix nan handling in fp.mag() and hyper()
2023-04-28 07:43:10 +03:00
Sergey B Kirpichev 154e67bada Correct fp.mag(nan): return nan like mp.mag() 2023-04-21 14:50:27 +03:00
Sergey B Kirpichev 3e23967fda Add a quick exit for z==nan in hyper(),
Closes #485
Closes #479
Closes #507
Closes #489
Closes #488
Closes #478
2023-04-21 14:17:31 +03:00
Sergey B Kirpichev b37a5ec927 Merge pull request #685 from skirpichev/xdist
Run CI tests with pytest-xdist
2023-04-21 03:24:19 +03:00
Sergey B Kirpichev 57efbdc101 Drop resetting globals (mp.prec and so on) in doctests 2023-04-20 12:55:47 +03:00
Sergey B Kirpichev dbd06163a4 Drop resetting globals (mp.prec and so on) in tests 2023-04-20 12:05:49 +03:00
Sergey B Kirpichev 31381da358 Run CI tests with pytest-xdist
conftest.py moved to enable reset_mp_globals() fixture for doctests

Closes #99
2023-04-20 11:23:45 +03:00
Sergey B Kirpichev 24613379c6 Merge pull request #689 from skirpichev/fix-318
Raise IndexError if matrix index out of bounds
2023-04-20 06:39:07 +03:00
Sergey B Kirpichev a9637115e5 Raise IndexError if matrix index out of bounds
Closes #318
2023-04-20 06:21:21 +03:00
Tyler Chen ae610886c2 update generator used for sparse matrix vector product (#450) 2023-04-20 05:47:32 +03:00
Sergey B Kirpichev d100a89b4c Merge pull request #679 from skirpichev/misc
Misc fixes
2023-04-16 08:42:32 +03:00
Sergey B Kirpichev cd6dbcd772 Add MANIFEST.in
Closes #428
2023-04-16 06:34:10 +03:00
Devharsh Trivedi db7c250d34 Create CITATION.bib (#681)
Closes #680
2023-04-15 08:22:48 +03:00
Sergey B Kirpichev 425858e06b Add regression test
Closes #274
2023-04-07 10:15:12 +03:00
Sergey B Kirpichev c7690bbc45 Accept mpf('.00'), like float/Decimal
Closes #377
2023-04-07 10:03:59 +03:00
Sergey B Kirpichev bbe1ca6845 Add regression tests
Closes #539
2023-04-07 09:32:55 +03:00
Sergey B Kirpichev 0b9bca5517 Merge pull request #675 from skirpichev/drop-old-py3
Drop support for Python versions < 3.8
2023-04-06 10:08:05 +03:00
Sergey B Kirpichev 1bcb19776d Add numpy deps (for testing), reorganize compatibility tests 2023-04-04 12:41:36 +03:00
Sergey B Kirpichev 867c7a04c1 Catch AttributeError in matrix.__eq__ to return NotImplemented
Closes #283
2023-04-04 12:31:11 +03:00
Sergey B Kirpichev 6770d15c21 Add regression test
Closes #267
2023-04-04 12:00:39 +03:00
Sergey B Kirpichev 98c48faf58 Merge pull request #674 from skirpichev/coverage-action
Use codecov/codecov-action
2023-04-03 01:24:17 +03:00
Sergey B Kirpichev 99d650a3a7 Run doctests in mpmath/libmp/gammazeta.py 2023-04-02 06:12:11 +03:00
Sergey B Kirpichev f37c5d87ba Update uploading to the PyPI (run on 3.11 and use recommended version) 2023-04-02 04:17:10 +03:00
Sergey B Kirpichev bd46981e99 Run doctests in mpmath/matrices/linalg.py (adjust doctest for iv.matrix) 2023-04-02 04:16:57 +03:00
Sergey B Kirpichev cbcc9e8575 Run doctests in mpmath/calculus/quadrature.py 2023-04-02 04:16:57 +03:00
Sergey B Kirpichev df73f1de51 Optimize test workflow (e.g. don't run both coverage & regular tests) 2023-04-02 04:16:56 +03:00
Sergey B Kirpichev 8df4ff06ad Use codecov/codecov-action 2023-04-02 04:12:55 +03:00
Sergey B Kirpichev d4b4ff08e4 Merge pull request #673 from skirpichev/fix-373-odefun
Correct odefunc() docstring
2023-04-02 03:18:04 +03:00
Sergey B Kirpichev 057479e2ca Drop support for Python versions < 3.8
Closes #663
2023-03-30 06:00:33 +03:00
Sergey B Kirpichev 70f1efbf19 Amend 4f71a1b 2023-03-30 05:37:02 +03:00
Sergey B Kirpichev 86506049bf Merge pull request #672 from skirpichev/ei_asympt-nan
Propagate nan in ei_asymp()
2023-03-30 05:15:21 +03:00
Sergey B Kirpichev 55e9e2a0a2 Merge pull request #670 from skirpichev/fix-584-setup-and-docs
Fix docs (README.rst and setup.rst)
2023-03-30 05:13:26 +03:00
Sergey B Kirpichev 598627488d Merge branch 'master' into fix-584-setup-and-docs 2023-03-30 04:53:15 +03:00
Fangchen Li dfc289289d Drop py2 support (#629)
* remove xrange compat shim
* remove str compat shim
* remove exec compat shim
* remove object from class defination
* remove misc workarounds for python versions <3.5
* remove __future__ imports
* update readme
* Update setup.cfg

Closes #594

Co-authored-by: Fredrik Johansson <fredrik.johansson@gmail.com>
Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
Co-authored-by: Colin B. Macdonald <cbm@m.fsf.org>
2023-03-30 04:50:18 +03:00
Sergey B Kirpichev e678d57eba Correct odefunc() docstring
Closes #373
2023-03-29 10:43:22 +03:00
Sergey B Kirpichev 064e9400bf Propagate nan in ei_asymp()
Closes #480
Closes #481
Closes #482
Closes #483
Closes #484
Closes #487
2023-03-29 08:41:33 +03:00
Sergey B Kirpichev b2301fbabe Warn about Python's true division
Closes #632
2023-03-28 11:10:41 +03:00
Sergey B Kirpichev c60f506df1 Merge branch 'master' into fix-584-setup-and-docs 2023-03-28 11:10:20 +03:00
Sergey B Kirpichev 41df8c5a21 Merge pull request #666 from skirpichev/fix-465-ratconv
Add rationals converter for mpf()
2023-03-28 10:31:25 +03:00
Christian Clauss 6489ed3bc1 Fix pycodestyle errors E703, E712, E713 (#665) 2023-03-28 10:29:30 +03:00
Sergey B Kirpichev 52a6a70d3c sphinx's setuptools integration is deprecated since v5.0 2023-03-27 06:45:35 +03:00
Sergey B Kirpichev 4f71a1b7ab Update setup instructions 2023-03-27 06:44:37 +03:00
Sergey B Kirpichev 3ab0f5b42a Update README.rst
Closes #584
2023-03-27 06:08:14 +03:00
Sergey B Kirpichev 57c740db3a Require python version >= 3.6 for gmpy2 (wheels available) 2023-03-27 05:54:28 +03:00
Jeremy Tan Jie Rui f55cd4ff3b Add regression test
Closes #647 (fixed by f3bb6db)
2023-03-26 21:36:21 +03:00
Sergey B Kirpichev 998b662e37 Merge pull request #661 from skirpichev/fix-613
Support underscores (PEP 515)
2023-03-26 14:40:23 +03:00
Sergey B Kirpichev 1fbdd01efd Merge pull request #664 from skirpichev/misc
Misc fixes
2023-03-26 10:01:56 +03:00
Sergey B Kirpichev 573fa90547 Expose some docstrings (e.g. for bernoulli) 2023-03-26 09:21:59 +03:00
Sergey B Kirpichev fa217f8e14 Add .readthedocs.yaml 2023-03-26 06:02:54 +03:00
Sergey B Kirpichev 0249d97d28 Add rationals converter for mpf()
Closes #465
2023-03-26 04:34:37 +03:00
Fangchen Li cb08f2200f Add pytest's option testpaths
Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
2023-03-26 03:43:13 +03:00
Sergey B Kirpichev 5a4dc36c33 Fix rest of links to the repo 2023-03-25 12:37:36 +03:00
Sergey B Kirpichev b53b924c99 Update copyright years 2023-03-25 12:33:45 +03:00
Sergey B Kirpichev aa33d7765b Clarify power() docs
Fixes #587
2023-03-25 12:32:24 +03:00
Sergey B Kirpichev 373bdd6da7 Trivial fix in betainc() for x1==x2
Closes #569
2023-03-25 12:31:36 +03:00
Sergey B Kirpichev f051d33ea1 Trivial fix for sum_accurately (initialize sum_mag)
Fixes #604
2023-03-25 12:30:35 +03:00
Sergey B Kirpichev 8876b3e5eb Merge pull request #662 from skirpichev/fix-595
Restore testing doctests/docs on CI (broken by #537)
2023-03-25 12:28:15 +03:00
Sergey B Kirpichev f72cdbf218 Add more pypy versions 2023-03-25 12:10:21 +03:00
Sergey B Kirpichev 91b536a9ed pytest -> pytest docs mpmath 2023-03-25 12:10:21 +03:00
Sergey B Kirpichev 3d381b9f8b Ignore some files with doctests entirely
* mpmath/calculus/quadrature.py
* mpmath/matrices/linalg.py

Probably, due to 7123a67 and #409

* mpmath/libmp/gammazeta.py
2023-03-25 12:09:55 +03:00
Sergey B Kirpichev 91f3eefe38 Restore testing doctests/docs on CI (broken by #537)
Corrects also pytest configuration after moving docs (#582)

Fixes #595
2023-03-25 10:31:41 +03:00
Sergey B Kirpichev 9585bb95f1 Support underscores (PEP 515)
Closes #613
2023-03-25 10:15:57 +03:00
Fredrik Johansson f93f2b2f3f Merge pull request #660 from skirpichev/patch-1
Point README.rst badges to the new repo
2023-03-25 05:55:49 +01:00
Sergey B Kirpichev f530d5ed20 Point README.rst badges to the new repo 2023-03-25 07:41:36 +03:00
Fredrik Johansson b5c04506ef version 1.3.0
test / build (2.7) (push) Has been cancelled
test / build (3.10) (push) Has been cancelled
test / build (3.11) (push) Has been cancelled
test / build (3.5) (push) Has been cancelled
test / build (3.6) (push) Has been cancelled
test / build (3.7) (push) Has been cancelled
test / build (3.8) (push) Has been cancelled
test / build (3.9) (push) Has been cancelled
test / build (pypy2.7) (push) Has been cancelled
test / build (pypy3.9) (push) Has been cancelled
2023-03-07 17:43:16 +01:00
Fredrik Johansson a27581ca77 Merge pull request #656 from cclauss/patch-2
GitHub Actions: Test on Python 3.11 production release
2023-03-07 11:45:10 +01:00
Fredrik Johansson 9d7884bf96 don't use .ae method in library code 2023-01-10 11:54:27 +01:00
Christian Clauss 967de83d51 Downgrade to ubuntu-20.04 for Py35 and Py36 2023-01-05 10:06:37 +01:00
Christian Clauss 6425c6aa41 build: strategy: fail-fast: false 2023-01-05 09:55:02 +01:00
Christian Clauss e2341c762e GitHub Actions: Test on Python 3.11 production release 2022-12-28 15:21:11 +01:00
Fredrik Johansson 1258e33e16 fix failing doctests 2022-11-07 11:27:20 +01:00
Fredrik Johansson b7c15d668c include signals documentation; remove duplicate docstrings 2022-11-07 10:43:28 +01:00
Fredrik Johansson 1b476ea230 update doc building instructions 2022-11-07 10:34:24 +01:00
Fredrik Johansson 5f57beb1e3 Merge pull request #646 from cclauss/patch-1
Syntax Error: exec() is a function in Python 3
2022-09-06 12:04:03 +02:00
Christian Clauss c5da3b84f2 Syntax Error: exec() is a function in Python 3
https://docs.python.org/2/reference/simple_stmts.html#exec
https://docs.python.org/3/library/functions.html#exec
2022-09-06 11:46:55 +02:00
Fredrik Johansson 254f2086ee Merge pull request #645 from cclauss/patch-1
Test on Python 3.11 release candidate
2022-09-06 10:49:55 +02:00
Christian Clauss ee0735ad5f '3.10', 3.11-dev, pypy2.7, pypy3.9 2022-09-06 10:08:51 +02:00
Christian Clauss ab733d2793 '3.10' must be in quotes in YAML 2022-09-06 10:06:04 +02:00
Christian Clauss bf26007f39 Test on Python 3.11 release candidate
https://www.python.org/download/pre-releases
> The [Faster CPython Project](https://github.com/faster-cpython/) is already yielding some exciting results. Python 3.11 is up to **10-60% faster** than Python 3.10. On average, we measured a **1.22x speedup** on the standard benchmark suite. See [Faster CPython](https://docs.python.org/3.11/whatsnew/3.11.html#faster-cpython) for details.
2022-09-06 10:04:29 +02:00
Fredrik Johansson aa818c78c4 Merge pull request #606 from paulmasson/patch-1
Streamline Carlson algorithms
2022-08-23 15:30:26 +02:00
Fredrik Johansson 3b5d1b00a8 Merge pull request #599 from WarrenWeckesser/det-doc
DOC: Include det in matrices.rst
2022-08-23 15:16:44 +02:00
Fredrik Johansson c45da08456 Merge pull request #611 from c-f-h/master
Support QR for matrices of width 0 and 1
2022-08-23 15:14:12 +02:00
Fredrik Johansson 43868ddd07 Merge pull request #624 from warnerjon12/master
Added test options and small mpf hash fix
2022-08-23 15:13:37 +02:00
Fredrik Johansson ce7637d47f Merge pull request #643 from HPQC-LABS/master
Added Version 1.2.0 (February 2021) to README.rst
2022-08-23 10:30:17 +02:00
Nike Dattani b8ab8c84bd Added Version 1.2.0 (February 2021) to README.rst 2022-08-22 18:59:13 -04:00
Fredrik Johansson 356786e545 Merge pull request #642 from WarrenWeckesser/cleanup-inverselaplace
Some PEP-8 clean up in inverselaplace.py
2022-08-22 21:23:52 +02:00
warren f7c51fb21d Some PEP-8 clean up in inverselaplace.py 2022-08-22 15:17:28 -04:00
Fredrik Johansson 3e5e2ef05d Merge pull request #620 from guillermo-navas-palencia/master
Faster numerical inverse Laplace transform
2022-08-22 18:23:59 +02:00
Fredrik Johansson 17aa7a2a77 Merge pull request #640 from HPQC-LABS/squash_rebase
Added the signal functions: square wave, triangle wave, sawtooth wave, and logistic sigmoid in signals.py and Sphinx documentation code in signals.txt
2022-08-22 18:20:13 +02:00
Deyan Mihaylov 7cd161aef0 Add wrappers and fix documentation 2022-08-22 02:30:21 +02:00
Tina Yu d0135b941f The following things:
Adjusted function parameters to include an independent variable, t. Added other variations of each wave function. For square wave, added functions "squarew_floor" and "squarew_floorex". For triangle wave, added "trianglew_saw" function. For sawtooth, added functions "sawtoothw_mod" and "sawtoothw_floor".

The following things:
Added definitions, descriptions, and examples to functions "squarew", "squarew_floor", "squarew_floorex", "trianglew", "trianglew_saw", "sawtoothw", "sawtoothw_mod", "sawtooth_floor". Also added order of increasing run time for each type of signal wave.

Added logistic sigmoid function to signal.py file as well as the signal.txt file. Corrected examples in the signal.py file so that the period of each example is 2. Also, the last example of each function was correct so that input parameter t is 2 rather than 1.

Fixed typo from squarew_floorex to squarew_floor_ex

Tested the run time of all functions using 200 dps with t = 1.111111... Results were written under each function, giving both the function's return value as well as the run times.

Added type hints to all functions.

Added test file for signal.py.

Added unit triangle function to signal.txt and signal.py. Also added type hints to signal.txt and corrected sigmoid function in signal.py.

Added back signal.txt.

Changed signal files to be named signals.py and signals.txt.

Added unit triangle to test.py and fixed minor typos in docstrings.

Added 'triangle_wave' and 'sawtooth_wave'. Corrected sawtooth functions.

Removed extra wave functions and named remaining functions as squarew, trianglew, and sawtoothw. Added minor edits to function docstrings.

Removed test.py.

Corrected arguments to match those in signals.py.

Changed 'return 0' to 'return ctx.zero' and changed 'sigmoidw' to 'sigmoid'. Also changed 'signals.txt' to an rst file to match original repository.
2022-08-19 00:53:33 +02:00
Nike Dattani 26ed58a096 Added signal.txt with basic "template" including:
square wave, triangle wave, sawtooth wave as a function of amplitude and period, but with really just meant as a template (largely copied from bessel.txt) from which Tina can do her work.

Added the following to mpmath/__init__.py

squarew = mp.squarew
trianglew = mp.trianglew
sawtoothw = mp.sawtoothw
unit_triangle = mp.unit_triangle
sigmoidw = mp.sigmoidw

This block was added to the bottom of the list of functions which began with "sqrt = mp.sqrt" and went up to "stirling2 = mp.stirling2".
2022-08-19 00:51:37 +02:00
Jonathan Warner e2eaabd0ba Added options to runtests.py to skip tests and exit on failure plus small fix
runtests.py -skip ... can be used to skip test modules
  testit(..., exit_on_fail=True) will return if a test fails
  fixed a bug causing mpf values to return -1 hash rather than -2
2022-04-11 16:55:03 -06:00
GUI 9ce1a049cc Implementation of the Cohen algorithm for numerical inversion of the Laplace transform 2022-02-20 20:50:45 +01:00
fredrik fcc7e53362 polylog: fix for integer-valued parameter with complex type 2022-02-14 11:34:07 +01:00
fredrik 2bc6bd63dc Merge branch 'master' of github.com:fredrik-johansson/mpmath 2022-02-14 09:52:02 +01:00
fredrik f3bb6dbb76 fix issue #534: digamma hangs for some complex input 2022-02-14 09:51:53 +01:00
Warren Weckesser e021513baa DOC: Include det in matrices.rst 2021-11-07 01:15:26 -04:00
Clemens Hofreither 8d8f842d84 support QR for matrices of width 0 and 1 2021-09-30 12:16:31 +02:00
Paul Masson 9901f16f28 Streamline Carlson algorithms 2021-06-21 14:25:11 -07:00
Fredrik Johansson c11db84b32 Merge pull request #582 from skirpichev/doc-cleanup
Reorganize docs
2021-03-27 14:49:51 +01:00
Fredrik Johansson b7e176af2b Merge pull request #578 from skirpichev/cleanup
Cleanup top-level dir & misc fixes
2021-03-27 14:49:02 +01:00
Sergey B Kirpichev a5c95a8fbc Fix ~250 broken references in sphinx docs 2021-03-27 01:14:07 +03:00
Sergey B Kirpichev 4a2a320efc Add missing references
Note, that this changes sphinx docs for some constants.  Unfortunately,
there is no other way to display verbose docstrings for pi and euler.
2021-03-27 01:14:07 +03:00
Sergey B Kirpichev a9550c2b70 Reorganize docs (doc/source/ -> docs/, *.txt -> *.rst)
Structure now more closely follow https://packaging.python.org/

To build docs:

    python setup.py build_sphinx -c docs -b html,latex
    make -C build/sphinx/latex all-pdf
2021-03-27 01:14:07 +03:00
Sergey B Kirpichev becbe0d6bd Build docs on the GA CI 2021-03-27 01:13:45 +03:00
Sergey B Kirpichev 6aa2f3c931 Update copyright years 2021-03-27 01:13:45 +03:00
Sergey B Kirpichev 8b878f16f3 Cleanup sphinx config (drop useless and obsoleted options) 2021-03-27 01:13:45 +03:00
Sergey B Kirpichev f4a5aec01d Add __pycache__/ to .gitignore 2021-03-27 01:13:45 +03:00
Sergey B Kirpichev bf9ea9f3ec Drop TODO 2021-03-27 01:13:45 +03:00
Sergey B Kirpichev baff8006af Removed pkgdocs.sh 2021-03-27 01:13:45 +03:00
Sergey B Kirpichev cee8392be1 Removed epydoc.conf 2021-03-27 01:13:45 +03:00
Sergey B Kirpichev f1b1e7550f Drop redundant MANIFEST.in 2021-03-27 01:13:45 +03:00
Fredrik Johansson bd6715df41 Merge pull request #586 from skirpichev/no-sscm
Don't use setuptools_scm: revert to manual version management
2021-03-26 22:39:42 +01:00
Sergey B Kirpichev d3f8091c57 Don't use setuptools_scm: revert to manual version management
The setuptools_scm usage was broken by 867d8784 (likely,
this is a source of problem in #585)

Closes #580 (an alternative to #583 and #581)
Solves #585 as well.
2021-03-26 23:53:10 +03:00
Fredrik Johansson 1bb25a42cb Merge pull request #439 from skirpichev/fix-mpf-inf
Correct mpf initialization from tuple for f(n)inf
2021-03-04 12:19:07 +01:00
Fredrik Johansson 48ee557e29 Merge pull request #573 from skirpichev/test-gmpy
Add optional gmpy deps & run tests with gmpy
2021-03-04 12:17:38 +01:00
Fredrik Johansson f83136d46a Merge pull request #575 from skirpichev/remove-3.4
Drop support for CPython 3.4
2021-03-04 12:17:10 +01:00
Sergey B Kirpichev 8267c62997 Merge branch 'remove-3.4' into fix-mpf-inf 2021-03-03 15:41:15 +03:00
Sergey B Kirpichev 2eb4c5eba7 Drop support for CPython 3.4
Reason: test failure for the master.  GA has no such version
support anymore, e.g.:
https://github.com/fredrik-johansson/mpmath/runs/2005546465
2021-03-03 08:14:42 +03:00
Sergey B Kirpichev d208e50d25 Add optional gmpy deps & run tests with gmpy 2021-03-03 08:14:42 +03:00
Sergey B Kirpichev 25700e23b4 Drop support for CPython 3.4
Reason: test failure for the master.  GA has no such version
support anymore, e.g.:
https://github.com/fredrik-johansson/mpmath/runs/2005546465
2021-03-02 17:55:09 +03:00
Sergey B Kirpichev 7503cedaf5 Merge branch 'master' into fix-mpf-inf 2021-03-02 17:45:54 +03:00
fredrik 35d15f7048 simple matrix multiplication speedup 2021-03-01 17:13:32 +01:00
fredrik 7db68c5d74 fix stray lines 2021-02-26 15:46:23 +01:00
fredrik ecdb5380c8 Merge branch 'master' of github.com:fredrik-johansson/mpmath 2021-02-26 13:06:07 +01:00
fredrik 7123a67a1d naive quadrature using adaptive subdivision 2021-02-26 13:05:54 +01:00
Fredrik Johansson 13a55fd19b Merge pull request #572 from skirpichev/fix-pypi-upload
Fix PyPI uploading
2021-02-13 08:17:03 +01:00
Sergey B Kirpichev 60e2a2b015 Fix PyPI uploading by selecting a particular CPython version
Thanks to @sandrotosi
2021-02-13 08:04:45 +03:00
Fredrik Johansson 46d44c3c8f Merge pull request #570 from vks/fix-redos
Fix ReDOS vulnerability
2021-02-10 17:31:40 +01:00
Vinzent Steinberg 2865c7d12b Improve comment 2021-02-10 16:47:57 +01:00
Vinzent Steinberg c811b37c65 Fix ReDOS vulnerability
Fixes #548, with the workaround suggested by @yetingli.
2021-02-10 16:45:04 +01:00
fredrik c6a35f9ee7 version 1.2.1
test / build (3.4) (push) Has been cancelled
test / build (3.5) (push) Has been cancelled
test / build (3.6) (push) Has been cancelled
test / build (3.7) (push) Has been cancelled
test / build (3.8) (push) Has been cancelled
test / build (3.9) (push) Has been cancelled
test / build (pypy2) (push) Has been cancelled
test / build (pypy3) (push) Has been cancelled
test / build (2.7) (push) Has been cancelled
test / build (3.10-dev) (push) Has been cancelled
2021-02-09 16:19:48 +01:00
Fredrik Johansson c5af9dada3 Merge pull request #568 from skirpichev/pypi-uploads
test / build (2.7) (push) Has been cancelled
test / build (3.10-dev) (push) Has been cancelled
test / build (3.4) (push) Has been cancelled
test / build (3.5) (push) Has been cancelled
test / build (3.6) (push) Has been cancelled
test / build (3.7) (push) Has been cancelled
test / build (3.8) (push) Has been cancelled
test / build (3.9) (push) Has been cancelled
test / build (pypy2) (push) Has been cancelled
test / build (pypy3) (push) Has been cancelled
Automate PyPI uploads
2021-02-09 13:31:34 +01:00
Sergey B Kirpichev 9be306bc73 Add step to publish package on PyPI
Note, this uses https://pypi.org/help/#apitoken feature
of PyPI.  Instead of @master - I use the recent commit hash
from the gh-action-pypi-publish repo to make action more stable.

The secret used in ${{ secrets.PYPI_API_TOKEN }} needs to be created on
the settings page of the mpmath project.
2021-02-02 06:44:36 +03:00
Sergey B Kirpichev 88a1191d4f Make package while CI run 2021-02-02 06:37:04 +03:00
fredrik d806af3a63 version 1.2.0
test / build (2.7) (push) Has been cancelled
test / build (3.10-dev) (push) Has been cancelled
test / build (3.4) (push) Has been cancelled
test / build (3.5) (push) Has been cancelled
test / build (3.6) (push) Has been cancelled
test / build (3.7) (push) Has been cancelled
test / build (3.8) (push) Has been cancelled
test / build (3.9) (push) Has been cancelled
test / build (pypy2) (push) Has been cancelled
test / build (pypy3) (push) Has been cancelled
2021-02-01 22:26:49 +01:00
Fredrik Johansson c733d675e0 Merge pull request #566 from MaxGaukler/fix-remove-forcetype
remove force_type arguments, they were broken
2021-01-30 14:11:10 +01:00
Maximilian Gaukler 4b5f1e3735 remove force_type arguments, they were broken
Make matrices type-stable, not allowing mixed types in one matrix. Always use the type of the context.
Therefore, specifying an element type by the "force_type" argument does not make sense.

It did not work properly before either, the data was not stored in the given type:
```
>>> M = mpmath.matrix(mpmath.matrix([[0,1,2]]), force_type=bool)
>>> M
matrix(
[['0.0', '1.0', '1.0']])
>>> type(M[0,0])
<class 'mpmath.ctx_mp_python.mpf'>
>>> M._matrix__data
{(0, 1): mpf('1.0'), (0, 2): mpf('1.0')}
```

Now the argument is removed and gives a warning instead:
>>> mpmath.matrix(mpmath.matrix([[0,1,2]]), force_type=bool)
/mpmath/mpmath/matrices/matrices.py:288: UserWarning: The force_type argument was removed, it did not work properly anyway. If you want to force floating-point or interval computations, use the respective methods from `fp` or `mp` instead, e.g., `fp.matrix()` or `iv.matrix()`. If you want to truncate values to integer, use .apply(int) instead.
  warnings.warn("The force_type argument was removed, it did not work"
matrix([['0.0', '1.0', '2.0']])
2021-01-22 20:18:22 +01:00
Fredrik Johansson b8be2f5836 Merge pull request #531 from MaxGaukler/fix-iv-matmul
Fix initialization of iv.matrix from non-interval matrix
2021-01-22 17:30:04 +01:00
Maximilian Gaukler 58a597d5a1 Fix initialization of iv.matrix from non-interval matrix
Non-interval datatypes were not converted to intervals, resulting in unexpected behavior. For example, M[i, j] didn't return mpi interval objects, but mpf floats, so M[i, j] * M[k, l] and, under certain conditions, M * M, was not performed as interval multiplication.

This could have unexpected consequences, as outlined below.

"Exact" computation for reference:
>>> import mpmath
>>> x = mpmath.convert('1.00000000000001') # 1.0000...001 rounded to the next mpf floating point value
>>> mpmath.mp.dps=1000
>>> x*x # Good approximation of x*x
mpf('1.00000000000001998401444325291756783368705994138804689654360263219301518944348572404123842716217041015625')

Interval arithmetic should return an interval containing that value, with some uncertainty.

Restart python to reset mp.dps.
Before this commit, the following occurs:
>>> import mpmath
>>> x = mpmath.convert('1.00000000000001')
>>> x
mpf('1.00000000000001')
>>> A = mpmath.matrix([[x]])
>>> B = mpmath.iv.matrix(A)
>>> C = mpmath.iv.matrix([[x]])
>>> A*A
matrix(
[['1.00000000000002']])
>>> B*B
matrix(
[['[1.000000000000019984, 1.000000000000019984]']])
>>> (B*B)[0,0].delta
mpi('0.0', '0.0')
>>> C*C
matrix(
[['[1.000000000000019984, 1.0000000000000202061]']])

B*B is wrong, the interval width must be nonzero at the default precision of 15 digits.
B*B is different from C*C, although both were initialized from the same numerical value and computed the same way.

After this commit, the result is valid:
>>> B*B
matrix(
[['[1.000000000000019984, 1.0000000000000202061]']])
>>> (B*B)[0,0].delta
mpi('2.2204460492503131e-16', '2.2204460492503131e-16')

Some more insight:

Old incorrect behavior:
>>> mpmath.iv.matrix(mpmath.eye(1))[0,0]
mpf('1.0')

New correct behavior:
>>> mpmath.iv.matrix(mpmath.eye(1))[0,0]
mpf('1.0')
>>> mpmath.iv.eye(1)[0,0]
mpi('1.0', '1.0')

>>> import mpmath
>>> mpmath.iv.matrix(mpmath.eye(1))
matrix(
[['[1.0, 1.0]']])
>>> mpmath.iv.matrix(mpmath.eye(1))[0,0]
mpi('1.0', '1.0')
>>> mpmath.fp.matrix(mpmath.eye(1))[0,0]
1.0
>>> mpmath.matrix(mpmath.eye(1))[0,0]
mpf('1.0')

The type now exactly matches the type returned by the context's matrix functions such as eye():
>>> mpmath.matrix(mpmath.eye(1))[0,0]
mpf('1.0')
>>> mpmath.eye(1)[0,0]
mpf('1.0')
>>> mpmath.iv.matrix(mpmath.eye(1))[0,0]
mpi('1.0', '1.0')
>>> mpmath.iv.eye(1)[0,0]
mpi('1.0', '1.0')
>>> mpmath.fp.matrix(mpmath.eye(1))[0,0]
1.0
>>> mpmath.fp.eye(1)[0,0]
1.0
2021-01-22 08:28:37 +01:00
Fredrik Johansson 1617491d33 Merge pull request #555 from skirpichev/ci-to-gh
Enable testing with the Github Actions
2021-01-20 13:51:33 +01:00
Sergey B Kirpichev c7c1be1b1a Update classifiers (supported CPython versions) 2021-01-20 15:33:03 +03:00
Sergey B Kirpichev 89c702c1ea Enable testing on CPython 3.10 2021-01-20 15:30:25 +03:00
Sergey B Kirpichev e4a9d0c817 3.9-dev -> 3.9 2021-01-20 15:30:25 +03:00
Sergey B Kirpichev 4941d6771e Combine coverage stuff 2021-01-20 15:30:25 +03:00
Sergey B Kirpichev a45c2d35dc Apply review suggestions
1) verbose pip arguments
2) py.test -> pytest
2021-01-20 15:30:25 +03:00
Sergey B Kirpichev 7775622f37 Enable testing with the Github Actions
Closes #553
2021-01-20 15:30:23 +03:00
Fredrik Johansson 8ba6febce0 Merge pull request #554 from skirpichev/fix-ci2
Fix Travis-CI in the master & some cleanup of the Travis config
2021-01-20 10:09:34 +01:00
Sergey B Kirpichev 40e1017187 Enable testing on CPython 3.10 2021-01-03 07:01:23 +03:00
Sergey B Kirpichev 17493191da Merge branch 'master' into fix-ci2 2021-01-03 06:59:42 +03:00
Sergey B Kirpichev 82ae9ffdb5 3.9-dev -> 3.9 2021-01-03 06:58:52 +03:00
Fredrik Johansson 879699c6ae Merge pull request #564 from DamSenViet/preserve-wrapped-signature
PrecisionManager preserves caller signature
2020-12-17 13:47:37 +01:00
Viet Tran f63ffe0f6e Removed redundant lines 2020-12-16 21:41:54 -08:00
DamSenViet f8e8ef13dc PrecisionManager preserves caller signature 2020-12-16 17:44:38 -08:00
Fredrik Johansson 1769b4bf10 Merge pull request #560 from klkuhlm/master
revert previous change that had unintended consequences.
2020-10-26 15:28:23 +01:00
klkuhlm 518a52bda0 revert previous change that had unintended consequences. 2020-10-26 08:03:54 -06:00
Fredrik Johansson d957c3dabe Merge pull request #557 from jwilk-forks/sys.version
Fix sys.version comparisons
2020-10-26 09:05:00 +01:00
Fredrik Johansson 81e696eac8 Merge pull request #559 from klkuhlm/master
pass kwargs to laplace-space function in invertlaplace
2020-10-26 09:04:17 +01:00
klkuhlm cab6cba208 pass kwargs to laplace-space function in invertlaplace 2020-10-25 15:46:32 -06:00
Jakub Wilk 5ad1d2f88d Fix sys.version comparisons
"sys.version >= '3.2'" will break in Python 3.10.
2020-10-12 09:32:28 +02:00
Sergey B Kirpichev c62138cfb4 Apply fixes from the Travis CI build config validation 2020-10-03 05:27:33 +03:00
Sergey B Kirpichev 85cf16c5cb CI: Enable testing on CPython 3.9 2020-10-02 08:30:55 +03:00
Sergey B Kirpichev bbd6e02234 CI: provide pytest-cov arguments with PYTEST_ADDOPTS 2020-10-02 08:30:48 +03:00
Sergey B Kirpichev 59c1b7fde6 CI: reinstall setuptools globally (3.4 goes to the common build matrix) 2020-10-02 08:30:39 +03:00
Sergey B Kirpichev 401a652126 CI: Drop tests on arm64
This reverts c98b4d6.  I believe, for platform-independent
Python library these tests are not needed, even if we add
gmpy-enabled tests.  Right now this only enlarge the build
matrix and slowdown the testing process...
2020-10-02 08:30:02 +03:00
Sergey B Kirpichev f2be673aa8 CI: Set minimal pytest version (fixes testing in Travis-CI) 2020-10-02 08:29:37 +03:00
Fredrik Johansson 77c4c5e0ce Merge pull request #533 from MaxGaukler/fix-scalar-matmul
Fix scalar-matrix-multiplication for mpi * iv.matrix
2020-09-06 10:22:52 +02:00
Fredrik Johansson 6a675bf08e Merge pull request #537 from tminka/quad
QuadratureRule.summation adds the error across intervals
2020-06-08 09:29:40 +02:00
Fredrik Johansson 718b4a1457 Merge pull request #526 from MaxGaukler/pos
Implement unary plus for matrices (+M == M)
2020-06-08 09:27:59 +02:00
Tom Minka adb811b0f5 Added test 2020-05-20 12:45:07 +01:00
Tom Minka 6ef6ac44a9 Fixed broken link in README
Added pytest.ini
2020-05-20 12:37:36 +01:00
Tom Minka 51c63a27d4 QuadratureRule.summation adds the error across intervals 2020-05-15 15:14:45 +01:00
Maximilian Gaukler 5abc70fc9b Implement unary plus for matrices (+M == M rounded to current precision) 2020-04-24 15:10:02 +02:00
Maximilian Gaukler c2d2bf33ab Fix scalar-matrix-multiplication for mpi * iv.matrix 2020-03-24 12:23:07 +01:00
fredrik ffec62b29b Merge branch 'master' of github.com:fredrik-johansson/mpmath 2020-03-23 15:19:32 +01:00
fredrik 28973bc3ba slightly improve elliprj code 2020-03-23 15:19:19 +01:00
Fredrik Johansson deeb2a9cf4 Merge pull request #529 from klkuhlm/master
fixed indexing errors in inverse laplace transform algorithm, as pointed out by Mark Bakker
2020-03-22 18:01:02 +01:00
Fredrik Johansson b217369eee Merge pull request #525 from MaxGaukler/matmul
Support @ for matrix multiplication
2020-03-22 17:55:40 +01:00
klkuhlm c51e3e3dc8 fixed indexing errors in deHoog, Knight & Stokes inverse laplace transform algorithm, as pointed out by Mark Bakker 2020-03-22 09:05:47 -06:00
fredrik b80b8661b6 use integration as workaround where the algorithm for elliprj is not valid 2020-03-22 15:04:04 +01:00
Maximilian Gaukler 7a3bb2883d Support @ operator (PEP465) for matrix multiplication 2020-03-20 12:37:52 +01:00
Fredrik Johansson 411b74d0da Merge pull request #500 from cclauss/modernize-Python-2-codes
Use print() function in both Python 2 and Python 3
2020-02-20 12:06:07 +01:00
Fredrik Johansson c80fc1f55b Merge pull request #501 from ossdev07/arm_support
Adding Travis-Ci Support For Arm64
2020-02-20 12:05:28 +01:00
Fredrik Johansson a64ff99cf0 Merge pull request #502 from paulmasson/master
Modify period of cn
2020-02-20 12:05:06 +01:00
Paul Masson 4fc6783ade Modify period of cn 2020-01-01 15:58:07 -08:00
ossdev07 c98b4d6c73 Adding Travis-Ci Support For Arm64
Signed-off-by: ossdev07 <ossdev@puresoftware.com>
2019-12-30 12:26:57 +05:30
cclauss 15f68aa2f3 Use print() function in both Python 2 and Python 3
Legacy __print__ statements are syntax errors in Python 3 but __print()__ function works as expected in both Python 2 and Python 3.
2019-11-26 08:19:39 +01:00
Fredrik Johansson 981102736a Merge pull request #498 from paulmasson/patch-1
Update link to reference
2019-11-26 01:12:51 +01:00
Fredrik Johansson 67f3ca9446 Merge pull request #492 from cclauss/patch-1
Travis CI: Use production versions of CPython, pypy, pypy3
2019-11-26 01:12:21 +01:00
Paul Masson c7151a450c Update link 2019-11-22 16:16:25 -08:00
Christian Clauss 87bb8819c0 Travis CI: Use production versions of CPython, pypy, pypy3
Remove the hardcoding of out of date versions
2019-11-19 17:48:20 +01:00
Fredrik Johansson 64a33ea8e1 Merge pull request #463 from GeorgOstrovski/patch-1
Fix eig_sort(..., f="abs")
2019-09-05 20:01:52 +02:00
Fredrik Johansson 9688fb3452 Merge pull request #464 from GeorgOstrovski/patch-2
Fix docstring typo
2019-09-05 20:01:31 +02:00
Fredrik Johansson f115ce4ebb Merge pull request #466 from pv/sage-check
Enable sage backend by default only if SAGE_ROOT is set
2019-09-05 20:01:19 +02:00
Fredrik Johansson 3c5935fa37 Merge pull request #468 from thepith/master
Prevent division by zero
2019-09-05 19:59:00 +02:00
Pascal Hebbeker a61aa1d1e1 Prevent division by zero
Problem: `rnd.getrandbits` can result in 0, so that `b` could equal to 0.

This fix makes it that b is a pseudorandom number close, but not equal,
to zero.
2019-08-21 10:40:40 +02:00
Pauli Virtanen 84ca137ff8 Enable sage backend by default only if SAGE_ROOT is set
It's possible to install the Sage system as a normal Python package, as
e.g. in Fedora/Debian. In this case, presence of `sage.all` is not an
indicator whether the user is running Sage, and checking for 'SAGE_ROOT'
is more reliable.
2019-08-04 14:15:43 +03:00
Georg Ostrovski 9790c56e5c Fix docstring typo 2019-07-31 09:07:40 +01:00
Georg Ostrovski 4708e3c2ce Fix eig_sort(..., f="abs") 2019-07-31 08:38:45 +01:00
Fredrik Johansson ca36a7bfba Merge pull request #462 from sylee957/fix_docs
Polynomial doc rendering
2019-07-25 21:17:45 +02:00
S.Y. Lee 16bdffe621 Fix doc rendering 2019-07-26 03:44:22 +09:00
fredrik b8ea24aa1f add eta() implementing the Dedekind eta function 2019-07-16 15:59:34 +02:00
Fredrik Johansson ac5f60fd17 Merge pull request #456 from fchapoton/patch-1
remove unused variable tmp
2019-06-11 14:17:16 +09:00
Fredrik Johansson 9f650c1208 Merge pull request #454 from skirpichev/3.8
Enable testing on CPython 3.8
2019-06-11 14:16:21 +09:00
Sergey B Kirpichev 5d6f18b8e1 CPython 3.7 is available on xenial, use this 2019-04-21 19:50:52 +03:00
Frédéric Chapoton 47dce0439a remove unused variable tmp
as suggested by lgtm
2019-04-12 19:04:34 +02:00
Sergey B Kirpichev 0147fea4f7 Remove inaccessible logic in fsum/fdot 2019-03-20 14:58:43 +03:00
Sergey B Kirpichev 4ea5a4fc09 Exclude NotImplemented/NotImplementedError from the coverage 2019-03-20 14:58:02 +03:00
Sergey B Kirpichev 4990fb5cf3 Fix syntax warnings on CPython 3.8
Closes #444
2019-03-20 14:25:32 +03:00
Sergey B Kirpichev 4e0083034b Use dist xenial on travis 2019-03-20 14:25:32 +03:00
Sergey B Kirpichev 09f6c40ca6 Enable testing on CPython 3.8 2019-03-20 12:08:34 +03:00
Fredrik Johansson e0ec6e8944 Merge pull request #446 from FairyDwarves/fallback_distnotfound
reverting to use a static version string in code
2019-03-08 21:53:31 +01:00
AlexV 867d8784ce removing version retrieval via pkg_resources. static version string in code. 2019-03-08 13:56:09 +01:00
AlexV aef752d777 adding fallback value for version if distirbution not found by pkg_resources 2019-03-08 10:48:55 +01:00
Sergey B Kirpichev 1e80ccbb1c Correct mpf initialization from tuple for f(n)inf/fnan
Closes #438
2019-02-16 00:11:26 +03:00
Fredrik Johansson 224e0834bc Merge pull request #436 from skirpichev/restore-3.4
Restore support for CPython 3.4
2019-02-05 00:12:24 +01:00
Sergey B Kirpichev 9edecdd043 Upgrade setuptools for CPython 3.4 2019-02-04 23:44:29 +03:00
Sergey B Kirpichev 770275998f Revert "Drop support of CPython 3.4"
This reverts commit 5e3654757d.
2019-02-04 23:38:53 +03:00
Fredrik Johansson 808db2c846 Merge pull request #433 from skirpichev/fix-more-defun
Fix more broken defun decorators, amend ef75979
2019-02-04 11:46:56 +01:00
Sergey B Kirpichev 7f6a5c698f Fix more broken defun decorators, amend ef75979 2019-02-04 13:24:53 +03:00
Fredrik Johansson 90a9a4790d Merge pull request #432 from skirpichev/fix-defun
Return passed in function in defun* decorators
2019-02-03 19:58:10 +01:00
Sergey B Kirpichev 88346d43fd Amend 03b7514 2019-02-03 21:16:03 +03:00
Sergey B Kirpichev 5e3654757d Drop support of CPython 3.4 2019-02-03 21:15:01 +03:00
Sergey B Kirpichev 94b1928d32 Add doctest option to ignore exception details (including module path) 2019-02-03 21:15:01 +03:00
Sergey B Kirpichev ef7597994d Return passed in function in defun* decorators
This turn on more doctests, e.g.:

$ py.test mpmath/functions/qfunctions.py
============================= test session starts ==============================
platform linux -- Python 3.7.1, pytest-4.2.0, py-1.7.0, pluggy-0.8.1
hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('/home/sk/src/mpmath/.hypothesis/examples')
rootdir: /home/sk/src/mpmath, inifile: setup.cfg
plugins: xdist-1.26.1, timeout-1.3.3, forked-1.0.1, cov-2.6.1, hypothesis-4.4.3
collected 4 items

mpmath/functions/qfunctions.py ....                                      [100%]

=========================== 4 passed in 0.49 seconds ===========================

Some doctests were adapted.
2019-02-03 21:14:43 +03:00
Fredrik Johansson fcf7d44d7b Merge pull request #430 from adhoc-king/patch-2
A very optimized python_trailing function
2019-02-03 15:25:48 +01:00
adhoc-king fe571b39b9 Update libintmath.py 2019-02-03 19:41:57 +05:30
fredrik 474b987c19 remove old (unused) gamma function code 2019-02-03 14:37:33 +01:00
Fredrik Johansson 8613130de2 Merge pull request #422 from skirpichev/setup.cfg-and-cov
Use declarative config for setup.py and enable coverage testing
2019-02-03 14:30:56 +01:00
Sergey B Kirpichev 1f9d5dac50 Enable code coverage on Py2 too 2019-02-03 15:59:58 +03:00
Sergey B Kirpichev e24d5956f6 Upgrade deps on Travis 2019-02-03 15:01:58 +03:00
Sergey B Kirpichev 03b7514510 Drop dependency on six and implement exec() function for py2
We use "imports from future" to get print() function.
2019-02-03 15:00:19 +03:00
Fredrik Johansson 87a1442e2f Merge pull request #431 from fredrik-johansson/revert-425-leftScalarMatrixMult280
Revert "Fixed scalar-matrix multiplication in iv module"
2019-02-03 12:03:18 +01:00
Fredrik Johansson 88d01b7bd5 Revert "Fixed scalar-matrix multiplication in iv module" 2019-02-03 11:46:56 +01:00
adhoc-king 660770cde3 A very optimized python_trailing function
1. Added a lookup table (small_trailing) for numbers with a set bit in the lower byte
2. Loop masks out 8 bits instead of the earlier one bit
2019-02-03 13:33:27 +05:30
Fredrik Johansson 41426f8b9f Merge pull request #426 from warnerjon12/floatComplexCastExc266
Implemented float and complex conversions for ivmpf
2019-02-03 02:45:56 +01:00
Fredrik Johansson d67bfc5b32 Merge pull request #425 from warnerjon12/leftScalarMatrixMult280
Fixed scalar-matrix multiplication in iv module
2019-02-03 02:45:05 +01:00
Fredrik Johansson d76862f992 Merge pull request #427 from paulmasson/patch-1
Update URL for Inverse Symbolic Calculator
2019-02-03 02:40:36 +01:00
Fredrik Johansson e21cb3cb4a Merge pull request #429 from p15-git-acc/gram-index
use algebra instead of root finder for gram_index
2019-02-03 02:40:03 +01:00
p15-git-acc 26055234a2 use algebra instead of root finder for gram_index 2019-01-31 23:08:56 -06:00
Paul Masson 3578926895 Update URL 2019-01-23 11:58:56 -08:00
Jonathan Warner bce0e9afef Implemented float and complex conversions for ivmpf
Response to issue fredrik-johansson#266
2019-01-09 10:40:20 -07:00
Jonathan Warner de49931b7a Added test code for issue #280 2019-01-09 09:43:30 -07:00
Jonathan Warner 5c4cccd436 Fixed issue with scalar-matrix multiplication
Response to issue fredrik-johansson#280
2019-01-09 09:43:24 -07:00
Fredrik Johansson 30bfc79dd1 Fix statement about supported Python versions 2019-01-09 09:43:09 -07:00
Sergey B Kirpichev b746b504f5 Add codecov badge 2018-12-23 19:09:04 +03:00
Sergey B Kirpichev bcafa7f6ff Correct python runtime requirements 2018-12-23 18:14:30 +03:00
Sergey B Kirpichev 72ac616822 Unbundle six library 2018-12-23 17:44:34 +03:00
Sergey B Kirpichev 6f3b536b35 Alter last clause of Modified BSD License
In this way Github recognize the LICENSE as BSD
2018-12-23 17:22:28 +03:00
Sergey B Kirpichev f7fa465603 Use setuptools_scm to track versions
Also drop testing on py3.3
2018-12-23 17:22:14 +03:00
Sergey B Kirpichev c4d2491634 Enable coverage testing, report with codecov
We run coverage tests only in py3.6
2018-12-23 17:21:50 +03:00
Sergey B Kirpichev 0c99846c07 Use setup.cfg for setup() options
see
https://setuptools.readthedocs.io/en/latest/setuptools.html#configuring-setup-using-setup-cfg-files

Also this commit expands some metadata, e.g. classifiers and
project_urls.  Testing requirements are specified with "tests" extras.
Other development requirements are tracked with "develop" extras.

Peferences to extras are supported in tests_require since setuptools
v36.7.0, hence additional entry in setup_requires.
2018-12-23 16:22:59 +03:00
Sergey B Kirpichev d8462dfbbb pep8 -> pycodestyle (package was renamed), drop redundant comments 2018-12-23 16:22:59 +03:00
Fredrik Johansson 1e0743086a Fix statement about supported Python versions 2018-12-11 17:08:24 +01:00
282 changed files with 16779 additions and 10228 deletions
+11
View File
@@ -0,0 +1,11 @@
coverage:
precision: 0
round: down
status:
patch:
default:
target: 97
project:
default:
threshold: 1%
comment: false
+105
View File
@@ -0,0 +1,105 @@
Reporting Issues
================
When opening a new issue, please take the following steps:
1. Please search `GitHub issues`_ to avoid duplicate reports.
2. If possible, try updating to master and reproducing your issue.
3. Try to include a minimal code example that demonstrates the problem.
4. Include any relevant details of your local setup (mpmath version, Python
version, installed libraries).
Please avoid changing your messages on the GitHub, unless you want fix a typo
and so on. Just expand your comment or add a new one.
Contributing Code
=================
All work should be submitted via `Pull Requests (PR)`_.
1. PR can be submitted as soon as there is code worth discussing.
Please make a draft PR, if one is not intended to be merged
in its present shape even if all checks pass.
2. Please put your work on the branch of your fork, not in the
master branch. PR should generally be made against master.
3. One logical change per commit. Make good commit messages: short
(<= 78 characters) one-line summary, then newline followed by
verbose description of your changes. Please `mention closed
issues`_ with commit message.
4. Please conform to `PEP 8`_; run::
flake518
to check formatting.
5. PR should include tests:
1. Bugfixes should include regression tests (named as ``test_issue_123``).
2. All new functionality should be tested, every new line
should be covered by tests. Please use in tests only
public interfaces. Regression tests are not accounted in
the coverage statistics.
3. Optionally, provide doctests to illustrate usage. But keep in
mind, doctests are not tests. Think of them as examples that
happen to be tested.
6. It's good idea to be sure that **all** existing tests
pass and you don't break anything, so please run::
pytest
7. If your change affects documentation, please build it by::
sphinx-build -W -b html docs build/sphinx/html
and check that it looks as expected.
AI Generated Code and Communication Policy
==========================================
The person submitting an issue or PR is responsible for its content, regardless
of whether AI tools were used in its creation. Generative AI tools can produce
output quickly, but discretion, good judgment, and critical thinking are the
foundation of all good contributions.
You must understand and explain the code you submit as well as the existing
related code. It is not acceptable to submit a patch that you cannot
understand and explain yourself. In explaining your contribution, do not use
AI to automatically generate descriptions, as AI rarely communicates such
information correctly and concisely.
Disclosure
----------
If you substantially make use of AI to assist in the development of your patch,
you must disclose how it was used and what code in the patch is AI generated.
Pull request without such disclosure may be rejected.
Code Quality
------------
Code generated by AI is very often of low quality. Contributors are expected
to submit code that meets our standards (see above). We will reject pull
requests that we deem being "AI slop". Do not waste developers time by
submitting code that is fully or mostly generated by AI.
Communication
-------------
When interacting in communication among developers (email list, discussions,
issues, pull requests, etc) do not use AI to speak for you, other than for
translation or grammar editing.
.. _GitHub issues: https://github.com/mpmath/mpmath/issues
.. _Pull Requests (PR): https://github.com/mpmath/mpmath/pulls
.. _PEP 8: https://www.python.org/dev/peps/pep-0008/
.. _mention closed issues: https://help.github.com/en/github/managing-your-work-on-github/linking-a-pull-request-to-an-issue
+11
View File
@@ -0,0 +1,11 @@
version: 2
updates:
- package-ecosystem: github-actions
directory: "/"
schedule:
interval: "monthly"
rebase-strategy: "disabled"
groups:
actions-deps:
patterns:
- "*"
+45
View File
@@ -0,0 +1,45 @@
name: Run coverage tests
on: [workflow_dispatch, workflow_call]
jobs:
coverage:
runs-on: ubuntu-24.04
strategy:
fail-fast: true
env:
PYTEST_ADDOPTS: --cov mpmath --cov-append -n auto
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0
- uses: actions/setup-python@v7
with:
python-version: "3.x"
- name: Install dependencies
run: |
pip install --upgrade setuptools pip
pip install --upgrade .[develop,gmpy2,gmp,ci]
- name: Run coverage tests
run: |
pytest
pip uninstall -y ipython
pytest mpmath/tests/test_cli.py
pip uninstall -y gmpy2
pytest mpmath/tests/test_basic_ops.py mpmath/tests/test_convert.py \
mpmath/tests/test_functions.py mpmath/tests/test_gammazeta.py \
mpmath/tests/test_bitwise.py
pip uninstall -y python-gmp
pytest mpmath/tests/test_basic_ops.py mpmath/tests/test_convert.py \
mpmath/tests/test_functions.py mpmath/tests/test_gammazeta.py \
mpmath/tests/test_bitwise.py
- name: Generate coverage reports
run: |
coverage xml
coverage html
diff-cover coverage.xml --fail-under=100 \
--compare-branch=origin/master
- uses: actions/upload-artifact@v7
with:
name: coverage
path: |
coverage.xml
build/coverage/html/
+34
View File
@@ -0,0 +1,34 @@
name: Build & test docs
on: [workflow_dispatch, workflow_call]
jobs:
docs:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0
- uses: actions/setup-python@v7
with:
python-version: "3.x"
- name: Install libs
run: |
sudo apt update
sudo apt install latexmk texlive-xetex
- name: Install dependencies
run: |
pip install --upgrade setuptools pip
pip install --upgrade .[docs]
- name: Building docs
run: |
sphinx-build --color -W --keep-going -b html docs build/sphinx/html
sphinx-build --color -W --keep-going -b latex docs build/sphinx/latex
make -C build/sphinx/latex all-pdf
env:
NO_COLOR: 1 # workaround for sphinx-contrib/autoprogram#76
COLUMNS: 80 # also enable line wrapping for argparse
- uses: actions/upload-artifact@v7
with:
name: docs
path: |
build/sphinx/html/
build/sphinx/latex/mpmath.pdf
+15
View File
@@ -0,0 +1,15 @@
name: Linting with flake8, etc
on: [workflow_dispatch, workflow_call]
jobs:
linter:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0
- uses: actions/setup-python@v7
with:
python-version: "3.x"
- run: pip install --upgrade .[develop]
- run: python -We:invalid -m compileall -f mpmath -q
- run: flake518 mpmath
+35
View File
@@ -0,0 +1,35 @@
name: Publish on PyPI
on: [push, workflow_dispatch, workflow_call]
jobs:
build:
name: Build distributions
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0
- uses: actions/setup-python@v7
with:
python-version: "3.x"
- run: pip install build
- run: python -m build
- uses: actions/upload-artifact@v7
with:
name: build
path: dist/
publish-to-pypi:
name: Publish distributions to PyPI
if: startsWith(github.ref, 'refs/tags/')
needs:
- build
runs-on: ubuntu-24.04
steps:
- uses: actions/download-artifact@v8
with:
pattern: build
path: dist/
merge-multiple: true
- uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
+67
View File
@@ -0,0 +1,67 @@
name: test
on:
push:
pull_request:
workflow_dispatch:
schedule:
- cron: '0 0 * * 2'
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
linter:
uses: ./.github/workflows/linter.yml
coverage:
uses: ./.github/workflows/coverage.yml
docs:
uses: ./.github/workflows/docs.yml
frozen-version:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0
- uses: actions/setup-python@v7
with:
python-version: "3.x"
- name: Run frozen version test
run: ./mpmath/tests/test_version_frozen.sh
tests:
needs:
- linter
- coverage
- frozen-version
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
python-version: ['3.10', 3.11, 3.12, 3.13, 3.14, 3.14t, 3.15, 3.15t]
nogmpy: [false]
purepy: [false]
include:
- python-version: "3.x"
nogmpy: true
- python-version: "3.x"
purepy: true
- python-version: pypy3.11
purepy: true
env:
PYTEST_ADDOPTS: -n auto --durations=20
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v7
with:
python-version: ${{ matrix.python-version }}
allow-prereleases: true
- name: Install dependencies
run: |
pip install --upgrade setuptools pip
pip install --upgrade .[develop,gmpy2,gmp,ci]
- run: pip uninstall -y gmpy2
if: matrix.nogmpy
- run: pip uninstall -y gmpy2 python-gmp
if: matrix.purepy
- run: pytest
+22
View File
@@ -10,6 +10,7 @@
# Regular Python bytecode file
*.pyc
__pycache__/
# Optimized Python bytecode file
*.pyo
@@ -32,6 +33,9 @@ my/
dist/
build/
# Generated by setuptools_scm
mpmath/_version.py
# Tox files
.tox/
@@ -50,3 +54,21 @@ doc/source/_build/
# Files generated by setupegg.py
mpmath.egg-info/
.eggs
# Coverage-related files
.coverage
htmlcov/
# Visual Studio files
.vs/
# PyCharm files
.idea/
# Ignore files cached by Hypothesis (including examples directory so far)
.hypothesis/
# per-project directories for virtual environments
venv/
.venv/
+20
View File
@@ -0,0 +1,20 @@
version: 2
formats:
- htmlzip
- pdf
build:
os: ubuntu-22.04
tools:
python: "3"
jobs:
post_checkout:
- git fetch --unshallow
python:
install:
- method: pip
path: .
extra_requirements:
- docs
sphinx:
fail_on_warning: true
configuration: docs/conf.py
-21
View File
@@ -1,21 +0,0 @@
language: python
sudo: false
python:
- 2.7
- 3.3
- 3.4
- 3.5
- 3.6
- 3.7-dev
- pypy
- pypy3.5
install:
- pip install pep8
- pip install -e .
script:
# Guard against invalid escapes in strings, like '\s'.
- python -We:invalid -m compileall -f mpmath -q
- pep8
- py.test
notifications:
email: false
+417 -1
View File
@@ -1,3 +1,419 @@
--1.5.0--
Released TBD
Features:
* Support special numbers in mpf_frexp() like math.frexp(),
see #1081 (Sergey B Kirpichev)
* Add ModAB rootfinding algorithm, see #1093 (Ayush Baranwal)
* Add Brent root-finding algorithm, see #1103 (Ayush Baranwal)
* Correct integral path of the lerchphi() to use Laplace transform
integral, see #1109 (Sergey B Kirpichev)
* Add Weierstrass elliptic functions, see #1113, #1117,
#1141, #1146 and #1157 (Graham Hesketh)
* Implement the modified spherical bessel functions spherical_in()
and spherical_kn(), see #1121 (Warren Weckesser)
* Add ulp(), see #1144 (Sergey B Kirpichev)
* Use round_nearest in repr/str and as default mpf's rounding mode,
see #1153 (Sergey B Kirpichev)
* Add shortest_str context option to enable using shortest decimal
representations in str/repr/format output, see #1115 (Sergey B Kirpichev)
* Add fft()/invfft() functions for DFT calculation, see #1152 (Ayush Baranwal)
Compatibility:
* Drop support for CPython 3.9, see #1058 (Sergey B Kirpichev)
* Remove deprecated math2 and rational modules, see #1057 (Sergey B Kirpichev)
* Remove deprecated mp.mpnumeric alias, see #1057 (Sergey B Kirpichev)
* Remove deprecated bitcount(), fp.is_special() and to/from_pickable()
functions, see #1057 (Sergey B Kirpichev)
* Drop DeprecationWarning for force_type kwarg for matrix(),
see #1057 (Sergey B Kirpichev)
* Use signed=True per default in to_man_exp(), see #1057 (Sergey B Kirpichev)
* Use asc=True per default for polynomial functions, see
#1057 (Sergey B Kirpichev)
* Restrict libmp exports to public API, see #1089 (Sergey B Kirpichev)
* Use explicit kwargs in public API, where possible,
see #1127 (Sergey B Kirpichev)
Bug fixes:
* Fix test_hexadecimal_with_libc_bulk(), see #1049 (Doug Torrance)
* Keep available deprecated aliases for mpc/mpf_log() (Sergey B Kirpichev)
* Use version_file option of setuptools-scm to keep version info, see #1048
(Sergey B Kirpichev)
* Add workaround for test on s390x, see #1061 (Sergey B Kirpichev)
* Fix signature of root(), see #1072 (Sergey B Kirpichev)
* Speedup removal trailing zeros in _normalize/from_man_exp(), see #1074
(Fredrik Johansson and Sergey B Kirpichev)
* Improve documentation about rounding in the mp context,
see #1079 (Sergey B Kirpichev)
* Correct to_float() conversion for double-rounding cases (e.g. subnormals),
see #1082 (Sergey B Kirpichev)
* Fix qr_solve() failure on well-conditioned matrices with zero pivot, see
#1083 (Jam Balaya)
* Clarify to_float() docstring, see #1087 (Sergey B Kirpichev)
* Add extra precision for summation in mpf_hypot(), see
#1088 (Sergey B Kirpichev)
* Fix typo and function names for sin/cospi(), see #1091 (Sergey B Kirpichev)
* Raise ValueError when same sign at interval boundaries in bisection
rootfinding algorithm, see #1092 (Ayush Baranwal)
* Correct interval update for Ridder's method, see #1096 (Sergey B Kirpichev)
* Set dynamic maxsteps value for the bisect method, see
#1096 (Sergey B Kirpichev)
* Implement direct series for lerchphi() base case with |z| < 1,
see #1100 (Sergey B Kirpichev)
* Correct exception message for THETA_Q_LIM, see #1102
(Sergey B Kirpichev and Jam Balaya)
* Fix gegenbauer() failing to converge for odd integer n at z=0,
see #1101 (Vincent Gao)
* Reorganize fixed-precision computations for theta3 to avoid
severe cancellation, see #1107 (Sergey B Kirpichev)
* Fix fp.hypsum() to exit if ZeroDivisionError occurs and t==0,
see #1112 (Sergey B Kirpichev)
* Fix chebyfit IndexError when N <= 0, see #1114 (Vincent Gao)
* Use generic modular transformations to compute jtheta() with
|q| ~ 1, see #1111 (Sergey B Kirpichev, Jam Balaya)
* Fix repr_dps() to produce a correct estimate for prec!=53,
see #1118 (Sergey B Kirpichev)
* Use quasi-periodicity property (DLMF, §20.2(ii)) to compute
jtheta(), *_theta2/3a() helpers now not needed, see #1120
(Sergey B Kirpichev)
* Close leftover figure in plot/cplot/splot on error,
see #1123 (Apoorv Darshan)
* Better document None return value of the pslq(), see
#1134 (Sergey B Kirpichev)
* Fix last-digit rounding of the "f" format type, see #1132 (Vincent Gao)
* Use CoW pattern to manage constant_memo() cache, see
#1138 (Sergey B Kirpichev)
* Widen to_str's digit window so str/nstr rounds near-boundary values
correctly, see #1139 (Vincent Gao)
* Correct definitions for spherical Bessel functions, see #1143
(Sergey B Kirpichev)
* Added 2 new expceptions to Rosser's Rule, se #1148 (catalin-hanga)
* Avoid spurious overflow in fp gammaprod, see #1150 (Sanjay Santhanam)
* Document pretty_dps context's option, see #1153 (Sergey B Kirpichev)
* Fix cplot points rounding, see #1155 (alexfyp)
Maintenance:
* Add bash script to test package version in a frozen application version
and a separate CI job to run it, see #1055 (flurin4)
* Revert "Add backport action", see #1063 (Sergey B Kirpichev)
* Test on CPython 3.15, see #1071, #1106 and #1110 (Sergey B Kirpichev)
* Add AI-related policy, see #1098 (Sergey B Kirpichev)
* Fix test_sn_cn_dn_identities(), see #1106 (Sergey B Kirpichev)
* Fix test_compatibility(): avoid using of private numpy
API (Sergey B Kirpichev)
--1.4.1--
Released March 15, 2026
Bug fixes:
* Fix test_hexadecimal_with_libc_bulk(), see #1049 (Doug Torrance)
* Keep available deprecated aliases for mpc/mpf_log() (Sergey B Kirpichev)
* Use version_file option of setuptools-scm to keep version info, see #1048
(Sergey B Kirpichev)
* Add workaround for test on s390x, see #1061 (Sergey B Kirpichev)
--1.4.0--
Released February 23, 2026
Features:
* Support underscores as digit separators per PEP 515, see #661 (Sergey B
Kirpichev)
* Add rationals converter for mpf's, see #666 (Sergey B Kirpichev)
* Rewrite bernpoly/eulerpoly to avoid dependency on bernoulli(1) convention,
see #700 (Sergey B Kirpichev)
* Support base kwarg for from_str(), see #703 (Jonathan Warner, Sergey B
Kirpichev)
* Support randmatrix() for mp.iv and mp contexts, see #527 (Maximilian
Gaukler)
* Added rank() function for matrices, see #610 (Jan-Philipp Hoffmann)
* Add plus flag to select the B_1 sign convention for bernoulli/bernfrac, see
#724 (Jeremy Tan Jie Rui, Sergey B Kirpichev)
* Add mpf.as_integer_ratio() method, support construction of mpf from Decimal
objects, see #731 (Sergey B Kirpichev)
* Expose lower/upper_gamma functions, see #740 (Sergey B Kirpichev)
* Support mpc initialization from string, see #743 (Sergey B Kirpichev)
* Support asinh/acosh/atanh in the fp context, see #750 (Sergey B Kirpichev)
* Support binary/octal/hexadecimal string output, see #711 (Jonathan Warner,
Sergey B Kirpichev)
* Support pickling for matrices and mpi, see #761 (Sergey B Kirpichev)
* Support matrix.__array__() dunder method, see #767 (Sergey B Kirpichev)
* Support more number syntaxes, see #778 (Sergey B Kirpichev)
* Run mpmath as a module for interactive work, see #773, #923, #931, #936,
#939 and #954 (Sergey B Kirpichev)
* Add signed option to to_man_exp(), see #783 (Sergey B Kirpichev)
* Add fp.hypot, see #798 (Sergey B Kirpichev)
* Support inf/nan's in ctx.almosteq(), #802 (Sergey B Kirpichev)
* Implement mpf.__format__(), see #819, #831, #850, #859, #857, #862, #881,
#944 and #966 (Javier Garcia, Sergey B Kirpichev)
* Support conversion from scalar ndarray's, see #821 (Sergey B Kirpichev)
* Support rounding modes in mpf.__format__, see #823, #831, #834
and #969 (Javier Garcia, Sergey B Kirpichev)
* Support '%' presentation type for mpf, see #847 (Sergey B Kirpichev)
* Support gmpy2-like rounding modes in to_str(), see #830 (Javier Garcia)
* Implement 'a'/'A' formating types for mpf.__format__, see #841 and #870
(Sergey B Kirpichev)
* Add mpc.__format__(), see #855 (Sergey B Kirpichev)
* Now mpf.__round__() returns mpf, see #826 and #966 (Sergey B Kirpichev)
* Support 'b' (binary) format type for mpf/mpc, see #867 (Sergey B Kirpichev)
* Implement mpf.__floordiv__() and mpf.__divmod__(), see #873 (Sergey B
Kirpichev)
* Add parameters for MPContext constructor, see #876 and #963 (Sergey B Kirpichev)
* Add MPFR-compatible aliases for rounding modes, see #892 (Sergey B
Kirpichev)
* Support negative indexes in matrix, see #897 (Riccardo Orsi)
* Better introspection support for decorated functions, see #900 (Sergey B
Kirpichev)
* Add moving sofa demo, see #924 (Sergey B Kirpichev)
* Support spherical Bessel functions (jn/yn), #935 (Sergey B Kirpichev)
* Add pretty_dps context property to control number of printed digits, see
#933 (Sergey B Kirpichev)
* Support thousands separators for formatting of fractional part, see #925 and
#936 (Sergey B Kirpichev)
* Use PyREPL, as fallback (no IPython), see #941 (Sergey B Kirpichev)
* Add exp2() and log2(), see #948 (Sergey B Kirpichev)
* Support rounding property for the mp context, see #963 (Sergey B Kirpichev)
* Add Fox H-function with rational A/B parameters (foxh()), see #982 (Hongren Zheng)
* Provide experimental support for free-threading builds, see #993 (Sergey B Kirpichev)
Compatibility:
* Drop Python 2 support, see #629 (Fangchen Li)
* Drop support for Python versions < 3.9, see #675 and #911 (Sergey B Kirpichev)
* Drop private mpq class, use Rational's, provided by backend, see #691 and
#769 (Sergey B Kirpichev)
* Drop to_pickable()/from_pickable() helpers, see #667 and #769 (Sergey B
Kirpichev)
* Direct access to _mpf_ tuples now deprecated, please use from/to_man_exp()
functions and special constants (finf, fninf and fnan), see
#783 (Sergey B Kirpichev)
* Removed sage backend, see #732 (Sergey B Kirpichev)
* Drop MPMATH_STRICT environment variable, see #759 (Sergey B Kirpichev)
* Deprecate current (descending) order of coefficients in polyval(), etc, see
#779, #844 and #845 (Sergey B Kirpichev, Warren Weckesser)
* Deprecate mpmath.math2, see #769 (Sergey B Kirpichev)
* Importing from the mpmath.libmp submodules is deprecated, use instead ``from
mpmath.libmp import foo``, see
issue https://github.com/mpmath/mpmath/issues/704#issuecomment-2953536980
for available functions (Sergey B Kirpichev)
* Deprecate bitcount function, see #721 and #955 (Sergey B Kirpichev)
* Deprecate mpf/mpc_log, see #989 (Sergey B Kirpichev)
* Deprecate fp.is_special(), see #1042 (Sergey B Kirpichev)
Bug fixes:
* sum_accurately(), betainc() and power() fixes, see #664 (Sergey B Kirpichev)
* Warn users about Python's true division, see #670 (Sergey B Kirpichev)
* Propagate nan's in ei_asympt(), see #672 (Sergey B Kirpichev)
* Fix matrix.__eq__, fix string parsing with underscores, see #679 (Sergey B
Kirpichev)
* Raise IndexError if matrix index out of bounds, see #689 (Sergey B
Kirpichev)
* Fix nan handling in fp.mag() and hyper(), see #688 (Sergey B Kirpichev)
* Optimize sparse matrix dot product, see #450 (Tyler Chen)
* Correct pow() for mpf's to be consistent with mpfr/float's, see #690 (Sergey
B Kirpichev)
* Improve hypsum non-convergence behaviour, see #703 (Benjamin Fischer)
* Fixed TypeError in LU_comp, see #610 (Jan-Philipp Hoffmann)
* Fix disagreement fp.mod vs mp.mod, see #710 (Sergey B Kirpichev)
* Skip eigenvectors if left=right=False for one-dimentional matrix, see #713
(Sergey B Kirpichev)
* Fix mpc() constructor to be compatible with complex(), fix disagreement
fp.pow vs mp.pow, see #731 (Sergey B Kirpichev)
* Add derivative keyword argument for besselk(), see #735 (Sergey B Kirpichev)
* Fix quadosc(), fast case in _hyp2f1(), correct fp.gamma() and fp.isnprint(),
see #740 (Sergey B Kirpichev)
* Pevent erroneous setting of dps/prec on mpmath module, see #678
(Colin B. Macdonald)
* Update splot() for recent matplotlib, see #747 (Sergey B Kirpichev)
* acos_asin(): don't try to normalize special numbers, fix repr(mp.eps), see
#750 (Sergey B Kirpichev)
* Fix choleksy_solve for complex matrix, see #755 (Qiming Sun)
* Fix hang in polylog_general(), fix demos, use cholesky_solve() for
overdetermined complex linear systems, fix several issues with empty
matrices, see #759
* sqrt(z): special case for infinite z.imag, see #777 (Sergey B Kirpichev)
* Correct atan2(±inf, ±inf), see #775 (Sergey B Kirpichev)
* Handle infinite arguments in tan/tanh, see #785 (Sergey B Kirpichev)
* Drop mpf.__complex__(), workaround 1/z division for acot/asec/acsc/acoth,
see #797 (Sergey B Kirpichev)
* Handle more special cases in besselk and hyp1f1, see #792, #800 and #801
(Sergey B Kirpichev)
* Correct asin/acos for infinite arguments, see #795 (Sergey B Kirpichev)
* Reduce memory usage for QuadratureRule cache, see #812 (Sergey B Kirpichev)
* Drop sign from nstr(mpf('inf')) output, see #828 (Sergey B Kirpichev)
* Improve accuracy of log1p(), see #803 and #854 (Tim Peters, Sergey B
Kirpichev)
* Normalize mpf in mp.npconvert(), fix special cases in bernpoly(), see #839
(Sergey B Kirpichev)
* Fix mpf_div() for prec=0, see #849 (Sergey B Kirpichev)
* Raise ValueError for complex infininity condition in zeta(s, a), see #864
(Sergey B Kirpichev)
* Enable trap_complex for MDNewton, see #870 (Sergey B Kirpichev)
* Use correct mixed-mode functions in fsub/fdiv, add special cases for
infinities in mpc_*div(), see #873 (Sergey B Kirpichev)
* Revert "fix ellippi to return an inf instead of raising an exception", see
#875 (Sergey B Kirpichev)
* Reject invalid strings in from_str(), see #886 (Sergey B Kirpichev)
* Use parity formula for besseli, see #889 (Sergey B Kirpichev)
* Special case in ctx.hypsum for infinite z, see #902 (Sergey B Kirpichev)
* Raise an exception if iv's comparison can't be decided, see #903 (Sergey B
Kirpichev)
* Add special case for ±inf in polylog_continuation(), see #904, #1034
and #1037 (Sergey B Kirpichev, Colin B. Macdonald)
* Increase working precision in polylog_general() for negative s, see #898
(Sergey B Kirpichev)
* Correct case for integer n in besselj/besseli, see #909 (Sergey B Kirpichev)
* Use sum_accurately() in hankel1/2(), see #926 (Sergey B Kirpichev)
* Ensure mpf_bernoulli() returns normalized answer, see #939 (Sergey B
Kirpichev)
* Use mpf_log1p in acos_asin() helper (implementing Hull et al algorithm), see
#948 and #1036 (Sergey B Kirpichev)
* Fix kwargs passing in the nstr() for mpc, see #964 (David Walker)
* Fix exception type for int(inf), see #966 (Sergey B Kirpichev)
* Ensure exp, sin, tan, etc have a correct __name__ attribute, see #997
(Warren Weckesser)
* Matrix raise ValueError in case of negative dimensions, see #1004 (Ayush
Baranwal)
* Support lists in sinm() and cosm(), see #1003 (Ayush Baranwal)
* Properly handle nan's elliprj(), see #1038 (Sergey B Kirpichev)
* Raise ValueError for logm(0), see #1017 (Ayush Baranwal)
* Fix erf(z) with re(z) of large magnitude, see #1039 (Sergey B Kirpichev)
* Return nan's for polylog(s, nan) or polylog(s, nan+nanj),
see #1041 (Sergey B Kirpichev)
* Fix fp.isnormal() for subnormals, see #1042 (Sergey B Kirpichev)
Maintenance:
* Use codecov/coverage-action, see #674 (Sergey B Kirpichev)
* Run CI tests with pytest-xdist, see #685 (Sergey B Kirpichev)
* Add pyproject.toml, depend on flake518, see #684 (Sergey B Kirpichev)
* Port torture.py/extratest_zeta.py/extratest_gamma.py to the pytest
framework, see #687 (Sergey B Kirpichev)
* Create CITATION.bib, see #681 (Devharsh Trivedi)
* Avoid using star imports in tests and documentation, see #698 (Sergey B
Kirpichev)
* Fix some py2's remnants and remove old gmpy workarounds, see #699 (Sergey B
Kirpichev)
* Use math.isqrt in isqrt_python calculations, see #695 (Daiki Takahashi)
* Use gcd() and other bigint's functions from the backend, see #697 (Sergey B
Kirpichev)
* Drop legacy and redundant code, see #701 (Sergey B Kirpichev)
* Change FPContext to use more functions from the stdlib, see #692 (Sergey B
Kirpichev)
* Avoid dynamic method creation in _mpf, see #702 (Sergey B Kirpichev)
* Enable testing on CPython 3.12-dev, see #706 (Sergey B Kirpichev)
* Use bit_length() method instead of bitcount(), see #721 (Sergey B Kirpichev)
* Use lru_cache() in ifib() and eulernum(), isprime() alternatives from
backends, see #722 (Sergey B Kirpichev)
* Use setuptools_scm to update __version__, see #694 (Sergey B Kirpichev)
* Run tests on 3.13, see #759 (Sergey B Kirpichev)
* Do not build depend on pip and wheel, see #758 (Gonzalo Tornaría)
* Add CONTRIBUTING.rst, see #763 (Sergey B Kirpichev)
* Simplify ctx_mp_python.py, see #806 (Sergey B Kirpichev)
* Update gmpy2 deps, see #808 and #813 (Sergey B Kirpichev)
* Enable testing on 3.14, see #851 (Sergey B Kirpichev)
* Refactor Github Actions, see #905 (Sergey B Kirpichev)
* Build and publish wheel, see #913 (David Hotham)
* Use the intended setuptools_scm integration pattern, see #940 (Ronny
Pfannschmidt)
* Add backport action, see #1042 (Sergey B Kirpichev)
See the release milestone (1.4) for a complete list of issues and pull requests
involved in this release.
--1.3.0--
Released March 7, 2023
Security issues:
* Fixed ReDOS vulnerability in mpmathify() (CVE-2021-29063) (Vinzent Steinberg)
Features:
* Added quadsubdiv() for numerical integration with adaptive path splitting
(Fredrik Johansson)
* Added the Cohen algorithm for inverse Laplace transforms
(Guillermo Navas-Palencia)
* Some speedup of matrix multiplication (Fredrik Johansson)
* Optimizations to Carlson elliptic integrals (Paul Masson)
* Added signal functions (squarew(), trianglew(), sawtoothw(), unit_triangle()
sigmoidw()) (Nike Dattani, Deyan Mihaylov, Tina Yu)
Bug fixes:
* Correct mpf initialization from tuple for finf and fninf (Sergey B Kirpichev)
* Support QR decomposition for matrices of width 0 and 1 (Clemens Hofreither)
* Fixed some cases where elliprj() gave inaccurate results (Fredrik Johansson)
* Fixed cases where digamma() hangs for complex input (Fredrik Johansson)
* Fixed cases of polylog() with integer-valued parameter with complex type
(Fredrik Johansson)
* Fixed fp.nsum() with Euler-Maclaurin algorithm (Fredrik Johansson)
Maintenance:
* Dropped support for Python 3.4 (Sergey B Kirpichev)
* Documentation cleanup (Sergey B Kirpichev)
* Removed obsolete files (Sergey B Kirpichev)
* Added options to runtests.py to skip tests and exit on failure
(Jonathan Warner)
--1.2.0--
Released February 1, 2021
Features and optimizations:
* Support @ operator for matrix multiplication (Max Gaukler)
* Add eta() implementing the Dedekind eta function
* Optimized the python_trailing function (adhoc-king)
* Implement unary plus for matrices (Max Gaukler)
* Improved calculation of gram_index (p15-git-acc)
Compatibility:
* Enable sage backend by default only if SAGE_ROOT is set (Pauli Virtanen)
* Fix syntax warnings on CPython 3.8 (Sergey B Kirpichev)
* Changed version requirements to Python 2.7 and 3.4 or later
(Sergey B Kirpichev)
* Improvements to the setup and test code (Sergey B Kirpichev)
* Fix sys.version comparisons for compatibility with Python 3.10 (Jakub Wilk)
* Fixes to Python2/3 compatibility for printing (Christian Clauss)
Bug fixes:
* Fix a possible division by zero in shanks() (Pascal Hebbeker)
* Fixed indexing errors in deHoog, Knight & Stokes inverse laplace
transform algorithm (Kris Kuhlman)
* Corrected branch cuts of the elliprj() function in some cases
* Fix initialization of iv.matrix from non-interval matrix (Max Gaukler)
* Preserve function signatures in PrecisionManager (Viet Tran)
* Implemented float and complex conversions for ivmpf
(Jonathan Warner)
* Fixed issue with scalar-matrix multiplication for interval matrices
(Jonathan Warner)
* Fix estimation of quadrature error with multiple subintervals (Tom Minka)
* Fixed a problem with the defun decorators (Sergey B Kirpichev)
* Fix eigenvalue sorting by absolute value (Georg Ostrovski)
Cleanup:
* Documentation corrections (Paul Masson, S.Y. Lee)
* Remove inaccessible logic in fsum/fdot (Sergey B Kirpichev)
* Remove broken force_type option for matrix constructor (Max Gaukler)
* Fix text of the BSD license in LICENSE (Sergey B Kirpichev)
* Minor code cleanup (Frédéric Chapoton)
* Removed old, unused code
--1.1.0--
Released December 11, 2018
@@ -794,7 +1210,7 @@ New features:
Bugfixes, speed enhancements, and other improvements:
* compatibility tests should now pass on systems where Python is
compiled to use 80-bit registers for floating point operations
compiled to use 80-bit registers for floating-point operations
* fixed mpmath to work with some versions of Python 2.4 where a
list indexing bug is present in the Python core
* better algorithms for various complex elementary functions
+7
View File
@@ -0,0 +1,7 @@
@manual{mpmath,
key = {mpmath},
author = {The mpmath development team},
title = {mpmath: a {P}ython library for arbitrary-precision floating-point arithmetic (version 1.4.0)},
note = {{\tt https://mpmath.org/}},
year = {2026},
}
+4 -5
View File
@@ -1,4 +1,4 @@
Copyright (c) 2005-2018 Fredrik Johansson and mpmath contributors
Copyright (c) 2005-2026 Fredrik Johansson and mpmath contributors
All rights reserved.
@@ -10,10 +10,9 @@ modification, are permitted provided that the following conditions are met:
b. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
c. Neither the name of mpmath nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
c. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-4
View File
@@ -1,4 +0,0 @@
include mpmath/*.py
include mpmath/tests/*.py
include LICENSE
include CHANGES
+44 -43
View File
@@ -5,18 +5,18 @@ mpmath
.. |pypi version| image:: https://img.shields.io/pypi/v/mpmath.svg
:target: https://pypi.python.org/pypi/mpmath
.. |Build status| image:: https://secure.travis-ci.org/fredrik-johansson/mpmath.svg?branch=master
:target: https://travis-ci.org/fredrik-johansson/mpmath
.. |Build status| image:: https://github.com/mpmath/mpmath/workflows/test/badge.svg
:target: https://github.com/mpmath/mpmath/actions?workflow=test
.. |Zenodo Badge| image:: https://zenodo.org/badge/2934512.svg
:target: https://zenodo.org/badge/latestdoi/2934512
A Python library for arbitrary-precision floating-point arithmetic.
Website: http://mpmath.org/
Website: https://mpmath.org/
Main author: Fredrik Johansson <fredrik.johansson@gmail.com>
Mpmath is free software released under the New BSD License (see the
LICENSE file for details)
LICENSE file for details).
0. History and credits
----------------------
@@ -44,15 +44,16 @@ or new features to mpmath:
* Paul Masson <paulmasson@analyticphysics.com>
* Michael Kagalenko <michael.kagalenko@gmail.com>
* Jonathan Warner <warnerjon12@gmail.com>
* Max Gaukler <max.gaukler@fau.de>
* Guillermo Navas-Palencia <g.navas.palencia@gmail.com>
* Nike Dattani <nike@hpqc.org>
* Tim Peters <tim.peters@gmail.com>
* Javier Garcia <javier.garcia.tw@hotmail.com>
Numerous other people have contributed by reporting bugs,
requesting new features, or suggesting improvements to the
documentation.
Mpmath includes a copy of Benjamin Peterson's six.py for
Python 2/3 compatibility. six.py is provided under the MIT license
(see the source file for details).
For a detailed changelog, including individual contributions,
see the CHANGES file.
@@ -84,6 +85,11 @@ Credit also goes to:
Release history:
* Version 1.4.1 released on March 15, 2026
* Version 1.4.0 released on February 23, 2026
* Version 1.3.0 released on March 7, 2023
* Version 1.2.1 released on February 9, 2021
* Version 1.2.0 released on February 1, 2021
* Version 1.1.0 released on December 11, 2018
* Version 1.0.0 released on September 27, 2017
* Version 0.19 released on June 10, 2014
@@ -109,11 +115,11 @@ Release history:
1. Download & installation
--------------------------
Mpmath requires Python 2.5 or later. It has been tested
with CPython 2.7, 3.3 through 3.7 and for PyPy.
Mpmath requires Python 3.10 or later versions. It has been tested with CPython
3.10 through 3.15 and for PyPy 3.11.
The latest release of mpmath can be downloaded from the mpmath
website and from https://github.com/fredrik-johansson/mpmath/releases
website and from https://github.com/mpmath/mpmath/releases
It should also be available in the Python Package Index at
https://pypi.python.org/pypi/mpmath
@@ -122,45 +128,37 @@ To install latest release of Mpmath with pip, simply run
``pip install mpmath``
Or unpack the mpmath archive and run
or from the source tree
``python setup.py install``
Mpmath can also be installed using
``python -m easy_install mpmath``
``pip install .``
The latest development code is available from
https://github.com/fredrik-johansson/mpmath
https://github.com/mpmath/mpmath
See the main documentation for more detailed instructions.
2. Running tests
2. Documentation
----------------
The unit tests in mpmath/tests/ can be run via the script
runtests.py, but it is recommended to run them with py.test
(http://codespeak.net/py/dist/index.html), especially
to generate more useful reports in case there are failures.
Documentation in reStructuredText format is available in the
docs directory included with the source package. These files
are human-readable, but can be compiled to prettier HTML using
`Sphinx <https://www.sphinx-doc.org/>`_.
The most recent documentation is also available in HTML format:
https://mpmath.readthedocs.io/
3. Running tests
----------------
The unit tests in mpmath/tests/ can be run with `pytest
<https://pytest.org/>`_, see the main documentation.
You may also want to check out the demo scripts in the demo
directory.
The master branch is automatically tested by Travis CI.
3. Documentation
----------------
Documentation in reStructuredText format is available in the
doc directory included with the source package. These files
are human-readable, but can be compiled to prettier HTML using
the build.py script (requires Sphinx, http://sphinx.pocoo.org/).
See setup.txt in the documentation for more information.
The most recent documentation is also available in HTML format:
http://mpmath.org/doc/current/
The master branch is automatically tested on the Github Actions.
4. Known problems
-----------------
@@ -175,8 +173,8 @@ Mpmath is a work in progress. Major issues include:
or two units in the last place (even if otherwise accurate).
* Some IEEE 754 features are not available. Inifinities and NaN are
partially supported; denormal rounding is currently not available
at all.
partially supported, there is no signed zero; denormal rounding is
not available at all.
* The interface for switching precision and rounding is not finalized.
The current method is not threadsafe.
@@ -184,8 +182,11 @@ Mpmath is a work in progress. Major issues include:
5. Help and bug reports
-----------------------
General questions and comments can be sent to the mpmath mailinglist,
mpmath@googlegroups.com
General questions and comments can be `sent <mailto:mpmath@googlegroups.com>`_
to the `mpmath mailinglist <https://groups.google.com/g/mpmath>`_.
You can also report bugs and send patches to the mpmath issue tracker,
https://github.com/fredrik-johansson/mpmath/issues
https://github.com/mpmath/mpmath/issues
See also our `contributing guidelines
<https://github.com/mpmath/mpmath/blob/master/.github/CONTRIBUTING.rst>`_.
-1
View File
@@ -1 +0,0 @@
See README and the mpmath website for more information.
+36
View File
@@ -0,0 +1,36 @@
import sys
import pytest
import mpmath
def pytest_report_header(config):
print("mpmath backend: %s" % mpmath.libmp.backend.BACKEND)
print("mpmath mp class: %s" % repr(mpmath.mp))
print("mpmath version: %s" % mpmath.__version__)
print("Python version: %s" % sys.version)
def pytest_configure(config):
config.addinivalue_line('markers', 'slow: marks tests as slow')
if "no:hypothesispytest" not in config.getoption("-p"):
from hypothesis import settings
default = settings.get_profile("default")
settings.register_profile("default",
settings(default, max_examples=1000))
ci = settings.get_profile("ci")
settings.register_profile("ci", settings(ci, max_examples=10000))
@pytest.fixture(autouse=True)
def reset_mp_globals():
mpmath.mp.prec = sys.float_info.mant_dig
mpmath.mp.pretty = False
mpmath.mp.rounding = 'n'
mpmath.mp.pretty_dps = "str"
mpmath.mp.shortest_str = False
mpmath.iv.prec = mpmath.mp.prec
mpmath.iv.pretty = False
+1 -2
View File
@@ -5,7 +5,6 @@ to improve accuracy at extremely high zoom levels.
"""
import mpmath
import cmath
ctx = mpmath.fp
# ctx = mpmath.mp
@@ -24,7 +23,7 @@ IM = [-1.5, 1.5]
def mandelbrot(z):
c = z
for i in xrange(ITERATIONS):
for i in range(ITERATIONS):
zprev = z
z = z*z + c
if abs(z) > ESCAPE_RADIUS:
+54 -52
View File
@@ -8,9 +8,11 @@ Run with:
python manydigits.py
"""
from mpmath import (asin, asinh, atan, atanh, catalan, cos, e, exp, findroot,
mp, mpf, pi, quadts, sin, sqrt, tan, tanh, zeta)
from mpmath.libmp.libintmath import bin_to_radix
from mpmath.libmp.libmpf import to_fixed
from mpmath import *
from mpmath.libmp import to_fixed, bin_to_radix
dps = 100
mp.dps = dps + 10
@@ -24,81 +26,81 @@ def pr(x):
s = str(d).zfill(dps)[-dps:]
return s[:dps//2] + "\n" + s[dps//2:]
print """
print("""
This script prints answers to a selection of the "Many Digits"
competition problems: http://www.cs.ru.nl/~milad/manydigits/problems.php
The output for each problem is the first 100 digits after the
decimal point in the result.
"""
""")
print "C01: sin(tan(cos(1)))"
print pr(sin(tan(cos(1))))
print
print("C01: sin(tan(cos(1)))")
print(pr(sin(tan(cos(1)))))
print()
print "C02: sqrt(e/pi)"
print pr(sqrt(e/pi))
print
print("C02: sqrt(e/pi)")
print(pr(sqrt(e/pi)))
print()
print "C03: sin((e+1)^3)"
print pr(sin((e+1)**3))
print
print("C03: sin((e+1)^3)")
print(pr(sin((e+1)**3)))
print()
print "C04: exp(pi*sqrt(2011))"
print("C04: exp(pi*sqrt(2011))")
mp.dps += 65
print pr(exp(pi*sqrt(2011)))
print(pr(exp(pi*sqrt(2011))))
mp.dps -= 65
print
print()
print "C05: exp(exp(exp(1/2)))"
print pr(exp(exp(exp(0.5))))
print
print("C05: exp(exp(exp(1/2)))")
print(pr(exp(exp(exp(0.5)))))
print()
print "C06: arctanh(1-arctanh(1-arctanh(1-arctanh(1/pi))))"
print pr(atanh(1-atanh(1-atanh(1-atanh(1/pi)))))
print
print("C06: arctanh(1-arctanh(1-arctanh(1-arctanh(1/pi))))")
print(pr(atanh(1-atanh(1-atanh(1-atanh(1/pi))))))
print()
print "C07: pi^1000"
print("C07: pi^1000")
mp.dps += 505
print pr(pi**1000)
print(pr(pi**1000))
mp.dps -= 505
print
print()
print "C08: sin(6^(6^6))"
print pr(sin(6**(6**6)))
print
print("C08: sin(6^(6^6))")
print(pr(sin(6**(6**6))))
print()
print "C09: sin(10*arctan(tanh(pi*(2011^(1/2))/3)))"
print("C09: sin(10*arctan(tanh(pi*(2011^(1/2))/3)))")
mp.dps += 150
print pr(sin(10*atan(tanh(pi*sqrt(2011)/3))))
print(pr(sin(10*atan(tanh(pi*sqrt(2011)/3)))))
mp.dps -= 150
print
print()
print "C10: (7+2^(1/5)-5*(8^(1/5)))^(1/3) + 4^(1/5)-2^(1/5)"
print("C10: (7+2^(1/5)-5*(8^(1/5)))^(1/3) + 4^(1/5)-2^(1/5)")
a = mpf(1)/5
print pr(((7 + 2**a - 5*(8**a))**(mpf(1)/3) + 4**a - 2**a))
print
print(pr(((7 + 2**a - 5*(8**a))**(mpf(1)/3) + 4**a - 2**a)))
print()
print "C11: tan(2^(1/2))+arctanh(sin(1))"
print pr((tan(sqrt(2)) + atanh(sin(1))))
print
print("C11: tan(2^(1/2))+arctanh(sin(1))")
print(pr((tan(sqrt(2)) + atanh(sin(1)))))
print()
print "C12: arcsin(1/e^2) + arcsinh(e^2)"
print pr(asin(1/exp(2)) + asinh(exp(2)))
print
print("C12: arcsin(1/e^2) + arcsinh(e^2)")
print(pr(asin(1/exp(2)) + asinh(exp(2))))
print()
print "C17: S= -4*Zeta(2) - 2*Zeta(3) + 4*Zeta(2)*Zeta(3) + 2*Zeta(5)"
print pr(-4*zeta(2) - 2*zeta(3) + 4*zeta(2)*zeta(3) + 2*zeta(5))
print
print("C17: S= -4*Zeta(2) - 2*Zeta(3) + 4*Zeta(2)*Zeta(3) + 2*Zeta(5)")
print(pr(-4*zeta(2) - 2*zeta(3) + 4*zeta(2)*zeta(3) + 2*zeta(5)))
print()
print "C18: Catalan G = Sum{i=0}{\infty}(-1)^i/(2i+1)^2"
print pr(catalan)
print
print(r"C18: Catalan G = Sum{i=0}{\infty}(-1)^i/(2i+1)^2")
print(pr(catalan))
print()
print "C21: Equation exp(cos(x)) = x"
print pr(findroot(lambda x: exp(cos(x))-x, 1))
print
print("C21: Equation exp(cos(x)) = x")
print(pr(findroot(lambda x: exp(cos(x))-x, 1)))
print()
print "C22: J = integral(sin(sin(sin(x)))), x=0..1"
print pr(quadts(lambda x: sin(sin(sin(x))), [0, 1]))
print
print("C22: J = integral(sin(sin(sin(x)))), x=0..1")
print(pr(quadts(lambda x: sin(sin(sin(x))), [0, 1])))
print()
+24 -23
View File
@@ -4,13 +4,14 @@ Calculate digits of pi. This module can be run interactively with
python pidigits.py
"""
__docformat__ = 'plaintext'
import sys
import math
from time import clock
import sys
from time import perf_counter
from mpmath.libmp.libelefun import pi_fixed
from mpmath.libmp.libintmath import bin_to_radix, numeral
from mpmath.libmp import bin_to_radix, numeral, pi_fixed
def display_fraction(digits, skip=0, colwidth=10, columns=5):
perline = colwidth * columns
@@ -18,10 +19,10 @@ def display_fraction(digits, skip=0, colwidth=10, columns=5):
for linecount in range((len(digits)-skip) // (colwidth * columns)):
line = digits[skip+linecount*perline:skip+(linecount+1)*perline]
for i in range(columns):
print line[i*colwidth : (i+1)*colwidth],
print ":", (linecount+1)*perline
print(line[i*colwidth : (i+1)*colwidth], end=' ')
print(":", (linecount+1)*perline)
if (linecount+1) % 10 == 0:
print
print()
printed += colwidth*columns
rem = (len(digits)-skip) % (colwidth * columns)
if rem:
@@ -30,7 +31,7 @@ def display_fraction(digits, skip=0, colwidth=10, columns=5):
for i in range(columns):
s += buf[:colwidth].ljust(colwidth+1, " ")
buf = buf[colwidth:]
print s + ":", printed + colwidth*columns
print(s + ":", printed + colwidth*columns)
def calculateit(base, n, tofile):
intpart = numeral(3, base)
@@ -40,42 +41,42 @@ def calculateit(base, n, tofile):
prec = int(n*math.log(base,2))+10
print "Step 1 of 2: calculating binary value..."
t = clock()
print("Step 1 of 2: calculating binary value...")
t = perf_counter()
a = pi_fixed(prec, verbose=True, verbose_base=base)
step1_time = clock() - t
step1_time = perf_counter() - t
print "Step 2 of 2: converting to specified base..."
t = clock()
print("Step 2 of 2: converting to specified base...")
t = perf_counter()
d = bin_to_radix(a, prec, base, n)
d = numeral(d, base, n)
step2_time = clock() - t
step2_time = perf_counter() - t
print "\nWriting output...\n"
print("\nWriting output...\n")
if tofile:
out_ = sys.stdout
sys.stdout = tofile
print "%i base-%i digits of pi:\n" % (n, base)
print intpart, ".\n"
print("%i base-%i digits of pi:\n" % (n, base))
print(intpart, ".\n")
display_fraction(d, skip, colwidth=10, columns=5)
if tofile:
sys.stdout = out_
print "\nFinished in %f seconds (%f calc, %f convert)" % \
((step1_time + step2_time), step1_time, step2_time)
print("\nFinished in %f seconds (%f calc, %f convert)" % \
((step1_time + step2_time), step1_time, step2_time))
def interactive():
print "Compute digits of pi with mpmath\n"
print("Compute digits of pi with mpmath\n")
base = input("Which base? (2-36, 10 for decimal) \n> ")
digits = input("How many digits? (enter a big number, say, 10000)\n> ")
tofile = raw_input("Output to file? (enter a filename, or just press " \
tofile = input("Output to file? (enter a filename, or just press " \
"enter\nto print directly to the screen) \n> ")
if tofile:
tofile = open(tofile, "w")
calculateit(base, digits, tofile)
raw_input("\nPress enter to close this script.")
calculateit(int(base), int(digits), tofile)
input("\nPress enter to close this script.")
if __name__ == "__main__":
interactive()
+10 -11
View File
@@ -1,36 +1,35 @@
"""
Function plotting demo.
"""
from mpmath import *
def main():
print """
print("""
Simple function plotting. You can enter one or several
formulas, in ordinary Python syntax and using the mpmath
function library. The variable is 'x'. So for example
the input "sin(x/2)" (without quotation marks) defines
a valid function.
"""
""")
functions = []
for i in xrange(10):
for i in range(10):
if i == 0:
s = raw_input('Enter a function: ')
s = input('Enter a function: ')
else:
s = raw_input('Enter another function (optional): ')
s = input('Enter another function (optional): ')
if not s:
print
print()
break
f = eval("lambda x: " + s)
functions.append(f)
print "Added f(x) = " + s
print
xlim = raw_input('Enter xmin, xmax (optional): ')
print("Added f(x) = " + s)
print()
xlim = input('Enter xmin, xmax (optional): ')
if xlim:
xlim = eval(xlim)
else:
xlim = [-5, 5]
print "Plotting..."
print("Plotting...")
plot(functions, xlim=xlim)
main()
+63
View File
@@ -0,0 +1,63 @@
'''
This script calculates the constant in Gerver's solution to the moving sofa
problem.
See Finch, S. R. "Moving Sofa Constant." §8.12 in Mathematical Constants.
Cambridge, England: Cambridge University Press, pp. 519-523, 2003.
'''
from mpmath import cos, sin, pi, quad, findroot, mp
mp.prec = 113
eqs = [lambda A, B, φ, θ: (A*(cos(θ) - cos(φ)) - 2*B*sin(φ)
+ (θ - φ - 1)*cos(θ) - sin(θ) + cos(φ) + sin(φ)),
lambda A, B, φ, θ: (A*(3*sin(θ) + sin(φ)) - 2*B*cos(φ)
+ 3*(θ - φ - 1)*sin(θ) + 3*cos(θ) - sin(φ) + cos(φ)),
lambda A, B, φ, θ: A*cos(φ) - (sin(φ) + 0.5 - 0.5*cos(φ) + B*sin(φ)),
lambda A, B, φ, θ: ((A + pi/2 - φ - θ) - (B - (θ - φ)*(1 + A)/2
- 0.25*(θ - φ)**2))]
A, B, φ, θ = findroot(eqs, (0, 0, 0, 0))
def r(α):
if 0 <= α < φ:
return 0.5
if φ <= α < θ:
return (1 + A + α - φ)/2
if θ <= α < pi/2 - θ:
return A + α - φ
return B - (pi/2 - α - φ)*(1 + A)/2 - (pi/2 - α - φ)**2/4
s = lambda α: 1 - r(α)
def u(α):
if φ <= α < θ:
return B - (α - φ)*(1 + A)/2 - (α - φ)**2/4
return A + pi/2 - φ - α
def du(α):
if φ <= α < θ:
return -(1 + A)/2 - (α - φ)/2
return -1
def y(α, f):
if α > pi/2 - θ:
i = [0, φ, θ, pi/2 - θ, α]
elif α > θ:
i = [0, φ, θ, α]
elif α > φ:
i = [0, φ, α]
else:
i = i = [0, α]
return 1 - quad(lambda x: f(x)*sin(x), i)
y1 = lambda α: y(α, r)
y2 = lambda α: y(α, s)
y3 = lambda α: y2(α) - u(α)*sin(α)
S1 = quad(lambda x: y1(x)*r(x)*cos(x), [0, φ, θ, pi/2 - θ, pi/2 - φ])
S2 = quad(lambda x: y2(x)*s(x)*cos(x), [0, φ, θ])
S3 = quad(lambda x: y3(x)*(u(x)*sin(x) - du(x)*cos(x) - s(x)*cos(x)),
[φ, θ, pi/4])
print(2*(S1 + S2 + S3))
+34 -35
View File
@@ -6,24 +6,23 @@ This module can be run interactively with
python taylor.py
"""
from mpmath import *
from mpmath import mpi, exp, factorial, mpf
def taylor(x, n):
print "-"*75
print("-"*75)
t = x = mpi(x)
s = 1
print "adding 1"
print s, "\n"
print("adding 1")
print(s, "\n")
s += t
print "adding x"
print s, "\n"
print("adding x")
print(s, "\n")
for k in range(2, n+1):
t = (t * x) / k
s += t
print "adding x^%i / %i! ~= %s" % (k, k, t.mid)
print s, "\n"
print "-"*75
print("adding x^%i / %i! ~= %s" % (k, k, t.mid))
print(s, "\n")
print("-"*75)
return s
# Note: this should really be computed using interval arithmetic too!
@@ -41,32 +40,32 @@ def exponential(x, n):
t = taylor(x, n)
r = remainder(x, n)
expx = exp(x)
print "Correct value of exp(x): ", expx
print
print "Computed interval: "
print t
print
print "Computed value (midpoint): ", t.mid
print
print "Estimated rounding error: ", t.delta
print "Estimated truncation error: ", r
print "Estimated total error: ", t.delta + r
print "Actual error ", abs(expx - t.mid)
print
print("Correct value of exp(x): ", expx)
print()
print("Computed interval: ")
print(t)
print()
print("Computed value (midpoint): ", t.mid)
print()
print("Estimated rounding error: ", t.delta)
print("Estimated truncation error: ", r)
print("Estimated total error: ", t.delta + r)
print("Actual error ", abs(expx - t.mid))
print()
u = t + mpi(-r, r)
print "Interval with est. truncation error added:"
print u
print
print "Correct value contained in computed interval:", t.a <= expx <= t.b
print "When accounting for truncation error:", u.a <= expx <= u.b
print("Interval with est. truncation error added:")
print(u)
print()
print("Correct value contained in computed interval:", t.a <= expx <= t.b)
print("When accounting for truncation error:", u.a <= expx <= u.b)
if __name__ == "__main__":
print "Interval arithmetic demo"
print
print "This script sums the Taylor series for exp(x) using interval arithmetic,"
print "and then compares the numerical errors due to rounding and truncation."
print
x = mpf(raw_input("Enter the value of x (e.g. 3.5): "))
n = int(raw_input("Enter the number of terms n (e.g. 10): "))
print
print("Interval arithmetic demo")
print()
print("This script sums the Taylor series for exp(x) using interval arithmetic,")
print("and then compares the numerical errors due to rounding and truncation.")
print()
x = mpf(input("Enter the value of x (e.g. 3.5): "))
n = int(input("Enter the number of terms n (e.g. 10): "))
print()
exponential(x, n)
-6
View File
@@ -1,6 +0,0 @@
#!/usr/bin/env python
import os
if not os.path.exists("build"):
os.mkdir("build")
os.system("sphinx-build -E source build")
-14
View File
@@ -1,14 +0,0 @@
Numerical calculus
==================
.. toctree::
:maxdepth: 2
polynomials.txt
optimization.txt
sums_limits.txt
differentiation.txt
integration.txt
odes.txt
approximation.txt
inverselaplace.txt
-138
View File
@@ -1,138 +0,0 @@
# -*- coding: utf-8 -*-
#
# mpmath documentation build configuration file, created by
# sphinx-quickstart on Sun Apr 13 00:14:30 2008.
#
# This file is execfile()d with the current directory set to its containing dir.
#
# The contents of this file are pickled, so don't put values in the namespace
# that aren't pickleable (module imports are okay, they're removed automatically).
#
# All configuration values have a default value; values that are commented out
# serve to show the default value.
import sys
# If your extensions are in another directory, add it here.
sys.path.insert(0, '../..')
# General configuration
# ---------------------
# Add any Sphinx extension module names here, as strings. They can be extensions
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
extensions = ['sphinx.ext.autodoc', 'sphinx.ext.mathjax']
# MathJax file, which is free to use. See http://www.mathjax.org/docs/2.0/start.html
# mathjax_path = 'http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML-full'
# Add any paths that contain templates here, relative to this directory.
templates_path = []
# The suffix of source filenames.
source_suffix = '.txt'
# The master toctree document.
master_doc = 'index'
# General substitutions.
project = 'mpmath'
copyright = '2007-2018, Fredrik Johansson and mpmath developers'
# The default replacements for |version| and |release|, also used in various
# other places throughout the built documents.
#
# The short X.Y version.
import mpmath
version = mpmath.__version__
# The full version, including alpha/beta/rc tags.
release = mpmath.__version__
# There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used:
#today = ''
# Else, today_fmt is used as the format for a strftime call.
today_fmt = '%B %d, %Y'
# List of documents that shouldn't be included in the build.
#unused_docs = []
# If true, '()' will be appended to :func: etc. cross-reference text.
#add_function_parentheses = True
# If true, the current module name will be prepended to all description
# unit titles (such as .. function::).
#add_module_names = True
# If true, sectionauthor and moduleauthor directives will be shown in the
# output. They are ignored by default.
#show_authors = False
# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
# Options for HTML output
# -----------------------
# The "theme" that the HTML output should use.
html_theme = 'classic'
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = []
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
# using the given strftime format.
html_last_updated_fmt = '%b %d, %Y'
# If true, SmartyPants will be used to convert quotes and dashes to
# typographically correct entities.
#html_use_smartypants = True
# Content template for the index page.
#html_index = ''
# Custom sidebar templates, maps document names to template names.
#html_sidebars = {}
# Additional templates that should be rendered to pages, maps page names to
# template names.
#html_additional_pages = {}
# If false, no module index is generated.
#html_use_modindex = True
# If true, the reST sources are included in the HTML build as _sources/<name>.
#html_copy_source = True
# Output file base name for HTML help builder.
htmlhelp_basename = 'mpmathdoc'
# Options for LaTeX output
# ------------------------
# The paper size ('letter' or 'a4').
#latex_paper_size = 'letter'
# The font size ('10pt', '11pt' or '12pt').
#latex_font_size = '10pt'
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title, author, document class [howto/manual]).
latex_documents = [(master_doc, 'main.tex', 'mpmath documentation',
r'Fredrik Johansson \and mpmath contributors', 'manual')]
# Additional stuff for the LaTeX preamble.
latex_preamble = r'\usepackage{amsfonts}'
# Documents to append as an appendix to all manuals.
#latex_appendices = []
# If false, no module index is generated.
#latex_use_modindex = True
default_role = 'math'
pngmath_dvipng_args = ['-gamma 1.5', '-D 110']
Binary file not shown.

Before

Width:  |  Height:  |  Size: 42 KiB

-185
View File
@@ -1,185 +0,0 @@
Bessel functions and related functions
--------------------------------------
The functions in this section arise as solutions to various differential equations in physics, typically describing wavelike oscillatory behavior or a combination of oscillation and exponential decay or growth. Mathematically, they are special cases of the confluent hypergeometric functions `\,_0F_1`, `\,_1F_1` and `\,_1F_2` (see :doc:`hypergeometric`).
Bessel functions
...................................................
:func:`besselj`
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.besselj(n,x,derivative=0)
.. autofunction:: mpmath.j0(x)
.. autofunction:: mpmath.j1(x)
:func:`bessely`
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.bessely(n,x,derivative=0)
:func:`besseli`
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.besseli(n,x,derivative=0)
:func:`besselk`
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.besselk(n,x)
Bessel function zeros
...............................
:func:`besseljzero`
^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.besseljzero(v,m,derivative=0)
:func:`besselyzero`
^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.besselyzero(v,m,derivative=0)
Hankel functions
................
:func:`hankel1`
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.hankel1(n,x)
:func:`hankel2`
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.hankel2(n,x)
Kelvin functions
................
:func:`ber`
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.ber
:func:`bei`
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.bei
:func:`ker`
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.ker
:func:`kei`
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.kei
Struve functions
...................................................
:func:`struveh`
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.struveh
:func:`struvel`
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.struvel
Anger-Weber functions
...................................................
:func:`angerj`
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.angerj
:func:`webere`
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.webere
Lommel functions
...................................................
:func:`lommels1`
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.lommels1
:func:`lommels2`
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.lommels2
Airy and Scorer functions
...............................................
:func:`airyai`
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.airyai(z, derivative=0, **kwargs)
:func:`airybi`
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.airybi(z, derivative=0, **kwargs)
:func:`airyaizero`
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.airyaizero(k, derivative=0)
:func:`airybizero`
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.airybizero(k, derivative=0, complex=0)
:func:`scorergi`
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.scorergi(z, **kwargs)
:func:`scorerhi`
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.scorerhi(z, **kwargs)
Coulomb wave functions
...............................................
:func:`coulombf`
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.coulombf(l,eta,z)
:func:`coulombg`
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.coulombg(l,eta,z)
:func:`coulombc`
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.coulombc(l,eta)
Confluent U and Whittaker functions
...................................
:func:`hyperu`
^^^^^^^^^^^^^^
.. autofunction:: mpmath.hyperu(a, b, z)
:func:`whitm`
^^^^^^^^^^^^^^
.. autofunction:: mpmath.whitm(k,m,z)
:func:`whitw`
^^^^^^^^^^^^^^
.. autofunction:: mpmath.whitw(k,m,z)
Parabolic cylinder functions
.................................
:func:`pcfd`
^^^^^^^^^^^^^^
.. autofunction:: mpmath.pcfd(n,z,**kwargs)
:func:`pcfu`
^^^^^^^^^^^^^^
.. autofunction:: mpmath.pcfu(a,z,**kwargs)
:func:`pcfv`
^^^^^^^^^^^^^^
.. autofunction:: mpmath.pcfv(a,z,**kwargs)
:func:`pcfw`
^^^^^^^^^^^^^^
.. autofunction:: mpmath.pcfw(a,z,**kwargs)
-85
View File
@@ -1,85 +0,0 @@
Mathematical constants
----------------------
Mpmath supports arbitrary-precision computation of various common (and less common) mathematical constants. These constants are implemented as lazy objects that can evaluate to any precision. Whenever the objects are used as function arguments or as operands in arithmetic operations, they automagically evaluate to the current working precision. A lazy number can be converted to a regular ``mpf`` using the unary ``+`` operator, or by calling it as a function::
>>> from mpmath import *
>>> mp.dps = 15
>>> pi
<pi: 3.14159~>
>>> 2*pi
mpf('6.2831853071795862')
>>> +pi
mpf('3.1415926535897931')
>>> pi()
mpf('3.1415926535897931')
>>> mp.dps = 40
>>> pi
<pi: 3.14159~>
>>> 2*pi
mpf('6.283185307179586476925286766559005768394338')
>>> +pi
mpf('3.141592653589793238462643383279502884197169')
>>> pi()
mpf('3.141592653589793238462643383279502884197169')
Exact constants
...............
The predefined objects :data:`j` (imaginary unit), :data:`inf` (positive infinity) and :data:`nan` (not-a-number) are shortcuts to :class:`mpc` and :class:`mpf` instances with these fixed values.
Pi (``pi``)
....................................
.. autoattribute:: mpmath.mp.pi
Degree (``degree``)
....................................
.. autoattribute:: mpmath.mp.degree
Base of the natural logarithm (``e``)
.....................................
.. autoattribute:: mpmath.mp.e
Golden ratio (``phi``)
......................
.. autoattribute:: mpmath.mp.phi
Euler's constant (``euler``)
............................
.. autoattribute:: mpmath.mp.euler
Catalan's constant (``catalan``)
................................
.. autoattribute:: mpmath.mp.catalan
Apery's constant (``apery``)
............................
.. autoattribute:: mpmath.mp.apery
Khinchin's constant (``khinchin``)
..................................
.. autoattribute:: mpmath.mp.khinchin
Glaisher's constant (``glaisher``)
..................................
.. autoattribute:: mpmath.mp.glaisher
Mertens constant (``mertens``)
..................................
.. autoattribute:: mpmath.mp.mertens
Twin prime constant (``twinprime``)
...................................
.. autoattribute:: mpmath.mp.twinprime
-96
View File
@@ -1,96 +0,0 @@
Elliptic functions
------------------
.. automodule :: mpmath.functions.elliptic
Elliptic arguments
...................................................
:func:`qfrom`
^^^^^^^^^^^^^
.. autofunction:: mpmath.qfrom(**kwargs)
:func:`qbarfrom`
^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.qbarfrom(**kwargs)
:func:`mfrom`
^^^^^^^^^^^^^
.. autofunction:: mpmath.mfrom(**kwargs)
:func:`kfrom`
^^^^^^^^^^^^^
.. autofunction:: mpmath.kfrom(**kwargs)
:func:`taufrom`
^^^^^^^^^^^^^^^
.. autofunction:: mpmath.taufrom(**kwargs)
Legendre elliptic integrals
...................................................
:func:`ellipk`
^^^^^^^^^^^^^^
.. autofunction:: mpmath.ellipk(m, **kwargs)
:func:`ellipf`
^^^^^^^^^^^^^^
.. autofunction:: mpmath.ellipf(phi, m)
:func:`ellipe`
^^^^^^^^^^^^^^
.. autofunction:: mpmath.ellipe(*args)
:func:`ellippi`
^^^^^^^^^^^^^^^
.. autofunction:: mpmath.ellippi(*args)
Carlson symmetric elliptic integrals
...................................................
:func:`elliprf`
^^^^^^^^^^^^^^^
.. autofunction:: mpmath.elliprf(x, y, z)
:func:`elliprc`
^^^^^^^^^^^^^^^
.. autofunction:: mpmath.elliprc(x, y, pv=True)
:func:`elliprj`
^^^^^^^^^^^^^^^
.. autofunction:: mpmath.elliprj(x, y, z, p)
:func:`elliprd`
^^^^^^^^^^^^^^^
.. autofunction:: mpmath.elliprd(x, y, z)
:func:`elliprg`
^^^^^^^^^^^^^^^
.. autofunction:: mpmath.elliprg(x, y, z)
Jacobi theta functions
......................
:func:`jtheta`
^^^^^^^^^^^^^^
.. autofunction:: mpmath.jtheta(n,z,q,derivative=0)
Jacobi elliptic functions
.................................................................
:func:`ellipfun`
^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.ellipfun(kind,u=None,m=None,q=None,k=None,tau=None)
Modular functions
......................
:func:`kleinj`
^^^^^^^^^^^^^^^
.. autofunction:: mpmath.kleinj(tau=None, **kwargs)
-104
View File
@@ -1,104 +0,0 @@
Exponential integrals and error functions
-----------------------------------------
Exponential integrals give closed-form solutions to a large class of commonly occurring transcendental integrals that cannot be evaluated using elementary functions. Integrals of this type include those with an integrand of the form `t^a e^{t}` or `e^{-x^2}`, the latter giving rise to the Gaussian (or normal) probability distribution.
The most general function in this section is the incomplete gamma function, to which all others can be reduced. The incomplete gamma function, in turn, can be expressed using hypergeometric functions (see :doc:`hypergeometric`).
Incomplete gamma functions
..........................
:func:`gammainc`
^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.gammainc(z, a=0, b=inf, regularized=False)
Exponential integrals
.....................
:func:`ei`
^^^^^^^^^^
.. autofunction:: mpmath.ei(x, **kwargs)
:func:`e1`
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.e1(x, **kwargs)
:func:`expint`
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.expint(*args)
Logarithmic integral
....................
:func:`li`
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.li(x, **kwargs)
Trigonometric integrals
.......................
:func:`ci`
^^^^^^^^^^
.. autofunction:: mpmath.ci(x, **kwargs)
:func:`si`
^^^^^^^^^^
.. autofunction:: mpmath.si(x, **kwargs)
Hyperbolic integrals
....................
:func:`chi`
^^^^^^^^^^^
.. autofunction:: mpmath.chi(x, **kwargs)
:func:`shi`
^^^^^^^^^^^
.. autofunction:: mpmath.shi(x, **kwargs)
Error functions
...............
:func:`erf`
^^^^^^^^^^^
.. autofunction:: mpmath.erf(x, **kwargs)
:func:`erfc`
^^^^^^^^^^^^
.. autofunction:: mpmath.erfc(x, **kwargs)
:func:`erfi`
^^^^^^^^^^^^
.. autofunction:: mpmath.erfi(x)
:func:`erfinv`
^^^^^^^^^^^^^^
.. autofunction:: mpmath.erfinv(x)
The normal distribution
....................................................
:func:`npdf`
^^^^^^^^^^^^
.. autofunction:: mpmath.npdf(x, mu=0, sigma=1)
:func:`ncdf`
^^^^^^^^^^^^
.. autofunction:: mpmath.ncdf(x, mu=0, sigma=1)
Fresnel integrals
......................................................
:func:`fresnels`
^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.fresnels(x)
:func:`fresnelc`
^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.fresnelc(x)
-111
View File
@@ -1,111 +0,0 @@
Factorials and gamma functions
------------------------------
Factorials and factorial-like sums and products are basic tools of combinatorics and number theory. Much like the exponential function is fundamental to differential equations and analysis in general, the factorial function (and its extension to complex numbers, the gamma function) is fundamental to difference equations and functional equations.
A large selection of factorial-like functions is implemented in mpmath. All functions support complex arguments, and arguments may be arbitrarily large. Results are numerical approximations, so to compute *exact* values a high enough precision must be set manually::
>>> from mpmath import mp, fac
>>> mp.dps = 15; mp.pretty = True
>>> fac(100)
9.33262154439442e+157
>>> print(int(_)) # most digits are wrong
93326215443944150965646704795953882578400970373184098831012889540582227238570431295066113089288327277825849664006524270554535976289719382852181865895959724032
>>> mp.dps = 160
>>> fac(100)
93326215443944152681699238856266700490715968264381621468592963895217599993229915608941463976156518286253697920827223758251185210916864000000000000000000000000.0
The gamma and polygamma functions are closely related to :doc:`zeta`. See also :doc:`qfunctions` for q-analogs of factorial-like functions.
Factorials
..........
:func:`factorial`/:func:`fac`
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.factorial(x, **kwargs)
:func:`fac2`
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.fac2(x)
Binomial coefficients
....................................................
:func:`binomial`
^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.binomial(n,k)
Gamma function
..............
:func:`gamma`
^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.gamma(x, **kwargs)
:func:`rgamma`
^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.rgamma(x, **kwargs)
:func:`gammaprod`
^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.gammaprod(a, b)
:func:`loggamma`
^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.loggamma(x)
Rising and falling factorials
.............................
:func:`rf`
^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.rf(x,n)
:func:`ff`
^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.ff(x,n)
Beta function
.............
:func:`beta`
^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.beta(x,y)
:func:`betainc`
^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.betainc(a,b,x1=0,x2=1,regularized=False)
Super- and hyperfactorials
..........................
:func:`superfac`
^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.superfac(z)
:func:`hyperfac`
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.hyperfac(z)
:func:`barnesg`
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.barnesg(z)
Polygamma functions and harmonic numbers
........................................
:func:`psi`/:func:`digamma`
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.psi(m, z)
.. autofunction:: mpmath.digamma(z)
:func:`harmonic`
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.harmonic(z)
-56
View File
@@ -1,56 +0,0 @@
Hyperbolic functions
--------------------
Hyperbolic functions
....................
:func:`cosh`
^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.cosh(x, **kwargs)
:func:`sinh`
^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.sinh(x, **kwargs)
:func:`tanh`
^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.tanh(x, **kwargs)
:func:`sech`
^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.sech(x)
:func:`csch`
^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.csch(x)
:func:`coth`
^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.coth(x)
Inverse hyperbolic functions
............................
:func:`acosh`
^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.acosh(x, **kwargs)
:func:`asinh`
^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.asinh(x, **kwargs)
:func:`atanh`
^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.atanh(x, **kwargs)
:func:`asech`
^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.asech(x)
:func:`acsch`
^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.acsch(x)
:func:`acoth`
^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.acoth(x)
-115
View File
@@ -1,115 +0,0 @@
Hypergeometric functions
------------------------
The functions listed in :doc:`expintegrals`, :doc:`bessel` and
:doc:`orthogonal`, and many other functions as well, are merely
particular instances of the generalized hypergeometric function `\,_pF_q`.
The functions listed in the following section enable efficient
direct evaluation of the underlying hypergeometric series, as
well as linear combinations, limits with respect to parameters,
and analytic continuations thereof. Extensions to twodimensional
series are also provided. See also the basic or q-analog of
the hypergeometric series in :doc:`qfunctions`.
For convenience, most of the hypergeometric series of low order are
provided as standalone functions. They can equivalently be evaluated using
:func:`~mpmath.hyper`. As will be demonstrated in the respective docstrings,
all the ``hyp#f#`` functions implement analytic continuations and/or asymptotic
expansions with respect to the argument `z`, thereby permitting evaluation
for `z` anywhere in the complex plane. Functions of higher degree can be
computed via :func:`~mpmath.hyper`, but generally only in rapidly convergent
instances.
Most hypergeometric and hypergeometric-derived functions accept optional
keyword arguments to specify options for :func:`hypercomb` or
:func:`hyper`. Some useful options are *maxprec*, *maxterms*,
*zeroprec*, *accurate_small*, *hmag*, *force_series*,
*asymp_tol* and *eliminate*. These options give control over what to
do in case of slow convergence, extreme loss of accuracy or
evaluation at zeros (these two cases cannot generally be
distinguished from each other automatically),
and singular parameter combinations.
Common hypergeometric series
............................
:func:`hyp0f1`
^^^^^^^^^^^^^^
.. autofunction:: mpmath.hyp0f1(a, z)
:func:`hyp1f1`
^^^^^^^^^^^^^^
.. autofunction:: mpmath.hyp1f1(a, b, z)
:func:`hyp1f2`
^^^^^^^^^^^^^^
.. autofunction:: mpmath.hyp1f2(a1, b1, b2, z)
:func:`hyp2f0`
^^^^^^^^^^^^^^
.. autofunction:: mpmath.hyp2f0(a, b, z)
:func:`hyp2f1`
^^^^^^^^^^^^^^
.. autofunction:: mpmath.hyp2f1(a, b, c, z)
:func:`hyp2f2`
^^^^^^^^^^^^^^
.. autofunction:: mpmath.hyp2f2(a1, a2, b1, b2, z)
:func:`hyp2f3`
^^^^^^^^^^^^^^
.. autofunction:: mpmath.hyp2f3(a1, a2, b1, b2, b3, z)
:func:`hyp3f2`
^^^^^^^^^^^^^^
.. autofunction:: mpmath.hyp3f2(a1, a2, a3, b1, b2, z)
Generalized hypergeometric functions
....................................
:func:`hyper`
^^^^^^^^^^^^^^
.. autofunction:: mpmath.hyper(a_s, b_s, z)
:func:`hypercomb`
^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.hypercomb
Meijer G-function
...................................
:func:`meijerg`
^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.meijerg(a_s,b_s,z,r=1,**kwargs)
Bilateral hypergeometric series
...............................
:func:`bihyper`
^^^^^^^^^^^^^^^
.. autofunction:: mpmath.bihyper(a_s,b_s,z,**kwargs)
Hypergeometric functions of two variables
...............................................
:func:`hyper2d`
^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.hyper2d(a,b,x,y,**kwargs)
:func:`appellf1`
^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.appellf1(a,b1,b2,c,x,y,**kwargs)
:func:`appellf2`
^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.appellf2(a,b1,b2,c1,c2,x,y,**kwargs)
:func:`appellf3`
^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.appellf3(a1,a2,b1,b2,c,x,y,**kwargs)
:func:`appellf4`
^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.appellf4(a,b,c1,c2,x,y,**kwargs)
-93
View File
@@ -1,93 +0,0 @@
Number-theoretical, combinatorial and integer functions
-------------------------------------------------------
For factorial-type functions, including binomial coefficients,
double factorials, etc., see the separate
section :doc:`gamma`.
Fibonacci numbers
.................
:func:`fibonacci`/:func:`fib`
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.fibonacci(n, **kwargs)
Bernoulli numbers and polynomials
.................................
:func:`bernoulli`
^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.bernoulli(n)
:func:`bernfrac`
^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.bernfrac(n)
:func:`bernpoly`
^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.bernpoly(n,z)
Euler numbers and polynomials
.................................
:func:`eulernum`
^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.eulernum(n)
:func:`eulerpoly`
^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.eulerpoly(n,z)
Bell numbers and polynomials
...........................................
:func:`bell`
^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.bell(n,x)
Stirling numbers
...........................................
:func:`stirling1`
^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.stirling1(n,k,exact=False)
:func:`stirling2`
^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.stirling2(n,k,exact=False)
Prime counting functions
........................
:func:`primepi`
^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.primepi(x)
:func:`primepi2`
^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.primepi2(x)
:func:`riemannr`
^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.riemannr(x)
Cyclotomic polynomials
......................
:func:`cyclotomic`
^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.cyclotomic(n,x)
Arithmetic functions
......................
:func:`mangoldt`
^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.mangoldt(n)
-79
View File
@@ -1,79 +0,0 @@
Orthogonal polynomials
----------------------
An orthogonal polynomial sequence is a sequence of polynomials `P_0(x), P_1(x), \ldots` of degree `0, 1, \ldots`, which are mutually orthogonal in the sense that
.. math ::
\int_S P_n(x) P_m(x) w(x) dx =
\begin{cases}
c_n \ne 0 & \text{if $m = n$} \\
0 & \text{if $m \ne n$}
\end{cases}
where `S` is some domain (e.g. an interval `[a,b] \in \mathbb{R}`) and `w(x)` is a fixed *weight function*. A sequence of orthogonal polynomials is determined completely by `w`, `S`, and a normalization convention (e.g. `c_n = 1`). Applications of orthogonal polynomials include function approximation and solution of differential equations.
Orthogonal polynomials are sometimes defined using the differential equations they satisfy (as functions of `x`) or the recurrence relations they satisfy with respect to the order `n`. Other ways of defining orthogonal polynomials include differentiation formulas and generating functions. The standard orthogonal polynomials can also be represented as hypergeometric series (see :doc:`hypergeometric`), more specifically using the Gauss hypergeometric function `\,_2F_1` in most cases. The following functions are generally implemented using hypergeometric functions since this is computationally efficient and easily generalizes.
For more information, see the `Wikipedia article on orthogonal polynomials <http://en.wikipedia.org/wiki/Orthogonal_polynomials>`_.
Legendre functions
.......................................
:func:`legendre`
^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.legendre(n, x)
:func:`legenp`
^^^^^^^^^^^^^^^
.. autofunction:: mpmath.legenp(n, m, z, type=2)
:func:`legenq`
^^^^^^^^^^^^^^^
.. autofunction:: mpmath.legenq(n, m, z, type=2)
Chebyshev polynomials
.....................
:func:`chebyt`
^^^^^^^^^^^^^^^
.. autofunction:: mpmath.chebyt(n, x)
:func:`chebyu`
^^^^^^^^^^^^^^^
.. autofunction:: mpmath.chebyu(n, x)
Jacobi polynomials
..................
:func:`jacobi`
^^^^^^^^^^^^^^
.. autofunction:: mpmath.jacobi(n, a, b, z)
Gegenbauer polynomials
.....................................
:func:`gegenbauer`
^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.gegenbauer(n, a, z)
Hermite polynomials
.....................................
:func:`hermite`
^^^^^^^^^^^^^^^
.. autofunction:: mpmath.hermite(n, z)
Laguerre polynomials
.......................................
:func:`laguerre`
^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.laguerre(n, a, z)
Spherical harmonics
.....................................
:func:`spherharm`
^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.spherharm(l, m, theta, phi)
-89
View File
@@ -1,89 +0,0 @@
Powers and logarithms
---------------------
Nth roots
.........
:func:`sqrt`
^^^^^^^^^^^^^^
.. autofunction:: mpmath.sqrt(x, **kwargs)
:func:`hypot`
^^^^^^^^^^^^^
.. autofunction:: mpmath.hypot(x, y)
:func:`cbrt`
^^^^^^^^^^^^^^
.. autofunction:: mpmath.cbrt(x, **kwargs)
:func:`root`
^^^^^^^^^^^^^^
.. autofunction:: mpmath.root(z, n, k=0)
:func:`unitroots`
^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.unitroots(n, primitive=False)
Exponentiation
..............
:func:`exp`
^^^^^^^^^^^^^^
.. autofunction:: mpmath.exp(x, **kwargs)
:func:`power`
^^^^^^^^^^^^^^
.. autofunction:: mpmath.power(x, y)
:func:`expj`
^^^^^^^^^^^^^^
.. autofunction:: mpmath.expj(x, **kwargs)
:func:`expjpi`
^^^^^^^^^^^^^^
.. autofunction:: mpmath.expjpi(x, **kwargs)
:func:`expm1`
^^^^^^^^^^^^^^
.. autofunction:: mpmath.expm1(x)
:func:`powm1`
^^^^^^^^^^^^^^
.. autofunction:: mpmath.powm1(x, y)
Logarithms
..........
:func:`log`
^^^^^^^^^^^^^^
.. autofunction:: mpmath.log(x, b=None)
:func:`ln`
^^^^^^^^^^^^^^
.. autofunction:: mpmath.ln(x, **kwargs)
:func:`log10`
^^^^^^^^^^^^^^
.. autofunction:: mpmath.log10(x)
:func:`log1p`
^^^^^^^^^^^^^^
.. autofunction:: mpmath.log1p(x)
Lambert W function
...................................................
:func:`lambertw`
^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.lambertw(z, k=0)
Arithmetic-geometric mean
.......................................
:func:`agm`
^^^^^^^^^^^^^^
.. autofunction:: mpmath.agm(a, b=1)
-29
View File
@@ -1,29 +0,0 @@
q-functions
-------------------------------------------
q-Pochhammer symbol
..................................................
:func:`qp`
^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.qp(a, q=None, n=None, **kwargs)
q-gamma and factorial
..................................................
:func:`qgamma`
^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.qgamma(z, q, **kwargs)
:func:`qfac`
^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.qfac(z, q, **kwargs)
Hypergeometric q-series
..................................................
:func:`qhyper`
^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.qhyper(a_s, b_s, q, z, **kwargs)
-117
View File
@@ -1,117 +0,0 @@
Trigonometric functions
-----------------------
Except where otherwise noted, the trigonometric functions
take a radian angle as input and the inverse trigonometric
functions return radian angles.
The ordinary trigonometric functions are single-valued
functions defined everywhere in the complex plane
(except at the poles of tan, sec, csc, and cot).
They are defined generally via the exponential function,
e.g.
.. math ::
\cos(x) = \frac{e^{ix} + e^{-ix}}{2}.
The inverse trigonometric functions are multivalued,
thus requiring branch cuts, and are generally real-valued
only on a part of the real line. Definitions and branch cuts
are given in the documentation of each function.
The branch cut conventions used by mpmath are essentially
the same as those found in most standard mathematical software,
such as Mathematica and Python's own ``cmath`` libary (as of Python 2.6;
earlier Python versions implement some functions
erroneously).
Degree-radian conversion
...........................................................
:func:`degrees`
^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.degrees(x)
:func:`radians`
^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.radians(x)
Trigonometric functions
.......................
:func:`cos`
^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.cos(x, **kwargs)
:func:`sin`
^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.sin(x, **kwargs)
:func:`tan`
^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.tan(x, **kwargs)
:func:`sec`
^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.sec(x)
:func:`csc`
^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.csc(x)
:func:`cot`
^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.cot(x)
Trigonometric functions with modified argument
........................................................
:func:`cospi`
^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.cospi(x, **kwargs)
:func:`sinpi`
^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.sinpi(x, **kwargs)
Inverse trigonometric functions
................................................
:func:`acos`
^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.acos(x, **kwargs)
:func:`asin`
^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.asin(x, **kwargs)
:func:`atan`
^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.atan(x, **kwargs)
:func:`atan2`
^^^^^^^^^^^^^
.. autofunction:: mpmath.atan2(y, x)
:func:`asec`
^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.asec(x)
:func:`acsc`
^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.acsc(x)
:func:`acot`
^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.acot(x)
Sinc function
.............
:func:`sinc`
^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.sinc(x)
:func:`sincpi`
^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.sincpi(x)
-104
View File
@@ -1,104 +0,0 @@
Zeta functions, L-series and polylogarithms
-------------------------------------------
This section includes the Riemann zeta functions
and associated functions pertaining to analytic number theory.
Riemann and Hurwitz zeta functions
..................................................
:func:`zeta`
^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.zeta(s,a=1,derivative=0)
Dirichlet L-series
..................................................
:func:`altzeta`
^^^^^^^^^^^^^^^
.. autofunction:: mpmath.altzeta(s)
:func:`dirichlet`
^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.dirichlet(s,chi,derivative=0)
Stieltjes constants
...................
:func:`stieltjes`
^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.stieltjes(n,a=1)
Zeta function zeros
......................................
These functions are used for the study of the Riemann zeta function
in the critical strip.
:func:`zetazero`
^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.zetazero(n, verbose=False)
:func:`nzeros`
^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.nzeros(t)
:func:`siegelz`
^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.siegelz(t)
:func:`siegeltheta`
^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.siegeltheta(t)
:func:`grampoint`
^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.grampoint(n)
:func:`backlunds`
^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.backlunds(t)
Lerch transcendent
................................
:func:`lerchphi`
^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.lerchphi(z,s,a)
Polylogarithms and Clausen functions
.......................................
:func:`polylog`
^^^^^^^^^^^^^^^
.. autofunction:: mpmath.polylog(s,z)
:func:`clsin`
^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.clsin(s, z)
:func:`clcos`
^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.clcos(s, z)
:func:`polyexp`
^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.polyexp(s,z)
Zeta function variants
..........................
:func:`primezeta`
^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.primezeta(s)
:func:`secondzeta`
^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.secondzeta(s, a=0.015, **kwargs)
-232
View File
@@ -1,232 +0,0 @@
Utility functions
===============================================
This page lists functions that perform basic operations
on numbers or aid general programming.
Conversion and printing
-----------------------
:func:`mpmathify` / :func:`convert`
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.mpmathify(x, strings=True)
:func:`nstr`
^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.nstr(x, n=6, **kwargs)
:func:`nprint`
^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.nprint(x, n=6, **kwargs)
Arithmetic operations
---------------------
See also :func:`mpmath.sqrt`, :func:`mpmath.exp` etc., listed
in :doc:`functions/powers`
:func:`fadd`
^^^^^^^^^^^^^
.. autofunction:: mpmath.fadd
:func:`fsub`
^^^^^^^^^^^^^
.. autofunction:: mpmath.fsub
:func:`fneg`
^^^^^^^^^^^^^
.. autofunction:: mpmath.fneg
:func:`fmul`
^^^^^^^^^^^^^
.. autofunction:: mpmath.fmul
:func:`fdiv`
^^^^^^^^^^^^^
.. autofunction:: mpmath.fdiv
:func:`fmod`
^^^^^^^^^^^^^
.. autofunction:: mpmath.fmod(x, y)
:func:`fsum`
^^^^^^^^^^^^^
.. autofunction:: mpmath.fsum(terms, absolute=False, squared=False)
:func:`fprod`
^^^^^^^^^^^^^
.. autofunction:: mpmath.fprod(factors)
:func:`fdot`
^^^^^^^^^^^^^
.. autofunction:: mpmath.fdot(A, B=None, conjugate=False)
Complex components
------------------
:func:`fabs`
^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.fabs(x)
:func:`sign`
^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.sign(x)
:func:`re`
^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.re(x)
:func:`im`
^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.im(x)
:func:`arg`
^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.arg(x)
:func:`conj`
^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.conj(x)
:func:`polar`
^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.polar(x)
:func:`rect`
^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.rect(x)
Integer and fractional parts
-----------------------------
:func:`floor`
^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.floor(x)
:func:`ceil`
^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.ceil(x)
:func:`nint`
^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.nint(x)
:func:`frac`
^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.frac(x)
Tolerances and approximate comparisons
--------------------------------------
:func:`chop`
^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.chop(x, tol=None)
:func:`almosteq`
^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.almosteq(s, t, rel_eps=None, abs_eps=None)
Properties of numbers
-------------------------------------
:func:`isinf`
^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.isinf(x)
:func:`isnan`
^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.isnan(x)
:func:`isnormal`
^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.isnormal(x)
:func:`isfinite`
^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.isfinite(x)
:func:`isint`
^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.isint(x, gaussian=False)
:func:`ldexp`
^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.ldexp(x, n)
:func:`frexp`
^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.frexp(x, n)
:func:`mag`
^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.mag(x)
:func:`nint_distance`
^^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.nint_distance(x)
.. :func:`absmin`
.. ^^^^^^^^^^^^^^^^^^^^
.. .. autofunction:: mpmath.absmin(x)
.. .. autofunction:: mpmath.absmax(x)
Number generation
-----------------
:func:`fraction`
^^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.fraction(p,q)
:func:`rand`
^^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.rand()
:func:`arange`
^^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.arange(*args)
:func:`linspace`
^^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.linspace(*args, **kwargs)
Precision management
--------------------
:func:`autoprec`
^^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.autoprec
:func:`workprec`
^^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.workprec
:func:`workdps`
^^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.workdps
:func:`extraprec`
^^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.extraprec
:func:`extradps`
^^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.extradps
Performance and debugging
------------------------------------
:func:`memoize`
^^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.memoize
:func:`maxcalls`
^^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.maxcalls
:func:`monitor`
^^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.monitor
:func:`timing`
^^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.timing
Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

-32
View File
@@ -1,32 +0,0 @@
Plotting
========
If `matplotlib <http://matplotlib.sourceforge.net/>`_ is available, the functions ``plot`` and ``cplot`` in mpmath can be used to plot functions respectively as x-y graphs and in the complex plane. Also, ``splot`` can be used to produce 3D surface plots.
Function curve plots
-----------------------
.. image:: plot.png
Output of ``plot([cos, sin], [-4, 4])``
.. autofunction:: mpmath.plot
Complex function plots
-------------------------
.. image:: cplot.png
Output of ``fp.cplot(fp.gamma, points=100000)``
.. autofunction:: mpmath.cplot
3D surface plots
----------------
.. image:: splot.png
Output of ``splot`` for the donut example.
.. autofunction:: mpmath.splot
-50
View File
@@ -1,50 +0,0 @@
References
===================
The following is a non-comprehensive list of works used in the development of mpmath
or cited for examples or mathematical definitions used in this documentation.
References not listed here can be found in the source code.
.. [AbramowitzStegun] M Abramowitz & I Stegun. *Handbook of Mathematical Functions, 9th Ed.*, Tenth Printing, December 1972, with corrections (electronic copy: http://people.math.sfu.ca/~cbm/aands/)
.. [Bailey] D H Bailey. "Tanh-Sinh High-Precision Quadrature", http://crd.lbl.gov/~dhbailey/dhbpapers/dhb-tanh-sinh.pdf
.. [BenderOrszag] C M Bender & S A Orszag. *Advanced Mathematical Methods for
Scientists and Engineers*, Springer 1999
.. [BorweinBailey] J Borwein, D H Bailey & R Girgensohn. *Experimentation in Mathematics - Computational Paths to Discovery*, A K Peters, 2003
.. [BorweinBorwein] J Borwein & P B Borwein. *Pi and the AGM: A Study in Analytic Number Theory and Computational Complexity*, Wiley 1987
.. [BorweinZeta] P Borwein. "An Efficient Algorithm for the Riemann Zeta Function", http://www.cecm.sfu.ca/personal/pborwein/PAPERS/P155.pdf
.. [CabralRosetti] L G Cabral-Rosetti & M A Sanchis-Lozano. "Appell Functions and the Scalar One-Loop Three-point Integrals in Feynman Diagrams". http://arxiv.org/abs/hep-ph/0206081
.. [Carlson] B C Carlson. "Numerical computation of real or complex elliptic integrals". http://arxiv.org/abs/math/9409227v1
.. [Corless] R M Corless et al. "On the Lambert W function", Adv. Comp. Math. 5 (1996) 329-359. http://www.apmaths.uwo.ca/~djeffrey/Offprints/W-adv-cm.pdf
.. [DLMF] NIST Digital Library of Mathematical Functions. http://dlmf.nist.gov/
.. [GradshteynRyzhik] I S Gradshteyn & I M Ryzhik, A Jeffrey & D Zwillinger (eds.), *Table of Integrals, Series and Products*, Seventh edition (2007), Elsevier
.. [GravesMorris] P R Graves-Morris, D E Roberts & A Salam. "The epsilon algorithm and related topics", *Journal of Computational and Applied Mathematics*, Volume 122, Issue 1-2 (October 2000)
.. [MPFR] The MPFR team. "The MPFR Library: Algorithms and Proofs", http://www.mpfr.org/algorithms.pdf
.. [Slater] L J Slater. *Generalized Hypergeometric Functions*. Cambridge University Press, 1966
.. [Spouge] J L Spouge. "Computation of the gamma, digamma, and trigamma functions", SIAM J. Numer. Anal. Vol. 31, No. 3, pp. 931-944, June 1994.
.. [SrivastavaKarlsson] H M Srivastava & P W Karlsson. *Multiple Gaussian Hypergeometric Series*. Ellis Horwood, 1985.
.. [Vidunas] R Vidunas. "Identities between Appell's and hypergeometric functions". http://arxiv.org/abs/0804.0655
.. [Weisstein] E W Weisstein. *MathWorld*. http://mathworld.wolfram.com/
.. [WhittakerWatson] E T Whittaker & G N Watson. *A Course of Modern Analysis*. 4th Ed. 1946
Cambridge University Press
.. [Wikipedia] *Wikipedia, the free encyclopedia*. http://en.wikipedia.org/wiki/Main_Page
.. [WolframFunctions] Wolfram Research, Inc. *The Wolfram Functions Site*. http://functions.wolfram.com/
-161
View File
@@ -1,161 +0,0 @@
Setting up mpmath
=================
Download and installation
-------------------------
Installer
.........
The mpmath setup files can be downloaded from the `Python Package Index <http://pypi.python.org/pypi/mpmath/>`_. Download the source package (available as both .zip and .tar.gz), extract it, open the extracted directory, and run
``python setup.py install``
Using pip
.........
Releases are registered on PyPI, so you can install latest release
of the Mpmath with pip
``pip install mpmath``
or some specific version with
``pip install mpmath==0.19``
Using setuptools
................
If you have `setuptools <http://pypi.python.org/pypi/setuptools>`_ installed, you can download and install mpmath in one step by running:
``easy_install mpmath``
or
``python -m easy_install mpmath``
If you have an old version of mpmath installed already, you may have to pass ``easy_install`` the ``-U`` flag to force an upgrade.
Debian/Ubuntu
.............
Debian and Ubuntu users can install mpmath with
``sudo apt-get install python-mpmath``
See `debian <http://packages.debian.org/stable/python/python-mpmath>`_ and `ubuntu <https://launchpad.net/ubuntu/+source/mpmath>`_ package information; please verify that you are getting the latest version.
OpenSUSE
........
Mpmath is provided in the "Science" repository for all recent versions of `openSUSE <http://www.opensuse.org/en/>`_. To add this repository to the YAST software management tool, see http://en.opensuse.org/SDB:Add_package_repositories
Look up http://download.opensuse.org/repositories/science/ for a list
of supported OpenSUSE versions and use http://download.opensuse.org/repositories/science/openSUSE_11.1/
(or accordingly for your OpenSUSE version) as the repository URL for YAST.
Current development version
...........................
The git repository is https://github.com/fredrik-johansson/mpmath
Checking that it works
......................
After the setup has completed, you should be able to fire up the interactive Python interpreter and do the following::
>>> from mpmath import *
>>> mp.dps = 50
>>> print(mpf(2) ** mpf('0.5'))
1.4142135623730950488016887242096980785696718753769
>>> print(2*pi)
6.2831853071795864769252867665590057683943387987502
*Note: if you have are upgrading mpmath from an earlier version, you may have to manually uninstall the old version or remove the old files.*
Using gmpy (optional)
---------------------
By default, mpmath uses Python integers internally. If `gmpy <http://code.google.com/p/gmpy/>`_ version 1.03 or later is installed on your system, mpmath will automatically detect it and transparently use gmpy integers intead. This makes mpmath much faster, especially at high precision (approximately above 100 digits).
To verify that mpmath uses gmpy, check the internal variable ``BACKEND`` is not equal to 'python':
>>> import mpmath.libmp
>>> mpmath.libmp.BACKEND # doctest:+SKIP
'gmpy'
The gmpy mode can be disabled by setting the MPMATH_NOGMPY environment variable. Note that the mode cannot be switched during runtime; mpmath must be re-imported for this change to take effect.
Running tests
-------------
It is recommended that you run mpmath's full set of unit tests to make sure everything works. The `py.test <https://pytest.org/>`_ is a required dependence for testing. The tests are located in the ``tests`` subdirectory of the main mpmath directory. They can be run using::
``py.test --pyargs mpmath``
If any test fails, please send a detailed bug report to the `mpmath issue tracker <https://github.com/fredrik-johansson/mpmath/issues>`_.
To run the tests with support for gmpy disabled, set ``MPMATH_NOGMPY`` environment variable.
To enable extra diagnostics, use, set ``MPMATH_STRICT`` environment variable.
Compiling the documentation
---------------------------
If you downloaded the source package, the text source for these documentation pages is included in the ``doc`` directory. The documentation can be compiled to pretty HTML using `Sphinx <http://sphinx.pocoo.org/>`_. Go to the ``doc`` directory and run
``python build.py``
You can also test that all the interactive examples in the documentation work by running
``python run_doctest.py``
and by running the individual ``.py`` files in the mpmath source.
(The doctests may take several minutes.)
Finally, some additional demo scripts are available in the ``demo`` directory included in the source package.
Mpmath under Sage
-------------------
Mpmath is a standard package in `Sage <http://sagemath.org/>`_, in version 4.1 or later of Sage.
Mpmath is preinstalled a regular Python module, and can be imported as usual within Sage::
----------------------------------------------------------------------
| Sage Version 4.1, Release Date: 2009-07-09 |
| Type notebook() for the GUI, and license() for information. |
----------------------------------------------------------------------
sage: import mpmath
sage: mpmath.mp.dps = 50
sage: print mpmath.mpf(2) ** 0.5
1.4142135623730950488016887242096980785696718753769
The mpmath installation under Sage automatically use Sage integers for asymptotically fast arithmetic,
so there is no need to install GMPY::
sage: mpmath.libmp.BACKEND
'sage'
In Sage, mpmath can alternatively be imported via the interface library
``sage.libs.mpmath.all``. For example::
sage: import sage.libs.mpmath.all as mpmath
This module provides a few extra conversion functions, including :func:`call`
which permits calling any mpmath function with Sage numbers as input, and getting
Sage ``RealNumber`` or ``ComplexNumber`` instances
with the appropriate precision back::
sage: w = mpmath.call(mpmath.erf, 2+3*I, prec=100)
sage: w
-20.829461427614568389103088452 + 8.6873182714701631444280787545*I
sage: type(w)
<type 'sage.rings.complex_number.ComplexNumber'>
sage: w.prec()
100
See the help for ``sage.libs.mpmath.all`` for further information.
Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

+83 -27
View File
@@ -1,25 +1,28 @@
Basic usage
===========================
In interactive code examples that follow, it will be assumed that
all items in the ``mpmath`` namespace have been imported::
To avoid inadvertently overriding other functions or objects, explicitly import
only the needed objects, or use the ``mpmath.`` or ``mp.`` namespaces::
>>> from mpmath import *
>>> from mpmath import sin
>>> sin(1)
mpf('0.8414709848078965')
Importing everything can be convenient, especially when using mpmath interactively, but be
careful when mixing mpmath with other libraries! To avoid inadvertently overriding
other functions or objects, explicitly import only the needed objects, or use
the ``mpmath.`` or ``mp.`` namespaces::
>>> import mpmath
>>> mpmath.sin(1)
mpf('0.8414709848078965')
from mpmath import sin, cos
sin(1), cos(1)
>>> from mpmath import mp # mp context object -- to be explained
>>> mp.sin(1)
mpf('0.8414709848078965')
import mpmath
mpmath.sin(1), mpmath.cos(1)
from mpmath import mp # mp context object -- to be explained
mp.sin(1), mp.cos(1)
.. note::
Importing everything with ``from mpmath import *`` can be convenient,
especially when using mpmath interactively, but is best to avoid such
import statements in production code, as they make it unclear which
names are present in the namespace and wildcard-imported names may
conflict with other modules or variable names.
Number types
------------
@@ -40,6 +43,7 @@ The following section will provide a very short introduction to the types ``mpf`
The ``mpf`` type is analogous to Python's built-in ``float``. It holds a real number or one of the special values ``inf`` (positive infinity), ``-inf`` (negative infinity) and ``nan`` (not-a-number, indicating an indeterminate result). You can create ``mpf`` instances from strings, integers, floats, and other ``mpf`` instances:
>>> from mpmath import mpf, mpc, mp
>>> mpf(4)
mpf('4.0')
>>> mpf(2.5)
@@ -49,7 +53,7 @@ The ``mpf`` type is analogous to Python's built-in ``float``. It holds a real nu
>>> mpf(mpf(2))
mpf('2.0')
>>> mpf("inf")
mpf('+inf')
mpf('inf')
The ``mpc`` type represents a complex number in rectangular form as a pair of ``mpf`` instances. It can be constructed from a Python ``complex``, a real number, or a pair of real numbers:
@@ -76,7 +80,10 @@ Mpmath uses a global working precision; it does not keep track of the precision
Mpmath settings:
mp.prec = 53 [default: 53]
mp.dps = 15 [default: 15]
mp.rounding = 'n' [default: 'n']
mp.trap_complex = False [default: False]
mp.pretty_dps = 'str' [default: 'str']
mp.shortest_str = False [default: False]
The term **prec** denotes the binary precision (measured in bits) while **dps** (short for *decimal places*) is the decimal precision. Binary and decimal precision are related roughly according to the formula ``prec = 3.33*dps``. For example, it takes a precision of roughly 333 bits to hold an approximation of pi that is accurate to 100 decimal places (actually slightly more than 333 bits is used).
@@ -92,10 +99,10 @@ When the precision has been set, all ``mpf`` operations are carried out at that
>>> mp.dps = 50
>>> mpf(1) / 6
mpf('0.16666666666666666666666666666666666666666666666666656')
mpf('0.1666666666666666666666666666666666666666666666666666')
>>> mp.dps = 25
>>> mpf(2) ** mpf('0.5')
mpf('1.414213562373095048801688713')
mpf('1.41421356237309504880168871')
The precision of complex arithmetic is also controlled by the ``mp`` object:
@@ -111,11 +118,22 @@ There is no restriction on the magnitude of numbers. An ``mpf`` can for example
Or why not 1 googolplex:
>>> print(mpf(10) ** (10**100)) # doctest:+ELLIPSIS
>>> print(mpf(10) ** (10**100))
1.0e+100000000000000000000000000000000000000000000000000...
The (binary) exponent is stored exactly and is independent of the precision.
The ``rounding`` property control default rounding mode for the context:
>>> mp.rounding # round to nearest is the default
'n'
>>> sin(1)
mpf('0.8414709848078965')
>>> mp.rounding = 'u' # round up
>>> sin(1)
mpf('0.84147098480789662')
>>> mp.rounding = 'n'
Temporarily changing the precision
..................................
@@ -125,10 +143,10 @@ It is often useful to change the precision during only part of a calculation. A
>>> # do_something()
>>> mp.prec -= 2
Since Python 2.5, the ``with`` statement along with the mpmath functions ``workprec``, ``workdps``, ``extraprec`` and ``extradps`` can be used to temporarily change precision in a more safe manner:
The ``with`` statement along with the mpmath functions ``workprec``, ``workdps``, ``extraprec`` and ``extradps`` can be used to temporarily change precision in a more safe manner:
>>> from __future__ import with_statement # only need this in Python 2.5
>>> with workdps(20): # doctest: +SKIP
>>> from mpmath import extradps, workdps
>>> with workdps(20):
... print(mpf(1)/7)
... with extradps(10):
... print(mpf(1)/7)
@@ -138,7 +156,7 @@ Since Python 2.5, the ``with`` statement along with the mpmath functions ``workp
>>> mp.dps
15
The ``with`` statement ensures that the precision gets reset when exiting the block, even in the case that an exception is raised. (The effect of the ``with`` statement can be emulated in Python 2.4 by using a ``try/finally`` block.)
The ``with`` statement ensures that the precision gets reset when exiting the block, even in the case that an exception is raised.
The ``workprec`` family of functions can also be used as function decorators:
@@ -152,6 +170,7 @@ The ``workprec`` family of functions can also be used as function decorators:
Some functions accept the ``prec`` and ``dps`` keyword arguments and this will override the global working precision. Note that this will not affect the precision at which the result is printed, so to get all digits, you must either use increase precision afterward when printing or use ``nstr``/``nprint``:
>>> from mpmath import exp, nprint
>>> mp.dps = 15
>>> print(exp(1))
2.71828182845905
@@ -180,6 +199,8 @@ Note that when creating a new ``mpf``, the value will at most be as accurate as
>>> mp.dps = 30
>>> mpf(10.9) # bad
mpf('10.9000000000000003552713678800501')
>>> mpf(1090/100) # bad, beware Python's true division produces floats
mpf('10.9000000000000003552713678800501')
>>> mpf('10.9') # good
mpf('10.8999999999999999999999999999997')
>>> mpf(109) / mpf(10) # also good
@@ -214,14 +235,49 @@ Setting the ``mp.pretty`` option will use the ``str()``-style output for ``repr(
>>> mpf(0.6)
mpf('0.59999999999999998')
The number of digits with which numbers are printed by default is determined by the working precision. To specify the number of digits to show without changing the working precision, use :func:`mpmath.nstr` and :func:`mpmath.nprint`:
To use enough digits to be able recreate value exactly, enable
``mp.shortest_str`` option. With this, repr/str and the new-style string
formatting *without format specifier* will use *minimal* number of decimal
digits that will preserve value on string input, like repr for CPython's
builtin floats:
>>> mp.shortest_str = True
>>> mp.pretty = True
>>> mpf(10.9) == mpf("10.9")
True
>>> mpf(10.9)
10.9
>>> f"{_}"
'10.9'
>>> mp.pretty = False
>>> mpf(10.9)
mpf('10.9')
>>> mp.shortest_str = False
Alternatively, set ``mp.pretty_dps``
to ``"repr"`` (default value is ``"str"``). Same option is used to control
default number of digits in the new-style string formatting *without format
specifier*, i.e. ``format(exp(mpf(1)))``.
>>> mp.pretty = True
>>> mpf(0.1)
0.1
>>> mp.pretty_dps = "repr"
>>> mpf(0.1)
0.10000000000000001
>>> mp.pretty_dps = "str"
>>> mp.pretty = False
The number of digits with which numbers are printed by default is determined by
the working precision. To specify the number of digits to show without
changing the working precision, use :func:`format syntax support
<mpmath.mpf.__format__>` or functions :func:`mpmath.nstr` and
:func:`mpmath.nprint`:
>>> a = mpf(1) / 6
>>> a
mpf('0.16666666666666666')
>>> nstr(a, 8)
>>> f'{a:.8}'
'0.16666667'
>>> nprint(a, 8)
0.16666667
>>> nstr(a, 50)
>>> f'{a:.50}'
'0.16666666666666665741480812812369549646973609924316'
+13
View File
@@ -0,0 +1,13 @@
Fast Fourier Transform
----------------------------------
FFT
...
.. autofunction:: mpmath.fft
Inverse FFT
...........
.. autofunction:: mpmath.invfft
+15
View File
@@ -0,0 +1,15 @@
Numerical calculus
==================
.. toctree::
:maxdepth: 2
polynomials
optimization
sums_limits
differentiation
integration
odes
approximation
inverselaplace
fft
@@ -6,6 +6,11 @@ Standard quadrature (``quad``)
.. autofunction:: mpmath.quad
Quadrature with subdivision (``quadsubdiv``)
............................................
.. autofunction:: mpmath.quadsubdiv
Oscillatory quadrature (``quadosc``)
....................................
@@ -27,7 +27,13 @@ de Hoog, Knight & Stokes algorithm
.. autoclass:: mpmath.calculus.inverselaplace.deHoog
:members:
Manual approach
Cohen acceleration algorithm
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. autoclass:: mpmath.calculus.inverselaplace.Cohen
:members:
Manual approach
...............
It is possible and sometimes beneficial to re-create some of the
@@ -41,7 +47,7 @@ or function call.
A trivial example showing the process (which could be implemented
using the existing interface):
>>> from mpmath import *
>>> from mpmath import calculus, convert, exp, mp
>>> myTalbot = calculus.inverselaplace.FixedTalbot(mp)
>>> t = convert(0.25)
>>> myTalbot.calc_laplace_parameter(t)
@@ -49,7 +55,7 @@ using the existing interface):
>>> ft = lambda t: exp(-t) - exp(-1000*t)
>>> fpvec = [fp(p) for p in myTalbot.p]
>>> ft(t)-myTalbot.calc_time_domain_solution(fpvec,t,manual_prec=True)
mpf('1.928300179528890061756872185e-21')
mpf('1.92830017952889006175687218e-21')
This manual approach is also useful to look at the Laplace parameter,
order, or working precision which were computed.
@@ -61,4 +67,5 @@ Credit
......
The numerical inverse Laplace transform functionality was contributed
to mpmath by Kristopher L. Kuhlman in 2017.
to mpmath by Kristopher L. Kuhlman in 2017. The Cohen method was contributed
to mpmath by Guillermo Navas-Palencia in 2022.
@@ -4,7 +4,7 @@ Root-finding and optimization
Root-finding (``findroot``)
...........................
.. autofunction:: mpmath.findroot(f, x0, solver=Secant, tol=None, verbose=False, verify=True, **kwargs)
.. autofunction:: mpmath.findroot
Solvers
^^^^^^^
@@ -21,9 +21,5 @@ Solvers
.. autoclass:: mpmath.calculus.optimization.Ridder
.. autoclass:: mpmath.calculus.optimization.ANewton
.. autoclass:: mpmath.calculus.optimization.MDNewton
.. Minimization and maximization (``findmin``, ``findmax``)
.. ........................................................
.. (To be added.)
.. autoclass:: mpmath.calculus.optimization.ModAB
.. autoclass:: mpmath.calculus.optimization.Brent
@@ -1,7 +1,7 @@
Polynomials
-----------
See also :func:`taylor` and :func:`chebyfit` for
See also :func:`~mpmath.taylor` and :func:`~mpmath.chebyfit` for
approximation of functions by polynomials.
Polynomial evaluation (``polyval``)
@@ -9,38 +9,38 @@ for summation and multiplication of finite sequences.
Summation
..........................................
:func:`nsum`
^^^^^^^^^^^^^^^^^
:func:`~mpmath.nsum`
^^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.nsum
:func:`sumem`
^^^^^^^^^^^^^^^^^
:func:`~mpmath.sumem`
^^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.sumem
:func:`sumap`
^^^^^^^^^^^^^^^^^
:func:`~mpmath.sumap`
^^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.sumap
Products
...............................
:func:`nprod`
^^^^^^^^^^^^^^^^^
:func:`~mpmath.nprod`
^^^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.nprod
Limits (``limit``)
..................
:func:`limit`
^^^^^^^^^^^^^^^^^
:func:`~mpmath.limit`
^^^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.limit
Extrapolation
..........................................
The following functions provide a direct interface to
extrapolation algorithms. :func:`nsum` and :func:`limit` essentially
work by calling the following functions with an increasing
extrapolation algorithms. :func:`~mpmath.nsum` and :func:`~mpmath.limit`
essentially work by calling the following functions with an increasing
number of terms until the extrapolated limit is accurate enough.
The following functions may be useful to call directly if the
@@ -49,19 +49,19 @@ known in advance, or if one wishes to study the convergence
properties of the algorithms.
:func:`richardson`
^^^^^^^^^^^^^^^^^^
:func:`~mpmath.richardson`
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.richardson
:func:`shanks`
^^^^^^^^^^^^^^^^^
:func:`~mpmath.shanks`
^^^^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.shanks
:func:`levin`
^^^^^^^^^^^^^^^^^
:func:`~mpmath.levin`
^^^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.levin
:func:`cohen_alt`
^^^^^^^^^^^^^^^^^
:func:`~mpmath.cohen_alt`
^^^^^^^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.cohen_alt
+8
View File
@@ -0,0 +1,8 @@
.. _cli:
Command-Line Usage
==================
When called as a program from the command line, the following form is used:
.. autoprogram:: mpmath.__main__:parser
+52
View File
@@ -0,0 +1,52 @@
"""
Mpmath documentation build configuration file.
This file is execfile()d with the current directory set to its
containing dir.
The contents of this file are pickled, so don't put values in the
namespace that aren't pickleable (module imports are okay, they're
removed automatically).
"""
import mpmath
# Add any Sphinx extension module names here, as strings.
extensions = ['sphinx.ext.autodoc', 'sphinx.ext.mathjax',
'sphinx.ext.intersphinx', 'sphinxcontrib.autoprogram',
'matplotlib.sphinxext.plot_directive']
# Sphinx will warn about all references where the target cannot be found.
nitpicky = True
# Project information.
project = mpmath.__name__
copyright = '2007-2026, Fredrik Johansson and mpmath developers'
release = version = mpmath.__version__
# Define how the current time is formatted using time.strftime().
today_fmt = '%B %d, %Y'
# The "theme" that the HTML output should use.
html_theme = 'classic'
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title, author, document class [howto/manual]).
latex_documents = [('index', 'mpmath.tex', 'mpmath documentation',
r'Fredrik Johansson \and mpmath contributors', 'manual')]
# The name of default reST role, that is, for text marked up `like this`.
default_role = 'math'
# Contains mapping the locations and names of other projects that
# should be linked to in this documentation.
intersphinx_mapping = {
'python': ('https://docs.python.org/3/', None),
'sympy': ('https://docs.sympy.org/latest/', None),
}
plot_include_source = True
plot_formats = [('png', 96), 'pdf']
plot_html_show_formats = False
plot_html_show_source_link = False
+98 -34
View File
@@ -4,26 +4,29 @@ Contexts
High-level code in mpmath is implemented as methods on a "context object". The context implements arithmetic, type conversions and other fundamental operations. The context also holds settings such as precision, and stores cache data. A few different contexts (with a mostly compatible interface) are provided so that the high-level algorithms can be used with different implementations of the underlying arithmetic, allowing different features and speed-accuracy tradeoffs. Currently, mpmath provides the following contexts:
* Arbitrary-precision arithmetic (``mp``)
* A faster Cython-based version of ``mp`` (used by default in Sage, and currently only available there)
* Arbitrary-precision interval arithmetic (``iv``)
* Double-precision arithmetic using Python's builtin ``float`` and ``complex`` types (``fp``)
.. note::
Using global context is not thread-safe, create instead
local contexts with e.g. :class:`~mpmath.MPContext`.
Most global functions in the global mpmath namespace are actually methods of the ``mp``
context. This fact is usually transparent to the user, but sometimes shows up in the
form of an initial parameter called "ctx" visible in the help for the function::
>>> import mpmath
>>> help(mpmath.fsum) # doctest:+SKIP
>>> help(mpmath.fsum)
Help on method fsum in module mpmath.ctx_mp_python:
fsum(ctx, terms, absolute=False, squared=False) method of mpmath.ctx_mp.MPContext instance
<BLANKLINE>
fsum(terms, absolute=False, squared=False) method of mpmath.ctx_mp.MPContext instance
Calculates a sum containing a finite number of terms (for infinite
series, see :func:`~mpmath.nsum`). The terms will be converted to
...
The following operations are equivalent::
>>> mpmath.mp.dps = 15; mpmath.mp.pretty = False
>>> mpmath.fsum([1,2,3])
mpf('6.0')
>>> mpmath.mp.fsum([1,2,3])
@@ -100,7 +103,6 @@ Common interface
[1.0 0.0]
[0.0 1.0]
>>> fp.pretty = False
>>> mp.pretty = False
Arbitrary-precision floating-point (``mp``)
@@ -110,6 +112,18 @@ The ``mp`` context is what most users probably want to use most of the time, as
See :doc:`basics` for a description of basic usage.
.. autoclass:: mpmath.MPContext
Local contexts, created on demand, could be used just as the global ``mp``:
>>> from mpmath import MPContext
>>> ctx = MPContext()
>>> ctx.sin(1)
mpf('0.8414709848078965')
>>> ctx.prec = 113
>>> ctx.sin(1)
mpf('0.841470984807896506652502321630298954')
Arbitrary-precision interval arithmetic (``iv``)
------------------------------------------------
@@ -125,7 +139,6 @@ Interval arithmetic provides rigorous error tracking. If `f` is a mathematical f
Intervals can be created from single numbers (treated as zero-width intervals) or pairs of endpoint numbers. Strings are treated as exact decimal numbers. Note that a Python float like ``0.1`` generally does not represent the same number as its literal; use ``'0.1'`` instead::
>>> from mpmath import iv
>>> iv.dps = 15; iv.pretty = False
>>> iv.mpf(3)
mpi('3.0', '3.0')
>>> print(iv.mpf(3))
@@ -147,7 +160,11 @@ Intervals may be infinite or half-infinite::
>>> print(1 / iv.mpf([2, 'inf']))
[0.0, 0.5]
The equality testing operators ``==`` and ``!=`` check whether their operands are identical as intervals; that is, have the same endpoints. The ordering operators ``< <= > >=`` permit inequality testing using triple-valued logic: a guaranteed inequality returns ``True`` or ``False`` while an indeterminate inequality returns ``None``::
The equality testing operators ``==`` and ``!=`` check whether their operands
are identical as intervals; that is, have the same endpoints. The ordering
operators ``< <= > >=`` permit inequality testing using triple-valued logic: a
guaranteed inequality returns ``True`` or ``False`` while an indeterminate
inequality raises :exc:`ValueError`::
>>> iv.mpf([1,2]) == iv.mpf([1,2])
True
@@ -159,12 +176,18 @@ The equality testing operators ``==`` and ``!=`` check whether their operands ar
True
>>> iv.mpf([1,2]) < 1
False
>>> iv.mpf([1,2]) < 2 # returns None
>>> iv.mpf([1,2]) < 2
Traceback (most recent call last):
...
ValueError
>>> iv.mpf([2,2]) < 2
False
>>> iv.mpf([1,2]) <= iv.mpf([2,3])
True
>>> iv.mpf([1,2]) < iv.mpf([2,3]) # returns None
>>> iv.mpf([1,2]) < iv.mpf([2,3])
Traceback (most recent call last):
...
ValueError
>>> iv.mpf([1,2]) < iv.mpf([-1,0])
False
@@ -196,12 +219,12 @@ Some transcendental functions are supported::
>>> iv.exp(0)
[1.0, 1.0]
>>> iv.exp(['-inf','inf'])
[0.0, +inf]
[0.0, inf]
>>>
>>> iv.exp(['-inf',0])
[0.0, 1.0]
>>> iv.exp([0,'inf'])
[1.0, +inf]
[1.0, inf]
>>> iv.exp([0,1])
[1.0, 2.7182818284590455349]
>>>
@@ -210,7 +233,7 @@ Some transcendental functions are supported::
>>> iv.log([0,1])
[-inf, 0.0]
>>> iv.log([0,'inf'])
[-inf, +inf]
[-inf, inf]
>>> iv.log(2)
[0.69314718055994528623, 0.69314718055994539725]
>>>
@@ -239,13 +262,19 @@ seen by increasing the precision::
>>> print(mp.exp(mp.pi*mp.sqrt(163)))
262537412640768743.99999999999925007259719818568888
With interval arithmetic, the comparison returns ``None`` until the precision
is large enough for `x-y` to have a definite sign::
With interval arithmetic, the comparison raises :exc:`ValueError` until the
precision is large enough for `x-y` to have a definite sign::
>>> iv.dps = 15
>>> iv.exp(iv.pi*iv.sqrt(163)) > (640320**3+744)
Traceback (most recent call last):
...
ValueError
>>> iv.dps = 30
>>> iv.exp(iv.pi*iv.sqrt(163)) > (640320**3+744)
Traceback (most recent call last):
...
ValueError
>>> iv.dps = 60
>>> iv.exp(iv.pi*iv.sqrt(163)) > (640320**3+744)
False
@@ -258,38 +287,36 @@ Although mpmath is generally designed for arbitrary-precision arithmetic, many o
To take advantage of this feature, simply use the ``fp`` prefix, i.e. write ``fp.func`` instead of ``func`` or ``mp.func``::
>>> u = fp.erfc(2.5)
>>> print(u) # doctest:+SKIP
0.000406952017445
>>> type(u) # doctest:+SKIP
<type 'float'>
>>> mp.dps = 15
>>> print(mp.erfc(2.5))
0.000406952017444959
>>> u = fp.erfc(0.5)
>>> print(u)
0.4795001221869535
>>> type(u)
<class 'float'>
>>> mp.dps = 16
>>> print(mp.erfc(0.5))
0.4795001221869535
>>> fp.matrix([[1,2],[3,4]]) ** 2
matrix(
[['7.0', '10.0'],
['15.0', '22.0']])
>>>
>>> type(_[0,0]) # doctest:+SKIP
<type 'float'>
>>>
>>> type(_[0,0])
<class 'float'>
>>> print(fp.quad(fp.sin, [0, fp.pi])) # numerical integration
2.0
The ``fp`` context wraps Python's ``math`` and ``cmath`` modules for elementary functions. It supports both real and complex numbers and automatically generates complex results for real inputs (``math`` raises an exception)::
>>> fp.sqrt(5) # doctest:+SKIP
>>> fp.sqrt(5)
2.23606797749979
>>> fp.sqrt(-5) # doctest:+SKIP
>>> fp.sqrt(-5)
2.23606797749979j
>>> fp.sin(10) # doctest:+SKIP
>>> fp.sin(10)
-0.5440211108893698
>>> fp.power(-1, 0.25) # doctest:+SKIP
>>> fp.power(-1, 0.25)
(0.7071067811865476+0.7071067811865475j)
>>> (-1) ** 0.25
(0.7071067811865476+0.7071067811865475j)
>>> (-1) ** 0.25 # doctest:+SKIP
Traceback (most recent call last):
...
ValueError: negative number cannot be raised to a fractional power
The ``prec`` and ``dps`` attributes can be changed (for interface compatibility with the ``mp`` context) but this has no effect::
@@ -304,3 +331,40 @@ The ``prec`` and ``dps`` attributes can be changed (for interface compatibility
15
Due to intermediate rounding and cancellation errors, results computed with ``fp`` arithmetic may be much less accurate than those computed with ``mp`` using an equivalent precision (``mp.prec = 53``), since the latter often uses increased internal precision. The accuracy is highly problem-dependent: for some functions, ``fp`` almost always gives 14-15 correct digits; for others, results can be accurate to only 2-3 digits or even completely wrong. The recommended use for ``fp`` is therefore to speed up large-scale computations where accuracy can be verified in advance on a subset of the input set, or where results can be verified afterwards.
Beware that the ``fp`` context has signed zero, that can be used to distinguish
different sides of branch cuts. For example, ``fp.mpc(-1, -0.0)`` is treated
as though it lies *below* the branch cut for :func:`~mpmath.sqrt()`::
>>> fp.sqrt(fp.mpc(-1, -0.0))
-1j
>>> fp.sqrt(fp.mpc(-1, -1e-10))
(5e-11-1j)
But an argument of ``fp.mpc(-1, 0.0)`` is treated as though it lies *above* the
branch cut::
>>> fp.sqrt(fp.mpc(-1, +0.0))
1j
>>> fp.sqrt(fp.mpc(-1, +1e-10))
(5e-11+1j)
While near the branch cut, for small but nonzero deviations in components
results agreed with the ``mp`` contexts::
>>> fp.mpc(mp.sqrt(mp.mpc(-1, -1e-10)))
(5e-11-1j)
>>> fp.mpc(mp.sqrt(mp.mpc(-1, +1e-10)))
(5e-11+1j)
one has no signed zeros and allows to specify result *on the branch cut*
(nonpositive part of the real axis in this example)::
>>> fp.mpc(mp.sqrt(mp.mpc(-1, 0)))
1j
>>> fp.mpc(mp.sqrt(-1))
1j
Here it's continuous from the above of the :func:`~mpmath.sqrt()` branch
cut (from ``0`` along the negative real axis to the negative infinity).
+108
View File
@@ -0,0 +1,108 @@
Bessel functions and related functions
--------------------------------------
The functions in this section arise as solutions to various differential
equations in physics, typically describing wavelike oscillatory behavior or a
combination of oscillation and exponential decay or growth. Mathematically,
they are special cases of the confluent hypergeometric functions `\,_0F_1`,
`\,_1F_1` and `\,_1F_2` (see :doc:`hypergeometric`).
Bessel functions
................
.. autofunction:: mpmath.besselj
.. autofunction:: mpmath.j0
.. autofunction:: mpmath.j1
.. autofunction:: mpmath.bessely
.. autofunction:: mpmath.besseli
.. autofunction:: mpmath.besselk
Bessel function zeros
.....................
.. autofunction:: mpmath.besseljzero
.. autofunction:: mpmath.besselyzero
Hankel functions
................
.. autofunction:: mpmath.hankel1
.. autofunction:: mpmath.hankel2
Spherical Bessel functions
..........................
.. autofunction:: mpmath.spherical_jn
.. autofunction:: mpmath.spherical_yn
.. autofunction:: mpmath.spherical_in
.. autofunction:: mpmath.spherical_kn
Kelvin functions
................
.. autofunction:: mpmath.ber
.. autofunction:: mpmath.bei
.. autofunction:: mpmath.ker
.. autofunction:: mpmath.kei
Struve functions
................
.. autofunction:: mpmath.struveh
.. autofunction:: mpmath.struvel
Anger-Weber functions
.....................
.. autofunction:: mpmath.angerj
.. autofunction:: mpmath.webere
Lommel functions
................
.. autofunction:: mpmath.lommels1
.. autofunction:: mpmath.lommels2
Airy and Scorer functions
.........................
.. autofunction:: mpmath.airyai
.. autofunction:: mpmath.airybi
.. autofunction:: mpmath.airyaizero
.. autofunction:: mpmath.airybizero
.. autofunction:: mpmath.scorergi
.. autofunction:: mpmath.scorerhi
Coulomb wave functions
......................
.. autofunction:: mpmath.coulombf
.. autofunction:: mpmath.coulombg
.. autofunction:: mpmath.coulombc
Confluent U and Whittaker functions
...................................
.. autofunction:: mpmath.hyperu
.. autofunction:: mpmath.whitm
.. autofunction:: mpmath.whitw
Parabolic cylinder functions
............................
.. autofunction:: mpmath.pcfd
.. autofunction:: mpmath.pcfu
.. autofunction:: mpmath.pcfv
.. autofunction:: mpmath.pcfw
+45
View File
@@ -0,0 +1,45 @@
Mathematical constants
----------------------
Mpmath supports arbitrary-precision computation of various common (and less
common) mathematical constants. These constants are implemented as lazy
objects that can evaluate to any precision. Whenever the objects are used as
function arguments or as operands in arithmetic operations, they automagically
evaluate to the current working precision. A lazy number can be converted to a
regular ``mpf`` using the unary ``+`` operator, or by calling it as a
function::
>>> from mpmath import pi, mp
>>> pi
<pi: 3.14159~>
>>> 2*pi
mpf('6.2831853071795862')
>>> +pi
mpf('3.1415926535897931')
>>> pi()
mpf('3.1415926535897931')
>>> mp.dps = 40
>>> pi
<pi: 3.14159~>
>>> 2*pi
mpf('6.28318530717958647692528676655900576839434')
>>> +pi
mpf('3.14159265358979323846264338327950288419717')
>>> pi()
mpf('3.14159265358979323846264338327950288419717')
The predefined objects ``j`` (imaginary unit), ``inf`` (positive infinity) and
``nan`` (not-a-number) are shortcuts to ``mpc`` and ``mpf`` instances with
these fixed values.
.. autofunction:: mpmath.mp.pi
.. autoattribute:: mpmath.mp.degree
.. autoattribute:: mpmath.mp.e
.. autoattribute:: mpmath.mp.phi
.. autofunction:: mpmath.mp.euler
.. autoattribute:: mpmath.mp.catalan
.. autoattribute:: mpmath.mp.apery
.. autoattribute:: mpmath.mp.khinchin
.. autoattribute:: mpmath.mp.glaisher
.. autoattribute:: mpmath.mp.mertens
.. autoattribute:: mpmath.mp.twinprime
+66
View File
@@ -0,0 +1,66 @@
Elliptic functions
------------------
.. automodule:: mpmath.functions.elliptic
:no-index:
Elliptic arguments
..................
.. autofunction:: mpmath.qfrom
.. autofunction:: mpmath.qbarfrom
.. autofunction:: mpmath.mfrom
.. autofunction:: mpmath.kfrom
.. autofunction:: mpmath.taufrom
.. autofunction:: mpmath.g2g3from
.. autofunction:: mpmath.omega1omega2from
Legendre elliptic integrals
...........................
.. autofunction:: mpmath.ellipk
.. autofunction:: mpmath.ellipf
.. autofunction:: mpmath.ellipe
.. autofunction:: mpmath.ellippi
Carlson symmetric elliptic integrals
....................................
.. autofunction:: mpmath.elliprf
.. autofunction:: mpmath.elliprc
.. autofunction:: mpmath.elliprj
.. autofunction:: mpmath.elliprd
.. autofunction:: mpmath.elliprg
Jacobi theta functions
......................
.. autofunction:: mpmath.jtheta
Jacobi elliptic functions
.........................
.. autofunction:: mpmath.ellipfun
Weierstrass elliptic functions
..............................
.. autofunction:: mpmath.weierp
.. autofunction:: mpmath.weierpprime
.. autofunction:: mpmath.weiersigma
.. autofunction:: mpmath.weierzeta
.. autofunction:: mpmath.weierpinv
Modular functions
.................
.. autofunction:: mpmath.eta
.. autofunction:: mpmath.kleinj
.. autofunction:: mpmath.kleinjinv
+70
View File
@@ -0,0 +1,70 @@
Exponential integrals and error functions
-----------------------------------------
Exponential integrals give closed-form solutions to a large class of commonly
occurring transcendental integrals that cannot be evaluated using elementary
functions. Integrals of this type include those with an integrand of the form
`t^a e^{t}` or `e^{-x^2}`, the latter giving rise to the Gaussian (or normal)
probability distribution.
The most general function in this section is the incomplete gamma function, to
which all others can be reduced. The incomplete gamma function, in turn, can
be expressed using hypergeometric functions (see :doc:`hypergeometric`).
Incomplete gamma functions
..........................
.. autofunction:: mpmath.gammainc
.. autofunction:: mpmath.lower_gamma
.. autofunction:: mpmath.upper_gamma
Exponential integrals
.....................
.. autofunction:: mpmath.ei
.. autofunction:: mpmath.e1
.. autofunction:: mpmath.expint
Logarithmic integral
....................
.. autofunction:: mpmath.li
Trigonometric integrals
.......................
.. autofunction:: mpmath.ci
.. autofunction:: mpmath.si
Hyperbolic integrals
....................
.. autofunction:: mpmath.chi
.. autofunction:: mpmath.shi
Error functions
...............
.. autofunction:: mpmath.erf
.. autofunction:: mpmath.erfc
.. autofunction:: mpmath.erfi
.. autofunction:: mpmath.erfinv
The normal distribution
.......................
.. autofunction:: mpmath.npdf
.. autofunction:: mpmath.ncdf
Fresnel integrals
.................
.. autofunction:: mpmath.fresnels
.. autofunction:: mpmath.fresnelc
+79
View File
@@ -0,0 +1,79 @@
Factorials and gamma functions
------------------------------
Factorials and factorial-like sums and products are basic tools of
combinatorics and number theory. Much like the exponential function is
fundamental to differential equations and analysis in general, the factorial
function (and its extension to complex numbers, the gamma function) is
fundamental to difference equations and functional equations.
A large selection of factorial-like functions is implemented in mpmath. All
functions support complex arguments, and arguments may be arbitrarily large.
Results are numerical approximations, so to compute *exact* values a high
enough precision must be set manually::
>>> from mpmath import mp, fac
>>> mp.dps = 15
>>> mp.pretty = True
>>> fac(100)
9.33262154439442e+157
>>> print(int(_)) # most digits are wrong
93326215443944150965646704795953882578400970373184098831012889540582227238570431295066113089288327277825849664006524270554535976289719382852181865895959724032
>>> mp.dps = 160
>>> fac(100)
93326215443944152681699238856266700490715968264381621468592963895217599993229915608941463976156518286253697920827223758251185210916864000000000000000000000000.0
The gamma and polygamma functions are closely related to :doc:`zeta`. See also
:doc:`qfunctions` for q-analogs of factorial-like functions.
Factorials
..........
.. autofunction:: mpmath.factorial
.. autofunction:: mpmath.fac2
Binomial coefficients
.....................
.. autofunction:: mpmath.binomial
Gamma function
..............
.. autofunction:: mpmath.gamma
.. autofunction:: mpmath.rgamma
.. autofunction:: mpmath.gammaprod
.. autofunction:: mpmath.loggamma
Rising and falling factorials
.............................
.. autofunction:: mpmath.rf
.. autofunction:: mpmath.ff
Beta function
.............
.. autofunction:: mpmath.beta
.. autofunction:: mpmath.betainc
Super- and hyperfactorials
..........................
.. autofunction:: mpmath.superfac
.. autofunction:: mpmath.hyperfac
.. autofunction:: mpmath.barnesg
Polygamma functions and harmonic numbers
........................................
.. autofunction:: mpmath.psi
.. autofunction:: mpmath.digamma
.. autofunction:: mpmath.harmonic
+23
View File
@@ -0,0 +1,23 @@
Hyperbolic functions
--------------------
Hyperbolic functions
....................
.. autofunction:: mpmath.cosh
.. autofunction:: mpmath.sinh
.. autofunction:: mpmath.tanh
.. autofunction:: mpmath.sech
.. autofunction:: mpmath.csch
.. autofunction:: mpmath.coth
Inverse hyperbolic functions
............................
.. autofunction:: mpmath.acosh
.. autofunction:: mpmath.asinh
.. autofunction:: mpmath.atanh
.. autofunction:: mpmath.asech
.. autofunction:: mpmath.acsch
.. autofunction:: mpmath.acoth
+74
View File
@@ -0,0 +1,74 @@
Hypergeometric functions
------------------------
The functions listed in :doc:`expintegrals`, :doc:`bessel` and
:doc:`orthogonal`, and many other functions as well, are merely particular
instances of the generalized hypergeometric function `\,_pF_q`. The functions
listed in the following section enable efficient direct evaluation of the
underlying hypergeometric series, as well as linear combinations, limits with
respect to parameters, and analytic continuations thereof. Extensions to
twodimensional series are also provided. See also the basic or q-analog of the
hypergeometric series in :doc:`qfunctions`.
For convenience, most of the hypergeometric series of low order are provided as
standalone functions. They can equivalently be evaluated using
:func:`~mpmath.hyper`. As will be demonstrated in the respective docstrings,
all the ``hyp#f#`` functions implement analytic continuations and/or asymptotic
expansions with respect to the argument `z`, thereby permitting evaluation for
`z` anywhere in the complex plane. Functions of higher degree can be computed
via :func:`~mpmath.hyper`, but generally only in rapidly convergent instances.
Most hypergeometric and hypergeometric-derived functions accept optional
keyword arguments to specify options for :func:`~mpmath.hypercomb` or
:func:`~mpmath.hyper`. Some useful options are *maxprec*, *maxterms*,
*zeroprec*, *accurate_small*, *hmag*, *force_series*, *asymp_tol* and
*eliminate*. These options give control over what to do in case of slow
convergence, extreme loss of accuracy or evaluation at zeros (these two cases
cannot generally be distinguished from each other automatically), and singular
parameter combinations.
Common hypergeometric series
............................
.. autofunction:: mpmath.hyp0f1
.. autofunction:: mpmath.hyp1f1
.. autofunction:: mpmath.hyp1f2
.. autofunction:: mpmath.hyp2f0
.. autofunction:: mpmath.hyp2f1
.. autofunction:: mpmath.hyp2f2
.. autofunction:: mpmath.hyp2f3
.. autofunction:: mpmath.hyp3f2
Generalized hypergeometric functions
....................................
.. autofunction:: mpmath.hyper
.. autofunction:: mpmath.hypercomb
Meijer G-function
.................
.. autofunction:: mpmath.meijerg
Fox H-function
.................
.. autofunction:: mpmath.foxh
Bilateral hypergeometric series
...............................
.. autofunction:: mpmath.bihyper
Hypergeometric functions of two variables
.........................................
.. autofunction:: mpmath.hyper2d
.. autofunction:: mpmath.appellf1
.. autofunction:: mpmath.appellf2
.. autofunction:: mpmath.appellf3
.. autofunction:: mpmath.appellf4
@@ -6,16 +6,17 @@ Mpmath implements the standard functions from Python's ``math`` and ``cmath`` mo
.. toctree::
:maxdepth: 2
constants.txt
powers.txt
trigonometric.txt
hyperbolic.txt
gamma.txt
expintegrals.txt
bessel.txt
orthogonal.txt
hypergeometric.txt
elliptic.txt
zeta.txt
numtheory.txt
qfunctions.txt
constants
powers
trigonometric
hyperbolic
signals
gamma
expintegrals
bessel
orthogonal
hypergeometric
elliptic
zeta
numtheory
qfunctions
+58
View File
@@ -0,0 +1,58 @@
Number-theoretical, combinatorial and integer functions
-------------------------------------------------------
For factorial-type functions, including binomial coefficients, double
factorials, etc, see the separate section :doc:`gamma`.
Fibonacci numbers
.................
.. autofunction:: mpmath.fibonacci
Bernoulli numbers and polynomials
.................................
.. autofunction:: mpmath.bernoulli
.. autofunction:: mpmath.bernfrac
.. autofunction:: mpmath.bernpoly
Euler numbers and polynomials
.............................
.. autofunction:: mpmath.eulernum
.. autofunction:: mpmath.eulerpoly
Bell numbers and polynomials
............................
.. autofunction:: mpmath.bell
Stirling numbers
................
.. autofunction:: mpmath.stirling1
.. autofunction:: mpmath.stirling2
Prime counting functions
........................
.. autofunction:: mpmath.primepi
.. autofunction:: mpmath.primepi2
.. autofunction:: mpmath.riemannr
Cyclotomic polynomials
......................
.. autofunction:: mpmath.cyclotomic
Arithmetic functions
......................
.. autofunction:: mpmath.mangoldt
+77
View File
@@ -0,0 +1,77 @@
Orthogonal polynomials
----------------------
An orthogonal polynomial sequence is a sequence of polynomials `P_0(x), P_1(x),
\ldots` of degree `0, 1, \ldots`, which are mutually orthogonal in the sense
that
.. math ::
\int_S P_n(x) P_m(x) w(x) dx =
\begin{cases}
c_n \ne 0 & \text{if $m = n$} \\
0 & \text{if $m \ne n$}
\end{cases}
where `S` is some domain (e.g. an interval `[a,b] \in \mathbb{R}`) and `w(x)`
is a fixed *weight function*. A sequence of orthogonal polynomials is
determined completely by `w`, `S`, and a normalization convention (e.g. `c_n =
1`). Applications of orthogonal polynomials include function approximation and
solution of differential equations.
Orthogonal polynomials are sometimes defined using the differential equations
they satisfy (as functions of `x`) or the recurrence relations they satisfy
with respect to the order `n`. Other ways of defining orthogonal polynomials
include differentiation formulas and generating functions. The standard
orthogonal polynomials can also be represented as hypergeometric series (see
:doc:`hypergeometric`), more specifically using the Gauss hypergeometric
function `\,_2F_1` in most cases. The following functions are generally
implemented using hypergeometric functions since this is computationally
efficient and easily generalizes.
For more information, see the `Wikipedia article on orthogonal polynomials
<http://en.wikipedia.org/wiki/Orthogonal_polynomials>`_.
Legendre functions
..................
.. autofunction:: mpmath.legendre
.. autofunction:: mpmath.legenp
.. autofunction:: mpmath.legenq
Chebyshev polynomials
.....................
.. autofunction:: mpmath.chebyt
.. autofunction:: mpmath.chebyu
Jacobi polynomials
..................
.. autofunction:: mpmath.jacobi
Gegenbauer polynomials
......................
.. autofunction:: mpmath.gegenbauer
Hermite polynomials
...................
.. autofunction:: mpmath.hermite
Laguerre polynomials
....................
.. autofunction:: mpmath.laguerre
Spherical harmonics
...................
.. autofunction:: mpmath.spherharm
+45
View File
@@ -0,0 +1,45 @@
Powers and logarithms
---------------------
Nth roots
.........
.. autofunction:: mpmath.sqrt
.. autofunction:: mpmath.hypot
.. autofunction:: mpmath.cbrt
.. autofunction:: mpmath.root
.. autofunction:: mpmath.unitroots
Exponentiation
..............
.. autofunction:: mpmath.exp
.. autofunction:: mpmath.exp2
.. autofunction:: mpmath.power
.. autofunction:: mpmath.expj
.. autofunction:: mpmath.expjpi
.. autofunction:: mpmath.expm1
.. autofunction:: mpmath.powm1
Logarithms
..........
.. autofunction:: mpmath.log
.. autofunction:: mpmath.ln
.. autofunction:: mpmath.log2
.. autofunction:: mpmath.log10
.. autofunction:: mpmath.log1p
Lambert W function
..................
.. autofunction:: mpmath.lambertw
Arithmetic-geometric mean
.........................
.. autofunction:: mpmath.agm
+20
View File
@@ -0,0 +1,20 @@
q-functions
-----------
q-Pochhammer symbol
...................
.. autofunction:: mpmath.qp
q-gamma and factorial
.....................
.. autofunction:: mpmath.qgamma
.. autofunction:: mpmath.qfac
Hypergeometric q-series
.......................
.. autofunction:: mpmath.qhyper
+34
View File
@@ -0,0 +1,34 @@
Signal functions
----------------
The functions in this section describe non-sinusoidal waveforms, which are
often used in signal processing and electronics.
Square wave signal
..................
.. autofunction:: mpmath.squarew
Triangle wave signal
....................
.. autofunction:: mpmath.trianglew
Sawtooth wave signal
....................
.. autofunction:: mpmath.sawtoothw
Unit triangle signal
....................
.. autofunction:: mpmath.unit_triangle
Sigmoid wave signal
.....................
.. autofunction:: mpmath.sigmoid
+62
View File
@@ -0,0 +1,62 @@
Trigonometric functions
-----------------------
Except where otherwise noted, the trigonometric functions take a radian angle
as input and the inverse trigonometric functions return radian angles.
The ordinary trigonometric functions are single-valued functions defined
everywhere in the complex plane (except at the poles of tan, sec, csc, and
cot). They are defined generally via the exponential function, e.g.
.. math ::
\cos(x) = \frac{e^{ix} + e^{-ix}}{2}.
The inverse trigonometric functions are multivalued, thus requiring branch
cuts, and are generally real-valued only on a part of the real line.
Definitions and branch cuts are given in the documentation of each function.
The branch cut conventions used by mpmath are essentially the same as those
found in most standard mathematical software, such as Mathematica and Python's
own ``cmath`` libary.
Degree-radian conversion
........................
.. autofunction:: mpmath.degrees
.. autofunction:: mpmath.radians
Trigonometric functions
.......................
.. autofunction:: mpmath.cos
.. autofunction:: mpmath.sin
.. autofunction:: mpmath.tan
.. autofunction:: mpmath.sec
.. autofunction:: mpmath.csc
.. autofunction:: mpmath.cot
Trigonometric functions with modified argument
..............................................
.. autofunction:: mpmath.cospi
.. autofunction:: mpmath.sinpi
Inverse trigonometric functions
...............................
.. autofunction:: mpmath.acos
.. autofunction:: mpmath.asin
.. autofunction:: mpmath.atan
.. autofunction:: mpmath.atan2
.. autofunction:: mpmath.asec
.. autofunction:: mpmath.acsc
.. autofunction:: mpmath.acot
Sinc function
.............
.. autofunction:: mpmath.sinc
.. autofunction:: mpmath.sincpi
+60
View File
@@ -0,0 +1,60 @@
Zeta functions, L-series and polylogarithms
-------------------------------------------
This section includes the Riemann zeta functions and associated functions
pertaining to analytic number theory.
Riemann and Hurwitz zeta functions
..................................
.. autofunction:: mpmath.zeta
Dirichlet L-series
..................
.. autofunction:: mpmath.altzeta
.. autofunction:: mpmath.dirichlet
Stieltjes constants
...................
.. autofunction:: mpmath.stieltjes
Zeta function zeros
...................
These functions are used for the study of the Riemann zeta function in the
critical strip.
.. autofunction:: mpmath.zetazero
.. autofunction:: mpmath.nzeros
.. autofunction:: mpmath.siegelz
.. autofunction:: mpmath.siegeltheta
.. autofunction:: mpmath.grampoint
.. autofunction:: mpmath.backlunds
Lerch transcendent
..................
.. autofunction:: mpmath.lerchphi
Polylogarithms and Clausen functions
....................................
.. autofunction:: mpmath.polylog
.. autofunction:: mpmath.clsin
.. autofunction:: mpmath.clcos
.. autofunction:: mpmath.polyexp
Zeta function variants
......................
.. autofunction:: mpmath.primezeta
.. autofunction:: mpmath.secondzeta
+243
View File
@@ -0,0 +1,243 @@
Utility functions
===============================================
This page lists functions that perform basic operations
on numbers or aid general programming.
Conversion and printing
-----------------------
:func:`~mpmath.mpmathify` / ``convert()``
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.mpmathify
:func:`~mpmath.nstr`
^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.nstr
:func:`~mpmath.nprint`
^^^^^^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.nprint
:func:`mpmath.mpf.__format__`
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.mpf.__format__
:func:`mpmath.mpc.__format__`
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.mpc.__format__
Arithmetic operations
---------------------
See also :func:`mpmath.sqrt`, :func:`mpmath.exp` etc., listed
in :doc:`functions/powers`
:func:`~mpmath.fadd`
^^^^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.fadd
:func:`~mpmath.fsub`
^^^^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.fsub
:func:`~mpmath.fneg`
^^^^^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.fneg
:func:`~mpmath.fmul`
^^^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.fmul
:func:`~mpmath.fdiv`
^^^^^^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.fdiv
:func:`~mpmath.fmod`
^^^^^^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.fmod
:func:`~mpmath.fsum`
^^^^^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.fsum
:func:`~mpmath.fprod`
^^^^^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.fprod
:func:`~mpmath.fdot`
^^^^^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.fdot
Complex components
------------------
:func:`~mpmath.fabs`
^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.fabs
:func:`~mpmath.sign`
^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.sign
:func:`~mpmath.re`
^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.re
:func:`~mpmath.im`
^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.im
:func:`~mpmath.arg`
^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.arg
:func:`~mpmath.conj`
^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.conj
:func:`~mpmath.polar`
^^^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.polar
:func:`~mpmath.rect`
^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.rect
Integer and fractional parts
-----------------------------
:func:`~mpmath.floor`
^^^^^^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.floor
:func:`~mpmath.ceil`
^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.ceil
:func:`~mpmath.nint`
^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.nint
:func:`~mpmath.frac`
^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.frac
Tolerances and approximate comparisons
--------------------------------------
:func:`~mpmath.chop`
^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.chop
:func:`~mpmath.almosteq`
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.almosteq
Properties of numbers
-------------------------------------
:func:`~mpmath.isinf`
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.isinf
:func:`~mpmath.isnan`
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.isnan
:func:`~mpmath.isnormal`
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.isnormal
:func:`~mpmath.isfinite`
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.isfinite
:func:`~mpmath.isint`
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.isint
:func:`~mpmath.ldexp`
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.ldexp
:func:`~mpmath.frexp`
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.frexp
:func:`~mpmath.mag`
^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.mag
:func:`~mpmath.nint_distance`
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.nint_distance
:func:`~mpmath.absmin`
^^^^^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.absmin
:func:`~mpmath.absmax`
^^^^^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.absmax
Number generation
-----------------
:func:`~mpmath.fraction`
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.fraction
:func:`~mpmath.rand`
^^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.rand
:func:`~mpmath.arange`
^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.arange
:func:`~mpmath.linspace`
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.linspace
Precision management
--------------------
:func:`~mpmath.autoprec`
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.autoprec
:func:`~mpmath.workprec`
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.workprec
:func:`~mpmath.workdps`
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.workdps
:func:`~mpmath.extraprec`
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.extraprec
:func:`~mpmath.extradps`
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.extradps
Performance and debugging
------------------------------------
:func:`~mpmath.memoize`
^^^^^^^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.memoize
:func:`~mpmath.maxcalls`
^^^^^^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.maxcalls
:func:`~mpmath.monitor`
^^^^^^^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.monitor
:func:`~mpmath.timing`
^^^^^^^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.timing
+2
View File
@@ -0,0 +1,2 @@
Index
=====
@@ -7,25 +7,25 @@ Subject to certain restrictions, such "reverse engineering" is indeed possible t
Automated number recognition based on PSLQ is not a silver bullet. Any occurring transcendental constants (`\pi`, `e`, etc) must be guessed by the user, and the relation between those constants in the formula must be linear (such as `x = 3 \pi + 4 e`). More complex formulas can be found by combining PSLQ with functional transformations; however, this is only feasible to a limited extent since the computation time grows exponentially with the number of operations that need to be combined.
The number identification facilities in mpmath are inspired by the `Inverse Symbolic Calculator <http://oldweb.cecm.sfu.ca/projects/ISC/ISCmain.html>`_ (ISC). The ISC is more powerful than mpmath, as it uses a lookup table of millions of precomputed constants (thereby mitigating the problem with exponential complexity).
The number identification facilities in mpmath are inspired by the `Inverse Symbolic Calculator <http://wayback.cecm.sfu.ca/projects/ISC/ISCmain.html>`_ (ISC). The ISC is more powerful than mpmath, as it uses a lookup table of millions of precomputed constants (thereby mitigating the problem with exponential complexity).
Constant recognition
-----------------------------------
:func:`identify`
^^^^^^^^^^^^^^^^
:func:`~mpmath.identify`
^^^^^^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.identify
Algebraic identification
---------------------------------------
:func:`findpoly`
^^^^^^^^^^^^^^^^
:func:`~mpmath.findpoly`
^^^^^^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.findpoly
Integer relations (PSLQ)
----------------------------
:func:`pslq`
^^^^^^^^^^^^^^^^
:func:`~mpmath.pslq`
^^^^^^^^^^^^^^^^^^^^^
.. autofunction:: mpmath.pslq
+14 -12
View File
@@ -6,7 +6,7 @@ Welcome to mpmath's documentation!
==================================
Mpmath is a Python library for arbitrary-precision floating-point arithmetic.
For general information about mpmath, see the project website http://mpmath.org/
For general information about mpmath, see the project website https://mpmath.org/
These documentation pages include general information as well as docstring listing with extensive use of examples that can be run in the interactive Python interpreter. For quick access to the docstrings of individual functions, use the `index listing <genindex.html>`_, or type ``help(mpmath.function_name)`` in the Python interactive prompt.
@@ -16,8 +16,8 @@ Introduction
.. toctree ::
:maxdepth: 2
setup.txt
basics.txt
setup
basics
Basic features
----------------
@@ -25,9 +25,10 @@ Basic features
.. toctree ::
:maxdepth: 2
contexts.txt
general.txt
plotting.txt
contexts
general
plotting
cli
Advanced mathematics
--------------------
@@ -38,10 +39,10 @@ provides extensive support for transcendental functions, evaluation of sums, int
.. toctree ::
:maxdepth: 2
functions/index.txt
calculus/index.txt
matrices.txt
identification.txt
functions/index
calculus/index
matrices
identification
End matter
----------
@@ -49,5 +50,6 @@ End matter
.. toctree ::
:maxdepth: 2
technical.txt
references.txt
technical
references
genindex
+40 -12
View File
@@ -13,8 +13,8 @@ stored, so it is cheap to represent sparse matrices.
The most basic way to create one is to use the ``matrix`` class directly. You
can create an empty matrix specifying the dimensions::
>>> from mpmath import *
>>> mp.dps = 15; mp.pretty = False
>>> from mpmath import (matrix, ones, zeros, randmatrix, nprint, chop, iv,
... lu_solve, residual, fp, lu, diag, eye, eps, qr)
>>> matrix(2)
matrix(
[['0.0', '0.0'],
@@ -179,7 +179,7 @@ You can add and subtract matrices of compatible dimensions::
matrix(
[['3.0', '-2.0'],
['-2.0', '-5.0']])
>>> A + ones(3) # doctest:+ELLIPSIS
>>> A + ones(3)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "...", line 238, in __add__
@@ -260,6 +260,14 @@ so called norms.
Linear algebra
--------------
Determinant and Rank
....................
.. autofunction :: mpmath.det
.. autofunction :: mpmath.rank
Decompositions
..............
@@ -285,7 +293,8 @@ using ``lu_solve``::
[['30.0'],
['-20.0']])
If you don't trust the result, use ``residual`` to calculate the residual ||A*x-b||::
If you don't trust the result, use ``residual`` to calculate
the residual `||A x-b||`::
>>> residual(A, x, b)
matrix(
@@ -295,7 +304,7 @@ If you don't trust the result, use ``residual`` to calculate the residual ||A*x-
'2.22044604925031e-16'
As you can see, the solution is quite accurate. The error is caused by the
inaccuracy of the internal floating point arithmetic. Though, it's even smaller
inaccuracy of the internal floating-point arithmetic. Though, it's even smaller
than the current machine epsilon, which basically means you can trust the
result.
@@ -304,10 +313,10 @@ and methods::
>>> A = fp.matrix([[1, 2], [3, 4]])
>>> b = fp.matrix([-10, 10])
>>> fp.lu_solve(A, b) # doctest:+SKIP
>>> fp.lu_solve(A, b)
matrix(
[['30.0'],
['-20.0']])
[['29.999999999999996'],
['-19.999999999999996']])
``lu_solve`` accepts overdetermined systems. It is usually not possible to solve
such systems, so the residual is minimized instead. Internally this is done
@@ -316,6 +325,7 @@ that that ``lu_solve`` will square the errors. If you can't afford this, use
``qr_solve`` instead. It is twice as slow but more accurate, and it calculates
the residual automatically.
.. autofunction:: mpmath.lu_solve
Matrix factorization
....................
@@ -415,10 +425,10 @@ Examples::
>>> from mpmath import mp
>>> A = mp.matrix([[3, -1, 2], [2, 5, -5], [-2, -3, 7]])
>>> Q, R = mp.schur(A)
>>> mp.nprint(R, 3) # doctest:+SKIP
[2.0 0.417 -2.53]
[0.0 4.0 -4.74]
[0.0 0.0 9.0]
>>> mp.nprint(R, 3)
[2.0 0.417 2.53]
[0.0 4.0 4.74]
[0.0 0.0 9.0]
>>> print(mp.chop(A - Q * R * Q.transpose_conj()))
[0.0 0.0 0.0]
[0.0 0.0 0.0]
@@ -461,6 +471,9 @@ Examples::
[0.0 0.0 0.0]
See also [Stoer]_ and [Kresser]_.
The symmetric eigenvalue problem
................................
@@ -506,6 +519,21 @@ Examples::
[0.0]
See also [Golub]_, [GolubWelsch]_, [Stoer]_ and [Stroud]_.
Determinant
...........
The determinant of a square matrix is computed by the
function ``det``::
>>> from mpmath import mp
>>> A = mp.matrix([[7, 2], [1.5, 3]])
>>> print(mp.det(A))
18.0
Interval and double-precision matrices
--------------------------------------

Before

Width:  |  Height:  |  Size: 26 KiB

After

Width:  |  Height:  |  Size: 26 KiB

Before

Width:  |  Height:  |  Size: 60 KiB

After

Width:  |  Height:  |  Size: 60 KiB

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 19 KiB

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 19 KiB

Before

Width:  |  Height:  |  Size: 34 KiB

After

Width:  |  Height:  |  Size: 34 KiB

Before

Width:  |  Height:  |  Size: 23 KiB

After

Width:  |  Height:  |  Size: 23 KiB

Before

Width:  |  Height:  |  Size: 36 KiB

After

Width:  |  Height:  |  Size: 36 KiB

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 15 KiB

Before

Width:  |  Height:  |  Size: 30 KiB

After

Width:  |  Height:  |  Size: 30 KiB

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 19 KiB

Some files were not shown because too many files have changed in this diff Show More