
    wgxq                     H   d dl mZmZ d dlmZ ddlmZmZ ddlmZm	Z	m
Z
 ddlmZ ddlmZ ddlmZ dd	lmZ dd
lmZmZ ddlmZ ddlmZmZmZ ddlmZmZ ddlm Z  ddl!m"Z" ddl#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/m0Z0 ddl1m2Z2m3Z3m4Z4m5Z5m6Z6m7Z7m8Z8m9Z9m:Z:m;Z;m<Z<m=Z= ddl>m?Z?m@Z@ ddlAmBZBmCZCmDZDmEZEmFZF ddlGmHZH ddlImJZJ ddlKmLZL ddlMmNZN ddlOmPZP d ZQd ZRd ZSd%dZTd ZUd ZVej                  dd ZXej                  fd!ZYej                  fd"ZZej                  fd#Z[y$)&   )AccumBoundsAccumulationBounds)singularities    )PowS)diff
expand_mulFunction)
NumberKind)Mod)equal_valued)
Relational)SymbolDummy)_sympify)Absimre)explog)frac)	Piecewise)TrigonometricFunctionsincostancotcscsecasinacosacotatanasecacsc)sinhcoshtanhcothsechcschasinhacoshatanhacothasechacsch)degreelcm_list)IntervalIntersection	FiniteSetUnion
Complement)ImageSet)ConditionSet)
filldedent)iterable)hessianc                    ddl m} |j                  t        j                        st        t        d            t        t        t        t        t        t        t        t        t        t         t"        t$        t&        t(        t*        t,        t.        t0        t2        t4        t6        t8        t:        t<        t>        t@        tB        tD        tF        g| jI                  tJ              D cg c]   }|jM                  |      s|jN                  " }}tQ        fd|D              rt        t        d            tS        d      }t        |dkD  ft$        |dk\  |dk  ft&        |dk\  |dk  ft>        |dk\  ft@        |dkD  |dk  ftD        |dkD  |dk  fi}t,        |dk  |dk\  ft.        |dk  |dk\  ftB        |dk  |dkD  fi}|}	| jI                  t              D ]r  }
|
j                  jU                         d   }|
j                  jV                  r|jX                  rC ||
jZ                  dk\  |      j]                         }t_        ||	      }	t | jI                  tJ              D ]  }
|
jN                  |v rW||
jN                     D ]D  }|ja                  ||
jb                  d         } |||      j]                         }t_        ||	      }	F i|
jN                  |v rjt        jd                  }||
jN                     D ];  }|ja                  ||
jb                  d         }| |||      j]                         z  }= t_        ||	      }	|
jN                  t*        k(  r!dd	l3m4} |	 ||
jb                  d   |      z  }	|
jN                  t        k(  s*dd	l3m4} tk        |
jb                  d   ||      }t_        |t        jl                        }|jn                  r4t        jd                  }|D ]  }| ||
jb                  d   |z
  |      z  }  n7tq        |t        jl                  js                  |
jb                  d         |	      }|	|z  }	 |	tu        | ||      z
  S c c}w )
a  
    Returns the domain on which the function expression f is continuous.

    This function is limited by the ability to determine the various
    singularities and discontinuities of the given function.
    The result is either given as a union of intervals or constructed using
    other set operations.

    Parameters
    ==========

    f : :py:class:`~.Expr`
        The concerned function.
    symbol : :py:class:`~.Symbol`
        The variable for which the intervals are to be determined.
    domain : :py:class:`~.Interval`
        The domain over which the continuity of the symbol has to be checked.

    Examples
    ========

    >>> from sympy import Interval, Symbol, S, tan, log, pi, sqrt
    >>> from sympy.calculus.util import continuous_domain
    >>> x = Symbol('x')
    >>> continuous_domain(1/x, x, S.Reals)
    Union(Interval.open(-oo, 0), Interval.open(0, oo))
    >>> continuous_domain(tan(x), x, Interval(0, pi))
    Union(Interval.Ropen(0, pi/2), Interval.Lopen(pi/2, pi))
    >>> continuous_domain(sqrt(x - 2), x, Interval(-5, 5))
    Interval(2, 5)
    >>> continuous_domain(log(2*x - 1), x, S.Reals)
    Interval.open(1/2, oo)

    Returns
    =======

    :py:class:`~.Interval`
        Union of all intervals where the function is continuous.

    Raises
    ======

    NotImplementedError
        If the method to determine continuity of such a function
        has not yet been developed.

    r   solve_univariate_inequalityz=
            Domain must be a subset of S.Reals.
            c              3   &   K   | ]  }|v 
 y wN ).0funcimplementeds     X/home/mcse/projects/flask/flask-venv/lib/python3.12/site-packages/sympy/calculus/util.py	<genexpr>z$continuous_domain.<locals>.<genexpr>Z   s     
