Mostrando entradas con la etiqueta cálculo con matrices. Mostrar todas las entradas
Mostrando entradas con la etiqueta cálculo con matrices. Mostrar todas las entradas

lunes, 6 de julio de 2020

Ejemplo de resolución de un sistema de ecuaciones lineales compatible determinado utilizando R

En este breve artículo voy a mostraros cómo podemos resolver un sistema de ecuaciones lineales compatible determinado utilizando el programa de cálculo R, que se emplea en análisis numérico matricial y, especialmente, en estadística y probabilidad. Veamos el siguiente ejemplo: $$\left\{\begin{matrix}x+y+z=1\\x-y+z=0\\x-y-z=2\end{matrix}\right.$$ Este sistema de ecuaciones podemos escribirlo en forma matricial $$\begin{pmatrix}1&1&1\\1&-1&1\\ 1&-1&-1\end{pmatrix}\begin{pmatrix}x\\y\\z\end{pmatrix}=\begin{pmatrix}1\\0\\2\end{pmatrix}$$ Una vez identicados los elementos de la matriz de los coeficientes del sistema y los de la matriz de los términos independientes, basta utilizar las siguientes instrucciones de R


para obtener la solución:


esto es: $$x=\dfrac{3}{2}, y=\dfrac{1}{2}, z=-1$$

sábado, 9 de junio de 2018

Álgebra lineal. Cálculo con matrices.

ENUNCIADO. Dadas las matrices $A=\begin{pmatrix}m&0&2 \\ -2&4&m\\ 0&1&-1\end{pmatrix}$ y $B=\begin{pmatrix}-2\\0\\0\end{pmatrix}$, se pide:
a) Obtener los valores del parámetro $m$ para los cuales la matriz $A$ admite inversa
b) Para $m=0$, calcular $AB$ y $A^{-1}B$
c) Calcular $BB^{\top}$ y $B^{\top}B$

SOLUCIÓN.

miércoles, 27 de septiembre de 2017

Cálculo con matrices

ENUNCIADO. Dada la matriz $A=\begin{pmatrix}2 & 0 & 0 \\ 0 & 0 & 1 \\ 0 & 1 & 0 \end{pmatrix}$ y la matriz identidad $I=\begin{pmatrix}1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \end{pmatrix}$, se pide:
a) Calcular la matriz $B$, dada por $B=(A-I)(2I+2A)$
b) Determinar el rango de las matrices $A-I$, $A^2-I$ y $A^3-I$
c) Calcular la matriz inversa de la matriz $A^6$, en caso de que exista

SOLUCIÓN.
a)
$B=(A-I)(2A+2I)$
  $=2\,(A-I)(A+I)$
    $=2\,((A-I)I+(A-I)A)$
      $=2\,((AI-I^2+A^2-IA)$
        $=2\,(-I+A^2)$ ya que $IA=AI=A$ y $I^2=II=I$
          $=2\,(\begin{pmatrix}-1&0&0\\0&-1&0\\0&0&-1\end{pmatrix}+\begin{pmatrix}4&0&0\\0&1&0\\0&0&1\end{pmatrix}) \quad \quad (1)$
$$\text{ya que}\;\;A^2=\begin{pmatrix}2 & 0 & 0 \\ 0 & 0 & 1 \\ 0 & 1 & 0 \end{pmatrix}\begin{pmatrix}2 & 0 & 0 \\ 0 & 0 & 1 \\ 0 & 1 & 0 \end{pmatrix}=\begin{pmatrix}4 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \end{pmatrix}$$
con lo cual
            $B=2\,\begin{pmatrix}3&0&0\\0&0&0\\0&0&0\end{pmatrix}=\begin{pmatrix}6&0&0\\0&0&0\\0&0&0\end{pmatrix}$

b)
$A-I=\begin{pmatrix}2 & 0 & 0 \\ 0 & 0 & 1 \\ 0 & 1 & 0\end{pmatrix}-\begin{pmatrix}1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1\end{pmatrix}=\begin{pmatrix}1 & 0 & 0 \\ 0 & -1 & 1 \\ 0 & 1 & -1\end{pmatrix}$ y mediante la combinación $f_3 \leftarrow f_3+f_2$ vemos que dicha matriz es equivalente en rango a $\begin{pmatrix}1 & 0 & 0 \\ 0 & -1 & 1 \\ 0 & 0 & 0\end{pmatrix}$, que ya queda reducida por Gauss, y como aparecen sólo dos filas no nulas, su rango es $2$; esto es, $\text{rango}(A-I)=2$

