Module ImportFrom alias alias ImportFrom alias alias ImportFrom alias ImportFrom alias alias ImportFrom alias alias ImportFrom alias ImportFrom alias alias alias ImportFrom alias ImportFrom alias ImportFrom alias ImportFrom alias Assign NameStore Call NameLoad Str ClassDef bases NameLoad body Expr Str FunctionDef arguments args NameParam NameParam NameParam NameParam NameParam defaults body Assign TupleStore NameStore NameStore NameStore NameStore ListComp Call NameLoad NameLoad comprehension NameStore TupleLoad NameLoad NameLoad NameLoad NameLoad If Call AttributeLoad NameLoad attr body Assign NameStore UnaryOpUSub NameLoad Return BinOpMult BinOpMult BinOpPow AttributeLoad NameLoad attr NameLoad Call NameLoad BinOpMult BinOpMult BinOpMult Num NameLoad NameLoad NameLoad Call NameLoad NameLoad NameLoad NameLoad NameLoad If Call AttributeLoad NameLoad attr body Assign NameStore UnaryOpUSub NameLoad Return Call NameLoad NameLoad NameLoad NameLoad NameLoad If Call AttributeLoad NameLoad attr body Assign NameStore UnaryOpUSub NameLoad Return BinOpMult Call NameLoad BinOpMult BinOpMult BinOpMult Num NameLoad NameLoad NameLoad Call NameLoad NameLoad NameLoad NameLoad NameLoad decorator_list NameLoad FunctionDef arguments args NameParam defaults kwarg body Assign TupleStore NameStore NameStore NameStore NameStore AttributeLoad NameLoad attr Assign NameStore BinOpMult BinOpMult Call NameLoad BinOpDiv BinOpMult BinOpDiv BinOpAdd BinOpMult Num NameLoad Num BinOpMult Num NameLoad Call NameLoad BinOpSub NameLoad NameLoad Call NameLoad BinOpAdd NameLoad NameLoad Call NameLoad BinOpMult BinOpMult NameLoad NameLoad NameLoad Call NameLoad NameLoad NameLoad Call NameLoad NameLoad Return Call AttributeLoad NameLoad attr Call NameLoad BinOpAdd UnaryOpUSub BinOpPow Call NameLoad NameLoad Num Num Call NameLoad NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults Num body If CompareEq NameLoad Num body Raise Call NameLoad NameLoad NameLoad orelse If CompareEq NameLoad Num body Raise Call NameLoad NameLoad NameLoad orelse If CompareEq NameLoad Num body Assign TupleStore NameStore NameStore NameStore NameStore AttributeLoad NameLoad attr Return BinOpAdd BinOpMult BinOpMult NameLoad Call NameLoad NameLoad Call NameLoad NameLoad NameLoad NameLoad NameLoad BinOpMult BinOpMult Call NameLoad BinOpMult BinOpSub NameLoad NameLoad BinOpAdd BinOpAdd NameLoad NameLoad Num Call NameLoad BinOpMult UnaryOpUSub NameLoad NameLoad Call NameLoad NameLoad BinOpAdd NameLoad Num NameLoad NameLoad orelse If CompareEq NameLoad Num body Assign TupleStore NameStore NameStore NameStore NameStore AttributeLoad NameLoad attr Return BinOpMult BinOpMult NameLoad NameLoad Call NameLoad NameLoad NameLoad NameLoad NameLoad orelse Raise Call NameLoad NameLoad NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam NameParam defaults body Return Call AttributeLoad NameLoad attr keyword NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam NameParam defaults body Return Call AttributeLoad NameLoad attr NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam NameParam defaults body ImportFrom alias alias Assign NameStore Call NameLoad Call AttributeLoad NameLoad attr keyword NameLoad Assign NameStore Call AttributeLoad NameLoad attr Dict Call NameLoad Call NameLoad NameLoad Call NameLoad NameLoad Return Call NameLoad Call NameLoad NameLoad decorator_list FunctionDef arguments args NameParam defaults body Assign TupleStore NameStore NameStore NameStore NameStore AttributeLoad NameLoad attr Return BinOpMult BinOpPow AttributeLoad NameLoad attr NameLoad Call AttributeLoad NameLoad attr NameLoad UnaryOpUSub NameLoad NameLoad NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults NameLoad kwarg body Assign TupleStore NameStore NameStore NameStore NameStore AttributeLoad NameLoad attr Assign NameStore BinOpMult BinOpMult Call NameLoad BinOpDiv BinOpMult BinOpDiv BinOpAdd BinOpMult Num NameLoad Num BinOpMult Num NameLoad Call NameLoad BinOpSub NameLoad NameLoad Call NameLoad BinOpAdd NameLoad NameLoad Call NameLoad BinOpMult NameLoad NameLoad Call NameLoad NameLoad NameLoad Call NameLoad NameLoad Assign NameStore BinOpMult BinOpMult Call NameLoad BinOpDiv BinOpMult BinOpDiv BinOpAdd BinOpMult Num NameLoad Num BinOpMult Num NameLoad Call NameLoad BinOpSub NameLoad NameLoad Call NameLoad BinOpAdd NameLoad NameLoad Call NameLoad BinOpMult NameLoad NameLoad Call NameLoad NameLoad NameLoad Call NameLoad NameLoad Return TupleLoad NameLoad NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body ImportFrom alias alias ImportFrom alias Assign NameStore Call AttributeLoad SubscriptLoad AttributeLoad NameLoad attr Index Num attr NameLoad Assign NameStore Call AttributeLoad SubscriptLoad AttributeLoad NameLoad attr Index Num attr NameLoad Assign NameStore Call AttributeLoad SubscriptLoad AttributeLoad NameLoad attr Index Num attr NameLoad Assign NameStore Call AttributeLoad SubscriptLoad AttributeLoad NameLoad attr Index Num attr NameLoad With Call NameLoad NameLoad body Assign NameStore Call AttributeLoad NameLoad attr NameLoad NameLoad NameLoad NameLoad Return Call AttributeLoad NameLoad attr NameLoad NameLoad decorator_list FunctionDef arguments args NameParam defaults body Import alias identifier Return Call AttributeLoad NameLoad attr Call AttributeLoad SubscriptLoad AttributeLoad NameLoad attr Index Num attr Call AttributeLoad SubscriptLoad AttributeLoad NameLoad attr Index Num attr Call AttributeLoad SubscriptLoad AttributeLoad NameLoad attr Index Num attr Call AttributeLoad SubscriptLoad AttributeLoad NameLoad attr Index Num attr decorator_list decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam defaults body Expr Str ImportFrom alias Return Call NameLoad Call NameLoad NameLoad NameLoad NameLoad NameLoad decorator_list ClassDef bases NameLoad body Expr Str FunctionDef arguments args NameParam NameParam NameParam NameParam NameParam defaults body Assign TupleStore NameStore NameStore NameStore NameStore ListComp Call NameLoad NameLoad comprehension NameStore TupleLoad NameLoad NameLoad NameLoad NameLoad If AttributeLoad NameLoad attr body Assign NameStore BinOpDiv BinOpAdd Call NameLoad NameLoad NameLoad NameLoad NameLoad Call NameLoad NameLoad NameLoad NameLoad NameLoad Call NameLoad Num Return NameLoad orelse If AttributeLoad NameLoad attr body Return Call NameLoad NameLoad NameLoad NameLoad NameLoad orelse If AttributeLoad NameLoad attr body Assign NameStore BinOpDiv BinOpSub Call NameLoad NameLoad NameLoad NameLoad NameLoad Call NameLoad NameLoad NameLoad NameLoad NameLoad BinOpMult Call NameLoad Num NameLoad Return NameLoad decorator_list NameLoad decorator_list
N/A __future__ print_function division sympy pi I sympy.core.singleton S sympy.core Dummy sympify sympy.core.function Function ArgumentIndexError sympy.functions assoc_legendre sympy.functions.elementary.trigonometric sin cos cot sympy.functions.combinatorial.factorials factorial sympy.functions.elementary.complexes Abs sympy.functions.elementary.exponential exp sympy.functions.elementary.miscellaneous sqrt N/A _x N/A Dummy x Ynm N/A Function N/A N/A 
    Spherical harmonics defined as

    .. math::
        Y_n^m(\theta, \varphi) := \sqrt{\frac{(2n+1)(n-m)!}{4\pi(n+m)!}}
                                  \exp(i m \varphi)
                                  \mathrm{P}_n^m\left(\cos(\theta)\right)

    Ynm() gives the spherical harmonic function of order `n` and `m`
    in `\theta` and `\varphi`, `Y_n^m(\theta, \varphi)`. The four
    parameters are as follows: `n \geq 0` an integer and `m` an integer
    such that `-n \leq m \leq n` holds. The two angles are real-valued
    with `\theta \in [0, \pi]` and `\varphi \in [0, 2\pi]`.

    Examples
    ========

    >>> from sympy import Ynm, Symbol
    >>> from sympy.abc import n,m
    >>> theta = Symbol("theta")
    >>> phi = Symbol("phi")

    >>> Ynm(n, m, theta, phi)
    Ynm(n, m, theta, phi)

    Several symmetries are known, for the order

    >>> from sympy import Ynm, Symbol
    >>> from sympy.abc import n,m
    >>> theta = Symbol("theta")
    >>> phi = Symbol("phi")

    >>> Ynm(n, -m, theta, phi)
    (-1)**m*exp(-2*I*m*phi)*Ynm(n, m, theta, phi)

    as well as for the angles

    >>> from sympy import Ynm, Symbol, simplify
    >>> from sympy.abc import n,m
    >>> theta = Symbol("theta")
    >>> phi = Symbol("phi")

    >>> Ynm(n, m, -theta, phi)
    Ynm(n, m, theta, phi)

    >>> Ynm(n, m, theta, -phi)
    exp(-2*I*m*phi)*Ynm(n, m, theta, phi)

    For specific integers n and m we can evalute the harmonics
    to more useful expressions

    >>> simplify(Ynm(0, 0, theta, phi).expand(func=True))
    1/(2*sqrt(pi))

    >>> simplify(Ynm(1, -1, theta, phi).expand(func=True))
    sqrt(6)*exp(-I*phi)*sin(theta)/(4*sqrt(pi))

    >>> simplify(Ynm(1, 0, theta, phi).expand(func=True))
    sqrt(3)*cos(theta)/(2*sqrt(pi))

    >>> simplify(Ynm(1, 1, theta, phi).expand(func=True))
    -sqrt(6)*exp(I*phi)*sin(theta)/(4*sqrt(pi))

    >>> simplify(Ynm(2, -2, theta, phi).expand(func=True))
    sqrt(30)*exp(-2*I*phi)*sin(theta)**2/(8*sqrt(pi))

    >>> simplify(Ynm(2, -1, theta, phi).expand(func=True))
    sqrt(30)*exp(-I*phi)*sin(2*theta)/(8*sqrt(pi))

    >>> simplify(Ynm(2, 0, theta, phi).expand(func=True))
    sqrt(5)*(3*cos(theta)**2 - 1)/(4*sqrt(pi))

    >>> simplify(Ynm(2, 1, theta, phi).expand(func=True))
    -sqrt(30)*exp(I*phi)*sin(2*theta)/(8*sqrt(pi))

    >>> simplify(Ynm(2, 2, theta, phi).expand(func=True))
    sqrt(30)*exp(2*I*phi)*sin(theta)**2/(8*sqrt(pi))

    We can differentiate the functions with respect
    to both angles

    >>> from sympy import Ynm, Symbol, diff
    >>> from sympy.abc import n,m
    >>> theta = Symbol("theta")
    >>> phi = Symbol("phi")

    >>> diff(Ynm(n, m, theta, phi), theta)
    m*cot(theta)*Ynm(n, m, theta, phi) + sqrt((-m + n)*(m + n + 1))*exp(-I*phi)*Ynm(n, m + 1, theta, phi)

    >>> diff(Ynm(n, m, theta, phi), phi)
    I*m*Ynm(n, m, theta, phi)

    Further we can compute the complex conjugation

    >>> from sympy import Ynm, Symbol, conjugate
    >>> from sympy.abc import n,m
    >>> theta = Symbol("theta")
    >>> phi = Symbol("phi")

    >>> conjugate(Ynm(n, m, theta, phi))
    (-1)**(2*m)*exp(-2*I*m*phi)*Ynm(n, m, theta, phi)

    To get back the well known expressions in spherical
    coordinates we use full expansion

    >>> from sympy import Ynm, Symbol, expand_func
    >>> from sympy.abc import n,m
    >>> theta = Symbol("theta")
    >>> phi = Symbol("phi")

    >>> expand_func(Ynm(n, m, theta, phi))
    sqrt((2*n + 1)*factorial(-m + n)/factorial(m + n))*exp(I*m*phi)*assoc_legendre(n, m, cos(theta))/(2*sqrt(pi))

    See Also
    ========

    Ynm_c, Znm

    References
    ==========

    .. [1] http://en.wikipedia.org/wiki/Spherical_harmonics
    .. [2] http://mathworld.wolfram.com/SphericalHarmonic.html
    .. [3] http://functions.wolfram.com/Polynomials/SphericalHarmonicY/
    .. [4] http://dlmf.nist.gov/14.30
     eval N/A N/A cls n m theta phi N/A N/A N/A N/A n m theta phi N/A N/A sympify x N/A x N/A n m theta phi N/A N/A N/A m could_extract_minus_sign N/A N/A m N/A m N/A N/A N/A N/A N/A S NegativeOne m N/A exp N/A N/A N/A -2 I m phi N/A Ynm n m theta phi N/A N/A N/A theta could_extract_minus_sign N/A N/A theta N/A theta N/A N/A Ynm n m theta phi N/A N/A N/A phi could_extract_minus_sign N/A N/A phi N/A phi N/A N/A N/A exp N/A N/A N/A -2 I m phi N/A Ynm n m theta phi N/A classmethod _eval_expand_func N/A N/A self N/A hints N/A N/A N/A n m theta phi N/A self args N/A rv N/A N/A N/A sqrt N/A N/A N/A N/A N/A 2 n 1 N/A 4 pi N/A factorial N/A n m N/A factorial N/A n m N/A exp N/A N/A I m phi N/A assoc_legendre n m N/A cos theta N/A N/A N/A rv subs N/A sqrt N/A N/A N/A N/A cos theta 2 1 N/A sin theta N/A fdiff N/A N/A self argindex N/A 4 N/A N/A N/A argindex 1 N/A N/A N/A ArgumentIndexError self argindex N/A N/A N/A argindex 2 N/A N/A N/A ArgumentIndexError self argindex N/A N/A N/A argindex 3 N/A N/A N/A n m theta phi N/A self args N/A N/A N/A N/A m N/A cot theta N/A Ynm n m theta phi N/A N/A N/A sqrt N/A N/A n m N/A N/A n m 1 N/A exp N/A N/A I phi N/A Ynm n N/A m 1 theta phi N/A N/A N/A argindex 4 N/A N/A N/A n m theta phi N/A self args N/A N/A N/A I m N/A Ynm n m theta phi N/A N/A N/A ArgumentIndexError self argindex N/A _eval_rewrite_as_polynomial N/A N/A self n m theta phi N/A N/A N/A N/A N/A self expand func True N/A _eval_rewrite_as_sin N/A N/A self n m theta phi N/A N/A N/A N/A N/A self rewrite cos N/A _eval_rewrite_as_cos N/A N/A self n m theta phi N/A N/A sympy.simplify simplify trigsimp N/A term N/A simplify N/A N/A self expand func True N/A term N/A N/A term xreplace N/A N/A Abs N/A sin theta N/A sin theta N/A N/A simplify N/A trigsimp term N/A _eval_conjugate N/A N/A self N/A N/A N/A N/A n m theta phi N/A self args N/A N/A N/A N/A S NegativeOne m N/A N/A self func n N/A m theta phi N/A as_real_imag N/A N/A self deep N/A True hints N/A N/A N/A n m theta phi N/A self args N/A re N/A N/A N/A sqrt N/A N/A N/A N/A N/A 2 n 1 N/A 4 pi N/A factorial N/A n m N/A factorial N/A n m N/A cos N/A m phi N/A assoc_legendre n m N/A cos theta N/A im N/A N/A N/A sqrt N/A N/A N/A N/A N/A 2 n 1 N/A 4 pi N/A factorial N/A n m N/A factorial N/A n m N/A sin N/A m phi N/A assoc_legendre n m N/A cos theta N/A N/A re im N/A _eval_evalf N/A N/A self prec N/A N/A mpmath mp workprec sympy Expr N/A n N/A N/A N/A N/A self args N/A 0 _to_mpmath prec N/A m N/A N/A N/A N/A self args N/A 1 _to_mpmath prec N/A theta N/A N/A N/A N/A self args N/A 2 _to_mpmath prec N/A phi N/A N/A N/A N/A self args N/A 3 _to_mpmath prec N/A N/A workprec prec N/A N/A res N/A N/A mp spherharm n m theta phi N/A N/A N/A Expr _from_mpmath res prec N/A _sage_ N/A N/A self N/A N/A N/A sage.all sage N/A N/A N/A sage spherical_harmonic N/A N/A N/A N/A self args N/A 0 _sage_ N/A N/A N/A N/A self args N/A 1 _sage_ N/A N/A N/A N/A self args N/A 2 _sage_ N/A N/A N/A N/A self args N/A 3 _sage_ N/A N/A Ynm_c N/A N/A n m theta phi N/A N/A N/A Conjugate spherical harmonics defined as

    .. math::
        \overline{Y_n^m(\theta, \varphi)} := (-1)^m Y_n^{-m}(\theta, \varphi)

    See Also
    ========

    Ynm, Znm

    References
    ==========

    .. [1] http://en.wikipedia.org/wiki/Spherical_harmonics
    .. [2] http://mathworld.wolfram.com/SphericalHarmonic.html
    .. [3] http://functions.wolfram.com/Polynomials/SphericalHarmonicY/
     sympy conjugate N/A N/A conjugate N/A Ynm n m theta phi N/A Znm N/A Function N/A N/A 
    Real spherical harmonics defined as

    .. math::

        Z_n^m(\theta, \varphi) :=
        \begin{cases}
          \frac{Y_n^m(\theta, \varphi) + \overline{Y_n^m(\theta, \varphi)}}{\sqrt{2}} &\quad m > 0 \\
          Y_n^m(\theta, \varphi) &\quad m = 0 \\
          \frac{Y_n^m(\theta, \varphi) - \overline{Y_n^m(\theta, \varphi)}}{i \sqrt{2}} &\quad m < 0 \\
        \end{cases}

    which gives in simplified form

    .. math::

        Z_n^m(\theta, \varphi) =
        \begin{cases}
          \frac{Y_n^m(\theta, \varphi) + (-1)^m Y_n^{-m}(\theta, \varphi)}{\sqrt{2}} &\quad m > 0 \\
          Y_n^m(\theta, \varphi) &\quad m = 0 \\
          \frac{Y_n^m(\theta, \varphi) - (-1)^m Y_n^{-m}(\theta, \varphi)}{i \sqrt{2}} &\quad m < 0 \\
        \end{cases}

    See Also
    ========

    Ynm, Ynm_c

    References
    ==========

    .. [1] http://en.wikipedia.org/wiki/Spherical_harmonics
    .. [2] http://mathworld.wolfram.com/SphericalHarmonic.html
    .. [3] http://functions.wolfram.com/Polynomials/SphericalHarmonicY/
     eval N/A N/A cls n m theta phi N/A N/A N/A N/A n m th ph N/A N/A sympify x N/A x N/A n m theta phi N/A N/A m is_positive N/A N/A zz N/A N/A N/A Ynm n m th ph N/A Ynm_c n m th ph N/A sqrt 2 N/A zz N/A N/A N/A m is_zero N/A N/A N/A Ynm n m th ph N/A N/A N/A m is_negative N/A N/A zz N/A N/A N/A Ynm n m th ph N/A Ynm_c n m th ph N/A N/A sqrt 2 I N/A zz N/A classmethod N/A