[Date Index]
[Thread Index]
[Author Index]
Re: Re: numeric integration
*To*: mathgroup at smc.vnet.net
*Subject*: [mg81193] Re: [mg81181] Re: numeric integration
*From*: Vivek Joshi <vivekj at wolfram.com>
*Date*: Sat, 15 Sep 2007 04:10:15 -0400 (EDT)
*References*: <fcb40h$fm3$1@smc.vnet.net> <200709140748.DAA25892@smc.vnet.net>
Alternatively, If you want to make your previous definitions work,
You could simple change variable x to t for the second integration,
f = NIntegrate[Sin[x + #], {x, 0, 1}] &;
f[0.1]
0.541408
Quiet@NIntegrate[f[t], {t, 0, 0.1}]
0.050097
-Vivek
On Sep 14, 2007, at 2:48 AM, C. Seja wrote:
found two simple solutions:
1) writing
f[y_?NumericQ] := NIntegrate[Sin[x + y], {x, 0, 1}]
instead of
f = NIntegrate[Sin[x + #], {x, 0, 1}] &
2) writing
NIntegrateF[f, {0, 0.1}]
instead of
NIntegrate[f[x], {x, 0, 0.1}]
with the definition
NIntegrateF[f_ , a_] :=
Module[{F},
F[x_?NumericQ] = f[x];
NIntegrate[F[x], {x, a[[1]], a[[2]]}]
];
c. seja
> Hi,
>
> 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.
> 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)?
>
> Regards
>
> C. Seja
>
>
>
Vivek Joshi
217-372-3454
vivekj at wolfram.com
Prev by Date:
**Re: rationalize numerator of quotient**
Next by Date:
**Re: HELP!**
Previous by thread:
**Re: numeric integration**
Next by thread:
**Re: numeric integration**
| |