diff --git a/Chapitre 2 - Algebre matricielle/2.2 Multiplication de matrices.ipynb b/Chapitre 2 - Algebre matricielle/2.2 Multiplication de matrices.ipynb index 43eba50..02b1c10 100644 --- a/Chapitre 2 - Algebre matricielle/2.2 Multiplication de matrices.ipynb +++ b/Chapitre 2 - Algebre matricielle/2.2 Multiplication de matrices.ipynb @@ -1,320 +1,255 @@ { "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# **Concept(s)-clé(s) et théorie**\n", "\n", "Soient $A\\in M_{m\\times p}(\\mathbb{R})$ et $B\\in M_{p\\times n}(\\mathbb{R}).$ On définit *le produit* $A\\cdot B \\in M_{m\\times n}(\\mathbb{R})$ comme étant la matrice satisfaisant \n", "$$\n", "(A\\cdot B)_{ij}=\\sum_{k=1}^p{A_{ik}B_{kj}},\n", "$$\n", "\n", "ceci pour tout $1\\leq i \\leq m$ et tout $1\\leq j\\leq n.$" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 1, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/html": [ + " \n", + " " + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + " \n", + " " + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], "source": [ - "import AL_Fct as al" + "import Librairie.AL_Fct as al\n", + "import Corrections.corrections as corrections" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### **Exercice 1**\n", "Soient $A$ et $B$ données par\n", "$$\n", - "A=\\begin{pmatrix}\n", + "A=\\begin{bmatrix}\n", "1 & 2 \\\\\n", "3 & -1\\\\\n", "2 & 0\\\\\n", - "\\end{pmatrix}\\hskip2em\n", - "B=\\begin{pmatrix}\n", + "\\end{bmatrix}\\hskip2em\n", + "B=\\begin{bmatrix}\n", "-1 & 2\\\\\n", "0 & 3\\\\\n", - "\\end{pmatrix}\n", + "\\end{bmatrix}\n", "$$\n", "\n", - "Alors le produit $AB$ vaut" + "Alors:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ - "from IPython.display import display, Latex\n", - "from ipywidgets import Button, HBox, VBox,Layout\n", - "import ipywidgets as widgets\n", - " # OK PUT in AL_FCT\n", - "\n", - "a=widgets.Checkbox(\n", - " value=False,\n", - " description=r'\\(AB\\)\\(=\\)\\(\\begin{pmatrix}-1 & 4\\\\-3& -3\\\\2 & 0\\end{pmatrix}\\)',\n", - " disabled=False,\n", - " layout=Layout(width='30%', height='80px')\n", - ")\n", - "b=widgets.Checkbox(\n", - " value=False,\n", - " description=r'\\(AB\\)\\(=\\)\\(\\begin{pmatrix}-1 & 8\\\\-3& 3\\\\-2 & 4\\end{pmatrix}\\)',\n", - " disabled=False,\n", - " layout=Layout(width='80%', height='80px')\n", - "\n", - ")\n", - "c=widgets.Checkbox(\n", - " value=False,\n", - " description=r'\\(AB\\)\\(=\\)\\(\\bigg(\\begin{matrix}5 & -4\\\\1 & 0\\end{matrix}\\) \\(\\bigg)\\)',\n", - " disabled=False,\n", - " layout=Layout(width='80%', height='50px')\n", - ")\n", - "d=widgets.Checkbox(\n", - " value=False,\n", - " description=r\"\\(AB\\) n'est pas définie\",\n", - " disabled=False,\n", - " layout=Layout(width='80%', height='30px')\n", - ")\n", - "def correction(a,b,c,d): \n", - " if b and not(a) and not(c) and not(d):\n", - " print(\"C'est correct!\")\n", - " else:\n", - " print(\"C'est faux.\")\n", - "\n", - "out=interact_manual(correction,a=a,b=b,c=c,d=d)\n", - " " + "corrections.Ex1Chapitre2_2() " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### **Exercice 2**\n", "\n", "Soient $A$ et $B$ données par\n", "$$\n", - "A=\\begin{pmatrix}\n", + "A=\\begin{bmatrix}\n", "5 & 2 &-2\\\\\n", "3 & -1 & 0\n", - "\\end{pmatrix}\\hskip2em\n", - "B=\\begin{pmatrix}\n", + "\\end{bmatrix}\\hskip2em\n", + "B=\\begin{bmatrix}\n", "2 \\\\\n", "0\\\\\n", "-2\n", - "\\end{pmatrix}\n", + "\\end{bmatrix}\n", "$$\n", "\n", - "Alors " - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "from IPython.display import display, Latex\n", - "from ipywidgets import Button, HBox, VBox,Layout\n", - "import ipywidgets as widgets\n", - " # OK PUT in AL_FCT\n", - "\n", - "a=widgets.Checkbox(\n", - " value=False,\n", - " description=r'Le produit \\(AB\\) appartient à \\( M_{3\\times 3}(\\mathbb{R})\\)',\n", - " disabled=False,\n", - " layout=Layout(width='80%', height='80px')\n", - ")\n", - "b=widgets.Checkbox(\n", - " value=False,\n", - " description=r'Le produit \\(AB\\) appartient à \\(M\\)\\(_{3\\times 2}\\)\\((\\mathbb{R})\\)',\n", - " disabled=False,\n", - " layout=Layout(width='80%', height='80px')\n", - "\n", - ")\n", - "c=widgets.Checkbox(\n", - " value=False,\n", - " description=r'Le produit \\(AB\\) appartient à \\(M_{2\\times 1}(\\mathbb{R})\\)',\n", - " disabled=False,\n", - " layout=Layout(width='80%', height='50px')\n", - ")\n", - "d=widgets.Checkbox(\n", - " value=False,\n", - " description=r\"\\(AB\\) n'est pas définie\",\n", - " disabled=False,\n", - " layout=Layout(width='80%', height='30px')\n", - ")\n", - "def correction(a,b,c,d): \n", - " if c and not(a) and not(b) and not(d):\n", - " print(\"C'est correct! Le produit AB vaut\")\n", - " A=[[14],[6]]\n", - " al.printA(np.asmatrix(A))\n", - " else:\n", - " print(\"C'est faux.\")\n", - "\n", - "out=interact_manual(correction,a=a,b=b,c=c,d=d)\n", - " " + "Alors: " ] }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [] - }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ - "from IPython.display import display, Latex\n", - "from ipywidgets import Button, HBox, VBox,Layout\n", - "import ipywidgets as widgets\n", - " # OK PUT in AL_FCT\n", - "\n", - "a=widgets.Checkbox(\n", - " value=False,\n", - " description=r'Le produit \\(AB\\) appartient à \\( M_{3\\times 3}(\\mathbb{R})\\)',\n", - " disabled=False,\n", - " layout=Layout(width='80%', height='80px')\n", - ")\n", - "b=widgets.Checkbox(\n", - " value=False,\n", - " description=r'Le produit \\(AB\\) appartient à \\(M\\)\\(_{3\\times 2}\\)\\((\\mathbb{R})\\)',\n", - " disabled=False,\n", - " layout=Layout(width='80%', height='80px')\n", - "\n", - ")\n", - "c=widgets.Checkbox(\n", - " value=False,\n", - " description=r'Le produit \\(AB\\) appartient à \\(M_{2\\times 1}(\\mathbb{R})\\)',\n", - " disabled=False,\n", - " layout=Layout(width='80%', height='50px')\n", - ")\n", - "d=widgets.Checkbox(\n", - " value=False,\n", - " description=r\"\\(AB\\) n'est pas définie\",\n", - " disabled=False,\n", - " layout=Layout(width='80%', height='30px')\n", - ")\n", - "def correction(a,b,c,d): \n", - " if c and not(a) and not(b) and not(d):\n", - " print(\"C'est correct! Le produit AB vaut\")\n", - " A=[[14],[6]]\n", - " al.printA(np.asmatrix(A))\n", - " else:\n", - " print(\"C'est faux.\")\n", - "\n", - "out=interact_manual(correction,a=a,b=b,c=c,d=d)\n", - " " + "corrections.Ex2Chapitre2_2()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "## **Exercice 3 **\n", + "## Exercice 3\n", "\n", "Soient $A$ et $B$ deux matrices de taille $2\\times 2$ données par\n", "\n", "$$\n", - "A=\\begin{pmatrix}\n", + "A=\\begin{bmatrix}\n", "-1 & 2 \\\\\n", "5 & -2\n", - "\\end{pmatrix}\\hspace{2em}\n", - "B=\\begin{pmatrix}\n", + "\\end{bmatrix}\\hspace{2em}\n", + "B=\\begin{bmatrix}\n", "-1 & 1 \\\\\n", "a & b\n", - "\\end{pmatrix}\n", + "\\end{bmatrix}\n", "$$\n", "\n", "Trouver les valeurs de $a$ et $b$ - si elles existentent - telles que\n", "$$\n", "AB=BA\n", "$$" ] }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "A=[[-1, 2],[5,-2]]\n", - "B=[[-1,1],[5/2, -3/2]]" - ] - }, - { - "cell_type": "code", - "execution_count": null, + "execution_count": 2, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/latex": [ + "Insert the values of a and b as floating point numbers" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "8e959a52307c4f5d888166cffd3021c2", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "FloatText(value=0.0, description='a:', step=0.1)" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "9d76ced0d2d54c26bd742253f924012e", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "FloatText(value=0.0, description='b:', step=0.1)" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "27b75cb69a9d4aeba95c0594692fb47c", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "interactive(children=(Button(description='Run Interact', style=ButtonStyle()), Output()), _dom_classes=('widge…" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], "source": [ - "al.printA(A)\n", - "al.printA(B)\n", - "\n", - "print('Le produit AB vaut')\n", - "al.printA(np.dot(A,B))\n", - "print('Le produit BA vaut')\n", - "al.printA(np.dot(B,A))" + "corrections.Ex3Chapitre2_2()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "### **Vérification exercices**\n", - "\n", - "À l'aides des cases ci-dessous, vous pouvez vérifier vos calculs" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "A=[[1,2,3],[4,5,6],[7,8,9]]\n", - "B=[[1,0],[0,2],[1,2]]" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "#OK put in AL_Fct\n", - "\n", - "C=np.dot(np.asmatrix(A), np.asmatrix(B))\n", - "print('AB vaut')\n", - "al.printA(C)" + "[Passez au notebook du chapitre 2.3: Matrices carées, inversibles](./2.3%20Matrices%20carrées%2C%20inversibles.ipynb)" ] } ], "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.6.8" + "version": "3.7.4" } }, "nbformat": 4, "nbformat_minor": 2 }