diff --git a/Chapitre 8 - Valeurs propres, vecteurs propres, diagonalisation/8.9 Valeurs propres complexes.ipynb b/Chapitre 8 - Valeurs propres, vecteurs propres, diagonalisation/8.9 Valeurs propres complexes.ipynb
index 52ce6c7..4573cf1 100644
--- a/Chapitre 8 - Valeurs propres, vecteurs propres, diagonalisation/8.9 Valeurs propres complexes.ipynb
+++ b/Chapitre 8 - Valeurs propres, vecteurs propres, diagonalisation/8.9 Valeurs propres complexes.ipynb
@@ -1,224 +1,458 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Théorème fondamental de l'algèbre:\n",
"\n",
"Soit $p(x) \\in \\mathbb{P}(\\mathbb{C})$ un polynôme à coefficients dans $\\mathbb{C}$. Alors $p(x)$ se factorise en un produit de facteurs linéaires, i.e. il existe $\\lambda_{1}, \\ldots, \\lambda_{r} \\in \\mathbb{R}$ et\n",
"$\\mu_{1}, \\ldots, \\mu_{2 s} \\in \\mathbb{C}$ tels que\n",
"$$\n",
"p(x)=\\pm\\left(x-\\lambda_{1}\\right) \\cdots\\left(x-\\lambda_{r}\\right)\\left(x-\\mu_{1}\\right) \\cdots\\left(x-\\mu_{2 s}\\right)\n",
"$$\n",
"\n",
"De plus, si $v=a+i b \\in \\mathbb{C}$ est une racine de $p(x),$ alors $\\bar{\\mu}=a-i b$ est également une racine de $p(x)$\n",
"\n",
"### Critère de diagonalisabilité sur $\\mathbb{C}$ \n",
"\n",
"Une transformation linéaire $\\phi: V \\rightarrow V$ d'un $\\mathbb{C}$ -espace vectoriel de dimension finie est diagonalisable si et seulement si la multiplicité géométrique de chaque valeur propre de $\\phi$ est égale à sa multipicité algébrique."
]
},
{
"cell_type": "code",
- "execution_count": 1,
+ "execution_count": 2,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
" \n",
" "
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"import sys, os\n",
"sys.path.append('../Librairie')\n",
"import AL_Fct as al\n",
"import numpy as np\n",
"import sympy as sp\n",
"from IPython.utils import io\n",
"from IPython.display import display, Latex, Markdown\n",
"import plotly\n",
"import plotly.graph_objects as go\n",
"from Ch8_lib import *\n",
"from sympy import I"
]
},
{
"cell_type": "code",
"execution_count": 290,
"metadata": {},
"outputs": [
{
"data": {
"text/latex": [
"$\\displaystyle \\left[\\begin{matrix}0 & -1 & 0 & 0\\\\0 & -1 & -1 & -1\\\\-1 & 0 & 0 & -1\\\\-1 & 0 & -1 & 0\\end{matrix}\\right]$"
],
"text/plain": [
"Matrix([\n",
"[ 0, -1, 0, 0],\n",
"[ 0, -1, -1, -1],\n",
"[-1, 0, 0, -1],\n",
"[-1, 0, -1, 0]])"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"A1 = sp.Matrix([[0, 1], [-1, 0]])\n",
"A2 = sp.Matrix([[0, 0, 0], [0, -2, 1], [-2, -1, -2]])\n",
"A3 = sp.Matrix([[0, -1, 0, 0], [0, -1, -1, -1], [-1, 0, 0, -1], [-1, 0, -1, 0]])\n",
"\n",
"display(A3)\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"D = sp.Matrix([[1-I, 0, 0], [0, 1+I, 0], [0, 0, 2]])\n",
"\n",
"P * D * P**-1"
]
},
{
"cell_type": "code",
"execution_count": 284,
"metadata": {},
"outputs": [
{
"data": {
"text/latex": [
"$\\displaystyle \\left[\\begin{matrix}-3 & -1 & -2 & -3\\\\0 & -3 & 2 & -2\\\\3 & 0 & 0 & 3\\\\0 & 0 & -1 & -2\\end{matrix}\\right]$"
],
"text/plain": [
"Matrix([\n",
"[-3, -1, -2, -3],\n",
"[ 0, -3, 2, -2],\n",
"[ 3, 0, 0, 3],\n",
"[ 0, 0, -1, -2]])"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"{-2: 1, -3: 1, -3/2 - 3*sqrt(3)*I/2: 1, -3/2 + 3*sqrt(3)*I/2: 1}"
]
},
"execution_count": 284,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"A = np.random.randint(-3, 4, (4,4))\n",
"A = sp.Matrix(A)\n",
"display(A)\n",
"A.eigenvals()"
]
},
{
"cell_type": "code",
"execution_count": 83,
"metadata": {},
"outputs": [
{
"data": {
"text/latex": [
"$\\displaystyle \\left[\\begin{matrix}-1 & 0 & 1 & 1\\\\1 & 0 & 0 & -1\\\\1 & 1 & 0 & 0\\\\0 & 0 & 1 & -1\\end{matrix}\\right]$"
],
"text/plain": [
"Matrix([\n",
"[-1, 0, 1, 1],\n",
"[ 1, 0, 0, -1],\n",
"[ 1, 1, 0, 0],\n",
"[ 0, 0, 1, -1]])"
]
},
"execution_count": 83,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"A"
]
},
{
"cell_type": "code",
- "execution_count": 68,
+ "execution_count": 18,
"metadata": {},
"outputs": [
{
"data": {
+ "text/latex": [
+ "$\\displaystyle \\left[\\begin{matrix}1 & 0 & 0 & 1 + i\\\\0 & 1 & 0 & 1 - i\\\\0 & 0 & 1 & -1\\\\0 & 0 & 0 & 0\\end{matrix}\\right]$"
+ ],
"text/plain": [
- "{1: 1, -2: 1, -I: 1, I: 1}"
+ "Matrix([\n",
+ "[1, 0, 0, 1 + I],\n",
+ "[0, 1, 0, 1 - I],\n",
+ "[0, 0, 1, -1],\n",
+ "[0, 0, 0, 0]])"
]
},
- "execution_count": 68,
"metadata": {},
- "output_type": "execute_result"
+ "output_type": "display_data"
}
],
"source": [
"A = sp.Matrix([[0, -1, 0, 0], [0, -1, -1, -1], [-1, 0, 0, -1], [-1, 0, -1, 0]])\n",
- "A.eigenvals()"
+ "eig = A.eigenvects()\n",
+ "\n",
+ "\n",
+ "A_ech = (A - sp.eye(4)*I).rref()\n",
+ "display(sp.simplify(A_ech[0]))"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 11,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/latex": [
+ "$\\displaystyle \\left[\\begin{matrix}-1 - i\\\\-1 + i\\\\1\\\\1\\end{matrix}\\right]$"
+ ],
+ "text/plain": [
+ "Matrix([\n",
+ "[-1 - I],\n",
+ "[-1 + I],\n",
+ "[ 1],\n",
+ "[ 1]])"
+ ]
+ },
+ "execution_count": 11,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "sp.simplify(eig[3][2][0])"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 83,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "def diagonalizeComplex(A):\n",
+ " if not A.is_diagonalizable():\n",
+ " display(Latex(\"A n'est pas diagonalisable.\"))\n",
+ " return\n",
+ " \n",
+ " lamda = sp.symbols('lamda')\n",
+ " poly = A.charpoly(lamda)\n",
+ " poly = sp.factor(poly, extension=[I])\n",
+ " eig = A.eigenvects()\n",
+ " \n",
+ " eigenval = []\n",
+ " mult = []\n",
+ " \n",
+ " for el in eig:\n",
+ " eigenval.append(sp.simplify(el[0]))\n",
+ " mult.append(el[1])\n",
+ " \n",
+ " display(Latex(\"Le polynome caractéristique de la matrice $A = \" + latexp(A) + \"$ est $ c_A (\\lambda) = \" + sp.latex(poly) + \"$\"))\n",
+ " \n",
+ " display(Latex(\"Les valeurs propres de A sont donc: \" + listsp_to_str(eigenval)))\n",
+ " \n",
+ " display(Latex(\"Pour chaque valeur propre $\\lambda$, on calcule une base de l'espace propre associé \"\n",
+ " \"($\\ker (A -\\lambda I)$). On se sert ensuite des vecteurs propres (vecteur de base de l'espaces\" +\n",
+ " \" propre) pour diagonaliser la matrice.\"))\n",
+ " \n",
+ " \n",
+ " k = 0\n",
+ " P = sp.zeros(A.shape[0], A.shape[0])\n",
+ " D = sp.zeros(A.shape[0], A.shape[0])\n",
+ " for i, l in enumerate(eigenval):\n",
+ " display(Latex(\"Pour la valeur propres $\\lambda = \" + sp.latex(l) + \"$, on trouve une base de l'espace propre associé. \"\n",
+ " + \"On obtient comme base: \" + listsp_to_str(eig[i][2])))\n",
+ " \n",
+ " for vec in eig[i][2]:\n",
+ " P[:, k] = vec\n",
+ " D[k, k] = l\n",
+ " k+=1\n",
+ " \n",
+ " P = sp.simplify(P)\n",
+ " D = sp.simplify(D)\n",
+ " \n",
+ " display(Latex(\"Avec la matrice $D= \" + latexp(D) + \"$ on obtient la matrice $P = \" + latexp(P) + \"$.\"))\n",
+ " \n",
+ " display(Latex(\"La matrice $A$ se diagonalise donc avec comme $A = P D P^{-1}$\"))\n",
+ " \n",
+ " display(Latex(\"$P D P^{-1} = \" + latexp(P) + latexp(D) + latexp(sp.simplify(P**-1)) + \" = \" + \n",
+ " latexp(sp.simplify(P*D*P**-1)) +\" = A$ \"))\n",
+ " \n",
+ "def listsp_to_str(splist):\n",
+ " out = \"$\" + sp.latex(sp.simplify(splist[0]), mat_delim='(') + \"$\"\n",
+ " \n",
+ " if len(splist)==1:\n",
+ " return out\n",
+ " \n",
+ " for i in range(1, len(splist)-1):\n",
+ " out += \", $\" + sp.latex(sp.simplify(splist[i]), mat_delim='(') + \"$\"\n",
+ " \n",
+ " out += \" et $\" + sp.latex(sp.simplify(splist[-1]), mat_delim='(') + \"$\"\n",
+ " return out"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 84,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/latex": [
+ "Le polynome caractéristique de la matrice $A = \\left(\\begin{matrix}0 & -1 & 0 & 0\\\\0 & -1 & -1 & -1\\\\-1 & 0 & 0 & -1\\\\-1 & 0 & -1 & 0\\end{matrix}\\right)$ est $ c_A (\\lambda) = \\left(\\lambda - 1\\right) \\left(\\lambda + 2\\right) \\left(\\lambda - i\\right) \\left(\\lambda + i\\right)$"
+ ],
+ "text/plain": [
+ ""
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/latex": [
+ "Les valeurs propres de A sont donc: $-2$, $1$, $- i$ et $i$"
+ ],
+ "text/plain": [
+ ""
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/latex": [
+ "Pour chaque valeur propre $\\lambda$, on calcule une base de l'espace propre associé ($\\ker (A -\\lambda I)$). On se sert ensuite des vecteurs propres (vecteur de base de l'espaces propre) pour diagonaliser la matrice."
+ ],
+ "text/plain": [
+ ""
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/latex": [
+ "Pour la valeur propres $\\lambda = -2$, on trouve une base de l'espace propre associé. On obtient comme base: $\\left(\\begin{matrix}1\\\\2\\\\1\\\\1\\end{matrix}\\right)$"
+ ],
+ "text/plain": [
+ ""
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/latex": [
+ "Pour la valeur propres $\\lambda = 1$, on trouve une base de l'espace propre associé. On obtient comme base: $\\left(\\begin{matrix}0\\\\0\\\\-1\\\\1\\end{matrix}\\right)$"
+ ],
+ "text/plain": [
+ ""
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/latex": [
+ "Pour la valeur propres $\\lambda = - i$, on trouve une base de l'espace propre associé. On obtient comme base: $\\left(\\begin{matrix}-1 + i\\\\-1 - i\\\\1\\\\1\\end{matrix}\\right)$"
+ ],
+ "text/plain": [
+ ""
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/latex": [
+ "Pour la valeur propres $\\lambda = i$, on trouve une base de l'espace propre associé. On obtient comme base: $\\left(\\begin{matrix}-1 - i\\\\-1 + i\\\\1\\\\1\\end{matrix}\\right)$"
+ ],
+ "text/plain": [
+ ""
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/latex": [
+ "Avec la matrice $D= \\left(\\begin{matrix}-2 & 0 & 0 & 0\\\\0 & 1 & 0 & 0\\\\0 & 0 & - i & 0\\\\0 & 0 & 0 & i\\end{matrix}\\right)$ on obtient la matrice $P = \\left(\\begin{matrix}1 & 0 & -1 + i & -1 - i\\\\2 & 0 & -1 - i & -1 + i\\\\1 & -1 & 1 & 1\\\\1 & 1 & 1 & 1\\end{matrix}\\right)$."
+ ],
+ "text/plain": [
+ ""
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/latex": [
+ "La matrice $A$ se diagonalise donc avec comme $A = P D P^{-1}$"
+ ],
+ "text/plain": [
+ ""
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/latex": [
+ "$P D P^{-1} = \\left(\\begin{matrix}1 & 0 & -1 + i & -1 - i\\\\2 & 0 & -1 - i & -1 + i\\\\1 & -1 & 1 & 1\\\\1 & 1 & 1 & 1\\end{matrix}\\right)\\left(\\begin{matrix}-2 & 0 & 0 & 0\\\\0 & 1 & 0 & 0\\\\0 & 0 & - i & 0\\\\0 & 0 & 0 & i\\end{matrix}\\right)\\left(\\begin{matrix}\\frac{1}{5} & \\frac{1}{5} & \\frac{1}{5} & \\frac{1}{5}\\\\0 & 0 & - \\frac{1}{2} & \\frac{1}{2}\\\\- \\frac{1}{10} - \\frac{3 i}{10} & - \\frac{1}{10} + \\frac{i}{5} & \\frac{3}{20} - \\frac{i}{20} & \\frac{3}{20} - \\frac{i}{20}\\\\\\frac{i \\left(3 + i\\right)}{10} & \\frac{i \\left(-2 + i\\right)}{10} & \\frac{3}{20} + \\frac{i}{20} & \\frac{3}{20} + \\frac{i}{20}\\end{matrix}\\right) = \\left(\\begin{matrix}0 & -1 & 0 & 0\\\\0 & -1 & -1 & -1\\\\-1 & 0 & 0 & -1\\\\-1 & 0 & -1 & 0\\end{matrix}\\right) = A$ "
+ ],
+ "text/plain": [
+ ""
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
+ "source": [
+ "diagonalizeComplex(A)"
]
},
{
"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.7.2"
}
},
"nbformat": 4,
"nbformat_minor": 2
}