Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #5107 > unrolled thread
| Started by | Just A Stranger <forpeopleidontknow@gmail.com> |
|---|---|
| First post | 2011-09-21 09:36 +0000 |
| Last post | 2011-09-22 11:36 +0000 |
| Articles | 3 — 3 participants |
Back to article view | Back to comp.soft-sys.math.mathematica
Calculus and InterpolatingFunction Just A Stranger <forpeopleidontknow@gmail.com> - 2011-09-21 09:36 +0000
Re: Calculus and InterpolatingFunction "Oleksandr Rasputinov" <oleksandr_rasputinov@hmamail.com> - 2011-09-22 11:28 +0000
Re: Calculus and InterpolatingFunction "Kevin J. McCann" <Kevin.McCann@umbc.edu> - 2011-09-22 11:36 +0000
| From | Just A Stranger <forpeopleidontknow@gmail.com> |
|---|---|
| Date | 2011-09-21 09:36 +0000 |
| Subject | Calculus and InterpolatingFunction |
| Message-ID | <j5cb71$cvl$1@smc.vnet.net> |
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 ?
[toc] | [next] | [standalone]
| From | "Oleksandr Rasputinov" <oleksandr_rasputinov@hmamail.com> |
|---|---|
| Date | 2011-09-22 11:28 +0000 |
| Message-ID | <j5f65p$q73$1@smc.vnet.net> |
| In reply to | #5107 |
On Wed, 21 Sep 2011 10:36:33 +0100, 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 ?
This is slightly puzzling, though more in respect of why the first example
worked than why the second one didn't. If it's numerical integration you
wish to perform, NIntegrate is surely preferable to Integrate, and works
for both cases given above:
In[3] := NIntegrate[f[x], {x, 1, 10}]
Out[3] = 32.2367
In[4] := NIntegrate[f[x] + 1, {x, 1, 10}]
Out[4] = 41.2367
[toc] | [prev] | [next] | [standalone]
| From | "Kevin J. McCann" <Kevin.McCann@umbc.edu> |
|---|---|
| Date | 2011-09-22 11:36 +0000 |
| Message-ID | <j5f6k4$qas$1@smc.vnet.net> |
| In reply to | #5107 |
You need to use NIntegrate.
Kevin
On 9/21/2011 5:36 AM, Just A Stranger 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 ?
[toc] | [prev] | [standalone]
Back to top | Article view | comp.soft-sys.math.mathematica
csiph-web