{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 25460 characters]\n",
      "text/latex": [
       "$\\displaystyle \\left[ \\left[\\begin{matrix}\\frac{\\sqrt{2}}{2} & \\frac{\\sqrt{2}}{2}\\\\\\frac{\\sqrt{2}}{2} & - \\frac{\\sqrt{2}}{2}\\end{matrix}\\right], \\  \\left[\\begin{matrix}1 & 0\\\\0 & i\\end{matrix}\\right], \\  \\left[\\begin{matrix}1 & 0\\\\0 & 1\\end{matrix}\\right], \\  \\left[\\begin{matrix}\\frac{\\sqrt{2}}{2} & \\frac{\\sqrt{2}}{2}\\\\\\frac{\\sqrt{2} i}{2} & - \\frac{\\sqrt{2} i}{2}\\end{matrix}\\right], \\  \\left[\\begin{matrix}\\frac{\\sqrt{2}}{2} & \\frac{\\sqrt{2} i}{2}\\\\\\frac{\\sqrt{2}}{2} & - \\frac{\\sqrt{2} i}{2}\\end{matrix}\\right], \\  \\left[\\begin{matrix}1 & 0\\\\0 & -1\\end{matrix}\\right], \\  \\left[\\begin{matrix}\\frac{\\sqrt{2}}{2} & \\frac{\\sqrt{2} i}{2}\\\\\\frac{\\sqrt{2} i}{2} & \\frac{\\sqrt{2}}{2}\\end{matrix}\\right], \\  \\left[\\begin{matrix}\\frac{\\sqrt{2}}{2} & - \\frac{\\sqrt{2}}{2}\\\\\\frac{\\sqrt{2}}{2} & \\frac{\\sqrt{2}}{2}\\end{matrix}\\right], \\  \\left[\\begin{matrix}1 & 0\\\\0 & - i\\end{matrix}\\right], \\  \\left[\\begin{matrix}\\frac{\\sqrt{2}}{2} & - \\frac{\\sqrt{2}}{2}\\\\\\frac{\\sqrt{2} i}{2} & \\frac{\\sqrt{2} i}{2}\\end{matrix}\\right], \\  \\left[\\begin{matrix}\\frac{\\sqrt{2}}{2} & - \\frac{\\sqrt{2} i}{2}\\\\\\frac{\\sqrt{2}}{2} & \\frac{\\sqrt{2} i}{2}\\end{matrix}\\right], \\  \\left[\\begin{matrix}\\frac{\\sqrt{2}}{2} & - \\frac{\\sqrt{2} i}{2}\\\\\\frac{\\sqrt{2} i}{2} & - \\frac{\\sqrt{2}}{2}\\end{matrix}\\right], \\  \\left[\\begin{matrix}\\frac{1}{2} + \\frac{i}{2} & \\frac{1}{2} - \\frac{i}{2}\\\\\\frac{1}{2} - \\frac{i}{2} & \\frac{1}{2} + \\frac{i}{2}\\end{matrix}\\right], \\  \\left[\\begin{matrix}\\frac{\\sqrt{2}}{2} & \\frac{\\sqrt{2}}{2}\\\\- \\frac{\\sqrt{2}}{2} & \\frac{\\sqrt{2}}{2}\\end{matrix}\\right], \\  \\left[\\begin{matrix}0 & 1\\\\1 & 0\\end{matrix}\\right], \\  \\left[\\begin{matrix}\\frac{\\sqrt{2}}{2} & \\frac{\\sqrt{2}}{2}\\\\- \\frac{\\sqrt{2} i}{2} & \\frac{\\sqrt{2} i}{2}\\end{matrix}\\right], \\  \\left[\\begin{matrix}0 & 1\\\\i & 0\\end{matrix}\\right], \\  \\left[\\begin{matrix}\\frac{1}{2} - \\frac{i}{2} & \\frac{1}{2} + \\frac{i}{2}\\\\- \\frac{1}{2} + \\frac{i}{2} & \\frac{1}{2} + \\frac{i}{2}\\end{matrix}\\right], \\  \\left[\\begin{matrix}0 & i\\\\1 & 0\\end{matrix}\\right], \\  \\left[\\begin{matrix}\\frac{\\sqrt{2}}{2} & \\frac{\\sqrt{2} i}{2}\\\\- \\frac{\\sqrt{2} i}{2} & - \\frac{\\sqrt{2}}{2}\\end{matrix}\\right], \\  \\left[\\begin{matrix}\\frac{1}{2} - \\frac{i}{2} & - \\frac{1}{2} + \\frac{i}{2}\\\\- \\frac{1}{2} + \\frac{i}{2} & - \\frac{1}{2} + \\frac{i}{2}\\end{matrix}\\right], \\  \\left[\\begin{matrix}0 & -1\\\\1 & 0\\end{matrix}\\right], \\  \\left[\\begin{matrix}\\frac{\\sqrt{2}}{2} & - \\frac{\\sqrt{2}}{2}\\\\- \\frac{\\sqrt{2} i}{2} & - \\frac{\\sqrt{2} i}{2}\\end{matrix}\\right], \\  \\left[\\begin{matrix}\\frac{1}{2} - \\frac{i}{2} & \\frac{i \\left(-1 + i\\right)}{2}\\\\- \\frac{1}{2} + \\frac{i}{2} & \\frac{i \\left(-1 + i\\right)}{2}\\end{matrix}\\right]\\right]$"
      ],
      "text/plain": [
       "⎡⎡√2   √2 ⎤                  ⎡ √2     √2  ⎤  ⎡√2   √2⋅ⅈ ⎤           ⎡ √2   √2⋅\n",
       "⎢⎢──   ── ⎥                  ⎢ ──     ──  ⎥  ⎢──   ──── ⎥           ⎢ ──   ───\n",
       "⎢⎢2    2  ⎥  ⎡1  0⎤  ⎡1  0⎤  ⎢ 2      2   ⎥  ⎢2     2   ⎥  ⎡1  0 ⎤  ⎢ 2     2 \n",
       "⎢⎢        ⎥, ⎢    ⎥, ⎢    ⎥, ⎢            ⎥, ⎢          ⎥, ⎢     ⎥, ⎢         \n",
       "⎢⎢√2  -√2 ⎥  ⎣0  ⅈ⎦  ⎣0  1⎦  ⎢√2⋅ⅈ  -√2⋅ⅈ ⎥  ⎢√2  -√2⋅ⅈ ⎥  ⎣0  -1⎦  ⎢√2⋅ⅈ   √2\n",
       "⎢⎢──  ────⎥                  ⎢────  ──────⎥  ⎢──  ──────⎥           ⎢────   ──\n",
       "⎣⎣2    2  ⎦                  ⎣ 2      2   ⎦  ⎣2     2   ⎦           ⎣ 2     2 \n",
       "\n",
       "ⅈ⎤  ⎡√2  -√2 ⎤           ⎡ √2   -√2 ⎤  ⎡√2  -√2⋅ⅈ ⎤  ⎡ √2   -√2⋅ⅈ ⎤  ⎡1   ⅈ  1\n",
       "─⎥  ⎢──  ────⎥           ⎢ ──   ────⎥  ⎢──  ──────⎥  ⎢ ──   ──────⎥  ⎢─ + ─  ─\n",
       " ⎥  ⎢2    2  ⎥  ⎡1  0 ⎤  ⎢ 2     2  ⎥  ⎢2     2   ⎥  ⎢ 2      2   ⎥  ⎢2   2  2\n",
       " ⎥, ⎢        ⎥, ⎢     ⎥, ⎢          ⎥, ⎢          ⎥, ⎢            ⎥, ⎢        \n",
       " ⎥  ⎢√2   √2 ⎥  ⎣0  -ⅈ⎦  ⎢√2⋅ⅈ  √2⋅ⅈ⎥  ⎢√2   √2⋅ⅈ ⎥  ⎢√2⋅ⅈ   -√2  ⎥  ⎢1   ⅈ  1\n",
       " ⎥  ⎢──   ── ⎥           ⎢────  ────⎥  ⎢──   ──── ⎥  ⎢────   ──── ⎥  ⎢─ - ─  ─\n",
       " ⎦  ⎣2    2  ⎦           ⎣ 2     2  ⎦  ⎣2     2   ⎦  ⎣ 2      2   ⎦  ⎣2   2  2\n",
       "\n",
       "   ⅈ⎤  ⎡ √2   √2⎤          ⎡  √2     √2 ⎤          ⎡ 1   ⅈ   1   ⅈ⎤          ⎡\n",
       " - ─⎥  ⎢ ──   ──⎥          ⎢  ──     ── ⎥          ⎢ ─ - ─   ─ + ─⎥          ⎢\n",
       "   2⎥  ⎢ 2    2 ⎥  ⎡0  1⎤  ⎢  2      2  ⎥  ⎡0  1⎤  ⎢ 2   2   2   2⎥  ⎡0  ⅈ⎤  ⎢\n",
       "    ⎥, ⎢        ⎥, ⎢    ⎥, ⎢            ⎥, ⎢    ⎥, ⎢              ⎥, ⎢    ⎥, ⎢\n",
       "   ⅈ⎥  ⎢-√2   √2⎥  ⎣1  0⎦  ⎢-√2⋅ⅈ   √2⋅ⅈ⎥  ⎣ⅈ  0⎦  ⎢  1   ⅈ  1   ⅈ⎥  ⎣1  0⎦  ⎢\n",
       " + ─⎥  ⎢────  ──⎥          ⎢──────  ────⎥          ⎢- ─ + ─  ─ + ─⎥          ⎢\n",
       "   2⎦  ⎣ 2    2 ⎦          ⎣  2      2  ⎦          ⎣  2   2  2   2⎦          ⎣\n",
       "\n",
       "  √2    √2⋅ⅈ⎤  ⎡ 1   ⅈ     1   ⅈ⎤           ⎡  √2     -√2  ⎤  ⎡ 1   ⅈ   ⅈ⋅(-1 \n",
       "  ──    ────⎥  ⎢ ─ - ─   - ─ + ─⎥           ⎢  ──     ──── ⎥  ⎢ ─ - ─   ──────\n",
       "  2      2  ⎥  ⎢ 2   2     2   2⎥  ⎡0  -1⎤  ⎢  2       2   ⎥  ⎢ 2   2       2 \n",
       "            ⎥, ⎢                ⎥, ⎢     ⎥, ⎢              ⎥, ⎢               \n",
       "-√2⋅ⅈ   -√2 ⎥  ⎢  1   ⅈ    1   ⅈ⎥  ⎣1  0 ⎦  ⎢-√2⋅ⅈ   -√2⋅ⅈ ⎥  ⎢  1   ⅈ  ⅈ⋅(-1 \n",
       "──────  ────⎥  ⎢- ─ + ─  - ─ + ─⎥           ⎢──────  ──────⎥  ⎢- ─ + ─  ──────\n",
       "  2      2  ⎦  ⎣  2   2    2   2⎦           ⎣  2       2   ⎦  ⎣  2   2      2 \n",
       "\n",
       "+ ⅈ)⎤⎤\n",
       "────⎥⎥\n",
       "    ⎥⎥\n",
       "    ⎥⎥\n",
       "+ ⅈ)⎥⎥\n",
       "────⎥⎥\n",
       "    ⎦⎦"
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import sympy\n",
    "import numpy as np\n",
    "\n",
    "from collections import defaultdict\n",
    "from itertools import product\n",
    "\n",
    "M = sympy.Matrix\n",
    "simplify = sympy.simplify\n",
    "sqrt = sympy.sqrt\n",
    "i = sympy.I\n",
    "i_ = i\n",
    "\n",
    "from sympy.physics.quantum import Dagger\n",
    "from sympy.physics.quantum import tensorproduct\n",
    "\n",
    "sympy.init_printing()\n",
    "H = simplify(M([[1, 1], [1, -1]]) / sqrt(2))\n",
    "S = M([[1, 0], [0, i]])\n",
    "C_L = [H, S]\n",
    "basis_vectors = [M([1, 0]), M([0, 1])]\n",
    "\n",
    "def getitem(m, i, j):\n",
    "    # Note that sympy uses an extremely weird way to store the matrices,\n",
    "    # in particular the internal representation is vastly different from what\n",
    "    # is printed. For instance the H matrix is stored as a Mul object\n",
    "    # (even after using simplify) instead of a matrix. \n",
    "    # Therefore m[i][j] will NOT work. This is a workaround.\n",
    "    return (Dagger(basis_vectors[i]) * m * basis_vectors[j])[0]\n",
    "\n",
    "def is_known(C_L, a):\n",
    "    for c in C_L:\n",
    "        test = c * Dagger(a)\n",
    "        if(simplify(getitem(test, 0, 1)) != 0):\n",
    "            continue\n",
    "        if(simplify(getitem(test, 0, 0) / getitem(test, 1, 1)) == 1):\n",
    "            return True\n",
    "    return False\n",
    "for i in range(5):\n",
    "    for m in (H, S):\n",
    "        for c in C_L:\n",
    "            c = simplify(c*m)\n",
    "            if(is_known(C_L, c)):\n",
    "                continue\n",
    "            C_L.append(c)\n",
    "C_L"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAEYAAAAzCAYAAAAqwX72AAAACXBIWXMAAA7EAAAOxAGVKw4bAAADFElEQVRoBe2bjW0UMRCFbxEFnKCDo4MEKuDogNABSQkRFaDQQaACFDo4qCBKOoAOiNLB5b3gkYaN/87WZM8bj+Ss1+v1zHw3Xq93lGGxWCxRHsh2u7190DjDhmEYvP7T1d8o21E5B5jFUyjwezPynSw2z/CH8g4QBlVO/jXP/y98/s93eHzvu4CZP4EdPXye2x9z8QB9L1AOQXlvnj+w68z58BfHVyhnsO+Pays+RMG4B9M3jH6D8hplVazJ4EbYd4VhPwPEDw7v7L3CkdOjCk50KjEyUI5QOO++U/m+CJw/hi1L2HYPhXbRXhx4fs7zGomCqRn4Ee49go5rj55LtK1d9Hgu5zW1DGYNFznFxyLPP14vlibBZEbDi2IquLFJMLBbnJbo0Awkipa6cdd6q2By/HyZ0ynUp1UwEhU+vySa+F5TLE2CccsynfZNF2mze48pxv04N/6EmpVHlUQMrxdLkxHjvOX2hG/jYzlEw7WKqvH1rPNmwcDxr/DwBkv3e/HULeMfcP5R2kqP0b0SB4Uy/jKct/LrcC/CN85LGPcFxymF0fEJ9siUeoPzt7CL9lVJEgyU8NV7LwW23cKwUwvjmp1KFjD0mB2MpqHqHYyCoasdjKah6h2MgqGrHYymoeodjIKhqx2MpqHqHYyCoasdjKah6sktAftiL2KS1FJ2mFZh/wEU7JQsTILBoGZJLUsasJsb3+JkYXQqYXDTpJYlGG4wuQFGKUoWRsHAcNOkliWY2rFTYNZQ4PvwzO0+hddnKUEwbo6mnJbvq6l+zV0PgoEn4rREh3ZOoogPuFlKDEyOw1VJrRwFU/WJLdcSFT7bJJqqklq+gaXNTeVfON8lKrkKVX/vpQ1BMFzuYBz7+AyTtqqkFgcPCfXjGj92TyKpqWSa1JrE40ylKTCmSa1MGyfpFgWDcDZNak3icabS4DNG3W+W1FI6TKp4RhYnC5Ng3EPQJKllQkMNCtuLk4XRqaR0PLlqBxP4yTuYDiZAINDcIyYARlal1fgzg1uNArfNp3nsNzyT7U7/Ry7AGP8j2+YO/hNP/mmwrOMAAAAASUVORK5CYII=\n",
      "text/latex": [
       "$\\displaystyle \\left[\\begin{matrix}1 & 0\\\\0 & -1\\end{matrix}\\right]$"
      ],
      "text/plain": [
       "⎡1  0 ⎤\n",
       "⎢     ⎥\n",
       "⎣0  -1⎦"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "Z = C_L[5]\n",
    "Z"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 10780 characters]\n",
      "text/latex": [
       "$\\displaystyle \\left[ \\left[\\begin{matrix}0 & 1\\\\1 & 0\\end{matrix}\\right], \\  \\left[\\begin{matrix}1 & 0\\\\0 & -1\\end{matrix}\\right], \\  \\left[\\begin{matrix}1 & 0\\\\0 & -1\\end{matrix}\\right], \\  \\left[\\begin{matrix}0 & 1\\\\1 & 0\\end{matrix}\\right], \\  \\left[\\begin{matrix}0 & i\\\\- i & 0\\end{matrix}\\right], \\  \\left[\\begin{matrix}1 & 0\\\\0 & -1\\end{matrix}\\right], \\  \\left[\\begin{matrix}0 & i\\\\- i & 0\\end{matrix}\\right], \\  \\left[\\begin{matrix}0 & -1\\\\-1 & 0\\end{matrix}\\right], \\  \\left[\\begin{matrix}1 & 0\\\\0 & -1\\end{matrix}\\right], \\  \\left[\\begin{matrix}0 & -1\\\\-1 & 0\\end{matrix}\\right], \\  \\left[\\begin{matrix}0 & - i\\\\i & 0\\end{matrix}\\right], \\  \\left[\\begin{matrix}0 & - i\\\\i & 0\\end{matrix}\\right], \\  \\left[\\begin{matrix}0 & - i\\\\i & 0\\end{matrix}\\right], \\  \\left[\\begin{matrix}0 & 1\\\\1 & 0\\end{matrix}\\right], \\  \\left[\\begin{matrix}-1 & 0\\\\0 & 1\\end{matrix}\\right], \\  \\left[\\begin{matrix}0 & 1\\\\1 & 0\\end{matrix}\\right], \\  \\left[\\begin{matrix}-1 & 0\\\\0 & 1\\end{matrix}\\right], \\  \\left[\\begin{matrix}0 & i\\\\- i & 0\\end{matrix}\\right], \\  \\left[\\begin{matrix}-1 & 0\\\\0 & 1\\end{matrix}\\right], \\  \\left[\\begin{matrix}0 & i\\\\- i & 0\\end{matrix}\\right], \\  \\left[\\begin{matrix}0 & -1\\\\-1 & 0\\end{matrix}\\right], \\  \\left[\\begin{matrix}-1 & 0\\\\0 & 1\\end{matrix}\\right], \\  \\left[\\begin{matrix}0 & -1\\\\-1 & 0\\end{matrix}\\right], \\  \\left[\\begin{matrix}0 & - i\\\\i & 0\\end{matrix}\\right]\\right]$"
      ],
      "text/plain": [
       "⎡⎡0  1⎤  ⎡1  0 ⎤  ⎡1  0 ⎤  ⎡0  1⎤  ⎡0   ⅈ⎤  ⎡1  0 ⎤  ⎡0   ⅈ⎤  ⎡0   -1⎤  ⎡1  0 \n",
       "⎢⎢    ⎥, ⎢     ⎥, ⎢     ⎥, ⎢    ⎥, ⎢     ⎥, ⎢     ⎥, ⎢     ⎥, ⎢      ⎥, ⎢     \n",
       "⎣⎣1  0⎦  ⎣0  -1⎦  ⎣0  -1⎦  ⎣1  0⎦  ⎣-ⅈ  0⎦  ⎣0  -1⎦  ⎣-ⅈ  0⎦  ⎣-1  0 ⎦  ⎣0  -1\n",
       "\n",
       "⎤  ⎡0   -1⎤  ⎡0  -ⅈ⎤  ⎡0  -ⅈ⎤  ⎡0  -ⅈ⎤  ⎡0  1⎤  ⎡-1  0⎤  ⎡0  1⎤  ⎡-1  0⎤  ⎡0  \n",
       "⎥, ⎢      ⎥, ⎢     ⎥, ⎢     ⎥, ⎢     ⎥, ⎢    ⎥, ⎢     ⎥, ⎢    ⎥, ⎢     ⎥, ⎢   \n",
       "⎦  ⎣-1  0 ⎦  ⎣ⅈ  0 ⎦  ⎣ⅈ  0 ⎦  ⎣ⅈ  0 ⎦  ⎣1  0⎦  ⎣0   1⎦  ⎣1  0⎦  ⎣0   1⎦  ⎣-ⅈ \n",
       "\n",
       " ⅈ⎤  ⎡-1  0⎤  ⎡0   ⅈ⎤  ⎡0   -1⎤  ⎡-1  0⎤  ⎡0   -1⎤  ⎡0  -ⅈ⎤⎤\n",
       "  ⎥, ⎢     ⎥, ⎢     ⎥, ⎢      ⎥, ⎢     ⎥, ⎢      ⎥, ⎢     ⎥⎥\n",
       " 0⎦  ⎣0   1⎦  ⎣-ⅈ  0⎦  ⎣-1  0 ⎦  ⎣0   1⎦  ⎣-1  0 ⎦  ⎣ⅈ  0 ⎦⎦"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "resulting_matrices = [simplify(Dagger(C)*Z*C) for C in C_L]\n",
    "resulting_matrices"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAALYAAAAzCAYAAAA6jfJvAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAILUlEQVR4Ae2djVHcOBTHIUMBDOkAOiBHBYEOLrkKQjq4DBVkSAfcVXBHOoBUwIUOo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2yKcaNPaKaHac3Zbtaj+4MnPFZOtvmMaK+SpoIzvRgv3lwqDFuWzpOHtTMomX2SPpu6WY97WKVf6s1nOtnAFHDWw267rBah2V5NehYMsbHfJwn8XLu21qlouZ5Ajc17DrlpDd55lM161gKrQyPdl6E2n+kgTVFlbJzZt6ayL2DFsHn6ZIgYNzFclE1uRHO0HsA/nFH0KG7hBA6kV5R1LrFUGRNn2Suh86FyBZMiFCkpiSHwbxVsVFu6lA8zApNDwLx1ZfZlwbD19BGnMP2H184pIzBZBLy3xmN/qAu5YNi+AhUX/hNTvXE+zwiMjADjN/5zwsJ4MGjYqojH5n/R0DCnjMDkEJC3xjZvZavuhUxdwKBhU0kNWLH2KAIMJnPKCEwGAdkkc9b8S47GiYnKrEhdchqKyI1y8P9Vl+ofqk5lsKm2C91Dqf5kDutyS7CKHiMIOlss18FqVfxVn5dTjP/etvKTAeKdW7MIsLDkNFRP5Ww//FLLV6G6UyyT3OhWl/9mDFklx6yxXAezVfBXXZwO37HyfWmrzf4Pa6TvwXQmOPQAAAAASUVORK5CYII=\n",
      "text/latex": [
       "$\\displaystyle \\left( \\left[\\begin{matrix}0 & 1\\\\1 & 0\\end{matrix}\\right], \\  \\left[\\begin{matrix}0 & - i\\\\i & 0\\end{matrix}\\right]\\right)$"
      ],
      "text/plain": [
       "⎛⎡0  1⎤  ⎡0  -ⅈ⎤⎞\n",
       "⎜⎢    ⎥, ⎢     ⎥⎟\n",
       "⎝⎣1  0⎦  ⎣ⅈ  0 ⎦⎠"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "X = C_L[14]\n",
    "Y = i_ * C_L[21]\n",
    "X, Y"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "matrices = [Z, Y, X, -Z, -Y, -X]\n",
    "\n",
    "def get_matrix_index(m):\n",
    "    for i,p in enumerate(matrices):\n",
    "        if(simplify(m - p) == M([[0, 0], [0, 0]])):\n",
    "            return i\n",
    "    raise ValueError()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAnQAAAAVCAYAAADPXnMZAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAJP0lEQVR4Ae1dgVXkNhQE3hVALh2QDuDogOsAkgpy10F4qSDvrgOuhJAOuFRwgQ6gAzg6IDNG8sleeddr6c/u+n29JyzLskYz+v4rS7bZ39vb+wPxIyLDxcvLy91r0v+6Aq6AK+AKuAKugCvgCmyjAvv7+53x2wEa+TPiRwzkfvHB3DZ2mbfJSgFcDMf9upF3iHjUz9+V/Tly2hXtvZ2ugCvQVWCO/mibOGHM9pljN6j+D+LbN135f+yFH7XLkPMO2yfES4tBH7A+BZxHbNm4T8B5CHlVNwospXZ9cYDNQQoH6HHWtV9k8r5Cu1zjDDn9i7oPgRlnpZlmOHnd1P0r0k/KiQqF/rlG8gR291xXtR+1qXCIqMACBm8czH1swIn+gDZOXPrYr9hWDXPk1Bco2EZ1H6vsJxUn4Mj8kVA/GafYT8HmRvlYDqbOcHHvxYh9XvDXcZ9bBJZjolM2LTMljfpuEc/juUjT4dwjHsW8WlvUaY7FdiNKtMvpAmxq18HPlVs3D3WaazfUJkNO1IqRds0tbfxwqB0l+ahXol/gYc6JOiHSwVwhkhs1rK4d60Q0x2HfirEkfiJwukptF3kfEEm49bvp8alp1Dc7TjktwJPXV1Ufi/po55J+UnEiDgK1UvkjiX5iTqN8H9rUjOOwfU2knYw8VrLgnJH3nTEtW5JGXXQs9/06kMfG3fTzS/ZVWMCRaJfTAthcT7dwNrJ+6vOy4kQchKpOud/2uA8cmX4qTpFb0JF2R0EXfEZarjSN+iU4Ck7sp5xeyKvtY6Nm7eCNuIjsr9vSPknPR32z45TyS+zCwsfK+knFKeil8rEy/WjnfQ2t94EZ+WV9LI43A7oDJHLhDJnfMc3HCz8NnKKv+YzRBeqLy10p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kisq+tCfZrTYV+Gw7SosFY5zKl4KkNi495P3U853qvyECsft3O28b+due8U20Yzj4ksRfAaO4QJCd15GeM32v66AK+AKuAKugCvgCrgC26IAZgH5ZQZ+J5gv9V38D15jymskDsR+AAAAAElFTkSuQmCC\n",
      "text/latex": [
       "$\\displaystyle \\left[ 2, \\  0, \\  0, \\  2, \\  4, \\  0, \\  4, \\  5, \\  0, \\  5, \\  1, \\  1, \\  1, \\  2, \\  3, \\  2, \\  3, \\  4, \\  3, \\  4, \\  5, \\  3, \\  5, \\  1\\right]$"
      ],
      "text/plain": [
       "[2, 0, 0, 2, 4, 0, 4, 5, 0, 5, 1, 1, 1, 2, 3, 2, 3, 4, 3, 4, 5, 3, 5, 1]"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "resulting_indices = [get_matrix_index(m) for m in resulting_matrices]\n",
    "resulting_indices"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "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.7.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
