Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #5138
| From | Barrie Stokes <Barrie.Stokes@newcastle.edu.au> |
|---|---|
| Newsgroups | comp.soft-sys.math.mathematica |
| Subject | Re: Calculus and InterpolatingFunction |
| Date | 2011-09-22 11:31 +0000 |
| Organization | Steven M. Christensen and Associates, Inc and MathTensor, Inc. |
| Message-ID | <j5f69k$q87$1@smc.vnet.net> (permalink) |
| References | <201109210933.FAA13140@smc.vnet.net> |
Hi Stranger
Unless you're wedded to Integrate[...], NIntegrate[...] works in this case:
data = RandomReal[#]*2 & /@ Range[1, 10]
f = Interpolation[data]
Plot[f[x], {x, 1, 10}]
int1 = Integrate[f[x], {x, 1, 10}]
ClearAll[ ff ]
ff[x_] := f[x] + 1
{f[4], ff[4]}
Plot[ff[x], {x, 1, 10}]
int2 = NIntegrate[ff[x], {x, 1, 10}]
int2 - int1
Cheers
Barrie
>>> On 21/09/2011 at 7:33 pm, in message <201109210933.FAA13140@smc.vnet.net>, Just
A Stranger <forpeopleidontknow@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 ?
Back to comp.soft-sys.math.mathematica | Previous | Next | Find similar | Unroll thread
Re: Calculus and InterpolatingFunction Barrie Stokes <Barrie.Stokes@newcastle.edu.au> - 2011-09-22 11:31 +0000
csiph-web