+
    ‹°³j0  ã                   óp   € ^ RI t ^ RIHt ^ RIHtHt ^ RIHt ^ RIH	t	   ! R R]4      t
 ! R R	]4      tR# )
é    N)ÚInterval)Úis_increasingÚis_decreasing)ÚOptimization)ÚUndefinedFunctionc                   óH   a a€ ] tR t^t oRtV 3R ltR tR tR tRt	Vt
V ;t# )Ú	SumApproxaÀ  
Approximates sum by neglecting small terms.

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

If terms are expressions which can be determined to be monotonic, then
bounds for those expressions are added.

Parameters
==========

bounds : dict
    Mapping expressions to length 2 tuple of bounds (low, high).
reltol : number
    Threshold for when to ignore a term. Taken relative to the largest
    lower bound among bounds.

Examples
========

>>> from sympy import exp
>>> from sympy.abc import x, y, z
>>> from sympy.codegen.rewriting import optimize
>>> from sympy.codegen.approximations import SumApprox
>>> bounds = {x: (-1, 1), y: (1000, 2000), z: (-10, 3)}
>>> sum_approx3 = SumApprox(bounds, reltol=1e-3)
>>> sum_approx2 = SumApprox(bounds, reltol=1e-2)
>>> sum_approx1 = SumApprox(bounds, reltol=1e-1)
>>> expr = 3*(x + y + exp(z))
>>> optimize(expr, [sum_approx3])
3*(x + y + exp(z))
>>> optimize(expr, [sum_approx2])
3*y + 3*exp(z)
>>> optimize(expr, [sum_approx1])
3*y

c                ó@   <€ \         SV `  ! R/ VB  Wn        W n        R # )N© )ÚsuperÚ__init__ÚboundsÚreltol)Úselfr   r   ÚkwargsÚ	__class__s   &&&,€Ú]/home/luca/screen-checking/.venv/lib/python3.14/site-packages/sympy/codegen/approximations.pyr   ÚSumApprox.__init__6   s   ø€ Ü‰ÒÑ"˜6Ò"ØŒØŽó    c                ó`   a € VP                  4       P                  S P                  V 3R  l4      # )c                 ó&   <€ SP                  V 4      # ©N©Úvalue©Úargr   s   &€r   Ú<lambda>Ú$SumApprox.__call__.<locals>.<lambda><   ó   ø€ ¸T¿Z¹ZÈ¼_r   ©ÚfactorÚreplaceÚquery©r   Úexprs   f&r   Ú__call__ÚSumApprox.__call__;   ó!   ø€ Ø�{‰{‹}×$Ñ$ T§Z¡ZÔ1LÓMÐMr   c                ó   € VP                   # r   )Úis_Addr$   s   &&r   r#   ÚSumApprox.query>   s   € Ø�{‰{Ðr   c           
     óÂ  a € VP                    EFn  pVP                  '       g,   VS P                  9   g   \        VP                  4      ^8w  d   KC  VP                  w  pVS P                  9  d   Kd  \        S P                  V,          !  p\        W$V4      '       df   VP                  VS P                  V,          ^ ,          /4      VP                  VS P                  V,          ^,          /4      3S P                  V&   Kõ  \        W$V4      '       dg   VP                  VS P                  V,          ^,          /4      VP                  VS P                  V,          ^ ,          /4      3S P                  V&   EKm  Vu # 	  \        ;QJ d)    V 3R lVP                    4       F  '       d   K   RM	  RM! V 3R lVP                    4       4      '       Ed   VP                    Uu. uF*  q"P                  '       d   W"3MS P                  V,          NK,  	  pp^ pV FA  w  rxV^ u;8:  d   V8:  d   M MK  \        V\        \        V4      \        V4      4      4      pKC  	  . p	\        VP                   V4       FO  w  pw  rx\        \        V4      \        V4      4      VS P                  ,          8¼  g   K>  V	P                  V4       KQ  	  VP                   ! V	!  # V# u upi )é   c              3   óh   <"  € T F'  qP                   ;'       g    VSP                  9   x € K)  	  R # 5ir   )Ú	is_numberr   )Ú.0Útermr   s   & €r   Ú	<genexpr>Ú"SumApprox.value.<locals>.<genexpr>V   s'   øé € ÐJÁ¸�~‰~×4Ð4 ¨¯©Ñ!4Ô4Ãùs   ƒ2š2FT)Úargsr/   r   ÚlenÚfree_symbolsr   r   Úsubsr   ÚallÚmaxÚminÚabsÚzipr   ÚappendÚfunc)
