
    \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    P/var/www/auris/envauris/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_%%88!&&(%%C&&)C&=3JsF#$z#v'>>> !c3Z  AFF|dODA::f%%1f%A1v{HqLzqrU12" HdDG $ Q46>3J## 
aB9277CDD
4yA~$q'V+VVDGV$!Wtj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 3x1}1v
a&++f!f
%C
3x1}
SECGOV,,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   