Re: Integrating Interpolation functions
- To: mathgroup at smc.vnet.net
- Subject: [mg89057] Re: Integrating Interpolation functions
- From: dh <dh at metrohm.ch>
- Date: Sat, 24 May 2008 03:58:05 -0400 (EDT)
- References: <g15qk7$p9t$1@smc.vnet.net>
Hi Hugh,
see below, Daniel
Hugh Goyder 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
you put the "t" in yourself. If you want a pure function:
g1=Evaluate[Integrate[f1[x,#] ,{x,0,1}]]&
>
> 2.A method of using NIntegrate rather than Integrate which should be
> able to use the information that the function is interpolated
the only guys who can do something about this are at Wolfram
>
> 3. A method that would work on a product of interpolating functions
unfortunately, Mathematica can not Integrate functions of
InterpolatingFunctions. But a work around is to re-interpolate like:
f3=FunctionInterpolation[f1[x,t]f2[x,t],{x,0,1},{t,0,1}]
f3 can now be integrated
>
> 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}]
>
> g2[tt_] := Evaluate[g1 /. t -> tt]
>
> Plot[g2[t], {t, 0, 1}]
>
> g3 = Integrate[f1[x, t]*f2[x, t], {x, 0, 1}]
>
--
Daniel Huber
Metrohm Ltd.
Oberdorfstr. 68
CH-9100 Herisau
Tel. +41 71 353 8585, Fax +41 71 353 8907
E-Mail:<mailto:dh at metrohm.com>
Internet:<http://www.metrohm.com>