+
    ‹°³j ó  ã                   ó*  € ^ RI Ht ^ RIHt ^ RIHt ^ RIHt ^ RIH	t	H
t
Ht ^ RIHt ^ RIHt ^ RIHtHt ^ R	IHt ^ R
IHt ^ RIHt ^ RIHt ^ RIHt ^ RIHt ^ RIH t  ^ RI!H"t"H#t#H$t$H%t%H&t&H't'H(t( ^ RI)H*t*H+t+H,t,H-t-H.t.H/t/H0t0H1t1 ^ RI2H3t3 ^ RI4H5t5 ^ RI6H7t7 ^ RI8H9t9H:t: ^ RI;H<t< R t=R t>R t?R@R lt@R tAR tBR tCRAR ltDRAR ltER  tFRBR! ltGR" tHRBR# ltIR$ tJRCR& ltKR' tLRBR( ltMR) tNR* tOR+ tPRBR, ltQRAR- ltRRAR. ltSR/ tTRAR0 ltUR1 tVR2 tW]<'       d=   ]X! ]Y! ]:]=]>]?]A]B]D]E]F]G]H]I]K]M]O]@]P]Q]R]S]N]T]U34      4      w  t=t>t?tAtBtDtEtFtGtHtItKtMtOt@tPtQtRtStNtTtU]D]=3]E]=3]9.tZ]K]D]=3]E]=3]=.3t[]P]G]=3]P]G]J]=3]9.t\]B]J3]9.t]]B]A]B]M]B]O]B]=3t^]B]A]I]B]A]K3]D]F]K]B3]\]Z]H][]B]H]H]]3]9.t_R3 3R4 lt`RDR5 ltaR6PÅ                  4       tc]d! ]X! ]e! ]c]X! ]Y! ]f! 4       PÎ                  ]c4      4      4      4      4      th]R7 4       ti]R8 4       tj]R9 4       tkR@R: ltlR; tmR< tnR= toR> tpR? tqR%# )Eé    )Údefaultdict)ÚAdd)Úcacheit)ÚExpr)ÚFactorsÚ	gcd_termsÚfactor_terms)Ú
expand_mul)ÚMul)ÚpiÚI)ÚPow)ÚS)Úordered)ÚDummy)Úsympify©Ú	bottom_up)Úbinomial)ÚcoshÚsinhÚtanhÚcothÚsechÚcschÚHyperbolicFunction)ÚcosÚsinÚtanÚcotÚsecÚcscÚsqrtÚTrigonometricFunction)Úperfect_power)Úfactor)Úgreedy)ÚidentityÚdebug)ÚSYMPY_DEBUGc                óZ   € V P                  4       P                  4       P                  4       # )zwSimplification of rational polynomials, trying to simplify
the expression, e.g. combine things like 3*x + 2*x, etc....
)Únormalr&   Úexpand©Úrvs   &ÚR/home/luca/screen-checking/.venv/lib/python3.14/site-packages/sympy/simplify/fu.pyÚTR0r1       s"   € ð �9‰9‹;×ÑÓ×&Ñ&Ó(Ð(ó    c                ó   € R p\        W4      # )z²Replace sec, csc with 1/cos, 1/sin

Examples
========

>>> from sympy.simplify.fu import TR1, sec, csc
>>> from sympy.abc import x
>>> TR1(2*csc(x) + sec(x))
1/cos(x) + 2/sin(x)
c                 ó*  € \        V \        4      '       d4   V P                  ^ ,          p\        P                  \        V4      ,          # \        V \        4      '       d4   V P                  ^ ,          p\        P                  \        V4      ,          # V # ©r   )Ú
isinstancer!   Úargsr   ÚOner   r"   r   ©r/   Úas   & r0   ÚfÚTR1.<locals>.f5   s_   € Ü�bœ#×ÒØ—‘˜•
ˆAÜ—5‘5œ˜Q›•<ÐÜ˜œC× Ò Ø—‘˜•
ˆAÜ—5‘5œ˜Q›•<ÐØˆ	r2   r   ©r/   r;   s   & r0   ÚTR1r>   )   s   € òô �RÓÐr2   c                ó   € R p\        W4      # )a  Replace tan and cot with sin/cos and cos/sin

Examples
========

>>> from sympy.simplify.fu import TR2
>>> from sympy.abc import x
>>> from sympy import tan, cot, sin, cos
>>> TR2(tan(x))
sin(x)/cos(x)
>>> TR2(cot(x))
cos(x)/sin(x)
>>> TR2(tan(tan(x) - sin(x)/cos(x)))
0

c                 ó  € \        V \        4      '       d/   V P                  ^ ,          p\        V4      \	        V4      ,          # \        V \
        4      '       d/   V P                  ^ ,          p\	        V4      \        V4      ,          # V # r5   )r6   r   r7   r   r   r    r9   s   & r0   r;   ÚTR2.<locals>.fS   s_   € Ü�bœ#×ÒØ—‘˜•
ˆAÜ�q“6œ#˜a›&•=Ð Ü˜œC× Ò Ø—‘˜•
ˆAÜ�q“6œ#˜a›&•=Ð Øˆ	r2   r   r=   s   & r0   ÚTR2rB   A   s   € ò$ô �RÓÐr2   c                ó&   a€ V3R lp\        W4      # )ay  Converts ratios involving sin and cos as follows::
    sin(x)/cos(x) -> tan(x)
    sin(x)/(cos(x) + 1) -> tan(x/2) if half=True

Examples
========

>>> from sympy.simplify.fu import TR2i
>>> from sympy.abc import x, a
>>> from sympy import sin, cos
>>> TR2i(sin(x)/cos(x))
tan(x)

Powers of the numerator and denominator are also recognized

>>> TR2i(sin(x)**2/(cos(x) + 1)**2, half=True)
tan(x/2)**2

The transformation does not take place unless assumptions allow
(i.e. the base must be positive or the exponent must be an integer
for both numerator and denominator)

>>> TR2i(sin(x)**a/(cos(x) + 1)**a)
sin(x)**a/(cos(x) + 1)**a