4t4{"
4   zO
            Unable to determine the domain of the given function.
            xr   )solveset_real);sympy.solvers.inequalitiesrA   	is_subsetr   RealsNotImplementedErrorr<   r   r   r   r   r   r   r   r   r   r    r   r!   r"   r$   r#   r%   r&   r'   r(   r)   r*   r+   r,   r-   r.   r/   r0   r1   r2   atomsr   hasrF   anyr   as_numer_denomis_rationalis_oddbaseas_setr6   subsargsEmptySetsympy.solvers.solvesetrM   function_rangeIntegersis_finite_setr;   containsr   )fsymboldomainrA   fctusedrK   constraintsconstraints_unioncont_domainatomden
constraintcconstraint_relationalconstraint_setrM   rdiscontnrG   s                       @rH   continuous_domainrs      s   ` GAGG$!* . #  	 S#tS#sCtT4tT4%ue	=K
 !" 1ESWWV_CHHEDE

4t
44!* . #  	 	sAa!eXqBwQqBwQQyBAAqAvK 	qBwQqBwQBA K @hh%%'*88CJJ4TYY!^8>@@F &z;?K@ ! $#99# + H()q$))A,(?%!<)6"33968 *>;G	H
 YY++ZZN&tyy1 <()q$))A,(?%"=)6#33968<< '~{CK YY$<
 =1v>>K YY$<tyy|VV<AQ

+A** EA}TYYq\!^VDDGE 'AJJ//		!={L7"KI$#L q&&999K Fs   %Q<Qc                    |t         j                  u rt         j                  S t        | |      }|t         j                  k(  rt	        | j                               S ddlm} ddlm	} |t        |t              r0|j                  |j                  z
  j                  rot        d|      }nbt        |t              rR|j                   D ]C  }t        |t              s|j                  |j                  z
  j                  s8t        d|      }E t#        | ||      }t         j                  }t        |t        t        f      r|f}	n1t        |t              r|j                   }	nt%        t'        d            |	D ]  }
t        |
t              r+|
D ]%  }||v s|t	        | j)                  ||            z  }' ?t        |
t              rt         j                  }t         j                  }t         j                  }|
j*                  |
j                  df|
j,                  |
j                  dff}|D ]C  \  }}}|r|t	         || |||            z  }||z  }&|t	        | j)                  ||            z  }E  || j/                  |      ||
      }t1        |      st%        dj3                  |             t        |t4              rt%        dj3                  |             ||z  }|D ]   }|t	        | j)                  ||            z  }" d	\  }}|t         j                  ur6|j                  |j                  k(  rd
}|j                  |j                  k(  rd
}|t        |j                  |j                  ||      z  } t%        t'        d             |S )a  
    Finds the range of a function in a given domain.
    This method is limited by the ability to determine the singularities and
    determine limits.

    Parameters
    ==========

    f : :py:class:`~.Expr`
        The concerned function.
    symbol : :py:class:`~.Symbol`
        The variable for which the range of function is to be determined.
    domain : :py:class:`~.Interval`
        The domain under which the range of the function has to be found.

    Examples
    ========

    >>> from sympy import Interval, Symbol, S, exp, log, pi, sqrt, sin, tan
    >>> from sympy.calculus.util import function_range
    >>> x = Symbol('x')
    >>> function_range(sin(x), x, Interval(0, 2*pi))
    Interval(-1, 1)
    >>> function_range(tan(x), x, Interval(-pi/2, pi/2))
    Interval(-oo, oo)
    >>> function_range(1/x, x, S.Reals)
    Union(Interval.open(-oo, 0), Interval.open(0, oo))
    >>> function_range(exp(x), x, S.Reals)
    Interval.open(0, oo)
    >>> function_range(log(x), x, S.Reals)
    Interval(-oo, oo)
    >>> function_range(sqrt(x), x, Interval(-5, 9))
    Interval(0, 3)

    Returns
    =======

    :py:class:`~.Interval`
        Union of all ranges for all intervals under domain where function is
        continuous.

    Raises
    ======

    NotImplementedError
        If any of the intervals, in the given domain, for which function
        is continuous are not finite or real,
        OR if the critical points of the function on the domain cannot be found.
    r   )limitsolvesetzL
                Unable to find range for the given domain.
                +-z%Unable to find critical points for {}z)Infinite number of critical points for {})FFT)r   r\   periodicityZeror7   expandsympy.series.limitsru   r]   rw   
isinstancer5   infsupis_infiniter8   r[   rs   rQ   r<   rZ   	left_open
right_openr	   r=   formatr:   )rb   rc   rd   periodru   rw   sub_dom	intervals	range_intinterval_iterinterval	singletonvalscritical_pointscritical_valuesboundsis_openlimit_point	directionsolutioncritical_pointr   r   s                          rH   r^   r^      sD   f zzF#F$$)/fh'

VZZ'44!!V,&!;; 1gx0+++88%a0F1
 "!VV4I

I)Xy12"	Iu	%! &j 2 '   " /h	*% F	&166&)+D!EEIF (+::DjjOjjO))8<<=''s;=F 4: C/i#yq&+y1Y'ZZOO+D IaffV[&ABBDC  vAHH%)?FFqIK K(H-)CJJ1MO O x'O"1 B	!&&"@AAB %1!Izajj0"&&$((2 $I"&&$((2!%J$((DHHiLLI%j 2 '  [/b     c           
      L  
 t        |      dk(  rt        d      | t        j                  u rt        j                  S t	        | t
              r2| j                  d   }t        t        | j                  d   g| |      S t	        | t              r| }t        j                  }n| j                  d   }| j                  d   }t	        |t              st        dt        |      d|      t        |      dk(  r|d   
nt        d|d      
fd}t	        |t              rt        |D cg c]  } |||       c} S t	        |t
              rLt        j                  }|j                  D ]+  }t        |D cg c]  } |||       c} }	t        ||	      }- |S y	c c}w c c}w )
a  
    Finds the domain of the functions in ``finset_intersection`` in which the
    ``finite_set`` is not-empty.

    Parameters
    ==========

    finset_intersection : Intersection of FiniteSet
        The unevaluated intersection of FiniteSet containing
        real-valued functions with Union of Sets
    syms : Tuple of symbols
        Symbol for which domain is to be found

    Raises
    ======

    NotImplementedError
        The algorithms to find the non-emptiness of the given FiniteSet are
        not yet implemented.
    ValueError
        The input is not valid.
    RuntimeError
        It is a bug, please report it to the github issue tracker
        (https://github.com/sympy/sympy/issues).

    Examples
    ========

    >>> from sympy import FiniteSet, Interval, not_empty_in, oo
    >>> from sympy.abc import x
    >>> not_empty_in(FiniteSet(x/2).intersect(Interval(0, 1)), x)
    Interval(0, 2)
    >>> not_empty_in(FiniteSet(x, x**2).intersect(Interval(1, 2)), x)
    Union(Interval(1, 2), Interval(-sqrt(2), -1))
    >>> not_empty_in(FiniteSet(x**2/(x + 2)).intersect(Interval(1, oo)), x)
    Union(Interval.Lopen(-2, -1), Interval(2, oo))
    r   z*One or more symbols must be given in syms.r   zA FiniteSet must be given, not z: zmore than one variables z not handledc                 h   ddl m} |j                  }|j                  } || j	                         d   
t
        j                        }|j                  r@|t
        j                  u rt
        j                  }n9 || |k  
t
        j                        }n || |k  
t
        j                        }|j                  r@|t
        j                  u rt
        j                  }n9 || |kD  
t
        j                        }n || |k\  
t
        j                        }t        ||      }t        ||      }	|	S )z9 Finds the domain of an expression in any given interval r   rv   r   rd   )r]   rw   startendrU   r   rP   r   Infinityr   NegativeInfinityr6   r9   )exprintrvlrw   _start_end_singularities_domain1_domain2expr_with_singexpr_domainsymbs             rH   
elm_domainz not_empty_in.<locals>.elm_domainp  s    3zz!$"5"5"7":D)*2 qzz!77#D4KaggFd177CH+++77#D6M4HQWWEH &h9 @r   N)len
ValueErrorr   r\   r~   r8   r[   not_empty_inr7   rP   typerQ   r5   )finset_intersectionsymselm_in_sets
finite_set_setsr   element_domainr   _domain_elementr   s             @rH   r   r   *  s   T 4yA~EFFajj(zz%u-)..q1\"5":":1"=EE " 	" %y1(
(--a0
#((+j),z*J8 9 	9 4yA~Aw!#'#* + 	+< %"Lgz'51LMM%**jj 	6F#5?&A*1 '1&&A &A BOG_5G	6    M
&As   +F7F!
c                 J	   j                   t        urt        dj                   z        t        dd      }| j	                  |      } |fd}| }d}t        | t              r| j                  | j                  z
  } | j                         } | j                  vrt        j                  S t        | t              r	 | j                        }t        | t              rx| j                   d   }t        |t"        t$        t&        f      rt)        |j                   d         }t+        |      }|(t        |t(              rt        |      }	  |||dz        S t        | t,              s)| j.                  r| j0                  t        j2                  k(  rvt5        t        j2                  t7        | j,                              } t9        |       dk7  r;t+        t;        |             }	t+        t9        |             }
|	|
t=        |	|
g      }| j.                  r| j0                  t        j2                  k7  rm| j                   \  }}|j?                        }|j?                        }|r|st+        |      }n|r|st+        |      }ntA        | j                         }n| jB                  rX| jE                  d	
      \  }}t        |t              stG        |d      st+        |      }nytA        |j                         }na| jH                  rJ| jE                        \  }}|t        j                  urt+        |      S tA        |j                         }nt        | tJ              r| j                   \  }}|k(  r|}nt        |t              rt+        |      }n|jM                        rtO        |      dk(  r|j                  vrt        ||jQ                        z        }n{t        | tR              rnj|hddl*m+}m,}  ||       }t[        |      }|dkD  rGt]        t_        |            D ]0  \  }}|dz
  |z
  } |||d       }||| fvs!t+        |      }|0 n ||r	 |||      S |S y# t        $ r Y w xY w# t        $ r}|rt        |      Y d}~Fd}~ww xY w)a_  
    Tests the given function for periodicity in the given symbol.

    Parameters
    ==========

    f : :py:class:`~.Expr`
        The concerned function.
    symbol : :py:class:`~.Symbol`
        The variable for which the period is to be determined.
    check : bool, optional
        The flag to verify whether the value being returned is a period or not.

    Returns
    =======

    period
        The period of the function is returned.
        ``None`` is returned when the function is aperiodic or has a complex period.
        The value of $0$ is returned as the period of a constant function.

    Raises
    ======

    NotImplementedError
        The value of the period computed cannot be verified.


    Notes
    =====

    Currently, we do not support functions with a complex period.
    The period of functions having complex periodic values such
    as ``exp``, ``sinh`` is evaluated to ``None``.

    The value returned might not be the "fundamental" period of the given
    function i.e. it may not be the smallest periodic value of the function.

    The verification of the period through the ``check`` flag is not reliable
    due to internal simplification of the given expression. Hence, it is set
    to ``False`` by default.

    Examples
    ========
    >>> from sympy import periodicity, Symbol, sin, cos, tan, exp
    >>> x = Symbol('x')
    >>> f = sin(x) + sin(2*x) + sin(3*x)
    >>> periodicity(f, x)
    2*pi
    >>> periodicity(sin(x)*cos(x), x)
    pi
    >>> periodicity(exp(tan(2*x) - 1), x)
    pi/2
    >>> periodicity(sin(4*x)**cos(2*x), x)
    pi
    >>> periodicity(exp(x), x)
    zCannot use symbol of kind %srK   T)realc                     | j                  |z         }|j                  |       r|S t        t        ddd|d| d|d            )z,Return the checked period or raise an error.z\
                The period of the given function cannot be verified.
                When `z` was replaced with `z + z` in `z#`, the result
                was `z` which was not recognized as being the same as
                the original function.
                So either the period was wrong or the two forms were
                not recognized as being equal.
                Set check=False to obtain the value.)rZ   equalsrQ   r<   )orig_fr   new_frc   s      rH   _checkzperiodicity.<locals>._check  sN    FFVO4<<M%j 28 '9 : :r   Nr      F)as_Addr   )compogen
