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/CH9/EX9.9 | |
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/CH9/EX9.9')
-rw-r--r-- | Numerical_Methods_by_E_Balaguruswamy/CH9/EX9.9/Ex9_9.R | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/Numerical_Methods_by_E_Balaguruswamy/CH9/EX9.9/Ex9_9.R b/Numerical_Methods_by_E_Balaguruswamy/CH9/EX9.9/Ex9_9.R new file mode 100644 index 00000000..ee3dd35e --- /dev/null +++ b/Numerical_Methods_by_E_Balaguruswamy/CH9/EX9.9/Ex9_9.R @@ -0,0 +1,61 @@ +#Example 9 Chapter 9 Page no.: 299
+#Newton-Gregory backward difference formula
+
+#Given Data
+mydata<- data.frame(t=c(10,20,30,40,50),
+ s=c(0.1736, 0.3420, 0.5000, 0.6428, 0.7660),
+ stringsAsFactors = TRUE
+)
+mydata
+
+theta<-mydata$t
+sin<- mydata$s
+s0<-sin[1]
+s1<-sin[2]
+s2<-sin[3]
+s3<-sin[4]
+s4<-sin[5]
+
+x0<-theta[1]
+x1<-theta[2]
+x2<-theta[3]
+x3<-theta[4]
+x4<-theta[5]
+
+h=x1-x0
+h
+
+x=25
+a1<- (x-x4)/h #for backward interpolation ,start from bottom
+a2<- (x-x3)/h
+a3<- (x-x2)/h
+a4<- (x-x1)/h
+a5<- (x-x0)/h
+
+f1<-s1-s0
+f2<-s2-s1
+f3<-s3-s2
+f4<-s4-s3
+delta1<- f2-f1
+delta2<- f3-f2
+delta3<- f4-f3
+
+get1<-delta1-delta2
+get2<-delta2-delta3
+
+last<- get2-get1
+
+p1<- s4+ a1*(f4)/1
+p1
+p2<- p1+ a1*a2*(delta3)/2
+p2
+p3<- p2+ a1*a2*a3*(get2)
+p3
+p4<- p3+ a1*a2*a3*a4*(last)
+p4
+
+cat("using Newton-Gregory Backward difference formula value of sin(25) was obtained to be :",p4)
+
+#Differed value in textbook is due to approximation upto 4 decimal places.
+
+
|