diff --git "a/Chapitre 2 - Algebre matricielle/2.4 Syst\303\250mes d'\303\251quations et matrices.ipynb" "b/Chapitre 2 - Algebre matricielle/2.4 Syst\303\250mes d'\303\251quations et matrices.ipynb" index e10945b..c5bfadd 100644 --- "a/Chapitre 2 - Algebre matricielle/2.4 Syst\303\250mes d'\303\251quations et matrices.ipynb" +++ "b/Chapitre 2 - Algebre matricielle/2.4 Syst\303\250mes d'\303\251quations et matrices.ipynb" @@ -1,353 +1,414 @@ { "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# **Concept(s)-clé(s) et théorie**\n", "\n", + "## Théorème\n", "Soit $A$ une matrice $n\\times n $ inversible. Alors pour tout vecteur $\\overrightarrow{b}\\in \\mathbb{R}^n$, l'équation $A\\overrightarrow{x}=\\overrightarrow{b}$ admet pour unique solution le vecteur $$\n", - "\\overrightarrow{\\tilde{x}}=A^{-1}\\overrightarrow{b}$$\n", - "De plus, si le système $A\\overrightarrow{x} = \\overrightarrow{b}$ admet une solution unique $\\overrightarrow{\\tilde{x}}$, alors $A$ est inversible et son inverse est tel que $\\overrightarrow{\\tilde{x}} = A^{-1}\\overrightarrow{b}$ pour chaque $\\overrightarrow{b} \\in \\mathbb{R}^n$." + "\\overrightarrow{\\tilde{x}}=A^{-1}\\overrightarrow{b}$$" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 2, "metadata": { "scrolled": true }, - "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" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "### EXAMPLE 1\n", - "Consider the linear system $Ax=b$, with:\n", + "### EXEMPLE 1\n", + "Considérez le système linéaire $ Ax = b $, avec:\n", "\\begin{equation}\n", "A = \n", "\\begin{bmatrix}\n", "2 & 0 & 1\\\\\n", "0 & 3 & 4 \\\\\n", "2 & 2 & 1\n", "\\end{bmatrix}; \\qquad b = \n", "\\begin{bmatrix}\n", "2\\\\\n", "4\\\\\n", "3\\\\\n", "\\end{bmatrix};\n", "\\end{equation}\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "scrolled": true }, "outputs": [], "source": [ "A = [[2, 0, 1], [0, 3, 4], [2, 2, 1]]\n", "b = [[2], [4], [3]]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "#### TASK 1: solve the linear system taking advantage of the Gauss elimination method" + "#### ÉTAPE 1: résoudre le système linéaire en utilisant la méthode d'élimination de Gauss" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "scrolled": true }, "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": { "scrolled": true }, "outputs": [], "source": [ "m=al.echelonnage(i, j, r, alpha, A, m, MatriceList, RHSList)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "scrolled": true }, "outputs": [], "source": [ - "print('Insert here the value of the computed solution')\n", - "x1 = [[11/16], [1/2], [5/8]]\n", + "print('Insérez ici la valeur de la solution calculée')\n", + "x1 = [[1], [1], [1]]\n", "res1 = al.SolOfSyst(x1, A, b)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "#### TASK 2: compute the inverse of matrix A ([see the Notebook 2.3](./2.3%20Matrices%20carrées%2C%20inversibles.ipynb)) and derive the solution to the linear system according to the obtained result" + "#### TASK 2: calculer l'inverse de la matrice A ([voir le Notebook 2.3](./2.3%20Matrices%20carrées%2C%20inversibles.ipynb)) et dériver la solution du système linéaire en fonction du résultat obtenu" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "scrolled": true }, "outputs": [], "source": [ "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": { "scrolled": true }, "outputs": [], "source": [ "m=al.echelonnage(i,j,r,alpha,A,m,MatriceList,RhSList)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "scrolled": true }, "outputs": [], "source": [ - "print('Insert here the value of the computed solution')\n", - "A_inv = [[0.3125,-0.125,0.1875], [-0.5,0,0.5], [0.375,0.25,-0.375]]\n", + "print('Insérez ici la valeur de la solution calculée')\n", + "A_inv = [[1,0,0], [0,1,0], [0,0,1]]\n", "x2 = np.dot(np.array(A_inv), np.array(b))\n", "res2 = al.SolOfSyst(x2, A, b)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "scrolled": true }, "outputs": [], "source": [ "if res1 and res2:\n", - " print(f'You are right! And additionally x1={x1} is the only solution to the linear system!')" + " print(f'Tu as raison! Et en plus, x1 = {x1} est la seule solution au système linéaire')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "### EXERCISE 1\n", - "Consider the generic linear system $Ax=b$ with $A \\in \\mathbb{R}^{n \\times n}$ and $b \\in \\mathbb{R}^n$; mark those of the following statements which could be true for some values of $A$ and $b$:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "scrolled": true - }, - "outputs": [], - "source": [ - "corrections.Ex1Chapitre2_4()" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### EXERCISE 2\n", - "Consider the following system of equations:\n", + "### EXERCICE 1\n", + "Considérez le système d'équations suivant:\n", "\\begin{equation}\n", "\\begin{cases}\n", "x_1 + 2x_2 - x_3 &=0\\\\\n", "2x_1 - x_2 - x_3 &=1\\\\\n", "x_1 - 2x_2 + x_3 &=2\n", "\\end{cases}\n", "\\end{equation}\n", - "Which of the following statements is true?" + "Laquelle des affirmations suivantes est correcte?" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 4, "metadata": { "scrolled": true }, - "outputs": [], + "outputs": [ + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "582406aa85cb40d9a7dbbbbb19a61cc6", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "interactive(children=(Checkbox(value=False, description='Le système admet une solution unique et elle est:$$\\\\…" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], "source": [ - "corrections.Ex2Chapitre2_4()" + "corrections.Ex1Chapitre2_4()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "#### You can run the following cells to help yourself in computing the solution of the linear system and the inverse of matrix $A$" + "#### Vous pouvez exécuter les cellules suivantes pour vous aider à calculer (éventuellement) la solution du système linéaire et l'inverse de la matrice $A$, si elle existe" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "scrolled": true }, "outputs": [], "source": [ "A = [[1,2,-1],[2,-1,-1],[1,-2,1]]\n", "b = [[1], [-2], [1]]" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "scrolled": true }, "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": { "scrolled": true }, "outputs": [], "source": [ "m=al.echelonnage(i, j, r, alpha, A, m, MatriceList, RHSList)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "scrolled": true }, "outputs": [], "source": [ "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": { "scrolled": true }, "outputs": [], "source": [ "m=al.echelonnage(i,j,r,alpha,A,m,MatriceList,RhSList)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "### EXERCISE 3\n", - "Consider the linear system $Ax=b$ with:\n", + "### EXERCICE 2\n", + "\n", + "Considérez le système linéaire $Ax = b$ avec:\n", "\\begin{equation}\n", "A = \n", "\\begin{bmatrix}\n", "1 & 3 & 2\\\\\n", "0 & 4 & 1\\\\\n", "1 & -5 & 0\n", "\\end{bmatrix}\n", "\\qquad b=\n", "\\begin{bmatrix}\n", "3\\\\\n", "5\\\\\n", "\\alpha\n", "\\end{bmatrix}\n", "\\end{equation}\n", - "Which of the following statements is true?" + "Laquelle des affirmations suivantes est correcte?" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 5, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "308254240ce34aef8905bac8d621bbf5", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "interactive(children=(Checkbox(value=False, description=\"Le système n'admet une solution unique que si $\\\\alph…" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], "source": [ - "corrections.Ex3Chapitre2_4()" + "corrections.Ex2Chapitre2_4()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "[Passez au notebook 2.5: Matrices élémentaires](2.5%20Matrices%20élémentaires.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" } }, "nbformat": 4, "nbformat_minor": 2 }