Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2004
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2004

[Date Index] [Thread Index] [Author Index]

Search the Archive

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


  • Prev by Date: Re: simply problem (not for me) about axes scale
  • Next by Date: Re: Mathematica slows down
  • Previous by thread: Re: NIntegrate a list
  • Next by thread: Re: NIntegrate a list