R Under development (unstable) (2026-02-10 r89394 ucrt) -- "Unsuffered Consequences" Copyright (C) 2026 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > if(!require("BB"))stop("this test requires package BB.") Loading required package: BB > if(!require("setRNG"))stop("this test requires setRNG.") Loading required package: setRNG > > # Use a preset seed so test values are reproducable. > test.rng <- list(kind="Mersenne-Twister", normal.kind="Inversion", seed=1236) > old.seed <- setRNG(test.rng) > #iseed <- 1236 # this seed was used for tests conducted on March 25, 2008. > #set.seed(iseed) > > extrosbk <- function(x) { + n <- length(x) + f <- rep(NA, n) + j <- 2 * (1:(n/2)) + jm1 <- j - 1 + f[jm1] <- 10 * (x[j] - x[jm1]^2) + f[j] <- 1 - x[jm1] + f + } > > p0 <- runif(50) > ans1 <- dfsane(par=p0, fn=extrosbk, method=1) Iteration: 0 ||F(x0)||: 3.855142 iteration: 10 ||F(xn)|| = 0.8227363 iteration: 20 ||F(xn)|| = 3.391838 iteration: 30 ||F(xn)|| = 0.02200184 iteration: 40 ||F(xn)|| = 5.911658e-05 > ans2 <- dfsane(par=p0, fn=extrosbk, method=2) Iteration: 0 ||F(x0)||: 3.855142 iteration: 10 ||F(xn)|| = 1.10447 iteration: 20 ||F(xn)|| = 0.07791162 iteration: 30 ||F(xn)|| = 0.0003046161 > ans3 <- sane(par=p0, fn=extrosbk, method=1) Iteration: 0 ||F(x0)||: 3.855142 iteration: 10 ||F(xn)|| = 0.8227363 iteration: 20 ||F(xn)|| = 0.009788252 > ans4 <- sane(par=p0, fn=extrosbk, method=2) Iteration: 0 ||F(x0)||: 3.855142 iteration: 10 ||F(xn)|| = 1.10447 iteration: 20 ||F(xn)|| = 0.07791162 iteration: 30 ||F(xn)|| = 0.0003046161 > #ans <- nlsolve(p0, fn=extrosbk, method="L-BFGS-B") > > c(ans1$resid, ans2$resid,ans3$resid, ans4$resid) #, ans$val) [1] 4.704689e-08 6.128732e-08 5.406706e-08 8.015944e-08 > c(ans1$feval, ans2$feval,ans3$feval,ans4$feval) #, ans$counts[1]) [1] 54 43 61 76 > > nsim <- 10 > dfsane1.extrosbk <- dfsane2.extrosbk <- sane1.extrosbk <- sane2.extrosbk <- matrix(NA, nsim, 5) > for (i in 1:nsim) { + cat("Simulation" , i, "\n") + p0 <- runif(50) + t1 <- system.time(ans <- sane(par=p0, fn=extrosbk, method=1, control=list(BFGS=TRUE, trace=F)))[1] + if (!is.null(ans))sane1.extrosbk[i, ] <- c(ans$resid, ans$feval, ans$iter, ans$conv, t1) + t2 <- system.time(ans <- sane(par=p0, fn=extrosbk, method=2, control=list(BFGS=TRUE, trace=F)))[1] + if (!is.null(ans))sane2.extrosbk[i, ] <- c(ans$resid, ans$feval, ans$iter, ans$conv, t2) + t3 <- system.time(ans <- dfsane(par=p0, fn=extrosbk, method=1, control=list(BFGS=TRUE, trace=F)))[1] + if (!is.null(ans))dfsane1.extrosbk[i, ] <- c(ans$resid, ans$feval, ans$iter, ans$conv, t3) + t4 <- system.time(ans <- dfsane(par=p0, fn=extrosbk, method=2, control=list(BFGS=TRUE, trace=F)))[1] + if (!is.null(ans)) dfsane2.extrosbk[i, ] <- c(ans$resid, ans$feval, ans$iter, ans$conv, t4) + } Simulation 1 Simulation 2 Calling `L-BFGS-B' in `optim' Simulation 3 Simulation 4 Simulation 5 Calling `L-BFGS-B' in `optim' Calling `L-BFGS-B' in `optim' Simulation 6 Simulation 7 Simulation 8 Calling `L-BFGS-B' in `optim' Simulation 9 Simulation 10 Warning messages: 1: In sane(par = p0, fn = extrosbk, method = 2, control = list(BFGS = TRUE, : Unsuccessful convergence. 2: In sane(par = p0, fn = extrosbk, method = 2, control = list(BFGS = TRUE, : Unsuccessful convergence. 3: In dfsane(par = p0, fn = extrosbk, method = 1, control = list(BFGS = TRUE, : Unsuccessful convergence. 4: In sane(par = p0, fn = extrosbk, method = 2, control = list(BFGS = TRUE, : Unsuccessful convergence. > > z <- apply(sane1.extrosbk, 2, summary) > print(z) [,1] [,2] [,3] [,4] [,5] Min. 1.335340e-10 60.00 28.00 0 0.000 1st Qu. 5.951575e-09 66.75 32.25 0 0.000 Median 2.565887e-08 71.50 34.00 0 0.000 Mean 2.994176e-08 71.40 34.20 0 0.001 3rd Qu. 4.300206e-08 76.75 36.50 0 0.000 Max. 7.837160e-08 81.00 40.00 0 0.010 > print(z[,1], digits=18) Min. 1st Qu. Median 1.33533959609399358e-10 5.95157466621134557e-09 2.56588652902058739e-08 Mean 3rd Qu. Max. 2.99417578876312394e-08 4.30020575772886201e-08 7.83716024310325088e-08 > z <- apply(sane2.extrosbk, 2, summary) > print(z) [,1] [,2] [,3] [,4] [,5] Min. 1.907416e-09 65.00 31.00 0.00 0.000 1st Qu. 9.664449e-09 75.75 37.25 0.00 0.000 Median 1.978264e-08 87.50 42.50 0.00 0.000 Mean 4.013260e-05 164.50 66.40 1.50 0.020 3rd Qu. 8.988732e-05 273.25 106.50 3.75 0.045 Max. 1.412424e-04 396.00 130.00 5.00 0.080 > print(z[,1], digits=18) Min. 1st Qu. Median 1.90741649674069057e-09 9.66444946422534582e-09 1.97826361796275232e-08 Mean 3rd Qu. Max. 4.01325985691747974e-05 8.98873227557618024e-05 1.41242435258851070e-04 > z <- apply(dfsane1.extrosbk, 2, summary) > print(z) [,1] [,2] [,3] [,4] [,5] Min. 7.999536e-10 32.00 28.0 0.0 0.000 1st Qu. 1.819546e-08 36.75 31.5 0.0 0.000 Median 2.684498e-08 40.00 34.0 0.0 0.000 Mean 1.408748e-05 168.30 44.1 0.5 0.018 3rd Qu. 4.279201e-08 43.50 36.0 0.0 0.000 Max. 1.406332e-04 1332.00 140.0 5.0 0.160 > print(z[,1], digits=18) Min. 1st Qu. Median 7.99953602115996480e-10 1.81954615966572011e-08 2.68449821544756162e-08 Mean 3rd Qu. Max. 1.40874837921484094e-05 4.27920063452065560e-08 1.40633206116653049e-04 > z <- apply(dfsane2.extrosbk, 2, summary) > print(z) [,1] [,2] [,3] [,4] [,5] Min. 1.652119e-09 37.0 31.00 0 0.000 1st Qu. 4.804545e-09 44.0 37.00 0 0.000 Median 1.738585e-08 45.0 42.00 0 0.000 Mean 2.205162e-08 57.1 52.80 0 0.001 3rd Qu. 2.645730e-08 50.5 48.25 0 0.000 Max. 8.108725e-08 139.0 135.00 0 0.010 > print(z[,1], digits=18) Min. 1st Qu. Median 1.65211947335581901e-09 4.80454455551685901e-09 1.73858491674288428e-08 Mean 3rd Qu. Max. 2.20516197818450655e-08 2.64573017899939173e-08 8.10872457238558730e-08 > > > proc.time() user system elapsed 1.17 0.12 1.28