find_roots: find_roots

View source: R/RcppExports.R

find_rootsR Documentation

find_roots

Description

finds roots in complex plane.

Usage

find_roots(x_n,roots,digits)

Arguments

x_n

vector

roots

vector

digits

number of significant digits till calculation stops.

Details

find roots

Examples

#######
# 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(summary(f1)$zeros,6)

wagnius-GmbH/slvwagner documentation built on Jan. 19, 2025, 7:10 a.m.