Re: Precision of arguments to FunctionInterpolation
- To: mathgroup at smc.vnet.net
- Subject: [mg68514] Re: Precision of arguments to FunctionInterpolation
- From: "Andrew Moylan" <andrew.j.moylan at gmail.com>
- Date: Wed, 9 Aug 2006 04:17:57 -0400 (EDT)
- References: <eakeg1$r1j$1@smc.vnet.net><easjk5$fti$1@smc.vnet.net> <eauv4s$15k$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Peter Pein wrote: > Andrew Moylan schrieb: > > 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 latter works in Mathematica 5.1 for Windows You're right Peter, this last one works fine in Mathematica 5.2 for Windows too. I don't know now why I thought it didn't. > > 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? > > > You can test this using > > Reap[FunctionInterpolation[((Sow[Precision[#1]]; #1) & )[lowPrecisionSin[x]], {x, 0., 1}]][[2, 1]] > > which gives: > > {5.1924023244417254, Infinity, Infinity, 4.999999999999999, 5.000000000000001, 5., 5., 5., > 5.000000000000001, 4.999999999999999, 5., 5.000000000000001, 5., 5., 4.999999999999999, 5., > 5., 4.999999999999999, 5.000000000000001, 5.000000000000001, 5.000000000000001, 5., 5.} > > If you know the maximum precision of the function you want to interpolate (5 in this case), you can use > InterpolationPrecision->5: > > intfuns = {f14, f20, finf} = (FunctionInterpolation[lowPrecisionSin[x], > {x, 0, SetPrecision[1., #1]}, InterpolationPrecision -> 5] & ) /@ {14, 20, Infinity}; > > SameQ @@ intfuns > --> True > > Through[{f14, lowPrecisionSin, Sin}[0.6`14.000000000000002]] > --> {0.5646420701356566528`4.127871245474387, 0.5646424733950353572`5.000000000000002, 0.5646424733950353572009454457`14.056991706843485} Thanks Peter, this sheds some light on the meaning of the InterpolationPrecision option and how to choose it. I think that the default value for InterpolationPrecision is MachinePrecision, because the following succeeds with the same result as when using "InterpolationPrecision -> Automatic": FunctionInterpolation[lowPrecisionSin[x], {x, 0, 1}, InterpolationPrecision -> MachinePrecision] whereas any explicit numerical setting above about 13 for InterpolationPrecision fails. But again, when the upper bound of the region of interpolation is changed from 1 to the machine-precision number "1.", the interpolation suceeds for _any_ numerical value of the InterpolationPrecision option less than about 23, which is quite strange.