Re: numeric integration
- To: mathgroup at smc.vnet.net
- Subject: [mg81158] Re: numeric integration
- From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
- Date: Fri, 14 Sep 2007 03:37:00 -0400 (EDT)
- Organization: The Open University, Milton Keynes, UK
- References: <fcb40h$fm3$1@smc.vnet.net>
C. Seja wrote:
> I'd like to intergate a function f with NIntegrate:
> NIntegrate[f[x], {x, 0, 0.1}]
>
> But this doesn't work if, i.e.
>
> f = NIntegrate[Sin[x + #], {x, 0, 1}] &
>
> It will give a wrong result (0.7 instead of 0.05). Why? I mean, I can
> evaluate f at any point without problems, i.e. f[0.1] gives 0.37.
In[1]:= f = NIntegrate[Sin[x + #], {x, 0, 1}] &;
f[0.1]
Out[2]= 0.541408
> So why doesn't
>
> NIntegrate[f[x], {x, 0, 0.1}]
>
> work? It doesn't even give a warning! So, is there a proper way to do this
> (without using one two-dimensional NIntegrate)?
In[1]:= f[y_?NumericQ] := NIntegrate[Sin[x + y], {x, 0, 1}]
In[2]:= f[0.1]
Out[2]= 0.541408
In[3]:= NIntegrate[f[y], {y, 0, 0.1}]
Out[3]= 0.050097
Regards,
--
Jean-Marc