diff options
author | prashantsinalkar | 2019-10-04 12:24:07 +0530 |
---|---|---|
committer | prashantsinalkar | 2019-10-04 12:24:07 +0530 |
commit | b3f3a8ecd454359a2e992161844f2fb599f8238a (patch) | |
tree | 7bb3f64824627ef179d5f341266a664fd0b69011 /Numerical_Methods_by_E_Balaguruswamy/CH11/EX11.8 | |
parent | 80492d3788738910b80dc16f918511057b7321d6 (diff) | |
download | R_TBC_Uploads-b3f3a8ecd454359a2e992161844f2fb599f8238a.tar.gz R_TBC_Uploads-b3f3a8ecd454359a2e992161844f2fb599f8238a.tar.bz2 R_TBC_Uploads-b3f3a8ecd454359a2e992161844f2fb599f8238a.zip |
Initial commit/added all books
Diffstat (limited to 'Numerical_Methods_by_E_Balaguruswamy/CH11/EX11.8')
-rw-r--r-- | Numerical_Methods_by_E_Balaguruswamy/CH11/EX11.8/Ex11_8.R | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/Numerical_Methods_by_E_Balaguruswamy/CH11/EX11.8/Ex11_8.R b/Numerical_Methods_by_E_Balaguruswamy/CH11/EX11.8/Ex11_8.R new file mode 100644 index 00000000..fad41028 --- /dev/null +++ b/Numerical_Methods_by_E_Balaguruswamy/CH11/EX11.8/Ex11_8.R @@ -0,0 +1,40 @@ +# Example 8 Chapter 11 Page no.: 364
+# Richardson Extrapolation
+
+f <- function(x){
+ return(exp(x))
+}
+h1<- 0.5
+r1 <- 1/2
+x1<- 0.5
+
+#First order forward difference formula
+D1 <- function(x,h) {
+ return((f(x+h) - f(x-h))/(2*h))
+}
+
+Dr1 <- function(x,r,h){
+ return((f(x+(r*h)) - f(x-(r*h)))/(2*r*h))
+}
+
+f1 <- function(x,r,h){
+ return((Dr1(x,r,h)-(r^2)*D1(x,h))/(1-(r^2)))
+}
+F <- signif(f1(x1,r1,h1), digits = 5)
+
+cat("The value of function e^x at",x1," with parameters")
+cat("h=",h1)
+cat("r=",r1)
+cat("is",F)
+
+# The value deviates slighly from the value of the textbook becaues of approximation in the text
+
+r2 <- 2
+F1 <- signif(f1(x1,r2,h1), digits = 5)
+
+cat("The value of function e^x at",x1," with parameters")
+cat("h=",h1)
+cat("r=",r2)
+cat("is",F1)
+
+cat(" This shows that estimate with r=",r1,"is better than the estimate with r=",2)
\ No newline at end of file |