diff --git "a/Chapitre 4 - Bases et dimension/4.1-4.2. D\303\251pendance et ind\303\251pendance lin\303\251aire.ipynb" "b/Chapitre 4 - Bases et dimension/4.1-4.2. D\303\251pendance et ind\303\251pendance lin\303\251aire.ipynb" new file mode 100644 index 0000000..2075e75 --- /dev/null +++ "b/Chapitre 4 - Bases et dimension/4.1-4.2. D\303\251pendance et ind\303\251pendance lin\303\251aire.ipynb" @@ -0,0 +1,316 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Concept(s)-clé(s) et théorie\n", + "\n", + "### DÉFINITION 1\n", + "\n", + "Soient $V$ un $\\mathbb{R}$-espace vectoriel et $S\\subset V$ une collection de vecteurs dans $V.$ On dit que $S$ est linéairement dépendante (ou liée) s'il existe des vecteurs distincts $v_1,\\ldots,v_r\\in S$ et des scalaires $\\lambda_1,\\ldots,\\lambda_r\\in \\mathbb{R}$ non tous nuls tels que $\\lambda_1v_1+\\cdots+\\lambda_rv_r=0.$ (Autrement dit, s'il existe une combinaison linéaire (non triviale) de vecteurs de $S$ qui se réduit au vecteur nul.) S'il n'existe pas de tels vecteurs dans $S,$ alors on dit que $S$ est linéairement indépendante (ou libre).\n", + "\n", + "### PROPOSITION 1\n", + "\n", + "Soient $V$ un $\\mathbb{R}$-espace vectoriel et $v_1,\\ldots,v_r\\in V$ des vecteurs de $V.$ Alors ces derniers sont linéairement dépendants si et seulement s'il existe $1\\leq i\\leq r$ tels que $v_i\\in \\mbox{Vect}(\\{v_1,\\ldots,v_{i-1},v_{i+1},\\ldots,v_r\\}),$ c'est-à-dire si et seulement si l'on peut exprimer un des vecteurs de la liste comme une combinaison linéaire des autres.\n", + "\n", + "### PROPOSITION 2\n", + "\n", + "Soient $V$ un $\\mathbb{R}$-espace vectoriel et $S\\subset V$ une famille libre de vecteurs dans $V.$ Alors tout sous-ensemble $T\\subset S$ est aussi libre.\n", + "\n", + "### PROPOSITION 3\n", + "\n", + "Soient $V$ un $\\mathbb{R}$-espace vectoriel et $S\\subset V$ une famille liée de vecteurs dans $V.$ Alors toute collection de vecteurs $T$ contenant $S$ est également liée." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "%cd ..\n", + "import Librairie.AL_Fct as al\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" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### EXERCICE 1\n", + "\n", + "Soient:\n", + "\n", + "$$v_1 = \\begin{pmatrix} 1 \\\\ 0 \\\\ 2 \\end{pmatrix} \\ \\ v_2 = \\begin{pmatrix} 0 \\\\ 1 \\\\ 0 \\end{pmatrix} \\ \\ v_3 = \\begin{pmatrix} 1 \\\\ 1 \\\\ 1 \\end{pmatrix}$$\n", + "\n", + "Trouver une combinaison linéaire telle que:\n", + "\n", + "$$\\lambda_1 v_1 + \\lambda_2 v_2 + \\lambda_3 v_3 = \\begin{pmatrix} 3 \\\\ 5 \\\\ 4 \\end{pmatrix}$$\n", + "\n", + "Entrez les coefficients $\\lambda_i$ dans le vecteur ci-dessous puis exécutez les deux cellules pour vérifier votre réponse." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "jupyter": { + "source_hidden": true + } + }, + "outputs": [], + "source": [ + "def verification_1():\n", + " v = np.array([[1, 0, 2], [0, 1, 0], [1, 1, 1]]).transpose()\n", + " e = np.array([3, 5, 4])\n", + " s = np.array(solution)\n", + " r = v @ s\n", + " if np.allclose(e, r):\n", + " display(Markdown(\"**Correction:** C'est correct!\"))\n", + " else:\n", + " display(Markdown(\"**Correction:** C'est incorrect car: $\\lambda_1 v_1 + \\lambda_2 v_2 + \\lambda_3 v_3 = \\\\begin{pmatrix} %s \\\\\\\\ %s \\\\\\\\ %s \\end{pmatrix} \\\\neq \\\\begin{pmatrix} %s \\\\\\\\ %s \\\\\\\\ %s \\end{pmatrix}$\" % (r[0], r[1], r[2], e[0], e[1], e[2])))\n", + " \n", + " #plotly.offline.init_notebook_mode(connected=True)\n", + " \n", + " w = s * v\n", + " \n", + " x = np.cumsum(np.insert(w[0], 0, 0))\n", + " y = np.cumsum(np.insert(w[1], 0, 0))\n", + " z = np.cumsum(np.insert(w[2], 0, 0))\n", + "\n", + " pairs = [(0,1), (1,2), (2, 3)]\n", + "\n", + " x_lines = list()\n", + " y_lines = list()\n", + " z_lines = list()\n", + "\n", + " for p in pairs:\n", + " for i in range(2):\n", + " x_lines.append(x[p[i]])\n", + " y_lines.append(y[p[i]])\n", + " z_lines.append(z[p[i]])\n", + " x_lines.append(None)\n", + " y_lines.append(None)\n", + " z_lines.append(None)\n", + "\n", + " trace1 = go.Scatter3d(\n", + " x=x_lines,\n", + " y=y_lines,\n", + " z=z_lines,\n", + " mode='lines+markers',\n", + " name='Combinaison linéaire entrée',\n", + " marker_symbol='cross'\n", + " )\n", + "\n", + " trace2 = go.Scatter3d(\n", + " x=[0, e[0]],\n", + " y=[0, e[1]],\n", + " z=[0, e[2]],\n", + " mode='lines+markers',\n", + " name='Résultat attendu',\n", + " )\n", + "\n", + " fig = go.Figure(data=[trace1, trace2])\n", + "\n", + " fig.show()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "solution = [1, 0, 2] # Réponse à compléter\n", + "\n", + "verification_1()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### EXERCICE 2\n", + "\n", + "D'après les mêmes données que l'exercice 1, la collection des vecteurs $v_1$, $v_2$, $v_3$ et $\\begin{pmatrix} 3 \\\\ 0 \\\\ 4 \\end{pmatrix}$ est-elle liée ?" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "jupyter": { + "source_hidden": true + } + }, + "outputs": [], + "source": [ + "radio = widgets.RadioButtons(\n", + " options=['Oui, les vecteurs sont dépendants', 'Non, les vecteurs sont indépendants'],\n", + " layout={'width': 'max-content'},\n", + " value=None,\n", + " description='Réponse:',\n", + ")\n", + "\n", + "button = widgets.Button(description='Vérifier')\n", + "\n", + "out = widgets.Output()\n", + "\n", + "display(radio)\n", + "display(button)\n", + "display(out)\n", + "\n", + "def verification_2(e):\n", + " if radio.value is not None:\n", + " out.clear_output()\n", + " with out:\n", + " if radio.value.startswith('Oui'):\n", + " display(Markdown(\"C'est incorrect, il existe $\\lambda_1$, $\\lambda_2$ et $\\lambda_3$ tels que $\\lambda_1 v_1 + \\lambda_2 v_2 + \\lambda_3 v_3 - \\\\begin{pmatrix} 3 \\\\\\\\ 0 \\\\\\\\ 4 \\end{pmatrix} = 0$.\"))\n", + " else:\n", + " display(Markdown(\"C'est correct!\"))\n", + "\n", + "button.on_click(verification_2)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### EXERCICE 3\n", + "\n", + "Les collections de vecteurs suivantes sont-elles liées ?" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "jupyter": { + "source_hidden": true + } + }, + "outputs": [], + "source": [ + "def exercice_3(answer):\n", + " radio = widgets.RadioButtons(\n", + " options=['Oui, les vecteurs sont dépendants', 'Non, les vecteurs sont indépendants'],\n", + " layout={'width': 'max-content'},\n", + " value=None,\n", + " description='Réponse:',\n", + " )\n", + "\n", + " button = widgets.Button(description='Vérifier')\n", + "\n", + " out = widgets.Output()\n", + "\n", + " display(radio)\n", + " display(button)\n", + " display(out)\n", + "\n", + " def verification_3(e):\n", + " if radio.value is not None:\n", + " out.clear_output()\n", + " with out:\n", + " if radio.value.startswith('Oui') == answer:\n", + " display(Markdown(\"C'est correct!\"))\n", + " else:\n", + " display(Markdown(\"C'est incorrect!\"))\n", + "\n", + " button.on_click(verification_3)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### (a)\n", + "\n", + "$$v_1 = \\begin{pmatrix} 1 \\\\ 1 \\\\ 1 \\end{pmatrix} \\ \\ v_2 = \\begin{pmatrix} 1 \\\\ 2 \\\\ 1 \\end{pmatrix} \\ \\ v_3 = \\begin{pmatrix} 0 \\\\ 1 \\\\ 0 \\end{pmatrix}$$" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "jupyter": { + "source_hidden": true + } + }, + "outputs": [], + "source": [ + "exercice_3(True)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### (b)\n", + "\n", + "$$v_1 = \\begin{pmatrix} 1 \\\\ 0 \\\\ 4 \\end{pmatrix} \\ \\ v_2 = \\begin{pmatrix} 6 \\\\ 12 \\\\ 7 \\end{pmatrix} \\ \\ v_3 = \\begin{pmatrix} 0 \\\\ 9 \\\\ 7 \\end{pmatrix} \\ \\ v_4 = \\begin{pmatrix} 1 \\\\ 1 \\\\ 1 \\end{pmatrix}$$" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "jupyter": { + "source_hidden": true + } + }, + "outputs": [], + "source": [ + "exercice_3(True)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### (c)\n", + "\n", + "$$v_1 = \\begin{pmatrix} 1 \\\\ 0 \\\\ -1 \\end{pmatrix} \\ \\ v_2 = \\begin{pmatrix} 1 \\\\ 1 \\\\ 0 \\end{pmatrix} \\ \\ v_3 = \\begin{pmatrix} 0 \\\\ 1 \\\\ -1 \\end{pmatrix}$$" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "jupyter": { + "source_hidden": true + } + }, + "outputs": [], + "source": [ + "exercice_3(True)" + ] + } + ], + "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" + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} diff --git a/Chapitre 4 - Bases et dimension/Prototypes.txt b/Chapitre 4 - Bases et dimension/Prototypes.txt new file mode 100644 index 0000000..d0b27a0 --- /dev/null +++ b/Chapitre 4 - Bases et dimension/Prototypes.txt @@ -0,0 +1,3 @@ +Ressources complémentaires (hébergées sur le drive pour ne pas surcharger le dépôt) : + +https://drive.google.com/drive/folders/1tvgU6sx5Blwx-KriIPu7vP4iYlyLIAn9?usp=sharing \ No newline at end of file diff --git a/Chapitre 4 - Bases et dimension/courseware_script.ipynb b/Chapitre 4 - Bases et dimension/courseware_script.ipynb new file mode 100644 index 0000000..72196c7 --- /dev/null +++ b/Chapitre 4 - Bases et dimension/courseware_script.ipynb @@ -0,0 +1,88 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import html\n", + "import re" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# A small script to efficiently extract the courseware latex macros\n", + "def decode(s):\n", + " d = html.unescape(s)\n", + " def remove_html(html):\n", + " if not html: return html\n", + " innerText = re.compile('').sub('', html)\n", + " while innerText.find('>') >= 0:\n", + " text = re.compile('<[^<>]+?>').sub('', innerText)\n", + " if text == innerText:\n", + " break\n", + " innerText = text\n", + "\n", + " return innerText.strip()\n", + " d = remove_html(d)\n", + " d = d.replace(\"\\\\(\", \"$\").replace(\"\\\\)\", \"$\")\n", + " d = d.replace(\"\\n\", \"\\n\\n\")\n", + " return d" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "s = \"\"\"\n", + "<p>Soient \\(V\\) un \\(\\mathbb{R}\\)-espace vectoriel et \\(S\\subset V\\) une collection de vecteurs dans \\(V.\\) On dit que \\(S\\) est <em>lin&eacute;airement d&eacute;pendante</em> (ou <em>li&eacute;e</em>) s'il existe des vecteurs distincts \\(v_1,\\ldots,v_r\\in S\\) et des scalaires \\(\\lambda_1,\\ldots,\\lambda_r\\in \\mathbb{R}\\) non tous nuls tels que \\(\\lambda_1v_1+\\cdots+\\lambda_rv_r=0.\\) (Autrement dit, s'il existe une combinaison lin&eacute;aire (non triviale) de vecteurs de \\(S\\) qui se r&eacute;duit au vecteur nul.) S'il n'existe pas de tels vecteurs dans \\(S,\\) alors on dit que \\(S\\) est <em>lin&eacute;airement ind&eacute;pendante</em> (ou <em>libre</em>).</p>\n", + "<h3><span style="text-decoration: underline; color: #ff6600;">REMARQUE 2 :</span></h3>\n", + "<p>Si \\(0\\in S,\\) alors \\(S\\) est li&eacute;e car \\(\\lambda\\cdot 0=0\\) pour tout \\(\\lambda\\in \\mathbb{R}.\\)</p>\n", + "<p>&nbsp;</p>\n", + "</div>\n", + "\"\"\"\n", + "\n", + "print(decode(s))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "from IPython.display import display, Markdown, Latex\n", + "\n", + "display(Markdown(decode(s)))" + ] + } + ], + "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" + } + }, + "nbformat": 4, + "nbformat_minor": 4 +}