c           
      óD
  <a€ V P                   '       g   V # V P                  4       w  rVP                  '       g   VP                  '       d   V # V3R  loVP                  4       p\	        VP                  4       4       Uu. uF,  pS! W1V,          4      '       d   K  W1P                  V4      3NK.  	  ppV'       g   V # VP                  4       p\	        VP                  4       4       Uu. uF,  pS! W2V,          4      '       d   K  W2P                  V4      3NK.  	  ppV'       g   V # VV3R lpV! W4       V! W%4       . pV EFÜ  p\        V\        4      '       d÷   \        VP                  ^ ,          RR7      pW‚9   dV   W(,          W,          8X  dC   VP                  \        VP                  ^ ,          4      W,          ,          4       R;W&   W(&   K“  S'       ds   ^V,           p	W’9   da   W),          W,          8X  dK   VP                  \        VP                  ^ ,          ^,          4      W,          ,          4       R;W&   W)&   EK  EK
  EK  EK  \        V\        4      '       d‚   \        VP                  ^ ,          RR7      pW‚9   d[   W(,          W,          8X  dE   VP                  \        VP                  ^ ,          4      W,          ) ,          4       R;W&   W(&   EK¡  EK¤  EK§  S'       g   EK²  VP                  '       g   EKÇ  VP                  ^ ,          \        P                  J g   EKï  \        VP                  ^,          \        4      '       g   EK  \        VP                  ^,          P                  ^ ,          RR7      pW‚9   g   EKQ  W(,          W,          8X  g   EKg  W(,          P                   '       g   VP"                  '       g   EK”  VP                  \        VP                  ^ ,          ^,          4      W,          ) ,          4       R;W&   W(&   EKß  	  V'       dÔ   \%        YqP'                  4        U
Uu. uF  w  r«V'       g   K  W«,          NK  	  upp
,           !  \%        VP'                  4        U
Uu. uF  w  r«V'       g   K  W«,          NK  	  upp
!  ,          p T \%        V U
Uu. uF  w  r«W«,          NK  	  upp
!  \%        V U
Uu. uF  w  r«W«,          NK  	  upp
!  ,          ,          p V # u upi u upi u upp
i u upp
i u upp
i u upp
i )c                 ó¢  <€ VP                   ;'       g    V P                  ;'       d¨    V P                  \        \        39   ;'       g‡    S;'       d}    V P
                  ;'       di    \        V P                  4      ^8¬  ;'       dI    \        ;QJ d&    R V P                   4       F  '       g   K   R# 	  R# ! R V P                   4       4      # )é   c              3   óÚ   "  € T Fa  p\         ;QJ d0    R  \        P                  ! V4       4       F  '       g   K   RM%	  RM!! R  \        P                  ! V4       4       4      x € Kc  	  R# 5i)c              3   óž   "  € T FC  p\        V\        4      ;'       g'    VP                  ;'       d    VP                  \        J x € KE  	  R # 5i©N)r6   r   Úis_PowÚbase)Ú.0Úais   & r0   Ú	<genexpr>Ú8TR2i.<locals>.f.<locals>.ok.<locals>.<genexpr>.<genexpr>Š   s=   é € ð ,Ù*�Bô # 2¤sÓ+×KÐK¨r¯y©y×/KÐ/K¸R¿W¹WÌ¸^ÔKÛ*ùs   ‚AžA²ATFN)Úanyr   Ú	make_args)rL   r:   s   & r0   rN   Ú.TR2i.<locals>.f.<locals>.ok.<locals>.<genexpr>Š   sU   é € ð =Ù5;°÷ “Cñ ,ÜŸ-š-¨Ô*ó,—C—C’Cñ ,ÜŸ-š-¨Ô*ó,÷ ,ð ,Û5;ùs   ‚A+’%A+º1A+TF)	Ú
is_integerÚis_positiveÚfuncr   r   Úis_AddÚlenr7   rP   )ÚkÚeÚhalfs   &&€r0   ÚokÚTR2i.<locals>.f.<locals>.okƒ   sÁ   ø€ ð —‘×.Ð. §¡÷ ?ð ?Ø—‘œ3¤˜*Ñ$÷ >ð >¨÷ *=ð *=Ø—‘÷*=ð *=ä�A—F‘F“˜qÑ ÷*=ð *=÷ “ñ =Ø56·V²Vó=—”ð@ò
 ð@ð
 ñ =Ø56·V²Vó=ó =ð@r2   c                 óô  <€ . pV  Fk  pVP                   '       g   K  \        VP                  4      ^8”  g   K3  S'       d   \        V4      M
\	        V4      pWC8w  g   KY  VP                  W434       Km  	  V'       d|   \        V4       F  w  pw  r4W WBV&   K  	  \        V!  P                  4       pV F>  pW,          W#,          ,           pS! W64      '       d   W`V&   K,  VP                  W634       K@  	  ?R# R# )é   N)	rV   rW   r7   r&   r	   ÚappendÚ	enumerater   Úas_powers_dict)	ÚdÚddoneÚnewkrX   ÚknewÚiÚvrZ   r[   s	   &&     €€r0   Ú	factorizeÚ"TR2i.<locals>.f.<locals>.factorize™   sÅ   ø€ ØˆDÛ�Ø—8—8’8¤ A§F¡F£¨a¦ß(,œ6 !œ9´,¸q³/�DØ–yØŸ™ Q IÖ.ñ	 ÷
 Ü$-¨d¦O‘L�A‘y˜Ø˜Ø"˜“Gñ %4ô ˜D‘z×0Ñ0Ó2�Û�AØ�˜t�w��AÙ˜!—x’xØ ˜!›àŸ™ a VÖ,ñ ò ñ r2   F©ÚevaluateN)Úis_MulÚas_numer_denomÚis_Atomra   ÚlistÚkeysÚpopr6   r   r   r7   r_   r   rV   r   r8   rS   rT   r   Úitems)r/   Únrb   rX   Úndonerc   rh   Útr:   Úa1ÚbrY   r[   rZ   s   &           @€r0   r;   ÚTR2i.<locals>.f{   s„  ù€ Ø�y�yˆyØˆIà× Ñ Ó"‰ˆØ�9�9ˆ9˜Ÿ	Ÿ	˜	ØˆIõ	@ð ×ÑÓˆÜ(,¨Q¯V©V«X¬ÓJ© 1¹bÀÀaÅD¿k”�!—U‘U˜1“X“©ˆÐJßØˆIà×ÑÓˆÜ(,¨Q¯V©V«X¬ÓJ© 1¹bÀÀaÅD¿k”�!—U‘U˜1“X“©ˆÐJßØˆIö	ñ& 	�!ÔÙ�!Ôð ˆÜˆAÜ˜!œS×!Ò!Ü˜Ÿ™˜q�	¨EÔ2�Ø”6˜a�d a¥dœlØ—H‘HœS §¡¨¥›^¨Q­TÕ1Ô2Ø"&Ð&�A‘D˜1›4ßØ˜Q��BØ”w 1¥5¨A­D¤=ØŸ™¤# a§f¡f¨Q¥i°¥kÓ"2°QµTÕ!9Ô:Ø'+Ð+˜™˜qœuò $1’wò ô
 ˜Aœs×#Ò#Ü˜Ÿ™˜q�	¨EÔ2�Ø”6˜a�d a¥dœlØ—H‘HœS §¡¨¥›^¨a­d¨UÕ2Ô3Ø"&Ð&�A‘D˜1œ4ò +’6÷ ’˜!Ÿ(Ÿ(›( q§v¡v¨a¥y´A·E±EÖ'9Ü˜qŸv™v a�y¬#×.Õ.Ü˜Ÿ™˜q�	Ÿ™ qÕ)°EÔ:�Ø—6˜a�d a¥dŸl°µ··°ØŸŸ›Ø—H‘HœS §¡¨¥¨1¥Ó-°µ¨uÕ4Ô5Ø"&Ð&�A‘D˜1œ4ñ- ÷0 Ü�q¯W©W¬YÔ<©Y¡T Q¼!œD˜AŸD˜D©YÒ<Õ<Ñ>Ü q§w¡w¤yÔ6¡y™t˜q´A”d�a—d�d¡yÒ6Ñ7õ8ˆBà”#©Ô/©¡ ˜Ÿ˜©Ò/Ñ0´ÉÔ6NÉÁÀ°q·t°tÉÒ6NÑ1OÕOÕOˆBàˆ	ùòA Kùò
 Kùón =ùÛ6ùÛ/ùÓ6Ns<   Â T ÂT Ã)TÄTÑT
ÑT
ÒTÒTÒ7TÓTr   )r/   rZ   r;   s   &f r0   ÚTR2iry   _   s   ø€ õ8Sôj �RÓÐr2   c                óZ   a€ ^ RI Ho V3R lpV P                  R R 4      p \        W4      # )a  Induced formula: example sin(-a) = -sin(a)

Examples
========

>>> from sympy.simplify.fu import TR3
>>> from sympy.abc import x, y
>>> from sympy import pi
>>> from sympy import cos
>>> TR3(cos(y - x*(y - x)))
cos(x*(x - y) + y)
>>> cos(pi/2 + x)
-sin(x)
>>> cos(30*pi/2 + x)
-cos(x)

©Úsignsimpc                 ó¼  <€ \        V \        4      '       g   V # V P                  S! V P                  ^ ,          4      4      p \        V \        4      '       g   V # V P                  ^ ,          \        P
                  ^,          ,
          P                  \        P
                  ^,          V P                  ^ ,          ,
          P                  u;J d   RJ dˆ   M V # \        \        \        \        \        \        \        \        \        \        \        \        /pV\        V 4      ,          ! \        P
                  ^,          V P                  ^ ,          ,
          4      p V # ©r   T)r6   r$   rU   r7   r   ÚPirT   r   r   r   r    r!   r"   Útype)r/   Úfmapr|   s   & €r0   r;   ÚTR3.<locals>.fï   sÛ   ø€ Ü˜"Ô3×4Ò4ØˆIØ�W‰W‘X˜bŸg™g a�jÓ)Ó*ˆÜ˜"Ô3×4Ò4ØˆIØ�G‰G�A�JœŸ™˜a�Õ×,Ñ,´·±°aµ¸"¿'¹'À!½*Õ1D×0QÑ0QÕYÐUYÕYð ˆ	ô œœc¤3¬¬S´#´s¼CÄÄcÌ3ÐOˆDØ”d˜2“h–¤§¡ Q¥¨¯©°­Õ 3Ó4ˆBØˆ	r2   c                 ó"   € \        V \        4      # rI   )r6   r$   ©Úxs   &r0   Ú<lambda>ÚTR3.<locals>.<lambda>ü   s   € ”*˜QÔ 5Ô6r2   c                 ó*   € V P                  R  R 4      # )c                 óB   € V P                   ;'       d    V P                  # rI   )Ú	is_numberrl   ©rs   s   &r0   r†   Ú'TR3.<locals>.<lambda>.<locals>.<lambda>þ   s   € �a—k‘k×.Ð. a§h¡hÐ.r2   c                 ó6   € V P                   ! V P                  !  # rI   ©rU   r7   r‹   s   &r0   r†   rŒ   ÿ   s   € �a—f’f˜aŸf™f’or2   ©Úreplacer„   s   &r0   r†   r‡   ý   s   € �!—)‘)Ù.Ù%ô'r2   )Úsympy.simplify.simplifyr|   r�   r   )r/   r;   r|   s   & @r0   ÚTR3r’   Ó   s2   ø€ õ$ 1õ	ð 
�‰Ù6ñ	'ó
(€Bô �RÓÐr2   c                ó*   € V P                  R R 4      # )aT  Identify values of special angles.

    a=  0   pi/6        pi/4        pi/3        pi/2
----------------------------------------------------
sin(a)  0   1/2         sqrt(2)/2   sqrt(3)/2   1
cos(a)  1   sqrt(3)/2   sqrt(2)/2   1/2         0
tan(a)  0   sqt(3)/3    1           sqrt(3)     --

Examples
========

>>> from sympy import pi
>>> from sympy import cos, sin, tan, cot
>>> for s in (0, pi/6, pi/4, pi/3, pi/2):
...    print('%s %s %s %s' % (cos(s), sin(s), tan(s), cot(s)))
...
1 0 0 zoo
sqrt(3)/2 1/2 sqrt(3)/3 sqrt(3)
sqrt(2)/2 sqrt(2)/2 1 1
1/2 sqrt(3)/2 sqrt(3) sqrt(3)/3
0 1 zoo 0
c                 ó´   € \        V \        4      ;'       dB    V P                  ^ ,          \        ,          ;pP                  ;'       d    VP
                  R9   # )r   )r^   rF   é   é   é   )r6   r$   r7   r   Úis_RationalÚq)r…   Úrs   & r0   r†   ÚTR4.<locals>.<lambda>  sP   € Ü�qÔ/Ó0÷ Eð EØ—‘�q•	œ"•ˆ_ˆQ×)Ñ)÷Eð EØ./¯c©c°_Ñ.DðEr2   c                 ó˜   € V P                  V P                  ^ ,          P                   ! V P                  ^ ,          P                  !  4      # r5   rŽ   r„   s   &r0   r†   r›      s+   € Ø�F‰F�1—6‘6˜!•9—>’> 1§6¡6¨!¥9§>¡>Ñ2Ô3r2   r�   r.   s   &r0   ÚTR4r�     s    € ð0 �:‰:ñ	Eñ	4ó	5ð 5r2   c                ó6   aaaaa€ VVVVV3R lp\        W4      # )aÛ  Helper for TR5 and TR6 to replace f**2 with h(g**2)

Options
=======

max :   controls size of exponent that can appear on f
        e.g. if max=4 then f**4 will be changed to h(g**2)**2.
pow :   controls whether the exponent must be a perfect power of 2
        e.g. if pow=True (and max >= 6) then f**6 will not be changed
        but f**8 will be changed to h(g**2)**4

>>> from sympy.simplify.fu import _TR56 as T
>>> from sympy.abc import x
>>> from sympy import sin, cos
>>> h = lambda x: 1 - x
>>> T(sin(x)**3, sin, cos, h, 4, False)
(1 - cos(x)**2)*sin(x)
>>> T(sin(x)**6, sin, cos, h, 6, False)
(1 - cos(x)**2)**3
>>> T(sin(x)**6, sin, cos, h, 6, True)
sin(x)**6
>>> T(sin(x)**8, sin, cos, h, 10, True)
(1 - cos(x)**2)**4
c                 ó  <€ V P                   '       d   V P                  P                  S8X  g   V # V P                  P                  '       g   V # V P                  ^ 8  R8X  d   V # V P                  S8„  R8X  d   V # V P                  ^8X  d   V # V P                  ^8X  d1   S! S! V P                  P
                  ^ ,          4      ^,          4      # V P                  ^,          ^8X  ds   V P                  ^,          pS! V P                  P
                  ^ ,          4      S! S! V P                  P
                  ^ ,          4      ^,          4      V,          ,          # V P                  ^8X  d   ^pMiS'       g0   V P                  ^,          '       d   V # V P                  ^,          pM2\        V P                  4      pV'       g   V # V P                  ^,          pS! S! V P                  P
                  ^ ,          4      ^,          4      V,          # r~   )rJ   rK   rU   ÚexpÚis_realr7   r%   )r/   rY   Úpr;   ÚgÚhÚmaxÚpows   &  €€€€€r0   Ú_fÚ_TR56.<locals>._f>  sm  ø€ ð
 —	—	�	˜bŸg™gŸl™l¨aÔ/ØˆIØ�v‰v�~�~ˆ~ØˆIà�F‰F�Q‰J˜4ÔØˆIØ�F‰F�S‰L˜TÔ!ØˆIØ�6‰6�QŒ;ØˆIØ�6‰6�QŒ;Ù‘Q�r—w‘w—|‘| A•Ó'¨Õ*Ó+Ð+à�v‰v˜�z˜QŒØ—F‘F˜A•I�Ù˜Ÿ™Ÿ™ a�Ó)©!©A¨b¯g©g¯l©l¸1­oÓ,>ÀÕ,AÓ*BÀAÕ*EÕEÐEØ—‘˜1”Ø‘ßØ—6‘6˜A—:”:Ø�IØ—F‘F˜A•I‘ä! "§&¡&Ó)�ßØ�IØ—F‘F˜A•I�Ù‘Q�r—w‘w—|‘| A•Ó'¨Õ*Ó+¨QÕ.Ð.r2   r   )r/   r;   r£   r¤   r¥   r¦   r§   s   &fffff r0   Ú_TR56r©   $  s   ü€ ÷4!/ñ !/ôF �RÓÐr2   c           	     ó4   € \        V \        \        R WR7      # )aM  Replacement of sin**2 with 1 - cos(x)**2.

See _TR56 docstring for advanced use of ``max`` and ``pow``.

Examples
========

>>> from sympy.simplify.fu import TR5
>>> from sympy.abc import x
>>> from sympy import sin
>>> TR5(sin(x)**2)
1 - cos(x)**2
>>> TR5(sin(x)**-2)  # unchanged
sin(x)**(-2)
>>> TR5(sin(x)**4)
(1 - cos(x)**2)**2
c                 ó   € ^V ,
          # ©r^   © r„   s   &r0   r†   ÚTR5.<locals>.<lambda>v  ó   € ¨¨Q®r2   ©r¥   r¦   )r©   r   r   ©r/   r¥   r¦   s   &&&r0   ÚTR5r²   d  ó   € ô$ �”Sœ#™°CÔAÐAr2   c           	     ó4   € \        V \        \        R WR7      # )aL  Replacement of cos**2 with 1 - sin(x)**2.

See _TR56 docstring for advanced use of ``max`` and ``pow``.

Examples
========

>>> from sympy.simplify.fu import TR6
>>> from sympy.abc import x
>>> from sympy import cos
>>> TR6(cos(x)**2)
1 - sin(x)**2
>>> TR6(cos(x)**-2)  #unchanged
cos(x)**(-2)
>>> TR6(cos(x)**4)
(1 - sin(x)**2)**2
c                 ó   € ^V ,
          # r¬   r­   r„   s   &r0   r†   ÚTR6.<locals>.<lambda>‹  r¯   r2   r°   )r©   r   r   r±   s   &&&r0   ÚTR6r·   y  r³   r2   c                ó   € R p\        W4      # )zßLowering the degree of cos(x)**2.

Examples
========

>>> from sympy.simplify.fu import TR7
>>> from sympy.abc import x
>>> from sympy import cos
>>> TR7(cos(x)**2)
cos(2*x)/2 + 1/2
>>> TR7(cos(x)**2 + 1)
cos(2*x)/2 + 3/2

c                 ó   € V P                   '       d1   V P                  P                  \        8X  d   V P                  ^8X  g   V # ^\        ^V P                  P
                  ^ ,          ,          4      ,           ^,          # ©rF   )rJ   rK   rU   r   r    r7   r.   s   &r0   r;   ÚTR7.<locals>.fž  sO   € Ø—	—	�	˜bŸg™gŸl™l¬cÔ1°b·f±fÀ´kØˆIØ”C˜˜"Ÿ'™'Ÿ,™, q�/Õ)Ó*Õ*¨AÕ-Ð-r2   r   r=   s   & r0   ÚTR7r¼   Ž  s   € ò .ô
 �RÓÐr2   c                ó&   a€ V3R lp\        W4      # )aA  Converting products of ``cos`` and/or ``sin`` to a sum or
difference of ``cos`` and or ``sin`` terms.

Examples
========

>>> from sympy.simplify.fu import TR8
>>> from sympy import cos, sin
>>> TR8(cos(2)*cos(3))
cos(5)/2 + cos(1)/2
>>> TR8(cos(2)*sin(3))
sin(5)/2 + sin(1)/2
>>> TR8(sin(2)*sin(3))
-cos(5)/2 + cos(1)/2
c                 ó 
  <€ V P                   '       gr   V P                  '       d^   V P                  P                  \        \
        39   d9   V P                  P                  '       g   V P                  P                  '       g   V # S'       dî   V P                  4        Uu. uF  p\        V4      NK  	  upw  r#\        VR R7      p\        VR R7      pWB8w  g   WS8w  d›   \        WE,          4      p V P                   '       dx   V P                  ^ ,          P                  '       dU   \        V P                  4      ^8X  d;   V P                  ^,          P                   '       d   \#        V P%                  4       !  p V # \        . \
        . R. /p\"        P&                  ! V 4       EF*  pVP                  \        \
        39   d5   V\)        V4      ,          P+                  VP                  ^ ,          4       KS  VP                  '       d®   VP                  P,                  '       d’   VP                  ^ 8”  d�   VP                  P                  \        \
        39   d\   V\)        VP                  4      ,          P/                  VP                  P                  ^ ,          .VP                  ,          4       EK  VR,          P+                  V4       EK-  	  V\        ,          pV\
        ,          p	V'       d	   V	'       g#   \        V4      ^8”  g   \        V	4      ^8”  g   V # VR,          p\1        \        V4      \        V	4      4      p\3        V4       F`  pV	P5                  4       p
VP5                  4       pVP+                  \        W«,           4      \        W«,
          4      ,           ^,          4       Kb  	  \        V4      ^8”  d`   VP5                  4       p
VP5                  4       pVP+                  \	        W«,           4      \	        W«,
          4      ,           ^,          4       Ko  V'       d)   VP+                  \	        VP5                  4       4      4       \        V	4      ^8”  da   V	P5                  4       p
V	P5                  4       pVP+                  \	        W«,           4      ) \	        W«,
          4      ,           ^,          4       Kp  V	'       d)   VP+                  \        V	P5                  4       4      4       \        \        \#        V!  4      4      # u upi )F©ÚfirstN)rl   rJ   rK   rU   r   r   r    rS   rT   rm   r
   ÚTR8r   r7   r˜   rW   rV   r   Úas_coeff_MulrQ   r€   r_   Ú
is_IntegerÚextendÚminÚrangerq   )r/   rf   rs   rb   ÚnewnÚnewdr7   r:   ÚcÚsrv   Úa2rÀ   s   &           €r0   r;   ÚTR8.<locals>.f·  s3  ø€ à�I�IˆIØ�I�IˆIØ�G‰G�L‰LœS¤#˜JÔ&Ø�V‰V××Ð "§'¡'×"5×"5Ð"5ØˆIçØ+-×+<Ñ+<Ô+>Ó?Ñ+> a”J˜q–MÑ+>Ñ?‰DˆAÜ�q Ô&ˆDÜ�q Ô&ˆDØŒy˜DœIÜ˜t�yÓ)�Ø—9—9�9 §¡¨¥×!7×!7Ð!7Ü˜BŸG™G›¨Ô)¨b¯g©g°a­j×.?×.?Ð.?Ü˜bŸo™oÓ/Ñ0�BØˆIä�Rœ˜b $¨Ð+ˆÜ—’˜r×"ˆAØ�v‰vœ#œs˜Ô#Ø”T˜!“W•×$Ñ$ Q§V¡V¨A¥YÖ/Ø—(—(�(˜qŸu™u×/×/Ð/°A·E±E¸A´IØ—F‘F—K‘K¤C¬ :Ô-ð ”T˜!Ÿ&™&“\Õ"×)Ñ)¨1¯6©6¯;©;°q­>Ð*:¸1¿5¹5Õ*@×Aà�T•
×!Ñ! !×$ñ #ð ”�IˆØ”�Iˆß—aœ3˜q›6 Aœ:¬¨Q«°!¬ØˆIà�D�zˆÜ”�A“œ˜A›ÓˆÜ�q–ˆAØ—‘“ˆBØ—‘“ˆBØ�K‰Kœ˜R�W›¬¨B­G«Õ4°aÕ7Ö8ñ ô �!‹f�qŒjØ—‘“ˆBØ—‘“ˆBØ�K‰Kœ˜R�W›¬¨B­G«Õ4°aÕ7Ö8ßØ�K‰Kœ˜AŸE™E›G›Ô%Ü�!‹f�qŒjØ—‘“ˆBØ—‘“ˆBØ�K‰Kœ#˜b�g›,˜¬¨R­W«Õ5°qÕ8Ö9ßØ�K‰Kœ˜AŸE™E›G›Ô%Ü”:œc 4™jÓ)Ó*Ð*ùòY @s   ÂTr   ©r/   rÀ   r;   s   &f r0   rÁ   rÁ   ¦  s   ø€ õ"5+ôn �RÓÐr2   c                ó   € R p\        W4      # )a'  Sum of ``cos`` or ``sin`` terms as a product of ``cos`` or ``sin``.

Examples
========

>>> from sympy.simplify.fu import TR9
>>> from sympy import cos, sin
>>> TR9(cos(1) + cos(2))
2*cos(1/2)*cos(3/2)
>>> TR9(cos(1) + 2*sin(1) + 2*sin(2))
cos(1) + 4*sin(3/2)*cos(1/2)

If no change is made by TR9, no re-arrangement of the
expression will be made. For example, though factoring
of common term is attempted, if the factored expression
was not changed, the original expression will be returned:

>>> TR9(cos(3) + cos(3)*cos(2))
cos(3) + cos(2)*cos(3)

c                 óT   a€ V P                   '       g   V # RV3R llo\        V S4      # )Tc                 óä  <€ V P                   '       g   V # \        \        V P                  4      4      p\	        V4      ^8w  dÆ   Rp\        \	        V4      4       Fe  pW$,          pVf   K  \        V^,           \	        V4      4       F4  pW&,          pVf   K  WW,           pS! V4      p	W˜8w  g   K)  W’V&   RW&&   Rp Kc  	  Kg  	  V'       d=   \        V U
u. uF  qª'       g   K  V
NK  	  up
!  p V P                   '       d	   S! V 4      p V # \        V!  pV'       g   V # Vw  rÍrïppV'       d¢   WÞ8X  dL   WÍ,          ^,          \        VV,           ^,          4      ,          \        VV,
          ^,          4      ,          # V^ 8  d   TTppRV,          \        VV,           ^,          4      ,          \        VV,
          ^,          4      ,          # WÞ8X  dL   WÍ,          ^,          \        VV,           ^,          4      ,          \        VV,
          ^,          4      ,          # V^ 8  d   TTpp^V,          \        VV,           ^,          4      ,          \        VV,
          ^,          4      ,          # u up
i )rF   FNTéþÿÿÿ©
rV   ro   r   r7   rW   rÆ   r   Ú
trig_splitr   r   )r/   rÀ   r7   Úhitrf   rM   ÚjÚajÚwasÚnewr§   ÚsplitÚgcdÚn1Ún2r:   rw   ÚiscosÚdos   &&                €r0   rÞ   ÚTR9.<locals>.f.<locals>.do  sî  ø€ ð —9—9�9Ø�	äœ §¡Ó(Ó)ˆDÜ�4‹y˜AŒ~Ø�Üœs 4›yÖ)�AØ��BØ’zÙ Ü" 1 q¥5¬#¨d«)Ö4˜Ø!�W˜Øš:Ù$Ø �g˜Ù  ›g˜Øž:Ø&) ™GØ&*˜D™GØ"&˜CÚ!ó 5ñ	 *÷ Ü©DÓ7©D b³BŸr˜r©DÑ7Ñ8�BØ—y—y�yÙ ›V˜à�	ô  Ñ%ˆEßØ�	Ø',Ñ$ˆC�R˜A˜u÷ Ø”8Ø�6 !�8¤C¨¨Q­°­	£NÕ2´3¸¸A½¸qµy³>ÕAÐAØ˜”6Ø˜a�q�AØ˜#•vœc 1 q¥5¨!¥)›nÕ,¬S°!°aµ%¸µ«^Õ;Ð;à”8Ø�6 !�8¤C¨¨Q­°­	£NÕ2´3¸¸A½¸qµy³>ÕAÐAØ˜”6Ø˜a�q�AØ˜•uœS ! a¥%¨¥›^Õ+¬C°°Qµ¸µ	«NÕ:Ð:ùò1 8s   Ã	I-Ã"I-©T)rV   Úprocess_common_addends)r/   rÞ   s   &@r0   r;   ÚTR9.<locals>.f  s&   ø€ Ø�y�yˆyØˆI÷<	;ô| & b¨"Ó-Ð-r2   r   r=   s   & r0   ÚTR9rã   ñ  s   € ò.B.ôH �RÓÐr2   c                ó&   a€ V3R lp\        W4      # )aw  Separate sums in ``cos`` and ``sin``.

Examples
========

>>> from sympy.simplify.fu import TR10
>>> from sympy.abc import a, b, c
>>> from sympy import cos, sin
>>> TR10(cos(a + b))
-sin(a)*sin(b) + cos(a)*cos(b)
>>> TR10(sin(a + b))
sin(a)*cos(b) + sin(b)*cos(a)
>>> TR10(sin(a + b + c))
(-sin(a)*sin(b) + cos(a)*cos(b))*sin(c) +     (sin(a)*cos(b) + sin(b)*cos(a))*cos(c)
c                 óê  <€ V P                   \        \        39  d   V # V P                   pV P                  ^ ,          pVP                  '       Ed£   S'       d    \        \        VP                  4      4      pM\        VP                  4      pVP                  4       p\        P                  ! V4      pVP                  '       d®   V\        8X  dR   \        V4      \        \        V4      RR7      ,          \        V4      \        \        V4      RR7      ,          ,           # \        V4      \        \        V4      RR7      ,          \        V4      \        \        V4      RR7      ,          ,
          # V\        8X  d<   \        V4      \        V4      ,          \        V4      \        V4      ,          ,           # \        V4      \        V4      ,          \        V4      \        V4      ,          ,
          # V # ©r   Fr¿   )rU   r   r   r7   rV   ro   r   rq   r   Ú
_from_argsÚTR10)r/   r;   Úargr7   r:   rw   rÀ   s   &     €r0   r;   ÚTR10.<locals>.fa  sI  ø€ Ø�7‰7œ3¤˜*Ô$ØˆIà�G‰GˆØ�g‰g�a�jˆØ�:�:‰:ßÜœG C§H¡HÓ-Ó.‘ä˜CŸH™H“~�Ø—‘“
ˆAÜ—’˜tÓ$ˆAØ�x�xˆxØœ”8Ü˜q›6¤$¤s¨1£v°UÔ";Õ;Ü˜A›œt¤C¨£F°%Ô8Õ8õ9ð 9ô ˜q›6¤$¤s¨1£v°UÔ";Õ;Ü˜A›œt¤C¨£F°%Ô8Õ8õ9ð 9ð œ”8Ü˜q›6¤# a£&�=¬3¨q«6´#°a³&­=Õ8Ð8ä˜q›6¤# a£&�=¬3¨q«6´#°a³&­=Õ8Ð8Øˆ	r2   r   rÍ   s   &f r0   rè   rè   O  s   ø€ õ$ô6 �RÓÐr2   c                ó   € R p\        W4      # )a^  Sum of products to function of sum.

Examples
========

>>> from sympy.simplify.fu import TR10i
>>> from sympy import cos, sin, sqrt
>>> from sympy.abc import x

>>> TR10i(cos(1)*cos(3) + sin(1)*sin(3))
cos(2)
>>> TR10i(cos(1)*sin(3) + sin(1)*cos(3) + cos(3))
cos(3) + sin(4)
>>> TR10i(sqrt(2)*cos(x)*x + sqrt(6)*sin(x)*x)
2*sqrt(2)*x*sin(x + pi/6)

c                 ó.  a€ V P                   '       g   V # RV3R llo\        V SR 4      p V P                   '       EdL   \        \        4      pV P                   FÅ  p^ pVP
                  '       d   VP                   Fn  pVP                  '       g   K  VP                  \        P                  J g   K7  VP                  P                  '       g   KU  W,          P                  V4       ^p M	  V'       d   KŸ  V\        P                  ,          P                  V4       KÇ  	  . pV Fù  p\        4       V,          \        4       3 F×  pWa9   g   K  \!        \#        W,          4      4       F®  pW,          V,          f   K  \!        \#        W,          4      4       Fz  pW,          V,          f   K  \%        W,          V,          W,          V,          ,           4      p	S! V	4      p
W©8w  g   KR  VP                  V
4       RW,          V&   RW,          V&    K¬  	  K°  	  KÙ  	  Kû  	  V'       dT   \%        TVP'                  4        UUu. uF%  p\%        V Uu. uF  qÌ'       g   K  VNK  	  up!  NK'  	  upp,           !  p EKS  S! V 4      p  V # V # u upi u uppi )Tc                 ód  <€ V P                   '       g   V # \        \        V P                  4      4      p\	        V4      ^8w  dÆ   Rp\        \	        V4      4       Fe  pW$,          pVf   K  \        V^,           \	        V4      4       F4  pW&,          pVf   K  WW,           pS! V4      p	W˜8w  g   K)  W’V&   RW&&   Rp Kc  	  Kg  	  V'       d=   \        V U
u. uF  qª'       g   K  V
NK  	  up
!  p V P                   '       d	   S! V 4      p V # \        VRR/ pV'       g   V # Vw  rÍrïppV'       dA   WÜ,          pWÞ8X  d   V\        VV,
          4      ,          # V\        VV,           4      ,          # WÜ,          pWÞ8X  d   V\        VV,           4      ,          # V\        VV,
          4      ,          # u up
i )rF   FNTÚtworÒ   )r/   rÀ   r7   rÔ   rf   rM   rÕ   rÖ   r×   rØ   r§   rÙ   rÚ   rÛ   rÜ   r:   rw   ÚsamerÞ   s   &&                €r0   rÞ   ÚTR10i.<locals>.f.<locals>.do•  su  ø€ ð —9—9�9Ø�	äœ §¡Ó(Ó)ˆDÜ�4‹y˜AŒ~Ø�Üœs 4›yÖ)�AØ��BØ’zÙ Ü" 1 q¥5¬#¨d«)Ö4˜Ø!�W˜Øš:Ù$Ø �g˜Ù  ›g˜Øž:Ø&) ™GØ&*˜D™GØ"&˜CÚ!ó 5ñ	 *÷ Ü©DÓ7©D b³BŸr˜r©DÑ7Ñ8�BØ—y—y�yÙ ›V˜à�	ô  Ð/¨$Ñ/ˆEßØ�	Ø&+Ñ#ˆC�R˜A˜t÷ Ø•f�Ø”8Øœs 1 q¥5›z�>Ð)Øœ3˜q 1�u›:•~Ð%à•f�Ø”8Øœs 1 q¥5›z�>Ð)Øœ3˜q 1�u›:•~Ð%ùò- 8s   Ã	F-Ã"F-c                 ó>   € \        \        V P                  4      4      # rI   )Útupler   Úfree_symbolsr„   s   &r0   r†   Ú"TR10i.<locals>.f.<locals>.<lambda>Î  s   € œe¤G¨A¯N©NÓ$;Ô<r2   Nrà   )rV   rá   r   ro   r7   rl   rJ   r    r   ÚHalfrK   rÃ   r_   r8   Ú_ROOT3Ú	_invROOT3rÆ   rW   r   Úvalues)r/   Úbyradr:   rÔ   rM   r7   rw   rf   rÕ   r×   rØ   rg   r§   rÞ   s   &            @r0   r;   ÚTR10i.<locals>.f‘  sú  ø€ Ø�y�yˆyØˆI÷6	&ôp $Ø�Ñ<ó>ˆð
 �i�i‰iÜ¤Ó%ˆEØ—W”W�Ø�Ø—8—8�8ØŸfœf˜ØŸ9Ÿ9š9¨¯©´1·6±6Õ)9Ø "§¡× 2× 2Ò 2Ø!�I×,Ñ,¨QÔ/Ø"#˜CÙ!ñ %÷ ‘sØœ!Ÿ%™%•L×'Ñ'¨Ö*ñ ð ˆDÛ�Ü ›( 1�*¤i£kÓ2�AØ–zÜ!&¤s¨5­8£}Ö!5˜AØ$�x¨�{Ò2Ù (Ü%*¬3¨u­x«=Ö%9 Ø#(¥8¨A¥;Ò#6Ù$,Ü&)¨%­(°1­+¸½À½Õ*CÓ&D Ù&(¨£g Ø#&¦:Ø$(§K¡K°Ô$4Ø26 E¥H¨Q¡KØ26 E¥H¨Q¡KÚ$)ó &:ó "6ó 3ñ ÷  Ü˜4Ø"Ÿ\™\œ^ô#-Ù+˜ô $'±aÓ(>±a°»2¯¨±aÑ(>Ô#?Ù+ò#-õ -ñ /“ñ ˜“V�Øàˆ	ˆrˆ	ùò )?ùó #-s   ÉJÉ	JÉ!JÉ'	JÊJr   r=   s   & r0   ÚTR10irû     s   € ò$iôV �RÓÐr2   Nc                ó&   a€ V3R lp\        W4      # )aö  Function of double angle to product. The ``base`` argument can be used
to indicate what is the un-doubled argument, e.g. if 3*pi/7 is the base
then cosine and sine functions with argument 6*pi/7 will be replaced.

Examples
========

>>> from sympy.simplify.fu import TR11
>>> from sympy import cos, sin, pi
>>> from sympy.abc import x
>>> TR11(sin(2*x))
2*sin(x)*cos(x)
>>> TR11(cos(2*x))
-sin(x)**2 + cos(x)**2
>>> TR11(sin(4*x))
4*(-sin(x)**2 + cos(x)**2)*sin(x)*cos(x)
>>> TR11(sin(4*x/3))
4*(-sin(x/3)**2 + cos(x/3)**2)*sin(x/3)*cos(x/3)

If the arguments are simply integers, no change is made
unless a base is provided:

>>> TR11(cos(2))
cos(2)
>>> TR11(cos(4), 2)
-sin(2)**2 + cos(2)**2

There is a subtle issue here in that autosimplification will convert
some higher angles to lower angles

>>> cos(6*pi/7) + cos(3*pi/7)
-cos(pi/7) + cos(3*pi/7)

The 6*pi/7 angle is now pi/7 but can be targeted with TR11 by supplying
the 3*pi/7 base:

>>> TR11(_, 3*pi/7)
-sin(3*pi/7)**2 + cos(3*pi/7)**2 + cos(3*pi/7)

c                 ó  <€ V P                   \        \        39  d   V # S'       dí   V P                   pV! S^,          4      p\        P                  pVP
                  '       d   VP                  4       w  r2VP                   \        \        39  d   V # V P                  ^ ,          VP                  ^ ,          8X  dV   \        S4      p\        S4      pV\        J d   V^,          V^,          ,
          V,          # ^V,          V,          V,          # V # V P                  ^ ,          P                  '       gÏ   V P                  ^ ,          P                  RR7      w  rFVP                  ^,          ^ 8X  d’   VP                  ^,          V,          VP                  ,          p\        \        V4      4      p\        \        V4      4      pV P                   \        8X  d   ^V,          V,          p V # V^,          V^,          ,
          p V # )rF   T)Úrational)rU   r   r   r   r8   rl   rÂ   r7   Ú	is_Numberr¢   r™   ÚTR11)	r/   r;   ru   ÚcorÉ   rÊ   Úmré   rK   s	   &       €r0   r;   ÚTR11.<locals>.f)  sp  ø€ Ø�7‰7œ3¤˜*Ô$ØˆIçØ—‘ˆAÙ�$�q•&“	ˆAÜ—‘ˆBØ�x�xˆxØŸ™Ó(‘�Ø�v‰vœc¤3˜ZÔ'Ø�	Ø�w‰w�q�z˜QŸV™V A�YÔ&Ü˜“I�Ü˜“I�Øœ“8Ø˜q�D 1 a¥4�K¨Õ+Ð+à˜Q�3˜q�5 �8�OØˆIà—‘˜•×%×%Ð%ð —7‘7˜1•:×*Ñ*°DÐ*Ó9‰DˆAØ�s‰s�Q�w˜!Œ|Ø—c‘c˜1•f˜Q•h˜qŸs™s•l�Üœ˜S›“N�Üœ˜S›“N�Ø—7‘7œc”>Ø˜1�˜Q��Bð ˆ	ð ˜A�  1¥��BØˆ	r2   r   )r/   rK   r;   s   &f r0   r   r   ÿ  s   ø€ õT!ôF �RÓÐr2   c                ó   € R p\        W4      # )a®  
Helper for TR11 to find half-arguments for sin in factors of
num/den that appear in cos or sin factors in the den/num.

Examples
========

>>> from sympy.simplify.fu import TR11, _TR11
>>> from sympy import cos, sin
>>> from sympy.abc import x
>>> TR11(sin(x/3)/(cos(x/6)))
sin(x/3)/cos(x/6)
>>> _TR11(sin(x/3)/(cos(x/6)))
2*sin(x/6)
>>> TR11(sin(x/6)/(sin(x/3)))
sin(x/6)/sin(x/3)
>>> _TR11(sin(x/6)/(sin(x/3)))
1/(2*cos(x/6))

c                 óœ   € \        V \        4      '       g   V # R  p\        WP                  4       4      w  r#R pV! WV4      p V! WV4      p V # )c                 óZ  € \        \        4      p\        P                  ! V 4       F�  pVP	                  4       w  r4VP
                  '       g   K)  V^ 8”  g   K2  VP                  \        \        39   g   KO  V\        V4      ,          P                  VP                  ^ ,          4       Kƒ  	  V# r5   )r   Úsetr   rQ   Úas_base_exprÃ   rU   r   r   r€   Úaddr7   )Úflatr7   Úfirw   rY   s   &    r0   Úsincos_argsÚ%_TR11.<locals>.f.<locals>.sincos_argsh  ss   € ô œsÓ#ˆDÜ—m’m DÖ)�Ø—~‘~Ó'‘�Ø—<—<’< A¨¦EØ—v‘v¤#¤s Ö+ØœT !›W�×)Ñ)¨!¯&©&°­)Ö4ñ	 *ð
 ˆKr2   c                 óè   € V\         ,           F`  pV^,          pWB\        ,          9   d   \        pMWB\         ,          9   d   \         pMK>  \        W4      p W%,          P                  V4       Kb  	  V # rº   )r   r   r   Úremove)r/   Únum_argsÚden_argsÚnargrZ   rU   s   &&&   r0   Úhandle_matchÚ&_TR11.<locals>.f.<locals>.handle_matcht  s^   € ð !¤Ÿ˜�Ø˜A•v�Ø¤C�=Ô(Ü‘DØ¤c�]Ô*Ü‘DáÜ˜"“^�Ø•×%Ñ% dÖ+ñ &ð ˆIr2   )r6   r   Úmaprm   )r/   r  r  r  r  s   &    r0   r;   Ú_TR11.<locals>.fd  sU   € Ü˜"œd×#Ò#ØˆIò
	ô ! ×.?Ñ.?Ó.AÓBÑˆò	ñ  ˜"¨Ó1ˆá˜"¨Ó1ˆØˆ	r2   r   r=   s   & r0   Ú_TR11r  O  s   € ò*#ôJ �RÓÐr2   c                ó&   a€ V3R lp\        W4      # )zÊSeparate sums in ``tan``.

Examples
========

>>> from sympy.abc import x, y
>>> from sympy import tan
>>> from sympy.simplify.fu import TR12
>>> TR12(tan(x + y))
(tan(x) + tan(y))/(-tan(x)*tan(y) + 1)
c                 ó  <€ V P                   \        8X  g   V # V P                  ^ ,          pVP                  '       dÇ   S'       d    \	        \        VP                  4      4      pM\	        VP                  4      pVP                  4       p\        P                  ! V4      pVP                  '       d   \        \        V4      RR7      pM\        V4      p\        V4      V,           ^\        V4      V,          ,
          ,          # V # ræ   )
rU   r   r7   rV   ro   r   rq   r   rç   ÚTR12)r/   ré   r7   r:   rw   ÚtbrÀ   s   &     €r0   r;   ÚTR12.<locals>.f™  s«   ø€ Ø�w‰wœ#Œ~ØˆIà�g‰g�a�jˆØ�:�:ˆ:ßÜœG C§H¡HÓ-Ó.‘ä˜CŸH™H“~�Ø—‘“
ˆAÜ—’˜tÓ$ˆAØ�x�xˆxÜœ#˜a›&¨Ô.‘ä˜“V�Ü˜“F˜R•K !¤c¨!£f¨R¥i¥-Õ0Ð0Øˆ	r2   r   rÍ   s   &f r0   r  r  Œ  s   ø€ õô& �RÓÐr2   c                ó   € R p\        W4      # )a  Combine tan arguments as
(tan(y) + tan(x))/(tan(x)*tan(y) - 1) -> -tan(x + y).

