
    [hk                     2    S SK 7  S SK7  S SKrS rS rS rg)    )*Nc                  j   S[         l        [        S5      S-  S:X  d   e[        S5      S-  S:X  d   e[        S5      S-  S	:X  d   e[        S5      S
-  S:X  d   e[        S5      S-  R                  S5      (       d   e[        S5      S-  R                  S5      (       d   e[        S5      S-  R                  S5      (       d   e[        S5      S
-  R                  S5      (       d   e[        S5      S-  R                  S5      (       d   e[        S5      S-  R                  S5      (       d   eg )N      g      @i   @   g      ?   g      g      ?g      g      P?
   gR[:XL	@gXs@gIHb=?g3i?g333333?g[-?g333333ӿgRB3Ϲ	?)mpdpsmpfae     O/var/www/auris/envauris/lib/python3.13/site-packages/mpmath/tests/test_power.pytest_fractional_powr      s!   BFr7c>T!!!r7c>Qr7d?e###r7d?l***GsN12222GsN01111GtO 34444GtO 56666GsN12222GtO 34444r   c            
         [         R                  " S5        S H  n [        S5       H  n[         R                  " SU S-
  -  SU -  5      n[         R                  " SS5      nX#-  n[	        [        [        U5      [        U5      U [        5      5      U:  d   e[	        [        [        U5      [        U5      U [        5      5      U:  a  M   e   M     g)zF
Test that inexact integer powers are rounded in the right
direction.
i  )r	   5      2         d   N)	randomseedrangerandintto_intmpf_powfrom_int
round_downround_up)preciababs        r   test_pow_integer_directionr'      s    
 KKrAq46{AtG4Aq#&AB'(1+x{D*MNQSSSS'(1+x{D(KLrQQQ  r   c                  	   S n S GHv  u  pU[         l        [        S5      [        S5      U* S-   -  -   n[        S5      [        S5      U* S-   -  -
  nU* nU* nU[         l        [        nU " USU5      S:  d   eU " USU5      S:X  d   eU " USU5      S:  d   eU " USU5      S:X  d   eU " USU5      S:  d   eU " USU5      S:X  d   eU " USU5      S:  d   eU " USU5      S:X  d   eU " USU5      S:X  d   eU " USU5      S:  d   eU " USU5      S:X  d   eU " USU5      S:  d   eU " US	U5      S:X  d   eU " US	U5      S:  d   eU " US	U5      S:X  d   eU " US	U5      S:  d   e[        nU " USU5      S:X  d   eU " USU5      S:  d   eU " USU5      S:X  d   eU " USU5      S:  d   eU " USU5      S:X  d   eU " USU5      S:  d   eU " USU5      S:X  d   eU " USU5      S:  d   eU " USU5      S:  d   eU " USU5      S:X  d   eU " USU5      S:  d   eU " USU5      S:X  d   eU " US	U5      S:  d   eU " US	U5      S:X  d   eU " US	U5      S:  d   eU " US	U5      S:X  d   e[
        nU " USU5      S:  d   eU " USU5      S:X  d   eU " USU5      S:X  d   eU " USU5      S:  d   eU " USU5      S:  d   eU " USU5      S:X  d   eU " USU5      S:  d   eU " USU5      S:X  d   eU " USU5      S:X  d   eU " USU5      S:  d   eU " USU5      S:  d   eU " USU5      S:X  d   eU " US	U5      S:X  d   eU " US	U5      S:  d   eU " US	U5      S:X  d   eU " US	U5      S:  d   e[        nU " USU5      S:X  d   eU " USU5      S:  d   eU " USU5      S:  d   eU " USU5      S:X  d   eU " USU5      S:X  d   eU " USU5      S:  d   eU " USU5      S:X  d   eU " USU5      S:  d   eU " USU5      S:  d   eU " USU5      S:X  d   eU " USU5      S:X  d   eU " USU5      S:  d   eU " US	U5      S:  d   eU " US	U5      S:X  d   eU " US	U5      S:  d   eU " US	U5      S:X  a  GMw   e   S
[         l        g)aQ  
Stress test directed rounding for powers with integer exponents.
Basically, we look at the following cases:

>>> 1.0001 ** -5 # doctest: +SKIP
0.99950014996500702
>>> 0.9999 ** -5 # doctest: +SKIP
1.000500150035007
>>> (-1.0001) ** -5 # doctest: +SKIP
-0.99950014996500702
>>> (-0.9999) ** -5 # doctest: +SKIP
-1.000500150035007

>>> 1.0001 ** -6 # doctest: +SKIP
0.99940020994401269
>>> 0.9999 ** -6 # doctest: +SKIP
1.0006002100560125
>>> (-1.0001) ** -6 # doctest: +SKIP
0.99940020994401269
>>> (-0.9999) ** -6 # doctest: +SKIP
1.0006002100560125

etc.

We run the tests with values a very small epsilon away from 1:
small enough that the result is indistinguishable from 1 when
rounded to nearest at the output precision. We check that the
result is not erroneously rounded to 1 in cases where the
rounding should be done strictly away from 1.
c                 `    [        [        U R                  U[        R                  U5      5      $ )N)make_mpfmpf_pow_int_mpf_r
   r"   )xnrs      r   powr'test_pow_epsilon_rounding.<locals>.powrC   s     AGGQ;<<r   ))r      )i  i  r   r         ir   N)r
   r"   r   r!   r    round_ceilinground_floorr   )r0   inprecoutprecpos10001pos09999neg10001neg09999r/   s           r   test_pow_epsilon_roundingr?   #   sL   @= 7q6CFfWQY//q6CFfWQY//99Ha#a'''Ha#q(((Ha#b(((Ha#r)))Ha#a'''Ha#q(((Ha#a'''Ha#q(((Hb!$)))Hb!$q(((Hb!$***Hb!$r)))Hb!$)))Hb!$q(((Hb!$)))Hb!$q(((Ha#q(((Ha#a'''Ha#r)))Ha#b(((Ha#q(((Ha#a'''Ha#q(((Ha#a'''Hb!$q(((Hb!$)))Hb!$r)))Hb!$***Hb!$q(((Hb!$)))Hb!$q(((Hb!$)))Ha#a'''Ha#q(((Ha#r)))Ha#b(((Ha#a'''Ha#q(((Ha#a'''Ha#q(((Hb!$)))Hb!$q(((Hb!$r)))Hb!$***Hb!$)))Hb!$q(((Hb!$)))Hb!$q(((Ha#q(((Ha#a'''Ha#b(((Ha#r)))Ha#q(((Ha#a'''Ha#q(((Ha#a'''Hb!$q(((Hb!$)))Hb!$***Hb!$r)))Hb!$q(((Hb!$)))Hb!$q(((Hb!$)))i 7l BFr   )mpmathmpmath.libmpr   r   r'   r?   r   r   r   <module>rB      s      5R yr   