+
    	åûjg  ã                  óþ   € R 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 ^ R	IHt R
 R ltR R ltR R lt]R R l4       t]R R l4       t]R R l4       t]R R l4       tR R ltR# )aÛ  A module for special angle formulas for trigonometric functions

TODO
====

This module should be developed in the future to contain direct square root
representation of

.. math
    F(\frac{n}{m} \pi)

for every

- $m \in \{ 3, 5, 17, 257, 65537 \}$
- $n \in \mathbb{N}$, $0 \le n < m$
- $F \in \{\sin, \cos, \tan, \csc, \sec, \cot\}$

Without multi-step rewrites
(e.g. $\tan \to \cos/\sin \to \cos/\sqrt \to \ sqrt$)
or using chebyshev identities
(e.g. $\cos \to \cos + \cos^2 + \cdots \to \sqrt{} + \sqrt{}^2 + \cdots $),
which are trivial to implement in sympy,
and had used to give overly complicated expressions.

The reference can be found below, if anyone may need help implementing them.

References
==========

.. [*] Gottlieb, Christian. (1999). The Simple and straightforward construction
   of the regular 257-gon. The Mathematical Intelligencer. 21. 31-37.
   10.1007/BF03024829.
.. [*] https://resources.wolframcloud.com/FunctionRepository/resources/Cos2PiOverFermatPrime
)Úannotations)ÚCallable)Úreduce)ÚExpr)ÚS)Úigcdex)ÚInteger©Úsqrt)Úcacheitc               ó    € V ^8„  d   QhRRRR/# )é   ÚxÚintÚreturnztuple[tuple[int, ...], int]© )Úformats   "ÚmC:\Ai_Coding\apps\studio\ComfyUI\.venv\Lib\site-packages\sympy\functions\elementary\_trigonometric_special.pyÚ__annotate__r   .   s   € ÷ %'ñ %'�ð %'Ð3ñ %'ó    c                 ó,  a€ V '       g   R# \        V 4      ^8X  d   RV ^ ,          3# \        V 4      ^8X  d%   \        V ^ ,          V ^,          4      w  popVS3V3# \        V R,          !  w  r4\        V ^ ,          V4      w  popV.V3R lV 4       O5V3# )a  Compute extended gcd for multiple integers.

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

Given the integers $x_1, \cdots, x_n$ and
an extended gcd for multiple arguments are defined as a solution
$(y_1, \cdots, y_n), g$ for the diophantine equation
$x_1 y_1 + \cdots + x_n y_n = g$ such that
$g = \gcd(x_1, \cdots, x_n)$.

Examples
========