decompogen)0kindr   rQ   r   rZ   r~   r   lhsrhssimplifyfree_symbolsr   r{   r   r   r   r[   r    r   r   r   rz   r   is_PowrX   Exp1r   r
   r   r   lcimrS   _periodicityis_Mulas_independentr   is_Addr   is_polynomialr3   r	   r   sympy.solvers.decompogenr   r   r   	enumeratereversed)rb   rc   checktempr   r   r   argerrperiod_realperiod_imagrX   expobase_has_symexpo_has_symcoeffgkarr   r   r   g_s	num_of_gsindexstart_indexs    `                        rH   rz   rz     s   t {{*$!"@6;;"NOO4 D	vtAF:  FF!Z EEAEEM	

AQ^^#vv!*+	XXf%F !SffQicCc?+ chhqk"CS&)*S#"6
 XF3ffQh// !Sahh166QVV+;
155)*a5A:%beV4K%beV4K&;+B{K89xxAFFaff$VV
dxx'xx' v.F, v.F "!&&&1F	
##F5#9qa./|E17M F+F!!&&&1F	
'1AFF?q&))afff-	As	vv1;F01 F+Foof%&F*;q*@!..(Q/0	Ay	!	AF#H	q=%hsm4 q'!me3S.7VQK'(F3F) &&))} # 		& ' 3-c22 3s*   >Q1 R 1	Q>=Q>	R"
RR"c                     g }| D ]6  }t        ||      }| y|t        j                  us&|j                  |       8 t	        |      dkD  rt        |      S |r|d   S y)a]  
    Helper for `periodicity` to find the period of a list of simpler
    functions.
    It uses the `lcim` method to find the least common period of
    all the functions.

    Parameters
    ==========

    args : Tuple of :py:class:`~.Symbol`
        All the symbols present in a function.

    symbol : :py:class:`~.Symbol`
        The symbol over which the function is to be evaluated.

    Returns
    =======

    period
        The least common period of the function for all the symbols
        of the function.
        ``None`` if for at least one of the symbols the function is aperiodic.

    Nr   r   )rz   r   r{   appendr   r   )r[   rc   periodsrb   r   s        rH   r   r   Y  sn    2 G #Q'>NN6"# 7|aG}qz r   c                   	 d}t        d | D              r|| D cg c]  }|j                          }}|D cg c]  }|j                          }}|d   d   	t        	fd|D              r$	}|D cg c]  \  }}|	 }}}t        |      |z  }|S t        d | D              rt        |       }|S 	 |S c c}w c c}w c c}}w )a  Returns the least common integral multiple of a list of numbers.

    The numbers can be rational or irrational or a mixture of both.
    `None` is returned for incommensurable numbers.

    Parameters
    ==========

    numbers : list
        Numbers (rational and/or irrational) for which lcim is to be found.

    Returns
    =======

    number
        lcim if it exists, otherwise ``None`` for incommensurable numbers.

    Examples
    ========

    >>> from sympy.calculus.util import lcim
    >>> from sympy import S, pi
    >>> lcim([S(1)/2, S(3)/4, S(5)/6])
    15/2
    >>> lcim([2*pi, 3*pi, pi, pi/2])
    6*pi
    >>> lcim([S(1), 2*pi])
    Nc              3   4   K   | ]  }|j                     y wrC   )is_irrationalrE   nums     rH   rI   zlcim.<locals>.<genexpr>  s     
03
0   r   r   c              3   .   K   | ]  \  }}|k(    y wrC   rD   )rE   r   factorterms      rH   rI   zlcim.<locals>.<genexpr>  s     ?-%v~?s   c              3   4   K   | ]  }|j                     y wrC   )rV   r   s     rH   rI   zlcim.<locals>.<genexpr>  s     0S__0r   )allr   as_coeff_Mulr4   )
numbersresultr   factorized_numsfactors_numcommon_termr   r   coeffsr   s
            @rH   r   r     s    : F

0
003:;C3::<;;5DEcs'')EE1~a ?;??K1<=ve=F=f%3F M 
00	0'"
 M 	M <E >s   B4B93B>r   c                    t        |      dkD  rt        | |      j                  S ddlm} t        |       } |d   }t        fdt        | |      D              ry| j                  |d      dk  } |||d      ryy)a  Determines the  convexity of the function passed in the argument.

    Parameters
    ==========

    f : :py:class:`~.Expr`
        The concerned function.
    syms : Tuple of :py:class:`~.Symbol`
        The variables with respect to which the convexity is to be determined.
    domain : :py:class:`~.Interval`, optional
        The domain over which the convexity of the function has to be checked.
        If unspecified, S.Reals will be the default domain.

    Returns
    =======

    bool
        The method returns ``True`` if the function is convex otherwise it
        returns ``False``.

    Raises
    ======

    NotImplementedError
        The check for the convexity of multivariate functions is not implemented yet.

    Notes
    =====

    To determine concavity of a function pass `-f` as the concerned function.
    To determine logarithmic convexity of a function pass `\log(f)` as
    concerned function.
    To determine logarithmic concavity of a function pass `-\log(f)` as
    concerned function.

    Currently, convexity check of multivariate functions is not handled.

    Examples
    ========

    >>> from sympy import is_convex, symbols, exp, oo, Interval
    >>> x = symbols('x')
    >>> is_convex(exp(x), x)
    True
    >>> is_convex(x**3, x, domain = Interval(-1, oo))
    False
    >>> is_convex(1/x**2, x, domain=Interval.open(0, oo))
    True

    References
    ==========

    .. [1] https://en.wikipedia.org/wiki/Convex_function
    .. [2] http://www.ifp.illinois.edu/~angelia/L3_convfunc.pdf
    .. [3] https://en.wikipedia.org/wiki/Logarithmically_convex_function
    .. [4] https://en.wikipedia.org/wiki/Logarithmically_concave_function
    .. [5] https://en.wikipedia.org/wiki/Concave_function

    r   r   r@   c              3   &   K   | ]  }|v  
 y wrC   rD   )rE   srd   s     rH   rI   zis_convex.<locals>.<genexpr>  s     
611;
6rJ   Fr   T)	r   r>   is_positive_semidefiniterN   rA   r   rT   r   r	   )rb   rd   r   rA   var	conditions    `    rH   	is_convexr     sy    x 4y1}q$888FA
q'C

