R是否存在uniroot和處理浮點的已知問題?R中的浮點不準確性?
>str(uniroot(function(x) x*(x^2-1) + .5, lower = -2, upper = 2,
+ tol = 0.0001))
List of 4
$ root : num -1.19
$ f.root : num -2.55e-07
$ iter : int 7
$ estim.prec: num 5e-05
> -1.19 * (1.19^2 - 1) + 0.5
[1] 0.004841
顯然f.root
的值不等於手工計算的函數的值。
http://upload.wikimedia.org/wikipedia/en/b/b9/MagrittePipe.jpg – hadley
函數只顯示了3個無花果 –
您使用了錯誤的手 –