r   Úaddr1   ÚfsÚintrvlr   Úlargest_abs_guaranteeÚloÚhiÚ	new_termss
   f&        r   r   ÚSumApprox.valueA   s0  ø€ Ø—H•HˆDØ�~�~ˆ~ ¨¯©Ô!4¼¸D×<MÑ<MÓ8NÐRSÔ8SÙØ×#Ñ#‰CˆBØ˜Ÿ™Ô$ÙÜ˜tŸ{™{¨2�Ñ/ˆFÜ˜T¨2×.Ò.à—I‘I˜r 4§;¡;¨r¥?°1Õ#5Ð6Ó7Ø—I‘I˜r 4§;¡;¨r¥?°1Õ#5Ð6Ó7ð%�—‘˜DÓ!ô ˜t¨R×0Ò0à—I‘I˜r 4§;¡;¨r¥?°1Õ#5Ð6Ó7Ø—I‘I˜r 4§;¡;¨r¥?°1Õ#5Ð6Ó7ð%�—‘˜DÔ!ð
 ’
ñ% ÷( ‹3ÔJÀÇÂÓJ�3�3Š3ÔJÀÇÂÓJ×JÓJØX[×X`ÒX`ÓaÑX`ÐPT§n§n n�t‘l¸$¿+¹+ÀdÕ:KÒKÑX`ˆFÐaØ$%Ð!Û ‘�Ø˜–=˜b—=ÙÜ(+Ð,AÜ,/´°B³¼¸R»Ó,Aó)CÒ%ñ !ð
 ˆIÜ"% c§h¡h°Ö"7‘�‘h�rÜ”s˜2“w¤ B£Ó(Ð,AÀ$Ç+Á+Õ,MÖMØ×$Ñ$ TÖ*ñ #8ð —8’8˜YÑ'Ð'àˆJùò bs   Ç$0K)r   r   ©Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r   r&   r#   r   Ú__static_attributes__Ú__classdictcell__Ú__classcell__©r   Ú__classdict__s   @@r   r	   r	      s%   ù‡ € ñ%õNò
Nò÷#ò #r   r	   c                   óL   a a€ ] tR t^gt oRtRV 3R lltR tR tR tRt	Vt
V ;t# )ÚSeriesApproxa£  Approximates functions by expanding them as a series.

Parameters
==========

bounds : dict
    Mapping expressions to length 2 tuple of bounds (low, high).
reltol : number
    Threshold for when to ignore a term. Taken relative to the largest
    lower bound among bounds.
max_order : int
    Largest order to include in series expansion
n_point_checks : int (even)
    The validity of an expansion (with respect to reltol) is checked at
    discrete points (linearly spaced over the bounds of the variable). The
    number of points used in this numerical check is given by this number.

Examples
========

>>> from sympy import sin, pi
>>> from sympy.abc import x, y
>>> from sympy.codegen.rewriting import optimize
>>> from sympy.codegen.approximations import SeriesApprox
>>> bounds = {x: (-.1, .1), y: (pi-1, pi+1)}
>>> series_approx2 = SeriesApprox(bounds, reltol=1e-2)
>>> series_approx3 = SeriesApprox(bounds, reltol=1e-3)
>>> series_approx8 = SeriesApprox(bounds, reltol=1e-8)
>>> expr = sin(x)*sin(y)
>>> optimize(expr, [series_approx2])
x*(-y + (y - pi)**3/6 + pi)
>>> optimize(expr, [series_approx3])
(-x**3/6 + x)*sin(y)
>>> optimize(expr, [series_approx8])
sin(x)*sin(y)

c                óþ   <€ \         SV `  ! R/ VB  Wn        W n        W0n        V^,          ^8X  d   \        R4      hW@n        \        P                  ! \        P                  ! V P                  4      ) 4      V n
        R# )é   z7Checking the solution at expansion point is not helpfulNr   )r   r   r   r   Ú	max_orderÚ
ValueErrorÚn_point_checksÚmathÚceilÚlog10Ú_prec)r   r   r   rV   rX   r   r   s   &&&&&,€r   r   ÚSeriesApprox.__init__�   sa   ø€ Ü‰ÒÑ"˜6Ò"ØŒØŒØ"ŒØ˜AÕ Ô"ÜÐVÓWÐWØ,ÔÜ—Y’Y¤§
¢
¨4¯;©;Ó 7Ð7Ó8ˆŽ
r   c                ó`   a € VP                  4       P                  S P                  V 3R  l4      # )c                 ó&   <€ SP                  V 4      # r   r   r   s   &€r   r   Ú'SeriesApprox.__call__.<locals>.<lambda>˜   r   r   r    r$   s   f&r   r&   ÚSeriesApprox.__call__—   r(   r   c                ó”   € VP                   ;'       d6    \        V\        4      '       * ;'       d    \        VP                  4      ^8H  # )r-   )Úis_FunctionÚ
isinstancer   r5   r4   r$   s   &&r   r#   ÚSeriesApprox.queryš   sA   € Ø× Ñ ÷ (ð (¬°DÔ:KÓ)LÔ%L÷ (ð (Ü˜Ÿ	™	“N aÑ'ð	)r   c                óÐ  € VP                   p\        V4      ^8w  d   V# Vw  pW0P                  9  d   V# V P                  V,          w  rEWE,           ^,          pRp\        V P                  ^,           ^ R4       Fã  pVP                  W6VR7      P                  4       p	Rp
\        V P                  4       F˜  pWKWT,
          ,          V P                  ^,
          ,          ,           pV	P                  W</4      pVP                  W</4      p\        ^WÞ,          ,
          P                  V P                  4      4      V P                  8”  g   K–  Rp
 M	  V
'       d   T	pKã   M	  Vf   V# V# )r-   N)Úx0ÚnTFéÿÿÿÿ)r6   r5   r   ÚrangerV   ÚseriesÚremoveOrX   Úxreplacer;   Úevalfr\   r   )r   Úfexprr6   ÚsymbrC   rD   rg   Úcheapestrh   ÚfseriÚn_okÚidxÚxÚvalÚrefs   &&             r   r   ÚSeriesApprox.valuež   s1  € Ø×)Ñ)ˆÜˆ|Ó Ô!ØˆLØ‰ˆØ—{‘{Ô"ØˆLØ—‘˜TÕ"‰ˆØ�g�q�[ˆØˆÜ�t—~‘~ aÕ'¨¨BÖ/ˆAØ—L‘L °�LÓ2×:Ñ:Ó<ˆEØˆDÜ˜T×0Ñ0Ö1�Ø˜b�g�¨×(;Ñ(;¸aÕ(?Õ@Õ@�Ø—n‘n d YÓ/�Ø—n‘n d YÓ/�Ü˜˜C�G�×*Ñ*¨4¯:©:Ó6Ó7¸$¿+¹+ÖEØ �DÙñ 2÷ Ø ’áñ 0ð  ÒØˆLàˆOr   )r\   r   rV   rX   r   )é   ry   rG   rP   s   @@r   rS   rS   g   s%   ù‡ € ñ$÷J9òNò)÷ò r   rS   )rY   Úsympy.sets.setsr   Úsympy.calculus.singularitiesr   r   Úsympy.codegen.rewritingr   Úsympy.core.functionr   r	   rS   r   r   r   Ú<module>r~      s6   ðÛ Ý $ß EÝ 0Ý 1ðôV�ô VôrT�<ö Tr   