Está en la página 1de 11

Laboratorio No.

4
Algebra Lineal - MAT1203
PrimerSemestre2023

La matriz Inversa y Determinantes

El comando Inverse[A] calcula la matriz inversa de una matriz cuadrada A.


El comando RowReduce[B] calcula la escalonada reducida de la matriz B.

Una matriz cuadrada de n x n es invertible si existe B cuadrada de n x n


de tal forma que AB = BA = I , I es la matriz identidad de n x n.

I = { e1 e2 ... en } donde ei = {0, ... 0, 1 , 0, ..., 0} 1 en la i-ésima posición.

Desde el punto de vista del pivoteo,


Una matriz cuadrada de n x n es invertible si y solo si la matriz tiene n pivotes.

Llamemos b1 , b2 , . . . , bn las columnas de la inversa.

Calcular la inversa es resolver AB =  A b1 A b2 . . . A bn ] = [ e1 e2 ... en ]

Es decir, hay que resolver n sistemas : A x = ei , i = 1 , . . . , n.


Hay que pivotear (escalonada reducida) [A e1 ] y se encuentra la primera columna de
la inversa,
pivotear [A e2 ] y se encuentra la segunda columna de la inversa y así sucesivamente.

En vez de repetir el proceso cada vez, se pivotea directamente la matriz de n x 2n

Printed by Wolfram Mathematica Student Edition


2 Lab4F_Pauta.nb

[A e1 e2 . . . en ] . Una vez pivoteada, en la posición de A quedará la identidad I de


nxn
y en vez de la matriz {e1 e2 . . . en } quedará la inversa.

Ejemplo.
Consideremos la matriz A

In[98]:= A = {{1, 0, 2}, {1, 0, 1}, {1, 1, 1}}

Out[98]= {{1, 0, 2}, {1, 0, 1}, {1, 1, 1}}

Calculemos la inversa, si existe por pivoteo

In[99]:= AA = {1, 0, 2}, {1, 0, 1}, {1, 1, 1}, {1, 0, 0}, {0, 1, 0}, {0, 0, 1}}

In[99]:= A1 = Transpose[Insert[Transpose[A], {1, 0, 0}, 4]]


transposición inserta transposición

Out[99]= {{1, 0, 2, 1}, {1, 0, 1, 0}, {1, 1, 1, 0}}

In[100]:=

MatrixForm[%]
forma de matriz
Out[100]//MatrixForm=

1 0 2 1
1 0 1 0
1 1 1 0

In[101]:= A2 = Transpose[Insert[Transpose[A1], {0, 1, 0}, 5]]


transposición inserta transposición

Out[101]= {{1, 0, 2, 1, 0}, {1, 0, 1, 0, 1}, {1, 1, 1, 0, 0}}

In[102]:= MatrixForm[%]
forma de matriz
Out[102]//MatrixForm=

1 0 2 1 0
1 0 1 0 1
1 1 1 0 0

In[103]:= A3 = Transpose[Insert[Transpose[A2], {0, 0, 1}, 6]]


transposición inserta transposición

Out[103]= {{1, 0, 2, 1, 0, 0}, {1, 0, 1, 0, 1, 0}, {1, 1, 1, 0, 0, 1}}

Printed by Wolfram Mathematica Student Edition


Lab4F_Pauta.nb 3

In[104]:= MatrixForm[A3]
forma de matriz
Out[104]//MatrixForm=

1 0 2 1 0 0
1 0 1 0 1 0
1 1 1 0 0 1

Hemos construido la matriz ampliada [ A I ] , ahora calculamos la escalonada reducida,

In[105]:= RowReduce[A3]
reduce filas

Out[105]= {{1, 0, 0, - 1, 2, 0}, {0, 1, 0, 0, - 1, 1}, {0, 0, 1, 1, - 1, 0}}

In[106]:= MatrixForm[%]
forma de matriz
Out[106]//MatrixForm=

1 0 0 -1 2 0
0 1 0 0 -1 1
0 0 1 1 -1 0

Luego, se prueba que la matriz A es invertible ya que los tres sistemas Ax = ei tienen
solución ;
y las soluciones son las columnas de la matriz inversa

