Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Bug introduced in 8 or earlier and persisting through 10.4 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.


"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

share|improve this question
up vote 5 down vote accepted

Change to real numbers:

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

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

enter image description here

The "error" is very small:

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

enter image description here

share|improve this answer
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

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.