# cubic spline  (polynomial function of degree 3 that passes for the points
# and can be derived there up to the 2nd order)

x <- c(1,3,4,5,7); y <- c(5,20,29,20,20)
x1 <- 0; x2 <- 8; y1 <- -1; y2 <- 30
Plane(0,8, 0,30); POINT(x,y, "blue")
lines(spline(x,y,n=1000),col="red")
# extension of tracking outside the data
lines(spline(x,y,n=1000,xmin=0,xmax=8),col="brown")



# other example:
x <- c(20,50,80,110,140,170,200,230,260,290,320,350)
y <- c(13,13.5,12.5,10,9,7.5,6,5,6,7,11,15)
Plane(0,400, 0,16); POINT(x,y, "blue")
lines(spline(x,y,n=1000),col="red")