Examples
========

>>> from sympy.simplify.fu import TR12i
>>> from sympy import tan
>>> from sympy.abc import a, b, c
>>> ta, tb, tc = [tan(i) for i in (a, b, c)]
>>> TR12i((ta + tb)/(-ta*tb + 1))
tan(a + b)
>>> TR12i((ta + tb)/(ta*tb - 1))
-tan(a + b)
>>> TR12i((-ta - tb)/(ta*tb - 1))
tan(a + b)
>>> eq = (ta + tb)/(-ta*tb + 1)**2*(-3*ta - 3*tc)/(2*(ta*tc - 1))
>>> TR12i(eq.expand())
-3*tan(a + b)*tan(a + c)/(2*(tan(a) + tan(b) - 1))
c                 óÞ
  € V P                   '       g'   V P                  '       g   V P                  '       g   V # V P                  4       w  rVP                  '       d   VP                  '       g   V # / pR  p\        \        P                  ! V4      4      p\        V4       EF×  w  rgV! V4      pV'       dP   Vw  rš\        V
P                   Uu. uF  q»P                  ^ ,          NK  	  up!  p\        P                  W<&   W•V&   Ke  VP                   '       dO   \        V4      pVP                  '       d0   VP                  VP                  4       \        P                  WV&   KÃ  KÅ  VP                  '       g   KÙ  VP                  P                  '       g    VP                   P"                  '       g   EK  V! VP                   4      pV'       d]   Vw  rš\        V
P                   Uu. uF  q»P                  ^ ,          NK  	  up!  pVP                  W<&   W—P                  ,          WV&   EKŠ  \        V4      pVP                  '       g   EKª  VP                  VP                  4       \        P                  WV&   EKÚ  	  V'       g   V # R p\        \        P                  ! \%        V4      4      4      pRp\        V4       EF  w  roV! V4      pV'       EgK   V! V) 4      pV'       d   \        P&                  WÖ&   EM7VP                   '       dM   \        V4      pVP                  '       d.   VP                  VP                  4       \        P                  WÖ&   Kš  VP                  '       d³   VP                  P                  '       g   VP                   P"                  '       d{   V! VP                   4      pV'       d   \        P                  WÖ&   Mb\        V4      pVP                  '       d.   VP                  VP                  4       \        P                  WÖ&   EK^  EKa  \        P                  WÖ&   Rp\        V Uu. uF  q»P                  ^ ,          NK  	  up!  pW<,          pVP)                  \        P                  4      pVe   V'       d   VW<&   MVP+                  V4       WÖ;;,          \-        V4      ) ,          uu&   EK  	  V'       dƒ   \        V!  \        V!  ,          \        VP/                  4        UUUu. uF@  w  pp\        VP                   Uu. uF  p\-        V4      NK  	  up!  ^,
          V,          NKB  	  uppp!  ,          p V # u upi u upi u upi u upi u upppi )c                 óh  € \        V 4      pV'       dŸ   Vw  r#pV\        P                  J d„   VP                  '       dp   \	        VP
                  4      ^8X  dT   \        ;QJ d&    R VP
                   4       F  '       d   K   RM	  RM! R VP
                   4       4      '       d   W#3# R# R# R# R# R# )rF   c              3   óB   "  € T F  p\        V\        4      x € K  	  R # 5irI   )r6   r   )rL   r  s   & r0   rN   Ú/TR12i.<locals>.f.<locals>.ok.<locals>.<genexpr>Ó  s   é € ÐA¹&°BœJ r¬3×/Ð/»&ùs   ‚FTN)Úas_f_sign_1r   ÚNegativeOnerl   rW   r7   Úall)Údir  r£   r;   rÊ   s   &    r0   r[   ÚTR12i.<locals>.f.<locals>.okÎ  s€   € Ü˜B“ˆAßØ‘��aØœŸ™Ó%¨!¯(¯(¨(´s¸1¿6¹6³{ÀaÔ7Gß›ÑA¸!¿&º&ÓAŸŸšÑA¸!¿&º&ÓA×AÒAØ˜4�Kñ Bñ 8H©(Ñ%ñ r2   c                 óä   € V P                   '       d^   \        V P                  4      ^8X  dB   V P                  w  r\        V\        4      '       d   \        V\        4      '       d   W3# R# R# R# R# )rF   N)rV   rW   r7   r6   r   )Únir:   rw   s   &  r0   r[   r&  ó  sT   € Ø�y�yˆyœS §¡›\¨QÔ.Ø—w‘w‘�Ü˜a¤×%Ò%¬*°Q¼×*<Ò*<Ø˜4�Kñ +=Ñ%ñ /‰yr2   FT)rV   rl   rJ   rm   r7   ro   r   rQ   r`   r   r   r8   r&   rÄ   r    rS   rK   rT   r	   r#  Úextract_additivelyrq   r   rr   )r/   rs   rb   Údokr[   Úd_argsrf   r%  r  r£   ru   Ú_rÊ   Ún_argsrÔ   r(  ÚedÚnewedrY   r:   s   &                   r0   r;   ÚTR12i.<locals>.fÄ  sß  € Ø—	—	�	˜RŸYŸY˜Y¨"¯)¯)¨)ØˆIà× Ñ Ó"‰ˆØ�v�vˆv˜QŸVŸV˜VØˆIàˆò	 ô ”c—m’m AÓ&Ó'ˆÜ˜v×&‰EˆAÙ�2“ˆAßØ‘�Ü¨Q¯VªVÓ4©V¨Ÿ&™& Ÿ)˜)©VÑ4Ñ5�ÜŸ™�‘Ø�q‘	ÙØ�y�yˆyÜ˜B“Z�Ø—9—9�9Ø—M‘M "§'¡'Ô*Ü !§¡�F“Iñ ð ——’ §¡× 1× 1Ð 1°R·W±W×5H×5HÓ5HÙ�r—w‘w“K�ßØ‘D�AÜ°·²Ó8±¨AŸf™f QŸi˜i±Ñ8Ñ9�AØŸV™V�C‘FØ !§6¡6¥	�F”Iä ›�BØ—y—y“yØŸ™ b§g¡gÔ.Ü$%§E¡E˜œ	ñ1 '÷2 ØˆIò	 ô
 ”c—m’m¤L°£OÓ4Ó5ˆØˆÜ˜v×&‰EˆAÙ�2“ˆAß�1Ù˜�s“G�ßÜ !§¡�F“Ià—y—y�yÜ# B›Z˜ØŸ9Ÿ9˜9Ø"ŸM™M¨"¯'©'Ô2Ü()¯©˜F™IÙ ØŸŸ˜ØŸF™F×-×-Ð-°·±×1D×1DÐ1DÙ˜rŸw™w›K˜ßÜ()¯©˜FšIä!'¨£˜BØ!ŸyŸy˜yØ &§¡¨b¯g©gÔ 6Ü,-¯E©E ¡	Ú$â äŸE™E�‘	ØˆCÜ©Ó+© A—f‘f˜Q—i�i©Ñ+Ñ,ˆAØ•ˆBØ×)Ñ)¬!¯%©%Ó0ˆEØÒ ßØ"�C’Fà—G‘G˜A”JØ�Iœ#˜a›&˜Õ ŽIñK '÷N Ü�f‘œc 6™lÕ*¬3Ø=@¿Y¹Y¼[õ1JÙ=H±T°Q¸ô 36Ø !§¢ó8(Ù &˜1”�A–¡ñ8(ñ 3)Ø+,õ3-Ø/0÷21ð 21Ù=Hó1Jñ ,Kõ KˆBð ˆ	ùòU 5ùò 9ùò^ ,ùò8(ùô 1Js*   ÃU
