Re: InterpolatingFunction and NIntegrate
- To: mathgroup at smc.vnet.net
- Subject: [mg108459] Re: InterpolatingFunction and NIntegrate
- From: Bob Hanlon <hanlonr at cox.net>
- Date: Fri, 19 Mar 2010 02:45:44 -0500 (EST)
timevector = Range[0, 1, 0.1]; discretesolution = RandomReal[{0, 1}, {11, 2}]; spline = Interpolation[Thread[ {timevector, discretesolution}], InterpolationOrder -> 1]; f[t_?NumericQ] := Norm[spline[t] + {2, 2}] NIntegrate[f[t], {t, 0, 1}, MinRecursion -> 3] 3.61654 Bob Hanlon ---- Benjamin Hell <hell at exoneon.de> wrote: ============= Hi, sorry for posting a similar question to my last one on such after such little time. This is due to the problem being a little bit different now. Last time I tried using Integrate, this time I am going with NIntegrate. The problem now is that using NIntegrate with the InterpolatingFunction works, but when for example adding a vector I get an NIntegrate::inum error, which does not make sense to me. Here is an example of what I mean: /timevector = Table[i*0.1, {i, 0, 10}]; discretesolution = Table[{RandomReal[], RandomReal[]}, {i, 0, 10}]; spline = Interpolation[Thread[{timevector, discretesolution}], InterpolationOrder -> 1]/ This does work: /NIntegrate[Norm[spline[t]], {t, 0, 1}]/ But here I get the NIntegrate::inum error, which says that at a certain point t the value of Norm[spline[t] + {2, 2}] is not numerical: NIntegrate[Norm[spline[t] + {2, 2}], {t, 0, 1}] The error does not make sense to me. First I figured I should use Evaluate, because NIntegrate has the HoldAll attribute, but as Norm[spline[t] + {2, 2}] does not seem to be affected by HoldAll this does not make any difference. So why is this not working? Thanks again, Benjamin