{ "cells": [ { "cell_type": "markdown", "metadata": { "id": "48HONqnFpIvI" }, "source": [ "# Problem 7\n", "Let $A$ be the $20000 \\times 20000$ matrix whose entries are 0 everywhere except for the primes $2,3,5,7,\\cdots,224737$ along the main diagonal and the number 1 in all the positions $ a_{ij} $ with $ |i-j| = 1,2,4,8,\\cdots,16384$. What is the $(1,1)$ entry of $A^{-1}$" ] }, { "cell_type": "markdown", "metadata": { "id": "JiZSIfm1qR-F" }, "source": [ "### Some introductory code " ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 34 }, "executionInfo": { "elapsed": 1558, "status": "ok", "timestamp": 1603893832461, "user": { "displayName": "Husnain Raza", "photoUrl": "", "userId": "16146658556003895350" }, "user_tz": 300 }, "id": "wvpmKjZMqRiB", "outputId": "9ad6fbfd-f2b3-4ad4-eca6-97830b9d01b0" }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "(554466, 3)\n" ] } ], "source": [ "import numpy as np\n", "\n", "def is_prime(N):\n", " return N > 1 and all([N%i != 0 for i in range(2, int(N**0.5+1))])\n", "\n", "primes = [i for i in range(2,250000) if is_prime(i)][:20000]\n", "entries = [(i,i,primes[i]) for i in range(len(primes))]\n", "for diff in [2**j for j in range(15)]:\n", " for i in range(20000):\n", " j1, j2 = i+diff, i-diff\n", " if 0<=j1<20000: entries.append((i,j1,1))\n", " if 0<=j2<20000: entries.append((i,j2,1))\n", "entries = np.array(entries)\n", "print(entries.shape)" ] }, { "cell_type": "markdown", "metadata": { "id": "vsdtHzxT3WQc" }, "source": [ "### Attempt 1: Using standard libraries\n", "\n", "Note that A is very sparse - with only $\\frac{554,466}{20000^2} \\approx 0.14\\% $ of its entries being non-zero\n", "\n", "![Plot of upper left 100x100 quadrant](media/prob7/plot1.png)\n", "![Plot of entire matrix](media/prob7/plot2.png)\n", "\n", "We therefore avoid calculating $A^{-1}$ explicitly (note that this is intractable as matrix inversion has a time complexity of $O(n^3)$) \n", "\n", "Instead, note that if we have $\\hat{v}$ be the first column of $ A^{-1} $, then we get that $ A \\hat{v} = (1,0,\\cdots, 0)^{T}$. We use [BIConjugate Gradient iteration in scipy](https://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.linalg.bicg.html#scipy.sparse.linalg.bicg) to solve this sparse system." ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 229 }, "executionInfo": { "elapsed": 789, "status": "error", "timestamp": 1603893823785, "user": { "displayName": "Husnain Raza", "photoUrl": "", "userId": "16146658556003895350" }, "user_tz": 300 }, "id": "3QZE1MQao2Zz", "outputId": "91fb2579-b63b-4656-d445-18ff6f771c42", "scrolled": true }, "outputs": [ { "data": { "text/plain": [ "0.7250783462684014" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "from scipy.sparse import coo_matrix\n", "from scipy.sparse.linalg import bicg\n", "\n", "row, col, data = entries[:, 0], entries[:, 1], entries[:, 2]\n", "\n", "A = coo_matrix((data, (row, col))).tocsc()\n", "b = np.zeros(A.shape[0])\n", "b[0] = 1\n", "\n", "iterations = 0\n", "curr_xk = None\n", "change_iter = []\n", "def callback(xk):\n", " global iterations, curr_xk\n", " iterations += 1\n", " if curr_xk is not None:\n", " change_iter.append(xk[0] - curr_xk)\n", " curr_xk = xk[0]\n", "x, exit_code = bicg(A,b,tol=1e-50,callback=callback)\n", "x[0]" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "image/png": "iVBORw0KGgoAAAANSUhEUgAAAY8AAAEGCAYAAACdJRn3AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/YYfK9AAAACXBIWXMAAAsTAAALEwEAmpwYAAArm0lEQVR4nO3deXhU5fn/8fedhCTsCARUFhOQpVjcCLiiuIPQWq3FrbVa+rO2WpfaBbdabV1au9r6rfvS1mrRWqWI2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zO42s9nhiQO/BWBmo8LrQfyV0AA7zOy58KSTi6onnjSzu4C24es9ES6rruVY+NoLw+tBnBdx7dfN7BkzW2JmT1SvEWFmd5nZu+FYfpn2uyOtRl7QAYhkmImE1rYYBxBOAlvdfbiZFQBvmtm/wueOAD7voSm6Ab7h7pvMrC0w28z+7u4TzexKdz88ymedQ2gywsOA7uH3zAi/dgRwCKF5kt4EjjOzdwlNHzLY3d3MujTvVxeppZqHSNOcDlxsZnMJTdndjdC8RhCa2+iDiHOvMrN5wFuEJtEbQHzHA096aFLCtcB0YHjEtcs9NFnhXEKP0z4FdgEPmdk5wI4mfjeRmJQ8RJrGgO+6++HhrcTdq2sen9WcZDYKOBU4xt0PA94BChO4diwVEft7gDx3ryJU2/k7oQWHXkrie4gkRclDJDnbCC1LWu1l4Nvh6bsxs4HhWYnr6wxsdvcdZjYYODritcrq99czAzgv3K5SRGiJ2JgzF4fXnujs7lOBawg98hJJCbV5iCRnPlAVfvz0GPA7Qo+M/hdutF5P9GVGXwIuN7P5hGZdfSvitQeA+Wb2P3e/KKL8H4TWvp5HaIbXH7r7J+HkE01H4HkzKyRUa7m2Ud9QJAGaVVdERJKmx1YiIpI0JQ8REUmakoeIiCRNyUNERJKm5CEiIklT8hARkaQpeYiISNL+Pwk2AGeXReA9AAAAAElFTkSuQmCC\n", "text/plain": [ "
" ] }, "metadata": { "needs_background": "light" }, "output_type": "display_data" } ], "source": [ "import matplotlib.pyplot as plt\n", "\n", "plt.yscale('log'); plt.xlabel(\"Iterations\"); plt.ylabel(\"Change from last iteration\")\n", "plt.plot(range(len(change_iter)), change_iter)\n", "plt.show()" ] } ], "metadata": { "colab": { "authorship_tag": "ABX9TyPEr5R+vBWEUgLKt8e+FhsB", "name": "Problem 7", "provenance": [] }, "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.10.6" } }, "nbformat": 4, "nbformat_minor": 1 }