Las matrices son un conjunto de vectores fila y columna.
\[B=\begin{pmatrix}-1 & 2 & 3 \\ 4&5&-6 \\-7&-8&-9 \end{pmatrix}\]
B=matrix(c(-1,2,3,4,5,-6,-7,-8,-9),nrow=3,ncol=3,byrow=TRUE)
B
## [,1] [,2] [,3]
## [1,] -1 2 3
## [2,] 4 5 -6
## [3,] -7 -8 -9
La suma de matrices es componente a componente
\[B=\begin{pmatrix}-1 & 2 & 3 \\ 4&5&-6 \\-7&-8&-9 \end{pmatrix} \ C=\begin{pmatrix}1 & 0 & 3 \\ 4&0&6 \\9&10&11 \end{pmatrix}\]
B=matrix(c(-1,2,3,4,5,-6,-7,-8,-9),nrow=3,ncol=3,byrow=TRUE)
B
## [,1] [,2] [,3]
## [1,] -1 2 3
## [2,] 4 5 -6
## [3,] -7 -8 -9
C=matrix(c(1,0,3,4,0,6,9,10,11),3,3,byrow=TRUE)
C
## [,1] [,2] [,3]
## [1,] 1 0 3
## [2,] 4 0 6
## [3,] 9 10 11
C+B
## [,1] [,2] [,3]
## [1,] 0 2 6
## [2,] 8 5 0
## [3,] 2 2 2
Una transpuesta es cambiar filas por columnas \[A^T\]
t(B)
## [,1] [,2] [,3]
## [1,] -1 4 -7
## [2,] 2 5 -8
## [3,] 3 -6 -9
Hallar el valor de las variales de un sistema de ecuaciones lineal
\[\begin{cases} 2x+y=5\\ x+3y=7 \end{cases}\]
A=matrix(c(2,1,1,3),2,2,byrow=TRUE)
b=c(5,7)
solucion=solve(A,b)
solucion
## [1] 1.6 1.8