-1 2 0
0 -1 1
1 -1 0
como a continuación se verifica.

In[107]:= A.{{- 1, 2, 0}, {0, - 1, 1}, {1, - 1, 0}}

Out[107]= {{1, 0, 0}, {0, 1, 0}, {0, 0, 1}}

PROBLEMA 1

Considere las matrices siguientes:

Printed by Wolfram Mathematica Student Edition


4 Lab4F_Pauta.nb

1 1 2 -1 1 0 1 4 3
Q = 0 1 3 , S = 0 2 2 , B = -1 1 2 ,
3 4 1 1 2 3 1 2 1

1.1 Calcule la cantidad de pivotes de cada una de ellas. Decida cuales son invertibles
1.2 Calcule las inversa cuando corresponda mediante pivoteo.
1.3 Calcule la inversa con el comando Inverse [ ] cuando corresponda.
1.4 Calcule la matriz X solución de la ecuación matricial QXQ - S = B

Desarrollo
Se definen las matrices Q,B,S

In[108]:= Q = {{1, 1, 2}, {0, 1, 3}, {3, 4, 1}}

Out[108]= {{1, 1, 2}, {0, 1, 3}, {3, 4, 1}}

In[109]:= S = {{- 1, 1, 0}, {0, 2, 2}, {1, 2, 3}}

Out[109]= {{- 1, 1, 0}, {0, 2, 2}, {1, 2, 3}}

In[110]:= B = {{1, 4, 3}, {- 1, 1, 2}, {1, 2, 1}}

Out[110]= {{1, 4, 3}, {- 1, 1, 2}, {1, 2, 1}}

1.1 Para ver sus pivotes aplicamos el algoritmo de reducción de Gauss, es decir, el comand RowRe-
duce[ ]

In[111]:= RowReduce[Q]
reduce filas

Out[111]= {{1, 0, 0}, {0, 1, 0}, {0, 0, 1}}

In[112]:= {{1, 0, 0}, {0, 1, 0}, {0, 0, 1}}

Out[112]= {{1, 0, 0}, {0, 1, 0}, {0, 0, 1}}

Q tiene tres pivotes, luego es invertible-.

In[113]:= RowReduce[B]
reduce filas

Out[113]= {{1, 0, - 1}, {0, 1, 1}, {0, 0, 0}}

B tiene 2 pivotes, luego no es invertible.

Printed by Wolfram Mathematica Student Edition


Lab4F_Pauta.nb 5

In[114]:= RowReduce[S]
reduce filas

Out[114]= {{1, 0, 1}, {0, 1, 1}, {0, 0, 0}}

La matriz S solo tiene dos pivotes, luego no es invertible.

1.2 Calculemos la inversa de Q mediante pivoteo.


Para ello debemos construir la matriz ampliada [Q I ]

In[115]:= Q1 = Transpose[Insert[Transpose[Q], {1, 0, 0}, 4]]


transposición inserta transposición

Out[115]= {{1, 1, 2, 1}, {0, 1, 3, 0}, {3, 4, 1, 0}}

In[116]:= Q2 = Transpose[Insert[Transpose[Q1], {0, 1, 0}, 5]]


transposición inserta transposición

Out[116]= {{1, 1, 2, 1, 0}, {0, 1, 3, 0, 1}, {3, 4, 1, 0, 0}}

In[117]:= Q3 = Transpose[Insert[Transpose[Q2], {0, 0, 1}, 6]]


transposición inserta transposición

Out[117]= {{1, 1, 2, 1, 0, 0}, {0, 1, 3, 0, 1, 0}, {3, 4, 1, 0, 0, 1}}

Pivoteamos la ampliada,

In[118]:= QQ = RowReduce[Q3]
reduce filas

11 7 1 9 5 3 3 1 1
Out[118]= 1, 0, 0, ,- ,- , 0, 1, 0, - , , , 0, 0, 1, , ,- 
8 8 8 8 8 8 8 8 8

In[119]:= MatrixForm[%]
forma de matriz
Out[119]//MatrixForm=

11 7 1
1 0 0 - -
8 8 8
9 5 3
0 1 0 -
8 8 8
3 1 1
0 0 1 -
8 8 8

Printed by Wolfram Mathematica Student Edition


