metoda.secen <- function(f, x01, x02, tol=1e-5, maxit=20){ x1<- x01 x2 <- x02 body <- c(x1,x2) for (iter in 1:maxit){ df <- (x2-x1)/(f(x2)-f(x1))*f(x2) x <- x2-df body <- c(body, x) x1 <- x2 x2 <- x if (f(x)==0) {return(result <- list(koren=x, pocitadlo=iter+2, chyba=0, body=body))} else if (abs(df) < tol){ result <- list(koren=x, pocitadlo=iter, chyba=(x2-x1)/(f(x2)-f(x1))*f(x2), body=body) return(result) } } }