-oOo-


$A^2-I=\begin{pmatrix}4 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1\end{pmatrix}-\begin{pmatrix}1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1\end{pmatrix}=\begin{pmatrix}3 & 0 & 0 \\ 0 & 0 & 0 \\ 0 & 0 & 0\end{pmatrix}$, que ya queda reducida por Gauss, y como aparece sólo una fila no nula, su rango es $1$; esto es, $\text{rango}(A^2-I)=1$

-oOo-

$A^3=A^2\,A=\begin{pmatrix}4 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1\end{pmatrix}\begin{pmatrix}2 & 0 & 0 \\ 0 & 0 & 1 \\ 0 & 1 & 0 \end{pmatrix}=\begin{pmatrix}8 & 0 & 0 \\ 0 & 0 & 1 \\ 0 & 1 & 0 \end{pmatrix}$ luego $A^3-I=\begin{pmatrix}8 & 0 & 0 \\ 0 & 0 & 1 \\ 0 & 1 & 0 \end{pmatrix}-\begin{pmatrix}1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \end{pmatrix}=\begin{pmatrix}7 & 0 & 0 \\ 0 & -1 & 1 \\ 0 & 1 & -1 \end{pmatrix}$. Con la combinación $f_3 \leftarrow f_3+f_2$ vemos que dicha matriz es equivalente en rango a $\begin{pmatrix}7 & 0 & 0 \\ 0 & -1 & 1 \\ 0 & 0 & 0\end{pmatrix}$, que ya queda reducida por Gauss, y como aparecen sólo dos filas no nulas, su rango es $2$; esto es, $\text{rango}(A^3-I)=2$

c)
Observemos que:
$A=\begin{pmatrix}2 & 0 & 0 \\ 0 & 0 & 1 \\ 0 & 1 & 0 \end{pmatrix}$
$A^2=\begin{pmatrix}2^2 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \end{pmatrix}$
y que $A^4=A^{3}A=\begin{pmatrix}2^3 & 0 & 0 \\ 0 & 0 & 1 \\ 0 & 1 & 0 \end{pmatrix}\begin{pmatrix}2 & 0 & 0 \\ 0 & 0 & 1 \\ 0 & 1 & 0 \end{pmatrix}=\begin{pmatrix}2^4 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \end{pmatrix}$
luego, por inducción, podemos escribir:
$A^6=\begin{pmatrix}2^6 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \end{pmatrix}=\begin{pmatrix}64 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \end{pmatrix}$
y al tratarse de una matriz diagonal, es evidente que
$(A^6)^{-1}=\begin{pmatrix}1/64 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \end{pmatrix}$
En efecto,
$(A^6)^{-1}A^6=\begin{pmatrix}1/64 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \end{pmatrix}\begin{pmatrix}64 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \end{pmatrix}=\begin{pmatrix}1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \end{pmatrix}$
y
$A^{6}(A^6)^{-1}=\begin{pmatrix}64 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \end{pmatrix}\begin{pmatrix}1/64 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \end{pmatrix}=\begin{pmatrix}1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \end{pmatrix}$

$\square$

lunes, 25 de septiembre de 2017

Potenciación recurrente de algunas matrices

ENUNCIADO. Considérese la matriz $A=\begin{pmatrix}1&1\\0&1\end{pmatrix}$. Calcúlese $A^{600}$

