+
    ih                        R t ^ RIt^RIHtHtHtHtHt ^RIH	t	H
t
HtHtHtHtHtHtHtHtHtHtHtHtHtHtHtHtHtHtHtHtHtH t H!t!H"t"H#t#H$t$H%t%H&t&H't'H(t(H)t)H*t*H+t+H,t,H-t-H.t.H/t/H0t0H1t1H2t2H3t3H4t4H5t5H6t6H7t7H8t8H9t9 ^RI:H;t;H<t<H=t=H>t>H?t?H@t@HAtAHBtBHCtCHDtDHEtEHFtFHGtGHHtHHItIHJtJHKtKHLtLHMtMHNtNHOtOHPtPHQtQHRtR ] ]3tS]]3tT]!]3tU]"]3tV]#]$3tW]#]$]%3tXR tYR tZR t[R]3R	 lt\R
 t]]3R lt^R t_]3R lt`]3R lta^ ]3R ltb^ ]3R ltc]3R ltdR]3R lteR tf]3R ltg]3R lth]3R lti]3R ltj]3R ltk]3R ltl]3R ltm]3R ltn]3R lto]3R ltp]3R ltq]3R ltr]3R  lts]3R! ltt]3R" ltuR# tv]3R$ ltw]3R% ltx]3R& lty]3R' ltzR( t{]3R) lt|]3R* lt}]3R+ lt~]3R, lt]3R- lt]3R. lt]3R/ lt]3R0 lt]3R1 lt]3R2 lt]3R3 lt]3R4 lt]3R5 lt]3R6 lt]3R7 lt]! R84      t]! R94      tR: t]3R; lt]3R< lt]3R= lt]3R> lt]3R? lt]3R@ ltRGRA ltRGRB ltRGRC ltRGRD lt]RE8X  d(    ^ RIHu Hu Ht ]P                  t~]P                  tzR# R#   ]]3 d    ]! RF4        R# i ; i)Hz-
Low-level functions for complex arithmetic.
N)MPZMPZ_ZEROMPZ_ONEMPZ_TWOBACKEND)1round_floorround_ceiling
round_downround_upround_nearest
round_fastbitcountbctable	normalize
normalize1reciprocal_rndrshiftlshiftgiant_stepsnegative_rndto_strto_fixedfrom_man_exp
from_floatto_floatfrom_intto_intfzerofoneftwofhalffinffninffnanfnonempf_absmpf_posmpf_negmpf_addmpf_submpf_mulmpf_divmpf_mul_int	mpf_shiftmpf_sqrt	mpf_hypotmpf_rdiv_int	mpf_floormpf_ceilmpf_nintmpf_fracmpf_signmpf_hashComplexResult)mpf_pimpf_expmpf_logmpf_cos_sinmpf_cosh_sinhmpf_tanmpf_pow_intmpf_log_hypotmpf_cos_sin_pimpf_phimpf_cosmpf_sin
mpf_cos_pi
mpf_sin_pimpf_atan	mpf_atan2mpf_coshmpf_sinhmpf_tanhmpf_asinmpf_acos	mpf_acoshmpf_nthrootmpf_fibonaccic                B    V w  rV\         9   d   R# V\         9   d   R# R# )z2Check if either real or imaginary part is infiniteTF)_infszreims   &  s/Users/tonyclaw/.openclaw/workspace/skills/math-calculator/venv/lib/python3.14/site-packages/mpmath/libmp/libmpc.py
mpc_is_infrW   )   s    FB	U{4	U{4    c                B    V w  rV\         9   d   R# V\         9   d   R# R# )z9Check if either real or imaginary part is infinite or nanTF)	_infs_nanrR   s   &  rV   mpc_is_infnanr[   0   s    FB	Yt	YtrX   c                     V w  r4\        W14      pV^ ,          '       d,   VR,           \        \        V4      V3/ VB ,           R,           # VR,           \        WA3/ VB ,           R,           # )    z - jz + )r   r'   )rS   dpskwargsrT   rU   rss   &&,   rV   
mpc_to_strrb   7   s]    FB	B	!uuEzF72;>v>>DDEzF25f55;;rX   Fc                 J    V w  r4\        \        W1V4      \        WAV4      4      # N)complexr   )rS   strictrndrT   rU   s   &&&  rV   mpc_to_complexrh   ?   s$    FB8B,hr3.GHHrX   c                 t   \         P                  R8  dr   V w  r\        V4      \         P                  P                  \        V4      ,          ,           pV^\         P                  P
                  ,          ,          p\        V4      #  \        \        V RR7      4      #   \         d    \        T 4      u # i ; i)   T)rf   )rj      )
sysversion_infor6   	hash_infoimagwidthinthashrh   OverflowError)rS   rT   rU   hs   &   rV   mpc_hashru   C   s    
6!RL3==--<<CMM'''(1v	q677 	7N	s   B B76B7c                 &    V w  r4V\        WAV4      3# rd   r'   rS   precrg   rT   rU   s   &&&  rV   mpc_conjugaterz   P   s    FBwr%%%rX   c                     V \         8g  # rd   )mpc_zero)rS   s   &rV   mpc_is_nonzeror}   T   s    =rX   c                 B    V w  rEVw  rg\        WFW#4      \        WWW#4      3# rd   r(   rS   wry   rg   abcds   &&&&    rV   mpc_addr   W   )    DADA1#WQ4%===rX   c                 &    V w  rE\        WAW#4      V3# rd   r   )rS   xry   rg   r   r   s   &&&&  rV   mpc_add_mpfr   \       DA1#Q&&rX   c                 B    V w  rEVw  rg\        WFW#4      \        WWW#4      3# rd   r)   r   s   &&&&    rV   mpc_subr   `   r   rX   c                 &    V w  rE\        WAW#4      V3# rd   r   )rS   pry   rg   r   r   s   &&&&  rV   mpc_sub_mpfr   e   r   rX   c                 :    V w  r4\        W1V4      \        WAV4      3# rd   )r&   rS   ry   rg   r   r   s   &&&  rV   mpc_posr   i   "    DA1C '!3"777rX   c                 :    V w  r4\        W1V4      \        WAV4      3# rd   rw   r   s   &&&  rV   mpc_negr   m   r   rX   c                 6    V w  r#\        W!4      \        W14      3# rd   )r-   )rS   nr   r   s   &&  rV   	mpc_shiftr   q   s    DAQ?IaO++rX   c                "    V w  r4\        W4W4      # )zAAbsolute value of a complex number, |a+bi|.
Returns an mpf value.)r/   r   s   &&&  rV   mpc_absr   u   s     DAQ4%%rX   c                "    V w  r4\        WCW4      # )z3Argument of a complex number. Returns an mpf value.)rG   r   s   &&&  rV   mpc_argr   {   s    DAQ4%%rX   c                 :    V w  r4\        W1V4      \        WAV4      3# rd   )r1   r   s   &&&  rV   	mpc_floorr      s"    DAQc"Ias$;;;rX   c                 :    V w  r4\        W1V4      \        WAV4      3# rd   )r2   r   s   &&&  rV   mpc_ceilr      "    DAAS!8AS#999rX   c                 :    V w  r4\        W1V4      \        WAV4      3# rd   )r3   r   s   &&&  rV   mpc_nintr      r   rX   c                 :    V w  r4\        W1V4      \        WAV4      3# rd   )r4   r   s   &&&  rV   mpc_fracr      r   rX   c                    V w  rEVw  rg\        WF4      p\        WW4      p	\        WG4      p
\        WV4      p\        WW#4      p\        WW#4      pW3# )z
Complex multiplication.

