Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #12431 > unrolled thread
| Started by | Bill Rowe <readnews@sbcglobal.net> |
|---|---|
| First post | 2012-11-23 08:34 +0000 |
| Last post | 2012-11-24 07:28 +0000 |
| Articles | 2 — 2 participants |
Back to article view | Back to comp.soft-sys.math.mathematica
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
| From | Bill Rowe <readnews@sbcglobal.net> |
|---|---|
| Date | 2012-11-23 08:34 +0000 |
| Subject | Re: question about NIntegrate |
| Message-ID | <k8ncfj$di5$1@smc.vnet.net> |
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
[toc] | [next] | [standalone]
| From | dsmirnov90@gmail.com |
|---|---|
| Date | 2012-11-24 07:28 +0000 |
| Message-ID | <k8psv8$irr$1@smc.vnet.net> |
| In reply to | #12431 |
Thanks for your answers, but actually the situation is a bit more complicated. In fact my function is not a square, my real function operates with quite huge matrices, and returns an array of about 20 numbers. Such function can be calculated only numerically. As a final result I want to get a Plot of all this 20 output numbers as a function of one input parameter. So the tips to calculate function analytically or to return a number rather than a list wouldn't for my real function. Any way thanks for all your suggestions once more!
[toc] | [prev] | [standalone]
Back to top | Article view | comp.soft-sys.math.mathematica
csiph-web