
    \hr                        S SK Jr  S SKJr  S SKJr  S SKJrJrJ	r	  S SK
Jr  S SKJr  S SKJrJr  S SKJrJr  S S	KJr  S S
KJr  S SKJr  S SKJr  S SKJr  S SKJr  S SK J!r!  S SK"J#r#J$r$J%r%J&r&J'r'J(r(J)r)J*r*J+r+J,r,J-r-J.r.J/r/J0r0J1r1J2r2  \" S5      r3\" S5      r4S r5S r6S r7S r8S r9S r:S r;S r<S r=S r>S r?S r@S rAS  rBS! rCS" rDS# rES$ rFS% rGS& rH\!S' 5       rIg())    )randint)Function)Mul)IRationaloo)Eq)S)Dummysymbols)explog)tanh)sqrt)sin)Poly)ratsimp)checkodesol)slow)riccati_normalriccati_inverse_normalriccati_reducedmatch_riccatiinverse_transform_polylimit_at_infcheck_necessary_conds
val_at_infconstruct_c_case_1construct_c_case_2construct_c_case_3construct_d_case_4construct_d_case_5construct_d_case_6rational_laurent_seriessolve_riccatifxc                 D    [        [        U * U 5      [        SU 5      5      $ N   )r   r   )maxints    \/var/www/auris/envauris/lib/python3.13/site-packages/sympy/solvers/ode/tests/test_riccati.pyrand_rationalr-      s    GVGV,ga.@AA    c                 p    [        [        US-   5       Vs/ s H  n[        U5      PM     snU 5      $ s  snf r)   )r   ranger-   )r'   degreer+   _s       r,   	rand_polyr3   !   s.    fQh@1v&@!DD@s   3c                     [        SU5      n[        SU5      n[        XU5      n[        XU5      nU[        SU 5      :X  a  [        XU5      nU[        SU 5      :X  a  M  XV-  $ )Nr*   r   )r   r3   r   )r'   r1   r+   degnumdegdennumdens          r,   rand_rational_functionr9   %   sd    QFQF
Av
&C
Av
&C
a
6* a
9r.   c                 P   U nUR                  U5      n[        USS5      n[        USS5      nUS:X  a  [        USS5      nUS:X  a  M  [        XEU-  -
  XcS-  -  -
  5      n[        UR                  5       XuU-  -   XbS-  -  -   5      n[        X#5      n	[	        X5      S:X  d   eXXV4$ )Nr*      r      )Tr   )diffr9   r   r	   r   )
ratfuncr'   yfyypq1q2q0eqsols
             r,   find_riccati_oderG   /   s    A	
B	1a	(B	1a	(B
'#Aq!, '	dR1W$	%B	BGGIrrEzB1uH,	-B
R)Cr9,,,2>r.   c                  	   [         [         S-
  -  [         S-  S-   S-  [         -  [         [         S-  * [         S-
  -  [         [         S-  S-  [        S5      S-  -   -  S-  -
  SS[         -  -  -
  4S[         -  S-   S[         -  S-   -  SS[         -  -
  [         S-   -  S[         -  S[         -  S[         -  S-   -  S[         -  S-   -  SS[         -  -
  [        S[         S-   SS9-  -
  SS[         -  -  -
  4S	S[         S-  -  S-
  -  S
S[         -
  S[         -  S-
  -  S[         -
  S[         -  S-
  S[         S-  -  S-
  -  -  S[         -  S-
  [        SS[         -
  SS9S[         -  S-
  S-  -  SS[         -  S-
  -  -
  -  [        SS[         -
  SS9-  -
  4[         S[         -  S-
  S[         -  S-   -  [         S-  S[         -  S-
  -  [         S-  * S[         -  S-
  -  S[         -  S-
  [        SS[         -  S-   SS9-  -
  S[         -  S-
  S[         S-  -  S[         -  S-
  S-  -  S[         S-  -  S[         -  S-
  -  -   -  S[         S-  -  -  -
  4/n U  HB  u  pp4U[        U[         X#5      :X  d   eU[	        U[         X#5      R                  5       :X  a  MB   e   S[         -  S-
  S[         S-  -  S[         -  -   S-
  -  S[         -  [         * S-
  S[         -  -  S[         S-  -  SS[         -  -  [         * S-
  S[         S-  -  -  -   -  [         * S-
  S-  -  S[         * S-
  -  -   S[         -  S	S[         -  -  [         * S-
  S[         S-  -  -  -
  -  [         * S-
  -  S[         -  S-
  [         * S-
  -  S[         -  S[         S-  -  S[         -  -   S-
  -  -  -
  S[         -  -   4SS[         S-  -  -  S[         -  [         * S-
  S[         -  -  S[         S-  -  SS[         -  -  [         * S-
  S[         S-  -  -  -   -  [         * S-
  S-  -  S[         * S-
  -  -   S[         -  S	S[         -  -  [         * S-
  S[         S-  -  -  -
  -  [         * S-
  -  S[         -  -   [        S[         * S-
  SS9S[         S-  -  -  -
  4/n U  HD  u  pp5nU[        U[         X#5      :X  d   eU[	        U[         X#U5      R                  5       :X  a  MD   e   g)aN  
This function tests the transformation of the
solution of a Riccati ODE to the solution of
its corresponding normal Riccati ODE.

Each test case 4 values -

1. w - The solution to be transformed
2. b1 - The coefficient of f(x) in the ODE.
3. b2 - The coefficient of f(x)**2 in the ODE.
4. y - The solution to the normal Riccati ODE.
r*   r<      r;      Fevaluater            	      N)r'   r
   r   r   r   cancel)testswb1b2r@   bps         r,   test_riccati_transformationr]   ?   sB    	
1q5		
A1Q		
Aq1u1a46AaDF?+A--1Q37	 
1q1Q37	
QqS1q5	!
1acAg!a A!Gc!QUU.K#LLqRSTURUwV	 	AadFQJ		
Q1q	
Q!A#'AadFQJ'(AaC!Gc"a!ee6TVWXYVY	W
V 71Q377 ,!!QUU;,= 	=	 	
	
1rBqD1H	1acAg	
AqsQw1Q38c!RTAX&FGG1Q3QR7UWXY[\X\U\^_`a^a
_^ VAqD&!A#'"V# K$%&q!tVK- 	-	)E6 rN1a0000*1a8??AAAA  
AAadFQqSL1$%
1
a!A#	!Q$1Q3A26AadF++,qb1fq[81qb1f:E
1b!A#h1"q&1QT6**+aR!V41qA267JAaCQRSTVWSWQWZ[\]Z]Q]
R M 8 	!	 	
1QT6

1
a!A#	!Q$1Q3A26AadF++,qb1fq[81qb1f:E
1b!A#h1"q&1QT6**+aR!V4qs:SQBFUZ=[]^_`bc_c]c=ddE  "rqN1a0000*1a<CCEEEE "r.   c                  
   [        [        5      R                  [        5      [        S-  -
  [        [        [        5      -  -
  [        [        [        5      S-  -  -
  [        [        5      R                  [        5      [        [        5      S-  -   [        S-  -   [        S-  S-  -
  SS[        S-  -  -  -
  4S[        -  S[        -  S-   -  [        [        5      R                  [        5      -   [        S-   [        [        5      S-  -  [        -  -
  S[        S-  -  S[        -  [        * S-
  [        S-  -  -   S-  -  S[        * S-
  S-  -  -  [        S[        * S-
  SS	9S[        -  S-   -  -   [        [        5      S-  -   [        [        5      R                  [        5      -   S
[        S-   [        -  -   [        [        * S-
  -  -  -
  4[        [        5      S-  [        [        5      R                  [        5      -   [        S-
  [        [        5      -  [        * [	        S5      S-  -
  -  -
  S[        -  S-
  S-  * SS[        -  S-   S-  -  -  S[        -  S-
  S[        -  S-   S-  -  -   [        [        5      S-  -   [        [        5      R                  [        5      -   SS[        -  S-   -  -
  4[        [        5      R                  [        5      [        [        5      S-  [        -  -
  [        [        5      S-  [        [        5      R                  [        5      -   SS[        S-  -  -  -   4S[        S-  * [        -
  S-   -  [        S-  S[        -  -   S-   -  [        [        5      R                  [        5      -   [        [        5      S-  [        -  -   [        [        5      S-  [        [        5      R                  [        5      -   S[        S-  -  [        S-  S[        -  -   S-   -  S[        -  [        S-  S[        -  -   S-   -  -   S[        S-  S[        -  -   S-   -  -
  [        -  -   SS[        S-  -  -  -   4S[        -  S[        -  S-   -  [        [        5      R                  [        5      -   [        S-   [        [        5      -  [        -  -
  S4[        [        5      [        [        5      R                  [        5      -  S[        -  -
  [        [        5      S-  -   [        [        5      S-  [        S-  S-
  -  -   S4/n U  H   u  pU[        U[         [        5      :X  a  M    e   g)z
This function tests the transformation of a
Riccati ODE to its normal Riccati ODE.

Each test case 2 values -

1. eq - A Riccati ODE.
2. normal_eq - The normal Riccati ODE of eq.
r<   r;   rO   rT   rS   r*   FrL   rN   N)r&   r'   r=   r   r
   r   )rX   rE   	normal_eqs      r,   test_riccati_reducedra      sJ    	
!		!q!ta!f$q1qy0	!		!qtQwA%1Q.AadF; 	
!QqS1W!		!$AqtQwq'88
1a41Q1}$q((!aR!VaK-83q	
Q< !"1q<* 	*,-aD!G	467diil	CQ	>ArAvJ
'	( 	
!a!A$))A,!a%1rAaDF{!;;
A#'Aq!A#'A~&!A#'AaC!Ga<)??	!a	A$))A,	!"AaC!G	- 	
!		!qtQwqy 	!a!A$))A,AadF+ 	QTEAIMAqD1Q3JN+adiil:QqT1WQYF	!a!A$))A,!AqD&!Q$1*q."9AaCA
A#BB = #1qs
Q'#()*"+ 	+-.!Q$Z	8 	
!QqS1W!		!$Aqt|A~5 	
!QqTYYq\AaC!A$q&(1Q47AqD1H+==G'EP OB15555 r.   c                     [        [        5      R                  [        5      S[        S-  -  S[        S-  -  -
  S[        -  -
  S-   S[        S-  -  S	[        S-  -  -
  S
[        S-  -  -   S[        -  -   S-
  -  -
  S-
  [        [        5      S-  S[        -  S-   -  -
  [        S5      S-  [        -
  [        [        5      -  [        S5      S-  S[        -  S-  -
  -  -
  SS[        S-  -  S[        S-  -  S[        S-  -  -
  S[        S-  -  -   S[        -  -   S-
  -  S[        S-  -  S[        S-  -  S[        S-  -  -
  S[        S-  -  -   S[        -  -   S-
  -  -
  S[        -  S[        S-  -  S[        S-  -  -
  S[        S-  -  -   S[        -  -   S-
  -  -
  S-   SS[        S-  -  S	[        S-  -  -
  S
[        S-  -  -   S[        -  -   S-
  -  -   [	        SSS[        -  -
  SS9S [        -  S-
  -  SS[        -  S-   -  4[        [        5      R                  [        5      S[        -  S-  -   [        S-  S-
  [        [        5      S-  -  -
  S[        -  S-  S-   [        [        5      -  S[        -  S-   -  -
  [        S!5      S-  -
  S"[        S-  -  S#[        -  -   S$-   S%[        S-  -  S&[        S-  -  -   -  -
  SS'[        -  S-  [        S!5      S-  -   SS[        S-  -  S[        S-  -  -   -  -   S(S)[        S-  -  S[        -  -   -  -   S"S%[        -  S&-   -  -   [	        SS*[        -  S-
  SS9S [        -  S-   -  [        S-  S-
  4[        [        5      R                  [        5      S+[        S,-  -  S-[        S-  -  -
  S.[        S-  -  -   S/[        S-  -  -
  S0[        -  -   S1-
  S)[        S-  -  S&[        S,-  -  -
  S2[        S-  -  -   S3[        S-  -  -
  S4[        S-  -  -   S1[        -  -
  -  -
  [        S55      S -  -
  [        [        S5      S-  -
  [        [        5      -  [        S-  [        S5      S-  -
  -  -
  [        S-  S-
  [        [        5      S-  -  S[        -  -  -
  SS+[        S-  -  S)[        S,-  -  S&[        S-  -  -
  S2[        S-  -  -   S3[        S-  -  -
  S4[        -  -   S1-
  -  S-[        S-  -  S)[        S,-  -  S&[        S-  -  -
  S2[        S-  -  -   S3[        S-  -  -
  S4[        -  -   S1-
  -  -
  S.[        S-  -  S)[        S,-  -  S&[        S-  -  -
  S2[        S-  -  -   S3[        S-  -  -
  S4[        -  -   S1-
  -  -   S6[        -  S7[        S,-  -  S[        S-  -  -
  S8[        S-  -  -   S9[        S-  -  -
  S:[        -  -   S)-
  -  -
  [        S55      S -  -   S7S[        S-  -  S[        S,-  -  -
  S;[        S-  -  -   S<[        S-  -  -
  S=[        S-  -  -   S7[        -  -
  -  -
  S>S[        S,-  -  S[        S-  -  -
  S;[        S-  -  -   S<[        S-  -  -
  S=[        -  -   S7-
  -  -   [	        SSS[        -  -
  SS9[        S-
  -  [	        SS [        -
  SS9S [        -  -  4[        [        5      R                  [        5      [        [        S5      S-  -  [        [        S5      S-  -  S-
  -  -
  [        S-  [        [        5      -  -   [        [        [        5      S-  -  [        [        S5      S-  -  -  -   SS?S?S?4[        [        5      R                  [        5      [        [        S-  5      -
  [        [        5      [        [        5      -  -   [        [        5      [        [        5      S-  -  -   SS?S?S?4[        [        5      R                  [        5      [        [        [        [        5      -   5      -
  [        [        5      -   [        S-  [        [        5      S-  -  -   SS?S?S?4S[        S-  -
  [        [        5      R                  [        S5      -  S[        -  [        [        5      R                  [        5      -  -
  S[        [        5      -  -   SS?S?S?4[        [        5      R                  [        5      [        S-  -
  [        S-  [        [        5      -  -   [        S-  [        S-   -  [        [        5      S-  -  -   SS?S?S?4[        [        5      R                  [        5      [        [        5      S-  -  [        S-  S-
  [        S-  S-   -  [        [        5      -  -   SS[        -  S-   -  -   [        [        5      S-  -   SS?S?S?4/	n U  H8  u  pp4n[        U[         [        5      u  pgXb:X  d   eU(       d  M.  X4U/U:X  a  M8   e   g@)Az
This function tests if an ODE is Riccati or not.

Each test case has 5 values -

1. eq - The Riccati ODE.
2. match - Boolean indicating if eq is a Riccati ODE.
3. b0 -
4. b1 - Coefficient of f(x) in eq.
5. b2 - Coefficient of f(x)**2 in eq.
i  r;   ir  r<   N   \      rO   i  iN     H   r*   T-      i   ^      rQ   b      Q   ;  i  <      rN   rT   FrL   rS   
   i	  i     iD     rP   /   $   rV   i0  rJ   i  iw  il     l   i  i7  ih     i$  rR         x   5   ?   (      r   N)r&   r'   r=   r
   r   r   r   r   r   r   r   )rX   rE   resb0rZ   r[   matchfuncss           r,   test_match_riccatir      s	    	
!		!AqD3q!t8+bd2R7#ad(
ad(;AX; #A;&(*;+ , 	,./	023A$'1Q372C	DQ46A:qt
QqT!Vac!e^
,	- 	
1a4AqD3q!t8#bAg-14q89Bq!tG	AqD3q!t8	bAg	%1	,q	0=2 	246qD"QT'AqD;q!t8; d;#%';( 5)	)+,	-/13q!t8c!Q$h3F
ad(4U44  0!	!
 	BAaC%(!A#'2	1Q37" 	
!		!qs2v1q!A$' 11QqSU	6
Q451q5 	bE"H	%(+AqD3q5(83(>
ad(SAX
(	 	
1R!B%(Q!Q$1a4002r!Q$w
Q$8 4 	s1us{#	$ 	B1q5)1Q373	!a 	
!		!AqD3q!t8+c!Q$h6QTA
a%1a4#ad(*SAX5AqD@AqDq5 	bE!G	$'(1Q46z1Q4&71	!Q: '	 Q37AaD!G#QqS)	*
 	AqD"QT'C1H$s1a4x/#ad(:SUB 	1a4xAqD3q!t8+c!Q$h6QTAA 	1a4xAqD3q!t8!3c!Q$h!>	1B "1u"" 	 "!eR1Wr!Q$w%6QT%AAqD&q5&& 	 "#2q		) ,.qAv1a4/?
1a40QT'0q!tG0$&(d0+ ,,		,
 /1!AqD&2ad72B
QT'3q!tG3 d3#%'3( /)	) 	BAaC%(!a%0BA&!,%, 	
!		!q1Q46{A!QK!O44q!tAaDy@	!A$'	1qtAv;	 q!Q 	
!		!s1a4y 3q6!A$;.Q!a?q!Q
 	
!		!tAQK((1Q4/!Q$qtQw,>q!Q 
QT1Q499Q?"QqS11%551Q4?q!Q
 	
!		!q!tad1Q4i'1a4Q<1q*@@q!Q
 	
!		!QqT1W1q1a4!84QqT99Aqs
@ = 	tQw	q!QWOE`  %$RA.||3B<5(((	  %r.   c                     [        S[        S-  -  S[        S-  -  -   S[        -  -
  S-   [        5      [        S[        S-  -  [        S-  -
  S	[        S-  -  -   S
[        S
-  -  -   S[        S-  -  -   S[        S	-  -  -   S
[        S-  -  -
  S[        S-  -  -   S[        S-  -  -
  S	[        -  -   S-   [        5      S
4[        S[        5      [        S[        S-  -  S[        S-  -  -   S[        S-  -  -   S[        -  -
  S-
  [        5      S4[        S[        S-  -  S[        S-  -  -
  S[        -  -   S-
  [        5      [        S[        S-  -  S[        S-  -  -   S[        -  -
  S-
  [        5      S4[        S[        S-  -  S[        S
-  -  -
  S[        S-  -  -
  S[        S	-  -  -   S[        S-  -  -   [        S-  -
  [        S-  -   S[        -  -
  [        5      [        S[        S-  -  [        -   [        5      S4[        S	[        S-  -  S[        S	-  -  -   S[        S-  -  -
  S[        S-  -  -
  [        S-  -   S[        -  -
  S-   [        5      [        S[        S-  -  S[        S-  -  -   S[        S-  -  -
  S[        -  -   S-   [        5      S4/n U  H  u  pn[        X[        5      U:X  a  M   e   g)z
This function tests the valuation of rational
function at oo.

Each test case has 3 values -

1. num - Numerator of rational function.
2. den - Denominator of rational function.
3. val_inf - Valuation of rational function at oo
rs   r;   rQ   r<      rT   irS   rJ   rI   rO      r*         rU   rK   rR   r   irV   N)r   r'   r   )rX   r7   r8   vals       r,   test_val_at_infr     s    	R1WqAv1$q(!,SBYA!Q$&1a4/"QT'9AadFBQq!tVKbQRTUQUgUXYZ[]^Z^X^^abcdaddgiiklm	
 	Q
R1WqAv1a4'!A#-2A6	
 	R1WqAv!#a'+R1Wr!Q$w1$q(!,	
 	R1Wr!Q$wAqD(1QT61AadF:QTAAqDH2a4OQRSSAX\1	 	Qq!tVa1f_r!Q$w&1a4/!Q$61<q@!DR1WqAv!Q$&A-2A6	1E: ##A&#--- r.   c                      [        S/ SQ5      S:X  d   e[        S/ SQ5      S:X  d   e[        S/ SQ5      S:X  d   e[        S/ SQ5      S	:X  d   eg
)zh
This function tests the necessary conditions for
a Riccati ODE to have a rational particular solution.
r_   )r*   r<   rO   Fr*   r<   )r;   r*   rT   )r*   r<   rQ   rR   TN)r    r.   r,   test_necessary_condsr   F  sX     !Y/5888 I.%777 I.%777 m4<<<r.   c            	      &   S[         S-  -  S[         S-  -  -
  S[         -  -
  S-
  S[         -  S-   -  S[         S-  -  S	[         S
-  -  -   S[         S-  -  -   S[         S-  -  -   S[         -  -
  S-
  S[         S-  -  S[         S-  -  -
  S[         -  -   S-   -  S[         S-  -  S[         S
-  -  -
  S[         S-  -  -   S[         S-  -  -
  S[         -  -
  S-
  S[         S
-  -  S[         S-  -  -   S[         S-  -  -   S[         -  -   S-
  -  S[         S-  -  S[         S-  -  -   S[         S-  -  -
  S[         S
-  -  -
  S[         S-  -  -   S[         -  -   S-
  S[         S-  -  S[         -  -
  S-
  -  S[         S-  -  S[         S-  -  -
  S[         S
-  -  -   S[         S-  -  -
  S[         -  -   S-   S[         S-  -  S[         S-  -  -
  S[         S-  -  -   S[         S
-  -  -   S[         S-  -  -
  S[         S-  -  -   S[         -  -   S-
  -  /n U  Hy  nUR                  5        Vs/ s H  n[        U[         5      PM     snu  p4[        X4[         5      u  p4UR	                  [         S[         -  5      R                  5       X4-  :X  a  My   e   gs  snf )z]
This function tests the substitution x -> 1/x
in rational functions represented using Poly.
r   r;   rQ   r<   rT      rf   rJ   r   rO   P      rq      K   rR   irw   rI   rr   rl   d      rs   rh   rS   r*   N)r'   as_numer_denomr   r   subsrW   )fnsr&   er7   r8   s        r,   test_inverse_transform_polyr   U  s    1WqAv!a"Q$(+AX1a4"QT'!Bq!tG+bd2R7#ad(SAX:MPRSTPT:TWY:YZAX1a4"QT'!Bq!tG+bd2R7"QT'Bq!tG:KbQRTUQUg:UXZ[\X\:\_a:ab1Wr!Q$wAqD 2ad7*R1W4s1u<rAC1HrRStOVXDXY1Wr!Q$wAqD 2ad7*RT1B61b52ad79JRPQSTPTW9TWYZ[]^Z^W^9^abcdfgcgag9gAg:1:: C ()(8(8(:;(:1DAJ(:;)#A6vva1~$$&#'111 ;s   %Jc                     [        S[        S-  -  S[        -  -   S-   [        5      [        S[        S-  -  S[        S-  -  -   S[        -  -   S-
  [        5      S4[        S[        S	-  -  S[        S-  -  -
  S
[        S-  -  -
  S[        -  -
  S-   [        5      [        S[        S-  -  S[        S-  -  -
  S[        -  -   S-
  [        5      [        4[        S[        S-  -  S[        S-  -  -
  S[        S-  -  -   S[        S-  -  -
  S[        S	-  -  -
  S[        S-  -  -   S[        S-  -  -
  S[        -  -   S-   [        5      [        S[        S-  -  S[        S-  -  -
  S[        S-  -  -
  S[        S	-  -  -   S[        S-  -  -
  S [        S-  -  -   S![        -  -   S"-   [        5      [        * 4[        S![        S-  -  S#[        S-  -  -
  S$[        S-  -  -   S$[        S	-  -  -   S%[        S-  -  -
  S&[        S-  -  -   S'[        -  -   S(-   [        5      [        S)[        S-  -  S[        S-  -  -   S*[        S-  -  -   S*[        S	-  -  -   S+[        S-  -  -
  S,[        S-  -  -
  S-[        -  -   S.-   [        5      [        S/5      S-  4[        S0[        S	-  -  S1[        S-  -  -
  S.[        S-  -  -   S2[        -  -
  S3-
  [        5      [        S4[        S	-  -  S[        S-  -  -   S5[        S-  -  -
  S[        -  -   S-   [        5      [        S05      S4-  4/n U  H  u  pn[	        X[        5      U:X  a  M   e   g6)7z
This function tests the limit at oo of a
rational function.

Each test case has 3 values -

1. num - Numerator of rational function.
2. den - Denominator of rational function.
3. limit_at_inf - Limit of rational function at oo
r<   rl       r;   rg   r     rO   i  ix  i  i'    i  i!rQ   rI   i  rT   rp   rJ   iX  H  i  iv  i  i  |  T     i  rj      i  rq   r   rh   r}   r   i  i  i   i	  i
  i  r*      i  i  Z   i_  i  N)r   r'   r   r
   r   )rX   r7   r8   lims       r,   test_limit_at_infr   l  sD    	SAX1_r!1%R1Wr!Q$w1$r)1-	 	T!Q$Yad"SAX-Q6=qAT!Q$Yad"SU*S0!4
 	T!Q$Yad"T!Q$Y.QT9C1HDs1a4xORUVWYZVZRZZ
a%	T!Q$Yad"R1W,tAqDy83q!t8Cd1a4iORUVWRWWZ]]_`a		 	SAXAqD 2ad7*R1W4r!Q$w>AqDH3q5PSUUWXYSAXAqD 3q!t8+c!Q$h6adBT!Q$YNQUVWQWWZ]]_`a	!Q 	SAXAqD 3q!t8+c!e3b8!<SAXAqD 419,s1u4s:A>	#s
5E> #Ca(C/// r.   c                     [        S[        S-  -  S[        S-  -  -   S[        -  -   S-
  [        SS9[        S[        S-  -  S	[        S
-  -  -   S[        S-  -  -   S[        S-  -  -   S[        S-  -  -   S[        S-  -  -   [        SS9[        S5      [        S5      S-  [        S5      [        -  S-  -   /[        S5      S-  [        S5      [        -  S-  -
  //4[        S[        S-  -  S[        S-  -  -   S[        -  -   S-   [        SS9[        S[        S-  -  S[        S-  -  -
  S[        S-  -  -   S[        S-  -  -
  S[        -  -   S-   [        SS9[        S
5      S-  [        S5      S-  [        S5      S-  -   /[        S5      S-  [        S5      S-  -
  //4[        S[        -  S-   [        SS9[        S[        S-  -  SS[        S5      -  -
  [        S-  -  -   SS[        S5      -  -
  [        S-  -  -   SS[        S5      -  -
  [        -  -   S[        S5      -  -   S	-   [        SS 9[        S5      [        S5      -   S-  [        S5      S-  [        [        SS[        S5      -  S-   S!S"9S#[        S5      -  S$-   -  S-   5      S-  -   /[        S5      S-  [        [        SS[        S5      -  S-   S!S"9S#[        S5      -  S$-   -  S-   5      S-  -
  //4/n U  H  u  pp4[        X[        U5      U:X  a  M   e   g%)&a>  
This function tests the Case 1 in the step
to calculate coefficients of c-vectors.

Each test case has 4 values -

1. num - Numerator of the rational function a(x).
2. den - Denominator of the rational function a(x).
3. pole - Pole of a(x) for which c-vector is being
   calculated.
4. c - The c-vector for the pole.
r_   r;   r<   rO   rJ   T	extensionrQ      rI   rS   rR   rT   r   r*   i  i  i0  i0     i  i  ie  i  1   ij iz  r   r   r   zQQ<sqrt(3)>domainFrL      ,   N)r   r'   r
   r   r   r   r   )rX   r7   r8   polecs        r,   test_construct_c_case_1r     s    	R1WqAv!#a'd;Qq!tVbAg!Q$&AqD01QT69Bq!tGCQRVW	!
A$q&4719Q;
	!A$q&4719Q;"6!78	 	T!Q$Yad"SU*S0!tDSAXAqD 419,tAqDy83q5@2EqTXY	!Q
A$q&4>#%
%	&1a$x.2D)D(EF	 	QqS1Wa4(R1WBtAwJ1,,RQZA/EEQtTUwYXYHYYQi	7	
1Q
A$q&4Aqay1}u=r$q'zBORSSTUVV
V	WqT!Vd3q!DG)a-%@"T!W*r/RUVVWXYYYZ	\E* #$!#At4999 #r.   c                     [        S[        SS9[        [        S-
  S-  [        S-
  -  [        SS9SS[        * S[        -
  -  S-  /[        S[        -   -  S-  //4[        S[        S-  -  S[        S	-  -  -
  S
[        S-  -  -
  S-   [        SS9[        S[        -  S-
  S-  [        S-   S-  -  [        SS9[        S5      S-  S[        S5      * S-  /[        S5      * S-  //4[        [        S-  [        S-  -
  S	[        -  -   [        SS9[        [        S-
  S	-  [        S-   S-  -  [        SS9SS	S
[	        S5      -  [        S5      S-  S	[	        S5      -  S
-  -
  -  S-  S[	        S5      -  S
-  /S[	        S5      -  [        S5      S-  S	[	        S5      -  S
-  -   -  S-  S[	        S5      -  S
-  //4[        S[        S-  -  [        S	-  -   S-   [        SS9[        S	[        -  S-   S	-  [        S-   -  [        SS9[        S5      * S	-  S	S[	        S5      -  [	        S5      * S-  [        S5      S-  -
  -  S-  [	        S5      S-  /S[	        S5      -  [	        S5      S-  [        S5      S-  -
  -  S-  [	        S5      * S-  //4[        [        S-  S-   [        SS9[        S[        -  S-
  S-  [        S-  S-   -  [        SS9[        S5      S-  SS[	        S5      -  [	        S5      * S-  [        S5      S-  -
  -  S-  S[	        S5      -  S-  [	        S5      S -  /S![	        S5      -  [	        S5      S-  [        S5      S-  -
  -  S-  S[	        S5      -  S-  [	        S5      * S -  //4[        [        S-  S-   [        SS9[        [        [	        S5      -
  S-  [        SS9[	        S5      S[	        S"5      [        S5      S
-  S[	        S"5      -  -
  -  S#-  [	        S
5      S
-  [	        S"5      /[	        S"5      * [        S5      S
-  S[	        S"5      -  -   -  S#-  [	        S
5      * S
-  [	        S"5      * //4/n U  H  u  pp4n[        X[        X45      U:X  a  M   e   g$)%ae  
This function tests the Case 2 in the step
to calculate coefficients of c-vectors.

Each test case has 5 values -

1. num - Numerator of the rational function a(x).
2. den - Denominator of the rational function a(x).
3. pole - Pole of a(x) for which c-vector is being
   calculated.
4. mul - The multiplicity of the pole.
5. c - The c-vector for the pole.
r*   Tr   r<   rN   r;   rJ   rR   rO   rI   Y   rm   rS   rq   iW  rV   r   i  7   i 8     irT   ri   B   6      i$ r   i  rt   ir      N)r   r'   r   r
   r   r   )rX   r7   r8   r   mulr   s         r,   test_construct_c_case_2r     s^   " 	QT"a!eaZQd3	1"b1f+a-1b1f:a<.)	 	Qq!tVbAg!Q$&*A>acAg\1q51*$a48	!QR5&)!uRxj!	 	QTAqD[1Q3T2a!eaZQ
"A6	1
DG)QrU3Y471,
-b
0!DG)A+	>	DGQrU3Y471,	-b	0"T!W*Q,?	A	 	Qq!tVad]QT2acAg\1q5!15	
1a
d3i-$s)C!B%+5
6s
:DIcM	J	d3ic32u4	5c	9DI:c>J	L	 	QTAXqD)acAg\1a4!8$a48	!Q
T"X+Ry|afVm3
4R
7DHT9I4PR8TW<	X	T"XtBx{QsVF]2	3B	6$r(
4$r(SVW	Y	 	QTBYT*a$q'kAqD1Q
r(AaDFQtBxZ'
(
+T!WQYR	A
r(AaDFQtBxZ'	(	+d1gXaZ$r(C	E	K+EX #($Q!#At9Q>>> #(r.   c                  (    [        5       S//:X  d   eg)zT
This function tests the Case 3 in the step
to calculate coefficients of c-vectors.
r*   N)r    r   r.   r,   test_construct_c_case_3r     s    
 QC5(((r.   c                  4   [        [        S-  * S[        S-  -  -
  S[        S-  -  -   S[        -  -   S-   [        SS9[        S[        S-  -  S[        S-  -  -
  S[        -  -   S-
  [        SS9SS[        -  S	-  [        S-  S
[        -  [        S5      S-  [        S-  -
  -  S-  /S[        -  S	-  [        * S-  S[        -  [        S5      S-  [        S-  -   -  S-  //4[        [        S-  * S[        S-  -  -   S[        S-  -  -   S[        S-  -  -   S[        S-  -  -   S[        -  -   S-   [        SS9[        [        S-  S[        S-  -  -   S[        S-  -  -   [        -
  S-   [        SS9SS[        -  [        [        * S[        -
  -  S-  /S[        -  [        * [        S[        -   -  S-  //4[        S[        S-  -  [        S-  -
  [        S-  -
  S[        S-  -  -
  [        S-  -
  S[        -  -
  S-
  [        SS9[        S[        S-  -  S[        -  -   S-   [        SS9SS[	        S5      -  [        -  S-  S[	        S5      -  [        -  S-  [	        S5      [        -  S-  [	        S5      * [        -  [        S5      S-  S[	        S5      -  [        -  S-  -
  -  S-  /S[	        S5      -  [        -  S-  S[	        S5      -  [        -  S-  [	        S5      * [        -  S-  [	        S5      [        -  [        S5      S-  S[	        S5      -  [        -  S-  -   -  S-  //4[        S
[        S-  -  S[        S-  -  -
  S[        S-  -  -
  [        S-  -
  S-
  [        SS9[        S[        -  S-
  [        SS9SS[        -  S-  S[        -  S-  [        S-  [        * [        S5      * S -  [        -
  -  /S![        -  S-  S"[        -  S-  [        * S-  [        [        S5      * S -  [        -   -  //4[        [        S-  * [        S-  -
  [        S-  -
  [        S-  -
  [        -
  [        SS9[        [        S-   [        SS9SS#[        -  S-  S[        -  [        * [        [        * S$S[        -  -
  -  S-  /S[        -  S-  S[        -  [        [        * [        S$S[        -  -   -  S-  //4[        [        S-  * [        S-  -
  S[        S-  -  -
  S[        S-  -  -
  [        S-  -
  [        S-  -
  S[        -  -   S-
  [        SS9[        S[        -  S-
  [        SS9SS[	        S5      -  [        -  S-  S[	        S5      -  [        -  S-  [	        S5      [        -  S-  [	        S5      [        -  S-  [	        S5      * [        -  [        S5      * S%-  S[	        S5      -  [        -  S-  -
  -  S-  /S
[	        S5      -  [        -  S-  S
[	        S5      -  [        -  S-  [	        S5      * [        -  S-  [	        S5      * [        -  S-  [	        S5      [        -  [        S5      * S%-  S[	        S5      -  [        -  S-  -   -  S-  //4/n U  H1  u  pp4[        X[        [        US5      n[        XSS-  5      U:X  a  M1   e   g&)'a  
This function tests the Case 4 in the step
to calculate coefficients of the d-vector.

Each test case has 4 values -

1. num - Numerator of the rational function a(x).
2. den - Denominator of the rational function a(x).
3. mul - Multiplicity of oo as a pole.
4. d - The d-vector.
rJ   r<   rO   r;   Tr   rS   rs   ri   r_      re   r   rT   rI   rR   rU   rz   rV   i  r   irw   iIB  i 
  ir*   )      rr   ;   i   ir   rK   r   rQ   N)r   r'   r   r
   r   r$   r   r!   )rX   r7   r8   r   dsers         r,   test_construct_d_case_4r     s@    	adUQq!tV^a1f$qs*Q.TBQq!tVa1f_r!t#a'd;	
Q$r'1Q31afSj1Q3./1	2	QrA2a41afSj1Q3./12	4	 	adUQq!tV^a1f$qAv-!Q$61<q@!tTQTAadF]R1W$q(1,a4@	
Q$A2rAv;q=	!AaC!QQZ\#:;	 	R1Wq!t^ad"Qq!tV+ad2QqS81<a4PQq!tVbd]QT2	
d1g+a-
Sa[]2-tAwqy{T!WHQJ%QU
DG)A+a-I == 
"47l1nS0"T!W*Q,r/DG8A:a<Q	1U8D=1T!W9Q;q=01!35	6	 	R1WqAv!Q$&A-11ERTAXqD)	
Q$s(AaCFAaC!aeVD[1_!5	6	QsBqDGaRT1qufTkAo#67	9	 	adUQT\AqD 1a4'!+Q$?QUA&	
Q$q&!A#r1qb"qs(mAo	.1Q1a!QQqS\RS^0TU	 	adUQT\AadF"Qq!tV+ad2QT9AaC?!CQRVWQqS1Wa4(	
DG)A+a-471QQ	!T!WQYq[47(1*qQRteTUg	$q'	!AO CC 
tAwJqLNBtAwJqLNT!WHQJqL4PQ7(ST*UV,Q	AaD57QtAwYq[]*+A-/	0	M-E\ "#%c2sA>!#Av.!333 "r.   c            
      B   [        S[        S-  -  [        S-  -   [        -   S-
  [        SS9[        S[        S-  -  S[        S-  -  -   S[        -  -   S-
  [        SS9[        S5      S-  [        S5      * S-  /[        S5      * S-  [        S5      S-  //4[        S[        S-  -  [        S	-  -   [        S-  -
  [        S-  -   S[        -  -
  S-
  [        S
S9[        S[        S-  -  S[        S	-  -  -   S[        S-  -  -   S[        S-  -  -   S[        -  -   S-   [        S
S9[        S5      S-  S[        S5      -  S-  /[        S5      * S-  S[        S5      -  S-  //4[        [        S-  [        -
  S-   [        S
S9[        S[        S-  -  S[        -  -   S-   [        S
S9[        S5      S-  S[        S5      -  S-  /[        S5      * S-  S[        S5      -  S-  //4/n U  H.  u  pn[        X[        [        SS5      n[        U5      U:X  a  M.   e   g)z
This function tests the Case 5 in the step
to calculate coefficients of the d-vector.

Each test case has 3 values -

1. num - Numerator of the rational function a(x).
2. den - Denominator of the rational function a(x).
3. d - The d-vector.
r<   r;   Tr   rS   rJ   r*   ry   rO   ZZr   rI   rV   ri   rK   r   N)r   r'   r   r$   r   r"   )rX   r7   r8   r   r   s        r,   test_construct_d_case_5r   E  s    	Qq!tVad]Q"A6Qq!tVa1f_qs"Q&T:
q'!)d1gXc\	"d1gXaZa$=> 	Qq!tVad]QT!AqD(1Q3.2AdCQq!tVa1f_qAv%!Q$.14q8!DI
q'!)RQZ]	#tAwhqj!DG)B,%?@ 	QTAX\1T*Qq!tVac\Aq.
q'!)RQZ\	"d1gXaZ471$=>E  !%c2q!<!#&!+++ r.   c            	         [        S[        S-  -  S-
  [        SS9[        S[        S-  -  S[        S-  -  -   S[        -  -   S-   [        SS9[        S5      S-  [        S-  -   /[        S5      S-  [        S-  -
  //4[        S[        S	-  -  S[        S-  -  -
  S[        -  -
  S-
  [        SS9[        [        S
-  [        S-  -
  S[        S-  -  -   S[        S	-  -  -
  S[        S-  -  -
  S[        -  -
  S-   [        SS9S/S//4[        S[        S	-  -  [        S-  -   S[        -  -   S-   [        SS9[        S
[        S-  -  S[        S-  -  -
  S[        S
-  -  -
  S[        S-  -  -
  S[        S-  -  -
  S[        S	-  -  -
  S[        S-  -  -
  S[        -  -
  S-
  [        SS9S/S//4/n U  H  u  pn[	        X[        5      U:X  a  M   e   g)z
This function tests the Case 6 in the step
to calculate coefficients of the d-vector.

Each test case has 3 values -

1. num - Numerator of the rational function a(x).
2. den - Denominator of the rational function a(x).
3. d - The d-vector.
rV   r<   rJ   r   r   rO   rs   r*   r;   rT   rS   r   rK   r   rR   rQ   rn   rI   ri   r   .   "   *   N)r   r'   r
   r   r#   )rX   r7   r8   r   s       r,   test_construct_d_case_6r   f  s    	R1Wq[!D)Qq!tVa1f_r!t#a'48
A$q&1Q3,!A$q&1Q3,( 	R1WqAv!#a'48QTAqD[1QT6!AadF*Qq!tV3ac9A=qN
qc
 	R1Wq!t^bd"R'48Qq!tVbAg1a4'"QT'1Bq!tG;bAgE1a4O
Q$t	%
qc
	E" !!#A.!333 r.   c                  v   [        [        S-  S[        -  -
  S-   [        SS9[        [        S-  [        -
  [        SS9[        S5      SSSS	SS
SS
S.4[        S[        S-  -  S[        -  -
  S-   [        SS9[        S[        S-  -  S[        S-  -  -
  S[        S-  -  -
  S[        -  -   S-
  [        SS9[        S5      S-  SS[        S5      S-  [        S5      S-  [        S5      S-  [        S5      S-  S.4[        S[        SS9[        [        S-  S[        S5      -  S-
  [        S-  -  -   S[        S5      -  S -   [        S-  -  -   S!S[        S5      -  -
  [        S-  -  -   SS[        S5      -  -   [        -  -   S-
  [        SS9[        S5      SSS[        S5      -   S"S[        S5      -  -
  [	        S#S"S[        S5      -  -
  S$S%9S#[        S5      -   -  S"S[        S5      -  -
  S#[        S5      -   S-  -  [	        S#S"S[        S5      -  -
  S$S%9S#[        S5      -   S-  -  S"S[        S5      -  -
  S#[        S5      -   S-  -  S&.4[        [        S-  S[        S-  -  -
  S[        S-  -  -   S'[        -  -   S(-
  [        SS9[        [        S-  S-
  [        SS9[
        SSSS)SSS*S+S,.4[        S[        S-  -  S[        S-  -  -   S[        -  -
  S-   [        SS9[        S[        S-  -  [        S-  -
  S[        S-  -  -
  S[        -  -   S-   [        SS9[        S5      S-  S)S[        S-5      S.-  [        S/5      S0-  [        S15      S2-  [        S35      S4-  [        S55      S6-  S7.4[        S8[        S-  -  S[        -  -   S-
  [        SS9[        S[        S-  -  S[        S-  -  -   S[        S-  -  -   S[        S-  -  -   S[        -  -   S-   [        SS9[
        S)SS)S)[        S95      * S:-  S)S#[        S;5      S-  S<.4/n U  H  u  pp4pVU[        X[        X4U5      :X  a  M   e   g=)>a  
This function tests the computation of coefficients
of Laurent series of a rational function.

Each test case has 5 values -

1. num - Numerator of the rational function.
2. den - Denominator of the rational function.
3. x0 - Point about which Laurent series is to
   be calculated.
4. mul - Multiplicity of x0 if x0 is a pole of
   the rational function (0 otherwise).
5. n - Number of terms upto which the series
   is to be calculated.
r<   r;   rS   Tr   r*   rT   rI   ir   )r*   r   rN   rV   r_   rP   @   i  i  rO   r   i?  i  i  rQ   i iKi  i  l    `B l   -R i0 i}' )r   r<   rN   r*   rJ   rP   rR   r   r_   rN   FrL   )rO   r;   r<   r*   r   rN   rs   r   r   r   rz   )r;   r<   r*   r   rN   rV   i  i  i i) l   ?PT l   @qs lF41l   @4lJ!tz l    Zdjm )r   rN   rV   r_   rP   r   G   r   r   )r   rV   rK   rN   r_   rP   N)r   r'   r
   r   r   r   r$   )rX   r7   r8   x0r   nr   s          r,   test_rational_laurent_seriesr     sP   & 	QTAaCZ!^Q$/QTAXqD)	!a"!3	 	R1WtAv$a48R1Wr!Q$wQT)DF2S8!tL	!Q1hK QtWS[an[6PV9U?		 	QT"QTRQZ!^QT))QtAwY^QT,AAS1TRSW9_VWYZVZDZZqay=!
 !"d	4QAQKB47Ns2rAd1gI~PU/VXZ
q'Y 0QtAwYd1g(99c"b1TRSW9n_d ?
Q<!
?"$qay.2Q<!2C!C	E 	QTAadF]Qq!tV#bd*R/dCQTAXqD)
Aq!aRR0	 	Qq!tVa1f_qs"Q&T:Qq!tVad]Qq!tV#ac)A-qDA	!Q1dGDLai/Qz]:5Mnm+3D1EFV1V	X	 	R1Wqs]QT2Qq!tVa1f_qAv%!Q$.14q8!tL
Aq11R5&)"a@	S.E^ &+!"1-c2AFFFF &+r.   c                   ^ [        U [        5      (       a  U R                  U R                  -
  n [	        U [
        [        5      u  p4[        [        [        5      [        /UQ76 n[        S5      nU Vs/ s H  owR                  UT5      PM     nn[        S [        X5       5       5      (       d   e[        U4S j[        XQ5       5       5      (       d   egs  snf )zr
Helper function to check if actual solution
matches expected solution if actual solution
contains dummy symbols.
C1c              3   *   #    U  H	  oS    v   M     g7f)r   Nr   ).0r'   s     r,   	<genexpr>"check_dummy_sol.<locals>.<genexpr>  s     32t2s   c              3   L   >#    U  H  u  pUR                  UT5      v   M     g 7f)N)dummy_eq)r   s1s2	dummy_syms      r,   r   r     s#     I8Hfbr{{2y))8Hs   !$N)
isinstancer	   lhsrhsr   r&   r'   r%   r   r   allr   zip)rE   solser   r2   r   solsr   rF   s     `     r,   check_dummy_solr     s     "bVVbff_RA&HA1q)5)D	tB/34tHHR#tD43[233333ID8HIIIII 5s   4Cc                  "   [        S5      n [        [        [        5      R	                  [        5      [        [        5      S-  -   S-
  S5      [        [        [        5      [        S5      5      [        [        [        5      [        S5      * 5      /4[        [        5      S-  [        [        5      R	                  [        5      -   S[        [        5      -  [        -  -   S[        S-  -  -   [        [        [        5      SU -  [        -
  U [        -  [        S-  -   -  5      /4S[        S-  -  [        [        5      R	                  [        5      -  [        S[        [        5      -  [        [        5      R	                  [        5      -   S-
  -  -
  [        [        5      S-
  [        [        5      -  -   [        [        [        5      U S[        S-  -  -   U [        -   -  5      /4[        [        [        5      R	                  [        5      [        [        5      S-  * S[        S-  [        S-  -
  -  -
  5      [        [        [        5      S[        S-  [        -
  -  5      /4[        S-  S[        -  S[        -  -   [        [        5      -  -
  [        [        5      S-  -   [        [        5      R	                  [        5      -   [        [        [        5      U [        -  [        S-  -   S[        -  -   U [        S-  -   -  5      [        [        [        5      [        5      /4[        S-  [        [        5      R	                  [        5      -  [        S-  -   [        S[        [        5      S-  -  [        [        5      R	                  [        5      -   -  -
  [        [        5      -   [        [        [        5      U [        S-  -  [        -   U [        S-  -   -  5      [        [        [        5      [        S-  5      /4[        [        5      S-  * [        [        5      R	                  [        5      -   S[        S-  -  S	[        -  -
  S
-   [        S-
  S-  S[        -  S-
  S-  -  -  -   [        [        [        5      SU -  [        -  SU -  -
  S[        S-  -  -
  S[        S-  -  -   S[        S-  -  -
  S[        S-  -  -   S[        -  -
  S-   SU -  [        S-  -  SU -  [        -  -
  SU -  -   S[        S-  -  -   S[        S-  -  -
  S[        S-  -  -   S[        S-  -  -
  S[        S-  -  -   S[        -  -
  -  5      [        [        [        5      S[        -  S-
  S[        S-  -  S[        -  -
  S-   -  5      /4[        [        5      S-  [        [        5      R	                  [        5      -   S[        S-  -  S[        S-  -  -
  S[        S-  -  -   S[        S-  -  -   S
[        S-  -  -   S	[        -  -
  S-   S[        S-  -  -  -
  [        [        [        5      S[        S-  -  S[        S-  -  -
  [        S-  -
  S[        S-  -  -   S[        -  -   S-
  S[        S-  -  S[        S-  -  -
  -  5      /4[        [        [        5      R	                  [        5      [        S-  * S[        S-  -  -   S[        S-  -  -
  S[        S-  -  -   S[        -  -
  S-   [        S-  S[        S-  -  -
  S[        S-  -  -   S[        S-  -  -
  S[        S-  -  -   S[        S
-  -  -
  S [        S-  -  -   S[        S-  -  -
  S[        S-  -  -   S[        S-  -  -
  S[        S-  -  -   S[        -  -
  S-   -  [        [        5      S-  -   [        [        5      -   5      [        [        [        5      S[        S-  S[        S-  -  -
  S[        S-  -  -   S	[        S-  -  -
  S[        S-  -  -   S[        -  -
  S-   -  5      /4[        [        [        5      R	                  [        5      [        [        [        5      -  S[        -  -   S[        -  S-
  [        [        5      S-  -  S[        -  S-   -  -   S[        S-  -  S
[        -  -
  S!-   S"[        S-  -  S[        S-  -  -
  S-   -  -   [        S5      S-  -
  5      [        [        [        5      SS[        -  -
  S[        -  S-
  -  5      /4[        [        [        5      R	                  [        5      S#[        S-  -  S$[        -  -
  S-
  S[        S-  -  S[        S-  -  -
  S[        -  -   S-   -  S[        [        5      S-  -  S[        -  S-   -  -   5      [        [        [        5      S[        -  S-   S[        -  S-
  -  5      /4[        [        5      R	                  [        5      S[        S-  -  S-   [        [        5      S-  -  [        -  -   S[        S-  -  [        -
  S-   [        [        5      -  [        [        S-
  -  -  -   S[        S-  -  S[        -  -
  S-   [        [        S-
  S-  -  -  -   [        [        [        5      U * [        S-  -
  [        S-  -   S[        -  -
  U [        -  U -
  [        S-  -   [        S-  -
  [        S-  -   [        -
  -  5      [        [        [        5      S%[        S-
  -  5      /4[        [        5      R	                  [        5      S[        -  [        [        5      S-  S-   -  [        -  -
  [        [        [        5      [        * U -  [        [        S-  -  -   U [        S-  -   -  5      [        [        [        5      [        * 5      /4[        [        [        5      R	                  [        5      [        [        [        5      -  [        S5      S-  S[        -  -
  -  [        S-  [        S5      S-  -
  [        [        5      S-  -  S[        -  S-  [        S5      S-  -
  -  -   [        S5      S-  -
  S&[        S-  -  S'[        -  -
  S(-   S"[        S-  -  S[        S-  -  -
  -  -   5      [        [        [        5      S[        -
  [        -  5      [        [        [        5      S[        S)-  -  S*[        S+-  -  -   S,[        S-  -  -   S-[        S-  -  -   S.[        S-  -  -   S/[        S-  -  -   S0[        S-  -  -   S1[        S
-  -  -   S2[        S-  -  -   S3[        S-  -  -   S4[        S-  -  -   S5[        S-  -  -   S6[        S-  -  -   S7[        -  -   S8-   S[        S)-  -  S9[        S+-  -  -   S:[        S-  -  -   S;[        S-  -  -   S<[        S-  -  -   S/[        S-  -  -   S=[        S-  -  -   S>[        S
-  -  -   S?[        S-  -  -   S@[        S-  -  -   SA[        S-  -  -   SB[        S-  -  -   SB[        S-  -  -   SC[        -  -   -  5      /4[        [        [        5      R	                  [        5      SD[        S-  -  SD[        S-  -  -   [        * S-  [        S5      S-  -
  [        [        5      S-  -  -   S-   5      [        [        [        5      S[        -  5      /4[        [        [        5      R	                  [        5      SE[        S-  -  S-  S[        -  S-  -   [        S-  [        S5      S-  -
  [        [        5      S-  -  -   S-   S[        -
  [        [        5      -  [        -  -   S[        -  -   5      [        [        [        5      SE[        -  S-  S-
  5      /4/nU H  u  p#[        X#U 5        M     gF)Ga  
This function tests the computation of rational
particular solutions for a Riccati ODE.

Each test case has 2 values -

1. eq - Riccati ODE to be solved.
2. sol - Expected solution to the equation.

Some examples have been taken from the paper - "Statistical Investigation of
First-Order Algebraic ODEs and their Rational General Solutions" by
Georg Grasegger, N. Thieu Vo, Franz Winkler

https://www3.risc.jku.at/publications/download/risc_5197/RISCReport15-19.pdf
C0r<   r   rO   rV   r*   r;   r   rl   rI   rS   rT   rJ   rq   rk   rg   r      9   :   rQ   rR   r   rh   rr   r   r   rs        i  i  rn   r   r   0   rN   i  r   r   r   r   r   r   r   i0H  i iF i4" i< ii2ҍi"0	iimi^   r   i  i<Z  i8X i4 iLB i i|Mi:i r   r_   N)	r   r	   r&   r'   r=   r   r
   r   r   r   rX   rE   rF   s       r,   test_solve_riccatir     s     
tB 	1Q499Q<!A$'!A%q)	AaD$q'	Bqtd1gX./ 	
!a!A$))A,1Q4)AadF2	AaD2b519r!tad{+	,- 	
!Q$qtyy|a1Q4!A$))A,!6!:;;qtax1oM	AaD2!Q$;a(	)* 	1Q499Q<!A$'Aq!tad{O34	AaD!QTAX,	  	
1!ac	1Q4!A$')AaDIIaL8	AaD2a4!Q$;1$rAqDy1	2BqtQK@
 	
1QqTYYq\AqD 1a!ai!A$))A,&>#??!A$F	AaD2ad7Q;ad+	,b1q!tn= 
1q1Q499Q<2ad7RT>A#5Q
AaCED 9 # 		AaD1R46AbD=2ad7*R1W4r!Q$w>AqDH
Q$rT!Q$Y2a'!B$.1a47"QT'A
1a4QT'q!tG$&'c*+ 
,-/!qsQw1a4
A#BB 7 .	 	
!a!A$))A,!AqD&1QT6/Bq!tG";a1f"DadF#T## !!Q$"( 	(	AaD1QT6AadF?QT)AadF2QqS81<qAv1f@  
 	 	1Q499Q<1a4%"QT'/Bq!tG3bAg=1DqHUR2X1b5(3q!t83c!Q$h>QTICPQSTPTHT1H1a4x "%ad(+-/1W579!t<>?@ACDQ47KMNqTR 	S 
AaD!QTAadF]R1W,r!Q$w6AqD@1Q3FJK	LM	 	1Q499Q<1Q4!A#1q!A$'(91Q37(CCq!tVac\BAqD2ad7!2Q!678:;A$q&A 	B	AaD1qs7QqS1W%	&' 	1Q499Q<#ad(RT/B.AqD2ad71BQqS1H11LM!ai1q!" 	#	AaD1Q37QqS1W%	&' 	
!		!!Q$
AaD!G+A--1a4!a10Eq!K H 1 	q!tVac\A%1q51*5	6	AaDB3A:1$qs*RTBYA-=1-Dq!t-K.  
adBAJ'	) 	
!		!qsAaD!GaK(**	AaDA2b51QT6>BAI.	/AaD1"> 	1Q499Q<1Q41a!A#.!A#!Q,!a1GqSUQqT!V^2  tAv&),QTDF):S)@2ad7RPQSTPTWCT(UV 	W	AaD1q5!)	b11b52ae8(;c!R%i(G$qRTu*(T!R%K) A+)&(.q!t)46=adl)CELQPQT\)RT\qDU)AqD=)!#,QT>)24=adN)CENq[)QS\)] BhQU"SBY.ae;eArEkIFSTVWSWKW1a4K!!Q$,')0A68@AFHPQRTUQUVX`TYQTM"$,QJ/(1 2 	3	 	1Q499Q<AqD2ad7*qbdQqT!VmQqT1W-DDqHI	AaD!A# 	1Q499Q<AqDRT!V+qsQqT!V|QqT1W.DDq5!A$,q.!#$Q3' 	(	AaD"Q$q&1*	AdEJ $ r.   c            	      \   [        S5      n [        [        [        5      R	                  [        5      S[        -
  [        [        5      -  [        S-
  -  SS[        -  -
  [        [        5      S-  -  S[        -  S-
  -  -   S[        S-  -  S[        S-  -  -
  S	[        -  -   S
-
  S[        S-  -  S[        S-  -  -
  S[        S-  -  -   S[        -  -
  S-   -  -   S-   5      [        [        [        5      S[        -  S-   S[        -  S-
  -  5      /4/nU H  u  p#[        X#U 5        M     g)z
This function tests the computation of rational
particular solutions for a Riccati ODE.

Each test case has 2 values -

1. eq - Riccati ODE to be solved.
2. sol - Expected solution to the equation.
r   r*   r;   r<   rR   rS   i  i/ i i- rQ   rO      i*  i  r   r   rT   N)r   r	   r&   r'   r=   r   r   s       r,   test_solve_riccati_slowr   X  s$    
tB 	1Q499Q<!a%1q1u-RT1Q470BAaC!G0LL1a4Z&A+%	1G;a1fs1a4x>ORUVWYZVZRZ>ZF??  ! 	" 
AaD2a4!8acAg&	'(	E $ r.   N)Jsympy.core.randomr   sympy.core.functionr   sympy.core.mulr   sympy.core.numbersr   r   r   sympy.core.relationalr	   sympy.core.singletonr
   sympy.core.symbolr   r   &sympy.functions.elementary.exponentialr   r   %sympy.functions.elementary.hyperbolicr   (sympy.functions.elementary.miscellaneousr   (sympy.functions.elementary.trigonometricr   sympy.polys.polytoolsr   sympy.simplify.ratsimpr   sympy.solvers.ode.subscheckr   sympy.testing.pytestr   sympy.solvers.ode.riccatir   r   r   r   r   r   r   r   r   r   r    r!   r"   r#   r$   r%   r&   r'   r-   r3   r9   rG   r]   ra   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r.   r,   <module>r     s    % (  0 0 $ " . = 6 9 8 & * 3 %     SMCL
BE ?FD36l`)F).X=2.+0\#:L;?|)<4~,B4@@GFJ$z%z % %r.   