       Re: Integrating Interpolation functions

• To: mathgroup at smc.vnet.net
• Subject: [mg89029] Re: Integrating Interpolation functions
• From: oshaughn <oshaughn at northwestern.edu>
• Date: Sat, 24 May 2008 03:52:55 -0400 (EDT)
• References: <g15qk7\$p9t\$1@smc.vnet.net>

```On May 23, 3:09 am, Hugh Goyder <h.g.d.goy... at cranfield.ac.uk> wrote:
> Below I given an illustrative example where I have a two-dimensional
> interpolation function, f1[x,t], and I integrate over x and obtain a
> one-dimensional expression g1 which is an interpolation function
> depending on t.  The interpolation function g1 has a built-in argument
> of t ie it ends in [t].  I would prefer it to be a pure function so
> that I could use any variable instead of t, like the original
> interpolation function, f1.  I give a work-around which defines a new
> function independent of t. However, I feel that there should be
>
> 1. A better way of getting the interpolation function from Integrate
> without the built in t
>
> 2.A method of using NIntegrate rather than Integrate which should be
> able to use the information that the function is interpolated
>
> 3. A method that would work on a product of interpolating functions
>
> Thanks
>
> Hugh
>
> data1 = Table[{x, t, Exp[(-x)*t]}, {x, 0, 1, 0.1}, {t, 0, 1, 0.1}];
>
> data2 = Table[{x, t, Sin[x*t]}, {x, 0, 1, 0.1}, {t, 0, 1, 0.1}];
>
> f1 = Interpolation[Flatten[data1, 1]]
>
> f2 = Interpolation[Flatten[data2, 1]]
>
> g1 = Integrate[f1[x, t], {x, 0, 1}]

(1)  Use g2new = Head[g1].  This strips off the 't' and can be used as
a pure function.

(2,3) If you aren't integrating a pure InterpolatingFunction (e.g., if
you even multiply it by a polynomial) this
method doesn't work.   For a quick black box, try
FunctionInterpolation
g3new = FunctionInterpolation[NIntegrate[f1[x, t]*f2[x, t], {x, 0,
1}], {t, 0, 1}]
Because of all the different ways one can imagine constructing
expressions involving interpolating functions
(F[D[f2,{x,5}], Exp[Sinh[f1[x-4]], ....]) I would not look too
hard for a completely general code.  But if
there's a limited set of operations you need to perform
involving simply-weighted products of low-order
interpolations, you could hardcode them in using the explicit
form of the interpolating polynomials.  That
too is more trouble than it is worth.

My two cents.

```

• Prev by Date: estimating parameters in a differential equation with mathematica 6
• Next by Date: Re: Please Help with Sums with the same StandardForm but
• Previous by thread: Re: Integrating Interpolation functions
• Next by thread: Re: Integrating Interpolation functions