MathGroup Archive 2006

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

Search the Archive

Re: Options to FunctionInterpolation

  • To: mathgroup at smc.vnet.net
  • Subject: [mg67591] Re: Options to FunctionInterpolation
  • From: "James Gilmore" <james.gilmore at yale.edu>
  • Date: Sat, 1 Jul 2006 05:12:39 -0400 (EDT)
  • Organization: Yale University
  • References: <e82o97$r6e$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Hi mathgroup,

Just re-reading my earlier post and it strikes me that the actual 
computation of the large fraction is the computationally intensive step, 
rather than the computation of Exp[fraction]. I checked this with my code 
and it is indeed the case. Does anyone know why the FunctionInterpolation 
fraction computation is slow?

Investigating a bit further reveals an interesting structure to the sampled 
point of the FunctionInterpolatgion. Does, anyone know why the following 
ListPlot has the "jagged" curve, and what algorithm is used to sample the 
function, because the pattern appears to repeat?

n = 0;
xl = {};
f[x_] := (++n; xl = Append[xl, {n, x}]; 1. Exp[x]);
g = FunctionInterpolation[f[x], {x, -5, 5}, PrecisionGoal -> 5, 
InterpolationPrecision -> Automatic, MaxRecursion -> 4];
ListPlot[xl, Frame -> True, PlotJoined -> True];


Cheers
James

"Andrew Moylan" <andrew.j.moylan at gmail.com> wrote in message 
news:e82o97$r6e$1 at smc.vnet.net...
> 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: Color names and the 10 elementary colors?
  • Next by Date: Re: Color names and the 10 elementary colors?
  • Previous by thread: Re: Color names and the 10 elementary colors?
  • Next by thread: Re: Options to FunctionInterpolation