{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Requirement already satisfied: nacal in /home/marcos/.local/lib/python3.9/site-packages (0.1.13)\n", "Requirement already satisfied: sympy>=1.1.0 in /usr/lib/python3/dist-packages (from nacal) (1.7.1)\n", "Note: you may need to restart the kernel to use updated packages.\n" ] } ], "source": [ "pip install nacal" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "autoscroll": false, "ein.hycell": false, "ein.tags": "worksheet-0", "slideshow": { "slide_type": "-" } }, "outputs": [], "source": [ "from nacal import *\n", "from IPython.display import display, Math" ] }, { "cell_type": "markdown", "metadata": { "ein.tags": "worksheet-0", "slideshow": { "slide_type": "-" } }, "source": [ "$\n", "\\renewcommand{\\R}[1][{}]{{\\mathbb{R}}^{#1}}\n", "\\renewcommand{\\Z}[1][{}]{{\\mathbb{Z}}^{#1}}\n", "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n", "\\renewcommand{\\getitemR}[1]{\\getItem{#1}}\n", "\\renewcommand{\\getItem}{\\pmb{\\mid}}\n", "\\renewcommand{\\elemR}[2]{{#1}^{\\phantom{\\T}}_{\\getitemR{#2}}} \n", "\\renewcommand{\\elemRP}[2]{{\\big(#1\\big)}^{\\phantom{\\T}}_{\\getitemR{#2}}} \n", "\\renewcommand{\\elemRPE}[2]{\\big({#1}^{\\phantom{\\T}}_{\\getitemR{#2}}\\big)}\n", "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n", "\\renewcommand{\\Vect}[2][{}]{{\\boldsymbol{#2}}_{#1}}\n", "\\renewcommand{\\eleVR}[2] {\\elemR {\\Vect{#1}}{#2}}\t % con subindices\n", "\\renewcommand{\\eleVRP}[2] {\\elemRP {\\Vect{#1}}{#2}} % con subindices y paréntesis interior\n", "\\renewcommand{\\eleVRPE}[2]{\\elemRPE{\\Vect{#1}}{#2}} % con subindices y paréntesis exterior\n", "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n", "\\renewcommand{\\VectC}[2][{}] {\\elemR {\\Mat{#2}}{#1}} % con subindices\n", "\\renewcommand{\\VectCP}[2][{}] {\\elemRP {\\Mat{#2}}{#1}} % con subindices y paréntesis\n", "\\renewcommand{\\VectCPE}[2][{}]{\\elemRPE{\\Mat{#2}}{#1}} % con subindices y paréntesis exterior\n", "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n", "\\renewcommand{\\mat}[1]{\\mathbf{#1}}\n", "\\renewcommand{\\Mat} [2][{}]{{\\mat{#2}}_{#1}} \n", "\\renewcommand{\\T}{\\intercal}\n", "\\renewcommand{\\MatT}[2][{}]{{\\mat{#2}}^{\\T}_{#1}}\n", "\\renewcommand{\\VectC}[2][{}] {\\elemR {\\Mat{#2}}{#1}} % con subindices\n", "\\renewcommand{\\VectCP}[2][{}] {\\elemRP {\\Mat{#2}}{#1}} % con subindices y paréntesis\n", "\\renewcommand{\\VectCPE}[2][{}] {\\elemRPE {\\Mat{#2}}{#1}} % con subindices y paréntesis exterior\n", "\\renewcommand{\\VectCC}[2][{}] {\\elemRR {\\Mat{#2}}{#1}} % con ()\n", "\\renewcommand{\\VectCCC}[2][{}] {\\elemRRR{\\Mat{#2}}{#1}} % con texto \"col\"\n", "%SELECCIÓNA de FILAS y COlUMNAS DE UNA MATRIZ TRANSPUESTA PARA GENERAR UN VECTOR DE Rn\n", "\\renewcommand{\\VectTC}[2][{}] {\\elemR{\\MatT{#2}\\!}{#1}} % con subindices\n", "\\renewcommand{\\VectTCC}[2][{}] {\\elemRR{ \\MatT{#2}}{#1}} % con ()\n", "\\renewcommand{\\VectTCCC}[2][{}] {\\elemRRR{\\MatT{#2}}{#1}} % con texto \"col\"\n", "$" ] }, { "cell_type": "markdown", "metadata": { "ein.tags": "worksheet-0", "slideshow": { "slide_type": "-" } }, "source": [ "${\\huge\\text{Jupyter notebook de la Lección 17}}$" ] }, { "cell_type": "markdown", "metadata": { "ein.tags": "worksheet-0", "slideshow": { "slide_type": "-" } }, "source": [ "**Índice de contenidos de este notebook** (Requiere ejecutar todo el Notebook para que aparezca el índice)\n", "
" ] }, { "cell_type": "markdown", "metadata": { "ein.tags": "worksheet-0", "slideshow": { "slide_type": "-" } }, "source": [ "# Autovalores y autovectores\n", "\n", "Considere la siguiente matriz cuadrada\n" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/html": [ "

$\\left[ \\begin{array}{cc}0&1\\\\1&0\\\\ \\end{array} \\right]$

" ], "text/plain": [ "Matrix([Vector([0, 1]), Vector([1, 0])])" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "A=Matrix([[0,1],[1,0]])\n", "A" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/html": [ "

$\\begin{pmatrix}1\\\\1\\end{pmatrix}$

" ], "text/plain": [ "Vector([1, 1])" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "x=Vector( [1, 1] )\n", "x" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/html": [ "

$\\begin{pmatrix}1\\\\1\\end{pmatrix}$

" ], "text/plain": [ "Vector([1, 1])" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "A*x" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "text/html": [ "

$\\begin{pmatrix}-5\\\\5\\end{pmatrix}$

" ], "text/plain": [ "Vector([-5, 5])" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "y=Vector( [-5, 5 ] ) #(lambda = -1)\n", "y" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "data": { "text/html": [ "

$\\begin{pmatrix}5\\\\-5\\end{pmatrix}$

" ], "text/plain": [ "Vector([5, -5])" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "A*y" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "data": { "text/html": [ "

$\\left[ \\begin{array}{cc}3&1\\\\1&3\\\\ \\end{array} \\right]$

" ], "text/plain": [ "Matrix([Vector([3, 1]), Vector([1, 3])])" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "A=Matrix([[3,1],[1,3]])\n", "A" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "data": { "text/html": [ "

$\\begin{pmatrix}1\\\\1\\end{pmatrix}$

" ], "text/plain": [ "Vector([1, 1])" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "x=Vector( [1, 1] ) # lambda=4\n", "x" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [ { "data": { "text/html": [ "

$\\begin{pmatrix}4\\\\4\\end{pmatrix}$

" ], "text/plain": [ "Vector([4, 4])" ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "A*x" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [ { "data": { "text/html": [ "

$\\begin{pmatrix}-1\\\\1\\end{pmatrix}$

" ], "text/plain": [ "Vector([-1, 1])" ] }, "execution_count": 11, "metadata": {}, "output_type": "execute_result" } ], "source": [ "y=Vector( [-1, 1] ) # lambda=2\n", "y" ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [ { "data": { "text/html": [ "

$\\begin{pmatrix}-2\\\\2\\end{pmatrix}$

" ], "text/plain": [ "Vector([-2, 2])" ] }, "execution_count": 12, "metadata": {}, "output_type": "execute_result" } ], "source": [ " A*y" ] }, { "cell_type": "code", "execution_count": 13, "metadata": {}, "outputs": [ { "data": { "text/html": [ "

$\\left[ \\begin{array}{cc}0&-1\\\\1&0\\\\ \\end{array} \\right]$

" ], "text/plain": [ "Matrix([Vector([0, 1]), Vector([-1, 0])])" ] }, "execution_count": 13, "metadata": {}, "output_type": "execute_result" } ], "source": [ "Q = Matrix( [ [0, -1], [1, 0] ] )\n", "Q" ] }, { "cell_type": "code", "execution_count": 14, "metadata": {}, "outputs": [ { "data": { "text/html": [ "

$\\begin{pmatrix}1\\\\2\\end{pmatrix}$

" ], "text/plain": [ "Vector([1, 2])" ] }, "execution_count": 14, "metadata": {}, "output_type": "execute_result" } ], "source": [ "x = Vector( [1, 2])\n", "x" ] }, { "cell_type": "code", "execution_count": 15, "metadata": {}, "outputs": [ { "data": { "text/html": [ "

$\\begin{pmatrix}-2\\\\1\\end{pmatrix}$

" ], "text/plain": [ "Vector([-2, 1])" ] }, "execution_count": 15, "metadata": {}, "output_type": "execute_result" } ], "source": [ "z=Q*x\n", "z" ] }, { "cell_type": "code", "execution_count": 16, "metadata": {}, "outputs": [ { "data": { "text/html": [ "

$\\begin{pmatrix}1\\\\2\\end{pmatrix}$

" ], "text/plain": [ "Vector([1, 2])" ] }, "execution_count": 16, "metadata": {}, "output_type": "execute_result" } ], "source": [ "Q*Q*Q*Q*x" ] }, { "cell_type": "code", "execution_count": 17, "metadata": {}, "outputs": [ { "data": { "text/html": [ "

$\\left[\\begin{pmatrix}1\\\\2\\end{pmatrix};\\;\\begin{pmatrix}-2\\\\1\\end{pmatrix};\\;\\begin{pmatrix}-1\\\\-2\\end{pmatrix};\\;\\begin{pmatrix}2\\\\-1\\end{pmatrix};\\;\\begin{pmatrix}1\\\\2\\end{pmatrix};\\;\\begin{pmatrix}-2\\\\1\\end{pmatrix};\\;\\begin{pmatrix}-1\\\\-2\\end{pmatrix};\\;\\begin{pmatrix}2\\\\-1\\end{pmatrix};\\;\\begin{pmatrix}1\\\\2\\end{pmatrix};\\;\\begin{pmatrix}-2\\\\1\\end{pmatrix};\\;\\begin{pmatrix}-1\\\\-2\\end{pmatrix};\\;\\begin{pmatrix}2\\\\-1\\end{pmatrix};\\;\\begin{pmatrix}1\\\\2\\end{pmatrix};\\right]$

" ], "text/plain": [ "Sistema([Vector([1, 2]); Vector([-2, 1]); Vector([-1, -2]); Vector([2, -1]); Vector([1, 2]); Vector([-2, 1]); Vector([-1, -2]); Vector([2, -1]); Vector([1, 2]); Vector([-2, 1]); Vector([-1, -2]); Vector([2, -1]); Vector([1, 2]);])" ] }, "execution_count": 17, "metadata": {}, "output_type": "execute_result" } ], "source": [ "S = Sistema([ (Q**n)*x for n in range(0,13) ])\n", "S" ] }, { "cell_type": "code", "execution_count": 18, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]" ] }, "execution_count": 18, "metadata": {}, "output_type": "execute_result" } ], "source": [ "[ (S|i) * (S|(i+1)) for i in range(1,13) ]" ] }, { "cell_type": "code", "execution_count": 19, "metadata": {}, "outputs": [ { "data": { "text/html": [ "

$\\left[ \\begin{array}{cc}3&1\\\\0&3\\\\ \\end{array} \\right]$

" ], "text/plain": [ "Matrix([Vector([3, 0]), Vector([1, 3])])" ] }, "execution_count": 19, "metadata": {}, "output_type": "execute_result" } ], "source": [ "A = Matrix( [[3, 1], [0, 3]] )\n", "A" ] }, { "cell_type": "code", "execution_count": 20, "metadata": {}, "outputs": [ { "data": { "text/latex": [ "$\\displaystyle \\left[ \\begin{array}{cc}0&1\\\\0&0\\\\ \\hline 1&0\\\\0&1\\\\ \\end{array} \\right]$" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "

$\\mathcal{L}\\left(\\ \\left[\\begin{pmatrix}1\\\\0\\end{pmatrix};\\right]\\ \\right)$

" ], "text/plain": [ "Combinaciones lineales de (Sistema([Vector([1, 0]);]))" ] }, "execution_count": 20, "metadata": {}, "output_type": "execute_result" } ], "source": [ "Homogenea(A-3*I(2),1)" ] }, { "cell_type": "code", "execution_count": 21, "metadata": {}, "outputs": [ { "data": { "text/html": [ "

$\\begin{pmatrix}1\\\\0\\end{pmatrix}$

" ], "text/plain": [ "Vector([1, 0])" ] }, "execution_count": 21, "metadata": {}, "output_type": "execute_result" } ], "source": [ "x = Vector( [1, 0] )\n", "x" ] }, { "cell_type": "code", "execution_count": 22, "metadata": {}, "outputs": [ { "data": { "text/html": [ "

$\\begin{pmatrix}3\\\\0\\end{pmatrix}$

" ], "text/plain": [ "Vector([3, 0])" ] }, "execution_count": 22, "metadata": {}, "output_type": "execute_result" } ], "source": [ "A*x" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Ejercicio 1" ] }, { "cell_type": "code", "execution_count": 23, "metadata": {}, "outputs": [ { "data": { "text/html": [ "

$\\left[ \\begin{array}{ccc}-3&4&-4\\\\-3&5&-3\\\\-1&2&0\\\\ \\end{array} \\right]$

" ], "text/plain": [ "Matrix([Vector([-3, -3, -1]), Vector([4, 5, 2]), Vector([-4, -3, 0])])" ] }, "execution_count": 23, "metadata": {}, "output_type": "execute_result" } ], "source": [ "A=Matrix([[-3,4,-4], [-3,5,-3], [-1,2,0]])\n", "A" ] }, { "cell_type": "code", "execution_count": 24, "metadata": {}, "outputs": [ { "data": { "text/html": [ "

$\\begin{pmatrix}0\\\\1\\\\1\\end{pmatrix}$

" ], "text/plain": [ "Vector([0, 1, 1])" ] }, "execution_count": 24, "metadata": {}, "output_type": "execute_result" } ], "source": [ "m = Vector([0,1,1]);m" ] }, { "cell_type": "code", "execution_count": 25, "metadata": {}, "outputs": [ { "data": { "text/html": [ "

$\\begin{pmatrix}0\\\\2\\\\2\\end{pmatrix}$

" ], "text/plain": [ "Vector([0, 2, 2])" ] }, "execution_count": 25, "metadata": {}, "output_type": "execute_result" } ], "source": [ "A*m" ] }, { "cell_type": "code", "execution_count": 26, "metadata": {}, "outputs": [ { "data": { "text/html": [ "

$\\begin{pmatrix}2\\\\1\\\\0\\end{pmatrix}$

" ], "text/plain": [ "Vector([2, 1, 0])" ] }, "execution_count": 26, "metadata": {}, "output_type": "execute_result" } ], "source": [ "v= Vector([2,1,0]); v" ] }, { "cell_type": "code", "execution_count": 27, "metadata": {}, "outputs": [ { "data": { "text/html": [ "

$\\begin{pmatrix}-2\\\\-1\\\\0\\end{pmatrix}$

" ], "text/plain": [ "Vector([-2, -1, 0])" ] }, "execution_count": 27, "metadata": {}, "output_type": "execute_result" } ], "source": [ "A*v" ] }, { "cell_type": "code", "execution_count": 28, "metadata": {}, "outputs": [ { "data": { "text/html": [ "

$\\begin{pmatrix}-2\\\\-1\\\\0\\end{pmatrix}$

" ], "text/plain": [ "Vector([-2, -1, 0])" ] }, "execution_count": 28, "metadata": {}, "output_type": "execute_result" } ], "source": [ "-1*v" ] }, { "cell_type": "code", "execution_count": 29, "metadata": {}, "outputs": [ { "data": { "text/html": [ "

$\\begin{pmatrix}1\\\\0\\\\-1\\end{pmatrix}$

" ], "text/plain": [ "Vector([1, 0, -1])" ] }, "execution_count": 29, "metadata": {}, "output_type": "execute_result" } ], "source": [ "w=Vector([1,0,-1]);w" ] }, { "cell_type": "code", "execution_count": 30, "metadata": {}, "outputs": [ { "data": { "text/html": [ "

$\\begin{pmatrix}1\\\\0\\\\-1\\end{pmatrix}$

" ], "text/plain": [ "Vector([1, 0, -1])" ] }, "execution_count": 30, "metadata": {}, "output_type": "execute_result" } ], "source": [ "A*w" ] }, { "cell_type": "code", "execution_count": 31, "metadata": {}, "outputs": [ { "data": { "text/html": [ "

$\\begin{pmatrix}1\\\\0\\\\-1\\end{pmatrix}$

" ], "text/plain": [ "Vector([1, 0, -1])" ] }, "execution_count": 31, "metadata": {}, "output_type": "execute_result" } ], "source": [ "1*w" ] }, { "cell_type": "code", "execution_count": 32, "metadata": {}, "outputs": [ { "data": { "text/html": [ "

$\\left[ \\begin{array}{ccc}-5&4&-4\\\\-3&3&-3\\\\-1&2&-2\\\\ \\end{array} \\right]$

" ], "text/plain": [ "Matrix([Vector([-5, -3, -1]), Vector([4, 3, 2]), Vector([-4, -3, -2])])" ] }, "execution_count": 32, "metadata": {}, "output_type": "execute_result" } ], "source": [ "A-2*I(3)" ] }, { "cell_type": "code", "execution_count": 33, "metadata": {}, "outputs": [ { "data": { "text/latex": [ "$\\displaystyle \\left[ \\begin{array}{ccc}-5&4&-4\\\\-3&3&-3\\\\-1&2&-2\\\\ \\hline 1&0&0\\\\0&1&0\\\\0&0&1\\\\ \\end{array} \\right]\\xrightarrow{\\underset{\\begin{subarray}{c} \\left[\\left(5\\right)\\mathbf{2}\\right]\\\\\\left[\\left(4\\right)\\mathbf{1}+\\mathbf{2} \\right]\\\\\\left[\\left(5\\right)\\mathbf{3}\\right]\\\\\\left[\\left(-4\\right)\\mathbf{1}+\\mathbf{3} \\right]\\end{subarray}}{\\pmb{\\tau}}}\\left[ \\begin{array}{ccc}-5&0&0\\\\-3&3&-3\\\\-1&6&-6\\\\ \\hline 1&4&-4\\\\0&5&0\\\\0&0&5\\\\ \\end{array} \\right]\\xrightarrow{\\underset{\\begin{subarray}{c} \\left[\\left(1\\right)\\mathbf{2}+\\mathbf{3} \\right]\\end{subarray}}{\\pmb{\\tau}}}\\left[ \\begin{array}{ccc}-5&0&0\\\\-3&3&0\\\\-1&6&0\\\\ \\hline 1&4&0\\\\0&5&5\\\\0&0&5\\\\ \\end{array} \\right]$" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "

$\\mathcal{L}\\left(\\ \\left[\\begin{pmatrix}0\\\\5\\\\5\\end{pmatrix};\\right]\\ \\right)$

" ], "text/plain": [ "Combinaciones lineales de (Sistema([Vector([0, 5, 5]);]))" ] }, "execution_count": 33, "metadata": {}, "output_type": "execute_result" } ], "source": [ "Homogenea(A-2*I(3),1)" ] }, { "cell_type": "markdown", "metadata": { "ein.tags": "worksheet-0", "slideshow": { "slide_type": "-" } }, "source": [ "\n", "---- FIN DE LA LECCIÓN -----\n", "\n", "\n", "\n", "Lo que sigue es sólo para crear un índice de contenidos de este notebook (y se muestra al principio de la página)" ] }, { "cell_type": "code", "execution_count": 34, "metadata": { "autoscroll": false, "ein.hycell": false, "ein.tags": "worksheet-0", "slideshow": { "slide_type": "-" } }, "outputs": [ { "data": { "application/javascript": [ "$.getScript('https://kmahelona.github.io/ipython_notebook_goodies/ipython_notebook_toc.js')\n", "$.getScript('https://kmahelona.github.io/ipython_notebook_goodies/ipython_notebook_toc.js')\n" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "%%javascript\n", "$.getScript('https://kmahelona.github.io/ipython_notebook_goodies/ipython_notebook_toc.js')\n", "$.getScript('https://kmahelona.github.io/ipython_notebook_goodies/ipython_notebook_toc.js')" ] } ], "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.9.2" }, "name": "Leccion05.ipynb" }, "nbformat": 4, "nbformat_minor": 2 }