\n",
" Need a hint? Click here
\n",
" To solve this exercise, you will need 3 for
loops: one to go over $n$ rows of the output matrix, one to go over $k$ columns, and one to add up $m$ products that form each element of the output:\n",
" \n",
" \n",
" for i in range(n):\n",
" for j in range(k):\n",
" sum = 0\n",
" for t in range(m):\n",
" sum = sum + ...\n",
" c[i][j] = sum\n",
"
\n",
"
\n",
" A video explanation can be found here.\n",
" "
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"@exercise\n",
"def matrix_mult(a : Matrix, b : Matrix) -> Matrix:\n",
" return ..."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"*Can't come up with a solution? See the explained solution in the [Linear Algebra Workbook](./Workbook_LinearAlgebra.ipynb#Exercise-3:-Matrix-multiplication.).*"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Inverse Matrices\n",
"\n",
"A square $n \\times n$ matrix $A$ is **invertible** if it has an inverse $n \\times n$ matrix $A^{-1}$ with the following property:\n",
"\n",
"$$AA^{-1} = A^{-1}A = I_n$$\n",
"\n",
"In other words, $A^{-1}$ acts as the **multiplicative inverse** of $A$.\n",
"\n",
"Another, equivalent definition highlights what makes this an interesting property. For any matrices $B$ and $C$ of compatible sizes:\n",
"\n",
"$$A^{-1}(AB) = A(A^{-1}B) = B$$\n",
"$$(CA)A^{-1} = (CA^{-1})A = C$$\n",
"\n",
"A square matrix has a property called the **determinant**, with the determinant of matrix $A$ being written as $|A|$. A matrix is invertible if and only if its determinant isn't equal to $0$.\n",
"\n",
"For a $2 \\times 2$ matrix $A$, the determinant is defined as $|A| = (A_{0,0} \\cdot A_{1,1}) - (A_{0,1} \\cdot A_{1,0})$.\n",
"\n",
"For larger matrices, the determinant is defined through determinants of sub-matrices. You can learn more from [Wikipedia](https://en.wikipedia.org/wiki/Determinant) or from [Wolfram MathWorld](http://mathworld.wolfram.com/Determinant.html)."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"###