Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2007
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2007

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

Search the Archive

Re: numeric integration

  • To: mathgroup at smc.vnet.net
  • Subject: [mg81161] Re: [mg81129] numeric integration
  • From: DrMajorBob <drmajorbob at bigfoot.com>
  • Date: Fri, 14 Sep 2007 03:38:33 -0400 (EDT)
  • References: <3216400.1189687710734.JavaMail.root@m35>
  • Reply-to: drmajorbob at bigfoot.com

It works here just fine, although my value f[0.1] doesn't match yours:

f = NIntegrate[Sin[x + #], {x, 0, 1}] &;
f[0.1]

0.541408

NIntegrate[f[x], {x, 0, 0.1}]

0.0708073

However... there's a subtlety, since that's the wrong integral unless you  
wanted THIS double integral:

Integrate[Sin[x + x], {x, 0, 1}] // N

0.0708073

You probably wanted this one:

Integrate[Sin[x + t], {t, 0, 0.1}, {x, 0, 1}]

0.050097

Quiet@NIntegrate[f[t], {t, 0, 0.1}]

(NIntegrate::"inumr" errors suppressed by Quiet)

0.050097

Using t as the parameter is different from using x as the parameter,  
because of the way you defined f. That can be eliminated, along with the 
NIntegrate::"inumr" errors, by defining f this way:

Clear[x, f]
f[t_?NumericQ] := NIntegrate[Sin[x + t], {x, 0, 1}]
f[0.1]

0.541408

NIntegrate[f[x], {x, 0, 0.1}]

0.050097

NIntegrate[f[t], {t, 0, 0.1}]

0.050097

That's much nicer anyway.

Bobby

On Thu, 13 Sep 2007 05:29:44 -0500, C. Seja <p5secr2 at uni-jena.de> wrote:

> 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
>
>
>
>



-- 

DrMajorBob at bigfoot.com


  • Prev by Date: Previous version features for 2-D and 3-D plots
  • Next by Date: Re: Optimization with symbolic paramters
  • Previous by thread: Re: Re: numeric integration
  • Next by thread: Cole-cole Plot