Returns the real and imaginary part of (a+bi)*(c+di), rounded to
the specified precision. The rounding mode applies to the real and
imaginary parts separately.
)r*   r)   r(   )rS   r   ry   rg   r   r   r   r   r   qrsrT   rU   s   &&&&          rV   mpc_mulr      sU     DADAAAAA	t	!B	t	!B6MrX   c                     V w  r4\        W34      p\        WD4      p\        W4W4      p\        WVW4      p\        V^4      p	W3#    )r*   r)   r-   )
rS   ry   rg   r   r   r   r   r   rT   rU   s
   &&&       rV   
mpc_squarer      sE    DAAATA	t	!B	1aB6MrX   c                 @    V w  rE\        WAW#4      p\        WQW#4      pWg3# rd   )r*   rS   r   ry   rg   r   r   rT   rU   s   &&&&    rV   mpc_mul_mpfr      s(    DA	t	!B	t	!B6MrX   c                R    V w  rE\        \        WQW#4      4      p\        WAW#4      pWg3# )z:
Multiply the mpc value z by I*x where x is an mpf value.
)r'   r*   )rS   r   ry   rg   r   r   rT   rU   s   &&&&    rV   mpc_mul_imag_mpfr      s/     DA	t)	*B	t	!B6MrX   c                 @    V w  rE\        WAW#4      p\        WQW#4      pWg3# rd   )r,   )rS   r   ry   rg   r   r   rT   rU   s   &&&&    rV   mpc_mul_intr      s(    DA	Q4	%B	Q4	%B6MrX   c                    V w  rEVw  rgV^
,           p\        \        Wf4      \        Ww4      V4      p	\        \        WF4      \        WW4      V4      p
\        \        WV4      \        WG4      V4      p\        WW#4      \        WW#4      3# 
   )r(   r*   r)   r+   )rS   r   ry   rg   r   r   r   r   wpmagtus   &&&&        rV   mpc_divr      st    DADA	B
