Suscribete a tu canal jorge R ..!

MATRIZ

Una matriz \(A\) de \(m \times n\) es un arreglo rectangular de \(mn\) numeros dispuestos en \(m\) renglones y \(n\) columnas

\[ A = \left( \begin{array}{cccc} a_{11} & a_{12} & \cdots & a_{1n}\\ a_{21} & a_{22} & \cdots & a_{2n} \\ \vdots & \vdots & & \vdots\\ a_{m1} & a_{m2} & \cdots & a_{mn} \end{array} \right)\]

El simbolo \(m \times n\) se lee "\(m\) por \(n\)".

MATRICES USING R PROJECT

En lenguaje \(R\),una matriz es un vector con un atributo adicional "dim". Para el caso de las matrices, este atributo es un vector entero de dos elementos, a saber el número de renglones (nrow) \(m\) y el número de columnas(ncol) \(n\) que componen a la matriz.

  • A <- matrix(data = , nrow =, ncol = , byrow = ,dimnames =)
  • B <- as.matrix(data =)
  • dim(B) <- c(m,n)
  • B

EJERCICIO 1

construye las siguientes matrices en \(R\).

  1. \[A = \left( \begin{array}{cccc} 1 & 3 \\ -2 & 4 \end{array} \right)\]

  2. \[B = \left( \begin{array}{cccc} 1 & 3 & -4\\ 2 & 4 & -2\\ 7 & 3 & -9\\ 9 & 3 & 0 \\ -2 & 4& 5 \end{array} \right)\]

CLASES DE MATRICES

  • El vector o matriz renglón \[ \left( \begin{array}{cccc} a_{i1} & a_{i2} & \cdots & a_{in} \\ \end{array} \right)\]

  • El vector o matriz renglón \[ \left( \begin{array}{cccc} a_{1j}\\ a_{2j}\\ \vdots\\ a_{nj} \\ \end{array} \right)\]

CLASES DE MATRICES

  • Si \(A\) es una matriz \(m \times n\) con \(m = n\), entonces A se llama matriz cuadrada.

  • Una matriz \(m \times n\) con todos los elementos iguales a cero se denomina matriz cero de \(m \times n\).

  • Se dice que una matriz \(m \times n\) tiene tamaño o dimensión \(m \times n\).

  • Traspuesta de la matriz \(A\) se denota como \(A^{t}\) y resulta de cambiar las filas por columnas.

IGUALDAD DE MATRICES

Dos matrices \(A = (a_{ij})\) y \(B = (b_{ij})\) son iguales si:

  • Son del mismo tamaño.

  • Las componentes correspondientes son iguales.

OPERACIONES CON MATRICES

Sean \(A = (a_{ij})\) y \(B = (b_{ij})\) dos matrices \(m \times n\). Entonces la suma o resta de \(A\) y \(B\) es la matriz \(m \times n\), \(A \pm B\) dada por

\[ (a_{ij} \pm b_{ij}) = \left( \begin{array}{cccc} a_{11}\pm b_{11} & a_{12}\pm b_{12} & \cdots & a_{1n}\pm b_{1n}\\ a_{21}\pm b_{21} & a_{22}\pm b_{22} & \cdots & a_{2n}\pm b_{2n} \\ \vdots & \vdots & & \vdots\\ a_{m1} \pm b_{m1} & a_{m2}\pm b_{m2} & \cdots & a_{mn}\pm b_{mn} \end{array} \right)\]

MULTIPLICACIÓN DE N ESCALAR POR UNA MATRIZ.

Sean \(A = (a_{ij})\) y \(\alpha \in R\) se define la multiplicación del escalar \(\alpha\) por la matriz A, denotada \(\alpha A\) , así:

\[ \alpha A = (\alpha a_{ij} ) = \left( \begin{array}{cccc} \alpha a_{11} & \alpha a_{12} & \cdots & \alpha a_{1n}\\ \alpha a_{21} & \alpha a_{22} & \cdots & \alpha a_{2n} \\ \vdots & \vdots & & \vdots\\ \alpha a_{m1} & \alpha a_{m2} & \cdots & \alpha a_{mn} \end{array} \right)\]

MULTIPLICACIÓN DE MATRICES.

  • Producto entre una matriz fila y una matriz columna.

sean \[ A = \left( \begin{array}{cccc} a_{11} & a_{12} & \cdots & a_{1n} \\ \end{array} \right)_{1 \times n}\]

