
    ЦiK.                        S r SSKJrJr  SSK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 r " S	 S
\5      rS r " S S\5      r\	" S5      rS r " S S\5      rS r " S S\5      rS r " S S\5      r\	" S5      rS r " S S\5      rS r " S S\5      rS r " S  S!\5      r S" r! " S# S$\5      r" " S% S&\5      r#g')(a#  
This module contains SymPy functions mathcin corresponding to special math functions in the
C standard library (since C99, also available in C++11).

The functions defined in this module allows the user to express functions such as ``expm1``
as a SymPy function for symbolic manipulation.

    )ArgumentIndexErrorFunction)Rational)Pow)S)explog)sqrtc                 :    [        U 5      [        R                  -
  $ Nr   r   Onexs    W/var/www/html/ai-image-ml/venv/lib/python3.13/site-packages/sympy/codegen/cfunctions.py_expm1r      s    q6AEE>    c                   R    \ rS rSrSrSrSS jrS rS r\r	\
S 5       rS rS	 rS
rg)expm1   a  
Represents the exponential function minus one.

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

The benefit of using ``expm1(x)`` over ``exp(x) - 1``
is that the latter is prone to cancellation under finite precision
arithmetic when x is close to zero.

Examples
========

>>> from sympy.abc import x
>>> from sympy.codegen.cfunctions import expm1
>>> '%.0e' % expm1(1e-99).evalf()
'1e-99'
>>> from math import exp
>>> exp(1e-99) - 1
0.0
>>> expm1(x).diff(x)
exp(x)

See Also
========

log1p
   c                 H    US:X  a  [        U R                  6 $ [        X5      e0
Returns the first derivative of this function.
r   )r   argsr   selfargindexs     r   fdiffexpm1.fdiff4   s$     q=		?"$T44r   c                 &    [        U R                  6 $ r   )r   r   r   hintss     r   _eval_expand_funcexpm1._eval_expand_func=       tyy!!r   c                 :    [        U5      [        R                  -
  $ r   r   r   argkwargss      r   _eval_rewrite_as_expexpm1._eval_rewrite_as_exp@   s    3x!%%r   c                 \    [         R                  " U5      nUb  U[        R                  -
  $ g r   )r   evalr   r   )clsr)   exp_args      r   r.   
