diff --git "a/Chapitre 1 - Systemes equations lineaires/1.2. Nombre de solutions d'un syst\303\250me.ipynb" "b/Chapitre 1 - Systemes equations lineaires/1.2. Nombre de solutions d'un syst\303\250me.ipynb" index f2f0de4..d464c84 100644 --- "a/Chapitre 1 - Systemes equations lineaires/1.2. Nombre de solutions d'un syst\303\250me.ipynb" +++ "b/Chapitre 1 - Systemes equations lineaires/1.2. Nombre de solutions d'un syst\303\250me.ipynb" @@ -1,595 +1,595 @@ { "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Concept(s)-clé(s) et théorie\n", "\n", "On considère un système d'équations linéaires aux inconnues $x_1,\\ldots,x_n$\n", "\n", "$$S=\\left\\{\\begin{array}{ccccccc}\n", "a_{11}x_1 &+a_{12}x_2 & + &\\cdots &+a_{1n}x_n &= &b_1 \\\\\n", "a_{21}x_1 &+a_{22}x_2 & + &\\cdots &+a_{2n}x_n &= &b_2 \\\\\n", "\\vdots & & & &\\vdots & \\vdots &\\vdots \\\\\n", "a_{m1}x_1 &+a_{m2}x_2 & + &\\cdots &+a_{mn}x_n &= &b_m\n", "\\end{array},\\right. $$\n", "\n", "où $a_{ij},b_i\\in \\mathbb{R}$ pour tout $1\\leq i\\leq m$ et tout $1\\leq j\\leq n.$ \n", "\n", "---\n", "Un système d'équations linéaires à coefficients réels satisfait précisément une seule des conditions suivantes.\n", "\n", "1. Le système ne possède aucune solution.\n", "\n", "2. Le système possède une solution unique.\n", "\n", "3. Le système possède une infinité de solutions.\n", "\n", "\n", "\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import Librairie.AL_Fct as al\n", "import numpy as np\n", "import matplotlib.pyplot as plt\n", "import plotly as py\n", "import plotly.graph_objs as go\n", "import pandas as pd\n", "import random\n", "from IPython.core.magic import register_cell_magic\n", "from IPython.display import HTML, display\n", "from ipywidgets import interactive, HBox, VBox, widgets, interact, FloatSlider\n", "\n", "py.offline.init_notebook_mode(connected=True)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### EXEMPLE 1\n", "\n", "Nous allons travailler avec un système de deux inconnues et deux équations:\n", "\n", "$$\n", "\\begin{cases}\n", "a_{11}x_1 + a_{12}x_2=b_1\\\\\n", "a_{21}x_1 + a_{22}x_2=b_2.\n", "\\end{cases}\n", "$$\n", "\n", "On rappelle qu'on *la syntaxe suivante pour entrer les coefficients du système*\n", "\n", "\\begin{align*}\n", "A&=\\quad [\\quad [ a_{11} , a_{12}, \\ldots, a_{1n} ], \\quad [ a_{21}, a_{22}, \\ldots, a_{2n}]\\quad, \\ldots , \\quad[a_{m1}, a_{m2}, \\ldots, a_{mn}]\\quad]\\\\\n", "b&=\\quad [\\quad b_1, b_2, \\ldots, b_m \\quad]\n", "\\end{align*}\n", "\n", "---\n", "Entrer le système ci-dessous - ou n'importe quel système de votre choix. Après avoir étudié les deux droites, entrer une solution du système\n", "\n", "$$\n", "\\begin{cases}\n", "-2x_1 + x_2=2\\\\\n", "2x_1 -2x_2=1.\n", "\\end{cases}\n", "$$\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "al.bgc('seashell')\n", "#Par défaut, les coefficients sont fixés à 1 et n=2, m=2\n", "\n", "A = [ [-2,1] , [2,-2]]\n", "b = [2,1]" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "al.printSyst(A,b)\n", "\n", "al.Plot2DSys(-7,7,15,A,b)\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "al.bgc('seashell')\n", "\n", "alpha=[-2.5, -3]\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "al.SolOfSyst(alpha, A,b)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### **EXERCICE 1**\n", "\n", "Pour chacun des cas ci-dessous, déterminer la/les solution(s) des systèmes en vous aidant du graphe. \n", "\n", " $$ \n", "a)\\quad \\begin{cases}\n", "\\dfrac{3}{2}x_1 - 2x_2&=0\\\\\n", "-3x_1 + 5 x_2&=3\n", "\\end{cases} \\hspace{1cm} b) \\quad \\begin{cases}\n", "x_1 - x_2&=\\phantom{-}2\\\\\n", "-3x_1 - 2x_2&=-1\\\\\n", "2x_1 + 3x_2&=\\phantom{-}4\n", "\\end{cases}\n", "$$\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "al.bgc('seashell')\n", "#Par défaut, les coefficients sont fixés à 1 \n", "#Attention d'adapter les valeurs ci-dessous pour a) et b)\n", "\n", "A = [[1, -1], [-3, -2],[2,3]]\n", "b =[2,-1,4]\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "al.printSyst(A,b)\n", "al.Plot2DSys(-7,7,15,A,b)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "al.bgc('seashell')\n", "#Entrer une solution du système\n", "alpha=[1,1]" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "al.SolOfSyst(alpha, A,b)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### **EXERCICE 2**\n", "\n", "Pour chacun des cas ci-dessous, déterminer, à l'aide des graphes interactifs, la/les solution(s) des systèmes. \n", "\n", "$$ \n", "a)\\quad \\begin{cases}\n", "x_1 - x_2 + 2x_3 &=0\\\\\n", "-3x_1 &=1\\\\\n", "2x_1 + 5x_2 &=-2\n", "\\end{cases} \\hspace{1cm} b) \\quad \\begin{cases}\n", "x_1 + x_2 -2x_3 &=0\\\\\n", "3x_2 - x_3 &=1\\\\\n", "-2x_1 -2x_2 + 4x_3 &=2\n", "\\end{cases} \\hspace{1cm} c) \\quad \\begin{cases}\n", "x_1 + x_2 -2x_3 &=-1\\\\\n", "3x_2 - x_3 &=1\\\\\n", "-2x_1 -2x_2 + 4x_3 &=2\n", "\\end{cases} \\hspace{1cm}\n", "$$\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "al.bgc('seashell')\n", "#Par défaut, les coefficients sont fixés à 1 \n", "\n", "A = [[ 1, 1, 1] ,[1, 1, 1] ,[1, 1, 1]]\n", "b= [1, 1, 1]" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "al.printSyst(A,b)\n", "al.Plot3DSys(-10,10,100,A,b)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "alpha = [1, 1, 1]\n", "al.SolOfSyst(alpha, A,b)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### **EXERCICE 3**\n", "\n", "À l'aide des graphes interactifs ci-dessous, trouver les valeurs des paramètres $h$ et $k$ pour que les systèmes a), b), c) et d) admettent, si possible,\n", "1. aucune solution\n", "2. une unique solution\n", "3. une infinité de solution \n", "\n", "\n", "$$ \n", "a)\\begin{cases}\n", "x_1 +5 x_2&=h\\\\\n", "-2x_1 -10 x_2&=18\n", "\\end{cases} \\hspace{1cm} b) \\begin{cases}\n", "hx_1 + x_2&=3\\\\\n", "-2x_1 - x_2&=-1\n", "\\end{cases}\\hspace{1cm} c) \\begin{cases}\n", "3x_1 + hx_2&=1\\\\\n", "x_1 + 3x_2&=h\n", "\\end{cases}\\hspace{1cm} d) \\begin{cases}\n", "kx_1 + x_2&=h\\\\\n", "3x_1 -5x_2&=2\n", "\\end{cases}\n", "$$" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## CASE a)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "A=[[1, 5], [-2, -10]] # we initialize the problem. The values of h and k must be fixed to one specific value here\n", "b=[0, 18]\n", "al.printSyst(A, b) # the system printed below shows the values of h and k inserted here!!\n", "\n", "data=[]\n", "x=np.linspace(-5,5,11)\n", "m=len(A)\n", "MatCoeff = [A[i]+[b[i]]for i in range(m)] #becomes augmented matrix\n", "MatCoeff=np.array(MatCoeff)\n", "\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='a) Droite %d'%(i+1))\n", " data.append(trace)\n", "\n", "f=go.FigureWidget(data=data,\n", " layout=go.Layout(xaxis=dict(\n", " range=[-5, 5]\n", " ),\n", " yaxis=dict(\n", " range=[-10, 10]\n", " ) )\n", "\n", ")\n", "\n", "def update_y(h):\n", " MatCoeff = [[1, 5, h]]\n", " MatCoeff=np.array(MatCoeff)\n", " f.data[0].y=(MatCoeff[0,2]-MatCoeff[0,0]*x)/MatCoeff[0,1]\n", " \n", "freq_slider = interactive(update_y, h=(-15, 15, 1/2)) \n", "vb = VBox((f, freq_slider))\n", "vb.layout.align_items = 'center'\n", "vb" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## CASE b)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "A=[[1, 1], [-2,-1]] # we initialize the problem. The value of h is fixed\n", "b=[3, -1]\n", "al.printSyst(A, b) # the system printed below shows the value of h inserted here\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(-5,5,11)\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='b) Droite %d'%(i+1))\n", " data.append(trace)\n", " \n", "f=go.FigureWidget(data=data,\n", " layout=go.Layout(xaxis=dict(\n", " range=[-5, 5]\n", " ),\n", " yaxis=dict(\n", " range=[-10, 10]\n", " ) )\n", " \n", ")\n", "\n", "def mat(k):\n", " h=k\n", " MatCoeff=[[h,1,3]]\n", " return MatCoeff\n", "def update_y(h):\n", " MatCoeff= mat(h)\n", " MatCoeff=np.array(MatCoeff)\n", " f.data[0].y=(MatCoeff[0,2]-MatCoeff[0,0]*x)/MatCoeff[0,1]\n", " \n", "freq_slider = interactive(update_y, h=(-10, 10, 1/2)) \n", "\n", "vb = VBox((f, freq_slider))\n", "vb.layout.align_items = 'center'\n", "vb" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## CASE c)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "A=[[3, 1], [1, 3]] # we initialize the problem. The values of h and k are fixed\n", "b=[1, 1]\n", "al.printSyst(A, b) # the system printed below shows the values of h and k inserted here\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(-25,25,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='c) Droite %d'%(i+1))\n", " data.append(trace)\n", " \n", "f=go.FigureWidget(data=data,\n", " layout=go.Layout(xaxis=dict(\n", " range=[-25, 25]\n", " ),\n", " yaxis=dict(\n", " range=[-50, 50]\n", " ) )\n", " \n", ")\n", "\n", "def mat(h):\n", " MatCoeff= [[h, 3, 1],[3, 1, h] ]\n", " return MatCoeff\n", "\n", "def update_y(h):\n", " MatCoeff= mat(h)\n", " MatCoeff=np.array(MatCoeff)\n", " f.data[0].y=(MatCoeff[0,2]-MatCoeff[0,0]*x)/MatCoeff[0,1]\n", " f.data[1].y=(MatCoeff[1,2]-MatCoeff[1,0]*x)/MatCoeff[1,1]\n", "\n", "freq_slider = interactive(update_y, h=(-20, 20, 1)) \n", "\n", "vb = VBox((f, freq_slider))\n", "vb.layout.align_items = 'center'\n", "vb" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## CASE d)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "A=[[1, 1], [3, -5]] # we initialize the problem. The values of h and k are fixed\n", "b=[1, 2]\n", "al.printSyst(A, b) # the system printed below shows the values of h and k inserted here\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", "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", "\n", "def update_y(h, k):\n", " MatCoeff= [[k, 1, h],[2, -5, 5] ]\n", " MatCoeff=np.array(MatCoeff)\n", " f.data[0].y=(MatCoeff[0,2]-MatCoeff[0,0]*x)/MatCoeff[0,1]\n", "\n", " \n", " f.data[1].y=(MatCoeff[1,2]-MatCoeff[1,0]*x)/MatCoeff[1,1]\n", "\n", "freq_slider = interactive(update_y, h=(-10, 10, 1/10),k=(-10, 10, 1))\n", "\n", "vb = VBox((f, freq_slider))\n", "vb.layout.align_items = 'center'\n", "vb" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "## Exercice 4\n", + "### **EXERCICE 4**\n", "\n", "À l'aide des graphes interactifs ci-dessous, trouver les valeurs des paramètre $h$ pour que le système admette, si possible,\n", "1. aucune solution\n", "2. une unique solution\n", "3. une infinité de solution \n", "\n", "$$ \n", "\\begin{cases}\n", "hx_1 -2 x_2 &=4\\\\\n", "-2x_1 +h x_2&=-4\\\\\n", "x_1 - x_2 &=h\n", "\\end{cases} \\hspace{1cm}\n", "$$" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "np.seterr(divide='ignore', invalid='ignore')\n", "\n", "A=[[1, -2], [-2, 1], [1, -1]] # we initialize the problem. The values of h and k are fixed\n", "b=[4, -4, 0]\n", "al.printSyst(A, b) # the system printed below shows the values of h and k inserted here\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(-25,25,101)\n", "MatCoeff=np.array(MatCoeff)\n", "for i in range(len(MatCoeff)):\n", " if MatCoeff[i,1] == 0:\n", " MatCoeff[i,1] += 1e-3\n", " trace=go.Scatter(x=x, y=(MatCoeff[i,2]-MatCoeff[i,0]*x)/MatCoeff[i,1], name='c) Droite %d'%(i+1))\n", " data.append(trace)\n", " \n", "f=go.FigureWidget(data=data,\n", " layout=go.Layout(xaxis=dict(\n", " range=[-25, 25]\n", " ),\n", " yaxis=dict(\n", " range=[-100, 100]\n", " ) )\n", " \n", ")\n", "\n", "def mat(h):\n", " MatCoeff= [[h, -2, 4], [-2, h, -4], [1, -1, h]]\n", " return MatCoeff\n", "\n", "def update_y(h):\n", " MatCoeff= mat(h)\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", " if MatCoeff[2,1] == 0:\n", " MatCoeff[2,1] += 1e-3\n", " f.data[2].y=(MatCoeff[2,2]-MatCoeff[2,0]*x)/MatCoeff[2,1]\n", "\n", "freq_slider = interactive(update_y, h=(-20, 20, 0.5)) \n", "\n", "vb = VBox((f, freq_slider))\n", "vb.layout.align_items = 'center'\n", "vb" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "[Passez au notebook du chapitre 1.3-4: Notation Matricielle](./1.3-4.%20Notation%20Matricielle.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.9" } }, "nbformat": 4, "nbformat_minor": 4 } diff --git "a/Chapitre 1 - Systemes equations lineaires/1.5-6. Matrices Echelonn\303\251es.ipynb" "b/Chapitre 1 - Systemes equations lineaires/1.5-6. Matrices Echelonn\303\251es.ipynb" index 73f0890..dc76cdb 100644 --- "a/Chapitre 1 - Systemes equations lineaires/1.5-6. Matrices Echelonn\303\251es.ipynb" +++ "b/Chapitre 1 - Systemes equations lineaires/1.5-6. Matrices Echelonn\303\251es.ipynb" @@ -1,486 +1,391 @@ { "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Concept(s)-clé(s) \n", "\n", "DEFINITION 1\n", "\n", "Soit $A$ une matrice de taille $m\\times n$ à coefficients réels. On dit que $A$ est *échelonnée* si l'indice de colonne du premier élément non-nul de chaque ligne est supérieur à l'indice de colonne du premier élément non-nul de la ligne précédente. C'est à dire que le nombre de zéros pécédant le premier élément non-nul une ligne augmente ligne par ligne, jusqu'à obtenir peut-être des lignes ne contenant que des zéros.\n", "\n", "Le premier élément non-nul de chaque ligne s'appelle un *pivot*, on les dénote par $\\color{red}\\oplus$. Les éléments quelconques sont dénotés par $*$. Attention $\\color{red}\\oplus$ est un élément non-nul, alors que $*$ peut être un élément nul. Les colonnes possédant un pivots s'appellent des *colonnes pivots*.\n", "\n", "Voici un exemple d'une telle matrice $A$ (ici de taille $7\\times 9$). Les colonnes $1,3,4,6$ et $9$ sont des colonnes pivots.\n", "\n", "$$\n", "A=\\begin{pmatrix}\n", "\\color{red}\\oplus & * & * & * & * & * & * &* & * \\\\\n", "0 & 0 &\\color{red}\\oplus & *& * & * & * & *&* \\\\\n", "0 & 0 & 0 & \\color{red}\\oplus& *& * &* & *& *\\\\\n", "0 & 0 & 0 & 0 & 0 &\\color{red}\\oplus & * & * & *\\\\\n", "0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 &\\color{red}\\oplus\\\\\n", "0 & 0 & 0 & 0 & 0& 0 & 0 &0&0\\\\\n", "0 & 0 & 0 & 0 & 0& 0 & 0 &0&0\n", "\\end{pmatrix}\n", "$$\n", "\n", "DEFINITON 2\n", "\n", "Soit $A$ une matrice de taille $m\\times n$ à coefficients réels. On dit que $A$ est *échelonnée réduite* si $A$ est échelonnée avec les propriétés suivantes\n", "1. tous ses pivots valent $1$ ($\\color{red}\\oplus=1$ dans ce cas)\n", "2. les pivots sont les seules valeurs non-nulles de leur colonne pivot (en dessous et en dessous d'un pivot il n'y a que des zéros).\n", "\n", "Voici un exemple d'une telle matrice $A$ (ici de taille $7\\times 9$). Les colonnes $1,3,4,6$ et $9$ sont des colonnes pivots et ne contiennent qu'un seul élément non-nul (les pivots valant 1).\n", "\n", "\n", "$$\n", "A=\\begin{pmatrix}\n", "\\require{enclose}\\enclose{circle}[mathcolor=\"red\"]{1} & * & 0 & 0 & * & 0 & * &* &0 \\\\\n", "0 & 0 &\\require{enclose}\\enclose{circle}[mathcolor=\"red\"]{1} &0& * & 0 & * & *&0 \\\\\n", "0 & 0 & 0 &\\require{enclose}\\enclose{circle}[mathcolor=\"red\"]{1}& *& 0 &* & *& 0\\\\\n", "0 & 0 & 0 & 0 & 0 &\\require{enclose}\\enclose{circle}[mathcolor=\"red\"]{1} & * & * & 0\\\\\n", "0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 &\\require{enclose}\\enclose{circle}[mathcolor=\"red\"]{1}\\\\\n", "0 & 0 & 0 & 0 & 0& 0 & 0 &0&0\\\\\n", "0 & 0 & 0 & 0 & 0& 0 & 0 &0&0\n", "\\end{pmatrix}\n", "$$\n" ] }, { "cell_type": "code", - "execution_count": 1, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "data": { - "text/html": [ - " \n", - " " - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/html": [ - " \n", - " " - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], + "outputs": [], "source": [ "import Librairie.AL_Fct as al\n", "import Corrections.corrections as corrections\n", "import numpy as np\n", "import ipywidgets as widgets\n", "import random\n", "\n", "from ipywidgets import interact, interactive, fixed, interact_manual" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### **EXERCICE 1**\n", "Parmi les matrices ci-dessous, indiquez lesquelles sont sous formes échelonnées et échelonnées réduites.\n", "\n", "$$\n", "A=\\begin{pmatrix}\n", "1 & 0 & 0 &1\\\\\n", "0 & 1 & 1 & 0\\\\\n", "0 & 1 & 0 & 3\\\\\n", "0 & 0 & 1 & 0\n", "\\end{pmatrix}\\hspace{1cm}\n", "B=\\begin{pmatrix}1&1& 0 & 0 & 1\\\\\n", " 0& 0 &1 &0 &1\\\\\n", " 0 & 0& 0& 0& 0\\\\\n", " 0 & 0 & 0 & 1 & 0\n", "\\end{pmatrix}\\hspace{1cm}\n", "C=\\begin{pmatrix}\n", "1& 0 & 0 & 2\\\\\n", "0 & 1 & 0 & -2\\\\\n", "0 & 0 & -1 & 0 \\\\\n", "0 & 0 & 0 & 0\n", "\\end{pmatrix}\n", "\\hspace{1cm}\n", "D=\\begin{pmatrix}\n", "0 & 1 & 1 & 0 & 0 & 1\\\\\n", "0 & 0 & 0 & 1 & 0 & 1\\\\\n", "0 &0 &0 &0 &1 & 1\n", "\\end{pmatrix}\n", "\\hspace{1cm}\n", "E=\\begin{pmatrix}1 & 1 & 0 \\\\\n", "0 & 2 &0 &-3\\\\\n", "0 & 0 & 3& 1\\\\\n", "0 & 0 & 0 &0\n", "\\end{pmatrix}\\\\\n", "F=\\begin{pmatrix}\n", "1\\\\\n", "0\\\\\n", "1\n", "\\end{pmatrix}\\hspace{1cm}\n", "G=\\begin{pmatrix}0 & 0 \\\\\n", "0 & 4\n", "\\end{pmatrix}\\hspace{1cm}\n", "H=\\begin{pmatrix}\n", "0 & 0 \\\\\n", "0 & 0\n", "\\end{pmatrix}\\hspace{1cm}\n", "I=\\begin{pmatrix}1\\end{pmatrix}\\hspace{1cm} \n", "J=\\begin{pmatrix}\n", "1 & 0 & 1\\end{pmatrix}\n", "$$" ] }, { "cell_type": "code", - "execution_count": 3, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "666a9c6f77934ae8a6bfaf97cc6e0176", - "version_major": 2, - "version_minor": 0 - }, - "text/plain": [ - "Textarea(value='', description='Matrices échelonnées:', layout=Layout(height='50px', width='60%'), placeholder…" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "63478f2a989643a782e5f568817f8463", - "version_major": 2, - "version_minor": 0 - }, - "text/plain": [ - "Textarea(value='', description='Matrices échelonnées-réduites:', layout=Layout(height='50px', width='60%'), pl…" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "48db73578fba4ac3a379118ec8beeef9", - "version_major": 2, - "version_minor": 0 - }, - "text/plain": [ - "Textarea(value='', description='Aucun des deux:', layout=Layout(height='50px', width='60%'), placeholder='Util…" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], + "outputs": [], "source": [ "data=al.Ex1Chapitre1_5_6() " ] }, { "cell_type": "code", - "execution_count": 4, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Les matrices n'étant ni échelonnées, ni échelonnées-réduites sont fausses. \n" - ] - } - ], + "outputs": [], "source": [ "corrections. Ex1Chapitre1_5_6(data)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Théorie\n", "\n", "\n", "La **méthode d'élimination de Gauss** est un algorithme central en algèbre linéaire qui consiste à appliquer une séquence appropriée d'opérations élémentaires à une matrice (voir [Notebook du chapitre 1.3-4: Notation Matricielle](./1.3-4.%20Notation%20Matricielle.ipynb)) jusqu'à ce qu'elle soit échelonnée. On peut continuer à appliquer des opérations élémentaires pour obtenir une matrice échelonnée réduite. \n", "\n", "\n", "La structure de la méthode d'élimination de Gauss est la suivante:\n", "![title](gauss_elimination.png)\n", "\n", "Soit le système linéaire suivant $$A\\overrightarrow{x} = \\overrightarrow{b}$$ où $A$ est la matrice des coefficients de taille $m\\times n$ et $\\overrightarrow{b}$ est le vecteur regrouppant les termes de droite.\n", "En appliquant la méthode d'élimination de Gauss à la matrice augmentée $(A|b)$ on obtient:\n", "\\begin{align*}\n", "\\text{Système Original} \\quad (A|b) \\quad & \\Leftrightarrow \\quad \\text{Système Échelonné} \\quad (\\tilde{A}|\\tilde{b}) \\quad & \\Leftrightarrow \\quad \\text{Système Réduit} \\quad (\\hat{A}|\\hat{b})\\\\\n", "\\left(\\begin{array}{cccc|c}\n", "a_{11} & a_{12} & \\dots & a_{1n} & b_1\\\\\n", "a_{21} & a_{22} & \\dots & a_{2n} & b_2\\\\\n", "\\vdots & \\vdots & \\ddots & \\vdots & \\vdots \\\\\n", "a_{m1} & a_{m2} & \\dots & a_{mn} & b_m\n", "\\end{array}\\right) \\quad & \\Leftrightarrow \\quad \\left(\\begin{array}{cccc|c}\n", "\\tilde{a}_{11} & \\tilde{a}_{12} & \\dots & \\tilde{a}_{1n} & \\tilde{b}_1\\\\\n", "0 & \\tilde{a}_{22} & \\dots & \\tilde{a}_{2n} & \\tilde{b}_2\\\\\n", "\\vdots & \\vdots & \\ddots & \\vdots & \\vdots \\\\\n", "0 & 0 & \\dots & \\tilde{a}_{mn} & \\tilde{b}_m\n", "\\end{array}\\right) \\quad & \\Leftrightarrow \\quad \\left(\\begin{array}{cccc|c}\n", "1 & 0 & \\dots & 0 & \\hat{b}_1\\\\\n", "0 & 1 & \\dots & 0 & \\hat{b}_2\\\\\n", "\\vdots & \\vdots & \\ddots & \\vdots & \\vdots \\\\\n", "0 & 0 & \\dots & 1 & \\hat{b}_m\n", "\\end{array}\\right)\\\\\n", "\\end{align*}\n", "\n", "**Remarque** Il s'agit d'un exemple, les pivots pouvant êtres à d'autres emplacements. Des lignes de zéros peuvent aussi êtres présentes.\n", "\n", "\n", "Comme seules des opérations élémentaires sur les lignes ont été utilisées, le système linéaire résultant est équivalent au système d'origine. Leur ensemble de solutions sont donc les mêmes. Mais le système resultant est beaucoup plus facile et plus rapide à résoudre. En utilisant d'abord la dernière équation, puis en substituant progressivement les variables dans les équations précédantes.\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "### **Exercice 1**\n", + "### **EXERCICE 2**\n", "\n", "À l'aide des opérations élémentaires, échelonner et réduire les matrices ci-dessous.\n", "\n", "$$\n", "\\begin{pmatrix}\n", "2 & -1\\\\\n", "1 &2\n", "\\end{pmatrix}\\hskip2em\n", "\\begin{pmatrix}\n", "\\dfrac{1}{2} & 3 & 0\\\\\n", "2 & -4 & 6\\\\\n", "1 & 3 &-1\n", "\\end{pmatrix}\\hskip2em\n", "\\begin{pmatrix}\n", "1 & 0 &1\\\\\n", "0 & 1 & -1\\\\\n", "1 & 1 &-1\n", "\\end{pmatrix}\n", "\\hskip2em\n", "\\begin{pmatrix}\n", "1 & 0 &1 & 3\\\\\n", "0 & 2 & -2&1\\\\\n", "1 & 1 &-1 & 0\n", + "\\end{pmatrix}\\hskip2em\n", + "\\begin{pmatrix}\n", + "1 & 1 &-1 & 1\\\\\n", + "1 & -1 & -2&2\\\\\n", + "1 & 1 &1 & 1\\\\\n", + "1 & 3 & 2 & 0\n", "\\end{pmatrix}\n", "$$\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "A=[[1,1], [1,1], [1,1]]" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "print('Vous allez échelonner la matrice')\n", "al.printA(A)\n", "[i,j,r,alpha]= al.manualEch(A)\n", "MatriceList=[np.array(A)]\n", "m=np.array(A)\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)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "### **Exercice 2**\n", - "\n", + "### **EXERCICE 3**\n", "À l'aide des opérations élémentaires, échelonner et réduire les matrices (augmentées) ci-dessous.\n", "\n", "$$A=\n", "\\begin{pmatrix}\n", "2 & -1\\\\\n", "1 &2\n", "\\end{pmatrix}\\hskip1em\n", "b=\n", "\\begin{pmatrix}\n", "1\\\\\n", "2\n", "\\end{pmatrix}\\hskip4em\n", "A=\n", "\\begin{pmatrix}\n", "\\dfrac{1}{2} & 3 & 0\\\\\n", "2 & -4 & 6\\\\\n", "1 & 3 &-1\n", "\\end{pmatrix}\\hskip1em\n", "b=\n", "\\begin{pmatrix}\n", "1\\\\\n", "2\\\\\n", "-1\n", "\\end{pmatrix}\\hskip4em\n", "A=\n", "\\begin{pmatrix}\n", "1 & 0 &1\\\\\n", "0 & 1 & -1\\\\\n", "1 & 1 &-1\n", "\\end{pmatrix}\\hskip1em\n", "b=\n", "\\begin{pmatrix}\n", "1\\\\\n", "0\\\\\n", "-1\n", "\\end{pmatrix}\n", "$$" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "A=[[1,1,1], [1,1,1],[1,1,1]]\n", "b =[[1], [1], [1]]" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "print('Vous allez échelonner la matrice augmenteé')\n", "al.printAAug(A,b)\n", "[i,j,r,alpha]= al.manualEch(A)\n", "MatriceList=[np.array(A)]\n", "RHSList = [np.array(b)]\n", "m=np.concatenate((A,b), axis=1)\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": [ "### **VERIFICATION**\n", "À l'aide des cellules ci-dessous, vous pouvez entrer la matrice (des coefficients ou augmentée) de votre choix et obtenir une forme échelonnée et sa forme échelonnée réduite.\n", "\n", "Pour **les formes échelonnées** on utilise la syntaxe suivante\n", "\n", "1. Pour la matrice $A$ : al.echelonMat('E', A)\n", "2. Pour la matrice augmentée $(A | b)$ : al.echelonMat('E', A, b)\n", "\n", "Pour obenir **les formes échelonnées réduites** mettez 'ER' au lieu de 'E'" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "A=[[2,1,1], [1,-1,1], [1,4,5]]\n", "b=[[1], [3], [1]]" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "M=al.echelonMat('ER',A,b)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "[Passez au notebook du chapitre 1.7: Résolutions de système linéarires](./1.7.%20Résolutions%20de%20systèmes%20linéaires.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.9" } }, "nbformat": 4, "nbformat_minor": 4 } diff --git "a/Chapitre 1 - Systemes equations lineaires/1.7. R\303\251solutions de syst\303\250mes lin\303\251aires.ipynb" "b/Chapitre 1 - Systemes equations lineaires/1.7. R\303\251solutions de syst\303\250mes lin\303\251aires.ipynb" index 071aebe..adb7f7b 100644 --- "a/Chapitre 1 - Systemes equations lineaires/1.7. R\303\251solutions de syst\303\250mes lin\303\251aires.ipynb" +++ "b/Chapitre 1 - Systemes equations lineaires/1.7. R\303\251solutions de syst\303\250mes lin\303\251aires.ipynb" @@ -1,243 +1,316 @@ { "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Concept(s)-clé(s) et théorie\n", + "On considère un système d'équations linéaires aux inconnues $x_1,\\ldots,x_n$\n", "\n", - "Soit $A\\overrightarrow{x}=\\overrightarrow{b}$ où $A$ est une matrice $m\\times n$ et $\\overrightarrow{b}$ un vecteur à $m$ composantes. \n", - "Soit $B$ une forme échelonnée de $A$, et $\\tilde{b}$ le vecteur obtenu de $\\overrightarrow{b}$ en lui appliquant les opérations élémentaires utilisées pour passer de $A$ à $B$.\n", + "$$S=\\left\\{\\begin{array}{ccccccc}\n", + "a_{11}x_1 &+a_{12}x_2 & + &\\cdots &+a_{1n}x_n &= &b_1 \\\\\n", + "a_{21}x_1 &+a_{22}x_2 & + &\\cdots &+a_{2n}x_n &= &b_2 \\\\\n", + "\\vdots & & & &\\vdots & \\vdots &\\vdots \\\\\n", + "a_{m1}x_1 &+a_{m2}x_2 & + &\\cdots &+a_{mn}x_n &= &b_m,\n", + "\\end{array}\\right. $$\n", + "\n", + "où $a_{ij},b_i\\in \\mathbb{R}$ pour tout $1\\leq i\\leq m$ et tout $1\\leq j\\leq n.$ \n", + "\n", + "Soit $A$ la matrice **augmentée** associée au système\n", + "$$\n", + "A=\\left(\\begin{array}{cccc|c}\n", + "a_{11} & a_{12} & \\cdots & a_{1n} & b_1\\\\\n", + "a_{21} & a_{22} & \\cdots & a_{2n} & b_2\\\\\n", + "\\vdots & \\vdots & \\vdots & \\vdots & \\vdots\\\\\n", + "a_{m1} & a_{m2}& \\cdots & a_{mn} & b_m\n", + "\\end{array}\\right).$$ \n", + "\n", + "On a que les composantes de la colonne $j$ sont les coefficients associés à la variable $x_j$ et que les coefficients de la dernière colonne sont les termes constants ou les termes de droite. On peut écrire la matrice $A$ de la forme suivante\n", + "$$\n", + "A=\\left(\\begin{array}{cccc|c} \\overrightarrow{a_1} & \\overrightarrow{a_2} & \\cdots & \\overrightarrow{a_n} & \\overrightarrow{b}\\end{array}\\right)\n", + "$$ où $\\overrightarrow{a_j}$ est un vecteur de $m$ composantes (celles de la colonnes $j$) donné par\n", + "$$\n", + "\\overrightarrow{a_j}=\\begin{pmatrix}\n", + "a_{1j}\\\\\n", + "a_{2j}\\\\\n", + "\\vdots\\\\\n", + "a_{mj}\n", + "\\end{pmatrix}\n", + "$$\n", + "\n", + "**Remarque** On considère ici la matrice $A$ comme étant une matrice augmentée et non pas celle des coefficients. La théorie ci-dessous doit être adaptée si vous considérez la matrice $A$ comme étant celle des coefficients!\n", + "\n", + "En appliquant l'algorithme de Gauss, on peut échelonner la matrice $A$ et obtenir une matrice échelonnée $B$ (il en existe plusieurs). On pourrait encore continuer l'algorithme et obtenir la forme échelonnée réduite de $A$ (elle est unique!). \n", + "\n", + "De même, on peut écrire la matrice $B$ en faisant référence à ses colonnes\n", + "$$\n", + "B=\\left(\\begin{array}{cccc|c} \\overrightarrow{b_1} & \\overrightarrow{b_2} & \\cdots & \\overrightarrow{b_n} & \\tilde{b}\\end{array}\\right)\n", + "$$ où $\\tilde{b}$ est un vecteur de $m$ composantes, obtenu en appliquant à $\\overrightarrow{b}$ la même suite d'opérations élémentaires utilisées pour passer de $A$ à $B$. \n", "\n", "#### DÉFINITION :\n", - "Les inconnues du système linéaire $B\\overrightarrow{x}=\\tilde{b}$ dont la colonne correspondante ne possède pas de pivot sont appelées les **inconnues libres**. Les inconnues dont la colonne correspondante possède un pivot sont appelées les **inconnues principales**.\n", + "Les inconnues du système linéaire $S$ dont la colonne de la matrice $B$ correspondante ne possède pas de pivot sont appelées les **inconnues libres**. Elles peuvent prendre n'importe quelle valeur réelle. Les inconnues dont la colonne de la matrice $B$ correspondante possède un pivot sont appelées les **inconnues principales**.\n", + "\n", + "\n", + "Prenons deux exemples:\n", + "1. Soit $B$ donnée par\n", + "$$B=\\begin{pmatrix}\n", + "\\color{red}\\oplus & * & * & * & * & * & * \\\\\n", + "0 & \\color{red}\\oplus & * & *& * & * & * \\\\\n", + "0 & 0 & 0 & \\color{red}\\oplus& *& * &* \\\\\n", + "0 & 0 & 0 & 0 & 0 &\\color{red}\\oplus & * \\\\\n", + "0 & 0 & 0 & 0 & 0& 0 & 0 \\end{pmatrix}\n", + "$$ \n", + "Le système initial est un système de cinq équations linéaires à six inconnues $x_1,x_2, \\ldots, x_6$. Il y a quatre colonnes pivots (1,2,4 et 6) et quatre pivots. Les inconnues principales sont $x_1, x_2, x_4$ et $x_6$ et les inconnues libres sont $x_3$ et $x_5$.\n", "\n", - "Reprenons l'exemple donné dans [Notebook du chapitre 1.5-6: Matrices Echelonnées](./1.5-6.%20Matrices%20Echelonnees.ipynb)\n", + "2. Prenons l'exemple donné dans [Notebook du chapitre 1.5-6: Matrices Echelonnées](./1.5-6.%20Matrices%20Echelonnees.ipynb) \n", "\n", - "$A=\\begin{pmatrix}\n", + "$$B=\\begin{pmatrix}\n", "\\color{red}\\oplus & * & * & * & * & * & * &* & * \\\\\n", "0 & 0 &\\color{red}\\oplus & *& * & * & * & *&* \\\\\n", "0 & 0 & 0 & \\color{red}\\oplus& *& * &* & *& *\\\\\n", "0 & 0 & 0 & 0 & 0 &\\color{red}\\oplus & * & * & *\\\\\n", "0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 &\\color{red}\\oplus\\\\\n", "0 & 0 & 0 & 0 & 0& 0 & 0 &0&0\\\\\n", "0 & 0 & 0 & 0 & 0& 0 & 0 &0&0\n", - "\\end{pmatrix}$\n", + "\\end{pmatrix}$$\n", + "\n", + "Le système initial est un système de sept équations linéaires à huit inconnues $x_1, \\ldots, x_8$. On constate que la matice $B$ possède cinq colonnes pivots (1,3,4,6 et 9). On aurait envie de dire que les inconnues principales sont $x_1, x_3, x_4$ et $x_6$ et les inconnues libres sont $x_2, x_5,x_7$ et $x_8$. \n", + "Mais attention la colonne 9 ne correspond pas à une inconnue! La présence du pivot dans cette colonne cause le problème suivant. La cinquième ligne de la matrice $B$ correspond à l'équation\n", + "\n", + "$$\n", + "\\begin{array}{rcccccclccrl}\n", + "(\\, & 0 & & 0 & & 0 & &\\cdots & &0 &\\,|\\,&\\color{red}\\oplus \\quad )\\\\\n", + " &0x_1 &+ & 0x_2 &+ & 0 x_3 &+ &\\cdots &+ &0 x_8 & = & \\color{red}\\oplus \\\\\n", + "& & & & & & & & & 0&= &\\color{red}\\oplus\n", + "\\end{array}\n", + "$$\n", + "\n", + "Ce qui n'est possible que si $\\color{red}\\oplus=0$ or cela n'est pas vrai car $\\color{red}\\oplus$ est un pivot dnc non-nul! On obtient un système inconsistant, qui n'admet pas de solutions. On ne parle pas de variables libres ou principales si le système n'admet pas de solutions. \n", + "\n", + "\n", "\n", "#### MÉTHODE DE RÉSOLUTION DE SYSTÈMES LINÉAIRES :\n", "Soit $S$ un système linéaire à $n$ inconnues. Afin de trouver l'ensemble des solutions de $S$, on procède comme suit :\n", "\n", - "1. Poser A la matrice augmentée du système.\n", - "2. Utiliser la méthode d'élimination de Gauss afin de transformer A en une matrice échelonnée B.\n", - "3. Si la matrice B possède une ligne de la forme $(0\\, 0 \\,⋯ \\,0 \\,|\\, c )$ avec $c\\neq 0$, alors le système ne possède aucune solution.\n", + "1. Poser $A$ la matrice **augmentée** du système.\n", + "2. Utiliser la méthode d'élimination de Gauss afin de transformer $A$ en une matrice échelonnée (réduite) $B$.\n", + "3. Si la matrice $B$ possède une ligne de la forme $(0\\, 0 \\,\\cdots \\,0 \\,|\\, c )$ avec $c\\neq 0$, alors le système ne possède aucune solution.\n", "4. S'il existe $n$ pivots, aucun dans la dernière colonne, alors il existe une unique solution.\n", "5. S'il existe moins de $n$ pivots, aucun dans la dernière colonne, alors il existe un nombre infini de solutions.\n", "\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import Librairie.AL_Fct as al\n", "import Corrections.corrections as corrections\n", "import numpy as np\n", "import ipywidgets as widgets\n", "\n", "from ipywidgets import interact, interactive, fixed, interact_manual, Layout" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### **EXERCICE 1**\n", "\n", "Trouver la solution du système en échelonnant la matrice augmentée correspondante\n", "\n", "$$\n", "\\begin{cases}\n", "-2x_1 + \\dfrac{2}{3}x_2 -x_3&=0\\\\\n", "x_1 -2x_2 + x_3&=2\\\\\n", "x_2 -5 x_3&=-3\n", "\\end{cases}\n", "$$\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "A=[[-2,2/3,-1], [1,-2,1], [0,1,-5]]\n", "b=[[0], [2], [-3]]\n", "print('Vous allez échelonner la matrice')\n", "al.printA(A,b)\n", "[i,j,r,alpha]= al.manualEch(A,b)\n", "m=np.concatenate((A,b), axis=1)\n", "MatriceList=[A]\n", "RhSList=[b]" ] }, { "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": [ - "### **Exercice 2**\n", + "### **EXERCICE 2**\n", "\n", "Soient les 4 systèmes ci-dessous. À l'aide du méthode d'élimination de Gauss, déterminez celles qui admettent au moins une solution (nommée compatible) et celles qui n'admettent aucune solution (nommée imcompatible).\n", "\n", "\n", "\n", "$$\n", "a) \\begin{cases}\n", "-2x_1 + 8x_2&=0\\\\\n", "\\dfrac{1}{2}x_1 -2 &=0\n", "\\end{cases}\\hskip1.2em\n", "b)\\begin{cases}\n", "x_1 + 3 x_2 &=-1\\\\\n", "-2x_1 -6 x_2&=-2\n", "\\end{cases}\\hskip1.2em\n", "c) \\begin{cases}\n", "x_1 -2x_3&=3\\\\\n", "2x_2 +x_3&=0\\\\\n", "-x_1 + x_2 + 2x_3&=2\n", "\\end{cases}\\hskip1.2em\n", "d) \\begin{cases}\n", "x_1 + x_2 + x_3&=1\\\\\n", "-x_1 + x_2 + x_3 &=-1\\\\\n", "-x_2 -x_3&=0\n", "\\end{cases}\n", "$$" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "A=[[1,1], [1,1], [1,1]]\n", "b=[[1],[1],[1]]" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "print('Vous allez échelonner la matrice')\n", "al.printA(A,b)\n", "[i,j,r,alpha]= al.manualEch(A,b)\n", "m=np.concatenate((A,b), axis=1)\n", "MatriceList=[A]\n", "RhSList=[b]" ] }, { "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": [ "corrections.Ex2Chapitre1_7()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Concept(s)-clé(s) et théorie\n", "\n", + "#### DÉFINITION :\n", + "On appelle *système linéaire homogène*, tous système d'équations linéaires n'ayant que des zéros comme termes constants (tous les termes de droites $b_j=0$). \n", + "Les systèmes homogène $A\\overrightarrow{x}=\\overrightarrow{0}$, avec $\\overrightarrow{0}$ le vecteur nul à m composantes, admettent toujours au moins une solution: la solution triviale (celle qu'avec des zéros). \n", + "\n", "#### Solution homogène et solution particulière\n", - "Pour les systèmes linéaires compatibles, la solution $s$ peut être donnée sous forme paramétrique vectorielle comme suit:\n", + "Pour les systèmes linéaires compatibles (qui admettent une solution), la solution $s$ peut être donnée sous forme paramétrique vectorielle comme suit:\n", "$$\n", - "s=p + t v\n", - "$$où $ p $ est une **solution particulière** au système linéaire, tandis que $ tv $ (avec $t \\in \\mathcal{R}$) est une solution au système homogène $ Ax = 0 $ (en effet appelé **solution homogène**).\n", + "s=\\overrightarrow{p} + t \\overrightarrow{v}\n", + "$$où $ \\overrightarrow{p} $ est une **solution particulière** au système linéaire, tandis que $ t\\overrightarrow{v} $ (avec $t \\in \\mathbb{R}$) est une solution du système linéaire homogène $ A\\overrightarrow{x}=\\overrightarrow{0} $ (appelé **solution homogène**).\n", "\n", - "En 2 dimensions, l'ensemble des solutions peut être un point (si la seule solution homogène est $ v = 0 $), une ligne droite (si l'ensemble des solutions homogènes se situe sur une droite du plan 2D) ou le plan entier (si chaque vecteur 2D est une solution au système homogène).\n", + "En deux dimensions, l'ensemble des solutions peut être un point (si la seule solution homogène est $ \\overrightarrow{v}=\\overrightarrow{0}$), une ligne droite (si l'ensemble des solutions homogènes se situe sur une droite du plan 2D) ou le plan entier (si chaque vecteur 2D est une solution au système homogène).\n", " \n", - "En 3 dimensions, l'ensemble des solutions peut être un point (si la seule solution homogène est $ v = 0 $), une ligne droite (si l'ensemble des solutions homogènes se trouve sur une droite dans l'espace 3D) , le plan entier (si l'ensemble des solutions hoogènes se trouve dans un plan de l'espace 3D) ou tout l'espace 3D (si chaque vecteur 3D est une solution au système homogène)." + "En trois dimensions, l'ensemble des solutions peut être un point (si la seule solution homogène est $ \\overrightarrow{v}=\\overrightarrow{0}$), une ligne droite (si l'ensemble des solutions homogènes se trouve sur une droite dans l'espace 3D) , le plan entier (si l'ensemble des solutions hoogènes se trouve dans un plan de l'espace 3D) ou tout l'espace 3D (si chaque vecteur 3D est une solution au système homogène)." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "Pour les systèmes de l'exercice 2, donner la nature des solutions. Un graphe s'affichera avec les solutions.\n", + "### **EXERCICE 3**\n", + "\n", + "\n", + "Pour les systèmes de l'exercice 2, donner la nature des solutions (droite, plan, point...). Un graphe s'affichera avec les solutions.\n", + "\n", "$$\n", "a) \\begin{cases}\n", "-2x_1 + 8x_2&=0\\\\\n", "\\dfrac{1}{2}x_1 -2 &=0\n", "\\end{cases}\\hskip1.2em\n", "b)\\begin{cases}\n", "x_1 + 3 x_2 &=-1\\\\\n", "-2x_1 -6 x_2&=-2\n", "\\end{cases}\\hskip1.2em\n", "c) \\begin{cases}\n", "x_1 -2x_3&=3\\\\\n", "2x_2 +x_3&=0\\\\\n", "-x_1 + x_2 + 2x_3&=2\n", "\\end{cases}\\hskip1.2em\n", "d) \\begin{cases}\n", "x_1 + x_2 + x_3&=1\\\\\n", "-x_1 + x_2 + x_3 &=-1\\\\\n", "-x_2 -x_3&=0\n", "\\end{cases}\n", "$$" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "corrections.Ex3Chapitre1_7()" ] } ], "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.9" } }, "nbformat": 4, "nbformat_minor": 4 }