Ç%U
Ð<U
Ó?U(ÔU#Ô.U(Õ#U(r   r=   s   & r0   ÚTR12ir1  ¯  s   € ò*aôF �RÓÐr2   c                ó   € R p\        W4      # )zöChange products of ``tan`` or ``cot``.

Examples
========

>>> from sympy.simplify.fu import TR13
>>> from sympy import tan, cot
>>> TR13(tan(3)*tan(2))
-tan(2)/tan(5) - tan(3)/tan(5) + 1
>>> TR13(cot(3)*cot(2))
cot(2)*cot(5) + 1 + cot(3)*cot(5)
c           	      óê  € V P                   '       g   V # \        . \        . R . /p\        P                  ! V 4       Fj  pVP
                  \        \        39   d5   V\        V4      ,          P                  VP                  ^ ,          4       KR  VR ,          P                  V4       Kl  	  V\        ,          pV\        ,          p\        V4      ^8  d   \        V4      ^8  d   V # VR ,          p\        V4      ^8”  d€   VP                  4       pVP                  4       pVP                  ^\        V4      \        WV,           4      ,          \        V4      \        WV,           4      ,          ,           ,
          4       K�  V'       d)   VP                  \        VP                  4       4      4       \        V4      ^8”  d€   VP                  4       pVP                  4       pVP                  ^\        V4      \        WV,           4      ,          ,           \        V4      \        WV,           4      ,          ,           4       K�  V'       d)   VP                  \        VP                  4       4      4       \        V!  # rI   )rl   r   r    r   rQ   rU   r€   r_   r7   rW   rq   )r/   r7   r:   ru   rÉ   Út1Út2s   &      r0   r;   ÚTR13.<locals>.f8  s”  € Ø�y�yˆyØˆIô �Rœ˜b $¨Ð+ˆÜ—’˜rÖ"ˆAØ�v‰vœ#œs˜Ô#Ø”T˜!“W•×$Ñ$ Q§V¡V¨A¥YÖ/à�T•
