Diofant

Latest version: v0.15.0

Safety actively analyzes 682404 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

Page 1 of 2

0.147518181586635

[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.2550501.svg)](https://doi.org/10.5281/zenodo.2550501)
See [release notes](https://diofant.readthedocs.io/en/latest/release/notes-0.10.html).

0.14.0

Construction of Poly's from expressions is now significantly faster with using recursive algorithm (former ``poly()`` function):
python
In [1]: %time p = Poly((x + 1)**1000, x)
CPU times: user 178 ms, sys: 3.88 ms, total: 181 ms
Wall time: 182 ms

0.13

python
In [1]: %time p = Poly((x + 1)**1000, x)
CPU times: user 1min 4s, sys: 55.9 ms, total: 1min 4s
Wall time: 1min 4s

or in the current SymPy master:
python
In [1]: %time p = Poly((x + 1)**1000, x)
CPU times: user 4.78 s, sys: 26.9 ms, total: 4.8 s
Wall time: 5.05 s


Support for directional limits on the complex plane was added:
python
In [1]: limit(sqrt(-1 + I*x), x, 0, dir=exp(I*pi/3))
Out[1]: -ⅈ

Direction ``exp(I*theta)`` at the limit point ``x0`` indicates the direction tangent of a curve approaching the limit point. Special cases ``-1`` (former dir=``+``) and ``+1`` (former dir=``-``) correspond to ``theta=pi`` and ``theta=0`` (i.e. limit from above or from below on the real line).

This release got better support for limits of piecewise and boolean expressions
python
In [1]: Piecewise((x**2/2, x <= 1/2), (x/2 - 1/8, True))
Out[1]:
⎧ 2
⎪ x
⎪ ── for x ≤ 1/2
⎪ 2

⎪x 1
⎪─ - ─ otherwise
⎪2 8


In [2]: limit(_1, x, 0)
Out[2]: 0

In [3]: limit(_1, x, oo)
Out[3]: ∞

In [4]: limit(x > 0, x, 0)
Out[4]: true

In [5]: limit(x > 0, x, 0, dir=1)
Out[5]: false


Also, for good or bad, now you could use any unicode symbols for identifiers (python does NFKC-normalization while parsing) in the Diofant console:
python
$ python -m diofant --no-ipython --unicode-identifiers
>>> Naturals

>>> ℕ = Naturals
>>> N = 2
>>> ℕ will print 2 in plain Python



[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.7820401.svg)](https://doi.org/10.5281/zenodo.7820401)

See [release notes](https://diofant.readthedocs.io/en/latest/release/notes-0.14.html).

0.13.0

This release supports calling the Diofant as a module to provide more enhanced CLI interface wrt the standard Python (or IPython) shell. For instance, per default it adds default imports from the Diofant, initialises some symbols and wraps all integer divisions with [fractions.Fraction](https://docs.python.org/3/library/fractions.html#fractions.Fraction)'s:
python
$ python -m diofant --no-ipython
>>> series(sin(x), x)
3 5
x x ⎛ 6⎞
x - ── + ─── + O⎝x ⎠
6 120
>>> rsolve(f(n + 2) - f(n))
⎡⎧ n ⎫⎤
⎢⎨f: n ↦ (-1) ⋅C₁ + C₀⎬⎥
⎣⎩ ⎭⎦
>>> type(1/2)
<class 'fractions.Fraction'>

The IPython shell is used, instead of the ordinary Python shell, if available:
python
$ python -m diofant

In [1]: series(sin(x), x)
Out[1]:
3 5
x x ⎛ 6⎞
x - ── + ─── + O⎝x ⎠
6 120

In [2]: rsolve(f(n + 2) - f(n))
Out[2]:
⎡⎧ n ⎫⎤
⎢⎨f: n ↦ (-1) ⋅C₁ + C₀⎬⎥
⎣⎩ ⎭⎦

In [3]: type(1/2)
Out[3]: fractions.Fraction

Use --help switch to see available options.

Support for square-free factorization of multivariate polynomials over Galois
fields was added:
python
In [4]: sqf_list(x**8*y**8 + 1, modulus=8)
Out[4]: (1, [(x⋅y + 1, 8)])


Please note, that this version require CPython >= 3.9 (latest 3.10 is supported too).
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.5651447.svg)](https://doi.org/10.5281/zenodo.5651447)
See [release notes](https://diofant.readthedocs.io/en/latest/release/notes-0.13.html).

0.12.0

This release finishes porting all algorithms in the polys module to use the sparse polynomial representation. While that change is mostly hidden from the end user - the codebase volume was reduced drastically:

$ wc -lc sympy/polys/*.py|tail -1 on SymPy 0.7.6
37942 1088668 total
$ wc -lc diofant/polys/*.py|tail -1
20960 672333 total

The implementation is not optimal and there are some speed regressions, which hopefully will be fixed in following releases.

The notable user-visible change is the new factorization algorithm for mutivariate polynomials over algebraic number fields. For example:
python
In [1]: R, x, y, z = ring('x, y, z', A)
...: f1, f2 = x**2 + 2*y + sqrt(2), root(3, 3)*x - z
...: f = f1*f2
...: %time r = f.factor_list()
CPU times: user 22.9 s, sys: 99.9 ms, total: 23 s
Wall time: 23.3 s

while on the current SymPy master (despite more optimized implementation of low-level operations) timings are:
python
CPU times: user 32.4 s, sys: 309 ms, total: 32.7 s
Wall time: 32.9 s

The difference is bigger for extensions of high degrees.

Also, this version supports solving linear inequalities with the classical Fourier-Motzkin elimination algorithm:
python
In [2]: reduce_inequalities([x >= 0, 2*x + 4*y <= 14, x - 2*y <= 1])
Out[2]:
x 1 x 7
x ≥ 0 ∧ y ≥ ─ - ─ ∧ x ≤ 4 ∧ y ≤ - ─ + ─
2 2 2 2

Please notice, that inequalities are solved now (per default) over extended reals.
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.4447168.svg)](https://doi.org/10.5281/zenodo.4447168)
See [release notes](https://diofant.readthedocs.io/en/latest/release/notes-0.12.html).

0.11.0

The major part of changes in this release are not visible directly via public API. For example, the [Poly](https://diofant.readthedocs.io/en/v0.11.0/modules/polys.html#diofant.polys.polytools.Poly) class now uses the sparse polynomial representation (via [PolyElement](https://diofant.readthedocs.io/en/v0.11.0/internals/polys.html#diofant.polys.rings.PolyElement)):
python
In [1]: Poly(x**2 + x*y)
Out[1]: Poly(x**2 + x*y, x, y, domain='ZZ')

In [2]: type(_1.rep)
Out[2]: abc.PolyElement

A noticiable exception is finite fields of prime powers. Now it's possible to represent ones:
python
In [3]: F4 = FF(4)

In [4]: F4(2)
Out[4]: GF(2, [1, 1, 1])(2)

In [5]: _ + F4(1)
Out[5]: GF(2, [1, 1, 1])(3)

and univariate polynomial algorithms are ported to support such fields:
python
In [6]: factor(x**3 + 3*x + 2, modulus=4)
Out[6]:
⎛ 2 ⎞
(x + 1)⋅⎝x + x + 2⎠

This release also continues to improve solvers, now multivariate equations with surds are solved correctly:
python
In [7]: %time solve([sqrt(x) + y + 2, sqrt(y)*x - 1], x, y)
CPU times: user 1min 22s, sys: 496 ms, total: 1min 22s
Wall time: 1min 37s
Out[7]:
⎡⎧ 2
⎢⎨ ⎛ 5 3 ⎞ ⎛ 5 3
⎣⎩x: 4 + 4⋅RootOf⎝a₁ + 4⋅a₁ + 4⋅a₁ - 1, 3⎠ + RootOf⎝a₁ + 4⋅a₁ + 4⋅a₁ - 1,

4 2⎫ ⎧
⎞ ⎛ 5 3 ⎞ ⎬ ⎨ ⎛ 5 3
3⎠ , y: RootOf⎝a₁ + 4⋅a₁ + 4⋅a₁ - 1, 3⎠ ⎭, ⎩x: 4 + RootOf⎝a₁ + 4⋅a₁ + 4⋅a

4 2
⎞ ⎛ 5 3 ⎞ ⎛ 5 3
₁ - 1, 4⎠ + 4⋅RootOf⎝a₁ + 4⋅a₁ + 4⋅a₁ - 1, 4⎠ , y: RootOf⎝a₁ + 4⋅a₁ + 4⋅a

2⎫⎤
⎞ ⎬⎥
₁ - 1, 4⎠ ⎭⎦

[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.3760329.svg)](https://doi.org/10.5281/zenodo.3760329)
See [release notes](https://diofant.readthedocs.io/en/latest/release/notes-0.11.html).

Page 1 of 2

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.