diff options
Diffstat (limited to 'Linear_Algebra_by_Jim_Hefferon/CH4')
-rw-r--r-- | Linear_Algebra_by_Jim_Hefferon/CH4/EX1.10/Ex4_1_10.R | 15 | ||||
-rw-r--r-- | Linear_Algebra_by_Jim_Hefferon/CH4/EX1.4/Ex4_1_4.R | 14 | ||||
-rw-r--r-- | Linear_Algebra_by_Jim_Hefferon/CH4/EX1.6/Ex4_1_6.R | 17 | ||||
-rw-r--r-- | Linear_Algebra_by_Jim_Hefferon/CH4/EX1.7/Ex4_1_7.R | 13 | ||||
-rw-r--r-- | Linear_Algebra_by_Jim_Hefferon/CH4/EX2.5/Ex4_2_5.R | 20 | ||||
-rw-r--r-- | Linear_Algebra_by_Jim_Hefferon/CH4/EX2.6/Ex4_2_6.R | 16 | ||||
-rw-r--r-- | Linear_Algebra_by_Jim_Hefferon/CH4/EX3.1/Ex4_3_1.R | 9 | ||||
-rw-r--r-- | Linear_Algebra_by_Jim_Hefferon/CH4/EX3.4/Ex4_3_4.R | 11 |
8 files changed, 115 insertions, 0 deletions
diff --git a/Linear_Algebra_by_Jim_Hefferon/CH4/EX1.10/Ex4_1_10.R b/Linear_Algebra_by_Jim_Hefferon/CH4/EX1.10/Ex4_1_10.R new file mode 100644 index 00000000..41570377 --- /dev/null +++ b/Linear_Algebra_by_Jim_Hefferon/CH4/EX1.10/Ex4_1_10.R @@ -0,0 +1,15 @@ +#Example 1.10,chapter 4,Section III. Laplace's Formula,page 356
+#package used matlib v0.9.1 and pracma
+#Github reposiory of matlib :https://github.com/friendly/matlib
+
+#installation and loading library
+#install.packages("matlib")
+library("matlib")
+
+#program
+t <- matrix(c(1,2,1,0,1,0,4,-1,1),ncol = 3)
+#finding inverse: if T has an inverse, if |T| != 0, then T^-1 = (1/|T|) adj(T)
+a <- adjoint(t)
+b <- 1/det(t)
+i <- b*a
+i
diff --git a/Linear_Algebra_by_Jim_Hefferon/CH4/EX1.4/Ex4_1_4.R b/Linear_Algebra_by_Jim_Hefferon/CH4/EX1.4/Ex4_1_4.R new file mode 100644 index 00000000..c42d8991 --- /dev/null +++ b/Linear_Algebra_by_Jim_Hefferon/CH4/EX1.4/Ex4_1_4.R @@ -0,0 +1,14 @@ +#Example 1.4,chapter 4,Section III. Laplace's Formula,page 354
+#package used matlib v0.9.1 and pracma
+#Github reposiory of matlib :https://github.com/friendly/matlib
+
+#installation and loading library
+#install.packages("matlib")
+library("matlib")
+
+#program
+T <- matrix(c(1,4,7,2,5,8,3,6,9),ncol = 3)
+T12 <- cofactor(T,1,2)
+T22 <- cofactor(T,2,2)
+T12
+T22
diff --git a/Linear_Algebra_by_Jim_Hefferon/CH4/EX1.6/Ex4_1_6.R b/Linear_Algebra_by_Jim_Hefferon/CH4/EX1.6/Ex4_1_6.R new file mode 100644 index 00000000..156a2053 --- /dev/null +++ b/Linear_Algebra_by_Jim_Hefferon/CH4/EX1.6/Ex4_1_6.R @@ -0,0 +1,17 @@ +#Example 1.6,chapter 4,Section III. Laplace's Formula,page 355\
+#package used matlib v0.9.1 and pracma
+#Github reposiory of matlib :https://github.com/friendly/matlib
+
+#installation and loading library
+#install.packages("matlib")
+library("matlib")
+
+#program
+t <- matrix(c(1,4,7,2,5,8,3,6,9),ncol = 3)
+x <- det(t)
+#computing the determinant by expanding along the first row,
+y <- t[1,1]*cofactor(t,1,1)+t[1,2]*cofactor(t,1,2)+t[1,3]*cofactor(t,1,3)
+#computing the determinant by expanding along the second row,
+z <- t[2,1]*cofactor(t,2,1)+t[2,2]*cofactor(t,2,2)+t[2,3]*cofactor(t,2,3)
+all.equal(x,y)
+all.equal(x,z)
diff --git a/Linear_Algebra_by_Jim_Hefferon/CH4/EX1.7/Ex4_1_7.R b/Linear_Algebra_by_Jim_Hefferon/CH4/EX1.7/Ex4_1_7.R new file mode 100644 index 00000000..e770d76f --- /dev/null +++ b/Linear_Algebra_by_Jim_Hefferon/CH4/EX1.7/Ex4_1_7.R @@ -0,0 +1,13 @@ +#Example 1.7,chapter 4,Section III. Laplace's Formula,page 355
+#package used matlib v0.9.1 and pracma
+#Github reposiory of matlib :https://github.com/friendly/matlib
+
+#installation and loading library
+#install.packages("matlib")
+library("matlib")
+
+#program
+t <- matrix(c(1,2,3,5,1,-1,0,1,0),ncol = 3)
+#computing the determinant by expanding along the third column.
+y <- t[1,3]*cofactor(t,1,3)+t[2,3]*cofactor(t,2,3)+t[3,3]*cofactor(t,3,3)
+y
diff --git a/Linear_Algebra_by_Jim_Hefferon/CH4/EX2.5/Ex4_2_5.R b/Linear_Algebra_by_Jim_Hefferon/CH4/EX2.5/Ex4_2_5.R new file mode 100644 index 00000000..2d4cdeab --- /dev/null +++ b/Linear_Algebra_by_Jim_Hefferon/CH4/EX2.5/Ex4_2_5.R @@ -0,0 +1,20 @@ +#Example 2.5,chapter4,Section I. Definition,page 325
+#package used matlib v0.9.1
+#install package using command: install.packages("matlib")
+#Github reposiory of matlib :https://github.com/friendly/matlib
+
+#installation and loading library
+#install.packages("matlib")
+library("matlib")
+
+#program
+A <- matrix(c(2,4,0,2,4,-3,6,3,5),ncol=3)
+b <- det(A)
+#determinant by normal ,ethod
+A <- rowadd(A,1,2,-2)
+A <- rowswap(A,2,3)
+A
+#reducing with gaussian reduction now multiplying the diagonal terms,keeping in mind the sign change due to row swap to find determinant.
+c <- -1*A[1,1]*A[2,2]*A[3,3]
+all.equal(b,c)
+#so the determinant by both techniques are the same
\ No newline at end of file diff --git a/Linear_Algebra_by_Jim_Hefferon/CH4/EX2.6/Ex4_2_6.R b/Linear_Algebra_by_Jim_Hefferon/CH4/EX2.6/Ex4_2_6.R new file mode 100644 index 00000000..a00f9279 --- /dev/null +++ b/Linear_Algebra_by_Jim_Hefferon/CH4/EX2.6/Ex4_2_6.R @@ -0,0 +1,16 @@ +#Example 2.6,chapter4,Section I. Definition,page 326
+#package used matlib v0.9.1 and pracma
+#Github reposiory of matlib :https://github.com/friendly/matlib
+
+#installation and loading library
+#install.packages("matlib")
+library("matlib")
+
+#program
+A <- matrix(c(1,0,0,0,0,1,0,1,1,1,0,0,3,4,5,1),ncol = 4)
+A <- rowadd(A,2,4,-1)
+A <- rowswap(A,3,4)
+A
+#multiplying diagonal terms and multiplying it with -1 to compensate for rowswap
+-1*A[1,1]*A[2,2]*A[3,3]*A[4,4]
+
diff --git a/Linear_Algebra_by_Jim_Hefferon/CH4/EX3.1/Ex4_3_1.R b/Linear_Algebra_by_Jim_Hefferon/CH4/EX3.1/Ex4_3_1.R new file mode 100644 index 00000000..3e45a8cf --- /dev/null +++ b/Linear_Algebra_by_Jim_Hefferon/CH4/EX3.1/Ex4_3_1.R @@ -0,0 +1,9 @@ +#Example3.1,chapter4,section1,page 329
+X <- matrix(c(4,-2,2,6),ncol = 2)
+#scalars come out of each row separately,not from the entire matrix at once.
+#so X will become
+A <- matrix(c(2,-1,1,3),ncol = 2)
+#with scalars 2 & 2 coming out of rows 1 and 2 respectively
+c <- det(X)
+d <- 4*det(A)
+all.equal(c,d)
diff --git a/Linear_Algebra_by_Jim_Hefferon/CH4/EX3.4/Ex4_3_4.R b/Linear_Algebra_by_Jim_Hefferon/CH4/EX3.4/Ex4_3_4.R new file mode 100644 index 00000000..29df6c40 --- /dev/null +++ b/Linear_Algebra_by_Jim_Hefferon/CH4/EX3.4/Ex4_3_4.R @@ -0,0 +1,11 @@ +#Example3.4,chapter 4,page 330
+A <- matrix(c(2,4,1,3),ncol = 2)
+#using multinlinearity property to break up the matrix
+a <- matrix(c(2,4,0,0),ncol = 2)
+b <- matrix(c(2,0,0,3),ncol = 2)
+c <- matrix(c(0,4,1,0),ncol = 2)
+d <- matrix(c(0,0,1,3),ncol = 2)
+#verifying the property
+x <- det(A)
+y <- det(a)+det(b)+det(c)+det(d)
+all.equal(x,y)
|