{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "bf9e8c58-6b79-4c3a-a5d2-4736640d497f",
   "metadata": {},
   "source": [
    "## Εξερεύνηση χώρου καταστάσεων\n",
    "Ολοκλήρωση της λύσης του προβλήματος με τον λύκο, την κατσίκα και το λάχανο.  \n",
    "Εδώ είχαμε μείνει την προηγούμενη φορά:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "97173a2b-2b6e-4b88-b280-9528b4451a34",
   "metadata": {},
   "outputs": [],
   "source": [
    "class state:\n",
    "    def __init__(self, left, right):\n",
    "        self.left = frozenset(left)\n",
    "        self.right = frozenset(right)\n",
    "    def __str__(self):\n",
    "        return str(self.left) + \" | \" + str(self.right)\n",
    "    def success(self):\n",
    "        return not self.left\n",
    "    def safe(self):\n",
    "        def tragic(bank):\n",
    "            return \"man\" not in bank and (\n",
    "                (\"wolf\" in bank and \"goat\" in bank) or\n",
    "                (\"goat\" in bank and \"cabbage\" in bank)\n",
    "            )\n",
    "        return not tragic(self.left) and not tragic(self.right)\n",
    "    def accessible(self):\n",
    "        if \"man\" in self.left:\n",
    "            for x in self.left:\n",
    "                moving = frozenset([\"man\", x])\n",
    "                yield state(self.left - moving, self.right | moving)\n",
    "        else:\n",
    "            for x in self.right:\n",
    "                moving = frozenset([\"man\", x])\n",
    "                yield state(self.left | moving, self.right - moving)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "de9633e1-faa4-4b02-8b95-c83391f4f1a4",
   "metadata": {},
   "source": [
    "Breadth First Search (BFS): ένας συστηματικός τρόπος εξερεύνησης όλων των καταστάσεων."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "32f59f8e-4d5d-4ffe-a1bc-68daee301f20",
   "metadata": {},
   "outputs": [],
   "source": [
    "from collections import deque\n",
    "\n",
    "def solve():\n",
    "    init = state(['man', 'wolf', 'goat', 'cabbage'], [])\n",
    "    Q = deque()\n",
    "    Q.append(init)\n",
    "    while Q:\n",
    "        s = Q.popleft()\n",
    "        for t in s.accessible():\n",
    "            if t.success():\n",
    "                return t\n",
    "            elif t.safe():\n",
    "                Q.append(t)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "845f778f-efdd-41f5-bdbe-e452659f455f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<__main__.state at 0x199d71514f0>"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "solve()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "979cd072-de9d-4e5f-a1c1-3d1f46aa3c0b",
   "metadata": {},
   "outputs": [],
   "source": [
    "final = solve()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "83b07de6-85d4-4285-af89-5018272731c9",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "\"frozenset() | frozenset({'goat', 'man', 'cabbage', 'wolf'})\""
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "str(final)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "bcdf011f-fbc4-484d-a410-a8edadce11af",
   "metadata": {},
   "source": [
    "Λείπουν:\n",
    "- Πώς να διαβάσουμε τη λύση (δηλαδή η ανακατασκευή των κινήσεων που οδήγησε εκεί).\n",
    "- Πώς να αποφεύγουμε να πηγαίνουμε ξανά και ξανά στις ίδιες καταστάσεις."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "cf466d05-d8d7-4119-a9c3-b40e8446aeba",
   "metadata": {},
   "outputs": [],
   "source": [
    "class state:\n",
    "    def __init__(self, left, right):\n",
    "        self.left = frozenset(left)\n",
    "        self.right = frozenset(right)\n",
    "    def __str__(self):\n",
    "        return \" \".join(self.left) + \" | \" + \" \".join(self.right)\n",
    "    def success(self):\n",
    "        return not self.left\n",
    "    def safe(self):\n",
    "        def tragic(bank):\n",
    "            return \"man\" not in bank and (\n",
    "                (\"wolf\" in bank and \"goat\" in bank) or\n",
    "                (\"goat\" in bank and \"cabbage\" in bank)\n",
    "            )\n",
    "        return not tragic(self.left) and not tragic(self.right)\n",
    "    def accessible(self):\n",
    "        if \"man\" in self.left:\n",
    "            for x in self.left:\n",
    "                moving = frozenset([\"man\", x])\n",
    "                yield state(self.left - moving, self.right | moving)\n",
    "        else:\n",
    "            for x in self.right:\n",
    "                moving = frozenset([\"man\", x])\n",
    "                yield state(self.left | moving, self.right - moving)\n",
    "    def __eq__(self, other):\n",
    "        return isinstance(other, state) and self.left == other.left\n",
    "    def __hash__(self):\n",
    "        return hash(self.left)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "b284d3d1-3f11-402d-a6ae-8cf091f50e24",
   "metadata": {},
   "outputs": [],
   "source": [
    "from collections import deque"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "18a1c7f8-969e-468e-ac70-f8be78bb6960",
   "metadata": {},
   "outputs": [],
   "source": [
    "def solve():\n",
    "    init = state([\"man\", \"wolf\", \"goat\", \"cabbage\"], [])\n",
    "    Q = deque()\n",
    "    seen = {}\n",
    "    Q.append(init)\n",
    "    seen[init] = None\n",
    "    while Q:\n",
    "        s = Q.popleft()\n",
    "        for t in s.accessible():\n",
    "            if t.success():\n",
    "                answer = [t]\n",
    "                while s is not None:\n",
    "                    answer.append(s)\n",
    "                    s = seen[s]\n",
    "                return reversed(answer)\n",
    "            elif t.safe() and t not in seen:\n",
    "                Q.append(t)\n",
    "                seen[t] = s"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "a199c56f-8184-422b-aee8-a6114c5b02f2",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "goat man cabbage wolf | \n",
      "cabbage wolf | goat man\n",
      "man cabbage wolf | goat\n",
      "wolf | goat man cabbage\n",
      "goat man wolf | cabbage\n",
      "goat | man cabbage wolf\n",
      "goat man | cabbage wolf\n",
      " | goat man cabbage wolf\n"
     ]
    }
   ],
   "source": [
    "for s in solve():\n",
    "    print(s)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "8c74fb2e-994a-4912-99a8-82b3c4b9bc05",
   "metadata": {},
   "source": [
    "## Numpy"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "a46c965f-8c93-4f04-9b50-810a15bad3e3",
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "8e13f381-8afa-4ace-96aa-3e56d5bb221c",
   "metadata": {},
   "outputs": [],
   "source": [
    "a = np.array([1, 2, 3])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "a48a7774-27de-48e7-87fe-974d232a948d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([1, 2, 3])"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "ce5d440e-40bc-4efc-914a-6edf3cab4669",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "numpy.ndarray"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "type(a)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "4a88057b-5000-4d32-ab4b-97dbb5dd99a2",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a.ndim"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "7c49c869-88c6-4ed2-99f3-ef56b0455ea3",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(3,)"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "25d9a099-c508-43ae-8460-f12da1fcea1c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "np.int64(2)"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a[1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "4a4158d0-e61a-4541-b8fa-7975dbc52fc3",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "np.int64(84)"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a[1]*42"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "c1bf8826-c2d7-4c94-96fd-fb662057589b",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[1 2 3]\n"
     ]
    }
   ],
   "source": [
    "print(a)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "dd449467-868b-4619-a4e6-92f43144719a",
   "metadata": {},
   "outputs": [],
   "source": [
    "b = np.array([[1, 2, 3], [4, 5, 6]])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "4bf7b090-d6f8-45be-abf9-98f0832b7b0f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[1, 2, 3],\n",
       "       [4, 5, 6]])"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "b"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "f12eefd9-d3f6-433c-b1c0-e70f221184a2",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[1 2 3]\n",
      " [4 5 6]]\n"
     ]
    }
   ],
   "source": [
    "print(b)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "17f31fa3-9768-4f4b-b74c-9758d232efc6",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "np.int64(6)"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "b[1][2]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "id": "3659e628-d062-4912-b24e-4a09a6b86f11",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(2, 3)"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "b.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "id": "5bd79689-6350-442f-b6c9-3a21be5d260b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "numpy.ndarray"
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "type(b)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "id": "d125c4fb-0355-4432-871f-3cffd8b2f912",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[1, 2, 3]])"
      ]
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.array([[1, 2, 3]])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "id": "288b7ed3-2cb4-49f6-add4-325232f0ee18",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[1],\n",
       "       [2],\n",
       "       [3]])"
      ]
     },
     "execution_count": 26,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.array([[1],[2],[3]])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "id": "0e5cc067-a582-4f75-ab30-f0971d7de1ab",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[1 2 3]\n",
      "[4 5 6]\n"
     ]
    }
   ],
   "source": [
    "for x in b:\n",
    "    print(x)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "id": "198aaf75-f88c-4bb4-bf1e-f9f30c3b475a",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1\n",
      "2\n",
      "3\n",
      "4\n",
      "5\n",
      "6\n"
     ]
    }
   ],
   "source": [
    "for x in b:\n",
    "    for y in x:\n",
    "        print(y)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "id": "4847ab66-4535-4da5-8b8f-1e697c4d5d67",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<numpy.flatiter at 0x199d5c54470>"
      ]
     },
     "execution_count": 29,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "b.flat"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "id": "0396297e-0bd2-48e8-835f-d8c1ce7831b6",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1\n",
      "2\n",
      "3\n",
      "4\n",
      "5\n",
      "6\n"
     ]
    }
   ],
   "source": [
    "for x in b.flat:\n",
    "    print(x)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "id": "34619f84-ec22-4df7-8386-b8bfd28ca9d4",
   "metadata": {},
   "outputs": [],
   "source": [
    "c = np.array([3.14, 42.17])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "id": "77fd2638-6d0f-4d3c-983d-4ce73ddc6e8a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "np.float64(42.17)"
      ]
     },
     "execution_count": 32,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "c[1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "id": "d2a70c3b-f57a-4c62-a8a1-3fc9cafb5357",
   "metadata": {},
   "outputs": [],
   "source": [
    "c = np.array([3.14, 42, 17])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "id": "db90f225-9dd2-40f0-a550-327bea8075c6",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "np.float64(3.14)"
      ]
     },
     "execution_count": 34,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "c[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "id": "035e102b-7e1f-400e-a6d6-e931973c9ede",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "np.float64(42.0)"
      ]
     },
     "execution_count": 35,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "c[1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "id": "01a40d44-709c-4c54-af30-4b9e54e1f375",
   "metadata": {},
   "outputs": [],
   "source": [
    "c[0] = 3"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "id": "492974d9-83ca-493a-b4d0-e9f21cebccf0",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([ 3., 42., 17.])"
      ]
     },
     "execution_count": 37,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "c"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "id": "7371efd8-a483-4e58-85cc-f8c44cae0bb3",
   "metadata": {},
   "outputs": [],
   "source": [
    "d = np.array([1, 2, 3])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "id": "678ecf32-8abf-473c-9658-041380041474",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "np.int64(1)"
      ]
     },
     "execution_count": 39,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "d[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "id": "c848db9d-d83e-4090-bc1a-f1d127acd444",
   "metadata": {},
   "outputs": [],
   "source": [
    "d[0] = 3.14"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "id": "fc0edf52-fe5a-4223-913d-951e0d8a8062",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([3, 2, 3])"
      ]
     },
     "execution_count": 41,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "d"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "id": "12a56b3b-3dd3-49a9-a779-3a6426c74ff7",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "dtype('int64')"
      ]
     },
     "execution_count": 42,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "d.dtype"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "id": "502bf92b-b941-44b4-82df-3136d18c7a68",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "dtype('int64')"
      ]
     },
     "execution_count": 43,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "b.dtype"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "id": "c9c6316d-436b-4f45-9592-db3fb642b4ec",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "dtype('float64')"
      ]
     },
     "execution_count": 44,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "c.dtype"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "id": "db7b8e6d-b3cb-4808-8b08-3d987bd9dc6e",
   "metadata": {},
   "outputs": [],
   "source": [
    "e = np.array([1, 2, 3], dtype=np.float64)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "id": "fcacc42e-4dff-441f-88be-51dc007cb974",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([1., 2., 3.])"
      ]
     },
     "execution_count": 46,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "e"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "id": "dd2cb1fd-4213-4b97-bc9b-2880fc11bf5b",
   "metadata": {},
   "outputs": [
    {
     "ename": "OverflowError",
     "evalue": "int too big to convert",
     "output_type": "error",
     "traceback": [
      "\u001b[31m---------------------------------------------------------------------------\u001b[39m",
      "\u001b[31mOverflowError\u001b[39m                             Traceback (most recent call last)",
      "\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[47]\u001b[39m\u001b[32m, line 1\u001b[39m\n\u001b[32m----> \u001b[39m\u001b[32m1\u001b[39m \u001b[43mb\u001b[49m\u001b[43m[\u001b[49m\u001b[32;43m0\u001b[39;49m\u001b[43m]\u001b[49m = \u001b[32m2\u001b[39m**\u001b[32m100\u001b[39m\n",
      "\u001b[31mOverflowError\u001b[39m: int too big to convert"
     ]
    }
   ],
   "source": [
    "b[0] = 2**100"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "id": "d5e08e9e-4233-4027-b5d2-10983f8efc5e",
   "metadata": {},
   "outputs": [],
   "source": [
    "e[0] = 2**100"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "id": "08102742-868d-4d9c-a4da-bc73656079b7",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([1.2676506e+30, 2.0000000e+00, 3.0000000e+00])"
      ]
     },
     "execution_count": 49,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "e"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 50,
   "id": "fcb8a933-1ace-4b32-869d-2deff84bbc30",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'1267650600228229401496703205376.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'"
      ]
     },
     "execution_count": 50,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "f\"{e[0]:.100f}\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 51,
   "id": "fe263d08-2dcf-42a7-80e0-4d2a76d6e643",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1267650600228229401496703205376"
      ]
     },
     "execution_count": 51,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "2**100"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 52,
   "id": "425adc9d-3336-4a5e-be51-d1fae373e5c8",
   "metadata": {},
   "outputs": [],
   "source": [
    "e[1] = 3**100"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 53,
   "id": "e32f87a6-dfda-4d9b-a0c4-7abf36458156",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'515377520732011324194596268868618440852459487232.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'"
      ]
     },
     "execution_count": 53,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "f\"{e[1]:.100f}\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 54,
   "id": "30a7a3fd-6c37-40a4-9b90-5f95e5da2703",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "515377520732011331036461129765621272702107522001"
      ]
     },
     "execution_count": 54,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "3**100"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 55,
   "id": "3da7f863-d248-480e-bce3-99cfd29a909f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([0., 0., 0.])"
      ]
     },
     "execution_count": 55,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.zeros(3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 56,
   "id": "76cc9140-3aa9-47a4-bfba-3a885f266b92",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[0., 0., 0., 0.],\n",
       "       [0., 0., 0., 0.],\n",
       "       [0., 0., 0., 0.]])"
      ]
     },
     "execution_count": 56,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.zeros((3, 4))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 57,
   "id": "6a783d50-10b0-4507-9fcb-ff4452b9be0c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[42, 42, 42],\n",
       "       [42, 42, 42],\n",
       "       [42, 42, 42]])"
      ]
     },
     "execution_count": 57,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.full((3, 3), 42)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 58,
   "id": "6e31b9de-9480-4c1c-985c-e642137e4f8f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])"
      ]
     },
     "execution_count": 58,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.arange(10)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 59,
   "id": "3864d154-0a2e-447d-b5b8-f554ee8aed66",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([4, 6, 8])"
      ]
     },
     "execution_count": 59,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.arange(4, 10, 2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 60,
   "id": "3a37e4cf-ace0-4a12-9bf5-d212d20fb8f6",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[0.24396523, 0.61581355, 0.99021505],\n",
       "       [0.75936435, 0.21184571, 0.98887409],\n",
       "       [0.54787589, 0.52445312, 0.05061276]])"
      ]
     },
     "execution_count": 60,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.random.random((3, 3))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 61,
   "id": "680458a8-6fbf-42af-a07d-2e0c2464714c",
   "metadata": {},
   "outputs": [],
   "source": [
    "i = np.eye(3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 62,
   "id": "ba376f8a-2149-4a7a-9682-b4f8379326a8",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[1., 0., 0.],\n",
       "       [0., 1., 0.],\n",
       "       [0., 0., 1.]])"
      ]
     },
     "execution_count": 62,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "i"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 63,
   "id": "3e2ce8ac-c850-4b45-a0c7-1332b80702d5",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[1., 0., 0.],\n",
       "       [0., 1., 0.]])"
      ]
     },
     "execution_count": 63,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "i[:2]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 64,
   "id": "2ea5506c-b6b5-4945-ad51-d72fb28be293",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[0., 1., 0.],\n",
       "       [0., 0., 1.]])"
      ]
     },
     "execution_count": 64,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "i[1:]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 65,
   "id": "bdaee999-c018-41a4-9581-4ef43fdbe26e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[0., 0.],\n",
       "       [1., 0.]])"
      ]
     },
     "execution_count": 65,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "i[:2, 1:3]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 66,
   "id": "dac9ad4a-69ec-47fc-b139-34728f828c2f",
   "metadata": {},
   "outputs": [],
   "source": [
    "j = i[:2, 1:3]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 67,
   "id": "46a176b7-b0ff-4092-b5e5-139657611859",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[0., 0.],\n",
       "       [1., 0.]])"
      ]
     },
     "execution_count": 67,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "j"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 68,
   "id": "9bf74c50-8a0c-458c-b308-4cae648841f5",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[1., 0., 0.],\n",
       "       [0., 1., 0.],\n",
       "       [0., 0., 1.]])"
      ]
     },
     "execution_count": 68,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "i"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 69,
   "id": "91c21791-54a9-4ee8-aa78-42a53c927458",
   "metadata": {},
   "outputs": [],
   "source": [
    "j[0][0] = 42"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 70,
   "id": "f70cd4d5-4a16-45a9-9d0f-2ad8a67fe212",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[42.,  0.],\n",
       "       [ 1.,  0.]])"
      ]
     },
     "execution_count": 70,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "j"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 71,
   "id": "7fa302a6-8df2-4c11-97bc-a2f4891b1b14",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[ 1., 42.,  0.],\n",
       "       [ 0.,  1.,  0.],\n",
       "       [ 0.,  0.,  1.]])"
      ]
     },
     "execution_count": 71,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "i"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 72,
   "id": "5baa975e-0b6e-41f7-a0c6-e8aeaf37b994",
   "metadata": {},
   "outputs": [],
   "source": [
    "j = i[:2, 1:3].copy()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 73,
   "id": "d057fc1c-e81e-40d7-b127-d8bf49eb277c",
   "metadata": {},
   "outputs": [],
   "source": [
    "j[0][0] = 17"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 74,
   "id": "f193ed4b-9520-4699-8c59-fd9b2defad00",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[ 1., 42.,  0.],\n",
       "       [ 0.,  1.,  0.],\n",
       "       [ 0.,  0.,  1.]])"
      ]
     },
     "execution_count": 74,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "i"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 75,
   "id": "d9cbb703-824b-48f9-8708-1cb9670cdc2e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[17.,  0.],\n",
       "       [ 1.,  0.]])"
      ]
     },
     "execution_count": 75,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "j"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 76,
   "id": "a22d5d34-0cba-42ae-96b3-620571d3882d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[ 1., 42.,  0.],\n",
       "       [ 0.,  1.,  0.],\n",
       "       [ 0.,  0.,  1.]])"
      ]
     },
     "execution_count": 76,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "i"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 77,
   "id": "9c3e2c3e-a25e-4390-8e3d-40e2ce16930e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[ 2., 43.,  1.],\n",
       "       [ 1.,  2.,  1.],\n",
       "       [ 1.,  1.,  2.]])"
      ]
     },
     "execution_count": 77,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "i+1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 78,
   "id": "e1f5aefe-5650-4615-8c86-cb6e53c52dff",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[  3., 126.,   0.],\n",
       "       [  0.,   3.,   0.],\n",
       "       [  0.,   0.,   3.]])"
      ]
     },
     "execution_count": 78,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "i*3"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 79,
   "id": "8ae4fd21-a8e3-41fc-930b-17e0078307aa",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[  3., 126.,   0.],\n",
       "       [  0.,   3.,   0.],\n",
       "       [  0.,   0.,   3.]])"
      ]
     },
     "execution_count": 79,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "3*i"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 80,
   "id": "9342c198-e8dd-4ea3-9da7-7961cb301e8c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[1.000e+00, 1.764e+03, 0.000e+00],\n",
       "       [0.000e+00, 1.000e+00, 0.000e+00],\n",
       "       [0.000e+00, 0.000e+00, 1.000e+00]])"
      ]
     },
     "execution_count": 80,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "i*i"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 81,
   "id": "83cb08fa-0c57-45c8-b70d-a1f1d14730f0",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[False,  True, False],\n",
       "       [False, False, False],\n",
       "       [False, False, False]])"
      ]
     },
     "execution_count": 81,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "i > 1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 82,
   "id": "20075b8a-c67f-4f95-9bcd-86e5e989dc73",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[ True,  True,  True],\n",
       "       [ True,  True,  True],\n",
       "       [ True,  True,  True]])"
      ]
     },
     "execution_count": 82,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "i == i"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 83,
   "id": "4decb7c5-bbe0-46ab-9f06-2860889e14a8",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[False, False, False],\n",
       "       [False, False, False],\n",
       "       [False, False, False]])"
      ]
     },
     "execution_count": 83,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "i == i+1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 84,
   "id": "3aed57e0-2023-4648-8ce1-b8021534f8c2",
   "metadata": {},
   "outputs": [
    {
     "ename": "ValueError",
     "evalue": "The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()",
     "output_type": "error",
     "traceback": [
      "\u001b[31m---------------------------------------------------------------------------\u001b[39m",
      "\u001b[31mValueError\u001b[39m                                Traceback (most recent call last)",
      "\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[84]\u001b[39m\u001b[32m, line 1\u001b[39m\n\u001b[32m----> \u001b[39m\u001b[32m1\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m i == i+\u001b[32m1\u001b[39m: \u001b[38;5;28mprint\u001b[39m(\u001b[33m\"\u001b[39m\u001b[33mNO WAY!\u001b[39m\u001b[33m\"\u001b[39m)\n",
      "\u001b[31mValueError\u001b[39m: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()"
     ]
    }
   ],
   "source": [
    "if i == i+1: print(\"NO WAY!\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 85,
   "id": "5a26b1fe-323c-4e98-a14f-73b421b86a75",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[ 1., 42.,  0.],\n",
       "       [ 0.,  1.,  0.],\n",
       "       [ 0.,  0.,  1.]])"
      ]
     },
     "execution_count": 85,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "i"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 86,
   "id": "07742cc8-bc6b-4383-8260-44dc7c1d4207",
   "metadata": {},
   "outputs": [],
   "source": [
    "i[0][1] = 0"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 87,
   "id": "c9cfe75a-a44e-4b07-a994-8e04d0e5fa31",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[1., 0., 0.],\n",
       "       [0., 1., 0.],\n",
       "       [0., 0., 1.]])"
      ]
     },
     "execution_count": 87,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "i"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 88,
   "id": "a31ce930-51d8-4c4a-bb43-68f30a693762",
   "metadata": {},
   "outputs": [],
   "source": [
    "i[2:, 1:3] = 42"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 89,
   "id": "a68efaae-361b-48c8-bada-378a3e1f676d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[ 1.,  0.,  0.],\n",
       "       [ 0.,  1.,  0.],\n",
       "       [ 0., 42., 42.]])"
      ]
     },
     "execution_count": 89,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "i"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 90,
   "id": "036ef712-1641-486f-9479-cae847e18f0b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([42., 42.])"
      ]
     },
     "execution_count": 90,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "i[i==42]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 91,
   "id": "5957409f-678e-4745-a103-2f986effc200",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([0., 0., 0., 0., 0.])"
      ]
     },
     "execution_count": 91,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "i[i==0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 92,
   "id": "fab357b0-89a5-45ec-a9c0-0ad54c175913",
   "metadata": {},
   "outputs": [],
   "source": [
    "i[i==0] = 42"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 93,
   "id": "c28aad1a-eab5-4401-95b2-685c7323e91e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[ 1., 42., 42.],\n",
       "       [42.,  1., 42.],\n",
       "       [42., 42., 42.]])"
      ]
     },
     "execution_count": 93,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "i"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 94,
   "id": "87d9ef7a-cc3c-4b84-8159-62c0a564cbe5",
   "metadata": {},
   "outputs": [],
   "source": [
    "i[1][1] = 0"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 95,
   "id": "912d7d18-2332-4b9f-b2f3-3c393997cc37",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[ 1., 42., 42.],\n",
       "       [42.,  0., 42.],\n",
       "       [42., 42., 42.]])"
      ]
     },
     "execution_count": 95,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "i"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 96,
   "id": "6c4929bd-9f2b-40ca-ba12-43e504a0ae3b",
   "metadata": {},
   "outputs": [],
   "source": [
    "i[i != 0] = -i[i != 0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 97,
   "id": "8127155a-9292-494c-afe0-b68fcfa2177d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[ -1., -42., -42.],\n",
       "       [-42.,   0., -42.],\n",
       "       [-42., -42., -42.]])"
      ]
     },
     "execution_count": 97,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "i"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 98,
   "id": "7c43ad65-26d9-4817-b756-20c1d39ac785",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[ -1., -42., -42.],\n",
       "       [-42.,   0., -42.],\n",
       "       [-42., -42., -42.]])"
      ]
     },
     "execution_count": 98,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.transpose(i)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 99,
   "id": "b9bc97ed-676b-4be7-9711-b910e2bc45e1",
   "metadata": {},
   "outputs": [],
   "source": [
    "i[0][1] = 17"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 100,
   "id": "e8a6abdc-f1a4-48d2-b03f-7f4e144b1b1b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[ -1., -42., -42.],\n",
       "       [ 17.,   0., -42.],\n",
       "       [-42., -42., -42.]])"
      ]
     },
     "execution_count": 100,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.transpose(i)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 101,
   "id": "fdf20c92-4779-4937-97d8-5eec294c34f6",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[ -1.,  17., -42.],\n",
       "       [-42.,   0., -42.],\n",
       "       [-42., -42., -42.]])"
      ]
     },
     "execution_count": 101,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "i"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 102,
   "id": "11840d8d-88cd-452d-823e-0a1c4d4e649f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[ 0.02439024, -0.03426249,  0.00987224],\n",
       "       [-0.        ,  0.02380952, -0.02380952],\n",
       "       [-0.02439024,  0.01045296, -0.00987224]])"
      ]
     },
     "execution_count": 102,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.linalg.inv(i)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 103,
   "id": "6140b1f0-a3f1-4df2-8ed0-3785a6994eec",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[-0.02439024, -0.58246225, -0.41463415],\n",
       "       [ 0.        ,  0.        ,  1.        ],\n",
       "       [ 1.02439024, -0.43902439,  0.41463415]])"
      ]
     },
     "execution_count": 103,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.linalg.inv(i) * i"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 104,
   "id": "a3b8ed9f-6e58-466e-93dc-93933877040d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[ 1.00000000e+00,  1.73472348e-17, -2.04697370e-16],\n",
       "       [-5.55111512e-17,  1.00000000e+00, -5.55111512e-17],\n",
       "       [-1.73472348e-17, -1.73472348e-17,  1.00000000e+00]])"
      ]
     },
     "execution_count": 104,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.linalg.inv(i) @ i"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 105,
   "id": "7f8d2615-0af2-4f35-97c0-2623592e4947",
   "metadata": {},
   "outputs": [],
   "source": [
    "v = np.array([1, 0, 2])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 106,
   "id": "4ee06985-2e0a-46fb-951e-34dc538cd60c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[1, 0, 2, 1, 0, 2],\n",
       "       [1, 0, 2, 1, 0, 2],\n",
       "       [1, 0, 2, 1, 0, 2]])"
      ]
     },
     "execution_count": 106,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.tile(v, (3, 2))"
   ]
  }
 ],
 "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.14.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