×!Ñ! !Ö$ñ	 #ð
 ”�IˆØ”�IˆÜˆq‹6�AŒ:œ#˜a›& 1œ*ØˆIØ�D�zˆÜ�!‹f�qŒjØ—‘“ˆBØ—‘“ˆBØ�K‰K˜œS ›W¤S¨­£\Õ1´C¸³G¼CÀÅ»LÕ4HÕHÕIÖJßØ�K‰Kœ˜AŸE™E›G›Ô%Ü�!‹f�qŒjØ—‘“ˆBØ—‘“ˆBØ�K‰K˜œC ›G¤C¨­£LÕ0Õ0´3°r³7¼3¸r½w»<Õ3GÕGÖHßØ�K‰Kœ˜AŸE™E›G›Ô%Ü�D‰zÐr2   r   r=   s   & r0   ÚTR13r7  *  s   € òô< �RÓÐr2   c                ó,   a€ RV3R llo\        V S4      # )a  Returns cos(x)*cos(2*x)*...*cos(2**(k-1)*x) -> sin(2**k*x)/(2**k*sin(x))

Examples
========

>>> from sympy.simplify.fu import TRmorrie, TR8, TR3
>>> from sympy.abc import x
>>> from sympy import Mul, cos, pi
>>> TRmorrie(cos(x)*cos(2*x))
sin(4*x)/(4*sin(x))
>>> TRmorrie(7*Mul(*[cos(x) for x in range(10)]))
7*sin(12)*sin(16)*cos(5)*cos(7)*cos(9)/(64*sin(1)*sin(3))

Sometimes autosimplification will cause a power to be
not recognized. e.g. in the following, cos(4*pi/7) automatically
simplifies to -cos(3*pi/7) so only 2 of the 3 terms are
recognized:

>>> TRmorrie(cos(pi/7)*cos(2*pi/7)*cos(4*pi/7))
-sin(3*pi/7)*cos(3*pi/7)/(4*sin(pi/7))

A touch by TR8 resolves the expression to a Rational

>>> TR8(_)
-1/8

In this case, if eq is unsimplified, the answer is obtained
directly:

>>> eq = cos(pi/9)*cos(2*pi/9)*cos(3*pi/9)*cos(4*pi/9)
>>> TRmorrie(eq)
1/16

But if angles are made canonical with TR3 then the answer
is not simplified without further work:

>>> TR3(eq)
sin(pi/18)*cos(pi/9)*cos(2*pi/9)/2
>>> TRmorrie(_)
sin(pi/18)*sin(4*pi/9)/(8*sin(pi/9))
>>> TR8(_)
cos(7*pi/18)/(16*sin(pi/9))
>>> TR3(_)
1/16

The original expression would have resolve to 1/16 directly with TR8,
however:

>>> TR8(eq)
1/16

References
==========

.. [1] https://en.wikipedia.org/wiki/Morrie%27s_law

c                 ó<  <€ V P                   '       g   V # V'       d*   V P                  4       w  r#S! V^ 4      S! V^ 4      ,          # \        \        4      p/ p. pV P                   FŽ  pVP                  4       w  r‰V	P                  '       dW   \        V\        4      '       dA   VP                  ^ ,          P                  4       w  r«WK,          P                  V
4       W•V&   K}  VP                  V4       K�  	  . pV EFÅ  pWK,          pVP                  4        V'       g   K&  ^ pV^ ,          ;rïWç9   d   V^,          pV^,          pK  V^8”  Ed3   \        ^V,          V,          V,          4      ^V,          ,          \        Wû,          4      ,          pRp. p\        V4       FT  pV^,          p\        W¾,          RR7      pVP                  V4       \        VV,          T;'       g
    VV,          4      pKV  	  \        V4       F]  pVP                  4       p\        W¾,          RR7      pVV;;,          V,          uu&   VV,          '       d   KL  VP!                  V4       K_  	  VP                  VV,          4       EKj  \        VP                  ^ 4      V,          4      pVP                  W…V,          ,          4       EK¬  	  V'       dI   \#        WÆ,           V UUu. uF%  q´V,           F  p\        WÛ,          RR7      NK  	  K'  	  upp,           !  p V # u uppi )r   NFrj   )rl   rm   r   ro   r7   r  rÃ   r6   r   rÂ   r_   Úsortr   rÆ   rÅ   rq   r  r   )r/   rÀ   rs   rb   r7   ÚcossÚotherrÉ   rw   rY   r  r:   rØ   rX   ÚccÚciÚnewargÚtakeÚccsrf   Úkeyr;   s   &&                   €r0   r;   ÚTRmorrie.<locals>.f”  sc  ø€ Ø�y�yˆyØˆIßØ×$Ñ$Ó&‰DˆAÙ�Q˜“7™1˜Q ›7•?Ð"äœ4Ó ˆØˆØˆØ—”ˆAØ—=‘=“?‰DˆAØ�|�|ˆ|¤
¨1¬c× 2Ò 2ØŸ™˜q�	×.Ñ.Ó0‘�Ø•—‘˜rÔ"Ø�Q“à—‘˜Q–ñ ð ˆÜˆAØ•ˆAØ�F‰FŒHß‘!Ø�Ø˜A�$��Ø”gØ˜•F�AØ˜!•G’BØ�q•5Ü   A¥ b¥¨¥›^¨A¨q­DÕ0´°RµT³Õ:�Fà�DØ�CÜ" 1žX˜Ø˜a�˜Ü! !¥$°Ô7˜ØŸ
™
 2œÜ" 4¨¥9¨d×.?Ð.?°d¸3µiÓ@šñ	 &ô # 1žX˜Ø ŸW™W›Y˜Ü! !¥$°Ô7˜Ø˜SŸ	 TÕ)›	Ø# CŸyžyØŸH™H RžLñ &ð —J‘J˜v t�|×,ä˜AŸE™E !›H Q�J›�AØ—L‘L ¨¥G¥×,ñ; ÷> Ü�s•{Ù26ô&IÙ26¨QÀQÇÀ¸1”�A•C %×(ÁÑ(±$ò&Iõ Iñ KˆBð ˆ	ùó&Is   Ë+Lrà   r   r=   s   &@r0   ÚTRmorrierD  Y  s   ø€ ÷v7ôr �R˜ÓÐr2   c                ó&   a€ V3R lp\        W4      # )aÒ  Convert factored powers of sin and cos identities into simpler
expressions.

Examples
========

>>> from sympy.simplify.fu import TR14
>>> from sympy.abc import x, y
>>> from sympy import cos, sin
>>> TR14((cos(x) - 1)*(cos(x) + 1))
-sin(x)**2
>>> TR14((sin(x) - 1)*(sin(x) + 1))
-cos(x)**2
>>> p1 = (cos(x) + 1)*(cos(x) - 1)
>>> p2 = (cos(y) - 1)*2*(cos(y) + 1)
>>> p3 = (3*(cos(y) - 1))*(3*(cos(y) + 1))
>>> TR14(p1*p2*p3*(x - 1))
-18*(x - 1)*sin(x)**2*sin(y)**4

c           	      ó¨	  <€ V P                   '       g   V # S'       dW   V P                  4       w  rV\        P                  Jd1   \	        VR R7      p\	        VR R7      pW18w  g   WB8w  d	   W4,          p V # . p. pV P
                   EF	  pVP                  '       dM   VP                  4       w  r‰V	P                  '       g&   VP                  '       g   VP                  V4       K_  TpM\        P                  p	\        V4      p
V
'       d#   V
^,          P                  \        \        39  d@   V	\        P                  J d   VP                  V4       MVP                  Wy,          4       Kæ  V
w  r¼pVP                  W¹P                  WœW×34       EK  	  \!        \#        V4      4      p\%        V4      p\!        \'        ^4      4      ;pw  pprœr×V'       EdÛ   VP)                  ^ 4      pV'       Ed˜   V^ ,          pVV	,          P                  '       Ed•   VV	,          P                  '       Ed{   VV,          VV,          8X  Edd   VV,          VV,          8w  EdN   VP)                  ^ 4      p\+        VV	,          VV	,          4      pVV	,          V8w  dA   V Uu. uF  pVV,          NK  	  ppVV	;;,          V,          uu&   VP-                  ^ V4       MMVV	,          V8w  d@   V Uu. uF  pVV,          NK  	  ppVV	;;,          V,          uu&   VP-                  ^ V4       \/        VV,          \        4      '       d   \        pM\        pVP                  VV,          ) VV,          ,          V! VV,          P
                  ^ ,          4      ^,          ,          V,          4       EKÙ  MàVV	,          VV	,          8X  dÌ   VV,          VV,          8X  d·   VV,          VV,          8w  d¢   VP)                  ^ 4      pVV	,          p\/        VV,          \        4      '       d   \        pM\        pVP                  VV,          ) VV,          ,          V! VV,          P
                  ^ ,          4      ^,          ,          V,          4       EKº  VP                  VV,          VV	,          ,          4       EKã  \%        V4      V8w  d
   \1        V!  p V # u upi u upi )Fr¿   )rl   rm   r   r8   ÚTR14r7   rJ   r  rS   rT   r_   r"  rU   r   r   rÿ   ro   r   rW   rÆ   rq   rÅ   Úinsertr6   r   )r/   rs   rb   rÇ   rÈ   r<  Úprocessr:   rw   rY   r  r£   r;   ÚsiÚnotherrp   ru   ÚAÚBr@  rf   ÚremrÀ   s   &                     €r0   r;   ÚTR14.<locals>.fæ  s‚  ø€ Ø�y�yˆyØˆIçð ×$Ñ$Ó&‰DˆAØœŸ™‹~Ü˜A UÔ+�Ü˜A UÔ+�Ø”9 ¤	Ø��BØ�	àˆØˆØ—•ˆAØ�x�xˆxØ—}‘}“‘�ØŸŸ˜¨¯¯¨Ø—L‘L ”OÙØ‘ä—E‘E�Ü˜A“ˆAß˜˜!�Ÿ	™	¬#¬s¨Ô3ØœŸ™“:Ø—L‘L •Oà—L‘L ¥Ô&ÙØ‰HˆA�"Ø�N‰N˜AŸ{™{¨A°"Ð8×9ñ# ô( ”w˜wÓ'Ó(ˆô �U“ˆô &*¬%°«(£^Ð3ˆÑ"��1�a˜BçˆgØ—‘˜A“ˆAßˆwØ˜A•J�à�Q•4—>—>‘> a¨¥d§n§n¡nà˜•t˜q �t•|Ø˜R�5 A b¥E�>Ø '§¡¨A£˜AÜ#& q¨¥t¨Q¨q­T£?˜Dð  ! �t tœ|Ù59Ó&:±T° q¨§t t±T Ð&:Ø # A§¨$¥£Ø '§¡¨q°#Õ 6Ø!" 1¥¨¤Ù59Ó&:±T° q¨§t t±T Ð&:Ø # A§¨$¥£Ø '§¡¨q°#Ô 6ä)¨!¨A­$´×4Ò4Ü$'¡ä$' Ø!ŸL™L¨1¨Q­4¨%°°!µ­*±Q°q¸µt·y±yÀµ|³_ÀaÕ5GÕ*GÈ$Õ)NÔOÚ$øà�q•T˜Q˜q�T”\à˜•t˜q �t”|Ø˜R�5 A b¥Eœ>Ø '§¡¨A£˜AØ#$ Q¥4˜DÜ)¨!¨A­$´×4Ò4Ü$'¡ä$' Ø!ŸL™L¨1¨Q­4¨%°°!µ­*±Q°q¸µt·y±yÀµ|³_ÀaÕ5GÕ*GÈ$Õ)NÔOÚ$ð �L‰L˜˜1�˜q �t�×$äˆu‹:˜ÔÜ�e‘ˆBàˆ	ùòE ';ùò ';s   ÊS
