A116 === Subject: Re: ReplacePart and Compile > > (More generally: Could it be annotated in the documentation, which > functions can be compiled and which functions cannot be compiled. For me > it is always an adventure to figure out a compiled version of a routine > I need, because of this lack of basic information.) > I agree, it is quite frustrating that this is not documented. The only doc page I could find about this is here: http://support.wolfram.com/mathematica/kernel/Symbols/System/Compile.html (Note that this is for Mathematica 3, not Mathematica 6.) Unfortunately it seems that WRI is not putting too much effort into developing Compile[] any more. It is not being taught to compile new functions, and its bugs are not fixed. === Subject: Re: ReplacePart and Compile >> (More generally: Could it be annotated in the documentation, which >> functions can be compiled and which functions cannot be compiled. For me >> it is always an adventure to figure out a compiled version of a routine >> I need, because of this lack of basic information.) > > I agree, it is quite frustrating that this is not documented. The only > doc page I could find about this is here: > > http://support.wolfram.com/mathematica/kernel/Symbols/System/Compile.html > > (Note that this is for Mathematica 3, not Mathematica 6.) > > Unfortunately it seems that WRI is not putting too much effort into > developing Compile[] any more. It is not being taught to compile new > functions, and its bugs are not fixed. > Perhaps it was a bit too harsh to say that its bugs are not being fixed. To be fair (and to avoid flames), I will note that this is the particular problem that I know about: Of course these kinds of problems are probably difficult to avoid, because the solution involves keeping track of which functions have side effects and which don't. === Subject: Enable multicore calculation ? Hello everyone, I'm running Mathematica 6.0.2 on a MacPro with 8 cores. I've noticed that the kernel only uses 1 core=85 Is it possible to enable multicore calculations ? === Subject: Re: Enable multicore calculation ? I run some larger calculations on Linux with Mathematica 6.0.2.1 and 8 cores essentially using NDSolve, and these calculations definitly use usually 4 cores without any interference from my side. Mathematica seems to detect the multicore environment automatically and the software acts then accordingly. In a sense I was (positively) surprised. However, not everything in Mathematica supports multicore, and it is my guess and partly my experience that it is mostly (maybe only) numerical stuff which uses multicores. Michael Weyrauch > Hello everyone, > > I'm running Mathematica 6.0.2 on a MacPro with 8 cores. I've noticed > that the kernel only uses 1 core=85 Is it possible to enable multicore > calculations ? > > === Subject: Re: installing Playe rPro killed using John Fultz's characterization of the situation here is right on the mark -- completely correct. > Really? What have you heard or read that gives you such a negative impression? > > I've read every remark about Player Pro on the group, and I believe this thread > represents the only bug/negative remark about the product I've seen. If I > missed something, please let me know! > > Specifically, Murray reported one bug in two different ways, conceded by me > both times, complete with mea culpas and workarounds... > > http://forums.wolfram.com/mathgroup/archive/2008/Apr/msg00605.html > http://forums.wolfram.com/mathgroup/archive/2008/Apr/msg00924.html > > > John Fultz > jfultz@wolfram.com > User Interface Group > Wolfram Research, Inc. > > > >> Such a gross oversight on Wolfram's part is unexpected. I suspect that >> unless the problem is fixed in short order that PlayerPro will not make >> it for very long. Given all that I have heard, I would not install it on >> my system. I am just thankful that my procrastination delayed prevented >> this problem for me. I would like to thank all those who quickly alerted >> the group. >> Kevin > Yes, this fixes the problem with the mathpass for Player Pro under my > configuration effectively killing the mathpass for Mathematica itself. Of course the problem should have been avoidable by the installer > program, or at least by installation directions, in the first place. > Yes, this is because of the overlapping use of MATHEMATICA_USERBASE. >> Anybody >> who does not set this variable will not see the problem. To work >> around this... >> * Take your current mathpass file and move it into Mathematica's >> installation >> directory in ConfigurationLicensing. >> * Start Player Pro and enter your password. >> * Take the newly generated mathpass file and move it into Player Pro's >> installation directory in ConfigurationLicensing. >> John Fultz >> jfultz@wolfram.com >> User Interface Group >> Wolfram Research, Inc. > With an existing installation of Mathematica 6.0.2 under Windows, I > just > installed Player Pro. The result: if I start Mathematica itself and > open a new notebook there, I am prohibited from typing any and all > input. This sort of thing is intolerable! An utterly time-frittering > aggravation. I suspect that the scenario involved here was not tested by WRI: My > mathpass for Mathematica itself is in the Licensing subdirectory of > my > USERBASE directory, which is the same as my BASE directory (both > set by > Windows environment variables MATHEMATICA_BASE and > MATHEMATICA_USERBASE). This is hardly the first time I have run into trouble with multiple > passwords from multiple Wolfram Research products. It is something > they > have just not yet gotten right. Beware! What I did as a temporary fix was to use my Windows backup program > to > restore my pre-existing mathpass file. Now regular Mathematica > works. > But of course Player Pro does not. > > > -- Murray Eisenberg murray@math.umass.edu Mathematics & Statistics Dept. Lederle Graduate Research Tower phone 413 549-1020 (H) University of Massachusetts 413 545-2859 (W) 710 North Pleasant Street fax 413 545-1801 Amherst, MA 01003-9305 === Subject: Base function ((1*12 + 4)*11 + 4)*10 + 4 1804 I need help with a function find the Calander base Cbase[1804,{12,11,10}] out put will be {1,4,4,4} Tomi === Subject: Re: Base function > > > > ((1*12 + 4)*11 + 4)*10 + 4 > > 1804 > > I need help with a function find the Calander base > > Cbase[1804,{12,11,10}] > > out put will be > {1,4,4,4} I don't understand the question. Why shouldn't it return e.g. {1, 3, 15, 4} ? After all, ((1*12 + 3)*11 + 15)*10 + 4 == 1804 Szabolcs === Subject: Re: Print[Plot] vs Print[text,Plot]? > >> There are a *lot* of extremely useful things New in 6.0 that are very >> much worth the effort to learn. > > Yes, I totally agree. > > So, could you please point me to the well-organized, well-written, > well-illustrated introduction to (repeat: Introduction to, not > Detailed Reference Documentation for) the most important and useful of > these new things (and the ones most changed since 5.n), > > --that I can order for $20 or $30 from amazon (a very small fraction of > the cost of Mathematica itself) (although something that, with more > savvy software developers, comes in the box with the product itself) > > --and can read in the evening, or on my next plane trip, or in the > dentist's waiting room, or during a particularly dull meeting > > --and can thereby get an _overview_ --- a _roadmap_ -- a _preview_ --- > of these useful new things, to let me know what I need to dig into > further to meet my particular, specific needs as a user (and which of > these I won't immediately need and can ignore). > > What? You want me to go to the Mathematica Documentation Center? > Several _hundred_ tersely labeled clickable links just on the initial > page? Each of which leads, not to a simple introduction, but to a > complex formal documentation page with multiple further links to click? > And all of which can only be read and navigated _on screen_? > > You and I, I'm afraid, just think differently. Not to turn this into a flame-fest, but how exactly would you know how I think? As for using the Mathematica Documentation Center to learn what is new in 6.0, I don't quite see what the problem is. Each of the major categories (Core Language, Visualization and Graphics, etc.) has a New in 6 link at the bottom, which will take you directly to a succinct list of new functions in 6.0, with links to further information and examples of their use. I found the New in 6 pages to be extremely helpful when I first upgraded to 6.0, and I still consult them regularly. There is also a Virtual Book, which you can get to clicking on the book icon in the Documentation Center (up at the top, to the left of the search field). -- Helen Read University of Vermont === Subject: Problems with NSolve Hi all I am trying to find the number of eigenvalue crossings for a matrix as a function of the parameter 'u', on which the elements of the (symmetric) matrix depend on linearly. The matrix elements also involve randomly chosen constants. The plan is to find the distribution of the crossings of these type of matrices as I scan over the random numbers. So far I have been using the following : NSolve[{chpoly[u, dim, [Alpha], [Gamma], [Epsilon], x] == 0, D[chpoly[u, dim, [Alpha], [Gamma], [Epsilon], x], x] == 0}, {x, u}, WorkingPrecision -> prec] where chpoly is the characteristic polynomial of the matrix (with the eigenvalue variable being x) and alpha, gamma and epsilon are constant parameter arrays of random numbers. For a double (or higher) degeneracy of the eigenvalues both the characteristic equation and its derivative should be zero. This approach has worked successfully only upto 12*12 matrices (where one such computation takes 40 secs on my laptop). For 13*13 my laptop takes 4000 sec. This seems to be somewhat surprising, because these polynomials are of the order 'n' (where n is dimension of the matrix) in both u and x - and n=13 does not sound very computationally unreasonable. So I was wondering if there was a faster approach I could take. Also, the problem essentially entails me to know the number (not the values) of the real solutions to this system of polynomials. CountRoots seemed ideal but it does not work for more than one equation. So is there any alternative along this route? Any other alternatives are also welcome. Kij. === Subject: Coordinate readout from Graphics3D? I thought I saw somewhere that one could read out coordinates from a Graphics plot, according to the mouse position. I can't find it now, and I don't see how it would work with Graphics3D. But anything would Steve Gray === Subject: Re: Coordinate readout from Graphics3D? > I thought I saw somewhere that one could read out coordinates from a > Graphics plot, according to the mouse position. I can't find it now, > and I don't see how it would work with Graphics3D. But anything would If you search MathGroup for 3D locator, you will find several threads on this topic. Here's one: The idea is to use MousePosition[Graphics3DBoxIntercepts] to find out where a line perpendicular to the screen intersects the 3D bounding box. If you are only interested in 2D, take a look at Locator, or, in Mathematica 6.0.2, the get coordinates drawing tool accessible from Graphics -> Drawing tools (CTRL-D). === Subject: Re: Wolfram User Interface Research? > >> This comment about APL is quite wrong: nothing compelled you to write >> inscrutable single line programs (except maybe in the earliest days, >> when one was sending single lines over a telephone line to a mainframe, >> then waiting for your instruction's turn to get its slice of time and >> have the result sent back and typed at your terminal). >> >> With APL then, and with IBM's APL2 now, you MAY, if you wish, write >> overly condensed one-liners. And indeed some APL programmers aimed to >> write as concise a program, all in one line, as they could possibly do. > > I'll totally concede your point here. But I don't think it makes > my original comment quite wrong, or even wrong at all. > > And I'm not attacking APL at all -- a great (if arcane) > intellectual achievement in computer science, and maybe > a great (if still arcane) tool for certain types of computation. > > But nonetheless, the arcane symbolic notation used in APL > tends to make even multi-line APL programs nearly as > inscrutable for all but APL experts. > > >> What's more, many of the combinations of symbols in APL were instantly >> recongnizable to any APL programmer as so-called idioms. > > Again, happy to agree. But, there aren't really a lot of > APL programmers around, right? -- and I'd bet that > they tend to be programmers employed as such, rather > than ordinary users from many other fields, who just > want to be get some computational task done in the > field where their skills primarily lie. For what it's worth, I've recently been re-implementing the functionality of our in-house APL application into Mathematica. My colleagues don't know I've done this yet -- it's been a home project to get to know the new date and time functionality in v6 better. (I don't actually know APL, but their documentation is pretty thorough.) It will be interesting to see which language produces the longer program. Luci === Subject: Re: Wolfram User Interface Research? [off-topic!] >You'd be surprised (or perhaps not) at how many mathematicians, >scientists, and engineers I know say about Mathematica something that >many have said about APL: that it's too hard to learn and too strange >and unfamiliar, i.e., either unlike traditional mathematical notation or >unlike FORTRAN and a certain CAS that's a glorified, enhanced FORTRAN. > About my experience with Mathematica: I've been using it for several years and always getting what I want done with less frustration and much more productivity than if I were using C (which I hate). There are still large parts of Mathematica that I don't know and don't use, but one can ease into programming it by starting off with plain old procedural methods and put in more functional methods in time. If I need lots of speed in parts of my code, I've posted the problem here and have gotten very good responses. One off-putting feature of Mathematica is the ability to write (if not always to read!) code that consists of strings of $&~/_@, etc. I know some but not all of them but use them sparingly because I have to read harder. Of course learning lists is essential from the beginning, but I found that to be intuitive and quite appealing, even though I had not used LISP or any other list-oriented language previously. Even though I paid for Mathematica myself, I have found it to be well worth the money. (Just to show that I'm not being paid by WRI for this, I think NKS is a total crock, and I worked on CA for years.) Steve Gray === Subject: Re: 2*m^z - m^z = ? Alexy, Not so much an explanation (which I will leave to WR experts) but another illustration that IF you are a true believer in Mathematica you can find a way to get the result or form you desire with a little patient exploration and trying. Table[{2*m^z - m^z, Collect[FullSimplify[2*m^z - m^z], z, Modulus -> 2]}, {m, 1, 11}] // TableForm ( { {1, 1}, {-2^z + 2^(z + 1), 2^z}, {3^z, 3^z}, {2^(2 z + 1) - 4^z, 4^z}, {5^z, 5^z}, {2^(z + 1) 3^z - 6^z, 6^z}, {7^z, 7^z}, {2^(3 z + 1) - 8^z, 8^z}, {9^z, 9^z}, {2^(z + 1) 5^z - 10^z, 10^z}, {11^z, 11^z} } ) HTH ... Syd Syd Geraghty B.Sc, M.Sc. sydgeraghty@mac.com My System Mathematica 6.0.2.1 for Mac OS X x86 (64 - bit) (March 13, 2008) MacOS X V 10.5.2 > What do you think about this: Table[ > {2*m^z - m^z, > FullSimplify[2*m^z - m^z]}, > {m, 1, 21}] // TableForm The answer is very interesting (only odd numbers are treated well): 1 1 > -2^z + 2^(1 + z) 2^z > 3^z 3^z > 2^(1 + 2*z) - 4^z 4^z > 5^z 5^z > 2^(1 + z)*3^z - 6^z 2^(1 + z)*3^z - 6^z > 7^z 7^z > 2^(1 + 3*z) - 8^z 8^z > 9^z 9^z > 2^(1 + z)*5^z - 10^z 2^(1 + z)*5^z - 10^z > 11^z 11^z > 2^(1 + 2*z)*3^z - 12^z 2^(1 + 2*z)*3^z - 12^z > 13^z 13^z > 2^(1 + z)*7^z - 14^z 2^(1 + z)*7^z - 14^z > 15^z 15^z > 2^(1 + 4*z) - 16^z 16^z > 17^z 17^z > 2^(1 + z)*9^z - 18^z 2^(1 + z)*9^z - 18^z > 19^z 19^z > 2^(1 + 2*z)*5^z - 20^z 2^(1 + 2*z)*5^z - 20^z > 21^z 21^z Can anyone explain the reason for this behavior? > === Subject: Re: 2*m^z - m^z = ? With the Presentations package you could use FactorOut. Needs[Presentations`Master`] Table[FactorOut[m^z][2*m^z - m^z], {m, 1, 21}] {1, 2^z, 3^z, 4^z, 5^z, 6^z, 7^z, 8^z, 9^z, 10^z, 11^z, 12^z, 13^z, 14^z, 15^z, 16^z, 17^z, 18^z, 19^z, 20^z, 21^z} -- David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ > What do you think about this: Table[ > {2*m^z - m^z, > FullSimplify[2*m^z - m^z]}, > {m, 1, 21}] // TableForm The answer is very interesting (only odd numbers are treated well): 1 1 > -2^z + 2^(1 + z) 2^z > 3^z 3^z > 2^(1 + 2*z) - 4^z 4^z > 5^z 5^z > 2^(1 + z)*3^z - 6^z 2^(1 + z)*3^z - 6^z > 7^z 7^z > 2^(1 + 3*z) - 8^z 8^z > 9^z 9^z > 2^(1 + z)*5^z - 10^z 2^(1 + z)*5^z - 10^z > 11^z 11^z > 2^(1 + 2*z)*3^z - 12^z 2^(1 + 2*z)*3^z - 12^z > 13^z 13^z > 2^(1 + z)*7^z - 14^z 2^(1 + z)*7^z - 14^z > 15^z 15^z > 2^(1 + 4*z) - 16^z 16^z > 17^z 17^z > 2^(1 + z)*9^z - 18^z 2^(1 + z)*9^z - 18^z > 19^z 19^z > 2^(1 + 2*z)*5^z - 20^z 2^(1 + 2*z)*5^z - 20^z > 21^z 21^z Can anyone explain the reason for this behavior? > === Subject: Re: 2*m^z - m^z = ? > What do you think about this: > > Table[ > {2*m^z - m^z, > FullSimplify[2*m^z - m^z]}, > {m, 1, 21}] // TableForm > > The answer is very interesting (only odd numbers are treated well): > > 1 1 > -2^z + 2^(1 + z) 2^z > 3^z 3^z > 2^(1 + 2*z) - 4^z 4^z > 5^z 5^z > 2^(1 + z)*3^z - 6^z 2^(1 + z)*3^z - 6^z > 7^z 7^z > 2^(1 + 3*z) - 8^z 8^z > 9^z 9^z > 2^(1 + z)*5^z - 10^z 2^(1 + z)*5^z - 10^z > 11^z 11^z > 2^(1 + 2*z)*3^z - 12^z 2^(1 + 2*z)*3^z - 12^z > 13^z 13^z > 2^(1 + z)*7^z - 14^z 2^(1 + z)*7^z - 14^z > 15^z 15^z > 2^(1 + 4*z) - 16^z 16^z > 17^z 17^z > 2^(1 + z)*9^z - 18^z 2^(1 + z)*9^z - 18^z > 19^z 19^z > 2^(1 + 2*z)*5^z - 20^z 2^(1 + 2*z)*5^z - 20^z > 21^z 21^z > > Can anyone explain the reason for this behavior? FWIW, Though this might not answer your question, as a rule of thumb -- or best practice -- one should always attempt to simplify symbolic expressions before using them in any iterative or recursive construct. FullSimplify[2*m^z - m^z] m^z -- === Subject: Re: 2*m^z - m^z = ? > What do you think about this: Table[ > {2*m^z - m^z, > FullSimplify[2*m^z - m^z]}, > {m, 1, 21}] // TableForm The answer is very interesting (only odd numbers are treated well): 1 1 > -2^z + 2^(1 + z) 2^z > 3^z 3^z > 2^(1 + 2*z) - 4^z 4^z > 5^z 5^z > 2^(1 + z)*3^z - 6^z 2^(1 + z)*3^z - 6^z > 7^z 7^z > 2^(1 + 3*z) - 8^z 8^z > 9^z 9^z > 2^(1 + z)*5^z - 10^z 2^(1 + z)*5^z - 10^z > 11^z 11^z > 2^(1 + 2*z)*3^z - 12^z 2^(1 + 2*z)*3^z - 12^z > 13^z 13^z > 2^(1 + z)*7^z - 14^z 2^(1 + z)*7^z - 14^z > 15^z 15^z > 2^(1 + 4*z) - 16^z 16^z > 17^z 17^z > 2^(1 + z)*9^z - 18^z 2^(1 + z)*9^z - 18^z > 19^z 19^z > 2^(1 + 2*z)*5^z - 20^z 2^(1 + 2*z)*5^z - 20^z > 21^z 21^z Can anyone explain the reason for this behavior? > Thera are many such pheonomna in computer algebra. This particular one I have already once explained on this forum, but as I can't find my post I will repeat it. The reason why this happens is that Mathematica (and all other Computer ALgebra Systems) performs certain simplifications, or more precisely reductions to canonical form automatically, even before applying Simplify or FullSimplify, simply as part of the evaluation process. One such simplification that is done automatically is this: 2*6^z 2^(z + 1)*3^z In other words, Mathematica sees that 6 has 2 as a factor, it factors it out and combines all factor of 2 into a single power. This is a typical example of reduction to canonical form. Such reductions make certian operations much simpler and faster but unfortunately this particular one does not fit in very well with another reduction that Mathematica also performs automatically: 2^z*3^z 6^z Such reductions cannot be undone by Simplify or FullSimplify because they are performed on evaluation, so even if Simplify undid one of them, the reduction would be immediately performed again. Unfortunately these two reductions prevent Simplify and FullSimplify form seeing that 2^(z + 1)*3^z-6^z can be simplified to 6^z, because Simplify cannot re-write 2^(z + 1)*3^z as 2*6^z and it also cannot re-write 6^z as 2^z*3^z for reasons described above. In the exmaple you gave the problem can be easily dealt with by wrapping Evaluate round the first argument of Table. Table[Evaluate[{2*m^z - m^z, FullSimplify[2*m^z - m^z]}], {m, 1, 21}] However the problem of simplifying p=2*6^z-6^z and similar expressions is harder to deal with. Note that Mathematica has no difficulty verifying that p == 6^z // Simplify True so it is only transforming p into 6^z by means of FullSimplify that is difficult. In fact, I don't think it can be done, without using some tricks. Here is one such trick. We divide p by 3^z, then FullSimplify and finally again multiply by 3^z: FullSimplify[[p/3^z]*3^z 6^z Andrzej Kozlowski === Subject: Re: Print[Plot] vs Print[text,Plot]? (*now Do and Table*) >And I was surprised much more when I have tried the more simple form >of the first expression: >Timing[icount = 0; >Do[icount += i, {i, 1, 10000000, 1}]; icount] >(*this returns {36.042, 50000005000000} on my machine*) >It means that using the += operator takes about 50% more time than >the usual form icount = icount + i; It is sad and very surprising! I understand why you might consider this surprising if you come from a C/C++ background. But why sad? You simply need to realize Mathematica is not C/C++. What is most efficient in such languages cannot be assumed to be most efficient in Mathematica. My experience indicates using Mathematica's functional constructs (Map, Apply etc) are almost always faster than the procedural constructs (Do, For etc.). Since I have no access to the source code, I've no real idea why this is so. I simply accept it as so and write code accordingly. Another rule of thumb seems to be, things run faster when the minimum amount of information needed is given rather than a more complete specification. For example, on my machine: In[251]:= Timing[Total@Table[n, {n, 1, 1000000, 1}]] Out[251]= {1.2309,500000500000} In[252]:= Timing[Total@Table[n, {n, 1, 1000000}]] Out[252]= {1.16736,500000500000} In[253]:= Timing[Total@Table[n, {n, 1000000}]] Out[253]= {1.16389,500000500000} There are other benefits to the functional style over the procedural style in addition to performance. With C/C++ loops probably one of the more common errors is to be one off at the end of a loop. This could happen as a result of using say n < limit versus n <= limit for the stopping criteria or failing to have the stopping test in the right sequence with the step incrementing the loop counter. These kind of problems are eliminated with functional programming constructs since you never need worry about the size on an array. === Subject: Re: Print[Plot] vs Print[text,Plot]? >>There are a *lot* of extremely useful things New in 6.0 that are >>very much worth the effort to learn. >Yes, I totally agree. >So, could you please point me to the well-organized, well-written, >well-illustrated introduction to (repeat: Introduction to, not >Detailed Reference Documentation for) the most important and >useful of these new things (and the ones most changed since 5.n), >These abstruse parts of Mathematica are not obligatory for >>ordinary users but for Mathematica programmers and developers >>(and many power users) they make life a lot easier. >Also agree -- but my expectation would be that there are (or could >be -- and should be) a *great* many more ordinary users than power >users. It is hard for me to think of using things like @, @@, /@ to be something that distinguishes between ordinary users and power users of Mathematica. Simply using Mathematica often and being willing to look up unfamiliar operators in code written by others should cause most users to rapidly start using this things. >I'm quite familiar with TeX and can program in it, though I'm not >really a TeXpert. Plain TeX is *much* less complex than >Mathematica. I use Mathematica daily but don't use TeX daily. Consequently, I have a much greater familiarity with Mathematica than TeX. And as a result, TeX seems more complex and arcane to me than Mathematica. It would be very surprising to learn I was unique in this regard. That is it seems to me usage of things like @, @@, /@ etc are more an issue of familiarity rather than power user versus ordinary user. >>Finally, in all your posts you never seem to mention the very >>essential (in the case of Mathematica) distinction between the >>Front End and the Kernel. The great majority of new functionality >>in v. 6 concerns the former. In principle there is no reason why >>Mathematica should not be available with alternative Front Ends. It >>used to be possible to run later versions with earlier Front Ends. >>I have not tried this with v. 6 but that would be one way to do >>away with most of the new complexity that you seems to displease >>you so. >If that can be done --- and documented for ordinary users --- have >at it! There is documentation telling how to connect a front end to a different kernel. But there won't be documentation talking about connecting say the version 5.x front end to the version 6.x kernel. How could there be since version 6 didn't exist when documentation for version 5 was written? Similarly, you won't find documentation describing what happens when connecting say the version 5.x kernel to the version 6.x front end. No one would reasonably expect this to be something desirable to do. So, all you need do is simply try making the connection and see how you like the result. === Subject: Re: HighlightedEdgeColors with Combinatoric`ShowGraph and AnimateGraph First I would like to say that I am not familiar with Combinatorica and its graph plotting functions, so what I write here might not be entirely correct. > The following works as expected to highlight two of the edges of a graph > with a different color each: > > < g=Cycle[3]; > > ShowGraph[ > Highlight[g,{{{1,2}},{{2,3}}},HighlightedEdgeColors->{Red,Blue}]] > > And the docs say that AnimateGraph takes the same options as Highlight. > But the following does NOT work -- it uses just the first color, Red, > when animating the highlighting of the two edges: > > AnimateGraph[g, {{1, 2}, {2, 3}}, > HighlightedEdgeColors -> {Red, Blue}] > > What's wrong? > > (I do know that I used different syntax in the 2nd argument of > Highlight, on the one hand, and in the 2nd argument of AnimateGraph, on > the other hand. For Highlight to work within ShowGraph so as to animate > edges, it is necessary to put the extra level of nesting in each edge > specification. But such extra nesting in the case of AnimateGraph would > not work: it gives no animation of edges.) > AnimateGraph says: Here l is a list containing vertices and edges of g. So no extra nesting should be necessary. In contrast to this, the doc page for Highlight says: The second argument p has the form {Subscript[s, 1],Subscript[s, 2],[Ellipsis]}, where the Subscript[s, i] are disjoint subsets of vertices and edges of g. So the second argument of highlight should be a list of lists, where the elements of each sublist will have a common style. This is the source code of AnimateGraph: AnimateGraph[g_Graph, l_List, flag_Symbol: All, opts___?OptionQ] := ListAnimate[ Map[ShowGraph, Table[ Highlight[g, {{l[[i]]}}, Sequence @@ FilterRules[{opts}, Except[Options[ListAnimate]]]], {i, Length[l]}], Table[Highlight[g, { l[[Range[i]]] }, Sequence @@ FilterRules[{opts}, Except[Options[ListAnimate]]]], {i, Length[l]}] ] ], Sequence @@ FilterRules[{opts}, Options[ListAnimate]] ] If you look at the second Table function, especially the { l[[ Range[i] ]] } part, you'll see that AnimateGraph will only use a single sublist in Highlight, so all edges/vertices will be highlighted with the same style. As I said, I am not familiar with Combinatorica, so I cannot tell whether AnimateGraph was written like this intentionally, or this is a bug, but the behaviour you are looking for can be achieved by changing { l[[ Range[i] ]] } to List /@ l[[ Range[i] ]] Note that this change will only affect the case when the flag has the value All. The AnimateGraph[g, l, One] case cannot be made to work with HighlightedEdgeColors without parsing the colour list inside AnimateGraph (instead of passing it to Highlight unchanged). Probably this is the reason why the All case uses only a single style too. I hope this helps, Szabolcs P.S. Actually Highlight seems to accept empty sublists too, so for the One case, {{l[[i]]}} could be replaced by ReplacePart[Table[{}, {Length[l]}], i -> {l[[i]]}] to get the right colour. === Subject: Re: OpenerView (with cells?) Put a regular Sectional header in your notebook. Use Ctrl-Shift-E to open up the underlying expression. Then add to the cell the option ShowGroupOpenCloseIcon->True. Then, as soon as you have another cell in the section the little triangle will show and you can use it to open and close the section. These open/close icons are a very nice thing to have and I don't understand why they are not present on any of the standard style sheets. This may seem like a small thing but some people don't know about the double-clicking on the brackets, and other people just don't like it. I have a style sheet at my web site that does have these icons on all sectional groupings - but not on anything else. This is similar to the style sheet that comes with Presentations. This brings up a related question. It would be nice to have some kind of 'BoxSection' that could contain Text cells and Input/Output cells, but which other sections could 'flow around' just like boxes in textbooks or sidebars up, and then enter a Text cell after it, the Text cell gets captured by the subsection. You can descend in the sectional hierarchy, but you can't get back up without actually starting a new higher level section. You can't 'flow around'. It is probably not easy for WRI to implement this. Right now for Presentations I've developed (but haven't included yet) something called Sidebars that solves this problem. The idea is to have Sidebar notebooks that are completely contained within a principal notebook but display as separate notebook windows. One first uses a MakeSidebar command to bring up a notebook window with a specified name. One can then add any desired information to the sidebar notebooks or change its style sheet just as with an ordinary notebook. But the sidebar notebook is not savable in the usual manner. Instead, in the principal notebook you can use a SaveSidebar command. This creates an initialization Input statement in the principal notebook that contains the sidebar notebook, but in skeleton form of display. The Sidebars are completely embedded in the principal notebook. Then there is a SidebarButton command that creates a distinctive button that will launch the Sidebar notebook. A reader can then bring up the Sidebars, read them, evaluate them and even do their own calculations in them, and then close them when finished. Sidebars are a very effective method to provide additional information without disrupting the flow of some argument, derivation or proof in a notebook. -- David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ > In the Mathematica documentation viewer, it looks as though sections > and subsection headers are implemented using an OpenerView that can > contain cells. At least when you click on the disclosure triangle next > to sections like Examples, More Information, Options, and so on, > the view reveals a number of input, output, and text cells. How are those section headers implemented? An ordinary OpenerView, as > far as I can tell, cannot contain cells (although you can fake it a > little bit using DisplayForm). I looked at the cell expression for > one using Show Expression but what I found was just a reference to a > stylesheet: Cell[TextData[{ > Basic Examples, > , > Cell[(4), ExampleCount] > }], ExampleSection, > CellID->454094506] Any ideas on how that effect is achieved? I'd like to use something > similar in my own notebooks. > Jason -- > Dr. J. McKenzie Alexander > Department of Philosophy, Logic and Scientific Method > London School of Economics and Political Science > Houghton Street, London, WC2A 2AE > === Subject: Re: OpenerView (with cells?) Such cells have the Cell option ShowGroupOpener->True --David > In the Mathematica documentation viewer, it looks as though sections > and subsection headers are implemented using an OpenerView that can > contain cells. At least when you click on the disclosure triangle next = > to sections like Examples, More Information, Options, and so on, = > the view reveals a number of input, output, and text cells. How are those section headers implemented? An ordinary OpenerView, as = > far as I can tell, cannot contain cells (although you can fake it a > little bit using DisplayForm). I looked at the cell expression for > one using Show Expression but what I found was just a reference to a > stylesheet: Cell[TextData[{ > Basic Examples, > , > Cell[(4), ExampleCount]}], ExampleSection, CellID->454094506] Any ideas on how that effect is achieved? I'd like to use something > similar in my own notebooks. > Jason -- > Dr. J. McKenzie Alexander > Department of Philosophy, Logic and Scientific Method > London School of Economics and Political Science > Houghton Street, London, WC2A 2AE Please access the attached hyperlink for an important electronic communica= tions disclaimer:http://www.lse.ac.uk/collections/secretariat/legal/disclaim= er.htm === Subject: Re: OpenerView (with cells?) > In the Mathematica documentation viewer, it looks as though sections > and subsection headers are implemented using an OpenerView that can > contain cells. At least when you click on the disclosure triangle next > to sections like Examples, More Information, Options, and so on, > the view reveals a number of input, output, and text cells. I don't think these are implemented with OpenerView but at a lower level with something like Opener, or even more likely at an even lower level which is probably not documented and not easy to access. Anyway, you can achieve the same behaviour with something like: CellPrint@Cell[tst, Section, CellDingbat -> ToBoxes@DynamicModule[{state = False}, Opener[Dynamic[state, Function[ FrontEndExecute[{ FrontEnd`SelectionMove[FrontEnd`ButtonNotebook[], All, ButtonCell], FrontEndToken[OpenCloseGroup] }]; state = # ] ]]] ] Of course you need to assure to create the right cell grouping if you don't want to rely on the automatic grouping of sections, subsections etc. On the other hand, when you create the correct grouping, you can just as well use the option ShowGroupOpener->True for the first cell to automatically get an opener with the correct behavior. hth, albert === Subject: ConstantArray and List Consider the following inputs: In[1]:= ConstantArray[f[], {5}] Out[1]= {f[], f[], f[], f[], f[]} In[2]:= ConstantArray[List[], {5}] During evaluation of In[2]:= ConstantArray::scalar: Argument {} at position 1 is not a scalar. >> Out[2]= ConstantArray[{}, {5}] Why doesn't the second one work? Is this because of the way packed arrays are handled (just a guess)? What is the advantage of ConstantArray over Table or Array? It doesn't seem to be much faster, and it doesn't seem to return an array stored in a more efficient way (I experimented a little with MemoryInUse[]). === Subject: Re: 3D Arrows Hello Robert, David Park has done a very nice job of implementing these, they are very pretty: http://home.comcast.net/~djmpark/ It has a modest price, but inexpensive if you compare the time required to build it yourself. WCC > Apparently Arrows is only a 2D graphic. Is there a way to make an arrow > in 3D? > Robert M Lurie -- W. Craig Carter === Subject: Re: 3D Arrows The Presentations package from my web site below has a quite comprehensive Arrow3D command. There is also an ArrowCurve3D command that will place arrowcones along curves and an ArrowTangent3D. In addition, the routines AngleArc3D, AngleDisk3D and AngleSquare3D will draw 3D arcs, disk segments, or squares between two 3D arrows or two 3D Lines. There is also an Arrow3D package on MathSource: http://library.wolfram.com/infocenter/TechNotes/4117/ -- David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ > Apparently Arrows is only a 2D graphic. Is there a way to make an arrow > in 3D? > Robert M Lurie > === Subject: Re: 3D Arrows >Apparently Arrows is only a 2D graphic. Is there a way to make an arrow >in 3D? >Robert M Lurie I had the same question about circles in 3D, but I thought of using cylinders. That works well, but if I needed a primitive which is a 3D ellipse or other 3D curve, even a planar one, I don't know how to do that. I have Trotter's Guidebook for Graphics (and the one for Programming) but they have so many complicated, bizarre examples that it's hard to find answers to simple questions. Steve Gray === Subject: Re: 3D Arrows > Apparently Arrows is only a 2D graphic. Is there a way to make an arrow > in 3D? To draw 3D arrows, the following packages are worth looking at: . Harry Calkins' *MyGraphics`Arrow3D`* http://library.wolfram.com/infocenter/TechNotes/4117/ . David Park's *Presentations* package (for v6 and above) or *DrawGraphics* (for v5.2 and below) http://home.comcast.net/~djmpark/Mathematica.html Note that David Park's packages are doing much more than just drawing 3D arrows! They define a simple yet powerful paradigm for drawing and plotting with Mathematica. -- === Subject: Re: 3D Arrows > Apparently Arrows is only a 2D graphic. Is there a way to make an arrow > in 3D? Robert, I use a short stack of Cylinders. Here's a stack of five, apex at p_, pointing in direction n_. arrowhead3D[p_, n_] := Module[{l = 0.2, d = 0.1, s = 5}, {EdgeForm[None], Table[Cylinder[{p - (i - 1) l n/s, p - i l n/s}, d i/s/2], {i, s}]}] p = {1, 1, 1}; n = {1, 1, 1}; Graphics3D[{Point[p], Line[{{0, 0, 0}, n}], arrowhead3D[p, n]}] The form is pretty cheap but not-ready-for-publication. Absolute size would be a good idea, but I didn't need it at the time. Hth, Fred Klingener === Subject: Re: 3D Arrows (* The following code defines a very simple command for 3d arrows, *) (* copy-paste to Mathematica and press Shift-Enter, *) (* no-output will be generated, but the new arrow3d command *) (* will be ready to be used, see example below *) arrow3d[{x1_, y1_, z1_}, {dx_, dy_, dz_}] := arrow3d[{{x1, y1, z1}, {x1 + dx, y1 + dy, z1 + dz}}]; arrow3d[{x1_, y1_, z1_}, d_] := arrow3d[{{x1, y1, z1}, {x1 + d, y1 + d, z1 + d}}]; arrow3d[{{x1_, y1_, z1_}, {x2_, y2_, z2_}}] := Module[{vector, magnitud, normal, vectornormal, cruz, vectorbinormal}, vector = {x2 - x1, y2 - y1, z2 - z1}; magnitud = Norm[vector]; normal = {0, z1 - z2, y2 - y1}; vectornormal = magnitud*normal/Norm[normal]; cruz = Cross[vector, vectornormal]; vectorbinormal = magnitud*cruz/Norm[cruz]; {Cylinder[{{x1, y1, z1}, {x1, y1, z1} + 0.8 vector}, 0.01 magnitud], Polygon[{{x1, y1, z1} + 0.8 vector + 0.1 vectornormal, {x1, y1, z1} + 0.8 vector - 0.1 vectornormal, {x2, y2, z2}}], Polygon[{{x1, y1, z1} + 0.8 vector + 0.1 vectorbinormal, {x1, y1, z1} + 0.8 vector - 0.1 vectorbinormal, {x2, y2, z2}}]} ]; (* the example below *) Graphics3D[{Sphere[{1, 1, 1}, 0.2], arrow3d[{{1.5, 1, 1}, {2, 2, 2}}], arrow3d[{{1.5, 0, 1}, {-2, -2, 2}}]}, PlotRange -> All] (* hope that helps *) (* Jose *) (* Mexico *) -----Mensaje original----- De: Robert M. Lurie [mailto:RMLURIE@ALUM.MIT.EDU] Enviado el: Viernes, 25 de Abril de 2008 04:28 a.m. Para: mathgroup@smc.vnet.net Asunto: 3D Arrows Apparently Arrows is only a 2D graphic. Is there a way to make an arrow in 3D? Robert M Lurie === Subject: Re: Print[Plot] vs Print[text,Plot]? (*now Do and Table*) > I should notice that it is VERY strange behavour that the simplest > Do[] loop takes MUCH more time than constructing a list of elements > and summing them. I do not understand the reason. It looks like a > defect. > Just try to relax a bit. :D You won't get much out of the system if you're constantly fighting it. === Subject: Re: ? (*now Do and Table*) Hello All, > Just a (tongue in cheek) reminder that Mathematica is a wonderful all > purpose environment in which to do Mathematics. 221 years ago the 10 year old Gauss would have solved the problem by > coding:- > I do know the Gauss story---one version has it that his tutor was becoming tired of his questions and sent him away to give himself an hour of peace; another version is that someone asked him to count objects stacked in the shape of the triangle. I like the first choice much better > Constructing Table takes 429 times more memory than using Do[]! It does point out the there may be relevant computations where Table may be impossible and Do is necessary. > It means that using the += operator takes about 50% more time than > the usual form > icount = icount + i; I am wondering about this. Perhaps in the compiled kernel, Plus is overloaded so that it is much faster when it gets a constant; However, += may need an extra step to determine what is being added added to the lhs. Perhaps the lesson here is not to think about interactions with the kernel is not compiled and gives us an indication to use the Compile function when it might matter very much. === Subject: Re: ? (*now Do and Table*) I get similar results, and yes, that IS disappointing. Timing[icount = 0; Do[icount += i, {i, 1, 10^7, 1}]; icount] {12.8702, 50000005000000} Timing[icount = 0; Do[icount = icount + i, {i, 1, 10^7, 1}]; icount] {8.98683, 50000005000000} 12.87/8.987 1.43207 I almost never use Do, however, so I'm not sure how much I care about this one. Bobby > And I was surprised much more when I have tried the more simple form > of the first expression: Timing[icount = 0; > Do[icount += i, {i, 1, 10000000, 1}]; > icount] > (*this returns > {36.042, 50000005000000} > on my machine*) It means that using the += operator takes about 50% more time than > the usual form > icount = icount + i; > It is sad and very surprising! > Table is usually a better choice than Do, but that is a choice and >> the > language is accommodating enough to allow you to make that choice ; >> and > if you should be curious, to explore. >> _Why_ (or, in what circumstances?) would Table be a better choice >> tha > n Do? >> =9AI appreciate that their logical behavior is similar, and indeed >> they > can be >> coded very similarly. >> I am happy to try to answer. >> I'll take the time to answer at length, because I find that many >> people that I try to help out have similar viewpoints as yours. >> Perhaps, I may have something useful to contribute. >> Primarily, it is a matter of choice and familiarity. =9AAnd they (Table >> and Do) are just about interchangeable, except in a few unusual (and >> technical) cases. =9ATable's advantage is speed and efficiency. (Once I >> asked someone at Wolfram how I should explain this to my students, and >> the kind answer was because Do has to access the =9Amain kernel's >> evaluation loop, and Table doesn't). >> =9AI'll try to demonstrate this as an example. I'll try to explain my >> steps carefully, and I'll avoid the use of #&/.^= syntax. =9AIt took me >> a while to cook this up--I hope that my example doesn't go amiss. >> This is problem with a known simple result, but it will serve: let's >> find the sum of the first 10000000 integers. >> (*let's use a do loop*) >> Timing[ >> =9Aicount = 0; >> =9ADo[icount = icount + i, {i, 1, 10000000, 1}]; >> =9Aicount >> =9A] >> (*this returns {10.2826, 50000005000000} on my machine.*) >> (*10.28 being a measure of how long the computation took to run*) >> (*lets try a table*) >> Timing[ >> =9ATotal[Table[i, {i, 1, 10000000, 1}]] >> =9A] >> (*This returns {3.25516, 50000005000000} on my machine*) >> This is a simple example, but it illustrates the difference nicely. ( >> Personally, I've yet to >> find a case for which I can replace a Do with a Table or similar list >> construct, although I am sure readers of this group could easily >> construct one as a challenge.) >> Another way to think of this is that Mathematica is very good at >> operating on lists. =9ATable and Lists work together nicely, and many of >> the functions like Total are designed to help you make your >> programming easier. >> Now, if you put yourself =9Ain the mind of a beginner who has neither >> seen Do, For, While, or Table. Which style would you recommend based >> on speed alone? =9AWhich style would you recommend on readability alone? >> So, a typical beginning user might find themselves tending to use >> Lists. =9AThey are content for a couple years, but soon master the idea >> so that begin to do what is natural, abbreviate (ASAP, RJ46, LOL, >> AWOL, PM. FM...). =9AThey find shortcuts and optimize their time: >> First attempt may be something like this: >> (*create a list*) >> Table[i,{i,1,10000000}] >> (*horrors, the output is too long, and I know what it might look like >> anyw= > ay*) >> (*they graduate to this*) >> mytable= Table[i,{i,1,1000000}]; >> Total[mytable] >> (* soon they get tired of typing and find an abbreviated version *) >> Total[Table[i,{i,1,1000000}]] >> (* soon they get tired of moving around the screen to type the two >> bracket= > s,*) >> (* so they find another way to do the same thing, no better, arguably >> less readable >> (*at first*) >> Total@Total[Table[i,{i,1,1000000}] >> (*or, depending on where your cursor tends to be sitting*) >> Table[i, {i, 1, 1000000}] // Total >> (*thus they learn a semaphore for analogous constructs*) >> (*but there's more, with ever more symbols, the efficiency and power >> goes*= > ) >> (*up rapidly, but the readability goes down for beginners*) >> (*where you find the happy medium is entirely up to you*) >> In my opinion, this is the fun part of mathematica. I get to decide >> how to share the labor with mathematica, and I get to decide how >> obscure to make my code. =9ASometimes, for my own pleasure, I write it >> as obscurely as possible (and I am no master at this by a long shot). >> If I am writing code that I hope someone else will use and modify, or >> learn from, I try to write as readable as possible. >> -- >> W. Craig Carter > -- DrMajorBob@longhorns.com === Subject: RE: ? (*now Do and Table*) I am Not surprised that a functional-programming and list-oriented language like Mathematica is much slower if you force it to Not to construct a list. Mathematica is made for working with lists, and structures similar to lists, for example evaluate FullForm[{a,b,c}] After that evaluate FullForm[a+b+c] Then you will see the kind of structures that Mathematica uses internally. Therefore the natural behavior of Mathematica is to create lists (and similar structures) Forcing Mathematica to NOT create a list, can make it SLOWER. language (like Mathematica) the Do[] loop IS NOT THE SIMPLEST, as you called it. Perhaps the document in the following links can be interesting for you: http://homepage.cem.itesm.mx/lgomez/matecmatica/funcionalprog.nb http://homepage.cem.itesm.mx/lgomez/matecmatica/fp/fp.html Hope that helps Jose Mexico -----Mensaje original----- De: Alexey Popkov [mailto:popkov@gmail.com] Enviado el: Viernes, 25 de Abril de 2008 04:30 a.m. Para: mathgroup@smc.vnet.net Asunto: ? (*now Do and Table*) I should notice that it is VERY strange behavour that the simplest Do[] loop takes MUCH more time than constructing a list of elements and summing them. I do not understand the reason. It looks like a defect. W_Craig Carter: > > Table is usually a better choice than Do, but that is a choice and the > language is accommodating enough to allow you to make that choice; and > if you should be curious, to explore. > > _Why_ (or, in what circumstances?) would Table be a better choice than Do? > > I appreciate that their logical behavior is similar, and indeed they can be > coded very similarly. I am happy to try to answer. I'll take the time to answer at length, because I find that many > people that I try to help out have similar viewpoints as yours. > Perhaps, I may have something useful to contribute. Primarily, it is a matter of choice and familiarity. And they (Table > and Do) are just about interchangeable, except in a few unusual (and > technical) cases. Table's advantage is speed and efficiency. (Once I > asked someone at Wolfram how I should explain this to my students, and > the kind answer was because Do has to access the main kernel's > evaluation loop, and Table doesn't). I'll try to demonstrate this as an example. I'll try to explain my > steps carefully, and I'll avoid the use of #&/.^= syntax. It took me > a while to cook this up--I hope that my example doesn't go amiss. This is problem with a known simple result, but it will serve: let's > find the sum of the first 10000000 integers. (*let's use a do loop*) > Timing[ > icount = 0; > Do[icount = icount + i, {i, 1, 10000000, 1}]; > icount > ] (*this returns {10.2826, 50000005000000} on my machine.*) > (*10.28 being a measure of how long the computation took to run*) (*lets try a table*) > Timing[ > Total[Table[i, {i, 1, 10000000, 1}]] > ] (*This returns {3.25516, 50000005000000} on my machine*) This is a simple example, but it illustrates the difference nicely. ( > Personally, I've yet to > find a case for which I can replace a Do with a Table or similar list > construct, although I am sure readers of this group could easily > construct one as a challenge.) > Another way to think of this is that Mathematica is very good at > operating on lists. Table and Lists work together nicely, and many of > the functions like Total are designed to help you make your > programming easier. Now, if you put yourself in the mind of a beginner who has neither > seen Do, For, While, or Table. Which style would you recommend based > on speed alone? Which style would you recommend on readability alone? So, a typical beginning user might find themselves tending to use > Lists. They are content for a couple years, but soon master the idea > so that begin to do what is natural, abbreviate (ASAP, RJ46, LOL, > AWOL, PM. FM...). They find shortcuts and optimize their time: First attempt may be something like this: > (*create a list*) Table[i,{i,1,10000000}] (*horrors, the output is too long, and I know what it might look like anyway*) (*they graduate to this*) > mytable= Table[i,{i,1,1000000}]; > Total[mytable] (* soon they get tired of typing and find an abbreviated version *) Total[Table[i,{i,1,1000000}]] (* soon they get tired of moving around the screen to type the two brackets,*) > (* so they find another way to do the same thing, no better, arguably > less readable > (*at first*) > Total@Total[Table[i,{i,1,1000000}] > (*or, depending on where your cursor tends to be sitting*) > Table[i, {i, 1, 1000000}] // Total (*thus they learn a semaphore for analogous constructs*) > (*but there's more, with ever more symbols, the efficiency and power goes*) > (*up rapidly, but the readability goes down for beginners*) > (*where you find the happy medium is entirely up to you*) > In my opinion, this is the fun part of mathematica. I get to decide > how to share the labor with mathematica, and I get to decide how > obscure to make my code. Sometimes, for my own pleasure, I write it > as obscurely as possible (and I am no master at this by a long shot). > If I am writing code that I hope someone else will use and modify, or > learn from, I try to write as readable as possible. > -- W. Craig Carter === Subject: Re: ? (*now Do and Table*) > [...] > Lets try the following: > > mmu = MaxMemoryUsed[]; > Timing[icount = 0; > Do[icount = icount + i, {i, 1, 10000000, 1}]; > icount] > MaxMemoryUsed[] - mmu > > (*This returns > {25.657, 50000005000000} > 1118080 > on my machine*) > > mmu = MaxMemoryUsed[]; > Timing[Total[Table[i, {i, 1, 10000000, 1}]]] > MaxMemoryUsed[] - mmu > > (*This returns > {7.651, 50000005000000} > 479959784 > on my machine but takes much more time because of using PAGEFILE*) > > 479959784/1118080=429.271 > Constructing Table takes 429 times more memory than using Do[]! Of course it does! It has to hold all those numbers! (Why are we shouting?) Daniel Lichtblau Wolfram Research === Subject: Re: Print[Plot] vs Print[text,Plot]? (*now Do and Table*) > And I was surprised much more when I have tried the more simple form > of the first expression: > > Timing[icount = 0; > Do[icount += i, {i, 1, 10000000, 1}]; > icount] > (*this returns > {36.042, 50000005000000} > on my machine*) > > It means that using the += operator takes about 50% more time than > the usual form > icount = icount + i; > It is sad and very surprising! FWIW, Speaking about speed, as a rule of thumb -- or best practice -- one should try to use the functional programming paradigm rather than the procedural one and, above all, use mathematical knowledge and insight. n = 10000000; Timing[icount = 0; Do[icount += i, {i, n}]; icount] (* {18.2542, 50000005000000} *) Timing[icount = 0; Do[icount = icount + i, {i, n}]; icount] (* {11.8114, 50000005000000} *) Timing[Fold[Plus, 0, Range[n]]] (* {5.21385, 50000005000000} *) Timing[Total@Table[i, {i, n}]] (* {3.47212, 50000005000000} *) Timing[Last@Accumulate[Range[n]]] (* {2.89324, 50000005000000} *) Timing[Sum[i, {i, n}]] (* {0.0312, 50000005000000} *) Timing[i (i + 1)/2 /. i -> n] (* {0.000049, 50000005000000} *) >> Table is usually a better choice than Do, but that is a choice and the= > >> language is accommodating enough to allow you to make that choice; and= > >> if you should be curious, to explore. > =9A_Why_ (or, in what circumstances?) would Table be a better choice tha= > n Do? > =9AI appreciate that their logical behavior is similar, and indeed they = > can be > coded very similarly. >> I am happy to try to answer. >> I'll take the time to answer at length, because I find that many >> people that I try to help out have similar viewpoints as yours. >> Perhaps, I may have something useful to contribute. >> Primarily, it is a matter of choice and familiarity. =9AAnd they (Table >> and Do) are just about interchangeable, except in a few unusual (and >> technical) cases. =9ATable's advantage is speed and efficiency. (Once I >> asked someone at Wolfram how I should explain this to my students, and >> the kind answer was because Do has to access the =9Amain kernel's >> evaluation loop, and Table doesn't). >> =9AI'll try to demonstrate this as an example. I'll try to explain my >> steps carefully, and I'll avoid the use of #&/.^= syntax. =9AIt took me >> a while to cook this up--I hope that my example doesn't go amiss. >> This is problem with a known simple result, but it will serve: let's >> find the sum of the first 10000000 integers. >> (*let's use a do loop*) >> Timing[ >> =9Aicount = 0; >> =9ADo[icount = icount + i, {i, 1, 10000000, 1}]; >> =9Aicount >> =9A] >> (*this returns {10.2826, 50000005000000} on my machine.*) >> (*10.28 being a measure of how long the computation took to run*) >> (*lets try a table*) >> Timing[ >> =9ATotal[Table[i, {i, 1, 10000000, 1}]] >> =9A] >> (*This returns {3.25516, 50000005000000} on my machine*) >> This is a simple example, but it illustrates the difference nicely. ( >> Personally, I've yet to >> find a case for which I can replace a Do with a Table or similar list >> construct, although I am sure readers of this group could easily >> construct one as a challenge.) >> Another way to think of this is that Mathematica is very good at >> operating on lists. =9ATable and Lists work together nicely, and many of >> the functions like Total are designed to help you make your >> programming easier. >> Now, if you put yourself =9Ain the mind of a beginner who has neither >> seen Do, For, While, or Table. Which style would you recommend based >> on speed alone? =9AWhich style would you recommend on readability alone? >> So, a typical beginning user might find themselves tending to use >> Lists. =9AThey are content for a couple years, but soon master the idea >> so that begin to do what is natural, abbreviate (ASAP, RJ46, LOL, >> AWOL, PM. FM...). =9AThey find shortcuts and optimize their time: >> First attempt may be something like this: >> (*create a list*) >> Table[i,{i,1,10000000}] >> (*horrors, the output is too long, and I know what it might look like anyw= > ay*) >> (*they graduate to this*) >> mytable= Table[i,{i,1,1000000}]; >> Total[mytable] >> (* soon they get tired of typing and find an abbreviated version *) >> Total[Table[i,{i,1,1000000}]] >> (* soon they get tired of moving around the screen to type the two bracket= > s,*) >> (* so they find another way to do the same thing, no better, arguably >> less readable >> (*at first*) >> Total@Total[Table[i,{i,1,1000000}] >> (*or, depending on where your cursor tends to be sitting*) >> Table[i, {i, 1, 1000000}] // Total >> (*thus they learn a semaphore for analogous constructs*) >> (*but there's more, with ever more symbols, the efficiency and power goes*= > ) >> (*up rapidly, but the readability goes down for beginners*) >> (*where you find the happy medium is entirely up to you*) >> In my opinion, this is the fun part of mathematica. I get to decide >> how to share the labor with mathematica, and I get to decide how >> obscure to make my code. =9ASometimes, for my own pleasure, I write it >> as obscurely as possible (and I am no master at this by a long shot). >> If I am writing code that I hope someone else will use and modify, or >> learn from, I try to write as readable as possible. >> -- >> W. Craig Carter > > === Subject: Re: Print[Plot] vs Print[text,Plot]? > There are a *lot* of extremely useful things New in 6.0 that are very > > much worth the effort to learn. > > Yes, I totally agree. > Yes, I think we can all agree You and I, I'm afraid, just think differently. How dull the world would be if this were not the case. --and can read in the evening, or on my next plane trip, or in the > dentist's waiting room, or during a particularly dull meeting --and can thereby get an _overview_ --- a _roadmap_ -- a _preview_ --- > of these useful new things, to let me know what I need to dig into > further to meet my particular, specific needs as a user (and which of > these I won't immediately need and can ignore). I agree there is a need for such a primer. I wonder if the size of the market would justify the labor and resources of writing it--I don't know. I do recall reading the original Wolfram book cover-to-cover to familiarize myself with the language. It was this reading experience that allowed me to abandon my previously familiar lisp-oriented symbolic language for Mathematica. One day of concentrated reading allowed me to attempt things in Mathematica, that I could have easily done in the language that was familiar to me. I don't think Wolfram has any intention to write a physical book for 6.0. I am of two minds about this: I do think that reflective and effective reading is best done away from the screen which has too many distractions; however, I think the habit of reading paper and ink will continue to diminish and improve our use of resources and eliminate the need for n-th editions. In any case, the original Mathematica book probably weighs less than a kilogram, that I see you can buy for $0.42 a copy. It still contains a useful guide for learning the structure on which 6.0 is built; it can be read in one day. It could be tossed in the recyling bin after a flight. W. Craig Carter PS: I am hoping that my currently immobility, due to a broken leg and newly installed hardware, will soon finish. Becoming more active in this group has been an effective way to stave off the boredom, and helped me think about new problems and solutions. I am very far from being expert, but participating has proved an effective means to improve my skills and, hopefully for my course that relies heavily on Mathematica, teach better. Unfortunately and fortunately, my impending de-incarceration will jolt me back to my regular three 8 hour/day jobs. === Subject: delayed function assignment Äåáò Íáôèçòï[O Tilde][Eth]¬ am trying to integrate the pdf of a chi-square mixture distribution. Éæ define the pdf as [Eth]äæ.b2Û°:= .25 ܡܨ[Eth][ADoubl eDot]æ.b2Ûø:= .5*((1/2^(1/ .b2ܩܩ[Capital UDoubleDot]¯Çáííá[Capita lUHat]±¯.b2[CapitalYAcute]Ü(x^(1/2 - 1)) [ExponentialE]^((-x Ü© 2) + .25*(1/(2*Gamma[1])) [ExponentialE]^((-x Ü©¯.b2Ü©[Ca pitalUDoubleDot]© can then obtaing the cumulative distribution function symbolically áó ÉîÛ±´[CapitalYAcute]º27 5ܡܨ¤[ CapitalAHat]¢é¨Â[Eth]äæ.b2[ CapitalUHat]ø[DifferentialD]x) ÏõôÛ±´[CapitalY Acute].bdܡܨ[Cap italUDoubleDot]¨[Hyphen]°®.b2[Micro][AGra ve]Ü©2.718281828459045`^((-0.5`) x) + 0.5` ÅòæÛ°®[ CenterDot]°·±°¶· 270±±¸¶[Micro]´·[Paragrap h]àÜ ÜÀø[CapitalYAcute][CapitalUDouble Dot]© can get numerical values using for example ÉîÛ.b3±[CapitalYAcute]º27 5ܡܨ- .25 - $Bi(B_0%12 pdf2[x] [DifferentialD]x) ÏõôÛ.b3±[CapitalY Acute].bd°®°°°¸¸ [Micro]¶.b9 Èï÷åöåif I try to define this as a function of the statistic ïâôáéîåäsay ܡܨã[OTi lde]í.b2Ûø:= 1 - .25 - $Bi(B_0%x pdf2[t] [DifferentialD]t) Ôèåî ÉîÛ.b3.b3[CapitalYAcute]º.bd[ATild e]õí.b2Û.b9 ÏõôÛ.b3.b3[CapitalYAcute]2 75ãõí.b2Û.b9 Äïåóî§evaluate. What should I do to obtain the value as output. Ôèáîëó æïyour help Ìåéç === Subject: Re: delayed function assignment ÈåììLeigh, believe you intended to use patterns in your function definitions: [Eth]äæ.b2Ûø] := ..... ãõí.b2Ûø] = .... éîóôåáof [Eth]äæ.b2Ûø ÂÔ[Times]¬ Éî íïóô ãáóåó¬ éô éó âåôôåò ôï õó1/4 instead of 0.25. In this ãáóåthe results are much íïòå óáôéóæùéî[CC edilla] ¨ômy eye). Âåóô [Times]éóèåóCraig .b2°°¸¯´¯.b2leigh : I am trying to integrate the pdf of a chi-square mixture distribution. If I define the pdf as > pdf2[0] := .25 !(pdf2[x] := .5*((1/2^(1/ 2))/Gamma[1/2]) (x^(1/2 - 1)) [ExponentialE]^((-x )/ 2) + .25*(1/(2*Gamma[1])) [ExponentialE]^((-x )/2)) : However if I try to define this as a function of the statistic obtained, say > !(cum2[x] := 1 - .25 - $Bi(B_0%x pdf2[t] [DifferentialD]t) [Hyphen][Hyphen] [Times]® ÃòáéCarter === Subject: Re: delayed function assignment I am trying to integrate the pdf of a chi-square mixture distribution. If I define the pdf as pdf2[0] := .25 !(pdf2[x] := .5*((1/2^(1/ 2))/Gamma[1/2]) (x^(1/2 - 1)) [ExponentialE]^((-x )/ 2) + .25*(1/(2*Gamma[1])) [ExponentialE]^((-x )/2)) I can then obtaing the cumulative distribution function symbolically as In[14]:=!($Bi(Bpdf2[x] [DifferentialD]x) Out[14]=!((-0.25`) 2.718281828459045`^((-0.5`) x) + 0.5` Erf[0.7071067811865476` @x]) I can get numerical values using for example In[31]:=!(1 - .25 - $Bi(B_0%12 pdf2[x] [DifferentialD]x) Out[31]=0.000885691 However if I try to define this as a function of the statistic obtained, say !(cum2[x] := 1 - .25 - $Bi(B_0%x pdf2[t] [DifferentialD]t) Then In[33]:=cum2[9] Out[33]=cum2[9] Doesn't evaluate. What should I do to obtain the value as output. Leigh Èé Ìåéçè¬ believe you are using a version prior to 6.0, you should use the ßÉî[Eth]õôÆï òíwhen copying an expression from a Mathematica notebook to an åíáéclient: select the cell(s) you want to include in your email, then ÷éôèéî ôè*Cell* menu select either *Convert To* or *Display As* and ãèïïóå ªÉî[Eth]õôÆï[O Grave]íª® Æéîáììù¬ ãï[Eth]ù áîpaste as usual. Áó [Eth]ïóôåäI was not able to copy and past without error some åø[Eth]òåóóé[IDouble Dot]î(using Thunderbird email/newsreader client or Google Groups ÷åinterface on Mac OS X). Òåçáòäó ¬ [Hyphen][Hyphen] Êåáî[Hyphen]Íá[OGr ave] === Subject: Re: delayed function assignment I am trying to integrate the pdf of a chi-square mixture distribution. If I define the pdf as pdf2[0] := .25 !(pdf2[x] := .5*((1/2^(1/ 2))/Gamma[1/2]) (x^(1/2 - 1)) [ExponentialE]^((-x )/ 2) + .25*(1/(2*Gamma[1])) [ExponentialE]^((-x )/2)) I can then obtaing the cumulative distribution function symbolically as In[14]:=!($Bi(Bpdf2[x] [DifferentialD]x) Out[14]=!((-0.25`) 2.718281828459045`^((-0.5`) x) + 0.5` Erf[0.7071067811865476` @x]) I can get numerical values using for example In[31]:=!(1 - .25 - $Bi(B_0%12 pdf2[x] [DifferentialD]x) Out[31]=0.000885691 However if I try to define this as a function of the statistic obtained, say !(cum2[x] := 1 - .25 - $Bi(B_0%x pdf2[t] [DifferentialD]t) Then In[33]:=cum2[9] Out[33]=cum2[9] Doesn't evaluate. What should I do to obtain the value as output. [CapitalEth]ìåáóå òåáä ôètutorial on defining functions and the introduction to [Eth]áôôåòîó èôô[Eth]º¯¯òåæå[OGr ave]åîãå®÷[IDoubleD ot]ìæòáí®ã[ IDoubleDot]í¯íáôèåí[ AAcute]ôéãá¯ôõô[IDouble Dot]òéáì¯Äåæ éîéîçÆõî[ATil de]ôéïîó®[EGrav e]ôíì èôô[Eth]º¯¯òåæå[OGr ave]åîãå®÷[IDoubleD ot]ìæòáí®ã[ IDoubleDot]í¯íáôèåí[ AAcute]ôéãá¯ôõô[IDouble Dot]òéáì¯Éîô[O Grave]ïäõãôé[IDoubleDo t]î[Hyphen][CapitalEth]áôôåò[IHat ]ó®èôíì Ôèproper function definition in your application has the form æÛøß:= x áînot æÛø[CapitalYAcute] º.bd ¨Ôèå ìáôôåò èáa different meaning.) === Subject: Change integral variables In Mathematica, how can I change integral variables? For example in integration: Integrate[Sin[Sqrt[x]], x] if I want to use t^2=x to instead x in the integral, how can I achieve this? PS: Does Mathematica have a inertial form of some symbolic command, for instance, the above integration, if I only want an integration form but not an answer, what can I do? === Subject: Cropping a surface to a sphere Is there a simple way to crop a surface to a sphere? For example, consider the surface ContourPlot3D[ -x^4*y^2 + x^2*y^4 + x^4*z^2 - y^4*z^2 - x^2*z^4 + y^2*z^4 == 1, {x, -3, 3}, {y, -3, 3}, {z, -3, 3}, Mesh -> False] It is cropped to a cube (the bounding box) by default. I would like to crop it to a sphere of radius 3 (or some other region). Is there an easy way to do this? I guess that if there really isn't a better way, I could write a polygon cropping function, convert the graphic to Normal[] form, and crop/remove each polygon one by one, but I was hoping for a simpler solution ... (built-in function or existing package). === Subject: Re: 2*m^z - m^z = ? It is, in fact, possible to write a function mySimplify which avoids this particular problem and (I think) gives the same results as Simplify, although it is inevitably a lot slower. Here is the function: SetAttributes[mySimplify, HoldAll] mySimplify[expr_] := Simplify[ReleaseHold[Simplify[Unevaluated[expr] /. x_?NumericQ :> Hold[x]]]] You can check that Table[{2*m^z - m^z, mySimplify[2*m^z - m^z]}, {m, 1, 21}] gives correct answers. It also simplifies other expressions in the expected way: mySimplify[Cos[x]^2 + Sin[x]^2] 1 I am sure mySimplify will not perform well in all sitiations but it maybe a useful alternative to Simplify and perhaps a sophisticated version of it could even be usefully implemented in Mathematica? Andrzej Kozlowski >> What do you think about this: >> Table[ >> {2*m^z - m^z, >> FullSimplify[2*m^z - m^z]}, >> {m, 1, 21}] // TableForm >> The answer is very interesting (only odd numbers are treated well): >> 1 1 >> -2^z + 2^(1 + z) 2^z >> 3^z 3^z >> 2^(1 + 2*z) - 4^z 4^z >> 5^z 5^z >> 2^(1 + z)*3^z - 6^z 2^(1 + z)*3^z - 6^z >> 7^z 7^z >> 2^(1 + 3*z) - 8^z 8^z >> 9^z 9^z >> 2^(1 + z)*5^z - 10^z 2^(1 + z)*5^z - 10^z >> 11^z 11^z >> 2^(1 + 2*z)*3^z - 12^z 2^(1 + 2*z)*3^z - 12^z >> 13^z 13^z >> 2^(1 + z)*7^z - 14^z 2^(1 + z)*7^z - 14^z >> 15^z 15^z >> 2^(1 + 4*z) - 16^z 16^z >> 17^z 17^z >> 2^(1 + z)*9^z - 18^z 2^(1 + z)*9^z - 18^z >> 19^z 19^z >> 2^(1 + 2*z)*5^z - 20^z 2^(1 + 2*z)*5^z - 20^z >> 21^z 21^z >> Can anyone explain the reason for this behavior? > Thera are many such pheonomna in computer algebra. This particular one > I have already once explained on this forum, but as I can't find my > post I will repeat it. The reason why this happens is that Mathematica (and all other > Computer ALgebra Systems) performs certain simplifications, or more > precisely reductions to canonical form automatically, even before > applying Simplify or FullSimplify, simply as part of the evaluation > process. One such simplification that is done automatically is this: 2*6^z > 2^(z + 1)*3^z In other words, Mathematica sees that 6 has 2 as a factor, it factors > it out and combines all factor of 2 into a single power. This is a > typical example of reduction to canonical form. Such reductions make > certian operations much simpler and faster but unfortunately this > particular one does not fit in very well with another reduction that > Mathematica also performs automatically: 2^z*3^z > 6^z Such reductions cannot be undone by Simplify or FullSimplify because > they are performed on evaluation, so even if Simplify undid one of > them, the reduction would be immediately performed again. > Unfortunately these two reductions prevent Simplify and FullSimplify > form seeing that 2^(z + 1)*3^z-6^z can be simplified to 6^z, because Simplify cannot re-write 2^(z + > 1)*3^z as 2*6^z and it also cannot re-write 6^z as 2^z*3^z for reasons > described above. In the example you gave the problem can be easily dealt with by > wrapping Evaluate round the first argument of Table. Table[Evaluate[{2*m^z - m^z, FullSimplify[2*m^z - m^z]}], {m, 1, 21}] However the problem of simplifying p=2*6^z-6^z and similar expressions is harder to deal with. Note that Mathematica > has no difficulty verifying that p == 6^z // Simplify > True so it is only transforming p into 6^z by means of FullSimplify that is > difficult. In fact, I don't think it can be done, without using some > tricks. Here is one such trick. We divide p by 3^z, then FullSimplify > and finally again multiply by 3^z: FullSimplify[[p/3^z]*3^z > 6^z > Andrzej Kozlowski > === Subject: Re: 2*m^z - m^z = ? expressions and such problems occur (see any book on symbolic algebra). There are likely to be such problems in other algebra system although of course not exactly the same one. This particular problem could have been avoided by a different choice of canonical forms. It probably was caused by an oversight but may be bow difficult to fix because quite likely many other simplifications depend on these particular reductions. You seem to take everything in a very literal sense... Demanding comments from Wolfram Research on this forum is not likely to lead to a success. Participation in the MathGroup by Wolfram staff is purely voluntary and unofficial and they respond to posts only if they happen to read them and like to respond to them. Writing that comments are expected and such stuff, is, in my opinion, likely to make them less inclined to do so. If you need technical support or believe you have found a bug, write to Wolfram's Technical Support, not to the MathGroup. Andrzej Kozlowski >> The reason why this happens is that Mathematica (and all other >> Computer ALgebra Systems) I do not agree about all other Computer ALgebra Systems. Try inter > in free Maxima 0.7.5 the following: > 2*6^z-6^z; > and press Enter. > The result is: > 6^z It means that it is specifical Mathematica problem... And comments > from Wolfram Research are expected... In Mathematica: > In[1]:= 2*6^z-6^z > Out[1]= 2^(1+z) 3^z-6^z > And even > In[2]:= FullSimplify[2*6^z-6^z] > Out[2]= 2^(1+z) 3^z-6^z === Subject: Re: ? (*now Do and Table*) Your curious result was Clear[n, result] result = Sum[i (i + 1)/2, {i, 1, 10^7}] 166666716666670000000 In general, the sum is Clear[k, result, n] result = Sum[i (i + 1)/2, {i, 1, n}] 1/6 n (1 + n) (2 + n) If n is the kth power of 10, the factor n causes result to have k trailing zeroes, and the factor (n+1) causes the repetition you noticed, but it also requires (n+2)/6 to be an integer, which occurs when Mod[10^k+2,6]==0. But, modulo 6, we see that 10 is congruent to 4, and 4 is idempotent: Mod[10, 6] 4 Mod[4^2, 6] 4 Union@Table[Mod[10^k, 6], {k, 100}] {4} As a consequence, the pattern you noticed will always appear when n is a power of 10. Table[Mod[10^k, 6], {k, 100}] {4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4} Oops! I almost forgot the final requirement, that (n+2)/6 < n. But that's pretty obvious. Bobby > Craig, Just a (tongue in cheek) reminder that Mathematica is a wonderful all > purpose environment in which to do Mathematics. 221 years ago the 10 year old Gauss would have solved the problem by > coding:- n = 10000000; Timing[total = n (n + 1)/2] {0.000035, 50000005000000} Which is a whole lot faster! I realize that this is not very helpful in deciding usage of Table vs > Do. But the precocious Gauss also might have tried Timing[total = Table[i (i + 1)/2, {i, 10000000}]] {20.46425400000001, {1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66, 78, > 91, <<9999974>>, > 49999885000066, 49999895000055, 49999905000045, 49999915000036, > 49999925000028, 49999935000021, 49999945000015, 49999955000010, > 49999965000006, 49999975000003, 49999985000001, 49999995000000, > 50000005000000}} or better yet Timing[Total[Table[i (i + 1)/2, {i, 10000000}]]] {31.7433, 166666716666670000000} Just to show off ... :) > PS Where would we be now if Stephen Wolfram had provided Gauss with a > free Mathematica License back then? BTW What a surprising result (1666667)(1666667)(0000000) I wonder if anyone has computed this result before and explained its > repetition of the first 7 digits? > Syd Geraghty B.Sc, M.Sc. sydgeraghty@mac.com My System Mathematica 6.0.2.1 for Mac OS X x86 (64 - bit) (March 13, 2008) > MacOS X V 10.5.2 > This is problem with a known simple result, but it will serve: let's >> find the sum of the first 10000000 integers. >> (*let's use a do loop*) >> Timing[ >> icount = 0; >> Do[icount = icount + i, {i, 1, 10000000, 1}]; >> icount >> ] >> (*this returns {10.2826, 50000005000000} on my machine.*) >> (*10.28 being a measure of how long the computation took to run*) >> (*lets try a table*) >> Timing[ >> Total[Table[i, {i, 1, 10000000, 1}]] >> ] >> (*This returns {3.25516, 50000005000000} on my machine*) > -- DrMajorBob@longhorns.com === Subject: Re: Print[Plot] vs Print[text,Plot]? (*now Do and Table*) > (*let's use a do loop*) > Timing[ > =9Aicount = 0; > =9ADo[icount = icount + i, {i, 1, 10000000, 1}]; > =9Aicount > =9A] > (*this returns {10.2826, 50000005000000} on my machine.*) > (*10.28 being a measure of how long the computation took to run*) > (*lets try a table*) > Timing[ > =9ATotal[Table[i, {i, 1, 10000000, 1}]] > =9A] > (*This returns {3.25516, 50000005000000} on my machine*) > W. Craig Carter Lets try the following: mmu = MaxMemoryUsed[]; > Timing[icount = 0; > Do[icount = icount + i, {i, 1, 10000000, 1}]; > icount] > MaxMemoryUsed[] - mmu (*This returns > {25.657, 50000005000000} > 1118080 > on my machine*) mmu = MaxMemoryUsed[]; > Timing[Total[Table[i, {i, 1, 10000000, 1}]]] > MaxMemoryUsed[] - mmu (*This returns > {7.651, 50000005000000} > 479959784 > on my machine but takes much more time because of using PAGEFILE*) 479959784/1118080=429.271 > Constructing Table takes 429 times more memory than using Do[]! The difference in timings is not surprising: in the example with Do the expression icount = icount + i goes through the interpreter 10^7 times, while in the Table example Plus or Total is only interpreted once and then sent to the low-level code, and additionally Table uses autocompilation. The reason for the memory usage difference is less obvious. Since the result of Total is not a machine number (at least on 32-bit machines), the table is being unpacked and then it takes up (20 bytes per element)*10^7. Apparently a copy is created somewhere along the way, which gives the 400Mb memory footprint. I suppose one can imagine a world where Total doesn't unpack a packed array and doesn't create a copy, but in this case you can avoid the problem by using reals, since the result is a machine real: In[1]:= Timing[Total@ Table[i, {i, 1, 10^7, 1.}]] Out[1]= {1.062, 5.0000005*10^13} In[2]:= MaxMemoryUsed[] Out[2]= 86264744 8*10^7 is the size of one packed array of reals. Or you can use Compile and avoid creating any arrays: In[3]:= Timing[Compile[{}, Module[{n = 10^7, s = 0.}, Do[s += i, {i, 10^7}]; s]][]] Out[3]= {0.609, 5.0000005*10^13} Of course then you might get rounding problems if your result doesn't fit in 53 mantissa bits. Maxim Rytin m.r@inbox.ru === Subject: financial chart with volumes are there examples to plot such chart ? http://www.wolfram.com/solutions/finance/images/fibonarcs.gif (the picture is from here: http://www.wolfram.com/solutions/finance/features.html ) === Subject: Re: Problems with NSolve > Hi all > > I am trying to find the number of eigenvalue crossings for a matrix as > a function of the parameter 'u', on which the elements of the > (symmetric) matrix depend on linearly. The matrix elements also > involve randomly chosen constants. The plan is to find the > distribution of the crossings of these type of matrices as I scan over > the random numbers. > > So far I have been using the following : > > NSolve[{chpoly[u, dim, [Alpha], [Gamma], [Epsilon], x] == 0, > D[chpoly[u, dim, [Alpha], [Gamma], [Epsilon], x], x] == 0}, {x, > u}, WorkingPrecision -> prec] > > where chpoly is the characteristic polynomial of the matrix (with the > eigenvalue variable being x) and alpha, gamma and epsilon are > constant parameter arrays of random numbers. For a double (or higher) > degeneracy of the eigenvalues both the characteristic equation and its > derivative should be zero. This approach has worked successfully only > upto 12*12 matrices (where one such computation takes 40 secs on my > laptop). For 13*13 my laptop takes 4000 sec. This seems to be somewhat > surprising, because these polynomials are of the order 'n' (where n > is dimension of the matrix) in both u and x - and n=13 does not sound > very computationally unreasonable. So I was wondering if there was a > faster approach I could take. > > Also, the problem essentially entails me to know the number (not the > values) of the real solutions to this system of polynomials. > CountRoots seemed ideal but it does not work for more than one > equation. So is there any alternative along this route? > > Any other alternatives are also welcome. > Kij. > Could you post, please, a *fully working* example of what you are doing? It is really hard to optimize fuzzy functions (fuzzy not as in fuzzy logic but as in fuzzy definitions or concepts :-) -- === Subject: Re: Problems with NSolve >Hi all I am trying to find the number of eigenvalue crossings for a matrix as >a function of the parameter 'u', on which the elements of the >(symmetric) matrix depend on linearly. The matrix elements also >involve randomly chosen constants. The plan is to find the >distribution of the crossings of these type of matrices as I scan over >the random numbers. So far I have been using the following : NSolve[{chpoly[u, dim, [Alpha], [Gamma], [Epsilon], x] == 0, > D[chpoly[u, dim, [Alpha], [Gamma], [Epsilon], x], x] == 0}, {x, > u}, WorkingPrecision -> prec] where chpoly is the characteristic polynomial of the matrix (with the >eigenvalue variable being x) and alpha, gamma and epsilon are >constant parameter arrays of random numbers. For a double (or higher) >degeneracy of the eigenvalues both the characteristic equation and its >derivative should be zero. This approach has worked successfully only >upto 12*12 matrices (where one such computation takes 40 secs on my >laptop). For 13*13 my laptop takes 4000 sec. This seems to be somewhat >surprising, because these polynomials are of the order 'n' (where n >is dimension of the matrix) in both u and x - and n=13 does not sound >very computationally unreasonable. So I was wondering if there was a >faster approach I could take. Also, the problem essentially entails me to know the number (not the >values) of the real solutions to this system of polynomials. >CountRoots seemed ideal but it does not work for more than one >equation. So is there any alternative along this route? Any other alternatives are also welcome. >Kij. > > I would find it helpful if you specified what chpoly, [Alpha] etc were to help diagnose you're problem. However, it seems you are coming across an issue described in the following thread: http://tinyurl.com/53cp5u I believe there are other threads that discuss this issue as well, but I couldn't find them in a quick search. Carl Woll Wolfram Research === Subject: Re: Enable multicore calculation ? You need to get the personal grid edition to make use of all the cores. I had the same problem with my 4 core G5 Mac Pro (since retired). I believe that Mathematica uses one core for the front end and one for the kernel by default. On a two core system, or even a 4 course system, that is usually sufficient, since one usually has other processes running. However, with an 8 core system, you should look into the personal grid edition to maximize throughput. george > Hello everyone, I'm running Mathematica 6.0.2 on a MacPro with 8 cores. I've noticed > that the kernel only uses 1 core=85 Is it possible to enable multicore > calculations ? === Subject: Re: Enable multicore calculation ? > > I run some larger calculations on Linux with Mathematica 6.0.2.1 and > 8 cores essentially using NDSolve, and these calculations definitly use > usually 4 cores without any interference from my side. Mathematica > seems to detect the multicore environment automatically and the > software acts then accordingly. In a sense I was (positively) surprised. > > However, not everything in Mathematica supports multicore, and it is > my guess and partly my experience that it is mostly (maybe only) > numerical stuff which uses multicores. > I do not have access to any multiprocessor machines which have Mathematica. I am curious: do functions like Map or Inner use multiple processors (in principle it is easy to parallellize these)? More generally, can those functions that call other Mathematica functions use more than one processor? Or is this capability restricted to built-in operations that are implemented at a lower level than the Mathematica language (such as numerical linear algebra)? Is it guaranteed that Map evaluates the elements of a list in order? What about misuses such as the following: a = 123; Map[(a = 100 + Mod[a, #]) &, {5, 6, 7, 8}]; a (Actually this one must be pretty hard to parallellize even if there are no guarantees about evaluation order.) Szabolcs === Subject: Re: Enable multicore calculation ? > I'm running Mathematica 6.0.2 on a MacPro with 8 cores. I've noticed > that the kernel only uses 1 core=85 Is it possible to enable multicore > calculations ? By default, a regular version of Mathematica 6.0.2 for Mac OS X on Intel Mac uses its *multi-threading* capabilities [1]. Which means that some functions (mostly linear algebra) may use extensively more than one core at some point during a computation. Which also means that only a small subset of Mathematica functions have natively multi-threading capabilities and one cannot write one's own parallel/multi-threaded functions with a regular version of Mathematica. To do so, depending of your needs and budget, several solutions are available from WRI [3, 4, 5]. So to see many cores used on one.89¥ús multi-core system, one may try a singular value decomposition or compute eigenvalues on a large numeric matrix. Your mileage may vary, but on my dual-core system, the SVD starts by using mostly only one core, then, after a while both core are used (as hand, the eigenvalues used mostly one core at a time (i.e. starts on one core, then switches to the other, then comes back to the first core). Timing[ SingularValueDecomposition[RandomReal[1, {3000, 3000}]];] (* {105.685, Null} *) Timing[Eigenvalues[RandomReal[1, {2500, 2500}]];] (* {109.357, Null} *) $Version (* 6.0 for Mac OS X x86 (64-bit) (February 7, 2008) *) HTH, [1] http://forums.wolfram.com/mathgroup/archive/2006/Apr/msg00708.html [2] Does Mathematica take advantage of multiple processors? http://support.wolfram.com/mathematica/systems/allplatforms/multipleprocesso rs.en.html [3] Wolfram gridMathematica http://www.wolfram.com/products/gridmathematica/ [4] Wolfram Mathematica Parallel Computing Toolkit http://www.wolfram.com/products/applications/parallel/ [5] Wolfram Mathematica Personal Grid Edition http://www.wolfram.com/products/personalgrid/ === Subject: Re: Coordinate readout from Graphics3D? > I thought I saw somewhere that one could read out coordinates from a > Graphics plot, according to the mouse position. I can't find it now, > and I don't see how it would work with Graphics3D. But anything would See Chris Carlson's Get Coordinates: New in 6.0.2, Wolfram Blog, (March 11, 2008), http://blog.wolfram.com/2008/03/11/get-coordinates-new-in-602/ This blog entry contains numerous interesting examples of various usages of this new function (zooming on a specific part of a plot, computing the area of a polygon, etc.) -- === Subject: Re: ConstantArray and List >Consider the following inputs: In[1]:= ConstantArray[f[], {5}] Out[1]= {f[], f[], f[], f[], f[]} In[2]:= ConstantArray[List[], {5}] During evaluation of In[2]:= ConstantArray::scalar: Argument {} at >position 1 is not a scalar. Out[2]= ConstantArray[{}, {5}] >Why doesn't the second one work? Is this because of the way packed >arrays are handled (just a guess)? >What is the advantage of ConstantArray over Table or Array? It doesn't >seem to be much faster, and it doesn't seem to return an array stored in >a more efficient way (I experimented a little with MemoryInUse[]). > > Try comparing ConstantArray and Table for the creation of very large packed arrays: In[41]:= ConstantArray[0, 10^7]; // Timing Table[0, {10^7}]; // Timing Out[41]= {0.031,Null} Out[42]= {0.531,Null} In[43]:= ConstantArray[1., {10^4, 10^3}]; // Timing Table[1., {10^4}, {10^3}]; // Timing Out[43]= {0.062,Null} Out[44]= {0.531,Null} So, ConstantArray is useful when you want to create a large constant packed array, which you then modify in some way. This approach is very common in Compile code. Another example is: In[51]:= r1 = Table[ConstantArray[i, 10^6], {i, 10}]; // Timing r2 = Table[i, {i, 10}, {10^6}]; // Timing Out[51]= {1.84075*10^-13,Null} Out[52]= {1.844,Null} Out[53]= True although here, I should mention that neither r1 nor r2 are packed. Carl Woll Wolfram Research === Subject: Re: ConstantArray and List > Consider the following inputs: > > In[1]:= ConstantArray[f[], {5}] > > Out[1]= {f[], f[], f[], f[], f[]} > > In[2]:= ConstantArray[List[], {5}] > > During evaluation of In[2]:= ConstantArray::scalar: Argument {} at > position 1 is not a scalar. > > Out[2]= ConstantArray[{}, {5}] > > > Why doesn't the second one work? Is this because of the way packed > arrays are handled (just a guess)? Packed array occurs, if I remember correctly, when the array has more than 250 or more elements. > What is the advantage of ConstantArray over Table or Array? It doesn't > seem to be much faster, and it doesn't seem to return an array stored in > a more efficient way (I experimented a little with MemoryInUse[]). The difference is the building speed of an array for ConstantArray evaluates only once the expression that is going to be present in every entry while Array evaluates the expression for each elements. In the examples below, we can see that building an array of symbols is five times faster, an array of constant integers is up to 30 times faster. In[22]:= ConstantArray[f[], {5000, 5000}] // Timing // First Out[22]= 2.10453 In[23]:= Array[f[], {5000, 5000}] // Timing // First Out[23]= 9.36111 In[24]:= %/%% Out[24]= 4.44809 In[25]:= ConstantArray[1, {5000, 5000}] // Timing // First Out[25]= 0.140288 In[26]:= Array[1, {5000, 5000}] // Timing // First Out[26]= 4.07251 In[27]:= %/%% Out[27]= 29.0296 In[28]:= ConstantArray[1., {5000, 5000}] // Timing // First Out[28]= 0.253713 In[29]:= Array[1., {5000, 5000}] // Timing // First Out[29]= 4.04874 In[30]:= %/%% Out[30]= 15.9579 -- === Subject: Re: Base function >> ((1*12 + 4)*11 + 4)*10 + 4 >> 1804 >> I need help with a function find the Calander base >> Cbase[1804,{12,11,10}] >> out put will be >> {1,4,4,4} > > I don't understand the question. Why shouldn't it return e.g. {1, 3, > 15, 4} ? After all, ((1*12 + 3)*11 + 15)*10 + 4 == 1804 > All right ... Now that I read the other responses, I understand what the question was. But it still wouldn't hurt if you tried to formulate the problem precisely. Maybe it would even lead you to the solution ... I searched Google, Mathworld and Wikipedia for Calander and Calander base, but all I could find is that calander is either a misspelling of calender, which is a machine used in making paper, or an obsolete variation on the spelling of the name of a species of lark. So I still have no clue about where you got this term from. I would be glad if someone could enlighten me. === Subject: Re: Base function > ((1*12 + 4)*11 + 4)*10 + 4 > > 1804 > > I need help with a function find the Calander base > > Cbase[1804,{12,11,10}] > > out put will be > {1,4,4,4} Since the above (incomplete) assignment sounds like homework, I shall suggest, without further explanation, one possible coding for such a function. cBase[d_Integer?NonNegative, l : {a_, b_, c_} /; VectorQ[l, IntegerQ@# && Positive@# &]] := Module[{v = {e, f, g, h}}, v /. ToRules@ Reduce[c (a b e + b f + g) + h == d && And @@ Thread[0 <= v <= 9], Integers]] cBase[1804, {12, 11, 10}] {1, 4, 4, 4} Note that the code above does not attempt to handle in any specific way cases where no solution or multiple solutions may arise. -- === Subject: Re: Base function ((1*12 + 4)*11 + 4)*10 + 4 1804 I need help with a function find the Calander base Cbase[1804,{12,11,10}] out put will be > {1,4,4,4} Tomi Here is an explicit loop approach. calBase[m_, ll_] := Module[{rem = m, div = Apply[Times, ll]}, Append[Table[{quo, rem} = QuotientRemainder[rem, div]; div = div/ll[[j]]; quo, {j, Length[ll]}], rem]] In[25]:= calBase[1804, {12, 11, 10}] Out[25]= {1, 4, 4, 4} While I doubt it matters for the application you intend, there are probably asymptotically faster methods using a divide-and-conquer strategy. Daniel Lichtblau Wolfram Research === Subject: Re: Base function ((1*12 + 4)*11 + 4)*10 + 4 1804 I need help with a function find the Calander base Cbase[1804,{12,11,10}] out put will be >{1,4,4,4} Tomi > > Here is a somewhat inscrutable piece of code to do this: Cbase[n_, base_] := Reverse@Rest[FoldList[QuotientRemainder[First[#1], #2] &, {n}, Append[Reverse@base, n]]][[All, 2]] In[69]:= Cbase[1804, {12, 11, 10}] Out[69]= {1,4,4,4} Carl Woll Wolfram Research === Subject: Re: Wolfram User Interface Research? Is the primary market for Mathematica supposed to be > Mathematica programmers, skilled in the arcana of the > more abstruse parts of Mathematica, or ordinary users > whose primary interests and skills lie in many, many other > fields -- and who want Mathematica to be (for them) just > an easy to learn, easy to use, easy to remember tool? >> Mathematica could not function the way it does unless it satisfied >> both types of users. It has to be powerful enough for professional >> programmers if not for other reason than just the fact that a large >> part of Mathematica itself (and all add on packages) are written in >> the Mathematica programming language. It also has to satisfy enough >> ordinary users for even more obvious reasons. In my opinion it has >> always performed both functions admirably. Fully and totally agree. > These abstruse parts of Mathematica are not obligatory for >> ordinary >> users but for Mathematica programmers and developers (and many >> power >> users) they make life a lot easier. Also agree -- but my expectation would be that there are (or could > be -- > and should be) a *great* many more ordinary users than power users. So it's important for both types that *both* markets be well served -- > and especially the ordinary users, because there are so many more of > them. Getting their $$ is vital to the success of Matheamtica . > The power users > are savvy enough that if Mathematica is very good -- which it is -- > they'll wade > through minor difficulties. The ordinary users won't --- they'll go > elsewhere. Hmm... I did write: It also has to satisfy enough ordinary users for even more obvious reasons. .... And anohter thing: I wonder what entitles you to consider yourself a spokesman for these ordinary users (who are going to go elswhere). Why not just speak for yourself? Judging by quite many ordinary users I known, the views you have been expressing, particularly those on the need for printed software manuals rather make you a memeber of a minority, and moreover a rather rapidly declining one. I for one, really hate printed software manuals. They occupy space, tend to vanish wihtout trace whenever I need them, and most of all, I can never remeber what I read in one of them when I actually try to work on my computer. I love printed books: my several homes, in different parts of the world, are filled with books on literature, history, mathematics etc. in several languages but I have got rid of all my software manuals and do not wish to see another one ever again. Of course I realize that this is only one person's view but so is yours). >> I believe you are familiar with TeX; at least you mention it often >> enough. Do you seriously claim that Mathematica has more of these >> abstruse parts than TeX? Have you ever heard words like TeXPert, >> TexMaster etc? Are you able to program or even understand a set of I'm quite familiar with TeX and can program in it, though I'm not > really a TeXpert. Plain TeX is *much* less complex than Mathematica. > Several decades ago, in fact, the lab I was in had several > secretaries/technical typists in the so-called Reports Group, > several > of whom had not finished high school --- but one could hand a > hand-written draft of a ms to them, full of complex math -- and they'd > turn it into TeX source. TeX is *much* smaller than Mathematica by whatever measure you like > (syntax, > size of code), and very well documented for ordinary or power users > (have a look at Knuth's TeXBook to understand this). You seem to have completely missed my point. You complained about abstruse Mathematica symbols such as @, /@, @@ etc. You seem to be oblivious to the fact that 1. You never need to use them yourself. Each of them can be replaced by a much more readable form. 2. TeX uses special forms such as {,$, &, %, and plenty of even more abstruse instructions. A typical fragment of TeX code looks like this: {xdefasts{}loopifnumn>0xdefasts{asts*}advancen-1repeat } There is no possibility of writing this in any more legible way. Do you still insist that this is simpler than equivalent Mathematica code? Andrzej Kozlowski === Subject: Re: Wolfram User Interface Research? I don't think it matters a whit which produces the longer program, Mathematica or APL. What should matter is: 0. Which application implementation does the better job, including the quality of user interface, ease of teaching/learning the use, giving correct results, etc. 1. Which application requires the least programming time to produce. 2. Which application is easier to maintain over time, especially by somebody knowledgeable in the language but not necessarily already familiar with the internals of the particular application. > > > > > > > > This comment about APL is quite wrong: nothing compelled you to write > > inscrutable single line programs (except maybe in the earliest days, > > when one was sending single lines over a telephone line to a mainframe, > > then waiting for your instruction's turn to get its slice of time and > > have the result sent back and typed at your terminal). > > > With APL then, and with IBM's APL2 now, you MAY, if you wish, write > > overly condensed one-liners. And indeed some APL programmers aimed to > > write as concise a program, all in one line, as they could possibly do. > > >> I'll totally concede your point here. But I don't think it makes > >> my original comment quite wrong, or even wrong at all. > > >> And I'm not attacking APL at all -- a great (if arcane) > >> intellectual achievement in computer science, and maybe > >> a great (if still arcane) tool for certain types of computation. > >> > >> But nonetheless, the arcane symbolic notation used in APL > >> tends to make even multi-line APL programs nearly as > >> inscrutable for all but APL experts. > > > > What's more, many of the combinations of symbols in APL were instantly > > recongnizable to any APL programmer as so-called idioms. > > >> Again, happy to agree. But, there aren't really a lot of > >> APL programmers around, right? -- and I'd bet that > >> they tend to be programmers employed as such, rather > >> than ordinary users from many other fields, who just > >> want to be get some computational task done in the > >> field where their skills primarily lie. > > > > > > For what it's worth, I've recently been re-implementing the functionality of > > our in-house APL application into Mathematica. My colleagues don't know I've > > done this yet -- it's been a home project to get to know the new date and > > time functionality in v6 better. (I don't actually know APL, but their > > documentation is pretty thorough.) > > > > It will be interesting to see which language produces the longer program. > > > > > Luci > > > > > -- Murray Eisenberg murray@math.umass.edu Mathematics & Statistics Dept. Lederle Graduate Research Tower phone 413 549-1020 (H) University of Massachusetts 413 545-2859 (W) 710 North Pleasant Street fax 413 545-1801 Amherst, MA 01003-9305 === Subject: FEM contourplotter - conversion completed The translation of the Fortran IV 1966 finite element contourplot to Mathematica is complete. Those interested in that specialized topic may download a mini test version from http://caswww.colorado.edu/courses.d/IFEM.d/IFEM.Ch27.d/IFEM.Ch27.index.html Click on ContBandPlotterMini.nb link. Download and execute. Self contained data. Tested so far under V4.1, 4.2 & 5.2. Untested under V6.0 as my laptop in Spain lacks it. Test plots take ~0.5 sec on 2.4 GHz MacBook Pro under 5.2. To run under 6.0 set DisplayChannel to Print (see top comment). The original Fortran code was roughly 9000 lines. Code was typical write only thesis spaghetti, with over 1000 GOTOs and (believe it or not) even a PAUSE statement! Mathematica code is about 800 lines. Imperative procedural logic reflects source, but could simplify later conversion to C or assembly. was reduced by deleting 6 element types out of 7, and removing an alternative divide & conquer contourplotting method. (D&C produces higher quality plots but is slower.) Code is slow (about 10K poly/sec) but that is enough for coursework. A C or assembly version will be needed for FEM production work (>=1M poly/sec) at the cost of portability. Worst flaw is the shoddy contour value labeling, done in a hurry. To see what's wrong, try resizing top plot with mouse. Advice on how to fix that mess welcome. newsdbm02.news.prodigy.net!newsdst02.news.prodigy.net!prodigy.com!newscon02. n ews.prodigy.net!prodigy.net!nx01.iad01.newshosting.com!newshosting.com!newsf e ed.icl.net!newsfeed.fjserv.net!newsfeed00.sul.t-online.de!t-online.de!news.b u erger.net!newsfeeds.sol.net!posts.news.twtelecom.net!nnrp3.twtelecom.net!not - for-mail === Subject: Re: How to put text on a curved surface? Inc. Park is needed. I found in that a reason to buy it. I already wanted to do t= hat a long time. For some purposes just using thick lines will be sufficient: Module[{R = 10, r = 3, S, L, edgemul, xmin, xmax, ymin, ymax}, S[u_, v_] := {Cos[u] (R + r Cos[v]), (R + r Cos[v]) Sin[u], r Sin[v]}; L = First@ Cases[ ImportString[ExportString[Mathematica, PDF], PDF], edgemul = Intersection[#, Reverse[#, 2]]&@ Partition[L, 2, 1, {1, 1}]; {{xmin, ymin}, {xmax, ymax}} = {Min /@ #, Max /@ #}&@ Transpose@ L; L = Split[L, !MemberQ[edgemul, {##}]&]; L = Flatten[#, 1]&@ Table[ (1 - t) #[[k]] + t #[[k + 1]], {k, Length@ # - 1}, {t, 0, 1, .1}]& /@ L; Show[ParametricPlot3D[S[u, v], {u, 0, 2 Pi}, {v, 0, 2 Pi}, Graphics3D[{Red, AbsoluteThickness[6], Line@ Transpose@ S[Rescale[#[[All, 1]], {xmin, xmax}, {0, Pi}], Rescale[#[[All, 2]], {ymin, ymax}, {0, Pi/2}] ]& /@ L}], If you don't have any transparency in the graphic and if you bend your head just right, it looks like filled outlines. Maxim Rytin m.r@inbox.ru newsdbm02.news.prodigy.net!newsdst02.news.prodigy.net!prodigy.com!newscon02. n ews.prodigy.net!prodigy.net!newspeer.monmouth.com!newspeer1.nac.net!border2. n ntp.dca.giganews.com!nntp.giganews.com!novia!newsfeeds.sol.net!posts.news.tw t elecom.net!nnrp3.twtelecom.net!not-for-mail === Subject: Re: running a program Inc. Most people run benchmarks to evaluate software, and I honestly think you need to take at least a few weeks to learn Mathematica before you can do that meaningfully. There are a host of issues that can affect the performance of a Mathematica program: Program style, such as use of functional programming Possible need to use the Compile function Avoiding mixed data in arrays so that they pack Ensuring algorithms operate on the right kind of data (for example, inverting a matrix of integers will run much slower than inverting the corresponding real array) ............... Etc etc Of course, if the benchmark was written by someone else, and is initiated by one function call - say bench[] then execute bench[]//Timing Even in that case, you want to ensure that you avoid printing a ridiculously large amount of data to your notebook. Preferably, the benchmark will produce very little output. David Bailey http://www.dbaileyconsultancy.co.uk newsdbm02.news.prodigy.net!newsdst02.news.prodigy.net!prodigy.com!newscon02. n ews.prodigy.net!prodigy.net!border1.nntp.dca.giganews.com!nntp.giganews.com! n x01.iad01.newshosting.com!newshosting.com!198.186.190.247.MISMATCH!news-xxxf e r.readnews.com!news-out.readnews.com!bins2.readnews.com!63.218.45.203.MISMAT C H!newsfeeds.sol.net!posts.news.twtelecom.net!nnrp3.twtelecom.net!not-for-mai l === Subject: Re: Simple Q: How to give computed results from NSolve to Inc. z = x^2 + Sqrt[x*y] /. soln[[1]] 1 + Sqrt[2] Bob Hanlon newsdbm02.news.prodigy.net!newsdst02.news.prodigy.net!prodigy.com!newscon02. n ews.prodigy.net!prodigy.net!news.glorb.com!newshub.sdsu.edu!headwall.stanfor d .edu!newsfeed.stanford.edu!newsfeed.berkeley.edu!ucberkeley!newsfeeds.sol.ne t !posts.news.twtelecom.net!nnrp3.twtelecom.net!not-for-mail === Subject: Re: Inconsistent behavior? Inc. It tries to keep the output to a reasonable length. If you want it expanded, use FunctionExpand. Binomial[n, 6] // FunctionExpand (1/720)*(n - 5)*(n - 4)*(n - 3)* (n - 2)*(n - 1)*n Binomial[n, 7] // FunctionExpand ((n - 6)*(n - 5)*(n - 4)*(n - 3)* (n - 2)*(n - 1)*n)/5040 Bob Hanlon newsdbm02.news.prodigy.net!newsdst02.news.prodigy.net!prodigy.com!newscon02. n ews.prodigy.net!prodigy.net!nx02.iad01.newshosting.com!newshosting.com!newsf e eds.sol.net!posts.news.twtelecom.net!nnrp3.twtelecom.net!not-for-mail === Subject: Re: Colored Output Inc. You could execute both MakeBoxes assignments in order to cover both cases - they will work together quite happily. David Bailey http://www.dbaileyconsultancy.co.uk newsdbm02.news.prodigy.net!newsdst02.news.prodigy.net!prodigy.com!newscon02. n ews.prodigy.net!prodigy.net!nntp1.roc.gblx.net!nntp.gblx.net!nntp.gblx.net!n e wsfeeds.sol.net!posts.news.twtelecom.net!nnrp3.twtelecom.net!not-for-mail === Subject: Re: same input ... different results??? Not sure about what you did, but both sums appear to be identical. For instance (note that I have change the order of the expressions and renamed the second f1 to f2), In[1]:= f1[n1_, n2_, x_, m_, i_, j_, k_] := Exp[I*2*Pi*(m/3*(n1 + n2 - i - 2 j - k) + x*(n2 + i - j - 2 k))] s1 = Sum[f1[n1, n2, x, m, i, j, k], {i, 0, n1}, {j, 0, n2}, {k, 0, n2 + i - j}] f2[n1_, n2_, x_, m_, i_, j_, k_] := Exp[I*2*Pi*(m/3*(n1 + n2 - i - 2 j - k) + x*n2 + x*i - x*j - 2 x*k)] s2 = Sum[f2[n1, n2, x, m, i, j, k], {i, 0, n1}, {j, 0, n2}, {k, 0, n2 + i - j}] Out[2]= ((-(-1)^(1/3))^(-m n2 - 3 n2 x) E^(-(2/3) I m [Pi] + 2/3 I m n1 [Pi] - 2 I [Pi] (-(m/3) - 2 x) - 2 I [Pi] x) (-(((1 - (-1)^((4 m)/3 + (4 m n1)/3 - 4 x - 4 n1 x)) E^((4 I m [Pi])/3 + 2 I [Pi] (-(m/3) - 2 x) + 2 I [Pi] x + 2/3 I [Pi] (2 m + 3 x)))/( 1 - (-1)^( 4/3 (m - 3 x)))) + ((1 - (-1)^((4 m)/3 + (4 m n1)/3 - 4 x - 4 n1 x)) E^((2 I m [Pi])/3 + 2 I [Pi] (-(m/3) - 2 x) + 4 I [Pi] x + 2/3 I [Pi] (2 m + 3 x)))/( 1 - (-1)^( 4/3 (m - 3 x))) + ((1 - (-1)^((4 m)/3 + (4 m n1)/3 - 4 x - 4 n1 x)) E^((4 I m [Pi])/3 + 2 I [Pi] (-(m/3) - 2 x) + 2 I [Pi] x - 2/3 I n2 [Pi] (2 m + 3 x)))/( 1 - (-1)^( 4/3 (m - 3 x))) - ((1 - (-1)^((4 m)/3 + (4 m n1)/3 - 4 x - 4 n1 x)) E^((2 I m [Pi])/3 + 2 I [Pi] (-(m/3) - 2 x) + 4 I [Pi] x - 2/3 I n2 [Pi] (2 m + 3 x)))/( 1 - (-1)^(4/3 (m - 3 x))) + E^(n2 (-(4/3) I m [Pi] - 2 I [Pi] (-(m/3) - 2 x) - 2 I [Pi] x)) (((-1)^(4 x) E^(-(2/3) I (1 + n2) [Pi] (m + 6 x)))/((-1)^( 4 x) - (-1)^(4 m/3) E^(2 I [Pi] (-(m/3) - 2 x))) - ((-1)^( 4/3 (m - 3 x) + 4 x) E^( 2 I [Pi] (-(m/3) - 2 x) - 2/3 I (1 + n2) [Pi] (m + 6 x)) ((-1)^(4/3 (m - 3 x)) E^( 2 I [Pi] (-(m/3) - 2 x)))^n1)/((-1)^( 4 x) - (-1)^(4 m/3) E^(2 I [Pi] (-(m/3) - 2 x)))) - E^((4 I m [Pi])/3 + 2 I [Pi] (-(m/3) - 2 x) + 2 I [Pi] x) (((-1)^(4 x) E^(-(2/3) I (1 + n2) [Pi] (m + 6 x)))/((-1)^( 4 x) - (-1)^(4 m/3) E^(2 I [Pi] (-(m/3) - 2 x))) - ((-1)^( 4/3 (m - 3 x) + 4 x) E^( 2 I [Pi] (-(m/3) - 2 x) - 2/3 I (1 + n2) [Pi] (m + 6 x)) ((-1)^(4/3 (m - 3 x)) E^( 2 I [Pi] (-(m/3) - 2 x)))^n1)/((-1)^( 4 x) - (-1)^(4 m/3) E^(2 I [Pi] (-(m/3) - 2 x)))) + E^((4 I m [Pi])/3 + 2 I [Pi] (-(m/3) - 2 x) + 2 I [Pi] x + 2/3 I [Pi] (2 m + 3 x)) (((-1)^(4 x) E^(-(2/3) I (1 + n2) [Pi] (m + 6 x)))/((-1)^( 4 x) - (-1)^(4 m/3) E^(2 I [Pi] (-(m/3) - 2 x))) - ((-1)^( 4/3 (m - 3 x) + 4 x) E^( 2 I [Pi] (-(m/3) - 2 x) - 2/3 I (1 + n2) [Pi] (m + 6 x)) ((-1)^(4/3 (m - 3 x)) E^( 2 I [Pi] (-(m/3) - 2 x)))^n1)/((-1)^( 4 x) - (-1)^(4 m/3) E^(2 I [Pi] (-(m/3) - 2 x)))) - E^(2/3 I [Pi] (2 m + 3 x) + n2 (-(4/3) I m [Pi] - 2 I [Pi] (-(m/3) - 2 x) - 2 I [Pi] x)) (((-1)^(4 x) E^(-(2/3) I (1 + n2) [Pi] (m + 6 x)))/((-1)^( 4 x) - (-1)^(4 m/3) E^(2 I [Pi] (-(m/3) - 2 x))) - ((-1)^( 4/3 (m - 3 x) + 4 x) E^( 2 I [Pi] (-(m/3) - 2 x) - 2/3 I (1 + n2) [Pi] (m + 6 x)) ((-1)^(4/3 (m - 3 x)) E^( 2 I [Pi] (-(m/3) - 2 x)))^n1)/((-1)^( 4 x) - (-1)^(4 m/3) E^(2 I [Pi] (-(m/3) - 2 x))))))/((-1 + E^(I [Pi] (-(m/3) - 2 x))) (1 + E^( I [Pi] (-(m/3) - 2 x))) (E^((I m [Pi])/3) - E^( I [Pi] x)) (E^((I m [Pi])/3) + E^(I [Pi] x)) (-1 + E^( 1/3 I [Pi] (2 m + 3 x))) (1 + E^(1/3 I [Pi] (2 m + 3 x)))) Out[4]= E^(2 I [Pi] x)/(1 - E^(2 I [Pi] x))^2 + ( 1 - E^(2 I [Pi] x + 2 I n1 [Pi] x))/( 1 - E^(2 I [Pi] x)) - (E^(2 I [Pi] x))^( 1 + n1) (E^(2 I [Pi] x)/(1 - E^(2 I [Pi] x))^2 - 1/(-1 + E^(2 I [Pi] x)) - n1/(-1 + E^(2 I [Pi] x))) + ( 3 (1 - E^(2 I [Pi] x + 2 I n1 [Pi] x)) n2)/( 2 (1 - E^(2 I [Pi] x))) + (E^( 2 I [Pi] x)/(1 - E^(2 I [Pi] x))^2 - (E^(2 I [Pi] x))^( 1 + n1) (E^(2 I [Pi] x)/(1 - E^(2 I [Pi] x))^2 - 1/(-1 + E^(2 I [Pi] x)) - n1/(-1 + E^(2 I [Pi] x)))) n2 + ((1 - E^( 2 I [Pi] x + 2 I n1 [Pi] x)) n2^2)/(2 (1 - E^(2 I [Pi] x))) Out[5]= True -- newsdbm02.news.prodigy.net!newsdst02.news.prodigy.net!prodigy.com!newscon02. n ews.prodigy.net!prodigy.net!nntp1.roc.gblx.net!nntp.gblx.net!nntp.gblx.net!n e wsfeeds.sol.net!posts.news.twtelecom.net!nnrp3.twtelecom.net!not-for-mail === Subject: Re: Simple Q: How to give computed results from NSolve to a new Assuming you use the correct syntax to define the variable z, you just else)via the replacement operator /. as in the following example: In[2]:= {x, y} /. sol[[1]] Out[2]= {1, 2} In[3]:= z = x^2 + Sqrt[x*y] /. sol[[1]] Out[3]= 1 + Sqrt[2] For more information, see http://reference.wolfram.com/mathematica/ref/ReplaceAll.html http://reference.wolfram.com/mathematica/tutorial/ApplyingTransformationRule s.html -- newsdbm02.news.prodigy.net!newsdst02.news.prodigy.net!prodigy.com!newscon02. n ews.prodigy.net!prodigy.net!nntp1.roc.gblx.net!nntp.gblx.net!nntp.gblx.net!n e wsfeeds.sol.net!posts.news.twtelecom.net!nnrp3.twtelecom.net!not-for-mail === Subject: Re: Simple Q: How to give computed results from NSolve to a new Inc. You will find that it is good practice not to use upper case characters as the first character in your variable names. This ensures there will not be conflicts with built in symbols since Mathematica always uses an upper case character for the first character of symbol names. Did you mean x^2+Sqrt[x y] here? z = x^2+Sqrt[x y]/.root will do what you want. newsdbm02.news.prodigy.net!newsdst02.news.prodigy.net!prodigy.com!newscon02. n ews.prodigy.net!prodigy.net!nx02.iad01.newshosting.com!newshosting.com!news- o ut.octanews.net!mauve.octanews.net!newsfeeds.sol.net!posts.news.twtelecom.ne t !nnrp3.twtelecom.net!not-for-mail === Subject: Re: mathematica on macbook... hangs on 5-4 Inc. I have what sounds like a similar problem on my Mac (Mathematica 6.0.0, Mac OS 10.5.2). After I launch Mathematica, the first expression I evaluate can take a long time (comparatively- I don't think it's ever been longer than one minute). I've found that if I manually launch the kernel before evaluating any expressions, this delay is eliminated. For some reason, letting the kernel launch automatically with the first expression I evaluate takes much longer than launching the kernel manually, and then evaluating the first expression. I have no idea why this is. If you find that manually launching the kernel solves your problem, there is a way to set up the kernel to launch automatically whenever you start Mathematica- look in better explanation! -Daniel newsdbm02.news.prodigy.net!newsdst02.news.prodigy.net!prodigy.com!newscon02. n ews.prodigy.net!prodigy.net!nntp1.roc.gblx.net!nntp.gblx.net!nntp.gblx.net!n e wsfeeds.sol.net!posts.news.twtelecom.net!nnrp3.twtelecom.net!not-for-mail === Subject: Re: mathematica on macbook... hangs on 5-4 I am not 100% sure that the following procedure will solve your problem; but, since what you describe is apparently related to some file protection messed up (you should never have to be logged as a ROOT user to run Mathematica!), I would suggest to check the file security first. Utilities), select the hard drive where Mathematica has been installed, then run Verify Disk Permissions. If any errors have been detected during this process, the next step is to run Repair Disk Permissions. Hopefully, Disk Utility will be able to correct all of them. Note that is would be a good idea to have a check on the disk and file system structures (run Verify Disk, and Repair Disk if needed). HTH, -- newsdbm02.news.prodigy.net!newsdst02.news.prodigy.net!prodigy.com!newscon02. n ews.prodigy.net!prodigy.net!newsfeed-00.mathworks.com!panix!newsfeed.stanfor d .edu!newsfeed.berkeley.edu!ucberkeley!newsfeeds.sol.net!posts.news.twtelecom . net!nnrp3.twtelecom.net!not-for-mail === Subject: Re: mathematica on macbook... hangs on 5-4 Inc. This is clearly something that you should address with Wolfram support. Your symptoms suggest that there is something amiss will permissions on your system, but probably the folks on this group setup to yours). Connect with Wolfram support, I am sure that they can help you. Of course you should try all the usual things, such as doing a fresh install of Mathematica and making sure that your system is up-to-date and that your personal account has administrator privileges, and so on.... --David newsdbm02.news.prodigy.net!newsdst02.news.prodigy.net!prodigy.com!newscon02. n ews.prodigy.net!prodigy.net!newspeer.monmouth.com!newspeer1.nac.net!newsfeed s .sol.net!posts.news.twtelecom.net!nnrp3.twtelecom.net!not-for-mail === Subject: Re: What is @@@? More broadly: * Do all the _non-alphabetical_ commands (or symbols, or operators, or abbreviations, or whatever is their proper appellation) like /., a class_? * Does each of these non-alphabetical constructs also have a unique individual name? * Suppose one wanted to get a complete (complete!) list of all of these non-alphabetical constructs, their names, and maybe a brief description of their meaning, to use maybe as a reference list, a crib sheet, or just to see which of them one hasn't learned yet. Where would one go? newsdbm02.news.prodigy.net!newsdst02.news.prodigy.net!prodigy.com!newscon02. n ews.prodigy.net!prodigy.net!news.glorb.com!newsfeeds.sol.net!posts.news.twte l ecom.net!nnrp3.twtelecom.net!not-for-mail === Subject: Re: What is @@@? Inc. what would a class be within mathematica? There is a symbol related to each of them... yes I don't know. What I usually do is to write a short expression that does not evaluated (if in doubt wrap it with Hold) and look at it's input form, e.g.: InputForm[ f @@@ x ] which gives you the full name of the corresponding symbol which you then can look up in the documentation. Of course in some cases like @@@ you will need to either read the corresponding page or at least search it for the string @@@ to find the explanation... hth, albert newsdbm02.news.prodigy.net!newsdst02.news.prodigy.net!prodigy.com!newscon02. n ews.prodigy.net!prodigy.net!news.glorb.com!green.octanews.net!news-out.octan e ws.net!mauve.octanews.net!newsfeeds.sol.net!posts.news.twtelecom.net!nnrp3.t w telecom.net!not-for-mail === Subject: Re: What is @@@? Well, it's no wonder I didn't find it. It is under Operator Input Forms in the Virtual Book, but it turns out that the files are missing! newsdbm02.news.prodigy.net!newsdst02.news.prodigy.net!prodigy.com!newscon02. n ews.prodigy.net!prodigy.net!nx01.iad01.newshosting.com!newshosting.com!newsf e eds.sol.net!posts.news.twtelecom.net!nnrp3.twtelecom.net!not-for-mail === Subject: Re: What is @@@? I remembered that there was a table in the documentation listing all operators in order of decreasing *precedence*. It is very easy to find by searching for precedence in the hand compiled master index of the v5 documentation. But after having searched for 10 minutes, I just don't have any more patience to look it up in the v6 documentation ... So here's the v5 doc link: http://documents.wolfram.com/mathematica/book/section-A.2.7 newsdbm02.news.prodigy.net!newsdst02.news.prodigy.net!prodigy.com!newscon02. n ews.prodigy.net!prodigy.net!news.glorb.com!newsfeeds.sol.net!posts.news.twte l ecom.net!nnrp3.twtelecom.net!not-for-mail === Subject: Re: How to display parameter in animation? newsdbm02.news.prodigy.net!newsdst02.news.prodigy.net!prodigy.com!newscon02. n ews.prodigy.net!prodigy.net!newspeer.monmouth.com!newspeer1.nac.net!newsfeed s .sol.net!posts.news.twtelecom.net!nnrp3.twtelecom.net!not-for-mail === Subject: A problem with solving some nonlinear system Inc. Hi. This is the first posting in this board(in Englsigh?). So, if there is any punctuation error or misunderstood, please let me know. The problem itself is in the book 428p. Introduction to Mathematical Statistics 6E In solving this problem, I've got stuck with this practical problem. To find n and c such that Integrate[f,{z,(c-75)/10/sqrt(n),inf}] = .05 Integrate[f,{z,(c-78)/10/sqrt(n),inf}] = .9 variance = 1 How can I solve this problem in mathematica? or any math-computational program? (e.g. R) newsdbm02.news.prodigy.net!newsdst02.news.prodigy.net!prodigy.com!newscon02. n ews.prodigy.net!prodigy.net!border1.nntp.dca.giganews.com!nntp.giganews.com! p .com!in01.usenetserver.com!news.usenetserver.com!newsfeeds.sol.net!posts.new s .twtelecom.net!nnrp3.twtelecom.net!not-for-mail === Subject: Re: A problem with solving some nonlinear system Inc. I assume that by f you mean the probability density functon of N[0,1]. This is specified by: PDF[ NormalDistribution[0,1] ] this returns a function, you may therefore say: fun1= PDF[ NormalDistribution[0,1] ] The integral of fun1 from -Infinity to x would then be the cumulative distribution function, denoted by: fun2= CDF[ NormalDistribution[0,1] ] the integral of fun1 from x to Infinity would be: 1-fun2[x] Therefore, your problem can be written by: eq={1-fun2[x1]==0.05,1-fun2[x2]==0.9}; t = {x1, x2} /. Solve[eq, {x1, x2}][[1]] this gives: t= {1.64485, -1.28155}, what makes sense. However,if n is a sample count, the final part does not make much sense. We must compute c and n from t: Solve[{(c-75)/10/Sqrt[n],(c-78)/10/Sqrt[n]}==t,{c,n}] hope this helps, Daniel newsdbm02.news.prodigy.net!newsdst02.news.prodigy.net!prodigy.com!newscon02. n ews.prodigy.net!prodigy.net!news.glorb.com!newsfeeds.sol.net!posts.news.twte l ecom.net!nnrp3.twtelecom.net!not-for-mail === Subject: Re: A problem with solving some nonlinear system Inc. we all like to do the home work of students! NSolve[{Integrate[ PDF[NormalDistribution[0, 1], z], {z, (c - 75)/10/Sqrt[n], Infinity}] == 5/100, Integrate[ PDF[NormalDistribution[0, 1], z], {z, (c - 78)/10/Sqrt[n], Infinity}] == 9/10 }, {c, n}] ?? Next time, make your home work *alone* because otherwise you will learn nothing. Jens newsdbm02.news.prodigy.net!newsdst02.news.prodigy.net!prodigy.com!newscon02. n ews.prodigy.net!prodigy.net!border1.nntp.dca.giganews.com!border2.nntp.dca.g i ganews.com!nntp.giganews.com!newspeer1.nac.net!newsfeeds.sol.net!posts.news. t wtelecom.net!nnrp3.twtelecom.net!not-for-mail === Subject: Using ListCorrelate with Inner Inc. I have a matrix of filter vectors h which I would like to ListCorrelate with a column of data vectors d as (pseudocode) r = Inner[ListCorrelate, h, d, Plus]. I haven't been able to write this in a neat form with Inner, which I suspect will also be faster than the below: {l,m,n,o} = {5,5,8,1000}; h = RandomReal[1., {l,m,n}]; d = RandomReal[1., {m,o}]; r = Total /@ Table[ListCorrelate[h[[i, j]], d[[j]]], {i, l}, {j,m}] Art newsdbm02.news.prodigy.net!newsdst02.news.prodigy.net!prodigy.com!newscon02. n ews.prodigy.net!prodigy.net!border1.nntp.dca.giganews.com!border2.nntp.dca.g i ganews.com!nntp.giganews.com!novia!newsfeeds.sol.net!posts.news.twtelecom.ne t !nnrp3.twtelecom.net!not-for-mail === Subject: Re: Using ListCorrelate with Inner Inc. Hi Art, just realized that my wording was a bit sloppy. With argument of Inner, I meant the argument of the first function of Inner. Daniel newsdbm02.news.prodigy.net!newsdst02.news.prodigy.net!prodigy.com!newscon02. n ews.prodigy.net!prodigy.net!border1.nntp.dca.giganews.com!nntp.giganews.com! n x01.iad01.newshosting.com!newshosting.com!newsfeeds.sol.net!posts.news.twtel e com.net!nnrp3.twtelecom.net!not-for-mail === Subject: Re: Using ListCorrelate with Inner Inc. Hi Art, Inner is geared towoards tensor analysis. Its arguments are atomic, not lists. But ListCorrelate needs lists as arguments. You can achieve this e.g. by using MapThread: Total@MapThread[ListCorrelate, {#, d}] & /@ h This may be shorter, but not more readable. hope this helps, Daniel newsdbm02.news.prodigy.net!newsdst02.news.prodigy.net!prodigy.com!newscon02. n ews.prodigy.net!prodigy.net!nntp1.roc.gblx.net!nntp.gblx.net!nntp.gblx.net!n e wsfeeds.sol.net!posts.news.twtelecom.net!nnrp3.twtelecom.net!not-for-mail === Subject: Re: How to put text on a curved surface? Inc. This forum has for a long time been having problems with posts filters. If for some reason the moderator decides not to post your message he will inform you of his reasons. If your message does not appear and you have not been contacted by the moderator you are advised to post it again (or write to the moderator). Several of my recent posts have failed to appear but I only resent post that I feel contain something that is both interesting and has not been posted by anyone else. Otherwise I don't bother. Andrzej Kozlowski [I have noted that posts that contain attachments, html, non-ascii characters, and for some odd reason the letter z in the poster's am attempting to train the filters to stop this. Attachments and html emails will be rejected initially since attachments in posts are not permitted - moderator.] newsdbm02.news.prodigy.net!newsdst02.news.prodigy.net!prodigy.com!newscon02. n ews.prodigy.net!prodigy.net!nx02.iad01.newshosting.com!newshosting.com!newsf e eds.sol.net!posts.news.twtelecom.net!nnrp3.twtelecom.net!not-for-mail Inc. Andrew, Assuming you are using Mathematica Version 6, you could write your function something like the following: f::usage = f[x,y,option] will peform an operation on x and y depending on the option.; fOperation::usage = fOperation [Rule] Plus is an option for f that gives the operation for combining the two arguments.; SyntaxInformation[ f[x_, y_, OptionsPattern[]] := Module[{op}, op = OptionValue[fOperation]; op[x, y] ] Then if the user types f[a] the input appears with a little red caret that indicates more arguments are needed. If evaluated with the wrong number of arguments it just returns unevaluated. If the user uses an incorrect option the default