expm1.evalE   s(    ((3-QUU?" r   c                 4    U R                   S   R                  $ Nr   )r   is_realr   s    r   _eval_is_realexpm1._eval_is_realK       yy|###r   c                 4    U R                   S   R                  $ r3   )r   	is_finiter5   s    r   _eval_is_finiteexpm1._eval_is_finiteN   s    yy|%%%r    Nr   )__name__
__module____qualname____firstlineno____doc__nargsr   r$   r+   _eval_rewrite_as_tractableclassmethodr.   r6   r;   __static_attributes__r=   r   r   r   r      sA    8 E5"  "6# #
$&r   r   c                 :    [        U [        R                  -   5      $ r   )r	   r   r   r   s    r   _log1prI   R   s    q155y>r   c                   d    \ rS rSrSrSrSS jrS rS r\r	\
S 5       rS rS	 rS
 rS rS rSrg)log1pV   a  
Represents the natural logarithm of a number plus one.

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

The benefit of using ``log1p(x)`` over ``log(x + 1)``
is that the latter is prone to cancellation under finite precision
arithmetic when x is close to zero.

Examples
========

>>> from sympy.abc import x
>>> from sympy.codegen.cfunctions import log1p
>>> from sympy import expand_log
>>> '%.0e' % expand_log(log1p(1e-99)).evalf()
'1e-99'
>>> from math import log
>>> log(1 + 1e-99)
0.0
>>> log1p(x).diff(x)
1/(x + 1)

See Also
========

expm1
r   c                     US:X  a1  [         R                  U R                  S   [         R                  -   -  $ [        X5      er   r   r   )r   r   r   r   r   s     r   r   log1p.fdiffw   s6     q=55$))A,.//$T44r   c                 &    [        U R                  6 $ r   )rI   r   r"   s     r   r$   log1p._eval_expand_func   r&   r   c                     [        U5      $ r   )rI   r(   s      r   _eval_rewrite_as_loglog1p._eval_rewrite_as_log       c{r   c                 :   UR                   (       a  [        U[        R                  -   5      $ UR                  (       d'  [        R
                  " U[        R                  -   5      $ UR                  (       a%  [        [        U5      [        R                  -   5      $ g r   )is_Rationalr	   r   r   is_Floatr.   	is_numberr   r/   r)   s     r   r.   
log1p.eval   s^    ??sQUU{##88C!%%K((]]x}quu,-- r   c                 V    U R                   S   [        R                  -   R                  $ r3   )r   r   r   is_nonnegativer5   s    r   r6   log1p._eval_is_real   s    		!quu$444r   c                     U R                   S   [        R                  -   R                  (       a  gU R                   S   R                  $ )Nr   F)r   r   r   is_zeror:   r5   s    r   r;   log1p._eval_is_finite   s3    IIaL155 ))yy|%%%r   c                 4    U R                   S   R                  $ r3   )r   is_positiver5   s    r   _eval_is_positivelog1p._eval_is_positive   s    yy|'''r   c                 4    U R                   S   R                  $ r3   )r   r`   r5   s    r   _eval_is_zerolog1p._eval_is_zero   r8   r   c                 4    U R                   S   R                  $ r3   )r   r]   r5   s    r   _eval_is_nonnegativelog1p._eval_is_nonnegative   s    yy|***r   r=   Nr>   )r?   r@   rA   rB   rC   rD   r   r$   rS   rE   rF   r.   r6   r;   rd   rg   rj   rG   r=   r   r   rK   rK   V   sP    : E5" "6. .5&
($+r   rK      c                 "    [        [        U 5      $ r   )r   _Twor   s    r   _exp2ro      s    tQ<r   c                   F    \ rS rSrSrSrS
S jrS r\rS r	\
S 5       rSrg	)exp2   a  
Represents the exponential function with base two.

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

The benefit of using ``exp2(x)`` over ``2**x``
is that the latter is not as efficient under finite precision
arithmetic.

Examples
========

>>> from sympy.abc import x
>>> from sympy.codegen.cfunctions import exp2
>>> exp2(2).evalf() == 4.0
True
>>> exp2(x).diff(x)
log(2)*exp2(x)

See Also
========

log2
r   c                 H    US:X  a  U [        [        5      -  $ [        X5      er   )r	   rn   r   r   s     r   r   
exp2.fdiff   s$     q=D	>!$T44r   c                     [        U5      $ r   )ro   r(   s      r   _eval_rewrite_as_Powexp2._eval_rewrite_as_Pow       Szr   c                 &    [        U R                  6 $ r   )ro   r   r"   s     r   r$   exp2._eval_expand_func       dii  r   c                 <    UR                   (       a  [        U5      $ g r   )rY   ro   rZ   s     r   r.   	exp2.eval   s    ==: r   r=   Nr>   )r?   r@   rA   rB   rC   rD   r   rv   rE   r$   rF   r.   rG   r=   r   r   rq   rq      s9    2 E5 "6!  r   rq   c                 8    [        U 5      [        [        5      -  $ r   )r	   rn   r   s    r   _log2r          q6#d)r   c                   L    \ rS rSrSrSrSS jr\S 5       rS r	S r
S r\rS	rg
)log2   a  
Represents the logarithm function with base two.

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

The benefit of using ``log2(x)`` over ``log(x)/log(2)``
is that the latter is not as efficient under finite precision
arithmetic.

Examples
========

>>> from sympy.abc import x
>>> from sympy.codegen.cfunctions import log2
>>> log2(4).evalf() == 2.0
True
>>> log2(x).diff(x)
1/(x*log(2))

See Also
========

exp2
log10
r   c                     US:X  a0  [         R                  [        [        5      U R                  S   -  -  $ [        X5      erN   )r   r   r	   rn   r   r   r   s     r   r   
log2.fdiff   6     q=55#d)DIIaL011$T44r   c                     UR                   (       a-  [        R                  " U[        S9nUR                  (       a  U$ g UR
                  (       a!  UR                  [        :X  a  UR                  $ g g N)base)rY   r	   r.   rn   is_Atomis_Powr   r   r/   r)   results      r   r.   	log2.eval  L    ==XXc-F~~ ZZCHH,77N -Zr   c                 L    U R                  [        5      R                  " U0 UD6$ r   )rewriter	   evalf)r   r   r*   s      r   _eval_evalflog2._eval_evalf  s!    ||C &&777r   c                 &    [        U R                  6 $ r   )r   r   r"   s     r   r$   log2._eval_expand_func  r{   r   c                     [        U5      $ r   )r   r(   s      r   rS   log2._eval_rewrite_as_log  rx   r   r=   Nr>   )r?   r@   rA   rB   rC   rD   r   rF   r.   r   r$   rS   rE   rG   r=   r   r   r   r      s>    4 E5  8! "6r   r   c                     X-  U-   $ r   r=   )r   yzs      r   _fmar     s    37Nr   c                   6    \ rS rSrSrSrS	S jrS rS
S jrSr	g)fmai   a\  
Represents "fused multiply add".

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

The benefit of using ``fma(x, y, z)`` over ``x*y + z``
is that, under finite precision arithmetic, the former is
supported by special instructions on some CPUs.

Examples
========

>>> from sympy.abc import x, y, z
>>> from sympy.codegen.cfunctions import fma
>>> fma(x, y, z).diff(x)
y

   c                 t    US;   a  U R                   SU-
     $ US:X  a  [        R                  $ [        X5      e)r   r   rl   rl   r   )r   r   r   r   r   s     r   r   	fma.fdiff6  s:     v99Q\**]55L$T44r   c                 &    [        U R                  6 $ r   )r   r   r"   s     r   r$   fma._eval_expand_funcB  s    TYYr   Nc                     [        U5      $ r   )r   )r   r)   limitvarr*   s       r   rE   fma._eval_rewrite_as_tractableE  s    Cyr   r=   r>   r   )
r?   r@   rA   rB   rC   rD   r   r$   rE   rG   r=   r   r   r   r      s    & E	5 r   r   
   c                 8    [        U 5      [        [        5      -  $ r   )r	   _Tenr   s    r   _log10r   L  r   r   c                   F    \ rS rSrSrSrS
S jr\S 5       rS r	S r
\
rSrg	)log10iP  z
Represents the logarithm function with base ten.

Examples
========

>>> from sympy.abc import x
>>> from sympy.codegen.cfunctions import log10
>>> log10(100).evalf() == 2.0
True
>>> log10(x).diff(x)
1/(x*log(10))

See Also
========

log2
r   c                     US:X  a0  [         R                  [        [        5      U R                  S   -  -  $ [        X5      erN   )r   r   r	   r   r   r   r   s     r   r   log10.fdiffe  r   r   c                     UR                   (       a-  [        R                  " U[        S9nUR                  (       a  U$ g UR
                  (       a!  UR                  [        :X  a  UR                  $ g g r   )rY   r	   r.   r   r   r   r   r   r   s      r   r.   
log10.evalo  r   r   c                 &    [        U R                  6 $ r   )r   r   r"   s     r   r$   log10._eval_expand_funcx  r&   r   c                     [        U5      $ r   )r   r(   s      r   rS   log10._eval_rewrite_as_log{  rU   r   r=   Nr>   )r?   r@   rA   rB   rC   rD   r   rF   r.   r$   rS   rE   rG   r=   r   r   r   r   P  s9    $ E5  " "6r   r   c                 6    [        U [        R                  5      $ r   )r   r   Halfr   s    r   _Sqrtr     s    q!&&>r   c                   6    \ rS rSrSrSrS	S jrS rS r\r	Sr
g)
Sqrti  a  
Represents the square root function.

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

The reason why one would use ``Sqrt(x)`` over ``sqrt(x)``
is that the latter is internally represented as ``Pow(x, S.Half)`` which
may not be what one wants when doing code-generation.

Examples
========

>>> from sympy.abc import x
>>> from sympy.codegen.cfunctions import Sqrt
>>> Sqrt(x)
Sqrt(x)
>>> Sqrt(x).diff(x)
1/(2*sqrt(x))

See Also
========

Cbrt
r   c                 x    US:X  a*  [        U R                  S   [        SS5      5      [        -  $ [	        X5      e)r   r   r   rl   r   r   r   rn   r   r   s     r   r   
Sqrt.fdiff  s6     q=tyy|Xb!_5d::$T44r   c                 &    [        U R                  6 $ r   )r   r   r"   s     r   r$   Sqrt._eval_expand_func  r{   r   c                     [        U5      $ r   )r   r(   s      r   rv   Sqrt._eval_rewrite_as_Pow  rx   r   r=   Nr>   r?   r@   rA   rB   rC   rD   r   r$   rv   rE   rG   r=   r   r   r   r     s%    2 E5! "6r   r   c                 .    [        U [        SS5      5      $ )Nr   r   )r   r   r   s    r   _Cbrtr     s    q(1a.!!r   c                   6    \ rS rSrSrSrS	S jrS rS r\r	Sr
g)
Cbrti  a  
Represents the cube root function.

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

The reason why one would use ``Cbrt(x)`` over ``cbrt(x)``
is that the latter is internally represented as ``Pow(x, Rational(1, 3))`` which
may not be what one wants when doing code-generation.

Examples
========

>>> from sympy.abc import x
>>> from sympy.codegen.cfunctions import Cbrt
>>> Cbrt(x)
Cbrt(x)
>>> Cbrt(x).diff(x)
1/(3*x**(2/3))

See Also
========

Sqrt
r   c                 ~    US:X  a-  [        U R                  S   [        [        * S-  5      5      S-  $ [	        X5      e)r   r   r   r   r   r   s     r   r   
Cbrt.fdiff  s;     q=tyy|XteAg%6799$T44r   c                 &    [        U R                  6 $ r   )r   r   r"   s     r   r$   Cbrt._eval_expand_func  r{   r   c                     [        U5      $ r   )r   r(   s      r   rv   Cbrt._eval_rewrite_as_Pow  rx   r   r=   Nr>   r   r=   r   r   r   r     s%    2 E5! "6r   r   c                 F    [        [        U S5      [        US5      -   5      $ )Nrl   )r
   r   )r   r   s     r   _hypotr     s    Aq	C1I%&&r   c                   6    \ rS rSrSrSrS	S jrS rS r\r	Sr
g)
hypoti  a  
Represents the hypotenuse function.

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

The hypotenuse function is provided by e.g. the math library
in the C99 standard, hence one may want to represent the function
symbolically when doing code-generation.

Examples
========

>>> from sympy.abc import x, y
>>> from sympy.codegen.cfunctions import hypot
>>> hypot(3, 4).evalf() == 5.0
True
>>> hypot(x, y)
hypot(x, y)
>>> hypot(x, y).diff(x)
x/hypot(x, y)

rl   c                     US;   a6  SU R                   US-
     -  [        U R                  " U R                   6 -  -  $ [        X5      e)r   r   rl   r   )r   rn   funcr   r   s     r   r   hypot.fdiff  sF     vTYYxz**DDII1F,FGG$T44r   c                 &    [        U R                  6 $ r   )r   r   r"   s     r   r$   hypot._eval_expand_func  r&   r   c                     [        U5      $ r   )r   r(   s      r   rv   hypot._eval_rewrite_as_Pow  rU   r   r=   Nr>   r   r=   r   r   r   r     s%    . E5" "6r   r   c                       \ rS rSrSrSrg)isnani  r   r=   N)r?   r@   rA   rB   rD   rG   r=   r   r   r   r     s    Er   r   N)$rC   sympy.core.functionr   r   sympy.core.numbersr   sympy.core.powerr   sympy.core.singletonr   &sympy.functions.elementary.exponentialr   r	   (sympy.functions.elementary.miscellaneousr
   r   r   rI   rK   rn   ro   rq   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r=   r   r   <module>r      s    = '   " ; 9:&H :&zK+H K+Z 	t18 1h968 96x&( &R 	u.6H .6b+68 +6\",68 ,6^'*6H *6ZH r   