get x-value given y-value: general root finding for linear / non-linear interpolation function
问题 I am interested in a general root finding problem for an interpolation function. Suppose I have the following (x, y) data: set.seed(0) x <- 1:10 + runif(10, -0.1, 0.1) y <- rnorm(10, 3, 1) as well as a linear interpolation and a cubic spline interpolation: f1 <- approxfun(x, y) f3 <- splinefun(x, y, method = \"fmm\") How can I find x -values where these interpolation functions cross a horizontal line y = y0 ? The following is a graphical illustration with y0 = 2.85 . par(mfrow = c(1, 2))