MathGroup Archive 2006

[Date Index] [Thread Index] [Author Index]

Search the Archive

Options to FunctionInterpolation

  • To: mathgroup at smc.vnet.net
  • Subject: [mg67550] Options to FunctionInterpolation
  • From: "Andrew Moylan" <andrew.j.moylan at gmail.com>
  • Date: Fri, 30 Jun 2006 04:15:02 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

Hi,

I am trying to understand the meaning of the options to
FunctionInterpolation, especially the InterpolationPrecision option,
whose default value is Automatic. Please consider the following code:

n = 0;
f[x_] := (++n; Exp[x]);
g = FunctionInterpolation[f[x], {
x, -5, 5}, PrecisionGoal -> 5, InterpolationPrecision ->
$MachinePrecision];
Print[n];

It creates an interpolating function for f[x] in the range {-5,5},
counting the number of times f[x] is evaluated. In this example, I get
n = 153, and the code takes less than a second to execute. Now consider
the following slightly different code:

n = 0;
f[x_] := (++n; Exp[x]);
TimeConstrained[g =
        FunctionInterpolation[f[x], {x, -5, 5}, PrecisionGoal -> 5, \
InterpolationPrecision -> Automatic], 5, Print["ran out of time"]];
Print[n];

Again this code tries to create an interpolating function for f[x] in
the range {-5,5}, but this time the default value of Automatic is used
for InterpolationPrecision. The output of this code is "ran out of
time" and "100". Thus, the code takes longer than 5 seconds to execute,
and f[x] is only evaluated 100 times during those 5 seconds!

Can anyone explain what the default setting of Automatic for
InterpolationPrecision does, and why FunctionInterpolation is failing
in this case? For reference, it may be useful to consider the following
final piece of code, in which the default settings (of Automatic) are
used for both PrecisionGoal and InterpolationPrecision:

n = 0;
f[x_] := (++n; Exp[x]);
g = FunctionInterpolation[f[x], {x, -5, 5}];
Print[n];

The result of this code is a very quick "243".

Thanks for any help.

Cheers,

Andrew


  • Prev by Date: Re: repeated usage of packages
  • Next by Date: RE: Change Symbol in ListPlot
  • Previous by thread: Pasting a color from DrawGraphicsPalette
  • Next by thread: Recognizing newline character in regular expressions