MathGroup Archive 2011

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

Search the Archive

Re: Calculus and InterpolatingFunction

  • To: mathgroup at smc.vnet.net
  • Subject: [mg121700] Re: Calculus and InterpolatingFunction
  • From: Murray Eisenberg <murray at math.umass.edu>
  • Date: Mon, 26 Sep 2011 04:15:54 -0400 (EDT)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • References: <201109221125.HAA26698@smc.vnet.net> <201109250233.WAA26134@smc.vnet.net>
  • Reply-to: murray at math.umass.edu

But why must NIntegrate be called by Integrate here? Is it merely the 
fact that the interpolating function has floating-point numbers in it?

If I have what I would reasonably call an "explicit" function f, given 
by some formula, and if it's possible to find a (piecewise) 
antiderivative exactly, then I would expect Integrate to work directly 
with that function -- even in finding an indefinite integral 
Integrate[f[x],x].

On 9/24/11 10:33 PM, DrMajorBob wrote:
> Interpolation does give "an explicit function" in any sense of "explicit"
> that I can think of. The problem you ran into is (IMHO) a "bug" or
> "feature lack" in Integrate. It should call NIntegrate when necessary, but
> it did not, in the OP's example.
>
> Bobby
>
> On Fri, 23 Sep 2011 02:45:03 -0500, Murray Eisenberg
> <murray at math.umass.edu>  wrote:
>
>> Two remaining problems:
>>
>> (1) The Documentation Center page for Interpolation says, "Interpolation
>> returns an InterpolatingFunction object, which can be used like any
>> other pure function."
>>
>>      Manifestly that is not the case. Thus the following, for a pure
>> function, _does_ work:
>>
>>     f = #^2&
>>     Integrate[f[x] + 1, {x, 1, 10}]
>>
>> (2) While the solutions you proposed both work, the latter using Map
>> would be problematic for integrands involving the InterpolatingFunction
>> in more complicated ways, e.g.:
>>
>>      f = Interpolation[data];
>>      Integrate[#, {x, 1, 10}]&  /@ (Sin[f[x]])
>> 0.576208
>>      NIntegrate[Sin[f[x]], {x, 1, 10}]
>> 0.607007
>>
>> Is there some way to obtain an explicit function from an
>> InterpolatingFunction object?
>>
>>
>> On 9/22/11 7:25 AM, Bob Hanlon wrote:
>>> data = RandomReal[#]*2&   /@ Range[1, 10];
>>>
>>> f = Interpolation[data];
>>>
>>> Integrate[f[x], {x, 1, 10}]
>>>
>>> 52.9041
>>>
>>> Use NIntegrate
>>>
>>> NIntegrate[f[x] + 1, {x, 1, 10}]
>>>
>>> 61.9041
>>>
>>> Or Map over the expression
>>>
>>> Integrate[#, {x, 1, 10}]&   /@ (f[x] + 1)
>>>
>>> 61.9041
>>>
>>>
>>> Bob Hanlon
>>>
>>> ---- Just A Stranger<forpeopleidontknow at gmail.com>   wrote:
>>>
>>> =============
>>> I'm trying to get a definite integral for an InterpolatingFunction. It
>>> works
>>> if it is the function by itself, but not for some reason arithmetically
>>> combining the InterpolatingFunction with another function makes it not
>>> return a value. e.g.
>>>
>>>
>>> In[1]:=
>>> data = RandomReal[#]*2&   /@ Range[1, 10];
>>> f = Interpolation[data];
>>>
>>>>    Integrate[f[x], {x, 1, 10}]
>>> Out[1]:=40.098
>>>
>>> So far so good. But just a little bit of arithmetic in the integral and
>>> it
>>> doesn't work anymore:
>>> In[2]:=
>>> Integrate[f[x]+1, {x, 1, 10}]
>>> Out[2]:=
>>> Integrate[Plus[1, InterpolatingFunction[][x]], List[x, 1, 10]]
>>>
>>> (That last answer was actually the output with  //FullForm applied)
>>> Why won't it give me a numerical evaluation? Is there anyway to make a
>>> continuous function from data that will seemlessly work with Integrate?
>>> I'm
>>> thinking of constructing a piecwise function using Fit, Piecwise, and a
>>> Table for the arguments to Piecewise. But I would think  Interpolation
>>> might
>>> have worked and been easier. I want to figure out if I am I doing
>>> something
>>> wrong with Interpolation before I start trying to tackle a slightly more
>>> complicated piecewise defined function ?
>>>
>>>
>>
>
>

-- 
Murray Eisenberg                     murray at math.umass.edu
Mathematics & Statistics Dept.
Lederle Graduate Research Tower      phone 413 549-1020 (H)
University of Massachusetts                413 545-2859 (W)
710 North Pleasant Street            fax   413 545-1801
Amherst, MA 01003-9305




  • Prev by Date: Re: problem opening mathematica
  • Next by Date: Re: Calculus and InterpolatingFunction
  • Previous by thread: Re: Calculus and InterpolatingFunction
  • Next by thread: Re: Calculus and InterpolatingFunction