Services & Resources / Wolfram Forums
MathGroup Archive
*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 or For or Special Function?

  • To: mathgroup at
  • Subject: [mg47726] RE: [mg47700] NIntegrate or For or Special Function?
  • From: David.Annetts at
  • Date: Fri, 23 Apr 2004 02:31:10 -0400 (EDT)
  • Sender: owner-wri-mathgroup at

Hi Matt,

> I am constructing filling entries in a matrix using For loops.  The
> individual entries come from integrating Bessel, Hankel and Kelvin
> functions numerically with NIntegrate.  A 100x100 matrix 
> takes a few hours
> to run?  Is my procedural way of doing things to blame?  Is it the
> specialty functions (Bessel etc)?  Is it simply NIntegrate?  
> Would anyone
> be willing to look at my awful code?
> Any help would be greatly appreciated.

Without looking at your 'awful code', it's very likely that your
procedural way of doing things is the root of the problem.  If you can
at all rethink things so that you can take advantage of Mathematica's
functional programming constructs (eg. Map, Inner, Outer, etc,.), then
it's time & effort well spent.  For example, I have seen a x20 speed up
replacing Fortran-style nested loops with Outer.

Perhaps posting a reduced (eg 3x3) version of your problem might elicit
some suggestions from the group?


  Dr. David Annetts
  EM Modelling Analyst
  CSIRO DEM            Tel: +612 9490 5416
  North Ryde           Fax: +612 9490 5467
  Australia         David.Annetts at

  • Prev by Date: Re: NIntegrate or For or Special Function?
  • Next by Date: Re: Trig identity oscillations
  • Previous by thread: Re: NIntegrate or For or Special Function?
  • Next by thread: Goldbach partition points plot; "Close; but no cigar" (still):