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 /Numerical_Methods_by_E_Balaguruswamy/CH6/EX6.12/Ex6_12.R | |
parent | cbb2770fb2f88246175add29623103a56ba338b8 (diff) | |
parent | b3f3a8ecd454359a2e992161844f2fb599f8238a (diff) | |
download | R_TBC_Uploads-master.tar.gz R_TBC_Uploads-master.tar.bz2 R_TBC_Uploads-master.zip |
Added R TBC
Diffstat (limited to 'Numerical_Methods_by_E_Balaguruswamy/CH6/EX6.12/Ex6_12.R')
-rw-r--r-- | Numerical_Methods_by_E_Balaguruswamy/CH6/EX6.12/Ex6_12.R | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/Numerical_Methods_by_E_Balaguruswamy/CH6/EX6.12/Ex6_12.R b/Numerical_Methods_by_E_Balaguruswamy/CH6/EX6.12/Ex6_12.R new file mode 100644 index 00000000..9c9499fa --- /dev/null +++ b/Numerical_Methods_by_E_Balaguruswamy/CH6/EX6.12/Ex6_12.R @@ -0,0 +1,46 @@ +# Example 12 Chapter 6 Page no.: 162
+# Fixed point method Convergence and Divergence
+
+# Installing and importing package 'spuRs'
+install.packages("spuRs")
+library("spuRs")
+
+#Given function when converted in terms of 'x'
+f <- function(x){
+ 5/x
+}
+cat("Let initial value be 1")
+x0 <- 1
+
+F1 <- fixedpoint(f,x0)
+cat("This type of divergence is called OSCILLATORY DIVERGENCE")
+
+cat(" Let us assume another function x=(x^2)+x-5")
+f1 <- function(x){
+ (x^2)+x-5
+}
+cat("Let initial value be 0")
+x0 <- 0
+F2 <- fixedpoint(f1,x0)
+
+cat("This type of divergence is called MONOTONE DIVERGENCE as it diverges rapidly")
+
+#*********************************************
+
+# Error May occour when calculating convergence on f1.
+# It is due to rapid divergance.
+
+#*********************************************
+
+cat(" Let us assume another function 2x=(5/x)+x")
+f3 <- function(x){
+ (x+(5/x))/2
+}
+cat("Let initial value be 1")
+x0 <- 1
+F3 <- fixedpoint(f3,x0)
+
+cat("This time the function converges rapidly")
+cat("The square root of 5 is",signif(F3,digits = 5))
+
+
|