find_roots_v2 | R Documentation |
finds roots in complex plane.
find_roots_v2(x_n,roots,digits)
x_n |
vector |
roots |
vector |
digits |
number of significant digits till calculation stops. |
find_roots_v2
#######
# seeds
seeds <- expand.grid(seq(-1,1, length.out = 20),
seq(-1,1, length.out = 20))
seeds <- complex(real = seeds$Var1, imaginary = seeds$Var2)
f <- function(x) 1 - x + x^2 + x^5
f_ableitung <- function(x) -1 + 2*x + 5*x^4
f1 <- polynom::polynomial(coef = c(-0.2,-1,1,0,0,1))
#######
x_n <- seeds|>
lapply(function(x){
x_n <- 1:100
x_n[1] <- x
for( i in 2:length(x_n)) {
x_n[i] <- x_n[i-1]-(f(x_n[i-1])/f_ableitung(x_n[i-1]))
}
return(x_n)
})
x_n[[1]]|>find_roots_v2(summary(f1)$zeros,6)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.