'!-
3CgalB/AgalB/A1"GA$$;;;rX   c                @    V w  rE\        WAW#4      p\        WQW#4      pWg3# )zCalculate z/p where p is real)r+   r   s   &&&&    rV   mpc_div_mpfr      s(    DA	t	!B	t	!B6MrX   c                    V w  r4\        \        W34      \        WD4      V^
,           4      p\        W5W4      p\        \        WEW4      4      pWg3# )zCalculate 1/z efficientlyr(   r*   r+   r'   )rS   ry   rg   r   r   mrT   rU   s   &&&     rV   mpc_reciprocalr      sG    DAWQ\$r'2A	t	!B	t)	*B6MrX   c                    Vw  rE\        \        WD4      \        WU4      V^
,           4      p\        \        W@4      WbV4      p\        \        \        WP4      4      WbV4      pWx3# )z)Calculate p/z where p is real efficientlyr   )	r   rS   ry   rg   r   r   r   rT   rU   s	   &&&&     rV   mpc_mpf_divr      sS    DAWQ\473A	q	,B	&	5B6MrX   c                    ^p^ pV'       dq   V^,          '       d3   W0,          WA,          ,
          W@,          W1,          ,           rCV^,          pW ,          W,          ,
          ^V ,          V,          rV^,          pKx  W43# )zcComplex integer power: computes (a+b*I)**n exactly for
nonnegative n (a and b must be Python ints). )r   r   r   wrewims   &&&  rV   complex_int_powr      sa     C
C
q55usu}cecemFAsQSy!A#a%1	a8OrX   c           	          V^,          \         8X  d   \        W^ ,          W#4      # \        \        \	        W^
,           4      W^
,           4      W#4      # r   )r   mpc_pow_mpfmpc_expr   mpc_log)rS   r   ry   rg   s   &&&&rV   mpc_powr      s?    tu}1dD..7712g.7;TGGrX   c           	         Vw  rErgV^ 8  d"   \        V RV,          WV,          ,          W#4      # VR8X  d.   \        W^
,           4      p\        VRV,          V,          W#4      # \        \        \	        W^
,           4      W^
,           4      W#4      # )r]   )mpc_pow_intmpc_sqrtr   r   r   )	rS   r   ry   rg   psignpmanpexppbcsqrtzs	   &&&&     rV   r   r      s{    Eqy1rEkTZ8$DDrzG$52+"4d@@;wqr'2ABw?KKrX   c           	         V w  rEV\         8X  d   \        WAW#4      \         3# V\         8X  dd   \        WQW#4      pV^,          pV^ 8X  d	   V\         3# V^8X  d	   \         V3# V^8X  d   \        V4      \         3# V^8X  d   \         \        V4      3# V^ 8X  d   \        # V^8X  d   \	        WV4      # V^8X  d   \        WV4      # VR8X  d   \        WV4      # V^ 8  d   \        \        W) V^,           4      W#4      # Vw  rxrVw  rrV'       d   V) pV'       d   V) pW,
          p\        V4      pVV\        W4      ,           ,          pVR8  di   V^ 8  d   W,          pTp	MW) ,          pT	p\        WV4      w  pp\        V\        W,          4      W#4      p\        V\        W,          4      W#4      pVV3# \        \        \        W^
