summaryrefslogtreecommitdiff
path: root/Numerical_Methods_by_E_Balaguruswamy/CH9/EX9.12/Ex9_12.R
blob: 715cf2d70d3731489a3802a4c4288fd49e606b3e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#Example 12     Chapter 9       Page no.: 313
#Estimating Function values using Cubic splines.

#Installing and importing library 'pracma'
install.packages("pracma")
library("pracma")

#Given Data
mydata<-data.frame(i= c(0,1,2,3),
                   xi= c(1,2,3,4),
                   fi= c(0.5, 0.3333, 0.25, 0.20),
       stringsAsFactors = TRUE
)
mydata

x<-mydata$xi
f<-mydata$fi

#function to find spline at xi
C <- signif(cubicspline(x, f, xi = 2.5),5)  

cat("Cubic spline of f(2.5) is :",C)