<commit_before>from sympy.core import S, C, sympify
from sympy.core.basic import Basic
from sympy.core.containers import Tuple
from sympy.core.operations import LatticeOp, ShortCircuit
from sympy.core.function import Application, Lambda
from sympy.core.expr import Expr
from sympy.core.singleton import Singleton

class IdentityFunction(Lambda):
    """The identity function

    >>> from sympy import Id, Symbol
    >>> x = Symbol('x')
    >>> Id(x)
    x
    """
    __metaclass__ = Singleton
    __slots__ = []
    nargs = 1
    def __new__(cls):
        x = C.Dummy('x')
        #construct "by hand" to avoid infinite loop
        return Expr.__new__(cls, Tuple(x), x)
Id = S.IdentityFunction

###############################################################################
############################# ROOT and SQUARE ROOT FUNCTION ###################
###############################################################################

def sqrt(arg):
    """The square root function

    sqrt(x) -> Returns the principal square root of x.


    Examples
    ========

    >>> from sympy import sqrt, Symbol
    >>> x = Symbol('x')

    >>> sqrt(x)
    sqrt(x)

    >>> sqrt(x)**2
    x


    See also
    ========
       L{root}
    """
    # arg = sympify(arg) is handled by Pow
    return C.Pow(arg, S.Half)


def root(arg, n):
    """The n-th root function

    root(x, n) -> Returns the principal n-th root of x.


    Examples<commit_msg>Add a note to the sqrt docstring about sqrt(x**2)<commit_after>from sympy.core import S, C, sympify
from sympy.core.basic import Basic
from sympy.core.containers import Tuple
from sympy.core.operations import LatticeOp, ShortCircuit
from sympy.core.function import Application, Lambda
from sympy.core.expr import Expr
from sympy.core.singleton import Singleton

class IdentityFunction(Lambda):
    """The identity function

    >>> from sympy import Id, Symbol
    >>> x = Symbol('x')
    >>> Id(x)
    x
    """
    __metaclass__ = Singleton
    __slots__ = []
    nargs = 1
    def __new__(cls):
        x = C.Dummy('x')
        #construct "by hand" to avoid infinite loop
        return Expr.__new__(cls, Tuple(x), x)
Id = S.IdentityFunction

###############################################################################
############################# ROOT and SQUARE ROOT FUNCTION ###################
###############################################################################

def sqrt(arg):
    """The square root function

    sqrt(x) -> Returns the principal square root of x.

    Examples
    ========

    >>> from sympy import sqrt, Symbol
    >>> x = Symbol('x')

    >>> sqrt(x)
    sqrt(x)

    >>> sqrt(x)**2
    x

    Note that sqrt(x**2) does not simplify to x.

    >>> sqrt(x**2)
    sqrt(x**2)

    This is because the two are not equal to each other in general.
    For example, consider x == -1:

    >>> sqrt(x**2).subs(x, -1)
    1
    >>> x.subs(x, -1)
    -1

    This is because sqrt computes the principle square root, so the square may
    put the argument in a different branch.  This identity does hold if x is
    positive:

    >>> y = Symbol('y', positive=True)
    >>> sqrt(y**2)
    y

    You can force this simplification by using the powdenest() function with
    the force option set to True:

    >>> from sympy import powdenest
    >>> sqrt(x**2)
    sqrt(x**2)
    >>> powdenest(sqrt(x**2), force=True)
    x

    See also
    ========
       L{root}
    """
    # arg = sympify(arg) is handled by Pow
    return C.Pow(arg, S.Half)


def root(arg, n):
    """The n-th root function

    root(x, n) -> Returns the principal n-th root of x.


    Examples
{'fraction_non_alphanumeric': 0.22334886270211016, 'fraction_numerical': 0.004932858317347218, 'mean_word_length': 3.091928251121076, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 73, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6976651', 'n_tokens_mistral': 1152, 'n_tokens_neox': 1066, 'n_words': 356}