get x-value given y-value: general root finding for linear / non-linear interpolation function

前端 未结 2 725
孤独总比滥情好
孤独总比滥情好 2020-11-30 13:23

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 &         


        
2条回答
  •  佛祖请我去吃肉
    2020-11-30 13:54

    Given data points and spline function as above, simply apply findzeros() from the pracma package.

    library(pracma)
    xs <- findzeros(function(x) f3(x) - 2.85,min(x), max(x))
    
    xs  # [1] 3.924513 6.435812 9.207169 9.886618
    points(xs, f3(xs))
    

提交回复
热议问题