
    \h+0                        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SKJrJr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' " 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)sqrt)BooleanFunctiontruefalsec                 :    [        U 5      [        R                  -
  $ Nr   r   Onexs    P/var/www/auris/envauris/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   r1   
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                  $ r6   )r   	is_finiter8   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classmethodr1   r9   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   _log1prL   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   )rL   r   r%   s     r   r'   log1p._eval_expand_func   r)   r   c                     [        U5      $ r   )rL   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_Floatr1   	is_numberr   r2   r,   s     r   r1   
log1p.eval   s^    ??sQUU{##88C!%%K((]]x}quu,-- r   c                 V    U R                   S   [        R                  -   R                  $ r6   )r   r   r   is_nonnegativer8   s    r   r9   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=   r8   s    r   r>   log1p._eval_is_finite   s3    IIaL155 ))yy|%%%r   c                 4    U R                   S   R                  $ r6   )r   is_positiver8   s    r   _eval_is_positivelog1p._eval_is_positive   s    yy|'''r   c                 4    U R                   S   R                  $ r6   )r   rc   r8   s    r   _eval_is_zerolog1p._eval_is_zero   r;   r   c                 4    U R                   S   R                  $ r6   )r   r`   r8   s    r   _eval_is_nonnegativelog1p._eval_is_nonnegative   s    yy|***r   r@   NrA   )rB   rC   rD   rE   rF   rG   r"   r'   rV   rH   rI   r1   r9   r>   rg   rj   rm   rJ   r@   r   r   rN   rN   V   sP    : E5" "6. .5&
($+r   rN      c                 "    [        [        U 5      $ r   )r   _Twor   s    r   _exp2rr      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	   rq   r   r   s     r   r"   
exp2.fdiff   s$     q=D	>!$T44r   c                     [        U5      $ r   )rr   r+   s      r   _eval_rewrite_as_Powexp2._eval_rewrite_as_Pow       Szr   c                 &    [        U R                  6 $ r   )rr   r   r%   s     r   r'   exp2._eval_expand_func       dii  r   c                 <    UR                   (       a  [        U5      $ g r   )r\   rr   r]   s     r   r1   	exp2.eval   s    ==: r   r@   NrA   )rB   rC   rD   rE   rF   rG   r"   ry   rH   r'   rI   r1   rJ   r@   r   r   rt   rt      s9    2 E5 "6!  r   rt   c                 8    [        U 5      [        [        5      -  $ r   )r	   rq   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rQ   )r   r   r	   rq   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)r\   r	   r1   rq   is_Atomis_Powr   r   r2   r,   results      r   r1   	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   rV   log2._eval_rewrite_as_log  r{   r   r@   NrA   )rB   rC   rD   rE   rF   rG   r"   rI   r1   r   r'   rV   rH   rJ   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   ro   ro   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   rH   fma._eval_rewrite_as_tractableE  s    Cyr   r@   rA   r   )
rB   rC   rD   rE   rF   rG   r"   r'   rH   rJ   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rQ   )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   )r\   r	   r1   r   r   r   r   r   r   s      r   r1   
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   rV   log10._eval_rewrite_as_log{  rX   r   r@   NrA   )rB   rC   rD   rE   rF   rG   r"   rI   r1   r'   rV   rH   rJ   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   ro   r   r   r   rq   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   ry   Sqrt._eval_rewrite_as_Pow  r{   r   r@   NrA   rB   rC   rD   rE   rF   rG   r"   r'   ry   rH   rJ   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   ry   Cbrt._eval_rewrite_as_Pow  r{   r   r@   NrA   r   r@   r   r   r   r     s%    2 E5! "6r   r   c                 F    [        [        U S5      [        US5      -   5      $ )Nro   )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)

ro   c                     US;   a6  SU R                   US-
     -  [        U R                  " U R                   6 -  -  $ [        X5      e)r   r   ro   r   )r   rq   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   ry   hypot._eval_rewrite_as_Pow  rX   r   r@   NrA   r   r@   r   r   r   r     s%    . E5" "6r   r   c                   (    \ rS rSrSr\S 5       rSrg)isnani  r   c                 d    U[         R                  L a  [        $ UR                  (       a  [        $ g r   )r   NaNr   r\   r   r]   s     r   r1   
isnan.eval  s!    !%%<K]]Lr   r@   NrB   rC   rD   rE   rG   rI   r1   rJ   r@   r   r   r   r         E r   r   c                   (    \ rS rSrSr\S 5       rSrg)isinfi$  r   c                 `    UR                   (       a  [        $ UR                  (       a  [        $ g r   )is_infiniter   r=   r   r]   s     r   r1   
isinf.eval'  s    ??K]]Lr   r@   Nr   r@   r   r   r   r   $  r   r   r   N))rF   sympy.core.functionr   r   sympy.core.numbersr   sympy.core.powerr   sympy.core.singletonr   &sympy.functions.elementary.exponentialr   r	   (sympy.functions.elementary.miscellaneousr
   sympy.logic.boolalgr   r   r   r   r   rL   rN   rq   rr   rt   r   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
O 

O 
r   