>>> from sympy.functions.elementary._trigonometric_special import migcdex
>>> migcdex()
((), 0)
>>> migcdex(4)
((1,), 4)
>>> migcdex(4, 6)
((-1, 1), 2)
>>> migcdex(6, 10, 15)
((1, 1, -1), 1)
:é   NNc              3  ó6   <"  € T F  pSV,          x € K  	  R # 5i©Nr   )Ú.0ÚiÚvs   & €r   Ú	<genexpr>Úmigcdex.<locals>.<genexpr>S   s   øé € Ð"¡˜1��Q—’£ùs   ƒ)r   é    )r   )Úlenr   Úmigcdex)r   ÚuÚhÚyÚgr   s   *    @r   r!   r!   .   s–   ø€ ÷2 Øˆä
ˆ1ƒv�„{Ø�Q�q•TˆzÐä
ˆ1ƒv�„{Ü˜˜1�˜q �tÓ$‰ˆˆ1ˆaØ�1ˆv�qˆyÐä�A�b•E‰?�D€AÜ�Q�q•T˜1‹o�G€A€qˆ!ØÐ#Ô"¡Ó"Ñ# QÐ&Ð&r   c               ó    € V ^8„  d   QhRRRR/# )r   Údenomsr   r   ztuple[int, ...]r   )r   s   "r   r   r   V   s   € ÷ Hñ H�sð H˜ñ Hr   c                 óŠ   € V '       g   R# R R lp\        W4      pV  Uu. uF  q2V,          NK  	  pp\        V!  w  rVV# u upi )a*  Compute the partial fraction decomposition.

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

Given a rational number $\frac{1}{q_1 \cdots q_n}$ where all
$q_1, \cdots, q_n$ are pairwise coprime,

A partial fraction decomposition is defined as

.. math::
    \frac{1}{q_1 \cdots q_n} = \frac{p_1}{q_1} + \cdots + \frac{p_n}{q_n}

And it can be derived from solving the following diophantine equation for
the $p_1, \cdots, p_n$

.. math::
    1 = p_1 \prod_{i \ne 1}q_i + \cdots + p_n \prod_{i \ne n}q_i

Where $q_1, \cdots, q_n$ being pairwise coprime implies
$\gcd(\prod_{i \ne 1}q_i, \cdots, \prod_{i \ne n}q_i) = 1$,
which guarantees the existence of the solution.

It is sufficient to compute partial fraction decomposition only
for numerator $1$ because partial fraction decomposition for any
$\frac{n}{q_1 \cdots q_n}$ can be easily computed by multiplying
the result by $n$ afterwards.

Parameters
==========

denoms : int
    The pairwise coprime integer denominators $q_i$ which defines the
    rational number $\frac{1}{q_1 \cdots q_n}$

Returns
=======

tuple[int, ...]
    The list of numerators which semantically corresponds to $p_i$ of the
    partial fraction decomposition
    $\frac{1}{q_1 \cdots q_n} = \frac{p_1}{q_1} + \cdots + \frac{p_n}{q_n}$

Examples
========

>>> from sympy import Rational, Mul
>>> from sympy.functions.elementary._trigonometric_special import ipartfrac

>>> denoms = 2, 3, 5
>>> numers = ipartfrac(2, 3, 5)
>>> numers
(1, 7, -14)

>>> Rational(1, Mul(*denoms))
1/30
>>> out = 0
>>> for n, d in zip(numers, denoms):
...    out += Rational(n, d)
>>> out
1/30
c               ó$   € V ^8„  d   QhRRRRRR/# )r   r   r   r$   r   r   )r   s   "r   r   Úipartfrac.<locals>.__annotate__˜   s!   € ÷ ñ ˆsð �sð ˜sñ r   c                ó   € W,          # r   r   )r   r$   s   &&r   ÚmulÚipartfrac.<locals>.mul˜   s	   € Ø�uˆr   r   )r   r!   )r'   r,   Údenomr   Úar#   Ú_s   *      r   Ú	ipartfracr1   V   sK   € ÷~ Øˆ	õô �3Ó€EÙ#Ó$™V˜�!�ˆ™V€AÐ$Ü�A‰;�D€AØ€Hùò 	%s    A c               ó    € V ^8„  d   QhRRRR/# )r   Únr   r   zlist[int] | Noner   )r   s   "r   r   r   ¡   s   € ÷ ñ �Sð Ð-ñ r   c                ó„   € . pR F7  p\        W4      w  r4V^ 8X  g   K  Tp VP                  V4       V ^8X  g   K5  Vu # 	  R# )zqIf n can be factored in terms of Fermat primes with
multiplicity of each being 1, return those primes, else
None
N)é   é   é   é  i  )ÚdivmodÚappend)r3   ÚprimesÚpÚquotientÚ	remainders   &    r   Úfermat_coordsr?   ¡   sH   € ð
 €FÛ#ˆÜ$ Q›lÑˆØ˜Ž>ØˆAØ�M‰M˜!ÔØ�AŽvØ’ñ $ñ r   c               ó   € V ^8„  d   QhRR/# ©r   r   r   r   )r   s   "r   r   r   ²   s   € ÷ ñ ˆtñ r   c                 ó"   € \         P                  # )z-Computes $\cos \frac{\pi}{3}$ in square roots)r   ÚHalfr   r   r   Úcos_3rD   ±   s   € ô �6‰6€Mr   c               ó   € V ^8„  d   QhRR/# rA   r   )r   s   "r   r   r   ¸   s   € ÷ ñ ˆtñ r   c                 ó4   € \        ^4      ^,           ^,          # )z-Computes $\cos \frac{\pi}{5}$ in square rootsr	   r   r   r   Úcos_5rG   ·   s   € ô �‹G�a�K˜1ÕÐr   c               ó   € V ^8„  d   QhRR/# rA   r   )r   s   "r   r   r   ¾   s   € ÷ ;ñ ;�ñ ;r   c                 óÞ  € \        ^\        ^4      ,           ^ ,          \        ^4      \        ^\        ^4      ,
          4      \        \        ^4      R\        ^\        ^4      ,           4      ,          ^\        ^4      ,
          \        ^\        ^4      ,
          4      ,          ,
          ,          ^\        ^4      ,          ,           ^",           4      ,           ,          ^ ,          ,           4      # )z.Computes $\cos \frac{\pi}{17}$ in square rootsiøÿÿÿr	   r   r   r   Úcos_17rJ   ½   s°   € ô Ø	Œd�2‹h�˜"Õœt A›w¬$¨r´D¸³H­}Ó*=ÜŒT�!‹W˜œT "¤t¨B£x¥-Ó0Õ0°A¼¸R»µLÜ
