       Re: Using InterpolatingFunction from NDSolve

• To: mathgroup at smc.vnet.net
• Subject: [mg58565] Re: Using InterpolatingFunction from NDSolve
• From: "Kevin J. McCann" <kjm at KevinMcCann.com>
• Date: Fri, 8 Jul 2005 00:45:56 -0400 (EDT)
• References: <daitir\$su4\$1@smc.vnet.net>
• Sender: owner-wri-mathgroup at wolfram.com

```I added a couple of definitions at the end, but most importantly, I used
NIntegrate rather than Integrate. The latter fails in its attempt to
find an exact expression for the integral.

Kevin

\!\(nds = NDSolve[{
D[u\ [t, x], {t,
1}] == D[u\ [t, x], {x, 2}] + u[t, x]\^2 -
u[t, x], u[0, x] == Sin[x], u[t, 0] == 0, u[t, 2\
Ï?] == 0}, u[t, x], {t, 0, 1}, {x, 0, 2\ Ï?}]\n
Plot3D[Evaluate[u[t, x] /. nds[\([\)\(1\)\(]\)]], {t, 0, 1}, {x,
0, 2\ Ï?}]\n
Plot3D[Evaluate[Integrate[\((u[t, x] /. nds[\([\)\(1\)\(]\)])\), {t,
0, s}]], {s, 0, 1}, {x, 0, 2  Ï?}]\n
Plot3D[Evaluate[D[u[t,
x] /. nds[\([\)\(1\)\(]\)], {x, 2}]], {t, 0, 1}, {x, 0, 2  Ï?}]\n
Integrate[D[u[t, x] /. nds[\([\)\(1\)\(]\)], {x, 2}], {t, 0, s}]\n
Plot3D[Evaluate[Integrate[D[u[t, x] /. nds[\([\)\(1\)\(]\)], {
x, 2}], {t, 0, s}]], {s, 0, 1}, {x, 0, 2
Ï?}]\n\[IndentingNewLine]
u[t, x]^2 /. nds[\(\)]\n
Plot3D[Evaluate[u[t, x]^2 /. nds[\([\)\(1\)\(]\)]], {t,
0, 1}, {x, 0, 2\ Ï?}, AxesLabel -> {t, x, u[t, x]}]\n
u2[t_, x_] = u[t, x]^2 /. nds[\(\)]\n
f[x_, s_] := NIntegrate[u2[t, x], {t, 0, s}]\n
Plot3D[f[x, s], {s, 0, 1}, {x, 0, 2  Ï?}]\n
f[1,  .5]\)

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: