U
    ZÊ¹j¤r  ã                   @   sÌ  d dl mZ d dlmZ d dlmZ d dlmZmZm	Z	 d dl
mZ d dlmZ d dlmZmZ d dlmZmZ d d	lmZ d d
lmZ d dlmZ d dlmZ d dl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(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/m0Z0m1Z1m2Z2 edƒZ3edƒZ4dd„ Z5dd„ Z6dd„ Z7dd„ Z8dd„ Z9dd„ Z:dd „ Z;d!d"„ Z<d#d$„ Z=d%d&„ Z>d'd(„ Z?d)d*„ Z@d+d,„ ZAd-d.„ ZBd/d0„ ZCd1d2„ ZDd3d4„ ZEd5d6„ ZFd7d8„ ZGd9d:„ ZHe!d;d<„ ƒZId=S )>é    )Ú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                 C   s   t t|  | ƒtd| ƒƒS )Né   )r   r   ©Úmaxint© r*   úc/var/www/html/bwave/python/venv/lib/python3.8/site-packages/sympy/solvers/ode/tests/test_riccati.pyÚrand_rational   s    r,   c                    s    t ‡ fdd„t|d ƒD ƒ| ƒS )Nc                    s   g | ]}t ˆ ƒ‘qS r*   )r,   )Ú.0Ú_r(   r*   r+   Ú
<listcomp>"   s     zrand_poly.<locals>.<listcomp>r'   )r   Úrange)r&   Údegreer)   r*   r(   r+   Ú	rand_poly!   s    r2   c                 C   sP   t d|ƒ}t d|ƒ}t| ||ƒ}t| ||ƒ}|td| ƒkrHt| ||ƒ}q,|| S )Nr'   r   )r   r2   r   )r&   r1   r)   ZdegnumZdegdenÚnumÚdenr*   r*   r+   Úrand_rational_function%   s    

r5   c           
      C   s¢   | }|  |¡}t|ddƒ}t|ddƒ}|dkr<t|ddƒ}q&t|||  ||d   ƒ}t|  ¡ |||  ||d   ƒ}t||ƒ}	t||	ƒdks–t‚||||fS )Nr'   é   r   é   )Tr   )Údiffr5   r   r   r   ÚAssertionError)
Zratfuncr&   ZyfÚyZypÚq1Úq2Úq0ÚeqÚsolr*   r*   r+   Úfind_riccati_ode/   s    
"
r@   c                  C   sv  t t d  t d d d t  t t d  t d  t t d d tdƒd   d  ddt    fdt  d dt  d  ddt   t d  dt  dt  dt  d  dt  d  ddt   tdt d dd�  ddt    fd	dt d  d  d
dt  dt  d  dt  dt  d dt d  d   dt  d tddt  dd�dt  d d  ddt  d    tddt  dd�  ft dt  d dt  d  t d dt  d  t d  dt  d  dt  d tddt  d dd�  dt  d dt d  dt  d d  dt d  dt  d    dt d    fg} | D ]B\}}}}|t|t ||ƒk�sHt‚|t|t ||ƒ ¡ k�s$t‚�q$dt  d dt d  dt   d  dt  t  d dt   dt d  ddt   t  d dt d     t  d d  dt  d   dt  d	dt   t  d dt d     t  d  dt  d t  d  dt  dt d  dt   d    dt   fddt d   dt  t  d dt   dt d  ddt   t  d dt d     t  d d  dt  d   dt  d	dt   t  d dt d     t  d  dt   tdt  d dd�dt d    fg} | D ]F\}}}}}|t|t ||ƒk�sPt‚|t|t |||ƒ ¡ k�s*t‚�q*dS )ar  
    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'   r7   é   r6   é   éûÿÿÿF©Úevaluateéÿÿÿÿr   é   éüÿÿÿé   é   é	   é   éúÿÿÿéþÿÿÿN)r&   r	   r   r   r9   r   Úcancel)ÚtestsÚwÚb1Úb2r:   Úbpr*   r*   r+   Útest_riccati_transformation?   sx    
