Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
# Bisection (numerical method) - Método da Bissecção
# Bisection (numerical method) - Método da Bissecção #….......................................... # Inserir sua função abaixo: g <- function(x){ x^3 - 6*x^2 - 33*x + 76 } #............................................ bis <- function(f,a,b,tol){ if( f(a)*f(b) > 0){ warning("Não existem raízes no intervalo: [",a,",",b,"]") }else{ while( (b-a)/2 > tol){ fa = f(a) fb = f(b) pm = (a+b)/2 fpm = f(pm) if( fpm*fb < 0){ a <- pm }else{ b <- pm pm <- (a+b)/2 } } } cat("Raíz: ", pm) curve(f, pm - 10, pm + 10) abline(h=0,v=0) points(pm,0, pch = 19, col = 'red') } bis(g,-5,1,0.00001) cat("\n ") bis(g,0,3,0.00001) cat("\n") bis(g,5,10,0.00001)
run
|
edit
|
history
|
help
0
3dgraphics-and-curvesb
ECO Stat
Labegen exemplo
Ex17-12-20
Graficos
Hello, world!
jcfatorial
Sequence position finder2
MAX
Grade.r