SOLUCIÓN. Si ensayamos las primeras potencias ( con la ayuda del escenario CAS de GeoGebra es muy rápido, no hace falta hacerlo a mano si no estamos resolviendo un ejercicio de examen ) observamos lo siguiente:
con lo que nos damos cuenta de la siguiente regla de formación de los elementos de la $k$-ésima potencia de la matriz $A$: $$A^k=\begin{pmatrix}1&k\\0&1\end{pmatrix}$$ por consiguiente podemos escribir $$A^{600}=\begin{pmatrix}1&600\\0&1\end{pmatrix}$$ y hemos terminado.
$\square$

miércoles, 28 de junio de 2017

Cálculo con matrices y determinantes

ENUNCIADO. Dadas las matrices $P=\begin{pmatrix}1&2&1\\ 3&2&2 \\ 2&3&2\end{pmatrix}$ y $J=\begin{pmatrix}-1&0&0\\ 0&2&0 \\ 0&0&1\end{pmatrix}$ se pide:
a) Determinar $P^{-1}$
b) Determinar $B^{-1}$, siendo $B=P^{-1}J^{-1}$
c) Calcular el determinante de $A^2$, siendo $A=PJP^{-1}$

SOLUCIÓN.
a)
Una condición necesaria y suficiente para que una matriz cuadrada tenga asociada una matriz inversa es que su determinante sea distinto de cero. Veamos si lo es: $\text{det}(P)=\begin{vmatrix}1&2&1\\ 3&2&2 \\ 2&3&2\end{vmatrix}=-1$, luego $P$ tiene inversa. Sugiero que se utilice el método de Gauss-Jordan tal como se muestra en [este otro ejercicio rutinario], obteniendo $$P^{-1}=\begin{pmatrix}2&1&-2\\ 2&0&1 \\ -5&-1&4\end{pmatrix}$$

b)
Notemos que $B=P^{-1}J^{-1}=(JP)^{-1}$ y, por tanto, $B^{-1}=\left((JP)^{-1}\right)^{-1}=JP=\begin{pmatrix}-1&0&0\\ 0&2&0 \\ 0&0&1\end{pmatrix}\begin{pmatrix}1&2&1\\ 3&2&2 \\ 2&3&2\end{pmatrix}=\begin{pmatrix}-1&-2&-1\\ 6&4&4 \\ 2&3&2\end{pmatrix}$

c)
$A^2=(PJP^{-1})^2=(PJP^{-1})(PJP^{-1})=PJ(P^{-1}P)JP^{-1}=PJIJP^{-1}=$
  $=PJJP^{-1}=PJ^2P^{-1}=P(J^2P^{-1})\quad \quad \quad (1)$

Entonces,
$J^2=\begin{pmatrix}-1&0&0\\ 0&2&0 \\ 0&0&1\end{pmatrix}\begin{pmatrix}-1&0&0\\ 0&2&0 \\ 0&0&1\end{pmatrix}=\begin{pmatrix}1&0&0\\ 0&4&0 \\ 0&0&1\end{pmatrix}$
y por tanto $J^2P^{-1}=\begin{pmatrix}1&0&0\\ 0&4&0 \\ 0&0&1\end{pmatrix}\begin{pmatrix}2&1&-2\\ 2&0&1 \\ -5&-1&4\end{pmatrix}=\begin{pmatrix}2&1&-2\\ 8&0&-4 \\ -5&-1&4\end{pmatrix}$ luego, de (1), llegamos a $$A^2=\begin{pmatrix}1&2&1\\ 3&2&2 \\ 2&3&2\end{pmatrix}\begin{pmatrix}2&1&-2\\ 8&0&-4 \\ -5&-1&4\end{pmatrix}=\begin{pmatrix}13&0&-6\\ 12&1&-6 \\ 18&0&-8\end{pmatrix}$$ Con lo cual $$\text{det}(A^2)=\begin{vmatrix}13&0&-6\\ 12&1&-6 \\ 18&0&-8\end{vmatrix}=4$$
$\square$

sábado, 17 de septiembre de 2016

