{
 "metadata": {
  "name": ""
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Derivation and Conversion of Planck-Einstein Terms"
     ]
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "Start with a generalized Helmholtz energy from \n",
      "$$\\alpha^0 = a_k\\log\\left[c_k + d_k\\exp\\left(\\frac{b_k\\tau}{T_c}\\right)\\right]$$\n",
      "\n",
      "The ideal-gas specific heat can be obtained from \n",
      "$$\\frac{c_p^0}{R} = -\\tau^2\\alpha^0_{\\tau\\tau}$$\n",
      "\n",
      "After some math shown below (and some manual grouping):\n",
      "$$\\frac{c_p^0}{R} = - \\frac{a_{k} (b_{k}\\tau/T_c)^{2} c_k d_{k} e^{\\frac{b_{k} \\tau}{T_{c}}}}{ \\left(c_{k} + d_{k} e^{\\frac{b_{k} \\tau}{T_{c}}}\\right)^2} $$\n",
      "\n",
      "Two important identities:\n",
      "$$ \\left(\\frac{1}{\\cosh x}\\right) = \\frac{2e^{-x}}{1+e^{-2x}}$$\n",
      "$$ \\left(\\frac{1}{\\sinh x}\\right) = \\frac{2e^{-x}}{1-e^{-2x}}$$\n",
      "which yield\n",
      "$$ \\left(\\frac{x}{\\cosh x}\\right)^2 = \\frac{4x^2e^{-2x}}{(1+e^{-2x})^2} = \\frac{(-2x)^2e^{-2x}}{(1+e^{-2x})^2}$$\n",
      "$$ \\left(\\frac{x}{\\sinh x}\\right)^2 = \\frac{4x^2e^{-2x}}{(1-e^{-2x})^2} = \\frac{(-2x)^2e^{-2x}}{(1-e^{-2x})^2}$$"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import division\n",
      "from sympy import *\n",
      "init_session(quiet=True)\n",
      "init_printing()"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "IPython console for SymPy 0.7.5 (Python 2.7.2-32-bit) (ground types: python)\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "a_k,b_k,c_k,d_k,tau,T_c = symbols('a_k,b_k,c_k,d_k,tau,T_c',real=True)\n",
      "alpha0 = a_k*log(c_k + d_k*exp(b_k*tau/T_c))\n",
      "print 'No derivatives'\n",
      "display(alpha0)\n",
      "print 'First partial w.r.t. tau'\n",
      "display(diff(alpha0, tau, 1).simplify())\n",
      "print 'Second partial w.r.t. tau'\n",
      "display(diff(alpha0, tau, 2).simplify())\n",
      "print latex(diff(alpha0, tau, 2).simplify()*(-tau**2))\n",
      "print 'Third partial w.r.t. tau'\n",
      "display(diff(alpha0, tau, 3).simplify())"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "No derivatives\n"
       ]
      },
      {
       "latex": [
        "$$a_{k} \\log{\\left (c_{k} + d_{k} e^{\\frac{b_{k} \\tau}{T_{c}}} \\right )}$$"
       ],
       "metadata": {},
       "output_type": "display_data",
       "png": "iVBORw0KGgoAAAANSUhEUgAAALYAAAAoBAMAAAChsh0EAAAAMFBMVEX///8AAAAAAAAAAAAAAAAA\nAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAv3aB7AAAAD3RSTlMAIquJdjLdEETvu2aZ\nVM0GsGrEAAADx0lEQVRIDa1WXYgbVRg9+ZlMNr+DSosvZqBFEKQGd6tvy0C3IC2WEUToixsVrb6l\nFAoFIQERLYXullZE1ocgfRFR8tAX6Q8Rf0AWYUARH0RTLPqgLLVr2UK3rN93586dO9OZTHbpB7lz\nvnPOd/Zm7iRZ4EHVafdBJd2fM3M/lcVUh1kOqT+m+0xb79LwkTQhzv92xb8pL3/0Rhc4G5cT+vKH\nCWQitZobYx8p3vssF21eJ9epqU/oen2AXznsWZH49+RcVp/MtkjHON/HD4zHgmjRjZlcxsZkXVPf\neR44dmYEcyDIvK1pibAx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n",
        "       \u239c           \u2500\u2500\u2500\u2500\u2500\u239f\n",
        "       \u239c            T_c \u239f\n",
        "a_k\u22c5log\u239dc_k + d_k\u22c5\u212f     \u23a0"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "First partial w.r.t. tau\n"
       ]
      },
      {
       "latex": [
        "$$\\frac{a_{k} b_{k} d_{k} e^{\\frac{b_{k} \\tau}{T_{c}}}}{T_{c} \\left(c_{k} + d_{k} e^{\\frac{b_{k} \\tau}{T_{c}}}\\right)}$$"
       ],
       "metadata": {},
       "output_type": "display_data",
       "png": "iVBORw0KGgoAAAANSUhEUgAAAJsAAABMBAMAAACIdNgoAAAAMFBMVEX///8AAAAAAAAAAAAAAAAA\nAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAv3aB7AAAAD3RSTlMAIquJdjLdEETvu2aZ\nVM0GsGrEAAAFE0lEQVRYCe1YXWgcVRT+Zncns5vd2QwFfTSL5kHwoQuJiChxiSnUJsgKIgTFrBZ/\n8GkQKbVGdp+q9aFsrRY0KkH6pqarFEVa2xV/XoS66ov4ku2PFUmJKRFSbUI9587O7J3snZ+tPvTB\nA7nzne989+yd2bsz3wToO9Jv9j0ldEI9tNpvUWv3OyNUby5/I+qPv/W0HSqMV8w1bkGiDbRejaeP\nUOWtX2A2SXRXhDBeOY/bkWuRth1PH6FKj7UwsPckjIUIYfxy5uOX4oujlQcnojV9KKbyL/ehjpR+\nmd0ZqfEJ9h2R0tfekZJrUkh0BDwn1zflBKdGN8aLPiY6kTuk1336pl43Sj4mMvF1SFZ8+la2YNR8\nTGSSrEiSfFNKCCZKNMQI7bYdzziy/Mg0/5A4to3NdqAxNm0xM1DmMToOWIOrSB0mYfU3XMYDRULp\nQzhmO3C/pTGDKv39dJJRaBjzyC0Az5JoycYaBmqEXmzgDC2IoPYu5sS6DgJmIUm18MitY6AEg7/H\nMzDWULUJfW9jNy2IYGJ+8jNukLxYRF705Sw4MguolpGukOIS0pv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baG6iO2agLyWau3kK33cjGZcYWO3ueuN+ZVEx9UkXE4\nU3lemXKcuQrNQENBIttWsTG4U2rNUTUdxWqH1Io913e2e1rqdtoTaj6C/SCoflNQIYw3ak71H3/h\nm+3fsAlYAAAAAElFTkSuQmCC\n",
       "text": [
        "               b_k\u22c5\u03c4  \n",
        "               \u2500\u2500\u2500\u2500\u2500  \n",
        "                T_c   \n",
        "  a_k\u22c5b_k\u22c5d_k\u22c5\u212f       \n",
        "\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n",
        "    \u239b           b_k\u22c5\u03c4\u239e\n",
        "    \u239c           \u2500\u2500\u2500\u2500\u2500\u239f\n",
        "    \u239c            T_c \u239f\n",
        "T_c\u22c5\u239dc_k + d_k\u22c5\u212f     \u23a0"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Second partial w.r.t. tau\n"
       ]
      },
      {
       "latex": [
        "$$\\frac{a_{k} b_{k}^{2} c_{k} d_{k} e^{\\frac{b_{k} \\tau}{T_{c}}}}{T_{c}^{2} \\left(c_{k} + d_{k} e^{\\frac{b_{k} \\tau}{T_{c}}}\\right)^{2}}$$"
       ],
       "metadata": {},
       "output_type": "display_data",
       "png": "iVBORw0KGgoAAAANSUhEUgAAAKgAAABQBAMAAAB/pCPzAAAAMFBMVEX///8AAAAAAAAAAAAAAAAA\nAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAv3aB7AAAAD3RSTlMAIquJdjLdEETvu2aZ\nVM0GsGrEAAAFkElEQVRYCc1YXYgbVRQ+yWx2JptkMhQUfHGXug8FwUa6PoiLhnULtV00ggiL4qb+\noCjCUETaurIBsVIfZLVaxPqzlIIvdRul6EMrRmwVfKjRJy2UTVt/kNZ1RWGr7RLPuXfuzNyZzJ2Z\n6EPPw733fOecL/fMT3K/APRtxht9lyoK5xWxfkOZTr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iPRhR+n4hVZCeWyq7GW5i1fkqm5IOfiEVlnLbYcYipuFaUr5wHh3B\nmWX+Prjxn/W/V96E4QYBnzE0alCrM94r1moVyNeh2GQncvS/jOLjuFKd3SNqs9hxCwoNgEcZ9KQI\neLPOrgvz1epsSSQ+gB23YcDG0zIru+KRiVWpKlag1d0lLQLqTCgiaABstMEAOM7T/+KTf/SRqtXZ\nHF5EYUwwGxWjhoB+maGuICPPJY1TZ+UqK6Yhwzp+6MxpmxxG6goyliRIY9WZT2AU2B19r9slhhxz\nXEEmke6KU2flFsunIUtfWcJytFNPkDFY7DRWnflI8TH1jLXvCTJ8jpeXf353ebmFKbHqzNc+Pqae\n6XT3XUHGcWen8eqMNJdj+Jj6jBQpBZkg47ggjVVnwx7TERtrtckqZ3gNJ0+QMUxc01h1NtPgHKAt\nds9VUY7n5jmwSJMryBgmSGPV2RJtz7Pigl7j3q0C9ASZIGURlWRxazlHvi243E/zBJnRFEGcVZLl\noC8Pl2VL+O776wkyEWKzSrLwV9xNNxvQ4s7QiAumXQT/bsycOGpzjvCvV2JurROViv8V9Gt5/7WX\nSe6W3RTeD9G5+Vp0TB15Kjpc6ETHlBFl4SFlaXTwOvex7JHzbH/960/34HKhzHZ3mWYxFH3vieaa\nNFxuru+P1H8Bv/Dea92wCuIAAAAASUVORK5CYII=\n",
       "text": [
        "                  b_k\u22c5\u03c4 \n",
        "                  \u2500\u2500\u2500\u2500\u2500 \n",
        "       2           T_c  \n",
        "a_k\u22c5b_k \u22c5c_k\u22c5d_k\u22c5\u212f      \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\n",
        "                       2\n",
        "     \u239b           b_k\u22c5\u03c4\u239e \n",
        "     \u239c           \u2500\u2500\u2500\u2500\u2500\u239f \n",
        "   2 \u239c            T_c \u239f \n",
        "T_c \u22c5\u239dc_k + d_k\u22c5\u212f     \u23a0 "
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "- \\frac{a_{k} b_{k}^{2} c_{k} d_{k} \\tau^{2} e^{\\frac{b_{k} \\tau}{T_{c}}}}{T_{c}^{2} \\left(c_{k} + d_{k} e^{\\frac{b_{k} \\tau}{T_{c}}}\\right)^{2}}\n",
        "Third partial w.r.t. tau\n"
       ]
      },
      {
       "latex": [
        "$$\\frac{a_{k} b_{k}^{3} c_{k} d_{k} \\left(c_{k} - d_{k} e^{\\frac{b_{k} \\tau}{T_{c}}}\\right) e^{\\frac{b_{k} \\tau}{T_{c}}}}{T_{c}^{3} \\left(c_{k}^{3} + 3 c_{k}^{2} d_{k} e^{\\frac{b_{k} \\tau}{T_{c}}} + 3 c_{k} d_{k}^{2} e^{\\frac{2 b_{k}}{T_{c}} \\tau} + d_{k}^{3} e^{\\frac{3 b_{k}}{T_{c}} \\tau}\\right)}$$"
       ],
       "metadata": {},
       "output_type": "display_data",
       "png": "iVBORw0KGgoAAAANSUhEUgAAAZYAAABUBAMAAABTgQyuAAAAMFBMVEX///8AAAAAAAAAAAAAAAAA\nAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAv3aB7AAAAD3RSTlMAIquJdjLdEETvu2aZ\nVM0GsGrEAAALOklEQVR4AeVafYxcVRU/s7Ozb2bnU4gaEmNH3KQaA4x0xbQ0ddKPBGhTxtRoGgy7\nVUFFsSMSQrE6kxirVVMWK+WjqBvSRIzYjqaRkCodhGJSSBmVP5SE7AC1xrSuWyUu2tb13HPvufe+\nN+/Nx9vZbUlvsvPOPb/f79x75915M/veD+A8tvj9wYO3w4JV5xGZaDN2O6yNrN/QoS4LRpo28Q67\nA27MBS1mZ7DZ5Wjpk0eIGfvbns8CxF0yxm5+6NZyl+UWgraz28FTtXfDAK4gHa+KeawWL9wYa3yb\nM+fj6LT5RLvnk8m9DOk65qK0+kzNgjX2YSu56OFAvdshM/A+SDWQnSFFZNYSaqxpJRciHL26z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nXuMcH8+qhQOwC4YR97FFadFNfbfG9L5rQnQCym8wO2XH0Qndy+Y4\n5H8q5HbgrPto/DDoL1QeGTcjqGfRabsF8VrzHejDeS3JVKEuOxU+CdZ20DQVtPXDeMlB/Tb1/SQd\n6OIqqVrk2YNlGeoFWtuBWXxs64dhUqdjm/p+0g50770DKpGcUJWs7eCt3dYP4yUH9dvU95N0oK/y\n08zDzuJXbrFye30H2uibvcCTad5N7nmGt7O46yxqb8h89O1xk0279xaJnwqY576A/AWcjtwXMLmQ\ndpaAaouSvqsRMExIO0tAtUVJ/yxwlHB2lsByCw+oG1n/Bx1oNENKOewqAAAAAElFTkSuQmCC\n",
       "text": [
        "                               \u239b           b_k\u22c5\u03c4\u239e  b_k\u22c5\u03c4             \n",
        "                               \u239c           \u2500\u2500\u2500\u2500\u2500\u239f  \u2500\u2500\u2500\u2500\u2500             \n",
        "                     3         \u239c            T_c \u239f   T_c              \n",
        "              a_k\u22c5b_k \u22c5c_k\u22c5d_k\u22c5\u239dc_k - d_k\u22c5\u212f     \u23a0\u22c5\u212f                  \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\n",
        "     \u239b                   b_k\u22c5\u03c4               2\u22c5b_k\u22c5\u03c4         3\u22c5b_k\u22c5\u03c4\u239e\n",
        "     \u239c                   \u2500\u2500\u2500\u2500\u2500               \u2500\u2500\u2500\u2500\u2500\u2500\u2500         \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u239f\n",
        "   3 \u239c   3        2       T_c             2    T_c        3    T_c  \u239f\n",
        "T_c \u22c5\u239dc_k  + 3\u22c5c_k \u22c5d_k\u22c5\u212f      + 3\u22c5c_k\u22c5d_k \u22c5\u212f        + d_k \u22c5\u212f       \u23a0"
       ]
      }
     ],
     "prompt_number": 16
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "Aly-Lee starts as\n",
      "$$\\frac{c_p^0}{R_u} = A + B\\left(\\frac{C/T}{\\sinh(C/T)}\\right)^2 + D\\left(\\frac{E/T}{\\cosh(E/T)}\\right)^2$$\n",
      "and generalized Plank-Einstein term is given by\n",
      "$$\\frac{c_p^0}{R_u} = - \\frac{a_{k} b_{k}^{2} c_{k} d_{k} \\tau^{2} e^{\\frac{b_{k} \\tau}{T_{c}}}}{T_{c}^{2} \\left(c_{k} + d_{k} e^{\\frac{b_{k} \\tau}{T_{c}}}\\right)^{2}}$$\n",
      "\n",
      "Constant is separated out, and handled separately.  sinh part can be expanded as\n",
      "$$B\\left(\\frac{C/T}{\\sinh(C/T)}\\right)^2 = \\frac{B(-2C/T)^2\\exp(-2C/T)}{(1-\\exp(-2C/T))^2}$$\n",
      "where\n",
      "$$a_k = B$$\n",
      "$$b_k = -2C$$\n",
      "$$c_k = 1$$\n",
      "$$d_k = -1$$\n",
      "\n",
      "cosh part can be expanded as\n",
      "$$D\\left(\\frac{E/T}{\\cosh(E/T)}\\right)^2 = \\frac{D(-2E/T)^2\\exp(-2E/T)}{(1+\\exp(-2E/T))^2}$$\n",
      "where\n",
      "$$a_k = -D$$\n",
      "$$b_k = -2E$$\n",
      "$$c_k = 1$$\n",
      "$$d_k = 1$$"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "B, D, T = symbols('B, D, T', real = True, positive = True)\n",
      "# From Aly-Lee:\n",
      "term1 = ((D/T)/sinh(D/T))**2\n",
      "# Planck Einstein\n",
      "term2 = (B/T)**2*exp(B/T)/(exp(B/T)-1)**2\n",
      "diff1 = term2 - term1\n",
      "display(diff1.rewrite(exp).subs(B, 2*D).simplify())\n",
      "term2 = (2*D/T)**2*exp(2*D/T)/(exp(2*D/T)-1)**2\n",
      "display(term2)\n",
      "print 'which is the same as the Aly-Lee sinh term with a_k = C, b_k = 2*D, c_k = -1, d_k = 1'\n",
      "\n",
      "B, F, T = symbols('B, F, T', real = True, positive = True)\n",
      "# From Aly-Lee:\n",
      "term1 = ((F/T)/cosh(F/T))**2\n",
      "# Planck Einstein\n",
      "term2 = (B/T)**2*exp(-B/T)/(exp(-B/T)+1)**2\n",
      "diff2 = term2 - term1\n",
      "display(diff2.rewrite(exp).subs(B, 2*F).simplify())\n",
      "# So Aly-Lee cosh term can be directly converted to Plank-Einstein2 term with b_k = 2*F, and c=1"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "latex": [
        "$$0$$"
       ],
       "metadata": {},
       "output_type": "display_data",
       "png": "iVBORw0KGgoAAAANSUhEUgAAAAoAAAAOBAMAAADkjZCYAAAAMFBMVEX///8AAAAAAAAAAAAAAAAA\nAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAv3aB7AAAAD3RSTlMAEJmJdjLNVN0iZu+7\nq0QgoRR7AAAAVklEQVQIHWNgEDJRZWBgSGeQmMDAtYGBOYGB5wID+0cG/gsMfN8Z5BUY+L4wzDdg\nYP0MJeUNQCL8Cgzs3xk4DjBwfWRg2cDAlMDA0M4gHcDAIOxylQEA9FISlFfRJtkAAAAASUVORK5C\nYII=\n",
       "text": [
        "0"
       ]
      },
      {
       "latex": [
        "$$\\frac{4 D^{2} e^{\\frac{2 D}{T}}}{T^{2} \\left(e^{\\frac{2 D}{T}} - 1\\right)^{2}}$$"
       ],
       "metadata": {},
       "output_type": "display_data",
       "png": "iVBORw0KGgoAAAANSUhEUgAAAIUAAABLBAMAAACsFlnLAAAAMFBMVEX///8AAAAAAAAAAAAAAAAA\nAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAv3aB7AAAAD3RSTlMAM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5SHflWMV33mGhnjudYtZSi\nT7VbB0VA7J5SVRFkoypSkaPSHZA+xny5e0oNFpgfzbKLRFWkIseKzaSiZc4zK3ePIDasjENYVEUq\ncojLsbE0Y/Z+ALl7mjb5mWexWGYg9BWpzOFwCe8K3i6jkN9k4am9bwrer0iP38XaOxyWOapCw3p6\nPPxWsckvrUkgoiIN56DHw2/8XkqOBNSJ5/PcC98LPR5+W2mQn3YAZhFRkcocNpOIJp5cGfAppFpY\ntBStsSJHs6uo3G73Q35NAaTXmJ3dZ4tQ299+8AFGV/pall6gWhFEGF7thDGO5OYjiDD8cRgSiPc+\nGyXw8RnfDXqmfGkJotooWhmZfTiP90/AMAG8Fob0SC569Ve6+iEhNG2HIAXQ8xWvfT1C9ugIbpC6\ndzAY8t8YiiNCY9R8k42IUUH4kBWMA5HpnzsBPBiY9wfjoej5UVdQ2qStPK3NlLVwEBz88+BfPbFP\nimrffr4AAAAASUVORK5CYII=\n",
       "text": [
        "        2\u22c5D   \n",
        "        \u2500\u2500\u2500   \n",
        "     2   T    \n",
        "  4\u22c5D \u22c5\u212f      \n",
        "\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n",
        "             2\n",
        "   \u239b 2\u22c5D    \u239e \n",
        "   \u239c \u2500\u2500\u2500    \u239f \n",
        " 2 \u239c  T     \u239f \n",
        "T \u22c5\u239d\u212f    - 1\u23a0 "
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "which is the same as the Aly-Lee sinh term with b_k = 2*D\n"
       ]
      },
      {
       "latex": [
        "$$0$$"
       ],
       "metadata": {},
       "output_type": "display_data",
       "png": "iVBORw0KGgoAAAANSUhEUgAAAAoAAAAOBAMAAADkjZCYAAAAMFBMVEX///8AAAAAAAAAAAAAAAAA\nAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAv3aB7AAAAD3RSTlMAEJmJdjLNVN0iZu+7\nq0QgoRR7AAAAVklEQVQIHWNgEDJRZWBgSGeQmMDAtYGBOYGB5wID+0cG/gsMfN8Z5BUY+L4wzDdg\nYP0MJeUNQCL8Cgzs3xk4DjBwfWRg2cDAlMDA0M4gHcDAIOxylQEA9FISlFfRJtkAAAAASUVORK5C\nYII=\n",
       "text": [
        "0"
       ]
      }
     ],
     "prompt_number": 10
    }
   ],
   "metadata": {}
  }
 ]
}