diff --git a/Prateek-python.md b/Prateek-python.md new file mode 100644 index 0000000..d377455 --- /dev/null +++ b/Prateek-python.md @@ -0,0 +1,7 @@ +### Introduce Yourself +My name is Prateek Verma + +### Tech Stack I use +C++,Python +### How did I discover Zoop? +Youtube diff --git a/Prateek-python2.md b/Prateek-python2.md new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/Prateek-python2.md @@ -0,0 +1 @@ + diff --git a/matrix_determinant.ipynb b/matrix_determinant.ipynb new file mode 100644 index 0000000..cd328d1 --- /dev/null +++ b/matrix_determinant.ipynb @@ -0,0 +1,360 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [], + "source": [ + "import numpy as np\n" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": {}, + "outputs": [], + "source": [ + "arr1 = np.array([[16, 1, 2, 3],\n", + " [4, 5, 6, 7],\n", + " [8, 9, 17, 11],\n", + " [12, 13, 14, 15]])\n" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "array([[16, 1, 2, 3],\n", + " [ 4, 5, 6, 7],\n", + " [ 8, 9, 17, 11],\n", + " [12, 13, 14, 15]])" + ] + }, + "execution_count": 7, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "arr1\n" + ] + }, + { + "cell_type": "code", + "execution_count": 21, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "-1792.0000000000032" + ] + }, + "execution_count": 21, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "det = np.linalg.det(arr1)\n", + "det\n" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "(array([-4.23921761+0.j , 4.11960881+0.97808983j,\n", + " 4.11960881-0.97808983j]),\n", + " array([[-0.29340298+0.j , -0.29794644-0.14168804j,\n", + " -0.29794644+0.14168804j],\n", + " [ 0.94705879+0.j , -0.17502754-0.05555916j,\n", + " -0.17502754+0.05555916j],\n", + " [ 0.13036236+0.j , -0.92597568+0.j ,\n", + " -0.92597568-0.j ]]))" + ] + }, + "execution_count": 5, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "np.linalg.eig(arr1)\n" + ] + }, + { + "cell_type": "code", + "execution_count": 17, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "array([[-1.12000000e+02, 1.68000000e+02, 1.24344979e-14,\n", + " -5.60000000e+01],\n", + " [ 1.68000000e+02, 1.36400000e+03, 1.28000000e+02,\n", + " -7.64000000e+02],\n", + " [-4.24296933e-15, 1.28000000e+02, -2.56000000e+02,\n", + " 1.28000000e+02],\n", + " [-5.60000000e+01, -1.43600000e+03, 1.28000000e+02,\n", + " 4.68000000e+02]])" + ] + }, + "execution_count": 17, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "adj = np.linalg.inv(arr1)*det\n", + "adj\n" + ] + }, + { + "cell_type": "code", + "execution_count": 23, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "array([[ 0.33333333, 0.66666667, -0.66666667],\n", + " [-0.66666667, 0.66666667, 0.33333333],\n", + " [ 0.66666667, 0.33333333, 0.66666667]])" + ] + }, + "execution_count": 23, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "ortho = np.array([[1/3, 2/3, -2/3],\n", + " [-2/3, 2/3, 1/3],\n", + " [2/3, 1/3, 2/3]])\n", + "ortho\n" + ] + }, + { + "cell_type": "code", + "execution_count": 35, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "array([[ 0.33333333, -0.66666667, 0.66666667],\n", + " [ 0.66666667, 0.66666667, 0.33333333],\n", + " [-0.66666667, 0.33333333, 0.66666667]])" + ] + }, + "execution_count": 35, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "transpose1 = ortho.transpose()\n", + "transpose1\n" + ] + }, + { + "cell_type": "code", + "execution_count": 37, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "array([[ 1.00000000e+00, -1.54197642e-17, 2.46716228e-17],\n", + " [-1.54197642e-17, 1.00000000e+00, -1.23358114e-17],\n", + " [ 2.46716228e-17, -1.23358114e-17, 1.00000000e+00]])" + ] + }, + "execution_count": 37, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "np.matmul(ortho, transpose1)\n" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "metadata": {}, + "outputs": [], + "source": [ + "M1 = np.array([[1, 0, -1],\n", + " [3, 1, 2]])\n", + "M2 = np.array([[1],\n", + " [2],\n", + " [3]])\n" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "array([[-2],\n", + " [11]])" + ] + }, + "execution_count": 14, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "np.matmul(M1, M2)\n" + ] + }, + { + "cell_type": "code", + "execution_count": 26, + "metadata": {}, + "outputs": [], + "source": [ + "M3 = np.array([[5, -3],\n", + " [1, 0],\n", + " [-7, 4],\n", + " [0, 2]])\n", + "M4 = np.array([[1],\n", + " [0]])\n" + ] + }, + { + "cell_type": "code", + "execution_count": 27, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "array([[ 5],\n", + " [ 1],\n", + " [-7],\n", + " [ 0]])" + ] + }, + "execution_count": 27, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "np.matmul(M3,M4)" + ] + }, + { + "cell_type": "code", + "execution_count": 37, + "metadata": {}, + "outputs": [], + "source": [ + "M5=np.array([[2,1,3],\n", + "[-1,1,0],\n", + "[-2,4,1]])" + ] + }, + { + "cell_type": "code", + "execution_count": 38, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "-2.999999999999998" + ] + }, + "execution_count": 38, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "np.linalg.det(M5)" + ] + }, + { + "cell_type": "code", + "execution_count": 39, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "array([[-750599937895083/2251799813685248,\n", + " -4128299658422957/1125899906842624,\n", + " 2251799813685249/2251799813685248],\n", + " [-750599937895083/2251799813685248,\n", + " -6004799503160665/2251799813685248,\n", + " 4503599627370499/4503599627370496],\n", + " [6004799503160663/9007199254740992,\n", + " 7505999378950831/2251799813685248,\n", + " -4503599627370499/4503599627370496]])" + ] + }, + "execution_count": 39, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "I=np.linalg.inv(M5)\n", + "I\n", + "# np.linalg.pinv(I)\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3.10.5 64-bit", + "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.5" + }, + "orig_nbformat": 4, + "vscode": { + "interpreter": { + "hash": "a9e1fd7a2e46eb840a8adc7a2cabae756acfcbc34a8c7d4b0aee6413053f8c96" + } + } + }, + "nbformat": 4, + "nbformat_minor": 2 +}