MathGroup Archive 2005

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

Search the Archive

Re: Do loop is faulty

  • To: mathgroup at smc.vnet.net
  • Subject: [mg55415] Re: Do loop is faulty
  • From: Paul Abbott <paul at physics.uwa.edu.au>
  • Date: Tue, 22 Mar 2005 03:51:06 -0500 (EST)
  • Organization: The University of Western Australia
  • References: <d1jfsj$sa4$1@smc.vnet.net> <d1lvsb$7ub$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

In article <d1lvsb$7ub$1 at smc.vnet.net>,
 "dumb_founded" <andreajagger_8 at hotmail.com> wrote:

> Oops, sorry, I mistyped the code.  It should read:
> 
> Array[c,10];
> Do[c[i]=NIntegrate[a[i]*x*Sin[b[i]*x],{x,0,b[i]}],{i,1,10}]

Others have answered your original question -- and you did mention that 
you were trying to use Mathematica for numerical analysis. However, you 
should realise that Mathematica can compute the required integrals in 
closed form for arbitrary a and b:

  int[a_,b_] = Integrate[a x Sin[b x], {x, 0, b}]

so there is no need to use NIntegrate.


> 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.
> >
> >
> > Array[c,10];
> > Do[c[i]=NIntegrate[a[i]*x*Sin[b[i]*x],{x,0,b[i]}]
> >
> > I get numerous error messages saying that b[i] is not a valid limit
> of
> > integration.
> >
> > This is sheer headache.  I will never try to use Mathematica for
> > numerical analysis again.
> >
> > All your efforts on this matter are sincerely appreciated.
> > 
> > 
> > 
> > Thanks
>

-- 
Paul Abbott                                   Phone: +61 8 6488 2734
School of Physics, M013                         Fax: +61 8 6488 1014
The University of Western Australia      (CRICOS Provider No 00126G)         
35 Stirling Highway
Crawley WA 6009                      mailto:paul at physics.uwa.edu.au 
AUSTRALIA                            http://physics.uwa.edu.au/~paul


  • Prev by Date: Re: Restriction on the domain of Plot3D
  • Next by Date: Re: Restriction on the domain of Plot3D
  • Previous by thread: Re: Do loop is faulty
  • Next by thread: simple cipher