Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #12431

Re: question about NIntegrate

From Bill Rowe <readnews@sbcglobal.net>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: question about NIntegrate
Date 2012-11-23 08:34 +0000
Message-ID <k8ncfj$di5$1@smc.vnet.net> (permalink)
Organization Time-Warner Telecom

Show all headers | View raw


On 11/22/12 at 4:33 AM, dsmirnov90@gmail.com 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} =
>{-0.984085}"

>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

Back to comp.soft-sys.math.mathematica | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

Re: question about NIntegrate Bill Rowe <readnews@sbcglobal.net> - 2012-11-23 08:34 +0000
  Re: question about NIntegrate dsmirnov90@gmail.com - 2012-11-24 07:28 +0000

csiph-web