maths - purrr package

hello, I am struggling to find a code which has to combine map_dbl along with uniroot to compute the root between the -3 pi/4 and 3 pi/4 of each of the three functions in list_fun which are :

linear = function(x) x
quadratic = function(x) (x - pi/2)^2 - pi/2
sinusoidal = function(x) sin(x)

finally, I should assign this result to a vector root_values having the same names
as list_fun .

What I have tried so far :

interval <- c(-3 pi/4, 3 pi/4)

linear <- uniroot(function(x) x, - x, interval)
quadratic <- uniroot(function(x) (x - pi/2)^2 - pi/2- x, interval)
sinusoidal <- uniroot(function(x) sin(x)- x, interval)
a <- map_dbl(1, list_fun)
root_values <- c(linear=linear$value, quadratic=quadratic$value, sinusoidal=sinusoidal$value)

A post was merged into an existing topic: mathematics purrr package map_dbl unroot

Please do not duplicate open topics