Re: Adaptive FunctionInterpolation[] ?
- To: mathgroup at smc.vnet.net
- Subject: [mg50180] Re: Adaptive FunctionInterpolation[] ?
- From: franjesus at hotmail.com (franjesus)
- Date: Thu, 19 Aug 2004 06:28:10 -0400 (EDT)
- References: <cfup5v$5ur$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
I solved a bug in the original version, which failed when the limits
of interpolation were not the same for all the variables present in
the expression.
This version works as expected:
AdaptiveFunctionInterpolation[expr_, x__, opts___?OptionQ] :=
Module[{acc, g, gridpts, iarrays, niacc, pts, vars, vol},
acc = AccuracyGoal /. {opts} /. AccuracyGoal -> 6;
vol = Times @@ ({x}[[All, 3]] - {x}[[All, 2]]);
niacc = -Log[10, 10^-acc vol];
vars = {x}[[All, 1]];
pts = {};
NIntegrate[expr, x, AccuracyGoal -> niacc, EvaluationMonitor :>
PrependTo[pts, vars]];
pts = Partition[Flatten[pts], Length[vars]];
gridpts = (Union[pts[[All, #1]], {x}[[#1, {2, 3}]]] &) /@
Range[Length[vars]];
iarrays = expr /. Outer[Thread[vars -> {##1}] &, Sequence @@
gridpts];
ListInterpolation[iarrays, gridpts]
]