MathGroup Archive 2008

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Calculations with Interpolating Functions

  • To: mathgroup at smc.vnet.net
  • Subject: [mg88524] Re: Calculations with Interpolating Functions
  • From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
  • Date: Wed, 7 May 2008 07:09:20 -0400 (EDT)
  • Organization: The Open University, Milton Keynes, UK
  • References: <fvpcqn$mhn$1@smc.vnet.net>

� wrote:

> I obtain an Interpolating function as a solution of a differential equation
> with the command NDSolve, lets call it =93solution=94, which gives x(t). Next I
> want to use this solution for further calculations. With the commands
> =93result=Evaluate[x(t)/. First[solution]]=94 or =93result=  x(t)/.solution,
> {t,0,tmax}=94 I do the plot x(t) without any problems. Now, with version 5.2 I
> manage to integrate x(t) or linear functions of it.  But when I try to
> integrate non linear functions of x(t), like x(t)^2 or Sin[x(t)] (which is
> what I want),  Mathematica is unable to give a numerical result, all I get
> is an integral saying that there is an InterpolatingFunction in the
> integrand. With Mathematica 6 the linear integration does not work either.

You message is difficult to read, but have you tried *NIntegrate[]*? For 
instance,

sol =
  NDSolve[{y'[x] == y[x] Cos[x + y[x]], y[0] == 1}, y, {x, 0, 30}]

y[x_] = y[x] /. sol[[1]]

Plot[y[x], {x, 0, 30}]

Integrate[y[x], {x, 5, 10}]

NIntegrate[y[x]^2, {x, 5, 10}]


{{y->InterpolatingFunction[{{0.,30.}},<>]}}

InterpolatingFunction[{{0.,30.}},<>][x]

1.13807

0.327983


Regards,
-- Jean-Marc


  • Prev by Date: Re: Calculations with Interpolating Functions
  • Next by Date: Re: Request for Collective Wisdom...
  • Previous by thread: Re: Calculations with Interpolating Functions
  • Next by thread: Re: orthonormal eigenvectors]