<üHüBÿÿÿÿüPÿÿÿ
ÿüì "H^ÿÿû	HZû÷rU   c                  C   s˜  t tƒ t¡td  tt tƒ  tt tƒd   t tƒ t¡t tƒd  td  td d  ddtd    fdt dt d  t tƒ t¡ td t tƒd  t  dtd  dt t d td   d  dt d d   tdt d dd	�dt d   t tƒd  t tƒ t¡ d
td t  tt d    ft tƒd t tƒ t¡ td t tƒ t tdƒd    dt d d  ddt d d   dt d dt d d   t tƒd  t tƒ t¡ ddt d   ft tƒ t¡t tƒd t  t tƒd t tƒ t¡ ddtd    fdtd  t d  td dt  d  t tƒ t¡ t tƒd t  t tƒd t tƒ t¡ dtd  td dt  d  dt td dt  d   dtd dt  d   t  ddtd    fdt dt d  t tƒ t¡ td t tƒ t  dft tƒt tƒ t¡ dt  t tƒd  t tƒd td d   dfg} | D ] \}}|t|t tƒk�srt‚�qrdS )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.
    r7   r6   rG   rL   rK   r'   éýÿÿÿFrD   rF   N)r%   r&   r8   r   r	   r   r9   )rP   r>   Z	normal_eqr*   r*   r+   Útest_riccati_reduced�   sf    0<ý8> ÿ
ÿ
ÿÿþý:@
ÿÿÿý(ýFBÿÿÿÿÿý4ý@ýÝ(rW   c                  C   sÜ  t tƒ t¡dtd  dtd   dt  d dtd  d	td   d
td   dt  d   d t tƒd dt d   tdƒd t t tƒ tdƒd dt d    ddtd  dtd  dtd   dtd   dt  d  dtd  dtd  dtd   dtd   dt  d   dt dtd  dtd   dtd   dt  d   d ddtd  d	td   d
td   dt  d   tdddt  dd�d t d  ddt d  ft tƒ t¡dt d  td d t tƒd   dt d d t tƒ dt d   td!ƒd  d"td  d#t  d$ d%td  d&td     dd't d td!ƒd  ddtd  dtd     d(d)td  dt    d"d%t d&   tdd*t d dd�d t d  td d ft tƒ t¡d+td,  d-td   d.td   d/td   d0t  d1 d)td  d&td,   d2td   d3td   d4td   d1t    td5ƒd   ttdƒd  t tƒ td tdƒd    td d t tƒd  dt   dd+td  d)td,  d&td   d2td   d3td   d4t  d1  d-td  d)td,  d&td   d2td   d3td   d4t  d1   d.td  d)td,  d&td   d2td   d3td   d4t  d1   d6t d7td,  dtd   d8td   d9td   d:t  d)   td5ƒd   d7dtd  dtd,   d;td   d<td   d=td   d7t    d>dtd,  dtd   d;td   d<td   d=t  d7   tdddt  dd�td  tdd t dd�d t  ft tƒ t¡ttdƒd  ttdƒd  d   td t tƒ  tt tƒd  ttdƒd    dd?d?d?ft tƒ t¡ttd ƒ ttƒt tƒ  ttƒt tƒd   dd?d?d?ft tƒ t¡ttt	tƒ ƒ t tƒ td t tƒd   dd?d?d?fdtd  t tƒ td¡ dt t tƒ t¡  dt tƒ  dd?d?d?ft tƒ t¡td  td t tƒ  td td  t tƒd   dd?d?d?ft tƒ t¡t tƒd  td d td d  t tƒ  ddt d   t tƒd  dd?d?d?fg	} | D ]H\}}}}}t
|t tƒ\}}||k�sºt‚|�rŽ|||g|k�sŽt‚�qŽd@S )Aa  
    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•  r6   ir  r7   éN   é\   éó   rG   i±  iN  é´   éH   r'   Té-   é   éi   é^   é   rI   éb   é   éQ   é;  i  é<   é   rF   rL   FrD   rK   é
   i	  i§  é¢   iD  éØ   rH   é/   é$   rN   i0  rB   ié  iw  il  éÆ   él   iÝ  i7  ih  é   i$  rJ   éŸ   é½   éx   é5   é?   é(   é   r   N)r%   r&   r8   r	   r   r   r   r   r   r   r   r9   )rP   r>   ÚresZb0rR   rS   ÚmatchÚfuncsr*   r*   r+   Útest_match_riccati·   sl   8
