
    \hl                     0    S SK Jr  S SKJr  SS jrSS jrg)    )S)PolyNc                    Ub  SOSnU(       a  U n[        U /UQ70 UD6n [        U/UQ70 UD6nU R                  (       a  UR                  (       d  [        S5      eU R                  UR                  :X  d  [        S5      eU R                  nU R	                  5       S:  d  UR	                  5       S:  a  S1$ U R                  5       nU(       d  UR                  5       OUn[        5       nUS    GH  u  pUS    H  u  pU	R	                  5       nUR	                  5       nX:w  a  M,  U	R                  5       nUR                  5       nX-
  R                  (       d  Ma  U	R                  X\S-
  -  5      nUR                  X]S-
  -  5      nUU-
  [        X-  5      -  nUR                  (       d  M  US:  d  UU;   a  M  US:  a$  XR                  U5      -
  R                  (       d  M  UR                  U5        M     GM     U$ )ai  Compute the *dispersion set* of two polynomials.

For two polynomials `f(x)` and `g(x)` with `\deg f > 0`
and `\deg g > 0` the dispersion set `\operatorname{J}(f, g)` is defined as:

.. math::
    \operatorname{J}(f, g)
    & := \{a \in \mathbb{N}_0 | \gcd(f(x), g(x+a)) \neq 1\} \\
    &  = \{a \in \mathbb{N}_0 | \deg \gcd(f(x), g(x+a)) \geq 1\}

For a single polynomial one defines `\operatorname{J}(f) := \operatorname{J}(f, f)`.

Examples
========

>>> from sympy import poly
>>> from sympy.polys.dispersion import dispersion, dispersionset
>>> from sympy.abc import x

Dispersion set and dispersion of a simple polynomial:

>>> fp = poly((x - 3)*(x + 3), x)
>>> sorted(dispersionset(fp))
[0, 6]
>>> dispersion(fp)
6

Note that the definition of the dispersion is not symmetric:

>>> fp = poly(x**4 - 3*x**2 + 1, x)
>>> gp = fp.shift(-3)
>>> sorted(dispersionset(fp, gp))
[2, 3, 4]
>>> dispersion(fp, gp)
4
>>> sorted(dispersionset(gp, fp))
[]
>>> dispersion(gp, fp)
-oo

Computing the dispersion also works over field extensions:

>>> from sympy import sqrt
>>> fp = poly(x**2 + sqrt(5)*x - 1, x, domain='QQ<sqrt(5)>')
>>> gp = poly(x**2 + (2 + sqrt(5))*x + sqrt(5), x, domain='QQ<sqrt(5)>')
>>> sorted(dispersionset(fp, gp))
[2]
>>> sorted(dispersionset(gp, fp))
[1, 4]

We can even perform the computations for polynomials
having symbolic coefficients:

>>> from sympy.abc import a
>>> fp = poly(4*x**4 + (4*a + 8)*x**3 + (a**2 + 6*a + 4)*x**2 + (a**2 + 2*a)*x, x)
>>> sorted(dispersionset(fp))
[0, 1]

See Also
========

dispersion

References
==========

.. [1] [ManWright94]_
.. [2] [Koepf98]_
.. [3] [Abramov71]_
.. [4] [Man93]_
FTz!Polynomials need to be univariatez(Polynomials must have the same generator   r   )r   is_univariate
ValueErrorgendegreefactor_listsetLCis_zerocoeff_monomialr   
is_integershiftadd)pqgensargssamer	   fpfqJsunusedtmnanbnanm1bnm1alphas                      N/var/www/auris/envauris/lib/python3.13/site-packages/sympy/polys/dispersion.pydispersionsetr&      s   R M5tDQAQA??!//<== 55AEE>CDD
%%C 	xxzA~as
 
B $"B 	AU	AIA
A
AvBBG$$ ##CA#J/D##CA#J/DD[AadG+E##qyEQJ1ua''%.099EE%L+  0 H    c                 l    [        X/UQ70 UD6nU(       d  [        R                  nU$ [        U5      nU$ )a  Compute the *dispersion* of polynomials.

For two polynomials `f(x)` and `g(x)` with `\deg f > 0`
and `\deg g > 0` the dispersion `\operatorname{dis}(f, g)` is defined as:

.. math::
    \operatorname{dis}(f, g)
    & := \max\{ J(f,g) \cup \{0\} \} \\
    &  = \max\{ \{a \in \mathbb{N} | \gcd(f(x), g(x+a)) \neq 1\} \cup \{0\} \}

and for a single polynomial `\operatorname{dis}(f) := \operatorname{dis}(f, f)`.
Note that we make the definition `\max\{\} := -\infty`.

Examples
========

>>> from sympy import poly
>>> from sympy.polys.dispersion import dispersion, dispersionset
>>> from sympy.abc import x

Dispersion set and dispersion of a simple polynomial:

>>> fp = poly((x - 3)*(x + 3), x)
>>> sorted(dispersionset(fp))
[0, 6]
>>> dispersion(fp)
6

Note that the definition of the dispersion is not symmetric:

>>> fp = poly(x**4 - 3*x**2 + 1, x)
>>> gp = fp.shift(-3)
>>> sorted(dispersionset(fp, gp))
[2, 3, 4]
>>> dispersion(fp, gp)
4
>>> sorted(dispersionset(gp, fp))
[]
>>> dispersion(gp, fp)
-oo

The maximum of an empty set is defined to be `-\infty`
as seen in this example.

Computing the dispersion also works over field extensions:

>>> from sympy import sqrt
>>> fp = poly(x**2 + sqrt(5)*x - 1, x, domain='QQ<sqrt(5)>')
>>> gp = poly(x**2 + (2 + sqrt(5))*x + sqrt(5), x, domain='QQ<sqrt(5)>')
>>> sorted(dispersionset(fp, gp))
[2]
>>> sorted(dispersionset(gp, fp))
[1, 4]

We can even perform the computations for polynomials
having symbolic coefficients:

>>> from sympy.abc import a
>>> fp = poly(4*x**4 + (4*a + 8)*x**3 + (a**2 + 6*a + 4)*x**2 + (a**2 + 2*a)*x, x)
>>> sorted(dispersionset(fp))
[0, 1]

See Also
========

dispersionset

References
==========

.. [1] [ManWright94]_
.. [2] [Koepf98]_
.. [3] [Abramov71]_
.. [4] [Man93]_
)r&   r   NegativeInfinitymax)r   r   r   r   r   js         r%   
dispersionr,      s>    X 	a*T*T*A H FHr'   )N)
sympy.corer   sympy.polysr   r&   r,    r'   r%   <module>r0      s     zzRr'   