ó
    Š*£h­  ã                   ól   • S SK JrJrJrJr  S SKJr  S SKJr  S SK	J
r
Jr  S SKJr  S SKJrJr  S rS rg	)
é    )ÚFunctionÚPowÚsympifyÚExpr)Ú
Relational)ÚS)ÚPolyÚ	decompose)Ú	func_name)ÚMinÚMaxc                 óv  ^• [        U 5      n [        U [        5      (       a  [        U [        5      (       a  [	        S[        U 5      -  5      eTU R                  ;  a  U /$ [        U [        [        45      (       at  U R                  (       a+  U R                  [        R                  :X  a  U R                  nOU R                  S   nUT:X  a  U /$ U R                  UT5      /[!        UT5      -   $ [        U ["        [$        45      (       a¡  ['        U R                  5      nSn[)        U5       H\  u  pVUR+                  T5      (       d  M  [!        UT5      n[-        U5      S:X  a  T/U-   nUc  USS nOUSS U:w  a  T/n  OUS   X5'   M^     WS   T:X  a  U /$ U R.                  " U6 /U-   $ [1        U 5      n['        [3        U4S jUR4                  5      5      n	[-        U	5      S:X  a3  U	S   T:w  a*  U R                  U	S   T5      n
U	S   nU
/[!        UT5      -   $  [7        U 5      $ ! [8         a    U /s $ f = f)aå  
Computes General functional decomposition of ``f``.
Given an expression ``f``, returns a list ``[f_1, f_2, ..., f_n]``,
where::
          f = f_1 o f_2 o ... f_n = f_1(f_2(... f_n))

Note: This is a General decomposition function. It also decomposes
Polynomials. For only Polynomial decomposition see ``decompose`` in polys.

Examples
========

>>> from sympy.abc import x
>>> from sympy import decompogen, sqrt, sin, cos
>>> decompogen(sin(cos(x)), x)
[sin(x), cos(x)]
>>> decompogen(sin(x)**2 + sin(x) + 1, x)
[x**2 + x + 1, sin(x)]
>>> decompogen(sqrt(6*x**2 - 5), x)
[sqrt(x), 6*x**2 - 5]
>>> decompogen(sin(sqrt(cos(x**2 + 1))), x)
[sin(x), sqrt(x), cos(x), x**2 + 1]
>>> decompogen(x**4 + 2*x**3 - x - 1, x)
[x**2 - x - 1, x**2 + x]

zexpecting Expr but got: `%s`r   Né   c                 ó"   >• TU R                   ;   $ )N)Úfree_symbols)ÚxÚsymbols    €ÚU/home/mande/repo/quber/.venv/lib/python3.13/site-packages/sympy/solvers/decompogen.pyÚ<lambda>Údecompogen.<locals>.<lambda>M   s   ø€  ¨1¯>©>Ò!9ó    )r   Ú
isinstancer   r   Ú	TypeErrorr   r   r   r   Úis_PowÚbaser   ÚExp1ÚexpÚargsÚsubsÚ
decompogenr   r   ÚlistÚ	enumerateÚhas_freeÚlenÚfuncr	   ÚfilterÚgensr
   Ú
ValueError)Úfr   Úargr   Úd0ÚiÚaÚdÚfpr'   Úf1Úf2s    `          r   r    r    	   s  ø€ ô6 	�‹
€AÜ�aœ×Ñ¤*¨Q´
×";Ñ";ÜÐ6¼À1»ÑEÓFÐFØ�Q—^‘^Ó#Øˆsˆ
ô �!”h¤�_×%Ñ%Ø�8�8˜Ÿ™¤!§&¡&Ó(Ø—%‘%‰Cà—&‘&˜‘)ˆCØ�&‹=Ø�3ˆJØ—‘�s˜FÓ#Ð$¤z°#°vÓ'>Ñ>Ð>ô �!”cœ3�Z× Ñ Ü�A—F‘F‹|ˆØˆÜ˜d–O‰DˆAØ—:‘:˜f×%Ñ%ÙÜ˜1˜fÓ%ˆAÜ�1‹v˜‹{Ø�H˜q‘L�Ø‰zØ�q�r�U‘Ø�1�2�˜"“ð �H�ÙØ˜‘dˆD‹Gñ $ð ˆQ‰4�6‹>Ø�3ˆJØ—’˜�ˆ Ñ#Ð#ô 
ˆa‹€BÜ”Ô9¸2¿7¹7ÓCÓD€Dä
ˆ4ƒy�Aƒ~˜$˜q™' VÓ+Ø�V‰V�D˜‘G˜VÓ$ˆØ�!‰WˆØˆt”j  VÓ,Ñ,Ð,ðÜ˜‹|ÐøÜó ØˆsŠ
ðús   È
H( È(H8È7H8c                 ó    • [        U 5      S:X  a  U S   $ U S   R                  XS   5      n[        U 5      S:X  a  U$ [        U/U SS -   U5      $ )aØ  
Returns the composition of functions.
Given a list of functions ``g_s``, returns their composition ``f``,
where:
    f = g_1 o g_2 o .. o g_n

Note: This is a General composition function. It also composes Polynomials.
For only Polynomial composition see ``compose`` in polys.

Examples
========

>>> from sympy.solvers.decompogen import compogen
>>> from sympy.abc import x
>>> from sympy import sqrt, sin, cos
>>> compogen([sin(x), cos(x)], x)
sin(cos(x))
>>> compogen([x**2 + x + 1, sin(x)], x)
sin(x)**2 + sin(x) + 1
>>> compogen([sqrt(x), 6*x**2 - 5], x)
sqrt(6*x**2 - 5)
>>> compogen([sin(x), sqrt(x), cos(x), x**2 + 1], x)
sin(sqrt(cos(x**2 + 1)))
>>> compogen([x**2 - x - 1, x**2 + x], x)
-x**2 - x + (x**2 + x)**2 - 1
r   r   é   N)r$   r   Úcompogen)Úg_sr   Úfoos      r   r4   r4   [   sW   € ô6 ˆ3ƒx�1ƒ}Ø�1‰vˆà
ˆa‰&�+‰+�f !™fÓ
%€Cä
ˆ3ƒx�1ƒ}Øˆ
ä�S�E˜C  ˜G‘O VÓ,Ð,r   N)Ú
sympy.corer   r   r   r   Úsympy.core.relationalr   Úsympy.core.singletonr   Úsympy.polysr	   r
   Úsympy.utilities.miscr   Ú(sympy.functions.elementary.miscellaneousr   r   r    r4   © r   r   Ú<module>r>      s&   ðß 5Ó 5Ý ,Ý "ß 'Ý *ß =òOód#-r   