## Example: Linear interpolation of the sine function
xs <- linspace(0, pi, 10)
ys <- sin(xs)
P <- matrix(NA, nrow = 9, ncol = 2)
for (i in 1:9) {
P[i, ] <- c((ys[i+1]-ys[i])/(xs[i+1]-xs[i]), ys[i])
}
ppsin <- mkpp(xs, P)
## Not run:
# plot(xs, ys); grid()
# x100 <- linspace(0, pi, 100)
# lines(x100, sin(x100), col="darkgray")
# ypp <- ppval(ppsin, x100)
# lines(x100, ypp, col="red")
# ## End(Not run)
Run the code above in your browser using DataLab