6a 5
66sA"I"9c5&Ar   c                     ddl m} |t        j                  u rt        j                  S t	        | ||      } |t        | |      ||      }|S )a  
    Returns the stationary points of a function (where derivative of the
    function is 0) in the given domain.

    Parameters
    ==========

    f : :py:class:`~.Expr`
        The concerned function.
    symbol : :py:class:`~.Symbol`
        The variable for which the stationary points are to be determined.
    domain : :py:class:`~.Interval`
        The domain over which the stationary points have to be checked.
        If unspecified, ``S.Reals`` will be the default domain.

    Returns
    =======

    Set
        A set of stationary points for the function. If there are no
        stationary point, an :py:class:`~.EmptySet` is returned.

    Examples
    ========

    >>> from sympy import Interval, Symbol, S, sin, pi, pprint, stationary_points
    >>> x = Symbol('x')

    >>> stationary_points(1/x, x, S.Reals)
    EmptySet

    >>> pprint(stationary_points(sin(x), x), use_unicode=False)
              pi                              3*pi
    {2*n*pi + -- | n in Integers} U {2*n*pi + ---- | n in Integers}
              2                                2

    >>> stationary_points(sin(x),x, Interval(0, 4*pi))
    {pi/2, 3*pi/2, 5*pi/2, 7*pi/2}

    r   rv   )r]   rw   r   r\   rs   r	   )rb   rc   rd   rw   sets        rH   stationary_pointsr     sE    R 0zzq&&1F
