Somme de matrices et multiplication par un scalaire


X<-matrix(c(3,-2,6,8,0,-2),nrow=2,byrow = T)
X%>%knitr::kable(caption = "**X**")
Y<-matrix(c(2,1,-9,-7,2,-3),nrow=2,byrow = T)
Y%>%knitr::kable(caption = "**Y**")
(X+Y)%>%knitr::kable(caption = "**X+Y**")
Z<-matrix(c(8,-2,6,-5,0,-3),nrow=2,byrow = T)
Z%>%knitr::kable(caption = "**Z**")
(-0.1*Z)%>%knitr::kable(caption = "-0.1**Z**")
-0.1Z
-0.8 |
0.2 |
-0.6 |
0.5 |
0.0 |
0.3 |
X<-matrix(c(4,-2,6,8,0,-2),nrow=2,byrow = T)
X%>%knitr::kable(caption = "**X**")
Y<-matrix(c(2,1,-9,-7,2,-3),nrow=2,byrow = T)
Y%>%knitr::kable(caption = "**Y**")
(0.5*X+(-2)*Y)%>%knitr::kable(caption = "0.5**X**+(-2)**Y**")
0.5X+(-2)Y
-2 |
-3 |
21 |
18 |
-4 |
5 |
Produit de matrices
A<-matrix(c(2,-4,1,7),nrow=2,byrow = T)
A%>%knitr::kable(caption = "**A**")
B<-matrix(c(-3,1,2,-5),nrow=2,byrow = T)
B%>%knitr::kable(caption = "**B**")
(A%*%B)%>%knitr::kable(caption = "**AB**")
X<-matrix(c(2,3,-1,-2,0,4),nrow=2,byrow = T)
X%>%knitr::kable(caption = "**X**")
Y<-matrix(c(3,5,4,-1,0,-2,0,6,0),nrow=3,byrow = T)
Y%>%knitr::kable(caption = "**B**")
(X%*%Y)%>%knitr::kable(caption = "**XY**")
F<-matrix(c(2,-1,-3,0,1,3,-2,-3),nrow=4,byrow = T)
F%>%knitr::kable(caption = "**F**")
A<-matrix(c(-4,1,6,-3,2,5),nrow=3,byrow = T)
A%>%knitr::kable(caption = "**A**")
(F%*%t(A)) %>%knitr::kable(caption = "**FA'**")
FA’
-9 |
15 |
-1 |
12 |
-18 |
-6 |
-1 |
-3 |
17 |
5 |
-3 |
-19 |
A<-matrix(c(-4,1,6,-3,2,5),nrow=3,byrow = T)
A%>%knitr::kable(caption = "**A**")
(A%*%t(A)) %>%knitr::kable(caption = "**S=AA'**")
S=AA’
17 |
-27 |
-3 |
-27 |
45 |
-3 |
-3 |
-3 |
29 |
(t(A)%*%A) %>%knitr::kable(caption = "**T=A'A**")
u<-matrix(c(2,-1,3),nrow=3,byrow = T)
u%>%knitr::kable(caption = "**u**")
v<-matrix(c(-2,3,-4),nrow=3,byrow = T)
v%>%knitr::kable(caption = "**v**")
(t(u)%*%v) %>%knitr::kable(caption = "**u'v**")
(u%*%t(v)) %>%knitr::kable(caption = "**uv'**")
uv’
-4 |
6 |
-8 |
2 |
-3 |
4 |
-6 |
9 |
-12 |
data.frame(X)%>%ggplot(aes(x =X1 ,y=X2,z=X3))+geom_point()

X<-matrix(c(3,-2,6,8,0,-2),nrow=2,byrow = T)
X%>%knitr::kable(caption = "**X**")
install.packages("scatterplot3d") # Install
## Installing package into '/cloud/lib/x86_64-pc-linux-gnu-library/4.2'
## (as 'lib' is unspecified)
library("scatterplot3d") # load
scatterplot3d(data.frame(X),xlim = c(-10,10),ylim = c(-10,10),zlim = c(-10,10),type="h")

install.packages("plotly")
## Installing package into '/cloud/lib/x86_64-pc-linux-gnu-library/4.2'
## (as 'lib' is unspecified)
library(plotly)
##
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
##
## last_plot
## The following object is masked from 'package:stats':
##
## filter
## The following object is masked from 'package:graphics':
##
## layout
mtcars$am[which(mtcars$am == 0)] <- 'Automatic'
mtcars$am[which(mtcars$am == 1)] <- 'Manual'
mtcars$am <- as.factor(mtcars$am)
fig <- plot_ly(mtcars, x = ~wt, y = ~hp, z = ~qsec, color = ~am, colors = c('#BF382A', '#0C4B8E'))
fig <- fig %>% add_markers()
fig <- fig %>% layout(scene = list(xaxis = list(title = 'Weight'),
yaxis = list(title = 'Gross horsepower'),
zaxis = list(title = '1/4 mile time')))
fig
n=10
(J<-diag(n)-(1/n)*matrix(1, nrow = n, ncol = n))
## [,1] [,2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