Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2005
*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 2005

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

Search the Archive

Computation speeds: numerical vs symbolic

  • To: mathgroup at smc.vnet.net
  • Subject: [mg55741] Computation speeds: numerical vs symbolic
  • From: AES <siegman at stanford.edu>
  • Date: Tue, 5 Apr 2005 03:21:06 -0400 (EDT)
  • Organization: Stanford University
  • Sender: owner-wri-mathgroup at wolfram.com

No actual question, or at least no immediately useful question in this 
post.  I'm just expressing surprise and/or asking for enlightenment on 
what seems like a vast disparity in speeds of symbolic vs numerical 
calculations in the latest version of Mathematica.

To be specific, take an expression like

  v = Exp[ -a (s+y)] ( Exp[2 a y] Cos[s0 + q (s-y)] - Cos[s0 + q (s+y)] )

which happens to have come up in a problem I'm just working on (y and s 
are the independent variables of interest, dimensionless surrogates for 
space and time; a, q and s0 are parameters; q happens to be an integer 
in the end).  I then want to evaluate the integral

   w = Integrate[v^2, {y, 0 , Pi}]

(symbolically) and make some plots of w versus s, with values of a, s0 
and q being set by rules for each plot.

The integration involved here (nothing but products of exponentials and 
cosines)  I would describe as trivial but tedious,  that is, I could do 
it by hand, but it would be a (very) dull job.  Yet on my Mac iBook G4 
under Mathematica 5.1, it takes 15 seconds to do this particular 
integration.  If I follow the above cell with a second cell putting in 
the "simplifying" assumption

   w = Integrate[v^2, {y, 0 , Pi}, Assumptions->Element[q,Integers]]

this calculation takes 27 seconds.  

Oddly, if I immediate re-evaluate either of the cells it only takes 2.7 
seconds or 5 seconds, respectively, for the results to come up the 
second time,  but having evaluated the first cell (without the 
Assumption) doesn't seem to speed up the second cell (with the 
Assumption), so it's not like some integration rules have gotten loaded 
and cached in evaluating the first cell and used in evaluating the 
second cell. So, I don't see how I can use this speedup in any practical 
way (???).

The speed contrast comes when I then make a single DisplayPlot 
containing Plots of the w function from above and two very similar 
functions wp and wpp versus s for 10 instances of rules specifying 
values of a, s0 and q,  in other words, thirty decaying-sinusoid-like 
curves in all, each containing 5 or 6 complete cycles.  This plot 
appears on the screen faster than I can release the Enter key to create 
it.

So, I'm just curious, how can a calculate and plot command like this 
be so stunningly fast?  and the trivially simple symbolic integration 
above be so slow?


  • Prev by Date: Re: Numerical accuracy of Hypergeometric2F1
  • Next by Date: Y axis labelling on OS X. new (to me) development.
  • Previous by thread: Re: Re: spiral cipher
  • Next by thread: Y axis labelling on OS X. new (to me) development.