Re: Using InterpolatingFunction from NDSolve
- To: mathgroup at smc.vnet.net
- Subject: [mg58573] Re: Using InterpolatingFunction from NDSolve
- From: dh <dh at metrohm.ch>
- Date: Fri, 8 Jul 2005 00:46:03 -0400 (EDT)
- References: <daitir$su4$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Hi Tamás,
It seems that "InterpolatingFunction" is not very well integrated in the
"Integrate" function. Integrate can not even handle very simple
functions of "InterpolatingFunction". Example:
We define an interpolating function (1 dimensionla for simplicity):
f = Interpolation[{{0, 0}, {1, 1}, {2, 2}, {3, 3}}]
The following works
Integrate[f[x],{x,0,3}]]
It also work if f is put inside a Plus function:
Integrate[ Plus[f[x],f[x]] ,{x,0,3}]]
however,if we change the Plus function to Times function, Integrate can
no more do it:
Integrate[ Times[f[x],f[x]] ,{x,0,3}]]
Now what can we do? A work around is to re-interpolate: e.g.
to get the f^2 we coud write:
ff= FunctionInterpolation[f[x]^2, {x, 0, 3}]
This function will then integrate:
Integrate[ff[x],{x,0,3}]]
for your case where you use replacement: u[t, x]^2 /. nds[[1]], note
that "FunctionInterpolation" has the Attribute "HoldAll". Therefore,
either you replace outside "FunctionInterpolation" or you wrap the
replacement inside "Evaluate".
Tamás wrote:
> I solved a PDE with NDSolve in Mathematica 5.1. I could plot,
> differentiate and integrate the obtained InterpolatingFunction object,
> the result being a similar object. I was able to integrate the 2nd
> derivative of it. What I need is to integrate the square of the
> obtained InterpolatingFunction object (the square itself does not
> simplify to such an object).
> You can see the details on my homepage:
> http://www.math.bme.hu/~tladics/nds.nb
>
> Every suggestions are welcome!
>
> Thank you,
> Tamás
>