summaryrefslogtreecommitdiff
path: root/Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH1
diff options
context:
space:
mode:
Diffstat (limited to 'Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH1')
-rw-r--r--Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH1/EX1.1/Ex1_1.R6
-rw-r--r--Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH1/EX1.2.1/Ex1.2_1.R14
-rw-r--r--Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH1/EX1.2.2/Ex1.2_2.R11
-rw-r--r--Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH1/EX1.2.5/Ex1.2_5.R11
-rw-r--r--Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH1/EX1.2.a/Ex1_1.2A.R17
-rw-r--r--Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH1/EX1.2.b/Ex1_1.2B.R10
-rw-r--r--Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH1/EX1.2.c/Ex1_1.2C.R6
-rw-r--r--Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH1/EX1.3.a/Ex1_1.3A.R4
8 files changed, 79 insertions, 0 deletions
diff --git a/Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH1/EX1.1/Ex1_1.R b/Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH1/EX1.1/Ex1_1.R
new file mode 100644
index 00000000..29aa56a6
--- /dev/null
+++ b/Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH1/EX1.1/Ex1_1.R
@@ -0,0 +1,6 @@
+#Example : 1 Chapter : 1 pageno : 1
+v<-matrix(c(1,1),2,1,TRUE)
+w<-matrix(c(2,3),2,1,TRUE)
+z<-v+w
+z
+
diff --git a/Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH1/EX1.2.1/Ex1.2_1.R b/Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH1/EX1.2.1/Ex1.2_1.R
new file mode 100644
index 00000000..ae9dccf2
--- /dev/null
+++ b/Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH1/EX1.2.1/Ex1.2_1.R
@@ -0,0 +1,14 @@
+#Example : 1 Chapter : 1.2 pgno:-11
+
+#Computing the dotproduct of two vectors
+dotproduct<-function(x,y){
+ res<-0
+ for(i in 1:length(x)){
+ res<-res+x[i]*y[i]
+ }
+ res
+}
+v<-matrix(c(4,2),nrow=2,ncol=1,byrow = T)
+w<-matrix(c(-1,2),nrow=2,ncol=1,byrow=T)
+r<-dotproduct(v,w)
+print(paste("Dot product of given vectors is",r))
diff --git a/Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH1/EX1.2.2/Ex1.2_2.R b/Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH1/EX1.2.2/Ex1.2_2.R
new file mode 100644
index 00000000..1f023173
--- /dev/null
+++ b/Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH1/EX1.2.2/Ex1.2_2.R
@@ -0,0 +1,11 @@
+#Example : 2 Chapter : 1.2 pgno:-11
+
+#Computing the dotproduct of two vectors
+dotproduct<-function(x,y){
+ dp<-sum(x*y)
+ return(dp)
+}
+weight<-matrix(c(4,2),nrow=2,ncol=1,byrow = T)
+distance<-matrix(c(-1,2),nrow=2,ncol=1,byrow=T)
+center_point<-dotproduct(weight,distance)
+center_point \ No newline at end of file
diff --git a/Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH1/EX1.2.5/Ex1.2_5.R b/Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH1/EX1.2.5/Ex1.2_5.R
new file mode 100644
index 00000000..d4e5a915
--- /dev/null
+++ b/Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH1/EX1.2.5/Ex1.2_5.R
@@ -0,0 +1,11 @@
+#Example : 5 Chapter : 1.2 pageno : 16
+
+v<-c(2,1)
+w<-c(1,2)
+dotproduct<-sum(v*w)
+magn_v<-sqrt(sum(v*v))
+magn_w<-sqrt(sum(w*w))
+cos_angle<-dotproduct/(magn_v*magn_w)
+print(paste("Cosine of the angle between the given vectors is",cos_angle))
+
+
diff --git a/Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH1/EX1.2.a/Ex1_1.2A.R b/Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH1/EX1.2.a/Ex1_1.2A.R
new file mode 100644
index 00000000..08e3cba5
--- /dev/null
+++ b/Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH1/EX1.2.a/Ex1_1.2A.R
@@ -0,0 +1,17 @@
+#Example : 1.2A Chapter : 1.2 Pageno : 17
+#Finds whether Schwartz and traingular inequality between the given vectors are satisfied
+#Finds the Cosine of the angle between the given vectors
+v<-c(3,4)
+w<-c(4,3)
+dp=sum(v*w)
+magn_v=sqrt(sum(v*v))
+magn_w=sqrt(sum(w*w))
+if(dp<=magn_v*magn_w){
+ print("Schwartz inequality is satisfied for the given vectors")
+}
+z=v+w
+magn_sum=sqrt(sum(z*z))
+if(magn_sum<=magn_v+magn_w){
+ print("Traingular inequality is satisfied for the given vectors")
+}
+print(paste("Cosine of the angle between the given vectors is ",dp/(magn_v*magn_w)))
diff --git a/Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH1/EX1.2.b/Ex1_1.2B.R b/Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH1/EX1.2.b/Ex1_1.2B.R
new file mode 100644
index 00000000..f6c244f7
--- /dev/null
+++ b/Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH1/EX1.2.b/Ex1_1.2B.R
@@ -0,0 +1,10 @@
+#Example : 1.2B Chapter : 1.2 Pageno:-18
+v<-c(3,4)
+V<-v/sqrt(sum(v*v))
+print(paste("The Unit vector in the direction of the given vector is ", V[1]," ",V[2]))
+u<-c(-4,3)
+if(sum(u*v)==0){
+ print("The vectors u and v are perpendicular to each other")
+}
+U = u/sqrt(sum(u*u))
+print(paste("The unit vector in the direction of u is",U[1]," ",U[2])) \ No newline at end of file
diff --git a/Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH1/EX1.2.c/Ex1_1.2C.R b/Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH1/EX1.2.c/Ex1_1.2C.R
new file mode 100644
index 00000000..78b288fc
--- /dev/null
+++ b/Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH1/EX1.2.c/Ex1_1.2C.R
@@ -0,0 +1,6 @@
+#Example : 1.2C Chapter : 1.2 Pageno : 18
+A<-matrix(c(2,-1,-1,2),ncol=2)
+b<-c(1,0)
+x<-solve(A,b)
+print("The solution of system is :")
+print(x) \ No newline at end of file
diff --git a/Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH1/EX1.3.a/Ex1_1.3A.R b/Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH1/EX1.3.a/Ex1_1.3A.R
new file mode 100644
index 00000000..3b47cc4f
--- /dev/null
+++ b/Introduction_To_Linear_Algebra_by_Gilbert_Strang/CH1/EX1.3.a/Ex1_1.3A.R
@@ -0,0 +1,4 @@
+#Example : 1.3A Chapter : 1.3 Pageno : 27
+A=matrix(c(1,0,0,-1,1,0,1,-1,1),ncol=3,byrow=T)
+A1=solve(A) # to find the inverse of the matrix
+A1 \ No newline at end of file