,           4      W^
,           4      W#4      # )   i'  r   )r   r>   r'   mpc_oner   r   r   r   absmaxr   r   rq   r   r   r   )rS   r   ry   rg   r   r   vasignamanaexpabcbsignbmanbexpbbcdeabs_de
exact_sizerT   rU   s   &&&&                rV   r   r      s   DAEz1+U22Ezd(	Q6e8O!V!8O!V1:u$$!V'!*$$Avg~Avgas++Avj#..Bw~as331u^K2tAv$>JJEEdUddUd	BWFFS]*+JE6KDDcNDD Q/B"c!&k45"c!&k452v;wqr'2ABw?KKrX   c                   V w  r4V\         8X  dO   V\         8X  d   W43# V^ ,          '       d   \        \        V4      W4      p\         V3# \        W1V4      pV\         3# V^,           pV^ ,          '       gV   \        \	        W43V4      W74      p\        VR4      p	\        WV4      p\        V^4      p
\        W4      p\        WKW4      pWe3# \        \	        W43V4      W74      p\        VR4      p	\        WV4      p\        V^4      p
\        W4      p\        WKW4      pV^ ,          '       d   \        V4      p\        V4      pWe3# )zComplex square root (principal branch).

We have sqrt(a+bi) = sqrt((r+a)/2) + b/sqrt(2*(r+a))*i where
r = abs(a+bi), when a+bi is not a negative real number.r   )r   r.   r'   r(   r   r-   r+   r)   )rS   ry   rg   r   r   rU   rT   r   r   r   r   r   s   &&&         rV   r   r   '  s2   
 DAEz:6MQ44'!*d0B2;!3'B;	bBQ44WaVR(!0aas#aOa_Q4% 6M GQFB'/aas#aOa_Q4%Q44BB6MrX   c                 8   ^2p\        \        WW$,          ,
          4      4      p\        \        WW$,          ,
          4      4      p VRV,          ,           RV,          ,          pVP                  pVP                  p	\	        \        V4      4      p\	        \        V	4      4      p	^
pTpTp\        WCV,           4       EFm  p\        WV^,
          4      w  pp\        VV^,
          V,          V,
          V,
          4      p\        VV^,
          V,          V,
          V,
          4      pVV,          VV,          ,           W,           ,	          p\        WV,
          4      p\        WV,
          4      pVV,          VV,          ,           V,	          pV) V,          VV,          ,           V,	          pVV,          V,          pVV,          V,          pVV^,
          \        WV,
          4      ,          ,           V,          pVV^,
          \        WV,
          4      ,          ,           V,          p	TpEKp  	  W3#   \
         d^    \        YT4      p\        Yd4      p\        T4      p
\        ^Y4      p\        YV3T\        3T4      w  r\        T4      p\        T	4      p	 ELi ; i)2   y              ?g      ?)rq   r   realro   r   rs   r   r0   r   r   r   r   r   r   )r   r   r   ry   starta1b1r   rT   rU   fnnthextraprevpextra1r   re2im2r4apbprecimcrebimbs   &&&&                     rV   mpc_nthroot_fixedr  K  s   E	VAag~&	'B	VAag~&	'B"r'\SU#VVVVR\R\ EEFU
+"21Q3/SS1Q3+/F23S1Q3+/F23#gCQZ0Aax Aax Cx"s("q(sSy28#)axBaxBQqS&uW---1QqS&uW---1 , 6M5  b b a[1b("C<7BZBZs   AH1 1A$JJc                   V w  rEV^ ,          ^ 8X  d    V\         8X  d   \        WAW#4      pV\         3# V^8  dn   V^ 8X  d   \        # V^8X  d   \        WE3W#4      # VR8X  d   \	        \        WE3W#4      # \        WE3V) V^,           \        V,          4      p\	        \        WrV4      # V^8:  d   \        RV^
,           ,          4      pVw  rrVw  rpp\        WE3V4      pVR,          VR,          ,           R8  dr   VR,          VR,          ,           V8  dV   \        WH4      p\        WX4      p\        VVW4      w  pp^
p\        Wh) V,
          W4      p\        VV) V,
          W4      pVV3# \        V4      pV^
,           ^
,           p\        ^VV4      p\        WE3V\         3W4      w  pp\        V^ ,          V^,          V^,          V^,          W#4      p\        V^ ,          V^,          V^,          V^,          W#4      pVV3# )ze
Complex n-th root.