Ë#Sr   rÍ   s   &f r0   rG  rG  Ð  s   ø€ õ,^ô@ �RÓÐr2   c                ó*   aa€ VV3R lp\        W4      # )zúConvert sin(x)**-2 to 1 + cot(x)**2.

See _TR56 docstring for advanced use of ``max`` and ``pow``.

Examples
========

>>> from sympy.simplify.fu import TR15
>>> from sympy.abc import x
>>> from sympy import sin
>>> TR15(1 - 1/sin(x)**2)
-cot(x)**2

c           	      ój  <€ \        V \        4      '       d!   \        V P                  \        4      '       g   V # V P                  pV^,          ^8X  d5   \        V P                  V^,           ,          4      V P                  ,          # ^V ,          p\        V\        \        R SSR7      pW28w  d   Tp V # )rF   c                 ó   € ^V ,           # r¬   r­   r„   s   &r0   r†   Ú!TR15.<locals>.f.<locals>.<lambda>b  ó   € ¨!¨a®%r2   r°   )r6   r   rK   r   r    ÚTR15r©   r    ©r/   rY   Úiar:   r¥   r¦   s   &   €€r0   r;   ÚTR15.<locals>.fY  ó†   ø€ Ü˜2œs×#Ò#¬
°2·7±7¼C×(@Ò(@ØˆIà�F‰FˆØˆq�5�AŒ:Ü˜Ÿ™ ! a¥%Õ(Ó)¨"¯'©'Õ1Ð1àˆr�TˆÜ�"”cœ3¡°S¸cÔBˆØŒ7ØˆBØˆ	r2   r   ©r/   r¥   r¦   r;   s   &ff r0   rU  rU  I  ó   ù€ ö ô �RÓÐr2   c                ó*   aa€ VV3R lp\        W4      # )zúConvert cos(x)**-2 to 1 + tan(x)**2.

See _TR56 docstring for advanced use of ``max`` and ``pow``.

Examples
========

>>> from sympy.simplify.fu import TR16
>>> from sympy.abc import x
>>> from sympy import cos
>>> TR16(1 - 1/cos(x)**2)
-tan(x)**2

c           	      ój  <€ \        V \        4      '       d!   \        V P                  \        4      '       g   V # V P                  pV^,          ^8X  d5   \        V P                  V^,           ,          4      V P                  ,          # ^V ,          p\        V\        \        R SSR7      pW28w  d   Tp V # )rF   c                 ó   € ^V ,           # r¬   r­   r„   s   &r0   r†   Ú!TR16.<locals>.f.<locals>.<lambda>ƒ  rT  r2   r°   )r6   r   rK   r   r    rU  r©   r   rV  s   &   €€r0   r;   ÚTR16.<locals>.fz  rY  r2   r   rZ  s   &ff r0   ÚTR16ra  j  r[  r2   c                ó   € R p\        W4      # )a   Convert f(x)**-i to g(x)**i where either ``i`` is an integer
or the base is positive and f, g are: tan, cot; sin, csc; or cos, sec.

Examples
========

>>> from sympy.simplify.fu import TR111
>>> from sympy.abc import x
>>> from sympy import tan
>>> TR111(1 - 1/tan(x)**2)
1 - cot(x)**2

c                 óî  € \        V \        4      '       dU   V P                  P                  '       g;   V P                  P
                  '       d   V P                  P                  '       g   V # \        V P                  \        4      '       d9   \        V P                  P                  ^ ,          4      V P                  ) ,          # \        V P                  \        4      '       d9   \        V P                  P                  ^ ,          4      V P                  ) ,          # \        V P                  \        4      '       d9   \        V P                  P                  ^ ,          4      V P                  ) ,          # V # r5   )r6   r   rK   rT   r    rS   Úis_negativer   r    r7   r   r"   r   r!   r.   s   &r0   r;   ÚTR111.<locals>.fš  sà   € ä�rœ3×ÒØ�W‰W× × Ð  B§F¡F×$5×$5Ð$5¸"¿&¹&×:L×:LÐ:LØˆIä�b—g‘gœs×#Ò#Ü�r—w‘w—|‘| A•Ó'¨"¯&©&¨Õ0Ð0Ü˜Ÿ™¤×%Ò%Ü�r—w‘w—|‘| A•Ó'¨"¯&©&¨Õ0Ð0Ü˜Ÿ™¤×%Ò%Ü�r—w‘w—|‘| A•Ó'¨"¯&©&¨Õ0Ð0Øˆ	r2   r   r=   s   & r0   ÚTR111rf  ‹  s   € òô �RÓÐr2   c                ó*   aa€ VV3R lp\        W4      # )a<  Convert tan(x)**2 to sec(x)**2 - 1 and cot(x)**2 to csc(x)**2 - 1.

See _TR56 docstring for advanced use of ``max`` and ``pow``.

Examples
========

>>> from sympy.simplify.fu import TR22
>>> from sympy.abc import x
>>> from sympy import tan, cot
>>> TR22(1 + tan(x)**2)
sec(x)**2
>>> TR22(1 + cot(x)**2)
csc(x)**2

c           	      óê   <€ \        V \        4      '       d&   V P                  P                  \        \
        39   g   V # \        V \
        \        R  SSR7      p \        V \        \        R SSR7      p V # )c                 ó   € V ^,
          # r¬   r­   r„   s   &r0   r†   Ú!TR22.<locals>.f.<locals>.<lambda>Á  ó   € ¨1¨q®5r2   r°   c                 ó   € V ^,
          # r¬   r­   r„   s   &r0   r†   rj  Â  rk  r2   )	r6   r   rK   rU   r    r   r©   r!   r"   r±   s   &€€r0   r;   ÚTR22.<locals>.f½  sU   ø€ Ü˜2œs×#Ò#¨¯©¯©¼¼c¸
Ô(BØˆIä�2”sœC¡°c¸sÔCˆÜ�2”sœC¡°c¸sÔCˆØˆ	r2   r   rZ  s   &ff r0   ÚTR22rn  «  s   ù€ ö$ô �RÓÐr2   c                ó   € R p\        W4      # )aÓ  Convert sin(x)**n and cos(x)**n with positive n to sums.

Examples
========

>>> from sympy.simplify.fu import TRpower
>>> from sympy.abc import x
>>> from sympy import cos, sin
>>> TRpower(sin(x)**6)
-15*cos(2*x)/32 + 3*cos(4*x)/16 - cos(6*x)/32 + 5/16
>>> TRpower(sin(x)**3*cos(2*x)**4)
(3*sin(x)/4 - sin(3*x)/4)*(cos(4*x)/2 + cos(8*x)/8 + 3/8)

References
==========

.. [1] https://en.wikipedia.org/wiki/List_of_trigonometric_identities#Power-reduction_formulae

c                 ó„  € \        V \        4      '       d'   \        V P                  \        \        34      '       g   V # V P                  4       w  rVP                  ^ ,          pVP                  '       Ed6   VP                  '       Ed#   VP                  '       dŒ   \        V\        4      '       dv   ^^V,
          ,          \        \        V^,           ^,          4       Uu. uF3  p\        W$4      \	        V^V,          ,
          V,          4      ,          NK5  	  up!  ,          p EMKVP                  '       dÒ   \        V\        4      '       d¼   ^^V,
          ,          \        P                  V^,
          ^,          ,          ,          \        \        V^,           ^,          4       Uu. uFO  p\        W$4      \        P                  V,          ,          \        V^V,          ,
          V,          4      ,          NKQ  	  up!  ,          p EMhVP                  '       d„   \        V\        4      '       dn   ^^V,
          ,          \        \        V^,          4       Uu. uF3  p\        W$4      \	        V^V,          ,
          V,          4      ,          NK5  	  up!  ,          p MÓVP                  '       dÂ   \        V\        4      '       d¬   ^^V,
          ,          \        P                  V^,          ,          ,          \        \        V^,          4       Uu. uFO  p\        W$4      \        P                  V,          ,          \	        V^V,          ,
          V,          4      ,          NKQ  	  up!  ,          p VP                  '       d)   V ^V) ,          \        W"^,          4      ,          ,          p V # u upi u upi u upi u upi r5   )r6   r   rK   r   r   r  r7   rÃ   rT   Úis_oddr   rÆ   r   r   r#  Úis_even)r/   rw   rs   r…   rX   s   &    r0   r;   ÚTRpower.<locals>.fÝ  s¶  € Ü˜2œs×#Ò#¬
°2·7±7¼SÄ#¸J×(GÒ(GØˆIØ�~‰~Ó‰ˆØ�F‰F�1�IˆØ�<�<‰<˜AŸMŸM™MØ�x�xˆxœJ q¬#×.Ò.Ø˜˜1�•XœcÜ" A¨¥E¨1¥9Ô-ó$/Ù-˜ô %-¨Q£N´3¸¸A¸a½C½Àµ{Ó3C×$CÐ$CÙ-ñ$/ñ 0õ 0’à——�œj¨¬C×0Ò0Ø˜˜1�•XœaŸm™m¨q°­s°A­gÕ6Õ6´sÜ?DÀaÈ!ÅeÈQÅYÔ?Oó=QÙ?O¸!ô >FÀa»^Ü—M‘M 1Õ$õ>%Ü%(¨!¨a°­c­'°1­Ó%5÷>6ð >6Ù?Oñ=Qñ 8Rõ R’à——�œz¨!¬S×1Ò1Ø˜˜1�•XœcÜ" 1 Q¥3œZó$)Ù'˜ô %-¨Q£N´3¸¸A¸a½C½Àµ{Ó3C×$CÐ$CÙ'ñ$)ñ *õ *‘à——�œz¨!¬S×1Ò1Ø˜˜1�•XœaŸm™m¨a°­cÕ2Õ2´3Ü?DÀQÀqÅS¼zó9KÙ?I¸!ô :BÀ!»Ü—M‘M 1Õ$õ:%Ü%(¨!¨a°­c­'°1­Ó%5÷:6ð :6Ù?Iñ9Kñ 4Lõ L�à�y�yˆyØ�a˜1˜"•gœh q¨A­#Ó.Õ.Õ.�Øˆ	ùò$/ùò=Qùò$)ùò9Ks   Ã!9N.
Æ(AN3
É9N8
ÌAN=
r   r=   s   & r0   ÚTRpowerrt  È  s   € ò*ô, �RÓÐr2   c                ó>   € \        V P                  \        4      4      # )zÁReturn count of trigonometric functions in expression.

Examples
========

>>> from sympy.simplify.fu import L
>>> from sympy.abc import x
>>> from sympy import cos, sin
>>> L(cos(x)+sin(x))
2
)r   Úcountr$   r.   s   &r0   ÚLrw  ö  s   € ô ˆR�X‰XÔ+Ó,Ó-Ð-r2   c                 ó8   € \        V 4      V P                  4       3# rI   )rw  Ú	count_opsr„   s   &r0   r†   r†   *  s   € œa ›d A§K¡K£MÑ2r2   c           
     ó¢  € \        \        V4      p\        \        V4      pT p\        V 4      p \	        V \
        4      '       g5   V P                  ! V P                   Uu. uF  p\        WQR7      NK  	  up!  # \        V 4      p V P                  \        \        4      '       dI   V! V 4      pV! V4      V! V 4      8  d   Tp V P                  \        \        4      '       d   \        V 4      p V P                  \        \        4      '       d,   V! V 4      p\!        \#        V4      4      p\%        W@Wg.VR7      p \%        \'        V 4      WR7      # u upi )a  Attempt to simplify expression by using transformation rules given
in the algorithm by Fu et al.

:func:`fu` will try to minimize the objective function ``measure``.
By default this first minimizes the number of trig terms and then minimizes
the number of total operations.

Examples
========

>>> from sympy.simplify.fu import fu
>>> from sympy import cos, sin, tan, pi, S, sqrt
>>> from sympy.abc import x, y, a, b

>>> fu(sin(50)**2 + cos(50)**2 + sin(pi/6))
3/2
>>> fu(sqrt(6)*cos(x) + sqrt(2)*sin(x))
2*sqrt(2)*sin(x + pi/3)

CTR1 example

>>> eq = sin(x)**4 - cos(y)**2 + sin(y)**2 + 2*cos(x)**2
>>> fu(eq)
cos(x)**4 - 2*cos(y)**2 + 2

CTR2 example

>>> fu(S.Half - cos(2*x)/2)
sin(x)**2

CTR3 example

>>> fu(sin(a)*(cos(b) - sin(b)) + cos(a)*(sin(b) + cos(b)))
sqrt(2)*sin(a + b + pi/4)

CTR4 example

>>> fu(sqrt(3)*cos(x)/2 + sin(x)/2)
sin(x + pi/3)

Example 1

>>> fu(1-sin(2*x)**2/4-sin(y)**2-cos(x)**4)
-cos(x)**2 + cos(y)**2

Example 2

>>> fu(cos(4*pi/9))
sin(pi/18)
>>> fu(cos(pi/9)*cos(2*pi/9)*cos(3*pi/9)*cos(4*pi/9))
1/16

Example 3

>>> fu(tan(7*pi/18)+tan(5*pi/18)-sqrt(3)*tan(5*pi/18)*tan(7*pi/18))
-sqrt(3)

Objective function example

>>> fu(sin(x)/cos(x))  # default objective function
tan(x)
>>> fu(sin(x)/cos(x), measure=lambda x: -x.count_ops()) # maximize op count
sin(x)/cos(x)

References
==========

.. [1] https://www.sciencedirect.com/science/article/pii/S0895717706001609
)Úmeasure)rB  )r'   ÚRL1ÚRL2r   r6   r   rU   r7   Úfur>   Úhasr   r    rB   r   r   rÁ   rD  rÅ   ry   )r/   r{  ÚfRL1ÚfRL2r×   r:   Úrv1Úrv2s   &&      r0   r~  r~  *  s  € ôL ”#�wÓ€DÜ”#�wÓ€Dà
€CÜ	�‹€BÜ�bœ$×ÒØ�wŠw¸¿ºÓA¹°Aœ˜A×/¹ÑAÑBÐBÜ	ˆR‹€BØ	‡v�vŒc”3×ÒÙ�2‹hˆÙ�C‹L™7 2›;Ô&ØˆBØ�6‰6”#”s×ÒÜ�R“ˆBØ	‡v�vŒc”3×ÒÙ�2‹hˆÜ”(˜3“-Ó ˆÜ�#˜3Ð$¨'Ô2ˆÜŒt�B‹x˜Ô)Ð)ùò Bs   ÁEc                ó²  € \        \        4      pV'       d]   V P                   FK  pVP                  4       w  reV^ 8  d   V) pV) pYFV'       d	   V! V4      M^3,          P	                  V4       KM  	  MUV'       dC   V P                   F1  pV\
        P                  V! V4      3,          P	                  V4       K3  	  M\        R4      h. pRpV Fs  p	WI,          p
