Re: NIntegrate a list
- To: mathgroup at smc.vnet.net
- Subject: [mg52986] Re: NIntegrate a list
- From: Bill Rowe <readnewsciv at earthlink.net>
- Date: Sat, 18 Dec 2004 04:00:32 -0500 (EST)
- Sender: owner-wri-mathgroup at wolfram.com
On 12/17/04 at 5:19 AM, aaronfude at yahoo.com (Aaron Fude) wrote:
>I can Integrate this, but apparently not NIntegrate this:
>Integrate[x*Sin[x]*{1, 2}, {theta, -Pi, Pi}]
>but not
>NIntegrate[x*Sin[x]*{1, 2}, {theta, -Pi, Pi}]
>Is there a good way to do this (w/o writing loops)?
Did you mean to write
Integrate[x*Sin[x]*{1, 2}, {x, -Pi, Pi}] instead of what you did write?
Since Integrate returns a symbolic answer, it is reasonable to expect Integrate to work. But NIntegrate is a numerical integration routine. As you wrote it, there is no way for Mathematica to assign a number to x and the numerical integration fails.
There is also a second issue in that NIntegrate does not have the attribute Listable. But this can be addressed using Map, i.e.
NIntegrate[#1, {x, -Pi, Pi}]&/@ (x Sin[x] {1, 2})
{6.283185307179588, 12.566370614359176}
--
To reply via email subtract one hundred and four