MathGroup Archive 2012

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

Search the Archive

Re: question about NIntegrate

  • To: mathgroup at
  • Subject: [mg128743] Re: question about NIntegrate
  • From: Bill Rowe <readnews at>
  • Date: Fri, 23 Nov 2012 03:25:13 -0500 (EST)
  • Delivered-to:
  • Delivered-to:
  • Delivered-to:
  • Delivered-to:

On 11/22/12 at 4:33 AM, dsmirnov90 at wrote:

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

>Strangely, the following code works fine:

>NIntegrate[f[1], {x, -1, 1}]

>giving the result {2.}

>What am I doing wrong?

Is there a reason you have defined f to return a list rather
than a number? This works:

In[7]:= Clear[f]
f[a_?NumericQ] := a^2
NIntegrate[f[x], {x, -1, 1}]

Out[9]= 0.666667

  • Prev by Date: Re: Novice problem in mathematica syntax : Function of a function
  • Next by Date: Is there way to use something like Assuming with the function SIgn?
  • Previous by thread: Re: question about NIntegrate
  • Next by thread: Re: question about NIntegrate