V	w  rk\        V
4      ^8”  d7   \        V
RR/ pV! V4      pWÜ8w  d   TpRpVP	                  Wl,          4       KU  VP	                  Wj^ ,          ,          4       Ku  	  V'       d
   \        V!  p V # )zÿApply ``do`` to addends of ``rv`` that (if ``key1=True``) share at least
a common absolute value of their coefficient and the value of ``key2`` when
applied to the argument. If ``key1`` is False ``key2`` must be supplied and
will be the only key applied.
zmust have at least one keyFrk   T)
r   ro   r7   rÂ   r_   r   r8   Ú
ValueErrorrW   r   )r/   rÞ   Úkey2Úkey1Úabscr:   rÉ   r7   rÔ   rX   rg   r,  rY   rØ   s   &&&&          r0   rá   rá   …  s(  € ô ”tÓ€DßØ—”ˆAØ—>‘>Ó#‰DˆAØ�1ŒuØ�B�Ø�B�Ø§‘T˜!”W¨!Ð,Õ-×4Ñ4°QÖ7ò ÷ 
Ø—”ˆAØ”!—%‘%™˜a›Ð!Õ"×)Ñ)¨!Ö,ò ô Ð5Ó6Ð6à€DØ
€CÛˆØ�GˆØ‰ˆÜˆq‹6�AŒ:Ü�QÐ' Ñ'ˆAÙ�Q“%ˆCØŒxØ�Ø�Ø�K‰K˜�Öà�K‰K˜˜A�$�Öñ ÷ Ü�$‰Zˆà€Ir2   z~
    TR0 TR1 TR2 TR3 TR4 TR5 TR6 TR7 TR8 TR9 TR10 TR10i TR11
    TR12 TR13 L TR2i TRmorrie TR12i
    TR14 TR15 TR16 TR111 TR22c                  ó   € \        ^4      # rº   ©r#   r­   r2   r0   Ú_ROOT2r‹  ¶  ó   € ä�‹7€Nr2   c                  ó   € \        ^4      # )r•   rŠ  r­   r2   r0   rö   rö   »  rŒ  r2   c                  ó&   € ^\        ^4      ,          # r¬   rŠ  r­   r2   r0   r÷   r÷   À  s   € àŒT�!‹W�9Ðr2   c           	     ó’  a€ W3 Uu. uF  p\        V4      NK  	  upw  rV P                  V4      w  rEV P                  V4      P                  4       p^;rx\        P
                  VP                  9   d$   VP                  \        P
                  4      pV) pMA\        P
                  VP                  9   d#   VP                  \        P
                  4      pV) pWE3 Uu. uF  q3P                  4       NK  	  upw  rR p	V	! W4      p
V
f   R# V
w  r¼pV	! W4      p
V
f   R# V
w  rïpV'       g	   V'       g   V'       d$   \        V\        4      '       d   WïVW¼V3w  r¼rÞppY‡r‡V'       gn   T;'       g    TpT;'       g    Tp\        VVP                  4      '       g   R# WgVVP                  ^ ,          VP                  ^ ,          \        V\        4      3# V'       gö   V'       gî   V'       dæ   V'       dÞ   V'       dÖ   V'       dÎ   \        WÍP                  4      \        VVP                  4      Jd   R# WÍ3 Uu0 uF  pVP                  kK  	  upo\        ;QJ d!    V3R lVV3 4       F  '       d   K   RM	  RM! V3R lVV3 4       4      '       g   R# WgWŒP                  ^ ,          VP                  ^ ,          \        WÍP                  4      3# V'       d	   V'       g)   V'       d	   V'       g   V'       d   Vf   Ve	   Vf   Vf   R# T;'       g    TpT;'       g    TpVP                  VP                  8w  d   R# V'       g   \        P                  pV'       g   \        P                  pW¾J d5   V\        4       ,          pWgVVP                  ^ ,          \         ^,          R3# W¾,          \#        4       8X  d4   V^V,          ,          pWgVVP                  ^ ,          \         ^,          R3# W¾,          \%        4       8X  d4   V^V,          ,          pWgVVP                  ^ ,          \         ^,          R3# R# u upi u upi u upi )a�  Return the gcd, s1, s2, a1, a2, bool where

If two is False (default) then::
    a + b = gcd*(s1*f(a1) + s2*f(a2)) where f = cos if bool else sin
else:
    if bool, a + b was +/- cos(a1)*cos(a2) +/- sin(a1)*sin(a2) and equals
        n1*gcd*cos(a - b) if n1 == n2 else
        n1*gcd*cos(a + b)
    else a + b was +/- cos(a1)*sin(a2) +/- sin(a1)*cos(a2) and equals
        n1*gcd*sin(a + b) if n1 = n2 else
        n1*gcd*sin(b - a)

Examples
========

>>> from sympy.simplify.fu import trig_split
>>> from sympy.abc import x, y, z
>>> from sympy import cos, sin, sqrt

>>> trig_split(cos(x), cos(y))
(1, 1, 1, x, y, True)
>>> trig_split(2*cos(x), -2*cos(y))
(2, 1, -1, x, y, True)
>>> trig_split(cos(x)*sin(y), cos(y)*sin(y))
(sin(y), 1, 1, x, y, True)

>>> trig_split(cos(x), -sqrt(3)*sin(x), two=True)
(2, 1, -1, x, pi/6, False)
>>> trig_split(cos(x), sin(x), two=True)
(sqrt(2), 1, 1, x, pi/4, False)
>>> trig_split(cos(x), -sin(x), two=True)
(sqrt(2), 1, -1, x, pi/4, False)
>>> trig_split(sqrt(2)*cos(x), -sqrt(6)*sin(x), two=True)
(2*sqrt(2), 1, -1, x, pi/6, False)
>>> trig_split(-sqrt(6)*cos(x), -sqrt(2)*sin(x), two=True)
(-2*sqrt(2), 1, 1, x, pi/3, False)
>>> trig_split(cos(x)/sqrt(6), sin(x)/sqrt(2), two=True)
(sqrt(6)/3, 1, 1, x, pi/6, False)
>>> trig_split(-sqrt(6)*cos(x)*sin(y), -sqrt(2)*sin(x)*sin(y), two=True)
(-2*sqrt(2)*sin(y), 1, 1, x, pi/3, False)

>>> trig_split(cos(x), sin(x))
>>> trig_split(cos(x), sin(z))
>>> trig_split(2*cos(x), -sin(x))
>>> trig_split(cos(x), -sqrt(3)*sin(x))
>>> trig_split(cos(x)*cos(y), sin(x)*sin(z))
>>> trig_split(cos(x)*cos(y), sin(x)*sin(y))
>>> trig_split(-sqrt(6)*cos(x), sqrt(2)*sin(x)*sin(y), two=True)
c                ó  € R;r#\         P                  pV P                  '       Ed�   V P                  4       w  r@\	        V P
                  4      ^8”  g	   V'       g   R# V P                  '       d   \        V P
                  4      pMV .pVP                  ^ 4      p \        V \        4      '       d   T pMT\        V \        4      '       d   T pM;V P                  '       d(   V P                  \         P                  J d
   W@,          pMR# V'       d�   V^ ,          p\        V\        4      '       d   V'       d   TpMbTpM_\        V\        4      '       d   V'       d   TpM>TpM;VP                  '       d(   VP                  \         P                  J d
   WF,          pMR# V\         P                  Jd   WBV3# RW#3# \        V \        4      '       d   T pM\        V \        4      '       d   T pVf   Vf   R# V\         P                  Jd   TMRpWBV3# )aE  Return ``a`` as a tuple (r, c, s) such that
``a = (r or 1)*(c or 1)*(s or 1)``.

Three arguments are returned (radical, c-factor, s-factor) as
long as the conditions set by ``two`` are met; otherwise None is
returned. If ``two`` is True there will be one or two non-None
values in the tuple: c and s or c and r or s and r or s or c with c
being a cosine function (if possible) else a sine, and s being a sine
function (if possible) else oosine. If ``two`` is False then there
will only be a c or s term in the tuple.

``two`` also require that either two cos and/or sin be present (with
the condition that if the functions are the same the arguments are
different or vice versa) or that a single cosine or a single sine
be present with an optional radical.

If the above conditions dictated by ``two`` are not met then None
is returned.
N)r   r8   rl   rÂ   rW   r7   ro   rq   r6   r   r   rJ   r    rõ   )r:   rî   rÉ   rÊ   r  r7   rw   s   &&     r0   Úpow_cos_sinÚtrig_split.<locals>.pow_cos_sin  sx  € ð( ˆˆÜ�U‰UˆØ�8�8‰8Ø—N‘NÓ$‰EˆBÜ�1—6‘6‹{˜QŒ§cÙØ�x�xˆxÜ˜AŸF™F“|‘à�s�Ø—‘˜“ˆAÜ˜!œS×!Ò!Ø‘Ü˜Aœs×#Ò#Ø‘Ø——�˜aŸe™e¤q§v¡v›oØ•‘áßØ˜•G�Ü˜a¤×%Ò%ßØ™à™Ü ¤3×'Ò'ßØ™à™Ø—X—X�X !§%¡%¬1¯6©6£/Ø•G‘BáØ¤1§5¡5›�2°qÐ8Ð8¨d°AÐ8Ð8Ü˜œ3×ÒØ‰AÜ˜œ3×ÒØˆAØŠ9˜šÙØœQŸU™U“?‰R¨ˆØ�aˆxˆr2   Nc              3   ó@   <"  € T F  qP                   S9   x € K  	  R # 5irI   )r7   )rL   rf   r7   s   & €r0   rN   Útrig_split.<locals>.<genexpr>^  s   øé € Ð<±8¨aŸ6™6 Tž>³8ùs   ƒFT)r   r,   rÚ   Úas_exprr   r#  ÚfactorsÚquor6   r   rU   r7   r   r$  r8   r‹  r   rö   r÷   )r:   rw   rî   rf   ÚuaÚubrÚ   rÛ   rÜ   r‘  r  ÚcoaÚcaÚsaÚcobÚcbÚsbrÉ   rÊ   rÕ   r7   s   &&&                 @r0   rÓ   rÓ   Å  s*  ø€ ðd "#¡Ó'¡˜1ŒG�AŽJ¡Ñ'�D€AØ�X‰X�a‹[�F€BØ
�%‰%�‹(×
Ñ
Ó
€CØ€K€BÜ‡}�}˜Ÿ
™
Ô"Ø�V‰V”A—M‘MÓ"ˆØˆS‰Ü	
�‰˜"Ÿ*™*Ô	$Ø�V‰V”A—M‘MÓ"ˆØˆSˆØ"$¡Ó*¡˜A�I‰IŽK¡Ñ*�D€Aò?ñD 	�AÓ€AØ‚yÙØ�K€CˆRÙ�AÓ€AØ‚yÙØ�K€CˆR÷ —BŸ"¤¨B´×!4Ò!4Ø#&¨B°¸Ð#;Ñ ˆ�˜"˜bØˆBßØ�HˆH�"ˆØ�HˆH�"ˆÜ˜!˜QŸV™V×$Ò$ÙØ˜˜AŸF™F 1�I q§v¡v¨a¥y´*¸QÄÓ2DÐDÐDçŸ3ß—rŸb§RÜ˜b§'¡'Ó*´*¸RÀÇÁÓ2IÓIÙØ)+©Ó1© 1˜Ÿœ©Ñ1�ß“sÔ<°B¸±8Ó<—s—s’sÔ<°B¸±8Ó<×<Ò<ÙØ §G¡G¨A¥J°·±¸µ
¼JÀrÏ7É7Ó<SÐSÐSß—"ŸŸrß�R’Z B¢J°"²*ÀÂÙØ�HˆH�"ˆØ�HˆH�"ˆØ�6‰6�Q—V‘VÔÙßÜ—%‘%ˆCßÜ—%‘%ˆCØ‹:Ø”6“8�OˆCØ˜B §¡ q¥	¬2¨a­4°Ð6Ð6Ø�Wœ›Ô Ø�1�S•5�LˆCØ˜B §¡ q¥	¬2¨a­4°Ð6Ð6Ø�Wœ	›Ô#Ø�1�S•5�LˆCØ˜B §¡ q¥	¬2¨a­4°Ð6Ð6ñ $ùòw (ùò +ùòx 2s   ‡P:ÃP?È7Qc                ó0  € V P                   '       d   \        V P                  4      ^8w  d   R# V P                  w  rV\        P                  \        P
                  39   dj   \        P
                  pVP                  '       dD   VP                  ^ ,          P                  '       d!   VP                  ^ ,          ^ 8  d	   V) V) r!V) pW2V3# V P                   Uu. uF  p\        V4      NK  	  upw  rVP                  V4      w  rVVP                  V4      P                  4       p\        P                  VP                  9   d%   VP                  \        P                  4      pRp^p	MF\        P                  VP                  9   d%   VP                  \        P                  4      p^pRp	M^;r‰WV3 Uu. uF  qDP                  4       NK  	  upw  rV\        P
                  J d   Y!r!Y˜r˜VR8X  d   V) pV	) p	V\        P
                  J d   WqV	3# R# u upi u upi )a´  If ``e`` is a sum that can be written as ``g*(a + s)`` where
