diff options
author | Prashant S | 2019-10-04 12:27:32 +0530 |
---|---|---|
committer | GitHub | 2019-10-04 12:27:32 +0530 |
commit | ac2986488a9731cff5cbb517d8f0ef98e2561d64 (patch) | |
tree | 7bb3f64824627ef179d5f341266a664fd0b69011 /Linear_Algebra_by_Jim_Hefferon/CH5 | |
parent | cbb2770fb2f88246175add29623103a56ba338b8 (diff) | |
parent | b3f3a8ecd454359a2e992161844f2fb599f8238a (diff) | |
download | R_TBC_Uploads-ac2986488a9731cff5cbb517d8f0ef98e2561d64.tar.gz R_TBC_Uploads-ac2986488a9731cff5cbb517d8f0ef98e2561d64.tar.bz2 R_TBC_Uploads-ac2986488a9731cff5cbb517d8f0ef98e2561d64.zip |
Added R TBC
Diffstat (limited to 'Linear_Algebra_by_Jim_Hefferon/CH5')
9 files changed, 112 insertions, 0 deletions
diff --git a/Linear_Algebra_by_Jim_Hefferon/CH5/EX1.3/Ex5_1_3.R b/Linear_Algebra_by_Jim_Hefferon/CH5/EX1.3/Ex5_1_3.R new file mode 100644 index 00000000..3d1d36dc --- /dev/null +++ b/Linear_Algebra_by_Jim_Hefferon/CH5/EX1.3/Ex5_1_3.R @@ -0,0 +1,12 @@ +#Example 1.3,chapter 5,Section II. Similarity,page 390
+#package used matlib v0.9.1
+#Github reposiory of matlib :https://github.com/friendly/matlib
+
+#installation and loading library
+#install.packages("matlib")
+library("matlib")
+P <- matrix(c(2,1,1,1),ncol = 2)
+T <- matrix(c(2,1,-3,-1),ncol = 2)
+#finding similar matrix of T
+T1 <- P %*% T %*% Inverse(P)
+T1
diff --git a/Linear_Algebra_by_Jim_Hefferon/CH5/EX2.10/Ex5_2_10.R b/Linear_Algebra_by_Jim_Hefferon/CH5/EX2.10/Ex5_2_10.R new file mode 100644 index 00000000..63487d6c --- /dev/null +++ b/Linear_Algebra_by_Jim_Hefferon/CH5/EX2.10/Ex5_2_10.R @@ -0,0 +1,16 @@ +#Example 2.10,chapter 5,scetion III.2,page 414
+#package used matlib v0.9.1
+#Github reposiory of matlib :https://github.com/friendly/matlib
+
+#installation and loading library
+#install.packages("matlib")
+library("matlib")
+N <- matrix(c(0,1,0,0,0,0,1,0,0,0,0,1,0,0,0,0),ncol=4)
+P <- matrix(c(1,0,1,0,0,2,1,0,1,1,1,0,0,0,0,1),ncol = 4)
+A <- P %*% N %*% Inverse(P)
+A
+#The new matrix,A is nilpotent; its fourth power is the zero matrix.
+x <- P %*% N^4 %*% Inverse(P)
+#since (PNP^-1)^4 = P * N^4 *P^-1
+y <- det(x)
+all.equal(y,0)
diff --git a/Linear_Algebra_by_Jim_Hefferon/CH5/EX2.17/Ex5_2_17.R b/Linear_Algebra_by_Jim_Hefferon/CH5/EX2.17/Ex5_2_17.R new file mode 100644 index 00000000..e6436638 --- /dev/null +++ b/Linear_Algebra_by_Jim_Hefferon/CH5/EX2.17/Ex5_2_17.R @@ -0,0 +1,21 @@ +#Example 2.17,chapter 5,scetion III.2,page 419
+#package used matlib v0.9.1
+#Github reposiory of matlib :https://github.com/friendly/matlib
+
+#installation and loading library
+#install.packages("matlib")
+library("matlib")
+M <- matrix(c(1,1,-1,-1),ncol = 2)
+#finding nilpotent index
+A <- matrix(c(0,0,0,0),ncol = 2)
+count <- 1
+Y <- M
+repeat{
+ Y <- Y %*% M
+ if (all.equal(Y,A)){
+ print(count+1)
+ break()
+ }
+ count= count+1
+}
+
diff --git a/Linear_Algebra_by_Jim_Hefferon/CH5/EX2.18/Ex5_2_18.R b/Linear_Algebra_by_Jim_Hefferon/CH5/EX2.18/Ex5_2_18.R new file mode 100644 index 00000000..960e5899 --- /dev/null +++ b/Linear_Algebra_by_Jim_Hefferon/CH5/EX2.18/Ex5_2_18.R @@ -0,0 +1,20 @@ +#Example 2.18,chapter 5,scetion III.2,page 420
+#package used matlib v0.9.1
+#Github reposiory of matlib :https://github.com/friendly/matlib
+
+#installation and loading library
+#install.packages("matlib")
+library("matlib")
+M <- matrix(c(0,1,-1,0,1,0,0,1,1,0,0,0,1,0,-1,0,0,-1,0,1,0,0,1,0,-1),ncol = 5)
+#finding nilpotent index
+A <- matrix(c(0),ncol = 5,nrow = 5)
+count <- 1
+Y <- M
+repeat{
+ Y <- Y %*% M
+ if (all.equal(Y,A)== TRUE){
+ print(count+1)
+ break()
+ }
+ count=count+1
+}
diff --git a/Linear_Algebra_by_Jim_Hefferon/CH5/EX2.2.2/Ex5_2_2_2.R b/Linear_Algebra_by_Jim_Hefferon/CH5/EX2.2.2/Ex5_2_2_2.R new file mode 100644 index 00000000..b78f52e9 --- /dev/null +++ b/Linear_Algebra_by_Jim_Hefferon/CH5/EX2.2.2/Ex5_2_2_2.R @@ -0,0 +1,7 @@ +#Example 2.2,chapter 5,section II.2 Diagonalizability,page 393
+#matrix: T is diagonalizable if there is a nonsingular P such that PTP-1 is diagonal.
+T <- matrix(c(4,1,-2,1),ncol = 2)
+P <- matrix(c(-1,1,2,-1),ncol = 2)
+#checking whether diagonizable
+P %*% T %*% Inverse(P) # diagonal matrix
+# so matrix P is diagonizable
\ No newline at end of file diff --git a/Linear_Algebra_by_Jim_Hefferon/CH5/EX2.2/Ex5_2_2.R b/Linear_Algebra_by_Jim_Hefferon/CH5/EX2.2/Ex5_2_2.R new file mode 100644 index 00000000..cf70b449 --- /dev/null +++ b/Linear_Algebra_by_Jim_Hefferon/CH5/EX2.2/Ex5_2_2.R @@ -0,0 +1,12 @@ +#Example 2.2,chapter 5,Section I. Complex Vector Spaces,page 387
+a <- complex(real = 1,imaginary = 1)
+b <- complex(real = 0,imaginary = 1)
+c <- complex(real = 2,imaginary = -0)
+d <- complex(real = -2,imaginary = 3)
+e <- complex(real = 1,imaginary = 0)
+f <- complex(real = 0,imaginary = 3)
+g <- complex(real = 1,imaginary = -0)
+h <- complex(real = 0,imaginary = -1)
+A <- matrix(c(a,b,c,d),ncol = 2)
+B <- matrix(c(e,f,g,h),ncol = 2)
+A %*% B
diff --git a/Linear_Algebra_by_Jim_Hefferon/CH5/EX2.4/Ex5_2_4.R b/Linear_Algebra_by_Jim_Hefferon/CH5/EX2.4/Ex5_2_4.R new file mode 100644 index 00000000..ed6d2f8a --- /dev/null +++ b/Linear_Algebra_by_Jim_Hefferon/CH5/EX2.4/Ex5_2_4.R @@ -0,0 +1,15 @@ +#Example 2.4,chapter 5,section IV.2,page 432
+#package used pracma v1.9.9
+#installing and loading library
+#install.packages("pracma")
+library("pracma")
+T <- matrix(c(2,1,-1,4),ncol=2)
+a <- eigen(T)
+a$values
+#so T has only the single eigenvalue 3.
+I <- matrix(c(1,0,0,1),ncol = 2)
+T-(3*I)
+# so for this,the only eigenvalue is 0 and T -3I is nilpotent.
+#to ease this computation we find nulspaces
+x <- nullspace(T)
+x
diff --git a/Linear_Algebra_by_Jim_Hefferon/CH5/EX3.19/Ex5_3_19.R b/Linear_Algebra_by_Jim_Hefferon/CH5/EX3.19/Ex5_3_19.R new file mode 100644 index 00000000..6b619a24 --- /dev/null +++ b/Linear_Algebra_by_Jim_Hefferon/CH5/EX3.19/Ex5_3_19.R @@ -0,0 +1,4 @@ +#Example3.19,chapter 5,section II.3 Eigenvalues and Eigenvectors,page 404
+T <- matrix(c(2,0,-4,-2,1,8,2,1,3),ncol = 3)
+a <- eigen(T)
+a$values
diff --git a/Linear_Algebra_by_Jim_Hefferon/CH5/EX3.6/Ex5_3_6.R b/Linear_Algebra_by_Jim_Hefferon/CH5/EX3.6/Ex5_3_6.R new file mode 100644 index 00000000..9bf70023 --- /dev/null +++ b/Linear_Algebra_by_Jim_Hefferon/CH5/EX3.6/Ex5_3_6.R @@ -0,0 +1,5 @@ +#Example3.6,chapter 5,section II.3 Eigenvalues and Eigenvectors,page 398
+T <- matrix(c(2,0,0,0),ncol = 2)
+a <-eigen(T)
+a$values
+a$vectors
|