tests/testthat/test-uniroot.R

context("test to existing function `uniroot`")

test_that("same result", {
  target_func2 <- function(x) {x^4 + 3*x^3 - 6*x^2 + 8*x - 10}
  res <- Newton_Raphson(func = target_func2, x0 = 10)
  res_uniroot <- uniroot(target_func2, c(0, 10))
  expect_equal(res$root, res_uniroot$root, tolerance = 1e-3)
})
wasabi1989/NewtonRaphson documentation built on Nov. 14, 2019, 12:18 a.m.