Here is some further information that makes the strangeness more
obvious:
The following three different calls to FunctionInterpolation all fail:
FunctionInterpolation[lowPrecisionSin[x], {x, 0, 1.`14}]
FunctionInterpolation[lowPrecisionSin[x], {x, 0, 1.`20}]
FunctionInterpolation[lowPrecisionSin[x], {x, 0, 1}]
The only way that I can successfully interpolate to an upper bound of
roughly 1 is by entering the upper bound as the
exactly-machine-precision number "1.":
FunctionInterpolation[lowPrecisionSin[x], {x, 0, 1.}]
Can anyone explain why higher-than-machine-precision (e.g. 1.`20),
lower-than-machine-precision (e.g. 1.`14), and infinite precision (1)
all fail, but exactly machine-precision succeeds here?
Secondly, does anyone know the meaning of the InterpolationPrecision
option to FunctionInterpolation? In particular, with the default
setting of InterpolationPrecision->Automatic, what value is
automatically chosen?
Andrew Moylan wrote:
> Hi,
>
> Can someone help me understand an unexpected dependence of
> FunctionInterpolation on the precision of its second argument?
>
> Here is function that behaves like a low-precision version of Sin:
>
> lowPrecisionSin[x_?NumericQ] := SetPrecision[Sin[x], 5]
>
> I can create an interpolation of this function thus:
>
> FunctionInterpolation[lowPrecisionSin[x], {x, 0, 1.}]
>
> This quickly successfully returns: InterpolatingFunction[{{0., 1.}},
> <>]
>
> If I instead try to create an interpolation of this function thus:
>
> FunctionInterpolation[lowPrecisionSin[x], {x, 0, 1.`14}]
>
> where the only difference is in the precision of the upper bound of the
> range of interpolation, FunctionInterpolation fails to return quickly,
> and it reports warnings like the following:
>
> FunctionInterpolation::ncvb: FunctionInterpolation failed to meet the
> \
> prescribed accuracy and precision goals after 6 recursive bisections
> near x = \
> 0.015625`13.154901959985743. Continuing to refine elsewhere.
>
> Note that this behaviour is unchanged if I add the options e.g.
> "PrecisionGoal -> 5, InterpolationPrecision -> 14" to each call to
> FunctionInterpolation. But the behaviour _does_ depend on the precision
> of lowPrecisionSin: if I change "5" to "10" in the definition of
> lowPrecisionSin, the problem disappears.
>
> Can anyone explain this apparently strange behaviour?
>
> Cheers,
>
> Andrew