MathGroup Archive 2012

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

Search the Archive

Re: question about NIntegrate

  • To: mathgroup at smc.vnet.net
  • Subject: [mg128757] Re: question about NIntegrate
  • From: Bob Hanlon <hanlonr357 at gmail.com>
  • Date: Fri, 23 Nov 2012 03:29:54 -0500 (EST)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • Delivered-to: l-mathgroup@wolfram.com
  • Delivered-to: mathgroup-newout@smc.vnet.net
  • Delivered-to: mathgroup-newsend@smc.vnet.net
  • References: <20121122093310.65AA568AD@smc.vnet.net>

Try it without the NumericQ

Clear[f]
f[a_] := {a^2};
NIntegrate[f[x], {x, -1, 1}]

{0.666667}

NIntegrate[#, {x, -1, 1}] & /@ f[x]

{0.666667}

Integrate[f[x], {x, -1, 1}]

{2/3}


Bob Hanlon


On Thu, Nov 22, 2012 at 4:33 AM,  <dsmirnov90 at gmail.com> wrote:
> Hi,
>
> I want to use function NIntegrate to integrate a rather complicated function which should be calculated numerically and returns a Table. However, when I write something of the kind:
>
> Clear[f]
> f[(a_)?NumericQ] := {a^2};
> NIntegrate[f[x], {x, -1, 1}]
>
> I get an error: "Integrand f[x] is not numerical at {x} = {-0.984085}"
>
> Strangely, the following code works fine:
>
> NIntegrate[f[1], {x, -1, 1}]
>
> giving the result {2.}
>
> What am I doing wrong?
>
> Dmitry
>



  • Prev by Date: Re: simultaneous equation
  • Next by Date: Re: correlation function
  • Previous by thread: question about NIntegrate
  • Next by thread: Re: question about NIntegrate