Determine, si es posible, los parámetros $\alpha$ y $\beta$ de modo que ...

ENUNCIADO.
a) Determine, si es posible, los parámetros $\alpha$ y $\beta$ de modo que se verifique la igualdad: $$\alpha\,\begin{pmatrix}3 & -4 \\ 5 & -1 \end{pmatrix}+\beta\,\begin{pmatrix}1 & 0 \\ 2 & 1 \end{pmatrix}^2=\begin{pmatrix}3 & -8 \\ -2 & -5 \end{pmatrix}$$
b) Determine los posibles valores de $\lambda$ para que el rango de la matriz $A$ sea $2$, donde $$A=\lambda\,\begin{pmatrix}2 & 2 \\ 1 & 3 \end{pmatrix}+\begin{pmatrix}1 & 0 \\ 0 & 1 \end{pmatrix}$$

SOLUCIÓN. Como
a)
$$\begin{pmatrix}1&0\\2&1\end{pmatrix}^2=\begin{pmatrix}1&0\\2&1\end{pmatrix}\begin{pmatrix}1&0\\2&1\end{pmatrix}=\begin{pmatrix}1&0\\4&1\end{pmatrix}$$ la ecuación pedida puede escribirse de la forma $$\alpha\,\begin{pmatrix}3 & -4 \\ 5 & -1 \end{pmatrix}+\beta\,\begin{pmatrix}1&0\\4&1\end{pmatrix}=\begin{pmatrix}3 & -8 \\ -2 & -5 \end{pmatrix}$$ Operando el primer miembro, nos queda $$\begin{pmatrix}3\alpha+\beta & -4\alpha \\ 5\alpha+4\beta & -\alpha+4 \end{pmatrix}=\begin{pmatrix}3 & -8 \\ -2 & -5 \end{pmatrix} \Leftrightarrow \left\{\begin{matrix}3\alpha+\beta=3 \\ -4\alpha=-8 \\ 5\alpha+4\beta=-2\\ -\alpha+\beta=-5\end{matrix}\right.$$ De la segunda ecuación se obtiene $\alpha=2$ y sustituyendo este valor en cualquier otra de las ecuaciones obtenemos $\beta=-3$.

b)
$A=\lambda\,\begin{pmatrix}2 & 2 \\ 1 & 3 \end{pmatrix}+\begin{pmatrix}1 & 0 \\ 0 & 1 \end{pmatrix}$
    $=\begin{pmatrix}2\lambda & 2\lambda \\ \lambda & 3\lambda \end{pmatrix}+\begin{pmatrix}1 & 0 \\ 0 & 1 \end{pmatrix}$
       $=\begin{pmatrix}2\lambda+1 & 2\lambda \\ \lambda & 3\lambda+1 \end{pmatrix}$

Teniendo en cuenta ahora que $$\begin{vmatrix}2\lambda+1 & 2\lambda \\ \lambda & 3\lambda+1 \end{vmatrix}=4\lambda^2+5\lambda+1=0\Leftrightarrow\lambda=\left\{\begin{matrix}-1 \\ -1/4\end{matrix}\right.$$ concluimos que $\text{rango}(A)=2 \Leftrightarrow \lambda \notin \{-1,-1/4\}\subset \mathbb{R}$
$\square$

lunes, 13 de junio de 2016

Cálculo con matrices

ENUNCIADO.
a) Despejar $X$ en la ecuación matricial $$X\,(C\,D)^{-1}=A+X\,(D^{-1}\,C^{-1}-B)$$ siendo $A,B,C,D$ matrices cuadradas invertibles. Expresar $X$ de la forma más simple posible.
b) Para $$A=\begin{pmatrix} 2 & 0 & -1 \\ 1 & 0 & 1 \\ 2 & 1 & 1\end{pmatrix}$$ y $$B=\begin{pmatrix} 1 & 1 & -1 \\ -1 & 0 & 1 \\ 1 & 1 & 1\end{pmatrix}$$ determinar la matriz $Y$ tal que $YB=A$