46?FF
3CJr   c                     t        |t              r4|t        j                  u rt	        d      t        | ||      j                  S t	        d|z        )a#  
    Returns the maximum value of a function in the given domain.

    Parameters
    ==========

    f : :py:class:`~.Expr`
        The concerned function.
    symbol : :py:class:`~.Symbol`
        The variable for maximum value needs to be determined.
    domain : :py:class:`~.Interval`
        The domain over which the maximum have to be checked.
        If unspecified, then the global maximum is returned.

    Returns
    =======

    number
        Maximum value of the function in given domain.

    Examples
    ========

    >>> from sympy import Interval, Symbol, S, sin, cos, pi, maximum
    >>> x = Symbol('x')

    >>> f = -x**2 + 2*x + 5
    >>> maximum(f, x, S.Reals)
    6

    >>> maximum(sin(x), x, Interval(-pi, pi/4))
    sqrt(2)/2

    >>> maximum(sin(x)*cos(x), x)
    1/2

    z+Maximum value not defined for empty domain.%s is not a valid symbol.)r~   r   r   r\   r   r^   r   rb   rc   rd   s      rH   maximumr  .  M    L &&!QZZJKKa04444v=>>r   c                     t        |t              r4|t        j                  u rt	        d      t        | ||      j                  S t	        d|z        )a  
    Returns the minimum value of a function in the given domain.

    Parameters
    ==========

    f : :py:class:`~.Expr`
        The concerned function.
    symbol : :py:class:`~.Symbol`
        The variable for minimum value needs to be determined.
    domain : :py:class:`~.Interval`
        The domain over which the minimum have to be checked.
        If unspecified, then the global minimum is returned.

    Returns
    =======

    number
        Minimum value of the function in the given domain.

    Examples
    ========

    >>> from sympy import Interval, Symbol, S, sin, cos, minimum
    >>> x = Symbol('x')

    >>> f = x**2 + 2*x + 5
    >>> minimum(f, x, S.Reals)
    4

    >>> minimum(sin(x), x, Interval(2, 3))
    sin(3)

    >>> minimum(sin(x)*cos(x), x)
    -1/2

    z+Minimum value not defined for empty domain.r   )r~   r   r   r\   r   r^   r   r  s      rH   minimumr  ]  r  r   N)F)\accumulationboundsr   r   r   
sympy.corer   r   sympy.core.functionr	   r
   r   sympy.core.kindr   sympy.core.modr   sympy.core.numbersr   sympy.core.relationalr   sympy.core.symbolr   r   sympy.core.sympifyr   $sympy.functions.elementary.complexesr   r   r   &sympy.functions.elementary.exponentialr   r   #sympy.functions.elementary.integersr   $sympy.functions.elementary.piecewiser   (sympy.functions.elementary.trigonometricr   r   r   r   r   r   r    r!   r"   r#   r$   r%   r&   %sympy.functions.elementary.hyperbolicr'   r(   r)   r*   r+   r,   r-   r.   r/   r0   r1   r2   sympy.polys.polytoolsr3   r4   sympy.sets.setsr5   r6   r7   r8   r9   sympy.sets.fancysetsr:   sympy.sets.conditionsetr;   sympy.utilitiesr<   sympy.utilities.iterablesr=   sympy.matrices.denser>   rs   r^   r   rz   r   r   rP   r   r   r  r  rD   r   rH   <module>r     s    ? (  : : &  + , + ' < < ; 4 :( ( ( (: : : : 2) ) ) 0 & . (@:FFRm`|~&R-^  !ww FR )* 1h  gg ,?^  gg ,?r   