
    sg3                        d dl mZmZmZmZmZmZmZmZm	Z	m
Z
mZmZmZmZmZ d dl mZmZmZmZmZmZ d dlmZmZmZmZmZmZmZmZ d dlm Z  d dl!m"Z" d dl#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z) d dl*m+Z+ d dl,m-Z-  ed	      \  Z.Z/Z0d
 Z1d Z2d Z3d Z4d Z5d Z6d Z7d Z8d Z9d Z:d Z;d Z<d Z=d Z>d Z?d Z@d ZAd ZBd ZCd ZDd ZEd ZFd  ZGd! ZHd" ZId# ZJd$ ZKd% ZLd& ZMd' ZNd( ZOd) ZPd* ZQd+ ZRd, ZSy-).    )SpioosymbolsFunctionRationalIntegerTupleSymbolEqNeLeLtGtGe)
EulerGammaGoldenRatioCatalanLambdaMulPow)	Piecewisesqrtceilingexpsincossinclucas)raises)implemented_function)eyeMatrixMatrixSymbolIdentityHadamardProductSparseMatrix)besseli
maple_codezx,y,zc                  h    t        t        d            dk(  sJ t        t        d            dk(  sJ y )NC   67z-1)r*   r	        R/var/www/html/venv/lib/python3.12/site-packages/sympy/printing/tests/test_maple.pytest_Integerr2      s0    gbk"d***gbk"d***r0   c                  X   t        t        dd            dk(  sJ t        t        dd            dk(  sJ t        t        dd            dk(  sJ t        t        d	d            dk(  sJ t        t        t        dd      z         d
k(  sJ t        t        dd      t        z        dk(  sJ y )N      z3/7   	   2iz-3/7zx + 3/7z(3/7)*x)r*   r   xr/   r0   r1   test_Rationalr;      s    hq!n%...hr1o&#---hq"o&&000hr2&'5000a(1a.()Y666hq!nq()Y666r0   c                     t        t        t        t                    dk(  sJ t        t	        t        t                    dk(  sJ t        t        t        t                    dk(  sJ t        t        t        t                    dk(  sJ t        t        t        t                    dk(  sJ t        t        t        t                    dk(  sJ y )Nzx = yzx <> yzx <= yzx < yzx > yzx >= y)	r*   r   r:   yr   r   r   r   r   r/   r0   r1   test_Relationalr>      s    bAh7***bAh8+++bAh8+++bAh7***bAh7***bAh8+++r0   c                      t        t        t              t        t              z        dk(  sJ t        t	        t                    dk(  sJ t        t        t                    dk(  sJ y )Nzsin(x)^cos(x)zabs(x)zceil(x))r*   r   r:   r   absr   r/   r0   r1   test_FunctionrA   '   sP    c!fA&'?:::c!f)))gaj!Y...r0   c                  <   t        t        dz        dk(  sJ t        t        t        dz  z        dk(  sJ t        t        dz  t        z        dk(  sJ t        t        t        dd      z        dk(  sJ t	        dt        t        dt        z              } t        d | t              d	z  t        t        t        z  z
  z  z  t        dz  t        z   z        d
k(  sJ t        t        dt        t        t        t        t        d      dd      d            dk(  sJ y )Nr4   zx^3zx^(y^3)z(x^3)^y   zx^(2/3)g   g      @z(3.5*2*x)^(-x + y^x)/(x^2 + y)F)evaluater.   z
-2*x/(y*y))r*   r:   r=   r   r!   r   r   r   )rD   s    r1   test_PowrH   -   s   a1f&&&aAFm$	111qAv!m$	111a8Aq>)*i777S&AE"23Aa1Q4#:1qAv:66!q&1*EF+, , , c"aSA%>U!S#(* +.:; ; ;r0   c                      t        t        t        z        dk(  sJ t        t        t        z         dk(  sJ t        t        t        z
        dk(  sJ t        t               dk(  sJ y )Nx*yzx + yzx - yz-x)r*   r:   r=   r/   r0   r1   test_basic_opsrK   <   s[    a!e%%%a!e'''a!e'''qb>T!!!r0   c                     t        dt        z        dk(  sJ t        t        dz        t        t        dz        cxk(  rdk(  sJ  J t        dt        t              z        dk(  sJ t        t        t        j                   z        t        t        dz        cxk(  rdk(  sJ  J t        t        t                    dk(  sJ t        t        t        j                  z        t        t        dz        cxk(  rdk(  sJ  J t        dt
        z        d	k(  sJ t        t
        dz        t        t
        dz        cxk(  rd	k(  sJ  J t        t
        dz        d
k(  sJ y )NrE   z1/xr.   g      z	1/sqrt(x)g      zsqrt(x)g      ?z1/Piz
1/sqrt(Pi))r*   r:   r   r   Halfr   r/   r0   r1   test_1_over_x_and_sqrtrN   C   s1    a!e%%%a2g*Q$Y"7@5@@@@@a$q'k"k111aAFF7l#z!t)'<KKKKKKd1g)+++a166k"jc&:GiGGGGGa"f'''bBh:bDj#9CVCCCCCbDj!\111r0   c                     t        dt        z        dk(  sJ t        t        t        z        dk(  sJ t        dt        z        dk(  sJ t        t        t        z        dk(  sJ t        t        dz        dk(  sJ t        t        t        z        dk(  sJ t        t        t        z        dk(  sJ t        dt        z  t        z        d	k(  sJ t        dt        z  t        z  t        z        d
k(  sJ t        t        t        z        dk(  sJ t        dt        z  t        z        dk(  sJ t        t        t        z  t        z        dk(  sJ t        t        t        z  t        z        dk(  sJ t        dt        z  t        z        dk(  sJ t        dt        z  t        z  t        z  t        z        dk(  sJ t        dt        z  t        z        dk(  sJ t        t        d      dz        dk(  sJ t        t        d      dz  t        z        dk(  sJ t        t        t        z  t        z        dk(  sJ t        t        t        z   t        z        dk(  sJ t        t        t        z   t        t        z   z        dk(  sJ t        t        t        z   t        z        dk(  sJ t        t        dz  t        z        dk(  sJ t        t        d      dz  t        z  t        z  t        z        dk(  sJ y )Nr4   z3*xzPi*xz3/xzPi/xz(1/3)*xzx/PirJ   z3*x*yz3*Pi*x*yzx/yz3*x/yzx*y/zzx*z/yrE   z1/(x*y)rC   z2*Pi*x/(y*z)z3*Pi/x   z3/5z(3/5)*xzx/(y*z)z	(x + y)/zz(x + y)/(x + z)z(x + y)/gammaz
(1/3)*x/Piz(3/5)*x*y/Pi)r*   r:   r   r=   zr   r   r/   r0   r1   test_mix_number_mult_symbolsrR   Q   s   a!e%%%b1f'''a!e%%%b1f'''a!e	)))a"f'''a!e%%%a!eai G+++a"fqj1n%333a!e%%%a!eai G+++a!eai G+++a!eai G+++a!eai I---a"fqj1nq()^;;;a"fqj!X---adQh5(((adQhl#y000a!eai I---q1uk"k111q1uQ'(,====q1u
*+>>>a!ebj!\111adQhlQ&+,>>>r0   c                  Z   t        t        dz        dk(  sJ t        t        dz        dk(  sJ t        t        t        dz  z        dk(  sJ t        t        t        z        dk(  sJ t        t        t        t        z  z        dk(  sJ t        t        t        z  t        z        dk(  sJ y )	Nr4   zPi^3rC   zx^2zx^(Pi^3)zx^yzx^(y^z)z(x^y)^z)r*   r   r:   r=   rQ   r/   r0   r1   test_mix_number_pow_symbolsrT   l   s    bAg&(((a1f&&&aB!Gn%333a1f&&&aAFm$	111qAv!m$	111r0   c                      t        d      } t        |       dk(  sJ t        d| z        dk(  sJ t        t        d      dz  | z        dk(  sJ t        dd| z  z         dk(  sJ y )	NIrP   z5*Ir4   rC   z(3/2)*I   z3 + 4*I)r   r*   )rV   s    r1   	test_imagrX   w   sn    	#Aa=Ca!e%%%qtax1n%222a!a%i I---r0   c                  d   t        t              dk(  sJ t        t              dk(  sJ t        t               dk(  sJ t        t        j                        dk(  sJ t        t        j
                        dk(  sJ t        t        j                        dk(  sJ t        t        d            dk(  sJ y )NPiinfinityz	-infinity	undefinedzexp(1)rE   )r*   r   r   r   NegativeInfinityNaNExp1r   r/   r0   r1   test_constantsr`      s    b>T!!!b>Z'''rc?k)))a(()[888aee+++aff)))c!f)))r0   c                      t        dt        z        dk(  sJ t        dt        z        dk(  sJ t        dt        z        dk(  sJ y )NrC   z2*(1/2 + (1/2)*sqrt(5))z	2*Catalanz2*gamma)r*   r   r   r   r/   r0   r1   test_constants_otherrb      sH    a+o&*CCCCa'k"k111a*n%222r0   c                     t        t        t        z        dk(  sJ t        t        t        z        dk(  sJ t        t               dk(  sJ t        t        t        z  t        z        dk(  sJ t        t        t        z  t        z        dk(  sJ t        t        t        z  t        z        dk(  sJ t        t        t        z  t        z        dk(  sJ y )Nzx and yzx or yznot xzx and y and zzx or y or zzz or x and yzz and (x or y))r*   r:   r=   rQ   r/   r0   r1   test_booleanrd      s    a!e	)))a!e(((qb>W$$$a!eai O333a!eai M111q1uk"n444q1uk"&6666r0   c            	      &   t        t        dddg            dk(  sJ t        dt        t        dz        t	        t              gddt
        gdt        d      t        t              gg      } d}t        |       |k(  sJ t        | d d df         dk(  sJ t        | dd d f         dk(  sJ t        t        t        t        t        z
  t         gg            d	k(  sJ t        t        ddg             d
k(  sJ t        t        ddg             d
k(  sJ y )NrE   
   z%Matrix([[10]], storage = rectangular)rC   r   z\Matrix([[1, sin((1/2)*x), abs(x)], [0, 1, Pi], [0, exp(1), ceil(x)]], storage = rectangular)z.Matrix([[1], [0], [0]], storage = rectangular)z:Matrix([[1, sin((1/2)*x), abs(x)]], storage = rectangular)z/Matrix([[x, x - y, -y]], storage = rectangular)z!Matrix([], storage = rectangular)r4   )	r*   r#   r   r:   r@   r   r   r   r=   Aexpecteds     r1   test_Matricesrj      sE   fQB4()23 3 3 	CAJA'Ar
CFGAJ') 	*A	!  a=H$$$ a1g;< < <a1gGH H Hfq!a%!n-./<= = = fQ2&'./ / /fQ2&'./ / /r0   c                  H    t        t        t        d                  dk(  sJ y )NrC   z*Matrix([[1, 0], [0, 1]], storage = sparse))r*   r'   r%   r/   r0   r1   test_SparseMatricesrl      s    l8A;/04````r0   c                      t        dt        dt        z        dt        z  t        z  dz  gg      } t	        |       dk(  sJ t	        | j
                        dk(  sJ y )NrE   rC   r4   rP   z:Matrix([[1, sin(2/x), (3/5)*Pi/x]], storage = rectangular)z>Matrix([[1], [sin(2/x)], [(3/5)*Pi/x]], storage = rectangular))r#   r   r:   r   r*   Trh   s    r1   test_vector_entries_hadamardrp      sf    CAJB
Q/01Aa=GH H Hacc?KL L Lr0   c                      t        dt        dt        z        dt        z  t        z  dz  gddt        t        z  gg      } d}t        |       |k(  sJ y )NrE   rC   r4   rP   zGMatrix([[1, sin(2/x), (3/5)*Pi/x], [1, 2, x*y]], storage = rectangular))r#   r   r:   r   r=   r*   rg   s     r1   "test_Matrices_entries_not_hadamardrr      sT    CAJB
Q/!QA?@A	!  a=H$$$r0   c                     t        dd      } t        d| |       }t        d| |       }t        ||z        dk(  sJ t        ||z        dk(  sJ t        d|z  |z        d	k(  sJ t        |dz  |z        d
k(  sJ t        ||dt        |       z  z   z        dk(  sJ t        |t        dz  z        dk(  sJ t        |dz        dk(  sJ t        |t
        j                  z        dk(  sJ y )NnT)integerrh   BzA.BzB.ArC   z2*A.Bz2*B.Ar4   z%A.(3*Matrix(n, shape = identity) + B)zMatrixPower(A, x^2)zMatrixPower(A, 3)zMatrixPower(A, 1/2))r   r$   r*   r%   r:   r   rM   )rt   rh   rv   s      r1   test_MatrixSymbolrw      s   sD!AS!QAS!QAa!e%%%a!e%%%a!eai G+++a!eai G+++	QXa[ !#&MN N N aAFm$(====a1f!4444aAFFm$(====r0   c                  v    t        dt        d      z        dk(  sJ t        t        t                    dk(  sJ y )N   r4   z=6*Matrix([[1, 0, 0], [0, 1, 0], [0, 0, 1]], storage = sparse)zMatrix(x, shape = identity))r*   r%   r:   r/   r0   r1   test_special_matricesrz      s6    a(1+o&*iiiihqk"&CCCCr0   c            	      p   t        dddddddggdd	d
gdg      dk(  sJ t        d      dk(  sJ t        dg      dk(  sJ t        d      dk(  sJ t        t        g d       dk(  sJ t        dt        t        z  dt        dz  ff      dk(  sJ t        dt	        d      t        ddg       g f      dk(  sJ y )NrE   rC   r4   rW   rP   ry   r5      r7   rf      z)[1, 2, 3, [4, 5, [6, 7]], 8, [9, 10], 11])rE   rC   )r4   rW   z[1, 2, [3, 4]]z[1])rE   rE   rC   r4   z	[1, 2, 3]z[1, x*y, [3, x^2]]r   zl[1, Matrix([[1, 0, 0], [0, 1, 0], [0, 0, 1]], storage = rectangular), Matrix([], storage = rectangular), []])r*   r
   r:   r=   r"   r#   r/   r0   r1   test_containersr      s    q!QA1vAr7B?@67 7 7 n%)9999qc?e###du$$$eY'(K777q!a%!Q!V-.2FFFF q#a&&Ar"2B78yz z zr0   c                  V    t        t        t        z   t        z  dd      } d}| |k(  sJ y )NmeF)	assign_toinlinezme := (x + y)/Catalan)r*   r:   r=   r   )sourceri   s     r1   test_maple_noninliner      s+    Q4FF&HXr0   c                      t        g dg      } t        | d      dk(  sJ t        ddgddgg      } t        | d	      d
k(  sJ y )Nr~   ar   z/a := Matrix([[1, 2, 3]], storage = rectangular)rE   rC   r4   rW   rh   z4A := Matrix([[1, 2], [3, 4]], storage = rectangular)r#   r*   ro   s    r1   test_maple_matrix_assign_tor      sQ    	{Aa3'+\\\\AA Aa3'+aaaar0   c                      t        g dg      t        ddd      } t        ddd      t        |       dk(  sJ t        t        fd	       t        t        fd
       y )Nr~   rv   rE   r4   CrC   r   z/B := Matrix([[1, 2, 3]], storage = rectangular)c                  &    t         t              S Nr   )r*   r:   ro   s   r1   <lambda>z2test_maple_matrix_assign_to_more.<locals>.<lambda>  s    z!q9 r0   c                      t               S r   r)   )rh   r   s   r1   r   z2test_maple_matrix_assign_to_more.<locals>.<lambda>  s    z!q9 r0   )r#   r$   r*   r    
ValueError)rv   rh   r   s    @@r1    test_maple_matrix_assign_to_morer      sW    	{AS!QAS!QAa1%)ZZZZ
:9:
:9:r0   c                  B    t        dgg      } t        | d      dk(  sJ y )Nr4   rv   r   z)B := Matrix([[3]], storage = rectangular)r   ro   s    r1   test_maple_matrix_1x1r   	  s%    uAa3'+VVVVr0   c                  F   t        t        dt        t        z  gg      } t        | d   dz  | d   z   | d   z         dk(  sJ t	        ddd      }t        |      dk(  sJ t        |d   dz  t        |d         z   |d   z         d	k(  sJ t        t        |            d
k(  sJ y )NrC   r   r   )r   rE   )r   rC   zx^2 + x*y + 2AArE   r4   z%sin(AA[1, 2]) + AA[1, 1]^2 + AA[1, 3]zAA[1, 1] + AA[1, 2] + AA[1, 3])r#   r:   r=   r*   r$   r   sum)rh   r   s     r1   test_maple_matrix_elementsr     s    Aq1uAaglQtW,qw67?JJJ	dAq	!Bb>T!!!bh!mc"T(m3bh>?23 3 3c"g"BBBBr0   c                      t        d      dk(  sJ t        t        j                        dk(  sJ t        d      dk(  sJ t        t        j                        dk(  sJ y )NTtrueFfalse)r*   r   r   r   r/   r0   r1   test_maple_booleanr     sV    dv%%%aff'''e'''agg')))r0   c                      t        ddi       } d| d<   d| d<   d| d<   d	| d
<   t        t        z  | d<   t        |       dk(  sJ y )NrP   ry   rf   )rC   rC      )rE   rC      )rE   r4      )r   r4   )r4   r   zMatrix([[0, 0, 0, 30, 0, 0], [0, 0, 20, 22, 0, 0], [0, 0, 10, 0, 0, 0], [x*y, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]], storage = sparse))r'   r:   r=   r*   )Ms    r1   test_sparser   !  s\    Q2AAdGAdGAdGAdG!eAdGa=  r0   c                  ~    t        t              5  t        t        j                         d d d        y # 1 sw Y   y xY wN)r    NotImplementedErrorr*   r   ComplexInfinityr/   r0   r1   test_maple_not_supportedr   1  s.    	#	$ &1$$%& & &s   3<c                      t        ddd      } t        ddd      }t        | d         dk(  sJ t        d| d   z        dk(  sJ | |z
  }t        |d         dk(  sJ y )	Nrh   rE   r4   rv   r   zA[1, 1]z	3*A[1, 1]zA[1, 1] - B[1, 1])r$   r*   )rh   rv   Fs      r1   test_MatrixElement_printingr   6  sq    S!QAS!QAqw9,-,q1T7{#{232	!Aqv"5565r0   c                  X   t        ddd      } t        ddd      }t        ddd      }t        ddd      }t        | |      }t        |      dk(  sJ t        ||z        dk(  sJ t        ||z  |z        d	k(  sJ t        || z        d
k(  sJ t        |t        z  t        z        dk(  sJ y )Nrh   r4   rv   vrE   hzA*Bz(A*B).vz	h.(A*B).vz(A*B).Az	x*y*(A*B))r$   r&   r*   r:   r=   )rh   rv   r   r   r   s        r1   test_hadamardr   C  s    S!QAS!QAS!QAS!QA1Aa=E!!!a!e	))) a!eai K///a!e	))) a!eai K///r0   c                     t        t        t        dk  ft        dz  df      t              dk(  sJ t        d      dk(  sJ t        t        dz  t        dk  ft        dz  t        dk  ft        d	z  t        dk  ft        d
z  df      d} t              | k(  sJ t        d      d| z   k(  sJ t        t        t        dk  ft        dz  t        dkD  ft        t              t        dkD  f      t	        t
        fd       y )NrE   rC   Tzpiecewise(x < 1, x, x^2)rr   zr := piecewise(x < 1, x, x^2)r4   rW   rP   z2piecewise(x < 1, x^2, x < 2, x^3, x < 3, x^4, x^5)zr := r   c                      t               S r   r)   )exprs   r1   r   z&test_maple_piecewise.<locals>.<lambda>d  s    z$/ r0   )r   r:   r*   r   r    r   )ri   r   s    @r1   test_maple_piecewiser   V  s    aQZ!q&$0Dd9999dc*') ) ) a1fa!e_qAvq1uoQAaQUWDCHdx'''dc*g.@@@@ aQZ!q&!a%3q61q5/BD
:/0r0   c                      t        t        t        dk  ft        dz  df      } t        d| z        dk(  sJ t        | t        z        dk(  sJ t        | t        t        z  z        dk(  sJ t        | dz        dk(  sJ y )	NrE   rC   Tz2*piecewise(x < 1, x, x^2)zpiecewise(x < 1, x, x^2)/xzpiecewise(x < 1, x, x^2)/(x*y)r4   z(1/3)*piecewise(x < 1, x, x^2))r   r:   r*   r=   )pws    r1    test_maple_piecewise_times_constr   g  s    	Aq1u:Q~	.Ba"f!====b1f!====bAEl#'GGGGb1f!AAAAr0   c                      t        d      } t         | t              j                  t                    dk(  sJ t         | t              j                  t        d            dk(  sJ y )Nfzdiff(f(x), x)rC   zdiff(f(x), x$2))r   r*   r:   diff)r   s    r1   test_maple_derivativesr   p  sL    Aadiil#666adii1o&*;;;;r0   c                  x    t        t        t                    dk(  sJ t        t        t                    dk(  sJ y )Nz,(2^(-x)*((1 - sqrt(5))^x + (1 + sqrt(5))^x))z (piecewise(x <> 0, sin(x)/x, 1)))r*   r   r:   r   r/   r0   r1   test_automatic_rewritesr   v  s2    eAh#QQQQd1g"DDDDr0   c                  h    t        d      dk(  sJ t        t        t        t                    dk(  sJ y )Nzasin(x)z	arcsin(x)zBesselI(x, y))r*   r(   r:   r=   r/   r0   r1   test_specfunr   {  s.    i K///gam$777r0   N)T
sympy.corer   r   r   r   r   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   sympy.functionsr   r   r   r   r   r   r   r   sympy.testing.pytestr    sympy.utilities.lambdifyr!   sympy.matricesr"   r#   r$   r%   r&   r'   sympy.functions.special.besselr(   sympy.printing.mapler*   r:   r=   rQ   r2   r;   r>   rA   rH   rK   rN   rR   rT   rX   r`   rb   rd   rj   rl   rp   rr   rw   rz   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r/   r0   r1   <module>r      s  ? ? ? ? ? I I P P P ' 9; ; 2 +
'
1a+
7,/;"2?62.*37/:aL%>"D
zb;W
	C* &

70&1"B<E
8r0   