Your function is not even differentiable. Simple integration rules will have error iff they span a point of non-differentiability so there is no way an automated routine will get a sensible error estimate for choosing adaptation.
You can integrate this function exactly, so why use integrate? If it is a sample of a smooth function, interpolate by say cubic splines rather than piecewise linearly (?splinefun). BTW, did you consult the reference on the help page? On Wed, 11 Aug 2004, Tine Buch-Larsen wrote: > I have a question regarding the function "integrate". > Why does integrate sometimes returns "extremely bad integrand behaviour", > when I integrate a well-define function between 0 and ,1 and how can I > solve the problem. > The following is an example of the problem: > x = seq(0, 1, length=50) > y = c(0.6697534, 0.7868631, 0.8793606, 0.9404326, 0.9933826, 1.0441545, > 1.0861214, 1.1076160, 1.0943228, 1.0620462, 1.0334792, 1.0176313, > 1.0189657, 1.0286591, 1.0635902, 1.0815423, 1.0952207, 1.0985036, > 1.0782912, 1.0411431, 1.0056234, 0.9641239, 0.9360296, 0.9212780, > 0.9057849, 0.8850640, 0.8836523, 0.8780735, 0.8793521, 0.8651096, > 0.8526203, 0.8280131, 0.8029167, 0.7886007, 0.7844318, 0.7838392, > 0.7996804, 0.8162264, 0.8245920, 0.8315790, 0.8465705, 0.8623909, > 0.8948042, 0.9145519, 0.9141968, 0.9188292, 0.9278436, 0.9264173, > 0.9381125, 0.9527778) > fct = approxfun(x, y, method="linear", rule=2) > integrate(fct, 0, 1)$value > > My R version is 1.7.1 Oh please, that's in need of an update. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595 ______________________________________________ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
