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. > options(digits=12) > 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="Wichmann-Hill", normal.kind="Box-Muller", seed=c(979,1479,1542)) > old.seed <- setRNG(test.rng) > > > ######################################### > cat("BB test froth ...\n") BB test froth ... > > froth <- function(p){ + # Freudenstein and Roth function (Broyden, Mathematics of Computation 1965, p. 577-593) + f <- rep(NA,length(p)) + f[1] <- -13 + p[1] + (p[2]*(5 - p[2]) - 2) * p[2] + f[2] <- -29 + p[1] + (p[2]*(1 + p[2]) - 14) * p[2] + sum (f * f) + } > > p0 <- rpois(2,10) > system.time(ans.spg <- spg(par=p0, fn=froth, control=list(M=20, maxit=2500)))[1] iter: 0 f-value: 90842 pgrad: 99836.0048106 iter: 10 f-value: 168.571319021 pgrad: 30.4387560845 iter: 20 f-value: 53.7424011506 pgrad: 2.95705866904 iter: 30 f-value: 54.695078884 pgrad: 80.9336462737 iter: 40 f-value: 50.1273929575 pgrad: 1.40112319968 iter: 50 f-value: 50.8368121528 pgrad: 49.5256877997 iter: 60 f-value: 49.3250968325 pgrad: 0.773142900812 iter: 70 f-value: 49.1136353221 pgrad: 0.46335657089 iter: 80 f-value: 49.0609920845 pgrad: 0.352581110974 iter: 90 f-value: 49.0506330175 pgrad: 9.94959741263 iter: 100 f-value: 48.9845020039 pgrad: 0.564741426956 user.self 0.02 > #ans.spg > system.time(ans.opt <- optim(par=p0, fn=froth, method="L-BFGS-B"))[1] user.self 0 > > z <- sum(ans.spg$par) > good <- 10.51597043896899 > #on Windows 10.51597043896899 > #on Linux64 10.51597043896899 > #on Linux64 10.51597048420193 Ubuntu 10.04 > #on Linux32 10.51597043896899 > print(z, digits=16) [1] 10.51597048420193 > if(any(abs(good - z) > 1e-7)) stop("BB test froth a FAILED") > > z <- sum(ans.opt$par) > good <- 9.00000701456296 > #on Windows 9.00000701456296 > #on Linux64 9.00000701456296 > #on Linux32 9.00000701456296 > print(z, digits=16) [1] 9.000007014562957 > if(any(abs(good - z) > 1e-12)) stop("BB test froth b FAILED") > > proc.time() user system elapsed 0.21 0.06 0.21