ÿ
ÿÿÿÿÿ.þD.ÿ
ÿ
ÿÿÿÿþ
ÿÿÿþ ò:ÿÿ
ÿ
ÿÿÿ>ÿÿ 
ô:ÿÿ.
ÿÿÿ
þ
ÿþý@ÿ8ÿÿÿ.ÿÿÿþ(
ÿÿÿý
ü
ÿ
ÿ
ÿÿü
ÿ
ÿÿÿûî@ÿ   ý<   þ8   þ<   þ@   þ@ÿ
ÿ   ýµPrz   c               
   C   sX  t dtd  dtd   dt  d tƒt dtd  td  d	td   d
td
   dtd   dtd	   d
td   dtd   dtd   d	t  d tƒd
ft dtƒt dtd  dtd   dtd   dt  d tƒdft dtd  dtd   dt  d tƒt dtd  dtd   dt  d tƒdft dtd  dtd
   dtd   dtd	   dtd   td  td  dt  tƒt dtd  t tƒdft d	td  dtd	   dtd   dtd   td  dt  d tƒt dtd  dtd   dtd   dt  d tƒdfg} | D ]"\}}}t||tƒ|k�s0t‚�q0dS )a  
    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
    rh   r6   rI   r7   é   rL   ióÿÿÿrK   rB   rA   rG   é   r'   é÷ÿÿÿé   é   rM   rC   rJ   r   iòÿÿÿrN   N)r   r&   r   r9   )rP   r3   r4   Úvalr*   r*   r+   Útest_val_at_inf  s.    (xý4ý((ýXýH4ýèr�   c                   C   sf   t ddddgƒdkst‚t ddddgƒdks0t‚t ddddgƒdksHt‚t dddd	d
gƒdksbt‚dS )zt
    This function tests the necessary conditions for
    a Riccati ODE to have a rational particular solution.
    rV   r'   r7   rG   Fr6   rL   éöÿÿÿrI   rJ   TN)r   r9   r*   r*   r*   r+   Útest_necessary_condsF  s    rƒ   c               	   C   s>  dt d  dt d   dt   d dt  d  dt d  d	t d
   dt d   dt d   dt   d dt d  dt d   dt   d  dt d  dt d
   dt d   dt d   dt   d dt d
  dt d   dt d   dt   d  dt d  dt d   dt d   dt d
   dt d   dt   d dt d  dt   d  dt d  dt d   dt d
   dt d   dt   d dt d  dt d   dt d   dt d
   dt d   dt d   dt   d  g} | D ]N}dd„ | ¡ D ƒ\}}t||t ƒ\}}| t dt  ¡ ¡ || k�sêt‚�qêdS )zi
    This function tests the substitution x -> 1/x
    in rational functions represented using Poly.
    r~   r6   rI   r7   rL   é   r[   rB   ru   rG   éP   é   rf   é–   éK   rJ   iñÿÿÿrl   rA   rg   ra   éd   éð   rh   r]   rK   c                 S   s   g | ]}t |tƒ‘qS r*   )r   r&   )r-   Úer*   r*   r+   r/   g  s     z/test_inverse_transform_poly.<locals>.<listcomp>r'   N)r&   Zas_numer_denomr   ÚsubsrO   r9   )Zfnsr%   r3   r4   r*   r*   r+   Útest_inverse_transform_polyU  s     .^j^t
ÿÿÿ÷r�   c               
   C   sÊ  t dtd  dt  d tƒt dtd  dtd   dt  d tƒdft dtd	  dtd   d
td   dt  d tƒt dtd  dtd   dt  d tƒtft dtd  dtd   dtd   dtd   dtd	   dtd   dtd   dt  d tƒt dtd  dtd   dtd   dtd	   dtd   d td   d!t  d" tƒt ft d!td  d#td   d$td   d$td	   d%td   d&td   d't  d( tƒt d)td  dtd   d*td   d*td	   d+td   d,td   d-t  d. tƒtd/ƒd ft d0td	  d1td   d.td   d2t  d3 tƒt d4td	  dtd   d5td   dt  d tƒtd0ƒd4 fg} | D ]"\}}}t||tƒ|k�s¢t‚�q¢d6S )7a   
    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
    éôÿÿÿr7   ra   é    r6   r\   r   éì  rG   i¼  ix  iœ  i'  éô  i  i!ýÿÿrI   rA   i�  rL   re   rB   iX  éH  i  iv  iÄ  ið  é|  éT   é¤  iè  r_   é¨   iÀ  rf   r…   r]   rr   r~   iß  iÐ  iÐ   iØ	  ið
  i  r'   é   iÂ  i„  éZ   i_  i  N)r   r&   r   r	   r   r9   )rP   r3   r4   Zlimr*   r*   r+   Útest_limit_at_infl  s:    (ý4(ýTÿÿÿXüXX