6 Lab4F_Pauta.nb

In[120]:= Inversa = {{QQ[[1, 4]], QQ[[1, 5]], QQ[[1, 6]]},


{QQ[[2, 4]], QQ[[2, 5]], QQ[[2, 6]]}, {QQ[[3, 4]], QQ[[3, 5]], QQ[[3, 6]]}}

11 7 1 9 5 3 3 1 1
Out[120]=  ,- ,- , - , , ,  , , - 
8 8 8 8 8 8 8 8 8

In[121]:= Q.Inversa

Out[121]= {{1, 0, 0}, {0, 1, 0}, {0, 0, 1}}

Lo cual prueba que es la inveersa de Q.

1.3 Calculemos la inversa usando directamente el comando Inverse[ ] , solo de Q en este caso,

In[122]:= Inverse[Q]
matriz inversa

11 7 1 9 5 3 3 1 1
Out[122]=  ,- ,- , - , , ,  , , - 
8 8 8 8 8 8 8 8 8

Luego S y B no son invertibles y Q lo es.

1.4 Calculemos la solución de QXQ =B+S.

Como Q tiene inversa, podemos aplicar Q-1 por la izquierda, QX = ( B+S)Q-1 . Aplicando Q-1 por la
izquierda se obtiene que
X = Q-1 ( B+S)Q-1 es la solución, la cual calculamos a continuación

In[123]:= X = Inverse[Q].(B + S).Inverse[Q]


matriz inversa matriz inversa

53 29 21 47 23 15 33 25 9
Out[123]= - , , ,  ,- ,- , - , , 
16 16 16 16 16 16 16 16 16

157 89 39 55 43 21 51 55 9
In[124]:=  ,- ,- , - , , , - , ,  // MatrixForm
64 64 64 64 64 64 64 64 64 forma de matriz

Out[124]//MatrixForm=

157 89 39
- -
64 64 64
55 43 21
-
64 64 64
51 55 9
-
64 64 64

Printed by Wolfram Mathematica Student Edition


Lab4F_Pauta.nb 7

Esta matriz X es la solución.

In[125]:= ClearAll["Global`*"]
borra todo

DETERMINANTE
Determinante es una operación det : Mn ⟶  que a cada matriz cuadrada de n x n se le asocia un
número.

Ella está determinada por las propiedades que tiene,


i) det[ I ] = 1
ii)) Es multilineal, esto quiere decir, si se fijan todas las filas excepto una, la aplicación es lineal en esa
fila .
det[ { f1 , f2 , . . . , α f j + β g j , . . . , fn } ] = α det[ { f1 , f2 , . . . , f j , . . . , fn } ] + β det[ { f1 , f2 , . . . , g j , .
. . , fn } ]
iiI) Si se intercambian dos filas, ambia de signo: det[ { f1 , f2 , . . . , fi , . . . , g j , . . . , fn } ] = (-1) det[ { f1
, f2 , . . . , gi , . . . , f j , . . . , fn } ]

De estas propiedades se deduce que

det[AB] = det[A]det[B]
det[ una matriz con dos filas iguales ] = 0.
det[matriz con una fila nula] = 0.
det[matriz escalonada] = det[matriz original ]
det[matriz_triangular] = producto de su diagonal
det[A] = ± Producto de sus pivotes en la escalonada =Producto de la diagonal de la escalonada

UNA MATRIZ CUADRADA A ES INVERTIBLE SI Y SOLO SI Det(A)≠0.

El comando en MATHEMATICA es Det[A]

In[126]:= Det[Q]
determinante

Out[126]= Det[Q]

Printed by Wolfram Mathematica Student Edition


8 Lab4F_Pauta.nb

Estas propiedades nos permiten calcular cualquier el determinante a cualquier matriz cuadrada.

Veamos un ejemplo,

In[127]:= G = {{1, 2}, {2, 3}}; Det[G]


determinante

Out[127]= -1

In[128]:= MatrixForm[G]
forma de matriz
Out[128]//MatrixForm=

1 2
2 3

el determinante de G es -1.

Multipliquemos la primera fila de G por por (-2) y sumar a la segunda.

In[129]:= G1 = {G[[1, All]], (- 2) G[[1, All]] + G[[2, All]]}


