+
    ig                        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   "o/var/www/html/photoedit/myenv/lib/python3.14/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 
1v{QqTz
1v{1qt$1a1vqyAbE?DAQqT1oGAq!#""#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!VA$A;DA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#$Ql>AMM!Av $ 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     66Mr   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     GaK1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 rootsir	   r   r   r   cos_17rJ      s     	d2h"tAw$rDH}*=T!WT"tBx-00ARL
rDH}
4  !"T"X.023 	4+4  579 : 	:; ;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  rV ! V^^V,           ^V,          ,           ,          4      w  rV ! V^^V,           ^V,          ,           ,          4      w  rV ! V^^V,           ^V,          ,           ,          4      w  rV ! 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      # )zComputes $\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'!d1a4!8n*<)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& ws|,FBGBK FBGBK FBAq2v"}%&FBAq2v"}%&FBAq2v"}%&FBAq2v"}%&FBB"qt+,-FBR2",-.GBR2",-.GBR2",-.GBR2",-.GBR2",-.GBR2",-.GCR2",-.GB	BBGbL2%&	'B	BBGbL2%&	'B	BBGcMC'(	)B	BBHsNS()	*B	CS3Y_s*+	,B	CS2X]R'(	)B
bS"b2g,
	B
bS"b2g,
	B	BsBrEN	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 	'1Tr   