MathGroup Archive 2005

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

Search the Archive

Re: nintegrate vs nintegrateinterpolatingfunction vs integrate

  • To: mathgroup at
  • Subject: [mg55614] Re: nintegrate vs nintegrateinterpolatingfunction vs integrate
  • From: "Carl K. Woll" <carlw at>
  • Date: Thu, 31 Mar 2005 01:24:13 -0500 (EST)
  • Organization: University of Washington
  • References: <d2doim$lkr$>
  • Sender: owner-wri-mathgroup at

"Chris Chiasson" <chris.chiasson at> wrote in message 
news:d2doim$lkr$1 at
> Dear MathGroup,
> I'm trying to get distance versus time functions from lists of time
> and velocity data. I've done this before, but with the data sets I am
> using now, I keep running into complex number errors. The only working
> implementation I found is to use nintegrate (& functioninterpolation),
> but it is much slower than nintegrateinterpolatingfunction or
> integrate (& functioninterpolation), at least for working on
> interpolated data:


>  MapThread[
>    Block[{t,arbittime,dist},
>        dist[arbittime_?NumericQ]:=NIntegrate[#1[t],{t,0,arbittime}];
>        FunctionInterpolation[
>          dist[t],{t,Evaluate[Sequence@@#2[[1]]]}]]&,{tracedatafuncs,
>      outerlimits}]


I didn't test your code, so I may be missing something here, but it appears 
to me that the above is the section where you are having trouble. Instead of 
defining dist as an integral and applying FunctionInterpolation to it, have 
you tried using NDSolve on the velocity interpolating functions? For 
example, suppose v is your velocity interpolating function. Then, note that 
the domain of v is given by it's first argument. If we assume that the 
distance traveled is 0 at the beginning of the domain of v, then the 
corresponding distance interpolating function d is given by

d = f /. First@NDSolve[{f'[t] == v[t], f[v[[1, 1, 1]]] == 0}, f, 
Prepend[v[[1, 1]], t]]

If you have a list of velocity interpolating functions vlist, then

dlist = (f /. 
First@NDSolve[{f'[t]==#[t],f[#[[1,1,1]]]==0},f,Prepend[#[[1,1]],t]])& /@ 

ought to produce the list you desire. It also possible to make use of the 
domain information when plotting, such as


Carl Woll 

  • Prev by Date: Re: Need a functional process for this.
  • Next by Date: Re: Re: Simplifying ArcTan
  • Previous by thread: nintegrate vs nintegrateinterpolatingfunction vs integrate
  • Next by thread: Mathematica hangs when solving sys. of equations w/ certain parameters