Use Newton method as in the real case when it is faster,
otherwise use z**(1/n)
g333333?r   i)r   rN   r   r   r   mpc_nthrootr   rq   r   r   r  r   r   r0   r   r   )rS   r   ry   rg   r   r   rT   inverseprec2r   r   r   r   r   r   r   r   pfafbfrU   r   r   r   s   &&&&                    rV   r  r  r  s    DAtqyQ%Zt)E{1u6N6A64--77QFD66qfqb$q&.2EFws33BwC4"9%&!"T!"T3aUD!b6BrF?S bfr"vo&<!#B!#B&r2q8FBEb&,;Bb5&,;Br6M	!BGbLE
q"e
$CaVc5\56FB	2a5"Q%A1t	9B	2a5"Q%A1t	9Br6MrX   c                    \        V ^W4      # )z
Complex cubic root.
)r  rS   ry   rg   s   &&&rV   mpc_cbrtr    s     q!T''rX   c                    V w  r4V\         8X  d   \        WAV4      # V\         8X  d   \        W1V4      \         3# \        W1^,           V4      p\        WA^,           V4      w  rg\        WVW4      p\        WWW4      p	W3# )aJ  
Complex exponential function.

We use the direct formula exp(a+bi) = exp(a) * (cos(b) + sin(b)*i)
for the computation. This formula is very nice because it is
pefectly stable; since we just do real multiplications, the only
numerical errors that can creep in are single-ulp rounding errors.

The formula is efficient since mpmath's real exp is quite fast and
since we can compute cos and sin simultaneously.