ý44
ýær™   c                  C   s¶  t dtd  dtd   dt  d tdd�t dtd  d	td
   dtd   dtd   dtd   dtd   tdd�tdƒtdƒd tdƒt d  gtdƒd tdƒt d  ggft dtd  dtd   dt  d tdd�t dtd  dtd   dtd   dtd   dt  d tdd�td
ƒd tdƒd tdƒd  gtdƒd tdƒd  ggft dt d tdd�t dtd  ddtdƒ  td   ddtdƒ  td   ddtdƒ  t  dtdƒ  d	 tdd �tdƒtdƒ d tdƒd ttddtdƒ d d!d"�d#tdƒ d$  d ƒd  gtdƒd ttddtdƒ d d!d"�d#tdƒ d$  d ƒd  ggfg} | D ]&\}}}}t||t|ƒ|k�sŠt‚�qŠd%S )&ab  
    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.
    rV   r6   r7   rG   rB   T©Ú	extensionrI   é   rA   rK   rJ   rL   r   r'   i°  i   i0  i0  é€   i�  ið  ie  i�  é1   ijÁù iz  r„   r   r|   zQQ<sqrt(3)>©ÚdomainFrD   é   é,   N)r   r&   r	   r   r   r   r   r9   )rP   r3   r4   ÚpoleÚcr*   r*   r+   Útest_construct_c_case_1š  s6    ,P:ü,D
2üP
ÿÿ ÿBBÿûór¥   c                  C   sò  t dtdd�t td d td  tdd�ddt dt  d gtdt  d ggft dtd  dtd	   d
td   d tdd�t dt d d td d  tdd�tdƒd dtdƒ d gtdƒ d ggft td td  d	t  tdd�t td d	 td d  tdd�dd	d
tdƒ tdƒd d	tdƒ d
   d dtdƒ d
 gdtdƒ tdƒd d	tdƒ d
   d dtdƒ d
 ggft dtd  td	  d tdd�t d	t d d	 td  tdd�tdƒ d	 d	dtdƒ tdƒ d tdƒd   d tdƒd gdtdƒ tdƒd tdƒd   d tdƒ d ggft td d tdd�t dt d d td d  tdd�tdƒd ddtdƒ tdƒ d tdƒd   d dtdƒ d tdƒd  gd!tdƒ tdƒd tdƒd   d dtdƒ d tdƒ d  ggft td d tdd�t ttdƒ d tdd�tdƒdtd"ƒtdƒd
 dtd"ƒ   d# td
ƒd
 td"ƒgtd"ƒ tdƒd
 dtd"ƒ   d# td
