options(digits=7)
FexGander <- function(xx) ifelse(xx < 1,xx+1,ifelse(xx <= 3, 3 - xx, 2 ))
adaptsim(sin,0,pi,2.0e-3,TRUE)$Q - 2.0 # -1.686905e-05
adaptsim(sin,0,pi,2.0e-23)$Q - 2.0 # 0
adaptsim(FexGander,0,5)$Q - 7.5 # -7.993606e-15 instead of 0
adaptlob(FexGander,0,5,2.0e-6,TRUE) # 7.500002 instead of 7.5
adaptlob(FexGander,0,5,2.0e-6)$Q - 7.5 # 1.781274e-06 instead of 0
adaptlob(FexGander,0,5)$Q-7.5 # instead of -8.881784e-16, with warnings
# that required tolerance is too small.
adaptlob(FexGander,0,5,5.0*.Machine$double.eps)$Q-7.5 # -5.329071e-15
Run the code above in your browser using DataLab