Поиск корней уравнения
# поиск корней уравнения
# R solve
# tol = задает точность
library(rootSolve)
options(digits = 14)
err = 1e-14
#------------------
# 20*sin(x) = 7
# создадим функцию
#y = function(x) 20*sin(x)-7
#y = function(x) 2*x^2 - 6*x - 20
#y = function(x) x^x - 10
y = function(x) x^3 - 6*x^2 + 11*x -6
x1 = 0.5
x2 = 3.5
x = seq(x1, x2, 0.1)
plot(x, y(x), type = 'l', lwd=2)
abline(h = 0, lwd =2)
grid(col='black')
roots = uniroot.all(y, interval = c(x1, x2), n = 5,
tol = err, maxiter=10)
roots
abline(v = roots, lwd=2, lty = "dashed")
points(roots,rep(0, length(as.vector(roots))), col='red', pch =16, lwd=2)
y(roots)