ƒ d
 td"ƒ ggfg} | D ]*\}}}}}t||t||ƒ|k�sÂt‚�qÂd$S )%a�  
    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š   r7   rF   r6   rB   rJ   rG   rA   éY   rb   rK   rf   iW  éùÿÿÿrN   r�   i·  é7   i 8  é   i€ÿÿÿrL   r^   éB   é6   éƒ   i$ rv   iÍ  ri   iåÿÿÿr   é   N)r   r&   r   r	   r   r   r9   )rP   r3   r4   r£   Úmulr¤   r*   r*   r+   Útest_construct_c_case_2À  s^     $ü0$
 ü   ::ÿü   44ÿü	$
 BBÿü 4:ÿüÛ,r¯   c                   C   s   t ƒ dggkst‚dS )z`
    This function tests the Case 3 in the step
    to calculate coefficients of c-vectors.
    r'   N)r   r9   r*   r*   r*   r+   Útest_construct_c_case_3þ  s    r°   c                  C   sœ  t td  dtd   dtd   dt  d tdd�t dtd  dtd   dt  d tdd�ddt d	 td d
t tdƒd td   d gdt d	 t d dt tdƒd td   d ggft td  dtd   dtd   dtd   dtd   dt  d tdd�t td dtd   dtd   t d tdd�ddt tt dt  d gdt t tdt  d ggft dtd  td  td  dtd   td  dt  d tdd�t dtd  dt  d tdd�ddtdƒ t d dtdƒ t d tdƒt d tdƒ t tdƒd dtdƒ t d   d gdtdƒ t d dtdƒ t d tdƒ t d tdƒt tdƒd dtdƒ t d   d ggft d
td  dtd   dtd   td  d tdd�t dt d tdd�ddt d dt d td t tdƒ d  t  gd!t d d"t d t d ttdƒ d  t  ggft td  td  td  td  t tdd�t td tdd�dd#t d dt t tt d$dt   d gdt d dt tt td$dt   d ggft td  td  dtd   dtd   td  td  dt  d tdd�t dt d tdd�ddtdƒ t d dtdƒ t d tdƒt d tdƒt d tdƒ t tdƒ d% dtdƒ t d   d gd
tdƒ t d d
tdƒ t d tdƒ t d tdƒ t d tdƒt tdƒ d% dtdƒ t d   d ggfg} | D ]8\}}}}t||tt|dƒ}t||d ƒ|k�s^t‚�q^d&S )'a9  
    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.
    rB   r7   rG   r6   Trš   rK   rh   r^   rV   éž   rZ   r‚   rL   rA   rJ   rM   ro   rN   i  r—   iïÿÿÿrl   iIB  i 
  ióþÿÿr'   é)   éÀ   rg   é;   i   i×ÿÿÿr§   rC   r}   rI   N)	r   r&   r   r	   r   r#   r   r    r9   )rP   r3   r4   r®   ÚdÚserr*   r*   r+   Útest_construct_d_case_4  sl    6,02ÿüN06üD Hÿÿ4.ÿÿü	822ÿü	.XüNXÿÿD0ÿÿüÚ.r·   c               	   C   sê  t dtd  td  t d tdd�t dtd  dtd   dt  d tdd�tdƒd tdƒ d gtdƒ d tdƒd ggft dtd  td	  td  td  dt  d td
d�t dtd  dtd	   dtd   dtd   dt  d td
d�tdƒd dtdƒ d gtdƒ d dtdƒ d ggft td t d td
d�t dtd  dt  d td
d�tdƒd dtdƒ d gtdƒ d dtdƒ d ggfg} | D ]0\}}}t||ttddƒ}t|ƒ|k�s´t‚�q´dS )a  
    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.
    r7   r6   Trš   rK   rB   r'   rn   rG   ÚZZrŸ   rA   rN   r^   rC   r   N)r   r&   r   r#   r   r!   r9   )rP   r3   r4   rµ   r¶   r*   r*   r+   Útest_construct_d_case_5E  s     $,2ý8D8ý 8ýõr¹   c                  C   s¼  t dtd  d tdd�t dtd  dtd   dt  d tdd�tdƒd td  gtdƒd td  ggft dtd	  dtd   dt  d tdd�t td
 td  dtd   dtd	   dtd   dt  d tdd�dgdggft dtd	  td  dt  d tdd�t d
td  dtd   dtd
   dtd   dtd   dtd	   dtd   dt  d tdd�dgdggfg} | D ]"\}}}t||tƒ|k�s”t‚�q”dS )a  
    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.
    rN   r7   rB   r¸   rŸ   rG   rh   r'   r6   rL   rK   r   rC   r|   rJ   rI   rc   rA   r^   r¢   é.   é"   é*   N)r   r&   r	   r   r"   r9   )rP   r3   r4   rµ   r*   r*   r+   Útest_construct_d_case_6f  s,    ,*ý,H
ý(Tÿÿ ÿ
üõr½   c                  C   sÜ  t td dt  d tdd�t td t tdd�tdƒdddd	dd
dd
dœft dtd  dt  d tdd�t dtd  dtd   dtd   dt  d tdd�tdƒd ddtdƒd tdƒd tdƒd tdƒd dœft dtdd�t td dtdƒ d td   dtdƒ d  td   d!dtdƒ  td   ddtdƒ  t  d tdd�tdƒdddtdƒ d"dtdƒ  td#d"dtdƒ  d$d%�d#tdƒ  d"dtdƒ  d#tdƒ d  td#d"dtdƒ  d$d%�d#tdƒ d  d"dtdƒ  d#tdƒ d  d&œft td dtd   dtd   d't  d( tdd�t td d tdd�tdddd)ddd*d+d,œft dtd  dtd   dt  d tdd�t dtd  td  dtd   dt  d tdd�tdƒd d)dtd-ƒd. td/ƒd0 td1ƒd2 td3ƒd4 td5ƒd6 d7œft d8td  dt  d tdd�t dtd  dtd   dtd   dtd   dt  d tdd�td)dd)d)td9ƒ d: d)d#td;ƒd d<œfg} | D ].\}}}}}}|t||t|||ƒk�s¨t‚�q¨d=S )>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.
    r7   r6   rK   Trš   r'   rL   rA   iøÿÿÿr}   )r'   r   rF   rN   rV   rH   é@   iÀ  iÀ  rG   r…   i?  i  iÌ  rI   i üêiKÝÅiû  iØ  l    `B l   -­R iý0 i}' )r   r7   rF   r'   rB   rH   rJ   rŽ   rV   rF   FrD   )rG   r6   r7   r'   r   rF   rh   r{   r   r~   ro   )r6   r7   r'   r   rF   rN   i  iè  iÝ i�¤) l   ?PT l   @qs lýÿÿÿF41l   @4ôÆlüÿÿÿ…J!tðz½ l    Zdjm® )r   rF   rN   rV   rH   r§   éG   rž   r|   )r   rN   rC   rF   rV   rH   N)r   r&   r	   r   r   r   r#   r9   )rP   r3   r4   Zx0r®   Únr¶   r*   r*   r+   Útest_rational_laurent_series†  s‚      ü 8
  
