Re: Algorithm Analysis Course: Should I use Mathematica for projects?

*To*: mathgroup at smc.vnet.net*Subject*: [mg127295] Re: Algorithm Analysis Course: Should I use Mathematica for projects?*From*: "djmpark" <djmpark at comcast.net>*Date*: Sat, 14 Jul 2012 01:31:48 -0400 (EDT)*Delivered-to*: l-mathgroup@mail-archive0.wolfram.com*Delivered-to*: mathgroup-newout@smc.vnet.net*Delivered-to*: mathgroup-newsend@smc.vnet.net*References*: <15963298.38946.1342045629048.JavaMail.root@m06> <jtm3kl$gdm$1@smc.vnet.net> <5038541.27016.1342162628470.JavaMail.root@m06>

But there is a difference between developing and analyzing an algorithm and running an algorithm on a particular machine. Unless one is going to do empirical algorithmics Mathematica might still bring much better capabilities to the subject matter. David Park djmpark at comcast.net http://home.comcast.net/~djmpark/index.html From: Richard Fateman [mailto:fateman at cs.berkeley.edu] On 7/12/2012 1:59 AM, djmpark wrote: > I'm not an expert at computer science so others may have something > better to say there. > > But I think your "Pros" argument is correct. Mathematica is broad > enough and deep enough that it is worthwhile getting good at it and it takes time. > > Are you aware of the book "Computer Science with Mathematica" by Roman E. > Maeder. It was published in 2000 for Version 4, but is still probably > plenty useful. > > An example. Create 3 arrays. A=Table[i,{i,0,100}]; B=Table[i,{i,0,1000}]; Q=Table[i,{i,0,10000}]; Try updating the 50th element of each of these items, which look like arrays in Mathematica. Timing [A[[50]],{i,0,100000}] Timing [B[[50]],{i,0,100000}] Timing [Q[[50]],{i,0,100000}] On my computer, these results take 0.266 seconds, 0.453 seconds, and 2.25 seconds, So, for the prize, tell me which is the fastest, and which is the slowest? Or more to the point, can you explain to your computer science professor why this is so? Now, instead of creating these guys as what appears to be arrays, one uses A=Array[#&,100] B=Array[#&,1000] Q=Array[#&,10000] How does that change the results? Note that the documentation says. that "Array[f,n] generates a list of length n with elements f[i]. Of course that is not really a list. experimenting with Append and Prepend might be amusing too.