diff --git a/Chapitre 4 - Bases et dimension/Prototype 4.10.ipynb b/Chapitre 4 - Bases et dimension/Prototype 4.10.ipynb new file mode 100644 index 0000000..c4bd547 --- /dev/null +++ b/Chapitre 4 - Bases et dimension/Prototype 4.10.ipynb @@ -0,0 +1,277 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "jupyter": { + "source_hidden": true + } + }, + "outputs": [], + "source": [ + "%cd ..\n", + "import Librairie.AL_Fct as al\n", + "%cd \"Chapitre 4 - Bases et dimension\"\n", + "\n", + "import numpy as np\n", + "from IPython.display import display, Markdown, Latex\n", + "import plotly.graph_objs as go\n", + "import plotly\n", + "import ipywidgets as widgets\n", + "from ipywidgets import interact, interactive, fixed, interact_manual\n", + "from ipywidgets import Layout, HBox, VBox, Label\n", + "#import matplotlib\n", + "#import plotly.express as px" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Concept(s)-clé(s)\n", + "\n", + "\n", + "\n", + "### LEMME 5 :\n", + "\n", + "Soit $S$ un système de $m$ équations linéaires à $n$ inconnues, $A$ la matrice des coefficients de $S$ et $\\hat{A}$ sa matrice augmentée. Alors $S$ possède une solution si et seulement si le rang colonne de $A$ est égal au rang colonne de $\\hat{A}.$" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### EXERCICE 1.1\n", + "\n", + "Soit 𝑆 un système de 𝑚 équations linéaires à 𝑛 inconnues:\n", + "\n", + "$\\begin{equation}\n", + " \\left\\{\n", + " \\begin{aligned}\n", + " x_1 + 4x_2 + 3x_3 + 4x_4 = 1 \\\\ \n", + " 2x_1 + 6x_2 + 5x_3 + 8x_4 = 1 \\\\\n", + " x_1 + x_3 + 4x_4 = 1\n", + " \\end{aligned}\n", + " \\right.\n", + "\\end{equation}$\n", + "\n", + "Cette quation peut se repréenseter sous la forme $AX =b$.\n", + "Ecrivez A la matrice et le vecteur b dans la cellule suivante en respectant\n", + "\n", + "$[[ a, b], [c, d]] = \\begin{pmatrix} a & b \\\\ c & d \\end{pmatrix}$\n", + "\n", + "et b en suivant le format \n", + "\n", + "$[e, f] = \\begin{pmatrix} e \\\\ f \\end{pmatrix}$" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "jupyter": { + "source_hidden": true + } + }, + "outputs": [], + "source": [ + "def exercice1_1():\n", + " A_sol = [[1, 4, 3, 4],[2, 6, 5, 8],[1, 0, 1, 4]]\n", + " b_sol = [1, 1, 1]\n", + " if A == [] or b == []:\n", + " print(\"Au moins une des deux entrée est vide\")\n", + " elif not (len(A) == len(b)):\n", + " print(\"Les tailles de la matrice et du vecteur ne correspondent pas\")\n", + " else:\n", + " if A == A_sol:\n", + " if b == b_sol:\n", + " print(\"Correct !\")\n", + " else:\n", + " print(\"Le vecteur b est faux, votre reponse correspond au système suivant:\")\n", + " al.printSyst(A, b)\n", + " elif b == b_sol:\n", + " print(\"La Matrice A est fausse, votre reponse correspond au système suivant:\")\n", + " al.printSyst(A, b)\n", + " else:\n", + " print(\"Faux, votre reponse correspond au système suivant:\")\n", + " al.printSyst(A, b)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# n'oubliez pas d'executer la cellule\n", + "A = []\n", + "b = []\n", + "\n", + "exercice1_1() # ne pas toucher cette ligne" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### EXERCICE 1.2\n", + "Pour calculer le rang colonne de $A$ nous échelonnons sa matrice transposée. Si et seulement si le rang colonne de $A$ est égal au rang colonne de $\\hat{A}$.\n", + "À partir de cette matrice, donnez le rang colonne de $A$ et trouvez une base de l'espace colonne de $A$ ." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "jupyter": { + "source_hidden": true + } + }, + "outputs": [], + "source": [ + "A_sol = np.array([[1, 4, 3, 4],[2, 6, 5, 8],[1, 0, 1, 4]])\n", + "A_sol_t = A_sol.transpose()\n", + "M = al.echelonMat('E', A_sol_t)\n", + " " + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "jupyter": { + "source_hidden": true + } + }, + "outputs": [], + "source": [ + "def exercice1_2_1():\n", + " \n", + " text_rang = widgets.IntText()\n", + " box = VBox([Label('Rang colonne de A:'), text_rang])\n", + " button = widgets.Button(description='Vérifier')\n", + " out = widgets.Output()\n", + " \n", + " def callback(e):\n", + " out.clear_output()\n", + " with out:\n", + " if(text_rang.value == 2):\n", + " print('Correct !')\n", + " else: \n", + " print('False, try again or check the solution')\n", + " \n", + " button.on_click(callback)\n", + " display(box)\n", + " display(button)\n", + " display(out)\n", + "\n", + "exercice1_2_1()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "jupyter": { + "source_hidden": true + } + }, + "outputs": [], + "source": [ + "def exercice1_2_2():\n", + " \n", + " base_sol = [[1,2,1],[0,1,2]]\n", + " \n", + " if base_sol == []:\n", + " print(\"L'entrée est vide\")\n", + " else:\n", + " if base == base_sol:\n", + " print(\"Correct !\")\n", + " else:\n", + " print(\"Faux\")\n", + " " + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# [vect1,vect2,...] avec vect = [a, b, c] n'oubliez pas d'executer la cellule\n", + "base = [[1,2,1],[0,1,2]]\n", + "exercice1_2_2()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### EXERCICE 1.3 \n", + "Le système possède-t-il une solution ? (utilisez le lemme 5)\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "jupyter": { + "source_hidden": true + } + }, + "outputs": [], + "source": [ + "def exercise_1_3():\n", + " \n", + " radio = widgets.RadioButtons(\n", + " options=['Yes', 'No'],\n", + " description='Answer:',\n", + " disabled=False\n", + " )\n", + "\n", + " button = widgets.Button(description='Vérifier')\n", + " out = widgets.Output()\n", + "\n", + " def callback(e):\n", + " out.clear_output()\n", + " with out:\n", + " if (radio.value == \"Yes\"):\n", + " print('Mauvaise réponse.')\n", + " else: \n", + " print('Correct !')\n", + " \n", + " button.on_click(callback)\n", + " display(radio)\n", + " display(button)\n", + " display(out)\n", + " \n", + "exercise_1_3()\n", + "\n", + "\n", + "\n" + ] + } + ], + "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.7.4" + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} diff --git a/Chapitre 4 - Bases et dimension/Prototype 4.9.ipynb b/Chapitre 4 - Bases et dimension/Prototype 4.9.ipynb new file mode 100644 index 0000000..22e4385 --- /dev/null +++ b/Chapitre 4 - Bases et dimension/Prototype 4.9.ipynb @@ -0,0 +1,314 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "jupyter": { + "source_hidden": true + } + }, + "outputs": [], + "source": [ + "%cd ..\n", + "import Librairie.AL_Fct as al\n", + "%cd \"Chapitre 4 - Bases et dimension\"\n", + "\n", + "import numpy as np\n", + "from IPython.display import display, Markdown, Latex\n", + "import plotly.graph_objs as go\n", + "import plotly\n", + "import ipywidgets as widgets\n", + "from ipywidgets import interact, interactive, fixed, interact_manual, Layout, HBox, VBox" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Concept(s)-clé(s)\n", + "\n", + "\n", + "\n", + "### DÉFINITION 1 :\n", + "\n", + "Soit $A\\in M_{m\\times n}(\\mathbb{R})$ une matrice de taille $m\\times n$ à coefficients réels.\n", + "\n", + "\n", + "\n", + "1. Le *rang ligne* de $A$ est la dimension de l'espace ligne de $A.$\n", + "\n", + "2. Le *rang colonne* de $A$ est la dimension de l'espace colonne de $A.$\n", + "\n", + "\n", + "\n", + "### REMARQUES 2 :\n", + "\n", + "\n", + "\n", + "1. Le rang ligne de $A$ est plus petit ou égal à $n,$ car c'est un sous-espace vectoriel de $\\mathbb{R}^n.$\n", + "\n", + "2. Le rang ligne de $A$ est plus petit ou égal à $m,$ car engendré par $m$ vecteurs.\n", + "\n", + "3. Le rang colonne de $A$ est plus petit ou égal à $m$ et $n,$ par le même raisonnement.\n", + "\n", + "4. Le rang colonne de $A$ est égal au rang ligne de $A^T.$\n", + "\n", + "5. Le rang ligne de $A$ est égal au rang colonne de $A^T.$\n", + "\n", + "\n", + "\n", + "### PROPOSITION 3 :\n", + "\n", + "Soient $A,B\\in M_{m\\times n}(\\mathbb{R})$ des matrices ligne équivalentes. Alors l'espace ligne de $A$ est égal à l'espace ligne de $B.$ Par conséquent, le rang ligne de $A$ est égal au rang ligne de $B.$\n", + "\n", + "### PROPOSITION 4 :\n", + "\n", + "Soit $A$ une matrice échelonnée. Alors le rang ligne de $A$ est égal au nombre de pivots. Aussi, une base de l'espace ligne de $A$ est donnée par les lignes contenant un pivots." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### EXERCICE 1\n", + "\n", + "Soit la matrice A :\n", + "\n", + "$$A = \\begin{pmatrix} 1 & 2 & 3 \\\\ 4 & 5 & 6 \\end{pmatrix}$$\n", + "\n", + "Sélectionnez les propositions correctes\n", + "(maintenez CTRL pour sélectionner plusieurs cellules à la fois)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "jupyter": { + "source_hidden": true + } + }, + "outputs": [], + "source": [ + "def exercise_1():\n", + " r1 = 'Le rang ligne de 𝐴 est plus petit ou égal à 2, car c\\'est un sous-espace vectoriel de ℝ2.'\n", + " r2 = 'Le rang ligne de 𝐴 est plus petit ou égal à 3, car c\\'est un sous-espace vectoriel de ℝ3.'\n", + " r3 = 'Le rang ligne de 𝐴 est plus petit ou égal à 3, car engendré par 3 vecteurs.'\n", + " r4 = 'Le rang ligne de 𝐴 est plus petit ou égal à 2, car engendré par 2 vecteurs.'\n", + " r5 = 'Le rang colonne de A est plus petit ou égal à 2.'\n", + "\n", + " select = widgets.SelectMultiple(\n", + " options=[(r1, 1), (r2, 2), (r3, 3), (r4, 4), (r5, 5)],\n", + " description='Sélection :',\n", + " disabled=False,\n", + " layout=Layout(width='auto', height='100px')\n", + " )\n", + "\n", + " button = widgets.Button(description='Vérifier')\n", + " out = widgets.Output()\n", + "\n", + " def callback(e):\n", + " out.clear_output()\n", + " with out:\n", + " if (1 in select.value or 3 in select.value):\n", + " print('Mauvaise réponse. \\nAttention à ne pas confondre les espaces des lignes et colonnes')\n", + " elif (2 not in select.value or 4 not in select.value or 5 not in select.value):\n", + " print('Il manque au moins une réponse.')\n", + " elif (2 in select.value and 4 in select.value and 5 in select.value):\n", + " print('Correct !')\n", + " \n", + " button.on_click(callback)\n", + "\n", + " display(select)\n", + " display(button)\n", + " display(out)\n", + " \n", + "exercise_1()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### EXERCICE 2\n", + "#### 2.1\n", + "Soit la matrice $A$ :\n", + "\n", + "$$A = \\begin{pmatrix} 1 & 2 & 3 \\\\ 0 & 1 & 2 \\end{pmatrix}$$\n", + "\n", + "Donnez le rang ligne de $A$." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "jupyter": { + "source_hidden": true + } + }, + "outputs": [], + "source": [ + "def exercice_2_1():\n", + " text = widgets.IntText(\n", + " description='Réponse :',\n", + " disabled=False\n", + " )\n", + " button = widgets.Button(description='Vérifier')\n", + " out = widgets.Output()\n", + " \n", + " def callback(e):\n", + " out.clear_output()\n", + " r = text.value\n", + " \n", + " with out:\n", + " if r == 2:\n", + " display(Markdown(\"Par la proposition 4 c'est correct!\"))\n", + " elif r > 2:\n", + " display(Markdown(\"Faux, c'est trop grand\"))\n", + " else:\n", + " display(Markdown(\"Faux, c'est trop petit\"))\n", + " \n", + " button.on_click(callback)\n", + " \n", + " display(text)\n", + " display(button)\n", + " display(out)\n", + "exercice_2_1()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### 2.2\n", + "Parmi les ensembles suivants, séléctionnez l'ensemble générant l'espace ligne de $A$\n", + "\n", + "$E_1 = \\begin{Bmatrix}\\begin{pmatrix} 1 \\\\ 2 \\\\ 3 \\end{pmatrix}, \\begin{pmatrix} 0 \\\\ 1 \\\\ 2 \\end{pmatrix}\\end{Bmatrix}$ $E_2 = \\begin{Bmatrix}\\begin{pmatrix} 1 \\\\ 2 \\\\ 3 \\end{pmatrix}, \\begin{pmatrix} 0 \\\\ 1 \\\\ 2 \\end{pmatrix}, \\begin{pmatrix} 0 \\\\ 0 \\\\ 1 \\end{pmatrix}\\end{Bmatrix}$ \n", + "$E_3 = \\begin{Bmatrix}\\begin{pmatrix} 1 \\\\ 0\\end{pmatrix}, \\begin{pmatrix} 2 \\\\ 1 \\end{pmatrix}, \\begin{pmatrix} 3 \\\\ 2 \\end{pmatrix}\\end{Bmatrix}$\n", + "$E_4 = \\begin{Bmatrix}\\begin{pmatrix} 1 \\\\ 0\\end{pmatrix}, \\begin{pmatrix} 2 \\\\ 1 \\end{pmatrix}\\end{Bmatrix}$" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "jupyter": { + "source_hidden": true + } + }, + "outputs": [], + "source": [ + "def exercise_2_2():\n", + " select = widgets.SelectMultiple(\n", + " options=['E1', 'E2', 'E3', 'E4'],\n", + " description='Sélection :',\n", + " disabled=False,\n", + " layout=Layout(width='auto', height='auto')\n", + " )\n", + "\n", + " button = widgets.Button(description='Vérifier')\n", + "\n", + " out = widgets.Output()\n", + "\n", + " def callback(e):\n", + " \n", + " out.clear_output()\n", + " with out:\n", + " if len(select.value) <= 0: # Empty\n", + " pass\n", + " elif len(select.value) > 1:\n", + " display(Markdown(\"Un seul de ces ensembles génère exactement l'espace ligne de A\"))\n", + " elif 'E1' not in select.value:\n", + " display(Markdown(\"Faux\"))\n", + " else:\n", + " display(Markdown(\"Correct !\"))\n", + " button.on_click(callback)\n", + " display(select)\n", + " display(button)\n", + " display(out)\n", + " \n", + "exercise_2_2()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### 2.3\n", + "Utilizez la remarque 2 ainsi que les propositions 3 et 4 pour trouver le rang colonne de $A$" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "jupyter": { + "source_hidden": true + } + }, + "outputs": [], + "source": [ + "\n", + "\n", + "def exercise_2_3():\n", + " text = widgets.IntText(description='Réponse :', disabled=False)\n", + "\n", + " button = widgets.Button(description='Vérifier')\n", + " button2 = widgets.Button(description='Solution', disabled=True)\n", + " box = HBox(children=[button,button2])\n", + " out = widgets.Output()\n", + "\n", + " def callback(e):\n", + " out.clear_output()\n", + " button2.disabled = False\n", + " with out:\n", + " if(text.value == 2):\n", + " print('Correct !')\n", + " else: \n", + " print('False, try again or check the solution')\n", + " \n", + " def solution(e):\n", + " out.clear_output()\n", + " with out:\n", + " A = np.array([[1, 2, 3], [0, 1, 2]])\n", + " A_t = A.transpose()\n", + " display(Markdown('Pour trouver le rang colonne de $A$, nous utilisons la remarque 2 et trouvous le rang ligne de la transposée de $A$.'))\n", + " display(Markdown('Par les propositions 3 et 4, nous échelonnons la matrice transposée et observont le nombre de lignes qui contiennent des pivots'))\n", + " M = al.echelonMat('E', A_t)\n", + " display(Markdown('Ainsi le rang colonne de $A$ est 2'))\n", + " \n", + " button.on_click(callback)\n", + " button2.on_click(solution)\n", + " \n", + " display(text)\n", + " display(box)\n", + " display(out)\n", + " \n", + "exercise_2_3()\n" + ] + } + ], + "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.7.4" + } + }, + "nbformat": 4, + "nbformat_minor": 4 +}