``s`` is ``+/-1``, return ``g``, ``a``, and ``s`` where ``a`` does
not have a leading negative coefficient.

Examples
========

>>> from sympy.simplify.fu import as_f_sign_1
>>> from sympy.abc import x
>>> as_f_sign_1(x + 1)
(1, x, 1)
>>> as_f_sign_1(x - 1)
(1, x, -1)
>>> as_f_sign_1(-x + 1)
(-1, x, -1)
>>> as_f_sign_1(-x - 1)
(-1, x, 1)
>>> as_f_sign_1(2*x + 2)
(2, x, 1)
Néÿÿÿÿ)rV   rW   r7   r   r#  r8   rl   rÿ   r   r,   rÚ   r•  r–  r—  )
rY   r:   rw   r£   rf   r˜  r™  rÚ   rÛ   rÜ   s
   &         r0   r"  r"  w  s™  € ð* �8�8ˆ8”s˜1Ÿ6™6“{ aÔ'Ùà�6‰6�D€AØŒQ�]‰]œAŸE™EÐ"Ô"Ü�E‰EˆØ�8�8ˆ8˜Ÿ™˜q�	×+×+Ð+°·±°qµ	¸A´Ø�2˜�rˆqØ�ˆAØ�Qˆwˆà !§¢Ó'¡˜1ŒG�AŽJ¡Ñ'�D€AØ�X‰X�a‹[�F€BØ
�%‰%�‹(×
Ñ
Ó
€CÜ‡}�}˜Ÿ
™
Ô"Ø�V‰V”A—M‘MÓ"ˆØˆØ‰Ü	
�‰˜"Ÿ*™*Ô	$Ø�V‰V”A—M‘MÓ"ˆØˆØ‰àˆˆØ"$¡Ó*¡˜A�I‰IŽK¡Ñ*�D€AØŒA�E‰EƒzØˆ1ØˆBØ	ˆR„xØˆdˆØˆSˆàŒA�E‰EƒzØ�rˆzÐñ ùò+ (ùò +s   ÃHÆ2Hc                ó&   a€ V3R lp\        W4      # )a  Replace all hyperbolic functions with trig functions using
the Osborne rule.

Notes
=====

``d`` is a dummy variable to prevent automatic evaluation
of trigonometric/hyperbolic functions.


References
==========

.. [1] https://en.wikipedia.org/wiki/Hyperbolic_function
c                 ó"  <€ \        V \        4      '       g   V # V P                  ^ ,          pVP                  '       g
   VS,          M5\        P
                  ! VP                   Uu. uF  q"S,          NK  	  up4      p\        V \        4      '       d   \        \        V4      ,          # \        V \        4      '       d   \        V4      # \        V \        4      '       d   \        \        V4      ,          # \        V \        4      '       d   \        V4      \        ,          # \        V \        4      '       d   \!        V4      # \        V \"        4      '       d   \%        V4      \        ,          # \'        RV P(                  ,          4      hu upi )r   úunhandled %s)r6   r   r7   rV   r   rç   r   r   r   r   r   r   r   r   r    r   r!   r   r"   ÚNotImplementedErrorrU   )r/   r:   rf   rb   s   &  €r0   r;   Ú_osborne.<locals>.fÁ  s  ø€ Ü˜"Ô0×1Ò1ØˆIØ�G‰G�A�JˆØ—x—x�xˆAˆaŽC¤S§^¢^À!Ç&Â&Ó4IÁ&¸Q°q·S°SÁ&Ñ4IÓ%JˆÜ�bœ$×ÒÜ”S˜“V•8ˆOÜ˜œD×!Ò!Ü�q“6ˆMÜ˜œD×!Ò!Ü”S˜“V•8ˆOÜ˜œD×!Ò!Ü�q“6œ!•8ˆOÜ˜œD×!Ò!Ü�q“6ˆMÜ˜œD×!Ò!Ü�q“6œ!•8ˆOä% n°r·w±wÕ&>Ó?Ð?ùò 5Js   Á&Fr   ©rY   rb   r;   s   &f r0   Ú_osborner¨  °  s   ø€ õ"@ô( �Q‹?Ðr2   c                ó&   a€ V3R lp\        W4      # )a  Replace all trig functions with hyperbolic functions using
the Osborne rule.

Notes
=====

``d`` is a dummy variable to prevent automatic evaluation
of trigonometric/hyperbolic functions.

References
==========

.. [1] https://en.wikipedia.org/wiki/Hyperbolic_function
c                 ó  <€ \        V \        4      '       g   V # V P                  ^ ,          P                  SRR7      w  rVP	                  S\
        P                  /4      V\        ,          ,           p\        V \        4      '       d   \        V4      \        ,          # \        V \        4      '       d   \        V4      # \        V \        4      '       d   \        V4      \        ,          # \        V \        4      '       d   \        V4      \        ,          # \        V \         4      '       d   \#        V4      # \        V \$        4      '       d   \'        V4      \        ,          # \)        RV P*                  ,          4      h)r   T)Úas_Addr¤  )r6   r$   r7   Úas_independentÚxreplacer   r8   r   r   r   r   r   r   r   r    r   r!   r   r"   r   r¥  rU   )r/   Úconstr…   r:   rb   s   &   €r0   r;   Ú_osbornei.<locals>.fè  s   ø€ Ü˜"Ô3×4Ò4ØˆIØ—7‘7˜1•:×,Ñ,¨Q°tÐ,Ó<‰ˆØ�J‰J˜œ1Ÿ5™5�zÓ" U¬1¥WÕ,ˆÜ�bœ#×ÒÜ˜“7œ1•9ÐÜ˜œC× Ò Ü˜“7ˆNÜ˜œC× Ò Ü˜“7œ1•9ÐÜ˜œC× Ò Ü˜“7œ1•9ÐÜ˜œC× Ò Ü˜“7ˆNÜ˜œC× Ò Ü˜“7œ1•9Ðä% n°r·w±wÕ&>Ó?Ð?r2   r   r§  s   &f r0   Ú	_osborneir°  Ø  s   ø€ õ @ô( �Q‹?Ðr2   c                ó8  aaaa	€ ^ RI Ho	 ^ RIHo V P	                  \
        4      pV Uu. uF  q"\        4       3NK  	  upoV P                  \        S4      4      pS UUu. uF  w  rEWT3NK
  	  uppo\        4       o\        VS4      VVVV	3R l3# u upi u uppi )a‚  Return an expression containing hyperbolic functions in terms
of trigonometric functions. Any trigonometric functions initially
present are replaced with Dummy symbols and the function to undo
the masking and the conversion back to hyperbolics is also returned. It
should always be true that::

    t, f = hyper_as_trig(expr)
    expr == f(t)

Examples
========

>>> from sympy.simplify.fu import hyper_as_trig, fu
>>> from sympy.abc import x
>>> from sympy import cosh, sinh
>>> eq = sinh(x)**2 + cosh(x)**2
>>> t, f = hyper_as_trig(eq)
>>> f(fu(t))
cosh(2*x)

References
==========

.. [1] https://en.wikipedia.org/wiki/Hyperbolic_function
r{   )Úcollectc           	      ó‚   <€ S! S! \        V S4      P                  \        S4      4      4      \        P                  4      # rI   )r°  r­  Údictr   ÚImaginaryUnit)r…   r²  rb   Úrepsr|   s   &€€€€r0   r†   Úhyper_as_trig.<locals>.<lambda>&  s1   ø€ ©'±(Ü�!�Q‹× Ñ ¤ d£Ó,ó3.Ü/0¯©ô+@r2   )
r‘   r|   Úsympy.simplify.radsimpr²  Úatomsr$   r   r­  r´  r¨  )
r/   Útrigsru   ÚmaskedrX   rg   r²  rb   r¶  r|   s
   &     @@@@r0   Úhyper_as_trigr¼  ÿ  s�   û€ õ4 1Ý.ð �H‰HÔ*Ó+€EÙ"'Ó(¡%˜Q”“‹L¡%Ñ(€DØ�[‰[œ˜d›Ó$€Fñ  $Ô$™t‘t�qˆQ‹F™tÒ$€Dä‹€Aä�F˜AÓ÷ !@ð @ð @ùò )ùó %s   ªBÁ Bc                ó€   € V P                  \        \        4      '       g   V # \        \	        \        V 4      4      4      # )a�  Convert products and powers of sin and cos to sums.

Explanation
===========

Applied power reduction TRpower first, then expands products, and
converts products to sums with TR8.

Examples
========

>>> from sympy.simplify.fu import sincos_to_sum
>>> from sympy.abc import x
>>> from sympy import cos, sin
>>> sincos_to_sum(16*sin(x)**3*cos(2*x)**2)
7*sin(x) - 5*sin(3*x) + 3*sin(5*x) - sin(7*x)
)r  r   r   rÁ   r
   rt  )Úexprs   &r0   Úsincos_to_sumr¿  *  s.   € ð& �8‰8”Cœ×ÒØˆä”:œg d›mÓ,Ó-Ð-r2   )F)r–   Frà   rI   )NT)rÚcollectionsr   Úsympy.core.addr   Úsympy.core.cacher   Úsympy.core.exprr   Úsympy.core.exprtoolsr   r   r	   Úsympy.core.functionr
   Úsympy.core.mulr   Úsympy.core.numbersr   r   Úsympy.core.powerr   Úsympy.core.singletonr   Úsympy.core.sortingr   Úsympy.core.symbolr   Úsympy.core.sympifyr   Úsympy.core.traversalr   Ú(sympy.functions.combinatorial.factorialsr   Ú%sympy.functions.elementary.hyperbolicr   r   r   r   r   r   r   Ú(sympy.functions.elementary.trigonometricr   r   r   r    r!   r"   r#   r$   Úsympy.ntheory.factor_r%   Úsympy.polys.polytoolsr&   Úsympy.strategies.treer'   Úsympy.strategies.corer(   r)   Úsympyr*   r1   r>   rB   ry   r’   r�   r©   r²   r·   r¼   rÁ   rã   rè   rû   r   r  r  r1  r7  rD  rG  rU  ra  rf  rn  rt  rw  ro   r  ÚCTR1ÚCTR2ÚCTR3ÚCTR4r|  r}  r~  rá   rÙ   Úfufuncsr´  ÚzipÚlocalsÚgetÚFUr‹  rö   r÷   rÓ   r"  r¨  r°  r¼  r¿  r­   r2   r0   Ú<module>rß     sÞ  ðÝ #å Ý $Ý  ß AÑ AÝ *Ý ß $Ý  Ý "Ý &Ý #Ý &Ý *Ý =÷<÷ <ñ <÷?÷ ?ó ?å /Ý (Ý (ß 1å ò)òò0ô<qòh.òb5ò@=ô@Bô*Bò*ô0HòV[ô|-ò`}ô@Mò`:ôz òFxòv,ò^tônvôrôBòBô@ò:+ò\.÷" ñ ‰C�Øˆ#ˆs�C˜˜c 3¨¨S°#°t¸TÀ4ÈØˆ(�D˜$  e¨U°Dð:ó;ó <ñ€Sˆ#ˆs�C˜˜c 3¨¨S°#°t¸TÀ4ÈØˆ(�D˜$  e¨U°Dð 
ˆcˆ
�S˜#�J Ð)€à��Sˆz˜C ˜: sÐ+Ð,€à	�3˜Ð˜x¨¨e°SÐ9¸8ÐD€à	ˆeˆ�hÐ€à
ˆC��d˜C  s¨CÐ0€ð 	ˆ#ˆt�S˜#˜tÐ$Øˆ#ˆt�SÐØ	ˆ4��d˜C  c¨4Ð0Øð	€ñ 3ô X*ôv'ðT!÷ "'¡£ð ñ 
‰$‰s�7™D¡¡V£X§\¡\°7Ó!;Ó<Ó=Ó
>Ó?€ð 	ñó 	ðð 	ñó 	ðð 	ñó 	ðôo7òd6òr%òP$òN(@ôV.r2   