MathGroup Archive 2005

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

Search the Archive

Re: Do loop is faulty

  • To: mathgroup at smc.vnet.net
  • Subject: [mg55393] Re: Do loop is faulty
  • From: Bill Rowe <readnewsciv at earthlink.net>
  • Date: Mon, 21 Mar 2005 03:02:00 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

On 3/20/05 at 4:12 AM, andreajagger_8 at hotmail.com (dumb_founded)
wrote:

>I define array a[i] and array b[i] of dimension 10.  Then I go
>through the following Do loop, or try to, that is.

In Mathematica a[i] is not an array element. The syntax for selecting an array element would be a[[i]] for a one dimensionsal array.

>Array[c,10]; Do[c[i]=NIntegrate[a[i]*x*Sin[b[i]*x],{x,0,b[i]}]

Array[c,10] does not create an array named c with 10 elements

>I get numerous error messages saying that b[i] is not a valid limit
>of integration.

Right it isn't a valid limit in Mathematica syntax. Valid Mathematica syntax that does what it appears you are trying to do would be

c = Table[NIntegrate[a[[k]] x Sin[b[[k]] x],{x, 0, b[[k]]}], {k,10}]

This assumes both a and b exist and are one dimensionsal lists with 10 elements

>This is sheer headache.  I will never try to use Mathematica for
>numerical analysis again.

Until you learn correct Mathematica syntax, you will continue to have problems. There is no universal syntax for software to do numerical analysis. Consequently, you cannot expect Mathematica syntax to be the same as syntax for other software you may have used. Nor can you escape the need to learn correct syntax by using something other than Mathematica.
--
To reply via email subtract one hundred and four


  • Prev by Date: Re: Do loop is faulty
  • Next by Date: Re: plotting weighted graphs
  • Previous by thread: Re: Do loop is faulty
  • Next by thread: Re: Do loop is faulty