The Interpolation section of the Boost Math library provides methods for numerical integration and differentiation of functions. These methods can be used directly in R without needing any additional compilation.
control_points <- list(c(0, 0, 0), c(1, 2, 0), c(2, 0, 0), c(3, 3, 0))
interpolator <- bezier_polynomial(control_points)
xi <- 1.5
interpolator$spline(xi)
#> [1] NaN NaN NaN
interpolator$prime(xi)
#> [1] 3.00 30.75 0.00
new_control_point <- c(1.5, 1, 0)
interpolator$edit_control_point(new_control_point, 2)
#> NULL
control_points <- list(c(0, 0, 0), c(1, 1, 0), c(2, 0, 0), c(3, 1, 0))
interpolator <- catmull_rom(control_points)
xi <- 1.5
interpolator$spline(xi)
#> [1] 1.2613446 0.8307972 0.0000000
interpolator$prime(xi)
#> [1] 0.8408964 -1.1363078 0.0000000
interpolator$max_parameter()
#> [1] 3.567621
interpolator$parameter_at_point(2)
#> [1] 2.378414
x <- c(0, 1, 2)
y <- c(0, 1, 0)
dydx <- c(1, 0, -1)
d2ydx2 <- c(0, -1, 0)
interpolator <- quintic_hermite(x, y, dydx, d2ydx2)
xi <- 0.5
interpolator$spline(xi)
#> [1] 0.640625
interpolator$prime(xi)
#> [1] 1.40625
interpolator$double_prime(xi)
#> [1] -1.25
interpolator$push_back(3, 0, 1, 0)
#> NULL
interpolator$domain()
#> [1] 0 3