Skip to content

Instantly share code, notes, and snippets.

@chakpongchung
Created November 5, 2015 16:57
Show Gist options
  • Select an option

  • Save chakpongchung/cf3929ea18c250b8778b to your computer and use it in GitHub Desktop.

Select an option

Save chakpongchung/cf3929ea18c250b8778b to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{"nbformat_minor": 0, "cells": [{"source": "## Derivation for the inner product of 3D rotational gradient operator acted on spherical harmonics ", "cell_type": "markdown", "metadata": {}}, {"source": "with application in object/scenes response to a lighting environment, often represented using spherical harmonics,including complex global illumination effects", "cell_type": "markdown", "metadata": {}}, {"source": "The first paper that\nhas been used extensively in games deals with using Spherical Harmonics to represent\nirradiance environment maps efficiently, allowing for interactive rendering of diffuse objects\nunder distant illumination", "cell_type": "markdown", "metadata": {}}, {"source": " \n ", "cell_type": "markdown", "metadata": {}}, {"source": "Reference about spherical harmonics\n", "cell_type": "markdown", "metadata": {"collapsed": false}}, {"source": "http://mathworld.wolfram.com/SphericalHarmonic.html", "cell_type": "markdown", "metadata": {}}, {"source": "#Spherical harmonics in Sympy", "cell_type": "markdown", "metadata": {}}, {"source": "To get back the well known expressions in spherical coordinates we use full expansion:", "cell_type": "markdown", "metadata": {}}, {"execution_count": 3, "cell_type": "code", "source": "from sympy import Ynm, Symbol, expand_func\nfrom sympy.abc import n,m\ntheta = Symbol(\"theta\")\nphi = Symbol(\"phi\")\nexpand_func(Ynm(n, m, theta, phi))", "outputs": [{"execution_count": 3, "output_type": "execute_result", "data": {"text/plain": "sqrt((2*n + 1)*factorial(-m + n)/factorial(m + n))*exp(I*m*phi)*assoc_legendre(n, m, cos(theta))/(2*sqrt(pi))"}, "metadata": {}}], "metadata": {"collapsed": false, "trusted": false}}, {"source": "Relevant page\nhttp://docs.sympy.org/latest/modules/functions/special.html?highlight=spherical%20harmonics#sympy.functions.special.spherical_harmonics.Ynm", "cell_type": "markdown", "metadata": {"collapsed": false}}, {"source": "3d plot of spherical harmonics\n\nhttp://stsdas.stsci.edu/download/mdroe/plotting/entry1/index.html", "cell_type": "markdown", "metadata": {"collapsed": false}}, {"source": "# Derivation", "cell_type": "markdown", "metadata": {"collapsed": false}}, {"source": "We try to derive the dot product of rotational gradient of spherical harmonics with spherical harmonics expansion.", "cell_type": "markdown", "metadata": {}}, {"source": "\n$$\\vec{R} = \\begin{bmatrix}\n R_{x}\\\\\n R_{y} \\\\\n R_{z}\n \\end{bmatrix}\n =\\begin{bmatrix}\n - \\frac{cos\\theta}{sin\\theta}cos\\phi \\frac{\\partial }{\\partial \\phi} - sin\\phi \\frac{\\partial }{\\partial \\theta}\n \\\\\n - \\frac{cos\\theta}{sin\\theta}cos\\phi \\frac{\\partial }{\\partial \\phi} + cos\\phi \\frac{\\partial }{\\partial \\theta} \n \\\\\n \\frac{\\partial }{\\partial \\phi} \n \\end{bmatrix}\n $$", "cell_type": "markdown", "metadata": {}}, {"source": "$$\nR_{\\alpha} = i L_{\\alpha}, where \\, \\alpha = x,y,z\n$$", "cell_type": "markdown", "metadata": {}}, {"source": "\n", "cell_type": "markdown", "metadata": {}}, {"source": " $$ \\vec{R} = \\begin{bmatrix}\n R_{x} \\\\\n R_{y} \\\\\n R_{z}\n \\end{bmatrix}\n =\n \\begin{bmatrix}\n i L_{x} \\\\\n i L_{y} \\\\\n i L_{z}\n \\end{bmatrix}\n =\n \\begin{bmatrix}\n \\frac{i}{2}(L_{+}+L_{-} ) \\\\\n \\frac{1}{2}(L_{+}-L_{-} ) \\\\\n i L_{z}\n \\end{bmatrix}\n $$", "cell_type": "markdown", "metadata": {}}, {"source": "$$\nL_{+} Y{_l^{m}}= c_{l,m,1} Y{_l^{m+1}}\n$$", "cell_type": "markdown", "metadata": {}}, {"source": "$$\nL_{-} Y{_l^{m}}= c_{l,m,2} Y{_l^{m-1}}\n$$", "cell_type": "markdown", "metadata": {"collapsed": true}}, {"source": "$$\nL_{z} Y{_l^{m}}= m Y{_l^{m}}\n$$", "cell_type": "markdown", "metadata": {"collapsed": true}}, {"source": "after some manipulations of the above identities, it can be shown that (details will be added later)", "cell_type": "markdown", "metadata": {}}, {"source": "$$ \\vec{R}Y{_j^{p}} \\cdot \\vec{R}Y{_l^{m}} = - \\frac{1}{2} [c_{j,p,1}c_{l,m,2}Y{_j^{p+1}} Y{_l^{m-1}}+c_{j,p,2}c_{l,m,1}Y{_j^{p-1}}Y{_l^{m+1}}] - mp Y{_j^{p}} Y{_l^{m}} $$ ", "cell_type": "markdown", "metadata": {}}, {"source": "$$ =(-1)*(-1)^{m+p} \\sum\\limits_{k=|l-j|}^{l+j}Y{_k^{m+p}}[\\frac{1}{2} (c_{j,p,1}c_{l,m,2} \\alpha_{l,m-1,j,p+1,k} +c_{j,p,2}C_{l,m,1}\\alpha_{l,m+1,j,p-1,k}) + mp \\alpha_{l,m,j,p,k}] $$", "cell_type": "markdown", "metadata": {}}, {"source": "where $$ \\alpha_{l,m,j,p,k} = \\int_{0}^{2\\pi} \\int_{0}^{\\pi} Y{_j^{p}} Y{_l^{m}} Y{_k^{-m-p}} \\sin \\theta d\\theta d\\phi$$", "cell_type": "markdown", "metadata": {}}, {"source": "$$ =[\\frac{(2l+1)(2j+1)(2k+1)}{4\\pi}]^{1/2} * \\left(\\begin{array}{clcr} j & l & k\\\\ 0& 0 & 0 \\end{array}\\right) * \\left(\\begin{array}{clcr} j & l & k\\\\ p& m & -(m+p) \\end{array}\\right) $$ ", "cell_type": "markdown", "metadata": {}}, {"source": "here \n$$\n\\left(\\begin{array}{clcr} j & l & k\\\\ 0& 0 & 0 \\end{array}\\right)\n$$\n\nis Wigner 3j symbol", "cell_type": "markdown", "metadata": {}}, {"source": "# Wigner 3j symbol", "cell_type": "markdown", "metadata": {}}, {"source": "reference for Wigner 3j symbol(strange fraction here)\n\nhttp://docs.sympy.org/dev/modules/physics/wigner.html", "cell_type": "markdown", "metadata": {}}, {"execution_count": 115, "cell_type": "code", "source": "from sympy.physics.wigner import wigner_3j\nwigner_3j(2, 6, 4, 0, 0, 0)", "outputs": [{"execution_count": 115, "output_type": "execute_result", "data": {"text/plain": " _____\n\u2572\u2571 715 \n\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n 143 ", "text/latex": "$$\\frac{\\sqrt{715}}{143}$$"}, "metadata": {}}], "metadata": {"collapsed": false, "trusted": false}}, {"execution_count": 164, "cell_type": "code", "source": "sqrt(S(5)/143)", "outputs": [{"execution_count": 164, "output_type": "execute_result", "data": {"text/plain": " _____\n\u2572\u2571 715 \n\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n 143 ", "text/latex": "$$\\frac{\\sqrt{715}}{143}$$"}, "metadata": {}}], "metadata": {"collapsed": false, "trusted": false}}, {"execution_count": 116, "cell_type": "code", "source": "wigner_3j(2, 6, 4, 0, 0, 1)", "outputs": [{"execution_count": 116, "output_type": "execute_result", "data": {"text/plain": "0", "text/latex": "$$0$$"}, "metadata": {}}], "metadata": {"collapsed": false, "trusted": false}}, {"source": "and$$\n Y{_j^{p}} = Y{_j^{p}}(\\theta, \\phi)\n$$", "cell_type": "markdown", "metadata": {}}, {"source": "$$\nc_{l,m,1}=\\sqrt{(l-m)(l+m+1)}\n$$", "cell_type": "markdown", "metadata": {}}, {"source": "$$\nc_{l,m,2}=\\sqrt{(l+m)(l-m+1)}\n$$", "cell_type": "markdown", "metadata": {}}, {"source": " using the recursive relation shown p760,34.3.14,NIST Handbook 2010 ,we have:", "cell_type": "markdown", "metadata": {}}, {"source": " $$ \\frac{1}{2} (c_{j,p,1}c_{l,m,2} \\alpha_{l,m-1,j,p+1,k} +c_{j,p,2}C_{l,m,1}\\alpha_{l,m+1,j,p-1,k}) + mp \\alpha_{l,m,j,p,k} $$ ", "cell_type": "markdown", "metadata": {}}, {"source": "$$ =\\frac{1}{2}[\\frac{(2l+1)(2j+1)(2k+1)}{4\\pi}]^{1/2} * \\left(\\begin{array}{clcr} j & l & k\\\\ 0& 0 & 0 \\end{array}\\right) * [ c_{j,p,1}c_{l,m,2} \\left(\\begin{array}{clcr} j & l & k\\\\ p+1& m-1 & -(m+p) \\end{array}\\right) + c_{j,p,2}c_{l,m,1} \\left(\\begin{array}{clcr} j & l & k\\\\ p-1& m+1 & -(m+p) \\end{array}\\right) + 2mp \\left(\\begin{array}{clcr} j & l & k\\\\ p-1& m+1 & -(m+p) \\end{array}\\right) ] $$ ", "cell_type": "markdown", "metadata": {}}, {"source": "$$ = \\frac{1}{2}[\\frac{(2l+1)(2j+1)(2k+1)}{4\\pi}]^{1/2} * \\left(\\begin{array}{clcr} j & l & k\\\\ 0& 0 & 0 \\end{array}\\right) * \\left(\\begin{array}{clcr} k & j & l\\\\ -(m+p)& p & m \\end{array}\\right) *(k^2-j^2-l^2+k-j-(-2pm+2pm)) $$ ", "cell_type": "markdown", "metadata": {}}, {"source": " $$ = \\frac{1}{2}[\\frac{(2l+1)(2j+1)(2k+1)}{4\\pi}]^{1/2} * \\left(\\begin{array}{clcr} k & j & l\\\\ 0& 0 & 0 \\end{array}\\right) * \\left(\\begin{array}{clcr} k & j & l\\\\ -(m+p)& p & m \\end{array}\\right) *(k^2-j^2-l^2+k-j-l) $$ ", "cell_type": "markdown", "metadata": {}}, {"source": "$$ = \\alpha_{l,m,j,p,k} * \\frac{1}{2} (k^2-j^2-l^2+k-j-l) $$ ", "cell_type": "markdown", "metadata": {}}, {"source": "## so, we have \n", "cell_type": "markdown", "metadata": {}}, {"source": "$$ \\vec{R}Y{_j^{p}} \\cdot \\vec{R}Y{_l^{m}} = (-1)^{m+p} \\sum\\limits_{k=|l-j|}^{l+j}Y{_k^{m+p}} * \\alpha_{l,m,j,p,k} * \\frac{1}{2} (k^2-j^2-l^2+k-j-l) $$", "cell_type": "markdown", "metadata": {}}, {"execution_count": 161, "cell_type": "code", "source": "from sympy import *\nfrom sympy.physics.wigner import wigner_3j\ninit_printing(use_latex='mathjax')\n\ndef dot_rota_grad_SH(j, p, l, m, theta, phi):\n temp=0\n for k in range(abs(l-j), l+j +1):\n temp+=Ynm(k, m+p, theta,phi)*alpha(l,m,j,p,k)/2*(k**2-j**2-l**2+k-j-l)\n\n return (-S(1))**(m+p)*temp\n\ndef alpha(l,m,j,p,k):\n return sqrt((2*l+1)*(2*j+1)*(2*k+1)/(4*pi))*wigner_3j(j, l, k, 0, 0, 0)*wigner_3j(j, l, k, p, m, -m-p)\n\n\nprint dot_rota_grad_SH(2,6,2,2,0,0)", "outputs": [{"output_type": "stream", "name": "stdout", "text": "0\n"}], "metadata": {"collapsed": false, "trusted": false}}, {"source": "it is now incorporated in SymPy", "cell_type": "markdown", "metadata": {}}, {"execution_count": 167, "cell_type": "code", "source": "from sympy import Ynm, init_printing, Expr, var, sympify, Dummy, S, Sum, sqrt, pi\nfrom sympy.physics.wigner import wigner_3j\n# init_printing(use_latex='mathjax')", "outputs": [], "metadata": {"collapsed": true, "trusted": false}}, {"execution_count": 168, "cell_type": "code", "source": "class Wigner3j(Expr):\n def doit(self, **hints):\n num = True\n for i in range(6):\n if not self.args[i].is_number:\n num = False\n if num:\n return wigner_3j(*self.args)\n else:\n return self\n\ndef alpha(l,m,j,p,k):\n return sqrt((2*l+1)*(2*j+1)*(2*k+1)/(4*pi)) * Wigner3j(j, l, k, S(0), S(0), S(0))*Wigner3j(j, l, k, p, m, -m-p)\n\ndef dot_rota_grad_SH(j, p, l, m, theta, phi):\n j = sympify(j)\n p = sympify(p)\n l = sympify(l)\n m = sympify(m)\n theta = sympify(theta)\n phi = sympify(phi)\n k = Dummy(\"k\")\n return (-S(1))**(m+p) * Sum(Ynm(k, m+p, theta, phi)*alpha(l,m,j,p,k)/2 *(k**2-j**2-l**2+k-j-l), (k, abs(l-j), l+j))", "outputs": [], "metadata": {"collapsed": true, "trusted": false}}, {"execution_count": 169, "cell_type": "code", "source": "var(\"j p l m theta phi\")\n#dot_rota_grad_SH(1, 5, 1, 1, 1, 2)\ndot_rota_grad_SH(2,0,2,1,theta,phi)", "outputs": [{"execution_count": 169, "output_type": "execute_result", "data": {"text/plain": " 4 \n _____ \n \u2572 \n \u2572 ___________ \u239b 2 \u239e \n \u2572 \u2572\u2571 50\u22c5k + 25 \u22c5\u239dk + k - 12\u23a0\u22c5Ynm(k, 1, \u03b8, \u03c6)\u22c5Wigner3j(2, 2, _k, 0, 0, 0)\n \u2572 \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n- \u2571 ___ \n \u2571 4\u22c5\u2572\u2571 \u03c0 \n \u2571 \n \u2571 \n \u203e\u203e\u203e\u203e\u203e \n k = 0 \n\n \n \n \n \n\u22c5Wigner3j(2, 2, _k, 0, 1, -1)\n\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n \n \n \n \n \n ", "text/latex": "$$- \\sum_{k=0}^{4} \\frac{\\sqrt{50 k + 25}}{4 \\sqrt{\\pi}} \\left(k^{2} + k - 12\\right) Y_{k}^{1}\\left(\\theta,\\phi\\right) Wigner3j(2, 2, _k, 0, 0, 0) Wigner3j(2, 2, _k, 0, 1, -1)$$"}, "metadata": {}}], "metadata": {"collapsed": false, "trusted": false}}, {"execution_count": 170, "cell_type": "code", "source": "print _.doit()", "outputs": [{"output_type": "stream", "name": "stdout", "text": "-3*sqrt(5)*Ynm(2, 1, theta, phi)/(14*sqrt(pi)) + 2*sqrt(30)*Ynm(4, 1, theta, phi)/(7*sqrt(pi))\n"}], "metadata": {"collapsed": false, "trusted": false}}, {"execution_count": 171, "cell_type": "code", "source": "_.expand(func=True)", "outputs": [{"execution_count": 171, "output_type": "execute_result", "data": {"text/plain": " 4 \n _____ \n \u2572 \n \u2572 \u239b _________________________ \n \u2572 \u239c 2 ___________ \u2571 2\u22c5k\u22c5(k - 1)! (k - 1)! \u2148\u22c5\u03c6 \n \u2572 \u239ck \u22c5\u2572\u2571 50\u22c5k + 25 \u22c5 \u2571 \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 + \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 \u22c5\u212f \u22c5assoc_legendre(k, \n- \u2571 \u239c \u2572\u2571 (k + 1)! (k + 1)! \n \u2571 \u239c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n \u2571 \u239d 8\u22c5\u03c0\n \u2571 \n \u203e\u203e\u203e\u203e\u203e \n k = 0 \n\n \n \n \n \n ____\n1, cos(\u03b8))\u22c5Wigner3j(2, 2, _k, 0, 0, 0)\u22c5Wigner3j(2, 2, _k, 0, 1, -1) k\u22c5\u2572\u2571 50\u22c5\n \n\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 + \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n \n \n \n \n\n \n \n \n _________________________ \n_______ \u2571 2\u22c5k\u22c5(k - 1)! (k - 1)! \u2148\u22c5\u03c6 \nk + 25 \u22c5 \u2571 \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 + \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 \u22c5\u212f \u22c5assoc_legendre(k, 1, cos(\u03b8))\u22c5Wigner\n \u2572\u2571 (k + 1)! (k + 1)! \n\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n 8\u22c5\u03c0 \n \n \n \n\n \n \n \n _____\n ___________ \u2571 2\u22c5k\u22c5\n3j(2, 2, _k, 0, 0, 0)\u22c5Wigner3j(2, 2, _k, 0, 1, -1) 3\u22c5\u2572\u2571 50\u22c5k + 25 \u22c5 \u2571 \u2500\u2500\u2500\u2500\n \u2572\u2571 (k\n\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 - \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n \n \n \n \n\n \n \n \n____________________ \n(k - 1)! (k - 1)! \u2148\u22c5\u03c6 \n\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 + \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 \u22c5\u212f \u22c5assoc_legendre(k, 1, cos(\u03b8))\u22c5Wigner3j(2, 2, _k, 0, 0\n + 1)! (k + 1)! \n\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n 2\u22c5\u03c0 \n \n \n \n\n \n \n \n \u239e\n \u239f\n, 0)\u22c5Wigner3j(2, 2, _k, 0, 1, -1)\u239f\n \u239f\n\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u239f\n \u23a0\n \n \n ", "text/latex": "$$- \\sum_{k=0}^{4} \\left(\\frac{\\sqrt{50 k + 25}}{8 \\pi} k^{2} \\sqrt{\\frac{2 k \\left(k - 1\\right)!}{\\left(k + 1\\right)!} + \\frac{\\left(k - 1\\right)!}{\\left(k + 1\\right)!}} e^{i \\phi} P_{k}^{\\left(1\\right)}\\left(\\cos{\\left (\\theta \\right )}\\right) Wigner3j(2, 2, _k, 0, 0, 0) Wigner3j(2, 2, _k, 0, 1, -1) + \\frac{\\sqrt{50 k + 25}}{8 \\pi} k \\sqrt{\\frac{2 k \\left(k - 1\\right)!}{\\left(k + 1\\right)!} + \\frac{\\left(k - 1\\right)!}{\\left(k + 1\\right)!}} e^{i \\phi} P_{k}^{\\left(1\\right)}\\left(\\cos{\\left (\\theta \\right )}\\right) Wigner3j(2, 2, _k, 0, 0, 0) Wigner3j(2, 2, _k, 0, 1, -1) - \\frac{3 e^{i \\phi}}{2 \\pi} \\sqrt{50 k + 25} \\sqrt{\\frac{2 k \\left(k - 1\\right)!}{\\left(k + 1\\right)!} + \\frac{\\left(k - 1\\right)!}{\\left(k + 1\\right)!}} P_{k}^{\\left(1\\right)}\\left(\\cos{\\left (\\theta \\right )}\\right) Wigner3j(2, 2, _k, 0, 0, 0) Wigner3j(2, 2, _k, 0, 1, -1)\\right)$$"}, "metadata": {}}], "metadata": {"collapsed": false, "trusted": false}}, {"execution_count": 173, "cell_type": "code", "source": "for j in range(2):\n for p in range(-j, j+1):\n for l in range(2):\n for m in range(-l, l+1):\n print j, p, l, m, dot_rota_grad_SH(j, p, l, m, theta, phi).doit()", "outputs": [{"output_type": "stream", "name": "stdout", "text": "0 0 0 0 0\n0 0 1 -1 0\n0 0 1 0 0\n0 0 1 1 0\n1 -1 0 0 0\n1 -1 1 -1 sqrt(30)*exp(-4*I*phi)*Ynm(2, 2, theta, phi)/(10*sqrt(pi))\n1 -1 1 0 -sqrt(15)*exp(-2*I*phi)*Ynm(2, 1, theta, phi)/(10*sqrt(pi))\n1 -1 1 1 Ynm(0, 0, theta, phi)/sqrt(pi) + sqrt(5)*Ynm(2, 0, theta, phi)/(10*sqrt(pi))\n1 0 0 0 0\n1 0 1 -1 -sqrt(15)*exp(-2*I*phi)*Ynm(2, 1, theta, phi)/(10*sqrt(pi))\n1 0 1 0 -Ynm(0, 0, theta, phi)/sqrt(pi) + sqrt(5)*Ynm(2, 0, theta, phi)/(5*sqrt(pi))\n1 0 1 1 sqrt(15)*Ynm(2, 1, theta, phi)/(10*sqrt(pi))\n1 1 0 0 0\n1 1 1 -1 Ynm(0, 0, theta, phi)/sqrt(pi) + sqrt(5)*Ynm(2, 0, theta, phi)/(10*sqrt(pi))\n1 1 1 0 sqrt(15)*Ynm(2, 1, theta, phi)/(10*sqrt(pi))\n1 1 1 1 sqrt(30)*Ynm(2, 2, theta, phi)/(10*sqrt(pi))\n"}], "metadata": {"collapsed": false, "trusted": false}}, {"execution_count": null, "cell_type": "code", "source": "", "outputs": [], "metadata": {"collapsed": true, "trusted": false}}, {"execution_count": null, "cell_type": "code", "source": "", "outputs": [], "metadata": {"collapsed": true, "trusted": false}}], "nbformat": 4, "metadata": {"kernelspec": {"display_name": "Python 2", "name": "python2", "language": "python"}, "language_info": {"mimetype": "text/x-python", "nbconvert_exporter": "python", "version": "2.7.9", "name": "python", "file_extension": ".py", "pygments_lexer": "ipython2", "codemirror_mode": {"version": 2, "name": "ipython"}}}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment