# FunctionInterpolation error when specifying AccuracyGoal

Bug introduced in 8 or earlier and persisting through 11.0.1 or later

In the help page ref/message/FunctionInterpolation/ncvb, it is mentioned that one should specify AccuracyGoal for some (even very simple) functions:

FunctionInterpolation[Sqrt[x], {x, 0, 1}, AccuracyGoal -> 2]


However, when I evaluate it, a lot of error messages are generated, such as

Thread::tdlen: Objects of unequal length in {-(1/8),-(1/24),1/24,1/8}^{} cannot be combined. FunctionInterpolation::nreal: "Near x = 1/8, the function did not evaluate to a real number.

Also, the precision I got is very bad (as one can check using Plot[%[x] - Sqrt[x], {x, 0, 1}, PlotRange -> All]). The error is about 5% so not usable for realistic work (and the situation does not change when I increase AccuracyGoal).

Is it a bug? Perhaps I have to do Interpolation or ListInterpolation by hand myself.

\$Version


"9.0 for Linux x86 (64-bit) (February 7, 2013)"

PS: I found this thread may be related but still different FunctionInterpolation Errors / Question re Evaluation Order and Options

Change to real numbers:

fi = FunctionInterpolation[Sqrt[x], {x, 0., 1.}]

Plot[fi@x, {x, 0., 1.}]


The "error" is very small:

Plot[fi@x - Sqrt@x, {x, 0., 1.}]


• Thanks! It's a nice workaround. But considering the integer argument appears in Mathematica's official documentation (also the error messages are not relevant), perhaps I should mark this question as a bug? – Yi Wang Jun 21 '14 at 15:24
• @YiWang - Using {0, 1} causes a relatively large pertubation near 0, wheras 0. behaves much better near 0. Yes, maybe it's a bug since Sqrt[0] == 0 and not something near 0. – eldo Jun 21 '14 at 15:35