7
$\begingroup$

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

$\endgroup$
0

1 Answer 1

6
$\begingroup$

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

$\endgroup$
2
  • $\begingroup$ 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? $\endgroup$
    – Yi Wang
    Commented Jun 21, 2014 at 15:24
  • $\begingroup$ @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. $\endgroup$
    – eldo
    Commented Jun 21, 2014 at 15:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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