R/dual-higher.R
differentiate_n.RdEvaluates f at a dual variable seeded for order n,
returning the function value and all derivatives from 1 to n.
differentiate_n(f, x, order)A named list with components value, d1,
d2, ..., d<order>.
# All derivatives of sin(x) at x = pi/4
differentiate_n(sin, pi/4, order = 4)
#> $value
#> [1] 0.7071068
#>
#> $d1
#> [1] 0.7071068
#>
#> $d2
#> [1] -0.7071068
#>
#> $d3
#> [1] -0.7071068
#>
#> $d4
#> [1] 0.7071068
#>
# $value = sin(pi/4)
# $d1 = cos(pi/4)
# $d2 = -sin(pi/4)
# $d3 = -cos(pi/4)
# $d4 = sin(pi/4)