Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.math.mathematica

Topic: question about NIntegrate
Replies: 1   Last Post: Nov 23, 2012 3:31 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View  
Bob Hanlon

Posts: 906
Registered: 10/29/11
Re: question about NIntegrate
Posted: Nov 23, 2012 3:31 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

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





Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.