SOLUCIÓN.
a)
$X\,(C\,D)^{-1}=A+X\,(D^{-1}\,C^{-1}-B)$
  $X\,(C\,D)^{-1}-X\,(D^{-1}\,C^{-1}-B)=A+X\,(D^{-1}\,C^{-1}-B)-X\,(D^{-1}\,C^{-1}-B)$
    $X\,(C\,D)^{-1}-X\,(D^{-1}\,C^{-1}-B)=A+O$
      $X\,(C\,D)^{-1}-X\,(D^{-1}\,C^{-1}-B)=A$
        $X\,(C\,D)^{-1}-X\,(D^{-1}\,C^{-1}-B)=A$
          $X\,( (D^{-1}\,C^{-1} - (D^{-1}\,C^{-1}-B) )=A$
            $X\,(D^{-1}\,C^{-1} - D^{-1}\,C^{-1}+B)=A$
              $X\,(O+B)=A$
                $X\,B=A$
                  $X\,B\,B^{-1}=A\,B^{-1}$
                    $X\,I=A\,B^{-1}$
                      $X=A\,B^{-1}$

b)
Por lo que acabamos de ver, si $YB=A$ entonces $Y=A\,B^{-1}$. Procedemos a calcular la inversa de $B$; para ello utilizaremos el método de Gauss-Jordan, que consiste en realizar operaciones elementales para transformar $(B|I)$ en $(I|B^{-1})$

$\left(\begin{array}{ccc|ccc}
1 & 1 & -1 & 1 & 0 & 0 \\
-1 & 0 & 1 & 0 & 1 & 0 \\
1 & 1 & 1 & 0 & 0 & 1 \\
\end{array}\right) \overset{f_1+f_2 \rightarrow f_2;(-1)\cdot f_1+f_3 \rightarrow f_3}{\rightarrow} \left(\begin{array}{ccc|ccc}
1 & 1 & -1 & 1 & 0 & 0 \\
0 & 1 & 0 & 1 & 1 & 0 \\
0 & 0 & 2 & -1 & 0 & 1 \\
\end{array}\right) \rightarrow$
$\overset{\dfrac{1}{2}\cdot f_3+f_1\rightarrow f_1}{\rightarrow}\left(\begin{array}{ccc|ccc}
1 & 1 & 0 & 1/2 & 0 & 1/2 \\
0 & 1 & 0 & 1 & 1 & 0 \\
0 & 0 & 2 & -1 & 0 & 1 \\
\end{array}\right) \overset{(-1)\cdot f_2+f_1\rightarrow f_1}{\rightarrow}$
$\left(\begin{array}{ccc|ccc}
1 & 0 & 0 & -1/2 & -1 & 1/2 \\
0 & 1 & 0 & 1 & 1 & 0 \\
0 & 0 & 2 & -1 & 0 & 1 \\
\end{array}\right) \overset{\dfrac{1}{2}\cdot f_3\rightarrow f_3}{\rightarrow} \left(\begin{array}{ccc|ccc}
1 & 0 & 0 & -1/2 & -1 & 1/2 \\
0 & 1 & 0 & 1 & 1 & 0 \\
0 & 0 & 1 & -1/2 & 0 & 1/2 \\
\end{array}\right)$
luego
$B^{-1}=\left(\begin{array}{ccc}
-1/2 & -1 & 1/2 \\
1 & 1 & 0 \\
-1/2 & 0 & 1/2 \\
\end{array}\right)$
Entonces,
$Y=A\,B^{-1}=\begin{pmatrix} 2 & 0 & -1 \\ 1 & 0 & 1 \\ 2 & 1 & 1\end{pmatrix}\,\left(\begin{array}{ccc}
-1/2 & -1 & 1/2 \\
1 & 1 & 0 \\
-1/2 & 0 & 1/2 \\
\end{array}\right)=\begin{pmatrix} -1/2 & -2 & 1/2 \\ -1 & -1 & 1 \\ -1/2 & -1 & 3/2\end{pmatrix}$
$\square$