{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Solutions Q1 - 10"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"# import all python add-ons etc that will be needed later on\n",
"%matplotlib inline\n",
"import numpy as np\n",
"import matplotlib.pyplot as plt\n",
"from sympy import *\n",
"import numpy.linalg as LA\n",
"init_printing() # allows printing of SymPy results in typeset maths format\n",
"plt.rcParams.update({'font.size': 14}) # set font size for plots"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
"\n",
"## Q1 answer\n",
"Expanding the determinant produces \n",
"\n",
"$$\\displaystyle \\frac{c}{\\sqrt{c^2-v^2}}\\left( 1-\\frac{v^2}{c^2} \\right) =\\frac{1}{c\\sqrt{c^2-v^2}}\\left( c^2-v^2 \\right)=\\frac{\\sqrt{c^2-v^2}}{c}=\\sqrt{1-\\frac{v^2}{c^2}} $$\n",
"\n",
"## Q2 answer\n",
"The first term in the expansion element in the top left corner is zero hence only two terms appear in the result. The cofactor of $y$ in the top row is $\\displaystyle -\\begin{vmatrix} x & -z\\\\ x& 0 \\end{vmatrix}=-xz$ and of $z$ is $\\displaystyle \\begin{vmatrix} x & 0\\\\ x& y \\end{vmatrix}=xy$ hence \n",
"\n",
"$$\\displaystyle \\qquad \\begin{vmatrix} 0 & y & z \\\\ x & 0 &-z \\\\x & y & 0 \\end{vmatrix}=-yxz+zxy=0$$\n",
"\n",
"## Q3 answer\n",
"The characteristic polynomial is the polynomial resulting from expansion of the determinant and made equal to zero,\n",
"\n",
"$$\\displaystyle \\quad \\begin{vmatrix} x & a & b \\\\ a & x & b \\\\a & b & x \\end{vmatrix}=x(x^2-b^2)-a(ax-ab)+b(ab-ax)=0$$\n",
"\n",
"Factoring produces $(x-b)\\left[ x(x+b)-a(a+b) \\right]=0$ with the solution $x=b$. The other solutions are found from the quadratic in square brackets. This produces $x=-b -a$ and $x=a$. Using Sympy is easy also, after factoring the solve step is really not necessary."
]
},
{
"cell_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4kAAAAASUVORK5CYII=\n",
"text/latex": [
"$\\displaystyle \\left(- a + x\\right) \\left(- b + x\\right) \\left(a + b + x\\right)$"
],
"text/plain": [
"(-a + x)⋅(-b + x)⋅(a + b + x)"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"x, a, b = symbols('x, a, b')\n",
"M = Matrix( [ [x,a,b], [a,x,b], [a,b,x] ] )\n",
"char_eqn = M.det()\n",
"\n",
"factor(char_eqn )"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAJQAAAAUCAYAAABrjBQMAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjYuMCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy89olMNAAAACXBIWXMAABJ0AAASdAHeZh94AAADl0lEQVR4nO2aT4hVVRzHPyNjSllMKoShDNqiwGaIJNwUmOIiXOWqomKiRRgh4kI3ytdvi6CFLaLcZWEIupFAgpCwiWhRaGr/oH8wbkyYpEUhgdJzce7V65v75p337rnv1sx8Nvdyz8z5/s73nff7nXPeHWq1WiywQCoWNR3AAnOL4fzG9ibgs0LbT5IeGnRA7djeARwCXpZ0uOl45jK9eG17JTBdfCZpaLjkbz8HJoE/EsVZlQ3Z9WyjUcwPevH6KuDsfgIYhUKGKjAp6UDVyBKyAfgH+KHpQOYB0V5LugocgJvVbRT+42so20uA9cC3kq43Hc9cJpXXZRlqNtHngG3AY8Aq4DrwK3BI0vv9BjELY8Bi4KztR4D9wCZgKfAlsFvS9zXo1k4DXnYjidfRGcr23cARYB3wBfAOcAJYCxy2vbe3+KPIa/ooYVAt4D3gG2ArcNr2SA26tdKQl91I4nUvGaoFrJZ0ufjQ9j7gZ+Al4M0e+ovh0ey6EXhc0rmC7hHgBeBV4I3EunXThJfdSOJ1dIaS9He7Adnz34FLwPLYvnog/9bsKQ4w493sOlaDbq005GU3kngdnaFs3wu8Rqj7DwL3cPuEbA+iErYXEwZwkVAe2sk/kKUpdTvEMkW2i4nkqKTnZ+mvkpc1xJPM66gJZXscOAXcB3wNHAOuEBaSa4EXgQsxffXAw8AdwMkOu47c0IuJdcv4jbCdjuVSp4ZEXiaLJyOZ17EZ6kNgBHhS0mSxwfbr2e2ZyL5iyVPwVIf2p7PrqcS6M5C0JWF3lb1MHA8k9LrrGsr2GmCccOA52dY2QlhAQvqT7HyQM9YTtlcBrwC/MIAJlYoGvexGMq9jFuV5al2X1dpcaAVwHFhNSNfnS4L5wHbL9kSETjv5ruNZ23cV+lxGqPNLgJ3tKbqiZt307WXN9OV1GV1LnqRp26eBzcBXtj8lHMQ9Rfgx+V/gR0llNT2fsD2dvNoeJnyTzwF3Audtf0QY2HbgfmCXpE9SaQ6Cil7WQkWvZxB7bPAMofavAXYADwC7CWcSi+hc88eAv4CPI3Vy1hN2FGeALcB3hLQ7QfidabOktxNrDop+vayLKl7PIGpRLmmasPsoY6jsYbYmGAcOSvozNqBM70Jbv9tj/q+K5qDox8s66dfrTpRNKNkW1d+HegK4BrxVoY//g+a8pOx9KLh9Qk1x6/0WqPg+lKSTDODQsWnNeUzxfaib3AAa9JDg5BNn9wAAAABJRU5ErkJggg==\n",
"text/latex": [
"$\\displaystyle \\left[ a, \\ b, \\ - a - b\\right]$"
],
"text/plain": [
"[a, b, -a - b]"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"solve(char_eqn,x)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Q4 answer\n",
"The $(2,3)$ element is the element in row $2$, column $3$ and is $1$. The cofactor is the $2 \\times 2$ determinant not including the second row or third column, $\\displaystyle -\\begin{vmatrix} a&b\\\\e&f\\end{vmatrix}$. The minus sign is present because the first cofactor in a row or column if multiplied by $+1$ and the second by $-1$, the third by $+1$ in an alternating pattern. \n",
"\n",
"## Q5 answer\n",
"(a) As it is small construct the matrix directly and calculate the determinant as in the examples, section 2.5. The first calculation is a numerical evaluation using the numpy linear algebra package. The second used algebraic solution using SymPy. The numerical value is effectively zero being so small. "
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"0.0\n"
]
}
],
"source": [
"M = np.array( [ [1,2,3,4], [5,6,7,8], [9,10,11,12], [13,14,15,16] ] ) # numerical method \n",
"print(LA.det(M)) # LA calls linear algebra package defined at top of document"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAA0AAAAQCAYAAADNo/U5AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjYuMCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy89olMNAAAACXBIWXMAABJ0AAASdAHeZh94AAABEElEQVR4nJXSsUqcURCG4cfFKosYCKRSECR6BzFgJcLiTdiLQsA6xTCCrYVibiAXkNjapFK8A90Vwc5KVMSUroVn5fjrBp3mg5l5Z4ZzvpF+v++9MdpMZOYENrCET7jAH2REXMFIvSkzp3GIz9jDCb5iAV3MR8Rlc9PPAnyPiJ1q2BbWsYmVVmNLB+fYbQwL3GE5M9utqrBQdD8i7p8REbc4wAd8q6HZor3m45Q4LTpTQ+NFb4ZAg/zH1pCG/0YNDSaNv9ZY5a9rqFt0Zgj0pWivhv4W7WTms7Mzcwzz+Iejp2JEnGEfU1hrbEm08Ssi7pqOWPVoo+3MXMQx5jz+YQ8/aHivnDLppWF/G2bYt8YDKpZR3A7SAGIAAAAASUVORK5CYII=\n",
"text/latex": [
"$\\displaystyle 0$"
],
"text/plain": [
"0"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"M = symbols('M') # symbolic algebra\n",
"M = Matrix( [ [1,2,3,4], [5,6,7,8], [9,10,11,12], [13,14,15,16] ] )\n",
"M.det()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The reason for this determinant being zero is seen in a determinant's properties (Chapter 7.2.4). Subtracting the first row from the second, this row becomes $4,4,4,4$. Similarly, subtracting the first row from the third, this becomes $8, 8, 8, 8$ and the $4$ and $8$ can be removed and the whole determinant multiplied by $32$. This leaves two rows the same, therefore the determinant is zero. \n",
"\n",
"$$\\displaystyle \\begin{vmatrix} 1 & 2& 3 &4\\\\5 & 6& 7 &8\\\\9 & 10& 11 &12\\\\13 & 14& 15 &16\\end{vmatrix} =32\\begin{vmatrix} 1 & 2& 3 &4\\\\1 & 1& 1 &1\\\\1 & 1& 1 &1\\\\13 & 14& 15 &16\\end{vmatrix}=0$$"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"0.0\n"
]
}
],
"source": [
"n = 4\n",
"M = np.zeros((n,n), dtype = int)\n",
"s = 1\n",
"for i in range(n):\n",
" for j in range(n):\n",
" M[i,j] = s\n",
" s = s + 1\n",
"print(LA.det(M)) # LA calls linear algebra package defined at top of document"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"This is a numerical answer, as opposed to an algebraic one, meaning that an numerical algorithm was used to evaluate it. The answer is sufficiently small to assume that it is zero. \n",
"\n",
"## Q6 answer\n",
"The prime numbers have to be found first. The first prime is $2$. The $\\mathtt{def\\; isprime(n)}$ checks only as far as the square root since, if it has a larger factor, it also has a smaller one."
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"primes [ 2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53]\n",
"value = 880.00\n"
]
}
],
"source": [
"#-------------\n",
"def isprime(n):\n",
" if n < 2: \n",
" return False;\n",
" if n % 2 == 0: # is a factor of 2. symbol % is modulus \n",
" return n == 2 # returns True note == is used to make it true\n",
" k = 3\n",
" while k*k <= n:\n",
" if n % k == 0:\n",
" return False # not prime\n",
" k = k + 2\n",
" return True # true if prime\n",
"#-------------\n",
"\n",
"n = 4\n",
"anum = np.zeros(n*n,dtype=int) # make array of integers \n",
"\n",
"max = 0\n",
"i = 2\n",
"while max < n*n : # make only n x n values \n",
" if isprime(i):\n",
" max = max + 1\n",
" anum[max-1] = i\n",
" i=i+1 # increment number to check\n",
"print('{:s} {:s}'.format('primes ',str(anum)) ) # list of primes\n",
"\n",
"M = np.zeros((n,n),dtype=int)\n",
"k = 0\n",
"for i in range(n):\n",
" for j in range(n):\n",
" M[i,j] = anum[k]\n",
" k = k + 1\n",
"\n",
"print( '{:s} {:8.2f}'.format('value = ', LA.det(M) ) )"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Q7 answer\n",
"The only change that has to be made in the case of benzene compared to the linear 1, 3, 5-hexatriene, is to add 1 to the matrix in the $(1, 6)$ and $(6, 1)$ positions, or $(1, n)$ and $(n, 1)$ generally. The calculation is the same as in Algorithm 1, but with $n=6$ because there are six carbon atoms each with one $\\pi$ electron, and changes to the two extreme elements, top right, bottom left, to unity from zero, to make the benzene structure cyclic. This can be done with a line added outside and after the last end do; to link the first to last atoms."
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"data": {
"text/latex": [
"$\\displaystyle \\left[\\begin{matrix}x & 1 & 0 & 0 & 0 & 1\\\\1 & x & 1 & 0 & 0 & 0\\\\0 & 1 & x & 1 & 0 & 0\\\\0 & 0 & 1 & x & 1 & 0\\\\0 & 0 & 0 & 1 & x & 1\\\\1 & 0 & 0 & 0 & 1 & x\\end{matrix}\\right]$"
],
"text/plain": [
"⎡x 1 0 0 0 1⎤\n",
"⎢ ⎥\n",
"⎢1 x 1 0 0 0⎥\n",
"⎢ ⎥\n",
"⎢0 1 x 1 0 0⎥\n",
"⎢ ⎥\n",
"⎢0 0 1 x 1 0⎥\n",
"⎢ ⎥\n",
"⎢0 0 0 1 x 1⎥\n",
"⎢ ⎥\n",
"⎣1 0 0 0 1 x⎦"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Algorithm Huckel Calculation Cyclic polyenes\n",
"\n",
"n, M, x = symbols('n, M, x') # define symbols to use\n",
"n = 6 # define size of linear polyene\n",
"M = zeros(n,n) # make an array of zeros \n",
"for i in range(n):\n",
" M[i,i] = x\n",
" if (i > -1) and (i < n-1):\n",
" M[i, i+1] = 1\n",
" M[i+1, i] = 1\n",
" \n",
" pass\n",
"M[0, n-1] = 1 # n-1 because index runs from 0 to n-1, for n values\n",
"M[n-1, 0] = 1\n",
"M"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAARYAAAAVCAYAAACDrsFVAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjYuMCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy89olMNAAAACXBIWXMAABJ0AAASdAHeZh94AAAGQ0lEQVR4nO2be4hUVRzHP5v+kWQPMsgwSqO0oMdSRBZam4+kgtzUoCzTrIjCzMrIjeTbr+ghha6FFSaoRFCiRCShvazsnZGRlEWWZamoKEYPM3X745zV2Tt37tx73Tt7Z5wvDGfmnt95/D5zzm/unHNuQ1tbG3XVVVddnanuXd2BuvIjM2sBRgEDgH+BT4EWSWu6tGM5U51TeR3W1R2oK1dqAp4FLgKGAHuAt83s2K7sVA7VRJ1TpBrC/gqZ2ULgcqCfpL8q3qsMZGbnAauAWyXNK2Nbc/5DMgbeviewE2iW9HoJm5pjVecUX6VYFQUWMzsf+AyYKmlmRXuZQGbWC7gauBI4C+gD7Aa+AeYD8yXtC5R5FRgInCbpzxL1VoX/AGY2BrgEaATOAY4EXpJ0Q0SZsgwKbE8ANgKDJX0Ykl+zrA5FTmnmlC9XxCrsr9CjwB/Ac5n0vvN0DfACcAHuS2sFlgBnAvOARWbWECjzONAbmBxRb7X4D/AgMAk3WX6PWSYOg3bNBlYDn5TIr2VWhyKnNHMKQlh1CCxm1h8YBiyS9E8WPe9E/QBcBZ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xy0sfYmLqttiFBvo0xWFF6P8923lkkFKhTKIq2ocKymVGSfIJ6uUcwoCrIIH5JbgTteNAH70DTUCS3EPWQ2XtAlA0mIzWwWMNLPBklamdye5zGw88DDujMBKYHLIYtV6SQsC1y7zZV4LqbbIf99WI/lk0Aw0+4+9fXqhmS3w77dJCu5UQDSDuKqaseL71kxyVplw8v1pJGesDmJOQYBVWGDZgtuznuOj7DKgDRdR1wXsW4C3gCc5ELEqpX4+7QZMKWHzPu42EwAzOxo3uJZK2hBi38F/XybPDBpxh6gKdYp/AfxCYAs0BoO4qqaxAglZZcXJ151XVonnFISzCnu6uQV4DDhX0led1eM8yMzuBJ6mxFOo3qZm/Yd4DBLUVbOs6pziK4xV2MNVs4BfcbdENSMz64H7JVhSZqDUpP+QiEFc1SSrOqf4KsWqKLBI2oU7CLPKH0muFfUF5lJ8OrKDath/iMkgrmqYVV/qnOKqLyGs/geoHWmDjPHT7QAAAABJRU5ErkJggg==\n",
"text/latex": [
"$\\displaystyle \\left(x - 2\\right) \\left(x - 1\\right)^{2} \\left(x + 1\\right)^{2} \\left(x + 2\\right)$"
],
"text/plain": [
" 2 2 \n",
"(x - 2)⋅(x - 1) ⋅(x + 1) ⋅(x + 2)"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"char_eqn = M.det()\n",
"factor(char_eqn)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"From the factors the solutions are $x= 2,1,1,-1,-1,-2 $. The energy is calculated using $E=\\alpha-\\beta x$ and hence the energies are $E=\\alpha \\pm 2\\beta$ and $\\alpha \\pm \\beta$ each of which is doubly degenerate giving six levels in all. The energies for cyclo-octatetraene $(n=8)$ are $x=0,0, -2,2,\\pm\\sqrt{2},\\pm\\sqrt{2}$ as shown in figure 74.\n",
"\n",
"The stabilization energy of benzene is the difference between $6\\pi$ electrons and that of the MO, which is $2(1 + 1 + 2)\\beta$ or $8\\beta$. The delocalization energy is that achieved over six electrons in three individual double bonds each with $\\pi$ energy $\\alpha+\\beta$. The delocalization energy is therefore $2\\beta$.\n",
"\n",
"![Drawing](matrices-fig74.png)\n",
"\n",
"Fig. 74 Benzene (left) and cyclo-octatetraene Huckel MO energies measured relative to energy $\\alpha$. Note that the energy integral $\\beta$ is a negative number.\n",
"_________\n",
"\n",
"## Q8 answer\n",
"Starting with the matrix, using the method of Algorithm 1 with $n = 6$, modify the matrix to connect atom $2$ atom $6$ as in the structure; the atoms $2$ and $3$ 3 are connected already because adjacent atoms always connect in the numbering scheme. Adding the following line, as was done in the previous problem, links atoms $2$ and $6$,\n"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [
{
"data": {
"text/latex": [
"$\\displaystyle \\left[\\begin{matrix}x & 1 & 0 & 0 & 0 & 0\\\\1 & x & 1 & 0 & 0 & 1\\\\0 & 1 & x & 1 & 0 & 0\\\\0 & 0 & 1 & x & 1 & 0\\\\0 & 0 & 0 & 1 & x & 1\\\\0 & 1 & 0 & 0 & 1 & x\\end{matrix}\\right]$"
],
"text/plain": [
"⎡x 1 0 0 0 0⎤\n",
"⎢ ⎥\n",
"⎢1 x 1 0 0 1⎥\n",
"⎢ ⎥\n",
"⎢0 1 x 1 0 0⎥\n",
"⎢ ⎥\n",
"⎢0 0 1 x 1 0⎥\n",
"⎢ ⎥\n",
"⎢0 0 0 1 x 1⎥\n",
"⎢ ⎥\n",
"⎣0 1 0 0 1 x⎦"
]
},
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Algorithm Huckel Calculation Fulvalene\n",
"n, M, x = symbols('n, M, x') # define symbols to use\n",
"n = 6 # define size of linear polyene\n",
"M = zeros(n,n) # make an array of zeros \n",
"for i in range(n):\n",
" M[i,i] = x\n",
" if (i > -1) and (i < n-1):\n",
" M[i, i+1] = 1\n",
" M[i+1, i] = 1\n",
" \n",
" pass\n",
"M[1,5] = 1 # 1 and 5 not 2 and 6, as index runs from zero\n",
"M[5,1] = 1\n",
"M"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"(x + 1)*(x**2 - x - 1)*(x**3 - 4*x + 1)\n"
]
}
],
"source": [
"char_eqn = factor(M.det()) \n",
"print(char_eqn)"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"x = -1+0j \n",
"x = -0.618+0j \n",
"x = 1.618+0j \n",
"x = 0.2541-5.294e-23j \n",
"x = 1.861+6.776e-21j \n",
"x = -2.115+2.647e-23j \n"
]
}
],
"source": [
"solns = solve(char_eqn,x)\n",
"\n",
"for i,j in enumerate(solns): # print out each solution in a table, j is sqrt(-1)\n",
" print('x = {:8.4g} '.format( complex(solns[i].evalf() )) )"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The solution contains complex numbers, which is quite a surprise as the energies must always be real; perhaps there is a mistake? However, in this example this is a limitation of the numerical method used to solve the determinant. Notice how small the values of the imaginary part of the complex numbers are (the part containing $j$), they are all $\\lt 10^{-20}$ and so insignificant compared to the real part and can safely be ignored. To convince you of this plot the characteristic equation; the six roots are clearly real numbers, Fig. 75, and are the solutions to $x+1=0,x^2 -x-1=0$ and $x^3 -4x+1=0$.\n",
"\n",
"The MO energies are calculated using $E = \\alpha -x\\beta$. The stabilization energy is the difference the $\\pi$ bond system has compared to the energy of all its isolated p electrons. In this molecule, the there are six p electrons with energy $6\\alpha$, and the stabilization energy is $2(2.115 + 1 + 0.618)\\beta$ because two electrons fill each of the lowest three orbitals and $\\beta$ is a negative number. This stabilization energy is $7.46\\beta$, which is less than the $8\\beta$ calculated for benzene, and the delocalization energy compared to three double bonds is $1.46\\beta$ smaller than the $2\\beta$ of benzene.\n",
"\n",
"![Drawing](matrices-fig75.png)\n",
"\n",
"Figure 75. Roots of the Fulvalene Huckel MO characteristic equation.\n",
"_______\n",
"\n",
"## Q9 answer\n",
"(a) Using the notation $x = (\\alpha - E)/\\beta$ the Huckel determinant for the linear molecule is\n",
"\n",
"$$\\displaystyle \\begin{vmatrix} x & 1 & 0 \\\\1 & x & 1 \\\\0 & 1 & x \\end{vmatrix}=x(x^2-1)-x$$\n",
"\n",
"Solving the characteristic equation $x^3 - 2x = 0$ produces the three roots, $x = 0,\\pm 2$, which means that the energies of the orbitals are, $E=\\alpha$ and $E=\\alpha \\pm 2\\beta$. The integral $\\beta$ is a negative quantity, therefore the total energy for three electrons is $3\\alpha + 2\\sqrt{2}\\beta$ and the stabilization energy is therefore $2\\sqrt{2}\\beta$ compared to that of three non-bonded electrons with a total energy $3\\alpha$.\n",
"\n",
"In its triangular form the Huckel determinant and characteristic equation is\n",
"\n",
"$$\\displaystyle \\begin{vmatrix} x & 1 & 1 \\\\1 & x & 1 \\\\1 & 1 & x \\end{vmatrix}=x^3-3x+2$$\n",
"\n",
"Solving this equation produces $x = 1, 1, -2$, with energies $E = \\alpha + \\beta$, twice and $E = \\alpha - 2\\beta$. The total energy of the three electrons is therefore $3\\alpha + 3\\beta$ making the stabilization energy $3\\beta$. As this is slightly larger than $2\\sqrt{2}\\beta$ the triangular form is expected to be the most stable. In the real molecule, the energy between the linear and triangular form is quite small and the triangular form is distorted by Jahn-Teller interaction and is not an isosceles triangle but an obtuse one. The linear structure was calculated by an _ab initio_ method to be approximately $13$ kJ mol$^{-1}$ higher in energy than the triangular one (Martin & Davidson 1988).\n",
"\n",
"(b) In Na$^+_3$ the linear ion has the same stabilization energy as Na$_3$, which is $2\\sqrt{2}\\beta$, because one electron is in a non-boding orbital. The triangular ion has stabilization $2\\beta$, which is smaller than the linear form and so it is less stable.\n",
"\n",
"(c) If atoms two and three are to be moved apart around a circle so that the $1\\to 2$ and $1\\to 3$ bond lengths are constant, then the Huckel determinant is\n",
"\n",
"$$\\displaystyle \\begin{vmatrix} x & 1 & 1 \\\\1 & x & b_\\theta \\\\1 & b_\\theta & x \\end{vmatrix}=(x-b_\\theta)(x^2-b_\\theta x -2)=0$$\n",
"\n",
"where $ b_\\theta$ is the overlap term as the angle changes. Solving the characteristic equation produces roots $x_1 = b_\\theta$ and $\\displaystyle x_{\\pm}=-\\frac{b_\\theta}{2}\\pm\\frac{\\sqrt{b^2_\\theta +8}}{2}$ wiith energies $E=\\alpha-x\\beta$. \n",
"\n",
"The separation of the two atoms is $(r/d)^2 = 2 - 2\\cos(\\theta)$ by the cosine rule. Substituting $b_\\theta = e^{-\\sqrt{-2-2\\cos(\\theta)}}$ with values $\\alpha = 0 ; \\beta = -1$, gives the energies shown in Figure 76. The exact value of $\\beta$ does not matter as long as it is negative; the energy is then in units of $\\beta$. The lowest energy is $2E_m + E_1$ and this is shown as $E_T$ at the bottom of the figure, and illustrates that the bent form of the molecule has the lowest energy. However the model is unrealistic at a smaller angle that $60^\\text{o}$ as here repulsion must increase the energy as the bond will become shorter than the equilibrium value. The change in energy with angle above $60^\\text{o}$ is small but this may not be realistic in view of the crudeness of the model. All that can be concluded is that the bent form is lower in energy that the straight one. As an exercise, recalculate the energy where the angular dependence is put in the form $b_\\theta = 2 - 2 \\sin(\\theta/2)$, which has a value of $1$ at $60^\\text{o}$.\n",
"\n",
"![Drawing](matrices-fig76.png)\n",
"\n",
"Figure 76. Left. The energy of Na$_3$ as a function of bond angle assuming a simple exponential model of orbital overlap, and that the bond lengths remain constant as the angle increases, (right).\n",
"_______\n",
"\n",
"## Q10 answer\n",
"(a) The first function with $n = 1$ is that of a single carbon atom and one p$\\pi$ electron, therefore, $f_1(x) = x$. Ethylene with one double bond and two carbon atoms has the $2 \\times 2$ determinant,\n",
"\n",
"$$\\displaystyle \\begin{vmatrix} x & 1\\\\ 1& x\\end{vmatrix}=x^2-1$$\n",
"\n",
"and for propene with three carbons\n",
"\n",
"$$\\displaystyle f_3(x)=\\begin{vmatrix} x & 1 & 0 \\\\1 & x & 1 \\\\0 & 1 & x \\end{vmatrix}=x(x^2-1)-x$$\n",
"\n",
"1,3-Butadiene with two bonds and four carbons produces $f_4(x)=x^4-3x^2+1=(x^2-1)^2-x^2$, Using the algorithm in the text (algorithm 1) with $n=5$ $f_5(x)=x^5-4x^3$.\n",
"\n",
"Now there are more than enough terms to try to relate these formulae to one another. If the suggested formula in the question is correct, then starting with $f_1$ and $f_2$ the recursion formula suggests that $f_3(x) = xf_2(x) - f_1(x)$. Using the values above $f_3(x) = x(x^2 - 1) - x$, which is the same equation as the characteristic equation calculated from the Huckel determinant for propene. The formula seems to be correct at least for these two terms. We can calculate another term as a check. For example, $f_5(x) = xf_4(x) - f_3(x)$ which is also correct, and as both examples work, this sufficient to 'prove' the recursion formula $f_n(x) = xf_{n-1}(x) - f_{n-2}(x)$.\n",
"\n",
"The Huckel energies for any linear polyene can now be calculated, provided the polynomial equations can be solved! If they cannot, you can always draw graphs to find the roots of the equations, and use the Newton-Raphson method, not that elegant, but does give good numerical values.\n",
"\n",
"(b) Calculating the recursion in Python/Sympy is very easy also."
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"3 x**3 - 2*x\n",
"4 x**4 - 3*x**2 + 1\n",
"5 x**5 - 4*x**3 + 3*x\n",
"6 x**6 - 5*x**4 + 6*x**2 - 1\n",
"7 x**7 - 6*x**5 + 10*x**3 - 4*x\n",
"8 x**8 - 7*x**6 + 15*x**4 - 10*x**2 + 1\n",
"9 x**9 - 8*x**7 + 21*x**5 - 20*x**3 + 5*x\n"
]
}
],
"source": [
"x, m = symbols('x, m')\n",
"m = 10\n",
"f01 = [0 for i in range(m)] # save values as we go along\n",
"f01[1] = x\n",
"f01[2] = x**2-1\n",
"for i in range(3,m):\n",
" f01[i]= x*f01[i-1] - f01[i-2]\n",
" print(i,expand(f01[i]) )"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Numerically solving the equations rather than factoring as above, and plotting the results, shows how the energy levels change as the number of carbon atoms and hence $\\pi$ electrons increases. As the number of levels increase more energy levels (states), appear to have large positive and negative values and fewer at zero energy. When the number of electrons becomes very large, as in a semiconductor, the levels merge into a band and then relatively more energy levels appear at the band edges than at the band centre. This is the trend that is seen to be starting here. All the levels below zero are filled and as the molecule gets longer the energy gap between HOMO and LUMO orbitals becomes very small, rather line this of a 1D metal. \n",
"\n",
"![Drawing](matrices-fig77.png)\n",
"\n",
"Figure 77. Plot of variable $x$, which is proportional to energy vs. the number of carbon atoms in a linear polyene, $E = \\alpha-\\beta x$"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.6"
}
},
"nbformat": 4,
"nbformat_minor": 2
}