       RE: RE: Fast Integration of a product of 2 interpolating function s

• To: mathgroup at smc.vnet.net
• Subject: [mg26620] RE: RE: Fast Integration of a product of 2 interpolating function s
• From: "Ersek, Ted R" <ErsekTR at navair.navy.mil>
• Date: Sat, 13 Jan 2001 22:36:03 -0500 (EST)
• Sender: owner-wri-mathgroup at wolfram.com

```Earlier I wrote:
---------------------
> Sebastien de Menten de Horne  wanted to efficiently Integrate the product
> of two IntegratingFunctions.  I think the following will work.
>
>  f=FunctionInterpolation[ Cos[x + y] + y^2, {x, -1., 1}, {y, -1., 1}];
>  g=FunctionInterpolation[ Exp[y] + z/(y + 2), {y, -1., 1}, {z, -1., 1}];
>  h=FunctionInterpolation[ f[x,y] g[y,z], {x,-1.,1.}, {y,-1.,1.},
> {z,-1.,1.}];
>  int[x_,z_]:=Integrate[ h[x,y,z], {y, -1, 1} ]
>
>
> The following standard package might also be helpful.
>      NumericalMath`NIntegrateInterpolatingFunct`
>
-----------------------
We can do much better because the code above performs the
integration every time (int[x,z]) is used.  Instead the following should be
used to allow faster evaluation of  int[x,z].

f=FunctionInterpolation[ Cos[x + y] + y^2, {x, -1., 1}, {y, -1.,
1}];
g=FunctionInterpolation[ Exp[y] + z/(y + 2), {y, -1., 1}, {z, -1.,
1}];
h=FunctionInterpolation[ f[x,y] g[y,z],
{x,-1.,1.}, {y,-1.,1.}, {z,-1.,1.}
];
Clear[x,z]
int[x_,z_]=Integrate[ h[x,y,z], {y, -1, 1} ]

---------------
Notice I use    int[x_,z_] =
rather than     int[x_,z_] :=
to ensure the integration is only done when (int) is defined.

Use of   Clear[x,z]   is recommended since this would not work right

if (x), or (z) have global values when (int) is defined.

> --------------------
> Regards,
> Ted Ersek
>

```

• Prev by Date: Name of a list
• Next by Date: Re: How to get the slope of a Interpolation[] function at a specified point?
• Previous by thread: Re: Name of a list
• Next by thread: Summary: Random Sampling Without Replacement