y \[B = \left( \begin{array}{cccc} a_{11}\\ a_{21}\\ \vdots\\ a_{n1} \\ \end{array} \right)_{n \times 1}\]

se define el producto de la matriz fila \(A\) con la matriz columna \(B\) como, \[AB = \left( \begin{array}{cccc} a_{11} & a_{12} & \cdots & a_{1n} \\ \end{array} \right) \left( \begin{array}{cccc} a_{11}\\ a_{21}\\ \vdots\\ a_{n1} \\ \end{array} \right)\]

\[AB = a_{11}b_{11} + a_{12}b_{21} + ... + a_{1n}b_{n1}\]

  • Dos matrices se pueden multiplicar únicamente si el número de columnas de la primera matriz es igual al número de renglones de la segunda.
  • Multiplicación de matrices \(A_{m \times n}B_{n \times q} = AB_{m \times q}\).

PROBLEMAS DE APLICACIÓN

Calcule la matriz inversa, los valores y vectores propios de la matriz \[A = \left( \begin{array}{cccc} 1 & 3 \\ -2 & 4 \end{array} \right)\] y \[B = \left( \begin{array}{cccc} 3 & -2 \\ 5 & 6 \end{array} \right)\]

a <- c(1,3,-2,4)   # Vector de información
A <- matrix(a,ncol=2,nrow = 2,byrow = T)  #matriz A
A
##      [,1] [,2]
## [1,]    1    3
## [2,]   -2    4
b <- c(3,-2,5,6)   # Vector de información
B <- matrix(b,ncol=2,nrow = 2,byrow = T)  #matriz B
B
##      [,1] [,2]
## [1,]    3   -2
## [2,]    5    6

a <- c(1,3,-2,4)   # Vector de información
A <- matrix(a,ncol=2,nrow = 2,byrow = T)  #matriz A

dim(A)  #Dimensión de la matriz.
## [1] 2 2
traza<-sum(diag(A))
traza
## [1] 5
diag(A) #Diagonal de la matriz A.
## [1] 1 4

a <- c(1,3,-2,4)   # Vector de información
Z <- diag(a,length(a)) #matriz diagonal
Z
##      [,1] [,2] [,3] [,4]
## [1,]    1    0    0    0
## [2,]    0    3    0    0
## [3,]    0    0   -2    0
## [4,]    0    0    0    4

t(A)    #Traspuesta de la matriz A.
##      [,1] [,2]
## [1,]    1   -2
## [2,]    3    4
A+t(A)  #Suma de matrices.
##      [,1] [,2]
## [1,]    2    1
## [2,]    1    8
A-t(A)  #Resta de matrices.
##      [,1] [,2]
## [1,]    0    5
## [2,]   -5    0
A*t(A)  #Producto de matrices.
##      [,1] [,2]
## [1,]    1   -6
## [2,]   -6   16
A/t(A)  #División de matrices.
##            [,1] [,2]
## [1,]  1.0000000 -1.5
## [2,] -0.6666667  1.0
A%*%t(A)  #Multiplicación de matrices.
##      [,1] [,2]
## [1,]   10   10
## [2,]   10   20

AUTOVALORES, AUTOVECTORES Y ALGO MÁS

det(A)       #  Determinante de la matriz A.
## [1] 10
I<-solve(A)  #  Inversa de la matriz A.
I
##      [,1] [,2]
## [1,]  0.4 -0.3
## [2,]  0.2  0.1

A%*%I        #  Multiplicación de una matriz por su inversa.
##      [,1]         [,2]
## [1,]    1 5.551115e-17
## [2,]    0 1.000000e+00
eigen(A)     #  Autovalores y autovectores. 
## $values
## [1] 2.5+1.936492i 2.5-1.936492i
## 
## $vectors
##                [,1]           [,2]
## [1,] 0.7745967+0.0i 0.7745967+0.0i
## [2,] 0.3872983+0.5i 0.3872983-0.5i

var(A)       #  La matriz de varianzas y covarianzas.
##      [,1] [,2]
## [1,]  4.5 -1.5
## [2,] -1.5  0.5
cov(A)       #  La matriz de varianzas y covarianzas.
##      [,1] [,2]
## [1,]  4.5 -1.5
## [2,] -1.5  0.5
cor(A)       #  La matriz de correlación.
##      [,1] [,2]
## [1,]    1   -1
## [2,]   -1    1

.libPaths() to see which libraries are currently active