todo todo todo

Out[129]= {{1, 2}, {0, - 1}}

In[130]:= MatrixForm[G1]
forma de matriz
Out[130]//MatrixForm=

1 2
0 -1

Se obtiene una matriz triangular , Luego su det es -1, como ya lo habíamos calculado.

Ejercicio.
Calcule el determinante de la matriz H de 4 x 4 dada sando pivoteo y verifique con el comando Det[H].

In[131]:= H = {{1, 2, 0, 1}, {1, 0, 0, 2}, {0, 0, 1, 0}, {- 1, 1, 1, 1}}

Out[131]= {{1, 2, 0, 1}, {1, 0, 0, 2}, {0, 0, 1, 0}, {- 1, 1, 1, 1}}

Printed by Wolfram Mathematica Student Edition


Lab4F_Pauta.nb 9

In[132]:= MatrixForm[%]
forma de matriz
Out[132]//MatrixForm=

1 2 0 1
1 0 0 2
0 0 1 0
-1 1 1 1

In[133]:= Det[H]
determinante

Out[133]= -7

Ahora lo calculamos pivotrando y usando las propiedades de la función Det.

Recordemos que el determinante no cambia bajo operaciones elementales.


Si intercambiamos filas el determinante es (-1) el determinante original.

Empezemos intercambiamos fila 1 con la 2

In[134]:= H1 = {{1, 0, 0, 2}, {1, 2, 0, 1}, {0, 0, 1, 0}, {- 1, 1, 1, 1}}

Out[134]= {{1, 0, 0, 2}, {1, 2, 0, 1}, {0, 0, 1, 0}, {- 1, 1, 1, 1}}

In[135]:= MatrixForm[%]
forma de matriz
Out[135]//MatrixForm=

1 0 0 2
1 2 0 1
0 0 1 0
-1 1 1 1

Luego, det[H] = (- 1)det[H1]

Si pivoteamos H1 el determinante no cambia

In[136]:= H2 = { H1[[1, All]], (- 1) H1[[1, All]] + H1[[2, All]],


todo todo todo
H1[[3, All]], H1[[1, All]] + H1[[4, All]]}
todo todo todo

Out[136]= {{1, 0, 0, 2}, {0, 2, 0, - 1}, {0, 0, 1, 0}, {0, 1, 1, 3}}

Printed by Wolfram Mathematica Student Edition


10 Lab4F_Pauta.nb

In[137]:= Det[H2]
determinante

Out[137]= 7

In[138]:= MatrixForm[%]
forma de matriz
Out[138]//MatrixForm=

Ahora multiplicamos por -1/2 la segunda y la sumamos a la cuarta de la matriz H2

In[139]:= H3 = { H2[[1, All]], H2[[2, All]],


todo todo
H2[[3, All]], (- 1 / 2) H2[[2, All]] + H2[[4, All]]}
todo todo todo

7
Out[139]= {1, 0, 0, 2}, {0, 2, 0, - 1}, {0, 0, 1, 0}, 0, 0, 1, 
2

In[140]:= MatrixForm[%]
forma de matriz
Out[140]//MatrixForm=

1 0 0 2
0 2 0 -1
0 0 1 0
7
0 0 1
2

Finalmente (-1)f3 + f4 y obtenemos la escalonada, que es una matriz rectangular superior,

In[141]:= H4 = { H3[[1, All]], H3[[2, All]],


todo todo
H2[[3, All]], (- 1) H3[[3, All]] + H3[[4, All]]}
todo todo todo

7
Out[141]= {1, 0, 0, 2}, {0, 2, 0, - 1}, {0, 0, 1, 0}, 0, 0, 0, 
2

In[142]:= MatrixForm[%]
forma de matriz
Out[142]//MatrixForm=

1 0 0 2
0 2 0 -1
0 0 1 0
7
0 0 0
2

Esta escalonada es rectángular, luego Det[H4] = 7 y por lo tanto, Det[H] = (-1) Det[H1] = (-1) Det[H4] = -
7.

Printed by Wolfram Mathematica Student Edition


Lab4F_Pauta.nb 11

Printed by Wolfram Mathematica Student Edition

También podría gustarte