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


Groups > comp.soft-sys.math.mathematica > #12416 > unrolled thread

question about NIntegrate

Started bydsmirnov90@gmail.com
First post2012-11-22 09:33 +0000
Last post2012-11-23 08:29 +0000
Articles 2 — 2 participants

Back to article view | Back to comp.soft-sys.math.mathematica


Contents

  question about NIntegrate dsmirnov90@gmail.com - 2012-11-22 09:33 +0000
    Re: question about NIntegrate "Nasser M. Abbasi" <nma@12000.org> - 2012-11-23 08:29 +0000

#12416 — question about NIntegrate

Fromdsmirnov90@gmail.com
Date2012-11-22 09:33 +0000
Subjectquestion about NIntegrate
Message-ID<k8krhj$83k$1@smc.vnet.net>
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

[toc] | [next] | [standalone]


#12422

From"Nasser M. Abbasi" <nma@12000.org>
Date2012-11-23 08:29 +0000
Message-ID<k8nc51$dft$1@smc.vnet.net>
In reply to#12416
On 11/22/2012 3:33 AM, dsmirnov90@gmail.com wrote:
> Hi,

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

do not make the result of f a List. i.e. remove the {}

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

Out[50]= 0.666667

--Nasser

[toc] | [prev] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web