ˆr”D˜“H�}Ó
õ4õ õ Ø!"¤T¨"£X¥õ.Ø02õ3ó 	4õ+4õ  5à79õ :õ 	:ó;ð ;r   c               ó   € V ^8„  d   QhRR/# rA   r   )r   s   "r   r   r   Ç   s   € ÷ '1ñ '1�ñ '1r   c                 ó¤  € R R lp R R lpV ! \         P                  \        R4      4      w  r#V ! V\        ^@4      4      w  rEV ! V\        ^@4      4      w  rgV ! V^^V,           ^V,          ,           ,          4      w  r‰V ! V^^V,           ^V,          ,           ,          4      w  r«V ! V^^V,           ^V,          ,           ,          4      w  rÍV ! V^^V,           ^V,          ,           ,          4      w  rïV ! VRW(,           V,           ^V
,          ,           ,          4      w  ppV ! VRW;,           V,           ^V,          ,           ,          4      w  ppV ! VRW,,           V	,           ^V,          ,           ,          4      w  ppV ! VRW?,           V
,           ^V,          ,           ,          4      w  ppV ! V	RW),           V,           ^V,          ,           ,          4      w  ppV ! V
RW:,           V,           ^V,          ,           ,          4      w  ppV ! VRW-,           V,           ^V,          ,           ,          4      w  ppV ! VRW>,           V,           ^V	,          ,           ,          4      w  ppV! VRVV,           V,           V,           ,          4      p V! VRVV,           V,           V,           ,          4      p!V! VRVV,           V,           V,           ,          4      p"V! VRVV,           V,           V,           ,          4      p#V! VRVV,           V,           V,           ,          4      p$V! VRVV,           V,           V,           ,          4      p%V! V ) RV!V",           ,          4      ) p&V! V#) RV$V%,           ,          4      ) p'RV! V&) RV',          4      ,          p(\        \        ^4      \        V(^,           4      ,          ^,          \         P                  ,           4      # )zíComputes $\cos \frac{\pi}{257}$ in square roots

References
==========

