tests/testthat/test-bisection.R

#library(ingaasp2rcpp)
#context("Bisection")

#TODO correct, this was the tests of bisection written in R
# test_that("x^2-3x+1", {
#   expect_equal(root_bisection(function(x){x^2-3*x+1},0,1,1e-8,100,debug=0), (3-sqrt(5))/2) #confirming convergence on simple case
# })
#
# test_that("many roots", {
#   # curve(x^4+5*x^3+1*x^2+3*x-1+sin(12*x),0,1)
#   expect_equal(root_bisection(function(x){x^4+5*x^3+1*x^2+3*x-1+sin(12*x)},0,1,1e-8,100,debug=0), (3-sqrt(5))/2) #confirming convergence on simple case
# })
krzyklo/ingaasp2rcpp documentation built on Nov. 6, 2021, 7:49 a.m.