diff --git "a/Chapitre 2 - Algebre matricielle/2.3 Matrices carr\303\251es, inversibles.ipynb" "b/Chapitre 2 - Algebre matricielle/2.3 Matrices carr\303\251es, inversibles.ipynb" index 5219ae6..5148533 100644 --- "a/Chapitre 2 - Algebre matricielle/2.3 Matrices carr\303\251es, inversibles.ipynb" +++ "b/Chapitre 2 - Algebre matricielle/2.3 Matrices carr\303\251es, inversibles.ipynb" @@ -1,277 +1,277 @@ { "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# **Concept(s)-clé(s) et théorie**\n", "\n", "### DÉFINITION 1 :\n", "On dit qu'une matrice $A$ est *carrée* si elle est de taille $n\\times n$ pour un certain entier $n\\in \\mathbb{N}^*,$ c'est-à-dire si elle possède le même nombre de lignes et de colonnes. \n", "\n", "Une matrice est dite *inversible* s'il existe une matrice $B\\in \\mathcal{M}_{n\\times n}(\\mathbb{R})$ telle que: \n", "\\begin{equation*}\n", "AB=I_n=BA\n", "\\end{equation*}\n", "où $I_n$ représente la matrice d'identité avec $n$ lignes et $n$ colonnes. Dans ce cas, on dit que $B$ est l'*inverse* de la matrice $A$. On note l'inverse de $A$ par $A^{-1}$.\n", "\n", "**Remarque** Une matrice inversible est forcément carrée car les produits matriciels $AB$ et $BA$ existent et sont égaux (ils valent $I_n$). Pour la définition du produit matriciel, voir [2.2 Multiplication de matrices](./2.2%Multiplication%de%matrices.ipynb).\n", "\n", "---\n", "### DÉFINITION 2 :\n", "Soit $A$ une matrice de taille $m\\times n$ à coefficients réels. La *diagonale principale* de $A$ est la \"ligne oblique\" formée des composantes $(i,i)$ de $A.$\n", "\n", "---\n", "### DÉFINITION 3 :\n", "On dit d'une matrice $A=(a_{ij})\\in \\mathcal{M}_{m\\times n}(\\mathbb{R})$ qu'elle est:\n", "\n", "$\\bullet$ *triangulaire supérieure*  si $a_{ij}=0$ pour tout $i>j$;\n", "\n", "$\\bullet$ *triangulaire inférieure*  si $a_{ij}=0$ pour tout $i\n", " window.PlotlyConfig = {MathJaxConfig: 'local'};\n", " if (window.MathJax) {MathJax.Hub.Config({SVG: {font: \"STIX-Web\"}});}\n", " if (typeof require !== 'undefined') {\n", " require.undef(\"plotly\");\n", " requirejs.config({\n", " paths: {\n", " 'plotly': ['https://cdn.plot.ly/plotly-latest.min']\n", " }\n", " });\n", " require(['plotly'], function(Plotly) {\n", " window._Plotly = Plotly;\n", " });\n", " }\n", " \n", " " ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ " \n", " " ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "import Librairie.AL_Fct as al\n", "import Corrections.corrections as corrections\n", "import numpy as np\n", "from numpy.linalg import *" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### **Exercice 1**\n", "\n", "Soit $A$ la matrice\n", "$$\n", "A=\\begin{pmatrix}\n", "-2 & 4/3 & -1\\\\\n", "0 & 3 & -5\\\\\n", "1/2 & 1 & 1/2\n", "\\end{pmatrix}.\n", "$$\n", "\n", "Trouver une matrice $B$ et une matrice $C$ telles que:\n", "1. $A + B$ soit diagonale\n", "2. $A + C$ soit symétrique mais non diagonale\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Reportez ici le matrices B et C\n", "A=[[-2, 4/3,-1],[0,3,-5],[1/2,1,1/2]]\n", "B=[[0,0,0],[0,0,0],[0,0,0]]\n", "C=[[0,0,0],[0,0,0],[0,0,0]]" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "print('La matrice B entrée est:')\n", "al.printA(B)\n", "print('La matrice C entrée est:')\n", "al.printA(C)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "corrections.Ex1Chapitre2_3(A,B,C)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### **Exemple 1**\n", "\n", "Soit $A$ la matrice carrée $3\\times 3$ donnée par\n", "$$\n", "A=\\begin{pmatrix}\n", "1 & 2 & 3\\\\\n", "0 & -1 & 0\\\\\n", "0 & 2 & 3\n", "\\end{pmatrix}\n", "$$\n", "\n", "Nous allons trouver l'inverse de $A$ en appliquant des oéprations élémentaires à la matrice $(A|I)$ (il s'agit de la matrice $A$ augmentée de la matrice $I$, où $I$ est la matrice identité de la même dimension que $A$). Les opérations élémentaires que nous appliquons à $(A|I)$ sont les suivantes:\n", "1. $L_1-L_3$\n", "2. $(-1)L_2$\n", "3. $L_3-2L_2$\n", "4. $\\dfrac{1}{3}L_3$\n", "\n", "où $L_i$ représente la i-ème ligne de la matrice $(A|I)$. En particulier, nous allons transformer $(A|I)$ en la nouvelle matrice augmentée $(I|\\tilde{A})$. À la place de $A$ nous aurons l'identité $I$ et, en même temps, à la place de $I$ nous aurons une matrice $\\tilde{A}$ de taille $n\\times n$. Cette matrice $\\tilde{A}$ est enfait l'inverse de $A$. Nous avons le schéma suivant\n", "$$\n", "(A|I) \\sim \\quad \\stackrel{\\text{op. élémentaires}}{\\ldots\\ldots\\ldots} \\quad\\sim (I|A^{-1})\n", "$$\n", "\n", "**Remarque** Cet algorithme n'est rien d'autre que l'algorithme de Gauss expliqué dans le chapitre [](). La forme échelonnée réduite de la matrice $A$ sera l'identité $I$. Il s'agira d'une des propriétés des matrices inversibles. Nous pouvons donc reformuler l'algorithme ci-dessus de la manière suivante: appliquer à $(A|I)$ des opérations élémentaires jusqu'à obtenir la forme échelonnée de la matrice $A$ à gauche. L'inverse de la matrice $A$ sera la matirce obtenue à droite. " ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "A=[[1,2,3],[0,-1,0],[0,2,3]]\n", "I=[[1,0,0],[0,1,0],[0,0,1]]\n", "\n", "print(\"Appliquer les opérations élémentaires données pour obtenir l'identité à gauche (la forme échelonnée de A).\\n\"\n", " \"L'inverse de A se trouvera alors à droite, la où il y avait\" \n", " \"à l'origine la matrice identité I.\")\n", "al.printA(A,I)\n", "[i,j,r,alpha]= al.manualEch(A,I)\n", "m=np.concatenate((A,I), axis=1)\n", "MatriceList=[A]\n", "RhSList=[I]\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "m=al.echelonnage(i,j,r,alpha,A,m,MatriceList,RhSList)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "print('La matrice inverse de A est donnée par: ' )\n", "al.printA(inv(A))\n", "print('Le produit entre A et son inverse est en effet égal à: ')\n", "I=np.dot(A,inv(A))\n", "al.printA(I)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### **Exercice 2**\n", "\n", "Soit $A$ la matrice ci-dessous\n", "$$\n", "A=\\begin{pmatrix}\n", "-1 & 0 & 0 \\\\\n", "3 & \\dfrac{1}{2} & 0 \\\\\n", "1 & 2 & 1 \n", "\\end{pmatrix}.\n", "$$\n", "\n", "Laquelle des affirmations ci-dessous est correcte?\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "corrections.Ex2Chapitre2_3()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "[Passez au notebook 2.4: Systèmes d'équations et matrices](2.4%20Systèmes%20d'équations%20et%20matrices.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.7.4" + "version": "3.6.9" } }, "nbformat": 4, "nbformat_minor": 4 } diff --git "a/Chapitre 2 - Algebre matricielle/2.5 Matrices \303\251l\303\251mentaires.ipynb" "b/Chapitre 2 - Algebre matricielle/2.5 Matrices \303\251l\303\251mentaires.ipynb" index 4344abb..6189a09 100644 --- "a/Chapitre 2 - Algebre matricielle/2.5 Matrices \303\251l\303\251mentaires.ipynb" +++ "b/Chapitre 2 - Algebre matricielle/2.5 Matrices \303\251l\303\251mentaires.ipynb" @@ -1,211 +1,325 @@ { "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# **Concept(s)-clé(s) et théorie**\n", "\n", "## Rappel\n", "\n", - "Etant donné une matrice générique $A \\in \\mathcal{M}_{m \\times n}(\\mathbb{R})$, nous définissons les opérations élémentaires de type:\n", - "* (I): échanger deux lignes de matrice A\n", - "* (II): multiplier une ligne de matrice A par un scalaire\n", - "* (III): ajouter à une ligne de matrice A le multiple d'une autre ligne de la même matrice\n", + "Soit une matrice $A \\in \\mathcal{M}_{m \\times n}(\\mathbb{R})$ quelconque, nous définissons les opérations élémentaires de type:\n", + "* (I) échanger deux lignes de la matrice A;\n", + "* (II) multiplier une ligne de la matrice A par un scalaire non nul;\n", + "* (III) ajouter à une ligne de la matrice A le multiple d'une autre ligne de A.\n", "\n", "## Définition\n", - "Une matrice élémentaire (de taille $n \\times n$) est une matrice obtenue en effectuant une (et une seule) opération élémentaire, de type (I), (II) ou (III), sur les lignes de la matrice $I_n$ (i.e. la matrice d'identité de taille $n \\times n$). Concrétement, on adoptera les notations suivantes:\n", + "Une matrice élémentaire (de taille $m \\times m$) est une matrice obtenue en effectuant une (et une seule) opération élémentaire, de type (I), (II) ou (III), sur les lignes de la matrice $I_m$ (i.e. la matrice d'identité de taille $m \\times m$). On adoptera les notations suivantes:\n", "\n", - "* (I) La matrice $T_{ij}$ est la matrice obtenue en échangeant les lignes $i$ et $j$ de $I_n$.\n", - "* (II) La matrice $D_r(\\lambda)$ est la matrice obtenue en multipliant la $r$-ème ligne de $I_n$ par $\\lambda \\in \\mathbb{R}$.\n", - "* (III) La matrice $L_{rs}(\\lambda)$ est la matrice obtenue en ajoutant $\\lambda$ fois la ligne $s$ à la ligne $r$ de $I_n$.\n", + "* (I) la matrice $T_{ij}$ est la matrice obtenue en échangeant les lignes $i$ et $j$ de $I_m$;\n", + "* (II) la matrice $D_r(\\lambda)$ est la matrice obtenue en multipliant la $r$-ème ligne de $I_m$ par $\\lambda \\in \\mathbb{R}$ , $\\lambda\\neq 0$;\n", + "* (III) la matrice $L_{rs}(\\lambda)$ est la matrice obtenue en ajoutant $\\lambda\\in \\mathbb{R}$ fois la ligne $s$ à la ligne $r$ de $I_m$.\n", + "\n", + "**Remarque** Dans les matrices élémentaires de type (II) ($D_r(\\lambda)$) le scalaire $\\lambda$ **doit être différent de zéro**. Cette condition sur $\\lambda$ n'est pas nécessaire dans les matrices élémentaires de type (III).\n", "\n", "## Théorème\n", - "Soient $A \\in \\mathcal{M}_{m \\times n}(\\mathbb{R})$ une matrice arbitraire et $E \\in \\mathcal{M}_{m \\times m}(\\mathbb{R})$ une matrice élémentaire de type (I), (II) ou (III). Alors $EA$ est la matrice obtenue en effectuant sur les lignes de $A$ l'opération de type (I), (II) ou (III), qui définit la matrice $E$.\n", + "Soient $A \\in \\mathcal{M}_{m \\times n}(\\mathbb{R})$ une matrice quelconque et $E \\in \\mathcal{M}_{m \\times m}(\\mathbb{R})$ une matrice élémentaire de type (I), (II) ou (III). Alors $EA$ est la matrice obtenue en effectuant sur les lignes de $A$ l'opération de type (I), (II) ou (III) utilisée pour former $E$.\n", "\n", "## Corollaire\n", - "Les matrices élémentaires sont inversibles. On a en effet:\n", - "* (I): $T_{ij}^{-1} = T_{ji} = T_{ij}$\n", - "* (II): $D_r(\\lambda)^{-1} = D_r(\\lambda^{-1})$\n", - "* (III): $L_{rs}(\\lambda)^{-1} = L_{rs}(-\\lambda)$" + "Les matrices élémentaires sont inversibles. En effet, on trouve facilement leur inverse respectif:\n", + "* (I) $T_{ij}^{-1} = T_{ji} = T_{ij}$;\n", + "* (II) $D_r(\\lambda)^{-1} = D_r(\\lambda^{-1})$;\n", + "* (III)$L_{rs}(\\lambda)^{-1} = L_{rs}(-\\lambda)$;" ] }, { "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 Librairie.AL_Fct as al\n", "import Corrections.corrections as corrections\n", "import numpy as np\n", "from numpy.linalg import *\n", "from ipywidgets import interact_manual" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Exercice 1\n", "Soient les deux matrices élémentaires ci-dessous.\n", "$$\n", "E_1=\\begin{pmatrix}\n", "1 & 0 & 0 & 0\\\\\n", "0 & 1 & 0 & -6 \\\\\n", "0 & 0 & 1 &0 \\\\\n", "0 & 0 & 0 & 1\n", "\\end{pmatrix}\\hspace{3cm}\n", "E_2=\\begin{pmatrix}\n", "0 & 0 & 1 & 0\\\\\n", "0 & 1 & 0 & 0 \\\\\n", "1 & 0 & 0 &0 \\\\\n", "0 & 0 & 0& 1\n", "\\end{pmatrix}\n", "$$\n", "**ÉTAPE 1**: Laquelle des affirmations ci-dessous est correcte?\n" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 2, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "8edb8a177211473ca6bfcad2adaec45f", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "interactive(children=(Checkbox(value=False, description='\\\\(E_1E_2\\\\) multiplie la ligne 4 par -6 et échange l…" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], "source": [ "corrections.Ex1aChapitre2_5()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**ÉTAPE 2**: Donner l'inverse de $E_1E_2$\n", "\n", "**Aide** \n", "Considérez deux matrices inversibles $A, B \\in M_{n \\times n}(\\mathbb{R})$; alors $$(AB)^{- 1}=B^{- 1}A^{- 1}$$\n", "\n", "*Observation*: Inverser l'effet de $n$ opérations élémentaires consécutives consiste à appliquer l'inverse de chaque opération, de la dernière à la première." ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 5, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "La matrice inverse entrée est\n" + ] + }, + { + "data": { + "text/latex": [ + "$\\left(\\begin{array}{cccc} 1 & 0 & 0 & 0 \\\\0 & 1 & 0 & 0 \\\\0 & 0 & 1 & 0 \\\\0 & 0 & 0 & 1 \\end{array}\\right)$" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/latex": [ + "C'est faux." + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], "source": [ - "print('Insérez ici la valeur de la matrice inverse')\n", + "#Insérez ci-dessous la valeur de la matrice inverse\n", "inverse= [[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]]\n", + "\n", + "print('La matrice inverse entrée est')\n", + "al.printA(inverse)\n", "corrections.Ex1bChapitre2_5(inverse)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Exercice 2\n", "Soient $A$ et $B$ les deux matrices ci-dessous. \n", "\n", "$$\n", "A=\\begin{pmatrix}\n", "-2 &1& 4\\\\\n", "1 & 0 & 2\\\\\n", "-1 & -\\dfrac{1}{2} & 3\n", "\\end{pmatrix}, \\hspace{2em}\n", "B=\\begin{pmatrix}\n", "-1 & -\\dfrac{1}{2} & 3 \\\\\n", "5 & 2 & -10\\\\\n", "-10 & 5 & 20\n", "\\end{pmatrix}\n", "$$" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 8, "metadata": {}, "outputs": [], "source": [ "A=[[-2,1,4],[1,0,2],[-1, -1/2 , 3]]\n", "B=[[-1, -1/2, 3],[5, 2, -10],[-10,5,20]]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "On passe de la matrice $A$ à la matrice $B$ à l'aide de trois matrices élémentaires $T_{ij}$, $D_{r}(\\lambda)$ et $L_{rs}(\\lambda)$\n", + "On passe de la matrice $A$ à la matrice $B$ à l'aide de trois matrices élémentaires $T_{ij}$, $D_{r}(\\lambda)$ et $L_{rs}(\\mu)$\n", "$$\n", - "L_{rs}(\\lambda) \\cdot D_{r}(\\lambda)\\cdot T_{ij}\\cdot A =B\n", + "L_{rs}(\\mu) \\cdot D_{r}(\\lambda)\\cdot T_{ij}\\cdot A =B\n", "$$\n", "\n", "**ÉTAPE 1**: Trouvez les 3 matrices et insérez-les ci-dessous." ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 15, "metadata": {}, "outputs": [], "source": [ - "T=[[1,0,0],[0,1,0],[0,0,1]]\n", - "D=[[1,0,0],[0,1,0],[0,0,1]]\n", - "L=[[1,0,0],[0,1,0],[0,0,1]]" + "T=[[0,0,1],[0,1,0],[1,0,0]]\n", + "D=[[1,0,0],[0,1,0],[0,0,5]]\n", + "L=[[1,0,0],[-4,1,0],[0,0,1]]" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 16, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/latex": [ + "C'est correct!" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], "source": [ "corrections.Ex2aChapitre2_5(A, B, T, D, L)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "**ÉTAPE 2**: Donner l'inverse de $L_{rs}(\\lambda) \\cdot D_{r}(\\lambda)\\cdot T_{ij}$" + "**ÉTAPE 2**: Donner l'inverse de $L_{rs}(\\mu) \\cdot D_{r}(\\lambda)\\cdot T_{ij}$" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "print('Insérez ici la valeur de la matrice inverse')\n", "inverse= [[1,0,0],[0,1,0],[0,0,1]]\n", "corrections.Ex2bChapitre2_5(inverse)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "[Passez au notebook 2.6-7: Critéres d'inversibilité](2.6-2.7%20Critères%20d'inversibilité.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.7.4" + "version": "3.6.9" } }, "nbformat": 4, - "nbformat_minor": 2 + "nbformat_minor": 4 } diff --git "a/Chapitre 2 - Algebre matricielle/2.6-2.7 Crit\303\250res d'inversibilit\303\251.ipynb" "b/Chapitre 2 - Algebre matricielle/2.6-2.7 Crit\303\250res d'inversibilit\303\251.ipynb" index f3eca54..6aedfb8 100644 --- "a/Chapitre 2 - Algebre matricielle/2.6-2.7 Crit\303\250res d'inversibilit\303\251.ipynb" +++ "b/Chapitre 2 - Algebre matricielle/2.6-2.7 Crit\303\250res d'inversibilit\303\251.ipynb" @@ -1,272 +1,376 @@ { "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# **Concept(s)-clé(s) et théorie**\n", "\n", "## PREMIER CRITÈRE D'INVERSIBILITÉ \n", "Une matrice $A \\in \\mathcal{M}_{n \\times n}(\\mathbb{R})$ est inversible si et seulement si le système homogène $Ax=0$ possède une solution unique, à savoir, la solution triviale.\n", "\n", "## COROLLAIRE DU PREMIER CRITÈRE D'INVERSIBILITÉ \n", "Soit $A \\in \\mathcal{M}_{n \\times n}(\\mathbb{R})$ alors les deux affirmations suivantes sont vérifiées.\n", "\n", "1. La matrice $A$ est inversible si et seulement s'il existe $B \\in \\mathcal{M}_{n \\times n}(\\mathbb{R})$ telle que $BA = I_n$.\n", "2. La matrice $A$ est inversible si et seulement s'il existe $C \\in \\mathcal{M}_{n \\times n}(\\mathbb{R})$ telle que $AC = I_n$.\n", "\n", "## RAPPEL: ALGORITHME POUR TROUVER L'INVERSE D'UNE MATRICE DONNÉE\n", "Soit $A \\in \\mathcal{M}_{n \\times n}(\\mathbb{R})$ une matrice carrée. Afin de déterminer si $A$ est inversible et de calculer son inverse (lorsque c'est possible), on procède comme suit :\n", "\n", "1. Ecrire les matrices $A$ et $I_n$ l'une à côté de l'autre, formant ainsi une nouvelle matrice de taille $n \\times 2n$\n", "2. Opérer sur les lignes de cette matrice ainsi obtenue, afin de réduire le côté gauche à $I_n$\n", "3. Si l'on y arrive, alors $A$ est inversible et son inverse $A^{-1}$ est donnée par la matrice à droite." ] }, { "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 Librairie.AL_Fct as al\n", "import Corrections.corrections as corrections\n", "from ipywidgets import interact_manual\n", "import plotly as py\n", "import plotly.graph_objs as go\n", "from ipywidgets import interactive, HBox, VBox, widgets, interact, FloatSlider\n", "import numpy as np" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### EXERCICE 1\n", - "Considérez le système linéaire générique $Ax=b$ avec $A \\in \\mathcal{M}_{n \\times n}(\\mathbb{R})$ et $b \\in \\mathcal{M}_{n \\times 1}(\\mathbb{R})$; marquez celles des déclarations suivantes qui pourraient être vraies pour certaines valeurs de $A$ et $b$." + "Considérez le système linéaire générique $Ax=b$ avec $A \\in \\mathcal{M}_{n \\times n}(\\mathbb{R})$ et $b \\in \\mathcal{M}_{n \\times 1}(\\mathbb{R})$; cochez les déclarations suivantes qui pourraient être vraies pour certaines valeurs de $A$ et $b$." ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 2, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "986f8c33625f43b49af739289bc54bb6", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "interactive(children=(Checkbox(value=False, description='$A^{-1}$ existe et le système admet plusieurs solutio…" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], "source": [ "corrections.Ex1Chapitre2_6_7()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## EXERCICE 2 ##\n", - "Mark those of the following matrices which are invertible.\n", + "Cochez, parmi les matrices suivantes, celles qui sont inversibles.\n", "\\begin{equation}\n", "A_1 = \n", "\\begin{pmatrix}\n", "2 & 0 & 1\\\\\n", "0 & 6 & 4 \\\\\n", "2 & 2 & 1\n", "\\end{pmatrix} \\qquad A_2 = \n", "\\begin{pmatrix}\n", "3 & -7 & 0\\\\\n", "1 & 0 & 1\\\\\n", "-5 & 35/3 & 0\n", "\\end{pmatrix} \\qquad A_3 = \n", "\\begin{pmatrix}\n", "2 & 1 & -1\\\\\\\n", "2 & -5 & 4\\\\\n", "6 & -3 & 2\n", "\\end{pmatrix}\n", "\\end{equation}" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "corrections.Ex2Chapitre2_6_7()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**Vous pouvez vous aider à déterminer si les matrices suivantes sont inversibles ou non en exécutant les cellules suivantes et en calculant manuellement leurs inverses (éventuelles)**" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "A=[[2,0,1], [0,6,4], [2,2,1]]\n", "I=[[1,0,0],[0,1,0],[0,0,1]]\n", "print('Vous allez échelonner la matrice augmenteé avec la matrice identité')\n", "al.printA(A,I)\n", "[i,j,r,alpha]= al.manualEch(A,I)\n", "m=np.concatenate((A,I), axis=1)\n", "MatriceList=[A]\n", "RhSList=[I]\n", "print('\\033[1mExecutez la ligne suivante pour effectuer l\\'opération choisie \\033[0m')" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "m=al.echelonnage(i,j,r,alpha,A,m,MatriceList,RhSList)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## EXERCISE 3 ##\n", "Considéz le système linéaire générique $Ax = b$, avec:\n", "\\begin{equation}\n", "A = \n", "\\begin{pmatrix}\n", "2 & -\\alpha\\\\\n", "\\beta & -4 \\\\\n", "\\end{pmatrix} \\qquad b = \n", "\\begin{pmatrix}\n", "1\\\\\n", "-2\\\\\n", "\\end{pmatrix}\n", "\\end{equation}\n", - "Identifiez les valeurs des paramètres $\\alpha$ et $\\beta$ pour lesquels $A$ n'est pas inversible et marquez celles des déclarations suivantes qui sont correctes." + "Identifiez les valeurs des paramètres $\\alpha$ et $\\beta$ pour lesquels $A$ n'est pas inversible et cochez les déclarations suivantes qui sont correctes." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "with alpha =4 and beta=1, we have one unique sol.??why is h wrong?" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 3, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "99b5682615d34a02b7c13c771a1cf109", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "interactive(children=(Checkbox(value=False, description=\"Si $\\\\alpha = 4$ et $\\\\beta = 2$, alors $A$ n'est pas…" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], "source": [ "corrections.Ex3Chapitre2_6_7()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**AIDE: vous pouvez exécuter la cellule interactive suivante pour mieux visualiser le système paramétré**" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 5, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "6e1c223a65cf47f7becc5d3b12b93f57", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "VBox(children=(FigureWidget({\n", + " 'data': [{'name': 'd) Droite 1',\n", + " 'type': 'scatter',\n", + " …" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], "source": [ "np.seterr(divide='ignore', invalid='ignore')\n", "\n", "A=[[2, 0], [0, -4]] # we initialize the problem. The values of alpha and beta are fixed\n", "b=[1, -2]\n", "\n", "m=len(A)\n", "MatCoeff = [A[i]+[b[i]]for i in range(m)] #becomes augmented matrix\n", "MatCoeff=np.array(MatCoeff)\n", "data=[]\n", "x=np.linspace(-15,15,101)\n", "y=np.linspace(-10,10,101)\n", "MatCoeff=np.array(MatCoeff)\n", "for i in range(len(MatCoeff)):\n", " trace=go.Scatter(x=x, y= (MatCoeff[i,2]-MatCoeff[i,0]*x)/MatCoeff[i,1], name='d) Droite %d'%(i+1))\n", " data.append(trace)\n", " \n", "f=go.FigureWidget(data=data,\n", " layout=go.Layout(xaxis=dict(\n", " range=[-15, 15]\n", " ),\n", " yaxis=dict(\n", " range=[-10, 10]\n", " ) ) \n", ")\n", "\n", "def update_y(alpha, beta):\n", " MatCoeff= [[2, -alpha, 1],[beta, -4, -2]]\n", " MatCoeff=np.array(MatCoeff)\n", " if MatCoeff[0,1] == 0:\n", " MatCoeff[0,1] += 1e-3\n", " f.data[0].y = (MatCoeff[0,2]-MatCoeff[0,0]*x)/MatCoeff[0,1]\n", " if MatCoeff[1,1] == 0:\n", " MatCoeff[1,1] += 1e-3\n", " f.data[1].y=(MatCoeff[1,2]-MatCoeff[1,0]*x)/MatCoeff[1,1]\n", "\n", "freq_slider = interactive(update_y, alpha=(-20, 20, 1/2), beta=(-20, 20, 1/2))\n", "\n", "vb = VBox((f, freq_slider))\n", "vb.layout.align_items = 'center'\n", "vb" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## EXERCISE 4\n", "\n", "Considérez les matrices suivantes:\n", "\\begin{equation}\n", "A = \n", "\\begin{pmatrix}\n", "0.5 & a & 1\\\\\n", "0 & 2 & -1\\\\\n", "-2 & 1 & b\n", "\\end{pmatrix}; \\qquad B = \n", "\\begin{pmatrix}\n", "-6 & -2 & -2\\\\\n", "4 & 2 & 1\\\\\n", "8 & 3 & 2\n", "\\end{pmatrix}\n", "\\end{equation}\n", "\n", "Trouvez les valeurs des paramètres $a$ et $b$ pour lesquels $A$ et $B$ sont l'un l'inverse de l'autre." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "corrections.Ex4Chapitre2_6_7()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "[Passez au notebook 2.8-2.9: Décomposition LU (existance et algorithm)](2.8-2.9%20Décomposition%20LU%20(existance%20et%20algorithm).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.7.4" + "version": "3.6.9" } }, "nbformat": 4, - "nbformat_minor": 2 + "nbformat_minor": 4 }