.. [*] https://math.stackexchange.com/questions/516142/how-does-cos2-pi-257-look-like-in-real-radicals
.. [*] https://r-knott.surrey.ac.uk/Fibonacci/simpleTrig.html
c               ó$   € V ^8„  d   QhRRRRRR/# )r   r/   r   Úbr   ztuple[Expr, Expr]r   )r   s   "r   r   Úcos_257.<locals>.__annotate__Ð   s'   € ÷ Bñ Bˆdð B�tð BÐ 1ñ Br   c                óž   € V \        V ^,          V,           4      ,           ^,          V \        V ^,          V,           4      ,
          ^,          3# ©r   r	   ©r/   rN   s   &&r   Úf1Úcos_257.<locals>.f1Ð   s9   € Ø”D˜˜A� �“NÕ" aÕ'¨!¬d°1°aµ4¸!µ8«nÕ*<ÀÕ)AÐAÐAr   c               ó$   € V ^8„  d   QhRRRRRR/# )r   r/   r   rN   r   r   )r   s   "r   r   rO   Ó   s!   € ÷ &ñ &ˆdð &�tð & ñ &r   c                óP   € V \        V ^,          V,           4      ,
          ^,          # rQ   r	   rR   s   &&r   Úf2Úcos_257.<locals>.f2Ó   s   € Ø”D˜˜A� �“NÕ" AÕ%Ð%r   é   éüÿÿÿéþÿÿÿ)r   ÚNegativeOner   r
   rC   ))rS   rW   Út1Út2Úz1Úz3Úz2Úz4Úy1Úy5Úy6Úy2Úy3Úy7Úy8Úy4Úx1Úx9Úx2Úx10Úx3Úx11Úx4Úx12Úx5Úx13Úx6Úx14Úx15Úx7Úx8Úx16Úv1Úv2Úv3Úv4Úv5Úv6Úu1Úu2Úw1s)                                            r   Úcos_257r„   Æ   s  € õBõ&ñ ”—‘œw s›|Ó,�F€BÙ�”G˜B“KÓ �F€BÙ�”G˜B“KÓ �F€BÙ��A�q˜2•v  "¥•}Õ%Ó&�F€BÙ��A�q˜2•v  "¥•}Õ%Ó&�F€BÙ��A�q˜2•v  "¥•}Õ%Ó&�F€BÙ��A�q˜2•v  "¥•}Õ%Ó&�F€BÙ��B˜� "� q¨¥tÕ+Õ,Ó-�F€BˆÙ��R˜� 2�¨¨"­Õ,Õ-Ó.�G€BˆÙ��R˜� 2�¨¨"­Õ,Õ-Ó.�G€BˆÙ��R˜� 2�¨¨"­Õ,Õ-Ó.�G€BˆÙ��R˜� 2�¨¨"­Õ,Õ-Ó.�G€BˆÙ��R˜� 2�¨¨"­Õ,Õ-Ó.�G€BˆÙ��R˜� 2�¨¨"­Õ,Õ-Ó.�G€CˆÙ��R˜� 2�¨¨"­Õ,Õ-Ó.�G€BˆÙ	ˆB��B˜•G˜b•L 2Õ%Õ&Ó	'€BÙ	ˆB��B˜•G˜b•L 2Õ%Õ&Ó	'€BÙ	ˆB��B˜•G˜c•M CÕ'Õ(Ó	)€BÙ	ˆB��B˜•H˜s•N SÕ(Õ)Ó	*€BÙ	ˆC��S˜3•Y •_ sÕ*Õ+Ó	,€BÙ	ˆC��S˜2•X •] RÕ'Õ(Ó	)€BÙ
ˆbˆS�"�b˜2•g•,Ó
Ð	€BÙ
ˆbˆS�"�b˜2•g•,Ó
Ð	€BØ	‰B�ˆs�B�r•E‹NÕ	€BÜ”�Q“œ˜R !�V›Õ$ QÕ&¬¯©Õ/Ó0Ð0r   c               ó   € V ^8„  d   QhRR/# )r   r   zdict[int, Callable[[], Expr]]r   )r   s   "r   r   r   ñ   s   € ÷ ñ Ð0ñ r   c                 ó6   € ^\         ^\        ^\        R\        /# )aC  Lazily evaluated table for $\cos \frac{\pi}{n}$ in square roots for
$n \in \{3, 5, 17, 257, 65537\}$.

Notes
=====

65537 is the only other known Fermat prime and it is nearly impossible to
build in the current SymPy due to performance issues.

References
==========

https://r-knott.surrey.ac.uk/Fibonacci/simpleTrig.html
r8   )rD   rG   rJ   r„   r   r   r   Ú	cos_tabler‡   ñ   s"   € ð  	
Œ5Ø	Œ5Ø
ŒFØŒWð	ð r   N)Ú__doc__Ú
__future__r   Útypingr   Ú	functoolsr   Úsympy.core.exprr   Úsympy.core.singletonr   Úsympy.core.intfuncr   Úsympy.core.numbersr   Ú(sympy.functions.elementary.miscellaneousr
   Úsympy.core.cacher   r!   r1   r?   rD   rG   rJ   r„   r‡   r   r   r   Ú<module>r’      s�   ðñ!õD #Ý Ý Ý  Ý "Ý %Ý &Ý 9Ý $õ%'õPHõVð  	ôó 	ðð
 	ôó 	ðð
 	ô;ó 	ð;ð 	ô'1ó 	ð'1÷Tr   