summaryrefslogtreecommitdiff
path: root/Numerical_Methods_by_E_Balaguruswamy/CH14/EX14.6
diff options
context:
space:
mode:
authorPrashant S2019-10-04 12:27:32 +0530
committerGitHub2019-10-04 12:27:32 +0530
commitac2986488a9731cff5cbb517d8f0ef98e2561d64 (patch)
tree7bb3f64824627ef179d5f341266a664fd0b69011 /Numerical_Methods_by_E_Balaguruswamy/CH14/EX14.6
parentcbb2770fb2f88246175add29623103a56ba338b8 (diff)
parentb3f3a8ecd454359a2e992161844f2fb599f8238a (diff)
downloadR_TBC_Uploads-master.tar.gz
R_TBC_Uploads-master.tar.bz2
R_TBC_Uploads-master.zip
Merge pull request #1 from prashantsinalkar/masterHEADmaster
Added R TBC
Diffstat (limited to 'Numerical_Methods_by_E_Balaguruswamy/CH14/EX14.6')
-rw-r--r--Numerical_Methods_by_E_Balaguruswamy/CH14/EX14.6/Ex14_6.R25
1 files changed, 25 insertions, 0 deletions
diff --git a/Numerical_Methods_by_E_Balaguruswamy/CH14/EX14.6/Ex14_6.R b/Numerical_Methods_by_E_Balaguruswamy/CH14/EX14.6/Ex14_6.R
new file mode 100644
index 00000000..a8f0c2ac
--- /dev/null
+++ b/Numerical_Methods_by_E_Balaguruswamy/CH14/EX14.6/Ex14_6.R
@@ -0,0 +1,25 @@
+# Example 6 Chapter 14 Page no.: 478
+# Power method
+
+# Include "matlib" library
+install.packages("matlib")
+library(matlib)
+
+#Given Matrix
+A<-matrix(c(1,2,0,2,1,0,0,0,-1),nrow = 3,ncol = 3,byrow = TRUE)
+A
+eigen<-powerMethod(A)
+
+EigenVector<-(eigen$vector[,1]-eigen$vector[3,1])
+
+EigenVector<-matrix(EigenVector,nrow = 3,ncol = 1,byrow = TRUE)
+
+EigenVector<-(EigenVector/EigenVector[1]) #This is Eigen vector Corresponding to largest Eigen Value.
+
+EigenValue<-eigen$value #This is Largest Eigen Value.
+
+sprintf("The largest eigen value Lampda1=%g",EigenValue)
+
+print("The Eigen Vector corresponding to eigen value")
+
+print(EigenVector)