It is no problem if a and b are large; if the implementations of
exp/cos/sin are accurate and efficient for all real numbers, then
so is this function for all complex numbers.
)r   r;   r9   r*   )
rS   ry   rg   r   r   r   r   r   rT   rU   s
   &&&       rV   r   r     sy      DAEz1C((Ezq$e++
!!VS
!Cqq&#&DA		#B		#B6MrX   c                 V    \        V ^ ,          V ^,          W4      p\        WV4      pW43# r]   )r?   r   rx   s   &&&  rV   r   r     s+    	qtQqT4	-B	#	B6MrX   c                   V w  r4V\         8X  d   \        W1V4      \         3# V\         8X  d   \        WAV4      \         3# V^,           p\        W54      w  rg\	        WE4      w  r\        WhW4      p
\        WyW4      pV
\        V4      3# )a?  Complex cosine. The formula used is cos(a+bi) = cos(a)*cosh(b) -
sin(a)*sinh(b)*i.

The same comments apply as for the complex exp: only real
multiplications are pewrormed, so no cancellation errors are
possible. The formula is also efficient since we can compute both
pairs (cos, sin) and (cosh, sinh) in single stwps.)r   rB   rH   r;   r<   r*   r'   rS   ry   rg   r   r   r   r   r   chshrT   rU   s   &&&         rV   mpc_cosr    s     DAEzq$e++Ez%u,,	BqDA1!FB		"B		"Bwr{?rX   c                    V w  r4V\         8X  d   \        W1V4      \         3# V\         8X  d   \         \        WAV4      3# V^,           p\        W54      w  rg\	        WE4      w  r\        WxW4      p
\        WiW4      pW3# )z{Complex sine. We have sin(a+bi) = sin(a)*cosh(b) +
cos(a)*sinh(b)*i. See the docstring for mpc_cos for additional
comments.)r   rC   rI   r;   r<   r*   r  s   &&&         rV   mpc_sinr    s}     DAEzq$e++Ezhq,,,	BqDA1!FB		"B		"B6MrX   c                `   V w  r4Vw  rVrxVw  rrV\         8X  d   \        W1V4      \         3# V\         8X  d   \         \        WAV4      3# V^,           p\        V^4      p\        V^4      p\	        W=4      w  r\        WM4      w  pp\        VVV4      p\        VVW4      p\        VVW4      pVV3# )z_Complex tangent. Computed as tan(a+bi) = sin(2a)/M + sinh(2b)/M*i
where M = cos(2a) + cosh(2b).)r   r=   rJ   r-   r;   r<   r(   r+   )rS   ry   rg   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r   rT   rU   s   &&&                  rV   mpc_tanr    s     DAEEEz'!3/66Ez%!3!777	B!QA!QAqDA1!FB
!R
C	C	#B	S$	$Br6MrX   c                 V   V w  r4V\         8X  d   \        W1V4      \         3# \        V\        V^,           4      V^,           4      pV\         8X  d   \	        WAV4      \         3# V^,           p\        W54      w  rg\        WE4      w  r\        WhW4      p
\        WyW4      pV
\        V4      3#    )r   rD   r*   r8   rH   r@   r<   r'   r  s   &&&         rV   
mpc_cos_pir    s    DAEz!3'..6$q&>46*AEz%u,,	B! DA1!FB		"B		"Bwr{?rX   c                 B   V w  r4V\         8X  d   \        W1V4      \         3# \        V\        V^,           4      V^,           4      pV\         8X  d   \         \	        WAV4      3# V^,           p\        W54      w  rg\        WE4      w  r\        WxW4      p
\        WiW4      pW3# r  )r   rE   r*   r8   rI   r@   r<   r  s   &&&         rV   
mpc_sin_pir    s    DAEz!3'..6$q&>46*AEzhq,,,	B! DA1!FB		"B		"B6MrX   c                 t   V w  r4V\         8X  d   \        WAV4      w  rVV\         3\         V33# V\         8X  d   \        W1V4      w  rxV\         3V\         33# V^,           p	\        W94      w  rx\        WI4      w  rV\        WuW4      p
\        WW4      p\        WW4      p\        WvW4      pV
\	        V4      3W33# )   )r   r<   r;   r*   r'   )rS   ry   rg   r   r   r  r  r   r   r   crecimsresims   &&&           rV   mpc_cos_sinr%    s    DAEzq,E{UBK''Ez1C(5zAu:%%	BqDA1!FB
!
#C
!
#C
!
#C
!
#C
**rX   c                    V w  r4V\         8X  d   \        W1V4      w  rVV\         3V\         33# \        V\        V^,           4      V^,           4      pV\         8X  d   \	        WAV4      w  rxV\         3\         V33# V^,           p	\        W94      w  rV\	        WI4      w  rx\        WWW4      p
\        WhW4      p\        WgW4      p\        WXW4      pV
\        V4      3W33# r  )r   r@   r*   r8   r<   r'   )rS   ry   rg   r   r   r   r   r  r  r   r!  r"  r#  r$  s   &&&           rV   mpc_cos_sin_pir'  %  s    DAEzas+5zAu:%%6$q&>46*AEzq,E{UBK''	B! DA1!FB
!
#C
!
#C
!
#C
!
#C
**rX   c                8    V w  r4\        V\        V4      3W4      # )z:Complex hyperbolic cosine. Computed as cosh(z) = cos(z*i).)r  r'   r   s   &&&  rV   mpc_coshr)  7  s    DAAwqz?D..rX   c                .    V w  r4\        WC3W4      w  rCW43# )z;Complex hyperbolic sine. Computed as sinh(z) = -i*sin(z*i).)r  r   s   &&&  rV   mpc_sinhr+  <       DAA64%DA4KrX   c                .    V w  r4\        WC3W4      w  rCW43# )z>Complex hyperbolic tangent. Computed as tanh(z) = -i*tan(z*i).)r  r   s   &&&  rV   mpc_tanhr.  B  r,  rX   c                 h   V w  r4V^,           p\        \        WE4      \        V4      3p\        \        WE4      V3p\	        We4      p\	        Wu4      p	\        WW4      w  r4\        \        VR4      4      \        VR4      3p
V
^,          \        8X  d!   \        V 4      '       d   V
^ ,          \        3p
V
#    r   )
r(   r   r'   r)   r   r   r-   r#   rW   r   )rS   ry   rg   r   r   r   r   yl1l2r   s   &&&        rV   mpc_atanr5  I  s    DA 
Bagaj(AaaA	B	B24%DA	!B )Ab/1A 	tt|
1qT5MHrX   g:pΈ?g      ?c                
   V w  rEV^
,           pV\         8X  d   \        \        \        V4      V4      pV^ ,          '       g,   V^ 8X  d   \	        WAV4      \         3# \        WAV4      \         3# V^ ,          '       dL   \        W4      p\        \        V4      W4      p	V^ 8X  d   V\        V	4      3# \        \        VR4      4      V	3# \        WAV4      p	V^ 8X  d	   \         V	3# \        W4      p\        VR4      \        V	4      3# ^ ;rV^ ,          '       d   \        V4      p^p
V^ ,          '       d   \        V4      p^p\        \        WF4      p\        \        WF4      p\        WV4      p\        WuV4      p\        \        WV4      R4      p\        WOV4      p\        WUV4      p\        \        VV4      ^ ,          '       g$   V^ 8X  d   \	        VV4      pEMI\        VV4      pEM;\        WV4      pV^ ,          '       g   \        V\        WV4      V4      p	\        WV4      p\        \        V\        V	VV4      V4      R4      pV^ 8X  d"   \        \        \!        VV4      WF4      V4      pM\        \        V\!        VV4      V4      V4      pM\        V\        WV4      V4      p	\        V\        WV4      V4      p\        \        V	VV4      R4      p\        V\!        VV4      V4      pV^ 8X  d   \        \        VWF4      V4      pM\        \        VVV4      V4      p\        \"        W4      ^ ,          '       g   \        V\        WV4      V4      p\        V4      ^ ,          '       d2   \        WV4      p\        VVV4      p\        \        VVV4      R4      pM#\        WV4      p\        \        VVV4      R4      p\        V\        V\        V4      V4      p\%        \        \        \        V\!        VV4      V4      V4      V4      pM<\!        \        \        WV4      \        V4      V4      p\%        \        VVV4      V4      pV
'       d*   V^ 8X  d   \        \        V4      VV4      pM\        V4      pV'       g   V^ 8X  d   \        V4      pV'       d   V^8X  d   \        V4      p\'        V^ ,          V^,          V^,          V^,          W4      p\'        V^ ,          V^,          V^,          V^,          W4      pVV3# )a  complex acos for n = 0, asin for n = 1
The algorithm is described in
T.E. Hull, T.F. Fairgrieve and P.T.P. Tang
'Implementing the Complex Arcsine and Arcosine Functions
using Exception Handling',
ACM Trans. on Math. Software Vol. 23 (1997), p299
The complex acos and asin can be defined as
acos(z) = acos(beta) - I*sign(a)* log(alpha + sqrt(alpha**2 -1))
asin(z) = asin(beta) + I*sign(a)* log(alpha + sqrt(alpha**2 -1))
where z = a + I*b
alpha = (1/2)*(r + s); beta = (1/2)*(r - s) = a/alpha
r = sqrt((a+1)**2 + y**2); s = sqrt((a-1)**2 + y**2)
These expressions are rewritten in different ways in different
regions, delimited by two crossovers alpha_crossover and beta_crossover,
and by abs(a) <= 1, in order to improve the numerical accuracy.
r   )r   r)   r   r%   rL   rK   r8   rM   r'   r-   r(   r/   r+   r*   beta_crossoverrF   r.   alpha_crossoverr:   r   )rS   ry   rg   r   r   r   r   ampir   r   r   r   r   r   alphabetab2rT   Axr   c1c2Am1rU   s   &&&&                     rV   	acos_asinrB  _  s[   " DA	BEzT71:r*!uuAv-u44-u44 ttD&gaj$46wqz>)"9R#45q88 as+6 !8O*B$R,gaj88EttAJttAJ	q	B	q	B"A"AgaB',E1R D	b	B>4,Q//6$#B$#B Ur"!uu
 GA2.3Ar"A72wq!R'8"=rBBAvghr2&6>Cga"b)92>C GA2.3AGA2.3A71a,b1BHR,b1BAvgb!0"5gaR0"5
 ?E.q11R+R02;q>>#BR$BGBB/4C #BGBB/4CS'%r2B7WT73R0@"#ErJBO ggeB7rBBGWUB+R06R,BBQ!VR[aR[	2a5"Q%A1t	9B	2a5"Q%A1t	9Br6MrX   c                     \        WV^ 4      # r  rB  r  s   &&&rV   mpc_acosrE        Qc1%%rX   c                     \        WV^4      # r   rD  r  s   &&&rV   mpc_asinrH    rF  rX   c                 V    V w  r4\        V\        V4      3W4      w  r4\        V4      V3# rd   )rH  r'   r   s   &&&  rV   	mpc_asinhrJ    s-    DAa_d0DA1:q=rX   c                     \        WV4      w  r4V^ ,          '       g   V\        8X  d   \        V4      V3# V\        V4      3# r  )rE  r   r'   r   s   &&&  rV   	mpc_acoshrL    s=     AS!DAttqEzqz1}'!*}rX   c                    V^,           p\        V \        V4      p\        \        W4      p\        WC4      p\        WS4      p\	        \        WEV4      R4      pV^ ,          \
        8X  d!   \        V 4      '       d   \        V^,          3pV# r0  )r   r   r   r   r   r#   rW   r   )rS   ry   rg   r   r   r   r   s   &&&    rV   	mpc_atanhrN    sq    	B7BAAAA'!#R(A 	tt|
1AaDMHrX   c                    V w  r4V\         8X  d   \        W1V4      \         3# \        \        V^,          V^,          ,           4      \        V^,          V^,          ,           4      4      pW,           ^,           p\	        V4      p\        \        V^4      \        V4      p\        V\         3W4      p	\        W4      p
\        WV4      p
\        WV4      p	\        WW4      p	V	# )rk   )r   rO   r   r   rA   r(   r-   r$   r   r  r   r   r   )rS   ry   rg   rT   rU   sizer   r   r   r   r   s   &&&        rV   mpc_fibonaccirQ  
  s    FB	U{b,e44s2a5A;RU2a5[!12D	r	BA	!Q+AE
A"A1AbAbAA$$AHrX   c                     \         hrd   r7   r   ry   rg   s   &&&rV   mpf_expjrU        
rX   c                    V w  r4V\         8X  d   \        W1V4      # V\         8X  d   \        \        V4      W4      \         3# \        \        V4      V^
,           4      p\        W1^
,           4      w  rg\	        WVW4      p\	        WWW4      pW43# r   )r   r;   r9   r'   r*   )rS   ry   rg   rT   rU   eyr   r   s   &&&     rV   mpc_expjrY    s}    FB	U{2S))	U{wr{D.55	d2g	&Br7#DA		"B		"B6MrX   c                     \         hrd   rS  rT  s   &&&rV   
mpf_expjpir[  (  rV  rX   c                    V w  r4V\         8X  d   \        W1V4      # Vw  rVrxV^
,           p	V'       d   V	\        ^ Wx,           4      ,          p	\        \	        \        V	4      WI4      4      pV\         8X  d   \        WAV4      \         3# \        WA^
,           4      p
\        W1^
,           4      w  r\	        WW4      p\	        WW4      pW43# r   )r   r@   r   r'   r*   r8   r9   )rS   ry   rg   rT   rU   signmanexpbcr   rX  r   r   s   &&&          rV   
mpc_expjpira  +  s    FB	U{b,,Ds	bB

c!SVn	R,	-B	U{r%u,,	"W	B"2g&DA		"B		"B6MrX   sagez&Warning: Sage imports in libmpc failed)f)__doc__rl   backendr   r   r   r   r   libmpfr   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r    r!   r"   r#   r$   r%   r&   r'   r(   r)   r*   r+   r,   r-   r.   r/   r0   r1   r2   r3   r4   r5   r6   r7   	libelefunr8   r9   r:   r;   r<   r=   r>   r?   r@   rA   rB   rC   rD   rE   rF   rG   rH   rI   rJ   rK   rL   rM   rN   rO   r   r|   mpc_twompc_halfrQ   rZ   rW   r[   rb   rh   ru   rz   r}   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r  r   r   r  r  r  r  r  r%  r'  r)  r+  r.  r5  r7  r8  rB  rE  rH  rJ  rL  rN  rQ  rU  rY  r[  ra  sage.libs.mpmath.ext_libmplibsmpmath	ext_libmp_lbmpImportErrorAttributeErrorprintr   rX   rV   <module>rr     sG    = =                   +%<
+5>	u5$	< #
 I  * & ' >
 !+ ' j >
 * ' $ 8 j 8, $ & $ &
 & < % : % : % :
 ' $ '  !+  &0  !+  ' 	< !+  !+  !+  ' H
 !+ L !+ &LP % "H%N !+ 'R % ( $ 6 $ 
 $ ( $   $ & '  '  ( +" !+ +$ % /
 %  %  % & F#S/FP % & % & &  &  &   * 
$ f822-->>	 
 ( 8678s   3$I I0/I0