I came to the conclusion that many problems propagate along several versions. Also, rather often they disappear, and then resurface. Might it help to the developers to fix the bug (or to help them in any other way) if I would also name the concrete version where the bug appeared for the first time? Save them some time? Say, kinda the following: ............................................................................ ... BUG # 101 Integrate: INVALID PAGE FAULT/0167:64607028 BuildNumber=156656 Bug Presence Table: YES 4.1 for Microsoft Windows (November 2, 2000) YES 4.0 for Microsoft Windows (April 21, 1999) YES Microsoft Windows 3.0 (April 25, 1997) NO Windows 387 2.2 (April 9, 1993) BuildNumber 156656 CPU ID AuthenticAMD AMD Athlon(tm) XP 1600+ RAM size 512 Mb Free HDD size 11 Gb OS ID Microsoft Windows 98 4.10.2222 A After about 2 seconds while Mathematica 4.1 is the single running task MATHKERNEL caused an invalid page fault in module MATHDLL.DLL at 0167:64607028 Integrate[(Sqrt[1 + z^3] Log[z])/(1 - (-z)^(1/3)), {z, 0, 1}] The same problem with Integrate[(Sqrt[1 + z^3] Log[z])/(1 - (-z)^(1/4)), {z, 0, 1}] Integrate[(Sqrt[1 + z^3] Log[z])/(1 - (-z)^(1/5)), {z, 0, 1}] Integrate[(Sqrt[1 + z^3] Log[z])/(1 - (-z)^(-1/3)), {z, 0, 1}] Integrate[(Sqrt[1 + z^3] Log[z])/(1 - (-z)^(-1/4)), {z, 0, 1}] Integrate[(Sqrt[1 + z^3] Log[z])/(1 - (-z)^(-1/5)), {z, 0, 1}] ............................................................................ .. Or, to name the versions is not very helpful? (Actually, this version localization might take a tangible amount of time.) Vladimir Bondarenko ==== I don't know whether this is a bug or not, and it seems to me that this is just the sort of situation where we lack a clear definition of what constitutes a bug (Behaviour undesirable to some users? Unintended undesirable behaviour? Easily avoidable undesirable behaviour?). However, I can point out that this behaviour is a universal feature of Mathematica design in analogous cases. The same thing will happen if you replace Sum by Product, Table or Do. Integrate is not a good example because it does not assign values to the variable of integration (it just finds the antiderivative and evaluate limits). NIntegrate would have been a better example, but it actually also does not make assignments to an iterator. So bug or not it seems to be a feature (feature!) of Mathematicas design, more precisely of the way Matheamtica uses iterators. Andrzej Kozlowski Toyama International University JAPAN http://platon.c.u-tokyo.ac.jp/andrzej/ I stumbled across is trying to sum an expression with subscripts. > Anyway: In[1]:= n = 1; In[2]:= Sum[1, {f[x, 1], 1, 3}] > Out[2]= 3 > In[3]:= ?f > In[4]:= Sum[1, {f[x, n], 1, 3}] > Out[4]= 3 > In[5]:= ?f In[6]:= Clear[f]; > In[7]:= Sum[1, {f[x, 1*1], 1, 3}] > Out[7]= 3 > In[8]:= ?f The way that f gets set by the Sum to the final value is a bug is it > not? I would guess that Sum unsets the literal expression f[x, n] or > f[x, 1*1], rather than exactly what it set in the first place. I can > get around this by f[x,n]=. whenever I use it... but I would rather > not have a line with a comment saying Mathematica bug work-around. > Integrate works fine under similar circumstances. Martin ==== > Given a list of integers that generally contains the same number many times, > I'd like to reduce it to a list that just gives me the number/count pairs. > For example, I'd like to convert the list > {1, 1, 1, 1, 1, 2, 2, 2, 4, 4, 4, 4, 4, 4} > into > {{1,5}, {2,3}, (4,6}} l = {1, 1, 1, 1, 1, 2, 2, 2, 4, 4, 4, 4, 4, 4}; Map[{#, Count[l, #]} &, Union[l]] {{1, 5}, {2, 3}, {4, 6}} or see Statistics`DataManipulation` << Statistics`DataManipulation` Frequencies[l] {{5, 1}, {3, 2}, {6, 4}} ...which returns it the other way around... have fun, SteveC steve@fractalus.com fractalus.com/steve ==== >This seems like such a simple thing, yet I've search through the big book >trying to figure it out. Perhaps someone can help me... Given a list of integers that generally contains the same number many times, >I'd like to reduce it to a list that just gives me the number/count pairs. >For example, I'd like to convert the list > {1, 1, 1, 1, 1, 2, 2, 2, 4, 4, 4, 4, 4, 4} >into > {{1,5}, {2,3}, (4,6}} Is there a built-in function to do this? Seems like a histogramming > lst = Table[Random[Integer,{1,4}],{10}]; Look in the index under run length encoding. You will be directed to the function Split {First[#],Length[#]}&/@Split[Sort[lst]] or {#,Count[lst, #]}& /@ Union[lst] or Needs[Statistics`DataManipulation`]; Reverse /@ Frequencies[lst] Bob Hanlon Chantilly, VA USA ==== Bob, list = {1, 1, 1, 1, 1, 2, 2, 2, 4, 4, 4, 4, 4, 4}; Split[list] {First[#], Length[#]} & /@ % {{1, 1, 1, 1, 1}, {2, 2, 2}, {4, 4, 4, 4, 4, 4}} {{1, 5}, {2, 3}, {4, 6}} If your list is not initially in order you will want to use Split[Sort[list]]. David Park djmp@earthlink.net http://home.earthlink.net/~djmp/ Howdy, This seems like such a simple thing, yet I've search through the big book > trying to figure it out. Perhaps someone can help me... Given a list of integers that generally contains the same number > many times, > I'd like to reduce it to a list that just gives me the number/count pairs. > For example, I'd like to convert the list > {1, 1, 1, 1, 1, 2, 2, 2, 4, 4, 4, 4, 4, 4} > into > {{1,5}, {2,3}, (4,6}} Is there a built-in function to do this? Seems like a histogramming Bob H ==== Bob: If the list is sorted, Split will do most of the work for you. (Look it up in the book.) For example: lstone={1,1,1,1,2,2,2,3,3,3,3,3,3,4,4,5,5,5,6}; In[1]:= {#[[1]],Length[#]}&/@Split[lstone] Out[1]= {{1,4},{2,3},{3,6},{4,2},{5,3},{6,1}} If the list is not sorted, Split still does most of the work but you should Sort the list first. For example: lsttwo={1,4,3,2,2,3,4,2,5,4,3,6,5,4,3,2,3,4,3,2,1,5}; In[2]:= {#[[1]],Length[#]}&/@Split[Sort[lsttwo]] Out[2]= {{1,2},{2,5},{3,6},{4,5},{5,3},{6,1}} Hope that helps. Best, Harvey Harvey P. Dale University Professor of Philanthropy and the Law Director, National Center on Philanthropy and the Law New York University School of Law Room 206A 110 West 3rd Street New York, N.Y. 10012-1074 tel: 212-998-6161 fax: 212-995-3149 -----Original Message----- {{1,5}, {2,3}, (4,6}} Is there a built-in function to do this? Seems like a histogramming Bob H ________________________________________________________________________ service. For more information on a proactive anti-virus service working around the clock, around the globe, visit http://www.messagelabs.com ________________________________________________________________________ ==== >Given a list of integers that generally contains the same number many times, >I'd like to reduce it to a list that just gives me the number/count pairs. >For example, I'd like to convert the list > {1, 1, 1, 1, 1, 2, 2, 2, 4, 4, 4, 4, 4, 4} >into > {{1,5}, {2,3}, (4,6}} Try Map[{First#],Length[#]}&,Split[list]] If you want all the numbers on ascending order use Map[{First#],Length[#]}&,Split[Sort[list]]] Dennis ==== Bob, Here are some possibilities: mylist = {1, 1, 1, 1, 1, 2, 2, 2, 4, 4, 4, 4, 4, 4}; In[32]:=Map[{#[[1]], Length[#]} &, Split[mylist]] Out[32]={{1, 5}, {2, 3}, {4, 6}} In[31]:=Split[mylist] /. {x__Integer} :> {First[{x}], Length[{x}]} Out[31]={{1, 5}, {2, 3}, {4, 6}} Cheers, Brian > Howdy, > > This seems like such a simple thing, yet I've search through the big book > trying to figure it out. Perhaps someone can help me... > > Given a list of integers that generally contains the same number many times, > I'd like to reduce it to a list that just gives me the number/count pairs. > For example, I'd like to convert the list > {1, 1, 1, 1, 1, 2, 2, 2, 4, 4, 4, 4, 4, 4} > into > {{1,5}, {2,3}, (4,6}} > > Is there a built-in function to do this? Seems like a histogramming > > Bob H ==== This is a problem given at the 1990 programming competition at the Mathematica conference. The following code, taken from Ilan Vardi's book Computational Recreations in Mathematica will work: In[1]:=Attributes[times]={Flat} General::spell1: Possible spelling error: new symbol name times is similar to existing symbol Times. Out[1] = {Flat} In[2]:= times[{a_,m_},{a_,n_}]:=times[{a,m + n}] In[3]:= RunEncode[x_List]:= List @@ times @@ ({#,1}& /@ x) In[4]:= RunEncode[{1,1,1,1,1,2,2,2,4,4,4,4,4,4}] Out[4] = {{1,5},{2,3},{4,6}} > Howdy, > > This seems like such a simple thing, yet I've search through the big book > trying to figure it out. Perhaps someone can help me... > > Given a list of integers that generally contains the same number many times, > I'd like to reduce it to a list that just gives me the number/count pairs. > For example, I'd like to convert the list > {1, 1, 1, 1, 1, 2, 2, 2, 4, 4, 4, 4, 4, 4} > into > {{1,5}, {2,3}, (4,6}} > > Is there a built-in function to do this? Seems like a histogramming > > Bob H > > ==== What you get is so called roundoff error because all the calculations are done in machine precision (this is the precision you get when you run a program in C with type double variables). Because your problem is badly scaled (you have small and large numbers in the same expression), therefore your roundoff error is not zero. We can scale the problem introducing a new variable, say y, such that, x = y/Sqrt[nitrogen/(k*t)] In[1]:= amu = 1.661*10^-27; nitrogen = 28*amu; k = 1.381*10^-23; t = 1000; In[4]:= expr = 4 Pi ((nitrogen/(2 Pi k t))^(3/2)) x^2 Exp[(-1 nitrogen x^2)/(2 k t)] /. x->y/Sqrt[nitrogen/(k*t)] 2 0.00146422 y Out[4]= ------------- 2 0.5 y E We need to find the value of y corresponding to 11000: In[6]:= y0 = 11000*Sqrt[nitrogen/(k t)] Out[6]= 20.1864 And now we can do the calculation: In[7]:= Integrate[expr, {y, y0, Infinity}] Out[7]= 0. This result is correct when you use machine precision. You cannot get anything better. But in Mathematica you can use arbitrary precision numbers. The question is what precision should be used. Let's look at the value of Exp[-0.5 y^2] at y = y0: In[9]:= Exp[-0.5 y^2] /. y ->y0 -89 Out[9]= 3.26725 10 So it seems that precision 100 should be enough. In[10]:= expr = SetPrecision[expr, 100]; In[11]:= y0 = SetPrecision[y0, 100]; Then we can do the calculations: In[12]:= Integrate[expr, {y, y0, Infinity}] -91 Out[12]= 9.68078067 10 The result is positive (although very small). You can do the same computations with NIntegrate: In[13]:= NIntegrate[expr, {y, y0, Infinity}] -91 Out[13]= 9.68078 10 The obtained result agrees with the previous result. Zbigniew Leyk > I recently had to do an integral which should evaluate to be a very very > small quantity. The function is always positive, but the integral gives me a > negative number. I think this is a malfunction of some sort. Here's the > code: > > amu = 1.661*10^-27 > nitrogen = 28*amu > k = 1.381*10^-23 > t = 1000 > > Integrate[ > 4 Pi ((nitrogen/(2 Pi k t))^(3/2)) x^2 Exp[(-1 nitrogen x^2)/(2 k t)], {x, > 11000, Infinity}] > > Out[13]= -5.878291776559734*10^-16 > > does anyone know why this is happening? i tried NIntegrate instead, but it > said: > > General::unfl: Underflow occurred in computation. > > Steve Story > > > _______________ > > Steve Story > Polymer NEXAFS Research Group > 411B Cox > North Carolina State University > 1-919-515-8147 > sbstory@unity.ncsu.edu > _______________ > ==== because it needed the following 3 header files : mathlink.h , mui.h , unistd.h I found mathlink.h after downloading the whole mathlink but I haven't go a clue about the other two headers.... Can anybody help me????? thanx ==== What I've done so far: I use MathLink to generate and manipulate arrays within C++ and return them to Mathematica in order to speed it up. To achieve that I define a function with several parameters within C++ and call this function from within Mathematica. That works just fine. What I intend to do: When I call a function from Mathematica I would like to hand over one parameter (beside others) which is to be used as the length of the list later on in C++ (dynamic variable). What my problem is: I cannot hand over a parameter value from Mathematica to C++ and use it as the length of the list, but always have to use a fixed value. When I try to make this variable dynamical like this: double **stressstrainarray; // array gener. in C, not from Mathematica stressstrainarray = new double* [time]; //time param. from Mathematica for(i=0;i Identity]]; Then we shift all the plot points so the origin is at {2Pi,0,0}. surface = surface /. {x_?NumberQ, y_?NumberQ, z_?NumberQ} -> {x + 2 Pi, y, z}; Now, we plot the shifted surface and a vertical line at the origin. plot1 = Show[ Graphics3D[ {surface, AbsoluteThickness[2], Red, Line[{{0, 0, -2}, {0, 0, 2}}]}], PlotRange -> {{-4Pi, 4Pi}, {-4Pi, 4Pi}, {-2, 2}}, Boxed -> False, ImageSize -> 400]; This rotates the resulting image. SpinShow[plot1] SelectionMove[EvaluationNotebook[], All, GeneratedCell] FrontEndTokenExecute[OpenCloseGroup] FrontEndTokenExecute[SelectionAnimate] There are other variations depending upon your exact need. The whole process is slightly easier using my DrawGraphics package, at my web site, because the primitive graphics are immediately available for manipulation, there is a DrawingTransform command for mapping plot points, and there is a CustomTicks command for transforming and relabeling ticks. David Park djmp@earthlink.net http://home.earthlink.net/~djmp/ > Might anyone out there know of a method by which I could use the > SurfaceOfRevolution command to rotate a graph about a line that does NOT > pass through the origin? Can such a thing be done?