ÿüPÿÿ ÿ  2ÿ ÿþû4  ü	,4
  
 
ÿü D  "ü×/rÁ   c                    s–   t | tƒr| j| j } t| ttƒ\}}tttƒtf|žŽ }tdƒ‰ ‡ ‡fdd„|D ƒ}t	dd„ t
| |ƒD ƒƒsrt‚t	‡fdd„t||ƒD ƒƒs’t‚dS )z‚
    Helper function to check if actual solution
    matches expected solution if actual solution
    contains dummy symbols.
    ÚC1c                    s   g | ]}|  ˆ ˆ¡‘qS r*   )rŒ   )r-   r?   ©rÂ   Ú	dummy_symr*   r+   r/   Õ  s     z#check_dummy_sol.<locals>.<listcomp>c                 s   s   | ]}|d  V  qdS )r   Nr*   )r-   r&   r*   r*   r+   Ú	<genexpr>×  s     z"check_dummy_sol.<locals>.<genexpr>c                 3   s   | ]\}}|  |ˆ ¡V  qd S )N)Zdummy_eq)r-   Ús1Ús2)rÄ   r*   r+   rÅ   Ø  s     N)Ú
isinstancer   ÚlhsÚrhsr   r%   r&   r$   r
   Úallr   r9   Úzip)r>   ZsolserÄ   r.   ry   Zsolsr*   rÃ   r+   Úcheck_dummy_solÉ  s    
rÍ   c                  C   s0  t dƒ} tttƒ t¡ttƒd  d dƒtttƒtdƒƒtttƒtdƒ ƒgfttƒd ttƒ t¡ dttƒ t  dtd   tttƒd|  t | t td   ƒgfdtd  ttƒ t¡ tdttƒ ttƒ t¡ d   ttƒd ttƒ  tttƒ| dtd   | t  ƒgftttƒ t¡ttƒd  dtd td    ƒtttƒdtd t  ƒgftd dt dt  ttƒ  ttƒd  ttƒ t¡ tttƒ| t td  dt  | td   ƒtttƒtƒgftd ttƒ t¡ td  tdttƒd  ttƒ t¡   ttƒ tttƒ| td  t | td   ƒtttƒtd ƒgfttƒd  ttƒ t¡ dtd  d	t  d
 td d dt d d    tttƒd|  t d|   dtd   dtd   dtd   dtd   dt  d d|  td  d|  t  d|   dtd   dtd   dtd   dtd   dtd   dt   ƒtttƒdt d dtd  dt  d  ƒgfttƒd ttƒ t¡ dtd  dtd   dtd   dtd   d
td   d	t  d dtd    tttƒdtd  dtd   td  dtd   dt  d dtd  dtd    ƒgftttƒ t¡td  dtd   dtd   dtd   dt  d td dtd   dtd   dtd   dtd   dtd
   d td   dtd   dtd   dtd   dtd   dt  d  ttƒd  ttƒ ƒtttƒdtd dtd   dtd   d	td   dtd   dt  d  ƒgftttƒ t¡tttƒ dt  dt d ttƒd  dt d   dtd  d
