diff --git "a/Chapitre 1 - Systemes equations lineaires/1.1. Introduction et d\303\251finition.ipynb" "b/Chapitre 1 - Systemes equations lineaires/1.1. Introduction et d\303\251finition.ipynb" index b6a6386..2c9d3a6 100644 --- "a/Chapitre 1 - Systemes equations lineaires/1.1. Introduction et d\303\251finition.ipynb" +++ "b/Chapitre 1 - Systemes equations lineaires/1.1. Introduction et d\303\251finition.ipynb" @@ -1,463 +1,311 @@ { "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Concept(s)-clé(s) et théorie\n", "\n", "### DÉFINITION 1 :\n", "\n", "Une *équation linéaire* aux inconnues $x_1,\\ldots,x_n$ à coefficients réels est une équation de la forme\n", "\n", "$$a_1x_1+a_2x_2+\\cdots+a_nx_n=b,$$ \n", "où $a_1,a_2,\\ldots,a_n,b\\in \\mathbb{R}.$\n", " \n", "---\n", "### DÉFINITION 2 :\n", "\n", "On appelle *système d'équations linéaires* (ou simplement système linéaire) une famille d'équations linéaires aux inconnues $x_1,\\ldots,x_n$ à coefficients réels de la forme \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", "Aussi, on dit qu'une suite ordonnée de $n$ nombres réels $\\alpha=(\\alpha_1,\\ldots,\\alpha_n)$ est une *solution du système linéaire* $S$ si toutes les égalités du système sont vérifiées lorsque l'on remplace $x_j$ par $\\alpha_j,$ ceci pout tout $1\\leq j\\leq n.$" ] }, { "cell_type": "code", - "execution_count": 3, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import Librairie.AL_Fct as al\n", "#from IPython.core.magic import register_cell_magic\n", "#from IPython.display import HTML, display\n", "#import numpy as np" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### EXEMPLE 1\n", "\n", "Dans ce premier exemple nous nous familiarisons avec les équations et les ensembles de solutions. Soit \n", "$$ \n", "a_{1}x_{1} + a_{2}x_{2} + \\ldots a_{n}x_{n}=b_1.\n", "$$ \n", "On utilise *la syntaxe suivante pour définir les coefficients* de l'équation \n", "\n", "$$\n", "\\begin{align*}\n", "A&=[a_1, a_2, \\ldots, a_n]\\\\\n", "b&=[b_1].\n", "\\end{align*}\n", "$$\n", "\n", "---\n", "Dans la case ci-dessous, entrer les coefficients de l'équation \n", "$$3x_1 + 2x_2=7$$\n", "\n" ] }, { "cell_type": "code", - "execution_count": 2, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "data": { - "text/html": [ - "" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], + "outputs": [], "source": [ "al.bgc('seashell')\n", "#Toutes les valeurs sont initialisées à 1\n", "\n", "A = [1] \n", "b = [1]\n" ] }, { "cell_type": "code", - "execution_count": 3, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "data": { - "text/latex": [ - "$1x_1=1$" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], + "outputs": [], "source": [ "al.printEq(A,b)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "On utilise *la syntaxe suivante pour entrer une solution* d'une équation\n", "$$\\rm{alpha}=[\\alpha_1, \\alpha_2, \\ldots, \\alpha_n]$$" ] }, { "cell_type": "code", - "execution_count": 4, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "data": { - "text/html": [ - "" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], + "outputs": [], "source": [ "al.bgc('seashell')\n", "#Toutes les valeurs sont initialisées à 1\n", "\n", "alpha = [1] #solution" ] }, { "cell_type": "code", - "execution_count": 5, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "La suite entrée est une solution de l'équation 1\n" - ] - } - ], + "outputs": [], "source": [ "isSol = [al.SolOfEq(alpha, A+b,1)]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### **EXERCICE 1**\n", "\n", "Enter l'équation $$ \\frac{2}{5}x_1 -4x_2 + x_3 = 8$$ et donner une solution $$\\alpha=(\\alpha_1, \\alpha_2, \\alpha_3).$$\n", "\n", "Vous pouvez aussi adapter le code à l'équation de votre choix." ] }, { "cell_type": "code", - "execution_count": 6, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "data": { - "text/html": [ - "" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], + "outputs": [], "source": [ "al.bgc('seashell')\n", "\n", "#Par défaut, les valeurs sont fixées à 1\n", "\n", "A = [1] \n", "b =[1]\n", "alpha = [1] #solution " ] }, { "cell_type": "code", - "execution_count": 7, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "data": { - "text/latex": [ - "$1x_1=1$" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "La suite entrée est une solution de l'équation 1\n" - ] - } - ], + "outputs": [], "source": [ "al.printEq(A,b)\n", "isSol=[al.SolOfEq(alpha, A+b,1)]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### EXEMPLE 2\n", "\n", "Dans cet exercice nous nous familiarisonns avec les systèmes d'équations. La partie ci-dessous vous demande de rentrer un système d'équation. \n", "\n", "Soit\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", "On utilise *la syntaxe suivante pour entrer les coefficients du système*\n", "\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", "Essayer d'entrer le système d'équations ci-dessous\n", "\n", "$$\\begin{cases}\n", "x_1 &-3 x_2 &&=4\\\\\n", "-x_1 & + 4 x_2&&= 5\n", "\\end{cases}\n", "$$" ] }, { "cell_type": "code", - "execution_count": 8, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "data": { - "text/html": [ - "" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], + "outputs": [], "source": [ "al.bgc('seashell')\n", "\n", "#Par défaut, les valeurs sont fixées à 1\n", "\n", "A = [ [1, 1], [1, 1]] \n", "b=[1,1] \n", "alpha = [1,1] #solution" ] }, { "cell_type": "code", - "execution_count": 9, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "data": { - "text/latex": [ - "$\\begin{cases}1x_1 + 1x_2=1\\\\1x_1 + 1x_2=1\\\\\\end{cases}$" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], + "outputs": [], "source": [ "al.printSyst(A,b)" ] }, { "cell_type": "code", - "execution_count": 10, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "La suite entrée n'est pas une solution de l'équation 1\n", - "La suite entrée n'est pas une solution de l'équation 2\n", - "Ce n'est pas une solution du système\n" - ] - } - ], + "outputs": [], "source": [ "al.SolOfSyst(alpha, A,b)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### **EXERCICE 2**\n", " \n", "Entrer le système suivant et donner une solution du système.\n", "\n", "$$\\begin{cases}\n", "&2x_1 -3 x_2 + x_3&&=-5\\\\\n", "&-\\dfrac{1}{3}x_1 + x_3&&= 2\\\\\n", "&x_1 + 4x_2 -x_3 &&=0\n", "\\end{cases}\n", "$$\n", "\n", "Vous pouvez aussi adapter le code à l'équation de votre choix." ] }, { "cell_type": "code", - "execution_count": 11, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "data": { - "text/html": [ - "" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], + "outputs": [], "source": [ "al.bgc('seashell')\n", "#Par défaut, les valeurs sont fixées à 1\n", "\n", "A = [[1,1,1], [1,1,1], [1,1,1]]\n", "b =[1,1,1]\n", "alpha =[1,1,1] #solution\n" ] }, { "cell_type": "code", - "execution_count": 12, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "data": { - "text/latex": [ - "$\\begin{cases}1x_1 + 1x_2 + 1x_3=1\\\\1x_1 + 1x_2 + 1x_3=1\\\\1x_1 + 1x_2 + 1x_3=1\\\\\\end{cases}$" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "La suite entrée n'est pas une solution de l'équation 1\n", - "La suite entrée n'est pas une solution de l'équation 2\n", - "La suite entrée n'est pas une solution de l'équation 3\n", - "Ce n'est pas une solution du système\n" - ] - } - ], + "outputs": [], "source": [ "al.printSyst(A,b)\n", "al.SolOfSyst(alpha, A,b)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "[Passez au notebook du chapitre 1.2: Nombre de solutions d'un système](./1.2.%20Nombre%20de%20solution%20d'un%20système.ipynb)" ] }, { "cell_type": "code", - "execution_count": 2, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ "b=al.np.array([1,2,3])" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "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 1 - Systemes equations lineaires/1.2. Nombre de solution d'un syst\303\250me.ipynb" "b/Chapitre 1 - Systemes equations lineaires/1.2. Nombre de solution d'un syst\303\250me.ipynb" index 4bd78d3..f5c55db 100644 --- "a/Chapitre 1 - Systemes equations lineaires/1.2. Nombre de solution d'un syst\303\250me.ipynb" +++ "b/Chapitre 1 - Systemes equations lineaires/1.2. Nombre de solution d'un syst\303\250me.ipynb" @@ -1,457 +1,471 @@ { "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 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" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "editable": true }, "outputs": [], "source": [ - "import AL_Fct as al\n", + "import Librairie.AL_Fct as al\n", "import numpy as np\n", "import matplotlib.pyplot as plt\n", "import plotly\n", - "import plotly.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" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### EXEMPLE 1\n", "\n", "Nous allons travailler avec un système de $2$ inconnues, $2$ é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 utilise *la syntaxe suivante pour entrer les coefficients du système*\n", "\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=[3,2]\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. \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", "\n", "A = [ [1,1] , [1,1] ]\n", "b =[1,1]\n", "alpha=[1,1]" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "al.printSyst(A,b)\n", "al.SolOfSyst(alpha, A,b)\n", "al.Plot2DSys(-7,7,15,A,b)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### **EXERCICE 2**\n", "\n", "Pour chacun des cas ci-dessous, déterminer la/les solution(s) des systèmes. \n", "\n", " $$ \n", "a)\\quad \\begin{cases}\n", "3\\times 3\n", "\\end{cases} \\hspace{1cm} b) \\quad \\begin{cases}\n", "3\\times 3\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", "\n", "A = [ [1,-1,2] , [-3, 0, 0] ,[2,5,0]]\n", "b=[0,1,-2]\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "al.printSyst(A,b)\n", "al.Plot3DSys(-10,10,100,A,b)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "EXERCICE 3 #code 1.2.Ex3\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), et c) admettent, si possible,\n", "1. aucune solution\n", "2. une unique solution\n", "3. une infinité de solution \n", "\n", "$\\color{red}{\\rm{ Comment\\, on\\, corrige?}}$\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": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ - "import plotly\n", - "import plotly.plotly as py\n", + "import plotly as py\n", "import numpy as np\n", "plotly.offline.init_notebook_mode(connected=True)\n", "import plotly.graph_objs as go\n", "from ipywidgets import interactive, HBox, VBox, widgets, interact, FloatSlider\n", "\n", "#THIS IS WORKING\n", "\n", "A=[[1, 5], [-2,-10]] # we initialize the problem. Not what we plot, the one plotted is at zero.\n", "b=[3,18]\n", "\n", "al.printSyst(A, b)\n", "\n", "data=[]\n", "x=np.linspace(-5,5,11)\n", "m=len(A)\n", "MatCoeff = [A[i]+[b[i]]for i in range(0,m)] #becomes augmented matrix\n", "MatCoeff=np.array(MatCoeff)\n", "\n", "for i in range(1,len(MatCoeff)+1):\n", " trace=go.Scatter(x=x, y= (MatCoeff[i-1,2]-MatCoeff[i-1,0]*x)/MatCoeff[i-1,1], name='a) Droite %d'%i)\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", "#def update_y(coeff, cof):\n", " # MatCoeff= [[coeff, 1, cof]]\n", " # MatCoeff=np.array(MatCoeff)\n", " # f.data[0].y=(MatCoeff[0,2]-MatCoeff[0,0]*x)/MatCoeff[0,1]\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)) #,cof=(-10, 10, 1))\n", "\n", "vb = VBox((f, freq_slider))\n", "vb.layout.align_items = 'center'\n", "vb\n", "\n", "\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "#THIS IS WORKING\n", "MatCoeff=[[1, 1, 3], [-2,-1,-1]] # we initialize the problem. Not what we plot, the one plotted is at zero.\n", "data=[]\n", "x=np.linspace(-5,5,11)\n", "MatCoeff=np.array(MatCoeff)\n", "for i in range(1,len(MatCoeff)+1):\n", " trace=go.Scatter(x=x, y= (MatCoeff[i-1,2]-MatCoeff[i-1,0]*x)/MatCoeff[i-1,1], name='b) Droite %d'%i)\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", "#def update_y(coeff, cof):\n", " # MatCoeff= [[coeff, 1, cof]]\n", " # MatCoeff=np.array(MatCoeff)\n", " # f.data[0].y=(MatCoeff[0,2]-MatCoeff[0,0]*x)/MatCoeff[0,1]\n", "#coefficients=[[h,1,3]]\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)) #,cof=(-10, 10, 1))\n", "\n", "vb = VBox((f, freq_slider))\n", "vb.layout.align_items = 'center'\n", "vb" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "#THIS IS WORKING\n", "MatCoeff=[[3, 1, 1], [1,3,1]] # we initialize the problem. Not what we plot, the one plotted is at zero.\n", "data=[]\n", "x=np.linspace(-25,25,101)\n", "MatCoeff=np.array(MatCoeff)\n", "for i in range(1,len(MatCoeff)+1):\n", " trace=go.Scatter(x=x, y= (MatCoeff[i-1,2]-MatCoeff[i-1,0]*x)/MatCoeff[i-1,1], name='c) Droite %d'%i)\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", "#def update_y(coeff, cof):\n", " # MatCoeff= [[coeff, 1, cof]]\n", " # MatCoeff=np.array(MatCoeff)\n", " # f.data[0].y=(MatCoeff[0,2]-MatCoeff[0,0]*x)/MatCoeff[0,1]\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)) #,cof=(-10, 10, 1))\n", "\n", "vb = VBox((f, freq_slider))\n", "vb.layout.align_items = 'center'\n", "vb" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "#THIS IS WORKING\n", "MatCoeff=[[3, 1, 1], [1,3,1]] # we initialize the problem. Not what we plot, the one plotted is at zero.\n", "data=[]\n", "x=np.linspace(-15,15,101)\n", "MatCoeff=np.array(MatCoeff)\n", "for i in range(1,len(MatCoeff)+1):\n", " trace=go.Scatter(x=x, y= (MatCoeff[i-1,2]-MatCoeff[i-1,0]*x)/MatCoeff[i-1,1], name='d) Droite %d'%i)\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(coeff, cof):\n", " # MatCoeff= [[coeff, 1, cof]]\n", " # MatCoeff=np.array(MatCoeff)\n", " # f.data[0].y=(MatCoeff[0,2]-MatCoeff[0,0]*x)/MatCoeff[0,1]\n", "def update_y(h, k):\n", " MatCoeff= [[h, 1, k],[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 XX\n", + "\n", + "Systeme de 3 droites en 2D: en changeant $h$, on passe d'une solution à une infinité ou à zéro solutions" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] } ], "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": 2 + "nbformat_minor": 4 } diff --git a/Chapitre 1 - Systemes equations lineaires/1.3-4. Notation Matricielle.ipynb b/Chapitre 1 - Systemes equations lineaires/1.3-4. Notation Matricielle.ipynb index 11c98d0..db4e077 100644 --- a/Chapitre 1 - Systemes equations lineaires/1.3-4. Notation Matricielle.ipynb +++ b/Chapitre 1 - Systemes equations lineaires/1.3-4. Notation Matricielle.ipynb @@ -1,367 +1,367 @@ { "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", "Le système $S$ peut s'écrire sous forme matricielle $A\\overrightarrow{x}=\\overrightarrow{b}$ où la matrice $A$ est appelée *la matrice des coefficients* et $\\overrightarrow{x}$ et $\\overrightarrow{b}$ sont des vecteurs contant les composantes $x_i$ et $b_i$ respectivement. \n", "\n", "Plus précisemment\n", "$$A=\\begin{pmatrix}\n", "a_{11} & a_{12} & \\cdots & a_{1n}\\\\\n", "a_{21} & a_{22} &\\cdots & a_{2n}\\\\\n", "\\vdots & \\vdots & \\ddots & \\vdots\\\\\n", "a_{m1} & a_{m2} & \\cdots & a_{mn}\n", "\\end{pmatrix},\\hskip1em\n", "\\overrightarrow{x}=\\begin{pmatrix}\n", "x_1\\\\\n", "x_2\\\\\n", "\\vdots\\\\\n", "x_n\n", "\\end{pmatrix},\\hskip1em\n", "\\overrightarrow{b}=\n", "\\begin{pmatrix}\n", "b_1\\\\\n", "b_2\\\\\n", "\\vdots\\\\\n", "b_m\n", "\\end{pmatrix},\n", "$$\n", "\n", "---\n", "\n", "La matrice $A$ est de taille $m\\times n$ où **m correspond au nombre de lignes** et **n au nombre de colonnes**.\n", "Le vecteur $\\overrightarrow{x}$ est de taille $n\\times 1$ et le vecteur $\\overrightarrow{b}$ de taille $m\\times 1$.\n", "\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ - "import AL_Fct as al\n", + "import Librairie.AL_Fct as al\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", "\n", "Ci-dessous est générée une matrice $A$ de taille $m\\times n$. Trouver la dimension de la matrice en remplissant les deux champs dans lesquels vous pouvez rentrer une valeur pour $m$ et $n$. \n", "\n", "Vérifier en cliquant sur **Run Interact**" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "A=al.randomA()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "al.dimensionA(A)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### **Nouvelles notations**\n", "\n", "Pour rentrer une matrice on utilise *la syntaxe suivante*\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", "\n", "Comme nous souhaitons différencier les vecteurs colonnes - ceux usuel - des vecteurs lignes, nous les différencions **à partir de maintenant** en utilisant *la syntaxe suivante*\n", "\n", "$$\n", "\\begin{align*}\n", "\\overrightarrow{b}&=\\begin{pmatrix}b_1 \\\\ b_2 \\\\ \\vdots \\\\ b_m\\end{pmatrix}\n", "&&\\Rightarrow b=\\quad [\\quad [ b_{1} ], \\quad [b_{2}], \\quad \\ldots, \\quad [b_m] \\quad]\\\\\n", "\\overrightarrow{v}&=\\begin{pmatrix} v_1 & v_2 & \\cdots v_n\\end{pmatrix}\n", "&&\\Rightarrow v=\\quad[ \\quad v_1, \\quad v_2, \\quad \\ldots, \\quad v_n \\quad ]\n", "\\end{align*}\n", "$$\n", "\n", "---\n", "\n", "Entrez les vecteurs et matrices ci-dessous.\n", "$$\n", "\\begin{pmatrix}\n", "1 & -3 \\\\\n", "3 & 5\n", "\\end{pmatrix} \\hskip1em \\begin{pmatrix}\n", "1 \\\\\n", "2 \n", "\\end{pmatrix}\\hskip1em\\begin{pmatrix}\n", "1 \\\\\n", "0.3\\\\\n", "1/4\n", "\\end{pmatrix}\\hskip1em\\begin{pmatrix}\n", "1 &2 &-1\n", "\\end{pmatrix}\\hskip1em\\begin{pmatrix}\n", "1 & 0 & -1\\\\\n", "0 & -1 & 1\\\\\n", "1 & 1 & 0\n", "\\end{pmatrix}\n", "$$" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "al.bgc('seashell')\n", "A=[[1],[2]]" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "al.printA(A)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Lorsqu'on travaille avec des systèmes, on s'intéresse à la matrice augmentée - dans laquelle on retrouve la matrice des coefficients $A$ et une colonne additionnelle correspondant aux termes de droite.\n", "\n", "$$\\begin{align*}\n", "\\text{Notation système} \\quad &\\Leftrightarrow \\quad\\text{Notation matricielle}\\\\\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} \\quad &\\Leftrightarrow \\quad \\left(\\begin{array}{cc|c}\n", "a_{11} & a_{12} & b_1\\\\\n", "a_{21} & a_{22} & b_2\n", "\\end{array}\\right)\n", "\\end{align*}\n", "$$\n", "\n", "---\n", "Pour entrer les matrices augmentées des systèmes, en utilisez la syntaxe suivante\n", "\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], \\quad [b_2], \\ldots, [b_m]\\quad ] \\leftarrow\\text{ceci nous permet de différencier un vecteur colonne d'un vecteur ligne!}\n", "\\end{align*}\n", "$$\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### **EXERCICE 1**\n", "Entrez les matrices augmentées des systèmes ci-dessous.\n", "\n", "$$\n", "1) \\quad \\begin{cases}\n", "2x_1 -x_2&=3\\\\\n", "x_1 + x_2&=0,\n", "\\end{cases}\\hskip2em\n", "2)\\quad \\begin{cases}\n", "\\dfrac{1}{3}x_1 + x_2 - x_3&=-6\\\\\n", "x_1 + x_3&=2\\\\\n", "-x_1 + \\dfrac{27}{9}x_2- x_3&=-1,\n", "\\end{cases}\\hskip2em\n", "3)\\quad \\begin{cases}\n", "x_1 - 4x_2=7\n", "\\end{cases}\\hskip2em\n", "4) \\begin{cases}\n", "x_1 &=3\\\\\n", "x_2 &= 4\\\\\n", "x_3 &= -1\\\\\n", "x_4&=0\n", "\\end{cases}\\hskip1em\n", "$$" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "al.bgc('seashell')\n", "#Entrer la matrice des coeff et le vecteur des termes de droite. Attention aux dimensions!\n", "A=[[1,1], [1,1]]\n", "b=[[1],[1]]" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "print('Le système est\\n')\n", "\n", "al.printSyst(A,b)\n", "print('\\n')\n", "print(' Son écriture matricielle est\\n')\n", "al.printA(A,b)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Concept(s)-clé(s) et théorie\n", "\n", "Il existe trois type d'opérations que l'on peut effectuer sur un système d'équations linéaires, ou sur la matrice augmentée correspondante, sans changer son ensemble de solution. \n", "\n", "Ces opérations sont appelées *opérations élémentaires* \n", "\n", "\n", - "1. (Échange) Échanger la ligne $i$ avec la ligne $j$. \n", - "2. (Multiplication par un scalaire) Multiplier tous les coefficients de la ligne $i$ par une constante non-nulle $(\\alpha)$.\n", - "3. (Remplacement) Remplacer la ligne $i$ par la ligne obtenue en lui ajoutant un multiple ($\\alpha$) de la ligne $j$. " + "1. $E_{ij}$ (Échange) Échanger la ligne $i$ avec la ligne $j$. \n", + "2. $E_{i}(\\alpha)$ (Multiplication par un scalaire) Multiplier tous les coefficients de la ligne $i$ par une constante non-nulle $(\\alpha)$.\n", + "3. $E_{ij}(\\alpha)$ (Remplacement) Remplacer la ligne $i$ par la ligne obtenue en lui ajoutant un multiple ($\\alpha$) de la ligne $j$. " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### EXEMPLE 1 :\n", "\n", "Entrer la matrice (augmentée) correspondante au système ci-dessous et effectuer les trois opérations suivantes sur la matrice de départ. \n", "\n", "1. Échanger la ligne $1$ et la ligne $2$.\n", "2. Multiplier tous les coefficients de la ligne $2$ par $-\\dfrac{1}{2}$.\n", "3. Remplacer la ligne 2 par la ligne obtenue en lui ajoutant 3 fois la ligne $3$. \n", "\n", "Le systèmes est \n", "$$\n", "\\begin{cases}\n", "x_1 -3x_2 + \\dfrac{1}{3}x_3&=0\\\\\n", "x_1 -7 x_3&=2\\\\\n", "-2x_1 + 3x_2 -4x_3&=5\n", "\\end{cases}\n", "$$\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "al.bgc('seashell')\n", "#Entrer la matrice des coeff et le vecteur des termes de droite. Attention aux dimensions!\n", "A=[[1, 3, 1/3], [1, 0, -7],[-2,3,-4]]\n", "b=[[0],[2],[5]]" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "al.printA(A,b)\n", "al.manualOp(A,b)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### **EXERCICE 1**\n", "\n", "Parmis les systèmes ci-dessous, lesquels ont le même ensemble de solutions?\n", "\n", "$$\n", "a) \\begin{cases}\n", "3\\times 3\n", "\\end{cases}b) \\begin{cases}\n", "4\\times 4\n", "\\end{cases}c) \\begin{cases}\n", "3\\times 3\n", "\\end{cases}d) \\begin{cases}\n", "4\\times 4\n", "\\end{cases}e) \\begin{cases}\n", "3\\times 3\n", "\\end{cases}\n", "$$" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "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": 2 + "nbformat_minor": 4 } diff --git "a/Chapitre 1 - Systemes equations lineaires/1.5-1.6. Matrices Echelonn\303\251es.ipynb" "b/Chapitre 1 - Systemes equations lineaires/1.5-1.6. Matrices Echelonn\303\251es.ipynb" index 806e837..00061e9 100644 --- "a/Chapitre 1 - Systemes equations lineaires/1.5-1.6. Matrices Echelonn\303\251es.ipynb" +++ "b/Chapitre 1 - Systemes equations lineaires/1.5-1.6. Matrices Echelonn\303\251es.ipynb" @@ -1,146 +1,147 @@ { "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Concept(s)-clé(s) et théorie\n", "\n", "TBA." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ - "import AL_Fct as al\n", + "import Librairie.AL_Fct as al\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", "\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", "$$" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "A=[[2,-1], [1,2]]" ] }, { "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=[A]\n", - "m=np.matrix(A)" + "m=np.matrix(A)\n", + "print('executez la ligne suivante pour effectuer l\\'opération choisie')" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "m=al.echelonnage(i,j,r,alpha,A,m,MatriceList)" ] }, { "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=[[1,2,3,4], [5,6,7,8], [9,10,11,12]]\n", "b=[[-1],[-2],[-3]]" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "M=al.echelonMat('ER',A,b)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "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": 2 + "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 734b30c..292ef5d 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,301 +1,313 @@ { "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Concept(s)-clé(s) et théorie\n", "\n", "DÉFINITION 1 :\n", "Soit $B$ une matrice échelonnée. Alors les inconnues (du système linéaire associé) 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", "\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", "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 AL_Fct as al\n", + "import Librairie.AL_Fct as al\n", "import numpy as np\n", "import ipywidgets as widgets\n", "import random\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", "\n", "Soient les 4 systèmes ci-dessous. À l'aide de l'algorithme de Gauss, déterminer ceux qui sont consitants et inconsisitants. \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=[[-2,8],[1/2,-2]]\n", "b=[[0],[0]]" ] }, { "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": [ "\n", "print(\"Cliquer sur CTRL pour sélectionner plusieurs réponses\")\n", "inc=widgets.SelectMultiple(\n", " options=['a)', 'b)', 'c)', 'd)'],\n", " description='Incompatibles:',\n", " #layout=Layout(width='auto'),\n", " disabled=False,\n", " )\n", "comp=widgets.SelectMultiple(\n", " options=['a)', 'b)', 'c)', 'd)'],\n", " description='Compatibles:',\n", " disabled=False\n", " )\n", "\n", "def correction(inc,c): \n", " if 'a)' in c and 'c)' in c and 'd)' in c and 'b)' in inc:\n", " print(\"C'est correct!\")\n", " else:\n", " print(\"C'est faux. Veuillez rentrer d'autres valeurs\")\n", "\n", "out=interact_manual(correction,inc=inc,c=comp)\n", " \n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Concept(s)-clé(s) et théorie\n", "\n", "Solution homogène, solution particulière.\n", "Pour les systèmes compatibles, donner la solution du système sous forme paramétrique vectorielle\n", "$$\n", "s=p + t v\n", "$$ou $p$ est une solution particulière et $tv$ est un représentant des solutions de $Ax=0$\n", "\n", "Pour des systèmes compatibles.\n", "En 2 dimensions, l'ensemble de solution(s) peut être un point, une droite ou le plan tout entier.\n", "En 3 dimensions, l'ensemble de solution(s) peut être un point, une droite, un plan ou l'espace tout entier. " ] }, { "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", "$$\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": [ "al.Ex3Chapitre1_7()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**Vérification des exercices**\n", "\n", "À l'aide des cases ci-dessous, vous pouvez vérifier vos exercices. " ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "A=[[3, 5, -4], [-3, -2 ,4], [6, 1 ,-8]]\n", "b=[[0],[0],[0]]" ] }, { "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": [ - "v=[[4/3],[0],[2]]\n", + "# Axes \n", + "#al.drawLine([[0],[0],[0]], [[1],[0],[0]])\n", + "#al.drawLine([[0],[0],[0]], [[0],[1],[0]])\n", + "#al.drawLine([[0],[0],[0]], [[0],[0],[1]])\n", + "\n", "\n", + "v=[[4/3],[0],[2]]\n", "\n", - "fig=al.drawLine([[0],[0],[0]], v)" + "fig=al.drawLine([[10],[0],[0]], v)" ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] } ], "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": 2 + "nbformat_minor": 4 }