t  d! d"td  dtd   d   tdƒd  ƒtttƒddt  dt d  ƒgftttƒ t¡d#td  d$t  d dtd  dtd   dt  d  dttƒd  dt d   ƒtttƒdt d dt d  ƒgfttƒ t¡dtd  d ttƒd  t  dtd  t d ttƒ ttd    dtd  dt  d ttd d    tttƒ|  td  td  dt  | t |  td  td  td  t  ƒtttƒd%td  ƒgfttƒ t¡dt ttƒd d  t  tttƒt |  ttd   | td   ƒtttƒt ƒgftttƒ t¡tttƒ tdƒd dt   td tdƒd  ttƒd  dt d tdƒd    tdƒd  d&td  d't  d( d"td  dtd     ƒtttƒdt t ƒtttƒdtd)  d*td+   d,td   d-td   d.td   d/td   d0td   d1td
   d2td   d3td   d4td   d5td   d6td   d7t  d8 dtd)  d9td+   d:td   d;td   d<td   d/td   d=td   d>td
   d?td   d@td   dAtd   dBtd   dBtd   dCt   ƒgftttƒ t¡dDtd  dDtd   t d tdƒd  ttƒd   d ƒtttƒdt ƒgftttƒ t¡dEtd  d dt d  td tdƒd  ttƒd   d dt ttƒ t  dt  ƒtttƒdEt d d ƒgfg}|D ]\}}t||| ƒ �qdFS )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
    ÚC0r7   r   rG   rN   r'   r6   r~   ra   rA   rK   rL   rB   rf   r`   r\   r†   é   é9   é:   rI   rJ   ru   r]   rg   r|   rª   rh   éÜ   éï  i  iœ  rc   rœ   rŽ   é0   rF   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 iÄ4 iLžB i¾‹¦ i|Mi:£ói�Ñù r„   rV   N)	r
   r   r%   r&   r8   r   r	   r   rÍ   ©rÎ   rP   r>   r?   r*   r*   r+   Útest_solve_riccatiÛ  s\   "$þ4&þN"þ0þ8:þF6þ@ÿÿJÿÿ:
ÿ
ÿ
ÿÿÿÿÿþý
F
ÿÿÿ
ÿH
ÿýFN
ÿ
ÿ
ÿ
ÿÿÿÿ
þþRü	D2ÿ
ÿ"ýHÿ"ýJÿ&ÿFÿÿý(:þJÿ
ÿ.ÿJ
ÿ
ÿ
ÿ
ÿ
ÿÿÿ
þ
þ
þþþF
ÿ
ÿ
ÿ
ÿ
ÿÿÿ
þþýýLþHÿÿÿý er×   c                  C   sð   t dƒ} tttƒ t¡dt ttƒ td  ddt  ttƒd  dt d   dtd  dtd   d	t  d
 dtd  dtd   dtd   dt  d   d ƒtttƒdt d dt d  ƒgfg}|D ]\}}t||| ƒ qÖdS )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'   r6   r7   rJ   rK   iŒÖ  i/ i»‹ i-˜ rI   rG   é„   i*  i‹  rÓ   r„   rL   N)r
   r   r%   r&   r8   rÍ   rÖ   r*   r*   r+   Útest_solve_riccati_slowX  s    HDÿÿÿþ"üþrÙ   N)JZsympy.core.randomr   Zsympy.core.functionr   Zsympy.core.mulr   Zsympy.core.numbersr   r   r   Zsympy.core.relationalr   Zsympy.core.singletonr	   Zsympy.core.symbolr
   r   Z&sympy.functions.elementary.exponentialr   r   Z%sympy.functions.elementary.hyperbolicr   Z(sympy.functions.elementary.miscellaneousr   Z(sympy.functions.elementary.trigonometricr   Zsympy.polys.polytoolsr   Zsympy.simplify.ratsimpr   Zsympy.solvers.ode.subscheckr   Zsympy.testing.pytestr   Zsympy.solvers.ode.riccatir   r   r   r   r   r   r   r   r   r   r   r    r!   r"   r#   r$   r%   r&   r,   r2   r5   r@   rU   rW   rz   r�   rƒ   r�   r™   r¥   r¯   r°   r·   r¹   r½   rÁ   rÍ   r×   rÙ   r*   r*   r*   r+   Ú<module>   sN   H
B6c,.&>?! C}