A128 === Subject: Re: Show[list] does not work You don't give us enough information. You should check what the PlotRange is for each plot, and especially for the first plot. You could try to insert a PlotRange -> All at the end of the Show statement. David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ I am trying to overlay multiple plots using Show[list] where list contains my plots. But the command always draws a blank plot. Can someone let me know why? Venkatesh Ramakrishnan Department of Chemical Sciences Tata Institute of Fundamental Research Mumbai 400005 India === Subject: Re: Difficulties with Re Why don't you use ComplexExpand? ComplexExpand[Re[Exp[(x + I y)^2]]] E^(x^2 - y^2) Cos[2 x y] David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ Of the following two expressions, the first works, while the second doesn't. How does one make it work? Assuming[x > 0 && y > 0, Re[Exp[x + I y]] // Simplify] Assuming[x > 0 && y > 0, Re[Exp[(x + I y)^2]] // Simplify] Aaron === Subject: Re: Difficulties with Re >Of the following two expressions, the first works, while the >second doesn't. How does one make it work? >Assuming[x > 0 && y > 0, Re[Exp[x + I y]] // Simplify] >Assuming[x > 0 && y > 0, Re[Exp[(x + I y)^2]] // Simplify] Is the following adequate for you? In[9]:= Assuming[x > 0 && y > 0, Re[Exp[(x + y I )^2 // Expand]] // Simplify] Out[9]= E^(x^2 - y^2)*Cos[2*x*y] === Subject: Wolfram support website documents deleted It appears that Wolfram has recently redesigned the support.wolfram.com website and a lot of my links are toast. I called Wolfram support and they said that a lot of the older information has been removed or consolidated, or ???. Wow, I was really floored that so much information was just totally removed and no longer accessible to Mathematica users who try to look up information. Has anyone else, noticed having problems looking up things on Wolfram's support web site? Was there any sort of announcement that this was going to or had happened? Gosh, disk space is so cheap these days - why would such a valuable resource to the Mathematica user community be trashed? Does anyone else feel badly about this? Please let Wolfram know how you feel if you do. -Bob === Subject: Re: Wolfram support website documents deleted > It appears that Wolfram has recently redesigned the > support.wolfram.com website and a lot of my links are toast. I called > Wolfram support and they said that a lot of the older information has > been removed or consolidated, or ???. Wow, I was really floored that so much information was just totally > removed and no longer accessible to Mathematica users who try to look > up information. Has anyone else, noticed having problems looking up > things on Wolfram's support web site? Was there any sort of > announcement that this was going to or had happened? Gosh, disk space is so cheap these days - why would such a valuable > resource to the Mathematica user community be trashed? Does anyone else feel badly about this? Please let Wolfram know how > you feel if you do. -Bob > I really worry that the WRI documentation team has become obsessed with form over substance. I guess they would say that the information they removed related to earlier versions - but a lot of it was valuable, and their modern documentation is often too vague or incomplete - which is why people go and mine the old stuff - most of which is still valid. You might want to try GOOGLEing your favourite lost information and selecting the cached version (which usually hangs about for a little while) - then save it for future reference! David Bailey http://www.dbaileyconsultancy.co.uk === Subject: Re: Wolfram support website documents deleted I really worry that the WRI documentation team has become obsessed with > form over substance. I guess they would say that the information they > removed related to earlier versions - but a lot of it was valuable, and > their modern documentation is often too vague or incomplete - which is > why people go and mine the old stuff - most of which is still valid. You might want to try GOOGLEing your favourite lost information and > selecting the cached version (which usually hangs about for a little > while) - then save it for future reference! > There used to be a site that listed those functions that are compilable so that one did not have to weed them out of the Compile[] expression by trial and error. http://support.wolfram.com/mathematica/kernel/Symbols/System/Compile.html I miss that page. === Subject: Interface to Documentation Center As promised above, I have now updated my website to include the information about creating documentation that interfaces with the documentation center. Obviously you use this information at your own risk! My explanation uses my new DebugTrace package as an example, and as I explain on the website, it will probably be convenient to install this temporarily to start from a working example. David Bailey http://www.dbaileyconsultancy.co.uk === Subject: Re: Can nobody help me? Re: selecting a column in a grid A couple of ideas here. First, would a button work? It's not clear to me exactly how your UI works, so I don't know whether a button would interfere with other kinds of selectability. But a button can have the properties of expanding out automatically to the full width of the cell. Unfortunately, it has to be visible to do that, but if this is acceptable for you, it should be a fairly simple solution. Something like this... randomLengthString := StringJoin[Table[a, {RandomInteger[{1, 20}]}]]; Grid[Table[ With[{str = pushed { <> ToString[i] <> , <> ToString[j] <> }}, Button[randomLengthString, Print[str], Background -> White, Appearance -> Palette ]], {i, 5}, {j, 5}], Spacings -> {0, 0}] If that doesn't work for you, then you can calculate the dimensions you're looking for using Rasterize with the RasterSize element. Here's some example code which does exactly this, assigning the list of widths and heights to the appropriate variables... randomLengthString := StringJoin[Table[a, {RandomInteger[{1, 20}]}]]; gr = Grid[Table[randomLengthString, {i, 3}, {j, 5}]]; widths = First /@ Module[{width = Length[gr[[1, 1]]]}, Table[ Rasterize[ gr /. Grid[mat_, opts___] :> Grid[mat[[All, 1 ;; Min[i, width]]], opts], RasterSize], {i, width}]]; heights = Last /@ Module[{height = Length[gr[[1]]]}, Table[ Rasterize[ gr /. Grid[mat_, opts___] :> Grid[mat[[1 ;; Min[i, height]]], opts], RasterSize], {i, height}]] You could, of course, skip the 'heights' calculation if you don't need it. Here's a little visualization to show you how it's picking the numbers. gridlines = {Line[{{#, 0}, {#, Last[heights]}}] & /@ (widths), Line[{{0, #}, {Last[widths], #}}] & /@ (Last[heights] - heights)}; Graphics[{Inset[Rasterize[gr]], gridlines}, ImageSize -> {Last[widths], Last[heights]}, AspectRatio -> Full, PlotRange -> {{0, Last[widths]}, {0, Last[heights]}}] One downside to this method is that it doesn't center the dividing areas betweenthe fields, as you can see from the visualization. John Fultz jfultz@wolfram.com User Interface Group Wolfram Research, Inc. Unfortunately, this approach has a problem for me, and I have to admit I > don't know why it works at all! The following example shows my problem (I think I have adapted your code > to use a user-defined list of data properly): > myData = {{aasdfpppppppppppp, bbbbbbbbb, c}, {dasdf, , f}, > {gasdf, h, i}}; > Dynamic[clickpos] > Grid[Table[DynamicModule[{col = Black, pos = {i, j}}, > EventHandler[Style[myData[[i, j]], FontColor -> Dynamic[col]], > {MouseDown :> (clickpos = pos; col = Red), > MouseUp :> (col = Black)}]], {i, 3}, {j, 3}], > Frame -> All, > BaseStyle -> {Editable -> False, Selectable -> False}] In the grid that results, the cell selection only works if the mouse is > clicked inside the text in the cell, not in any whitespace, and the empty > cell cannot be selected at all. This is a problem for me. But how does it > work anyway? Eventhandler seems to be wrapped around the cell contents, > rather than the cell itself, but why is there a dynamic value of {i,j} > associated with the cell? I assume that it is something to do with the > fact that pos is defined within Dynamic, but how does the code know what > value of {i,j} is associated with each block of displayed text? Is this > some normal behaviour of Table that I was not aware of, and where would I > look to find more information about this behaviour? More to the point, is > there a way of forcing each CELL to take the value of {i,j}, because this > would solve my problem instantly? Incidentally, if you double-click in the empty cell, the whole table goes > blue - why is that? > proving > to be so complicated. > Paul. -----Original Message----- === > Subject: Re: Can nobody help me? Re: selecting a > column in a grid Hi Paul, Cool down ;-) Try this for inspiration: Dynamic[clickpos] > Grid[ > Table[ > DynamicModule[ > {col=Black, pos = {i, j}}, > EventHandler[ > Style[RandomInteger[{0, 1000000}], FontColor -> Dynamic[col]], > {MouseDown :> (clickpos = pos; col = Red), > MouseUp :> (col = Black)} > ] > ], {i, 5}, {j, 5}] > ] >> The key point in this problem is that the columns are not equal widths, >> and in fact are variable width, depending on the particular data >> displayed. So I set ItemSize to automatic, so that each column width is >> defined by the data. The trouble is that MousePosition gives me >> coordinates that are a linear function of the position in the grid, but >> the columns are not linearly spaced in the Grid, so how do I know which >> column the mouse is in? >> I need one of three things, all three of which are beyond my skills: >> 1) I could get the actual values that ItemSize is set to when Automatic >> is used. CurrentValue[ItemSize] doesn't work. Anyone got an alternative? >> 2) I could calculate what values ItemSize will be set to by looking at >> the type and number of characters in each grid cell, knowing the font >> size, font family, cell margins, frame linewidth etc. But I don't have >> access to the information needed - how many pixels does a Courier Size >> 10 n take up? >> 3) I could use EventHandler in a better way. Currently I wrap it around >> the whole Grid, but if I could wrap it around a cell, that would work >> for me. No syntax that I have tried works - should I try using GridBox, >> or is there an obvious better idea? >> Nobody got any ideas at all? What kind of language is this, where you >> can't even select a column in a table? >> Paul. >> -----Original Message----- === >> Subject: selecting a column in a grid >> I have a tricky problem with a graphical user interface. I have a grid >> of data, and I want to be able to MouseClick in the grid to either >> select a row or a column. Using GUIKit, this is trivial, but I want to >> be able to distribute my program using PlayerPro, which won't support >> GUIKit. >> Selecting a row is straightforward using EventHandler and >> EventHandlerScaled, since I know how many rows there are and they are >> all one line in height. However, the column widths change according to >> the data, since I have set ItemSize to Auto. So is there some way of >> retrieving the actual values used in ItemSize, when Auto is used? I have >> tried CurrentValue[ItemSize] in many variations, but it always fails. >> I could, of course, look at the data that will be in the grid, and >> compute the widths of each column accordingly, and synthesize the values >> that ItemSize will take. To do that, though, I would need to know what >> the pixel width of a particular text string will be, which varies with >> font family, size etc. Is there an easy way to do this? This is >> essentially what Mathematica does when ItemSize is set to Auto, but I >> have no idea how to do it myself. >> Currently I have EventHandler wrapped around the whole grid. Is it >> possible to wrap it around each individual cell in a grid? I have tried >> a few ideas, but they don't seem to work. The documentation suggests >> that EventHandler can be wrapped around any expression, but that doesn't >> seem to be the case, or at least the wrapped expression doesn't seem to >> display properly inside other constructs, such as Grid, Column etc. >> Is there some better approach I could take, rather than using >> EventHandler? > All ideas gratefully received. >> Paul. >> Dr. Paul A. Ellsmore >> Nanion Limited >> Oxford Centre for Innovation >> Mill Street >> Oxford >> United Kingdom >> OX2 0JX >> Tel: +44 (0) 1865 811175 >> Fax: +44 (0) 1865 248594 === Subject: Re: Does FindFit really use Norm[] when NormFunction -> Norm? 2009/4/6 Darren Glosemeyer : This has been pointed out to the developer for further consideration. What's happening now is that Norm is getting caught and the internal code > uses default code (mathematically equivalent nonlinear least squares > optimization code) which runs into some complexes in intermediate > calculations. The Abs@Norm or myNorm NormFunction settings do not get caught > and the complexes are not encountered. > then perhaps a default setting of NormFunction -> Automatic or something similar would be less confusing. Szabolcs === Subject: Re: Does FindFit really use Norm[] when NormFunction -> Norm? > [note: message sent to comp.soft-sys.math.mathematica] Today there was a question about fitting complex valued functions > again. It's not difficult to find the answer on MathGroup (posted by > Darren Glosemeyer): > But something doesn't seem to be right here ... Doesn't Norm[] return > a real number, so isn't Abs@Norm[...] really the same as Norm[...]? I > vaguely remembered that I already asked about this, and managed to > find the relevant thread: > But no one has given a definite reply there. So I'll ask again: What > going on? Why does FindFit[..., NormFunction -> Norm] behave > differently from FindFit[..., NormFunction -> myNorm] when myNorm is > defined as myNorm[x___] := Norm[x]? Szabolcs > This has been pointed out to the developer for further consideration. What's happening now is that Norm is getting caught and the internal code uses default code (mathematically equivalent nonlinear least squares optimization code) which runs into some complexes in intermediate calculations. The Abs@Norm or myNorm NormFunction settings do not get caught and the complexes are not encountered. Darren Glosemeyer Wolfram Research === Subject: Re: Partial derivatives for implicit functions === Subject: Does FindFit really use Norm[] when NormFunction -> Norm? Today there was a question about fitting complex valued functions again. It's not difficult to find the answer on MathGroup (posted by Darren Glosemeyer): But something doesn't seem to be right here ... Doesn't Norm[] return a real number, so isn't Abs@Norm[...] really the same as Norm[...]? I vaguely remembered that I already asked about this, and managed to find the relevant thread: But no one has given a definite reply there. So I'll ask again: What going on? Why does FindFit[..., NormFunction -> Norm] behave differently from FindFit[..., NormFunction -> myNorm] when myNorm is defined as myNorm[x___] := Norm[x]? Szabolcs === Subject: Re: Please help, factorisation question > thank you for your solution I regret to say that i had failed to specify that the elements of the list nn are rationals a/b, not integers can you think of a way to modify the algorithm so it gives a result in this case ? > Good day, Let me re-state your problem : given a list of fractions, you want to select which ones can be factored into fractions from the list, and output the many possible decompositions. Assuming you know the greatest exponent allowed for any one rational factor, seems to me you could simply use Reduce to solve your problem. Here is the way I would do it : In[1]:= myFactor[numbers_List, kmax_Integer: 2] := Module[{n,kk,red,tra}, n = Length[numbers]; kk = Array[k, n]; red = Reduce[And @@ ((0 <= # <= kmax) & /@ kk) && (Times @@ (numbers^kk)) == #, kk, Integers] & /@ numbers; tra = Transpose[{numbers, kk /. Solve /@ red}] /. (nn_List /; IntegerQ[nn[[1]]] && Length[nn] == n) :> Transpose@{numbers, nn}; DeleteCases[tra, {_, 0}, 4] /. {{{_, 1}}} -> {} /. {x_, {{{x_, 1}}, y___List}} -> {x, y} ]; In[2]:= s = {5/4, 4/3, 17/12, 5/3, 16/9}; In[3]:= myFactor[s] Out[3]= {{5/4, {}}, {4/3, {}}, {17/12, {}}, {5/ 3, {{5/4, 1}, {4/3, 1}}}, {16/9, {{4/3, 2}}}} One can check that 5/3 = 5/4 * 4/3 and 16*9 = (4/3)^2 are the only factorable fractions, given the input list and the maximum exponent (kmax=2). V.Astanoff === Subject: Wolfram Lightweight Grid Manager--available free to Premier Service subscribers and sites Wolfram Lightweight Grid Manager extends the parallel computing power built in to Mathematica 7, and is freely available to users with Premier Service and to organizations with a site license. This new technology makes it easy for you to discover and run Mathematica computation kernels on your remote hardware. This lends more CPU power to parallel Mathematica tasks, and can make idle hardware and software resources available to your whole workgroup. It can utilize existing clusters, ad hoc grids, or any combination thereof. Simply decide who has access to each machine and how many Mathematica computation kernels each can run. Lightweight Grid Manager's logging tools let you monitor use and look for potential problems, all through a web interface. For more information, or to watch a screencast on Lightweight Grid Manager, visit the product pages: http://www.wolfram.com/lightweightgrid Lightweight Grid Manager requires a Mathematica license and is available for all Mathematica platforms. It is included with gridMathematica Server, is available for other Mathematica licenses as a free benefit of Premier Service, and can be purchased from the Wolfram web store. http://store.wolfram.com/view/app/lightweightgrid NOTE: Mathematica users with Premier Service and site users will receive an email in the next few days with instructions on how to download their free copies. === Subject: Bug in Convolve, version 7 convolution is commutative, f*g == g*f. now consider the 2 calulations, where we simply exchange the first 2 arguments of Convolve: f = UnitBox; Convolve[f[x1], f[x1], x1, x2] Convolve[%, f[x2], x2, x3] Convolve[%, f[x3], x3, x4] Plot[%, {x4, -2, 2}] f = UnitBox; Convolve[f[x1], f[x1], x1, x2] Convolve[f[x2], %, x2, x3] Convolve[f[x3], %, x3, x4] Plot[%, {x4, -2, 2}] wheras the first calculation is correct, the second is obviously wrong. Daniel P.S. i tried this with version 7.0.1 and Windows === Subject: Re: Bug in Convolve, version 7 Hi Daniel, Looks like a genuine bug. I found another one with Convolve: Convolve[Sin[x], Cos[x], x, y] Mathematica thinks it's 0, whereas the integral doesn't converge. Interestingly, it doesn't report a result on the commuted version: Convolve[Cos[x], Sin[x], x, y] convolution is commutative, f*g == g*f. now consider the 2 calulations, where we simply exchange the first 2 arguments of Convolve: f = UnitBox; Convolve[f[x1], f[x1], x1, x2] Convolve[%, f[x2], x2, x3] Convolve[%, f[x3], x3, x4] Plot[%, {x4, -2, 2}] f = UnitBox; Convolve[f[x1], f[x1], x1, x2] Convolve[f[x2], %, x2, x3] Convolve[f[x3], %, x3, x4] Plot[%, {x4, -2, 2}] wheras the first calculation is correct, the second is obviously wrong. Daniel P.S. i tried this with version 7.0.1 and Windows === Subject: Enlarging figure size by Mathematica Enjoying the new image processing capabilities of Mathematica 7 I formed a GraphicsGrid form 12 jpg-figures, 1 MB altogether, and saved the result only to be astonished that it was 12 MB... How can I decrease the size of the result? J=E1nos === Subject: Re: Enlarging figure size by Mathematica Janos, I'm afraid I can't reproduce your results. When I save as JPG a GraphicsGrid of 3x3 identical JPGs it actually reduces in size (with the standard compression ratio setting). I assume that you are talking about the notebook containing those JPGs. In that case it is quite understandable, as this will deal with the uncompressed versions of the images. The same happens when you edit a JPG in Photoshop and save it as a Photoshop native format. > Enjoying the new image processing capabilities of Mathematica 7 I formed a > GraphicsGrid form 12 jpg-figures, 1 MB altogether, and saved the > result only to be astonished that it was 12 MB... > How can I decrease the size of the result? > J=E1nos === Subject: Re: Enlarging figure size by Mathematica a) how has you saved it. As JPEG, portable network graphics, in a notebook, as encapsulate postscript b) the input images where JPEG, that mean lossy compressed by a typical ratio 1:50. Usualy one avoid lossy compression at all especial when you work/image process the images because every evening when you save you work the lossy compression will reduce the quality of the image. Lossy compression is optimized in a way that a human eye will not see it. Any computer algorithm that work with the images will make the artifacts visible. c) save the last image of you processing chain a JPEG. But keep in mind lossy compression is the week version of trash it Jens > Enjoying the new image processing capabilities of Mathematica 7 I formed a > GraphicsGrid form 12 jpg-figures, 1 MB altogether, and saved the > result only to be astonished that it was 12 MB... > How can I decrease the size of the result? > J=E1nos > === Subject: Re: Joust in Mathematica HI, Sweet! Yes, this would be much better than dealing with buttons, much easier to add content too. Now, I would love to see this work in a palette form. Would someone try to make moust work with a cell in a notebook., ie clicking on a child will do an input? Will this support the various typesetting stuff to? A real curb cut for Mathematica that I can === Many of the postings around here (past and present) have been very helpful, and some postings off list. keep it up. And yes, just to make sure there is no confusion in regard to my postings, I enjoy Mathematica 7 overall. === Subject: Re: release memory The total MemoryInUse is about twice SMALLER than the memory used to store the table tbl. THAT is inconsistent. In practical terms I want to be able to make Mathematica re-use that memory, I don't care if it reports it or not. === Subject: Re: complex function fitting? Ned, It looks like Mathematica already can do this: In[673]:= data = Table[{y = RandomComplex[], RandomReal[{0.9, 1.1}] y^2 + RandomReal[{0.9, 1.1}] y + 1 + I}, {20}]; In[672]:= Fit[data, {1, x, x^2}, x] Out[672]= (0.988738 + 0.984148 I) + (1.0509 - 0.0357287 I) x + (1.0156 + 0.0497595 I) x^2 > Does anyone know how I could extend the domain of Mathematica's > function-fitting functions so I can use complex-valued data? === Subject: Re: complex function fitting? Hi Ned, what I said is still valid, by default Mathematica calculates with complex numbers. You must have made another error. Why do you not give a simple complete example? I can not help you without knowing the problem. Here is my working example using NonlinearModelFit: d = Table[{x + I y, Exp[x + y I]}, {x, 0, 1, .1}, {y, 0, 1, .1}]; d = Flatten[d, 1]; pol = NonlinearModelFit[d, {c0 + c1 x + c2 x^2}, {c0, c1, c2}, x] yc = pol[x] /. x -> d[[All, 1]]; ListPlot[{Re[#], Im[#]} & /@ (yc - d[[All, 2]]), PlotRange -> All] Daniel > Just a clarification of my original question: I'm referring to a specific > issue I'm having using the NonlinearModelFit function, which fits lists of > data-points to functions of a type specified by the user (for example, say I > knew that my data fit an exponential equation (it doesn't, by the way, this > is just an example) with x as an independent variable: NonLinearModelFit > could find the constant A in the equation A*e^x that would give the function > that most closely approximated my data). My list of data is complex-valued > (with non-zero imaginary components). Mathematica returned an error message > saying I could only use real numbers. I was wondering whether there was a > way to get around this. > -----Original Message----- === > Subject: Re: complex function fitting? Hi Ned, > Mathematica works by default with complex numbres. E.g. using Fit: > d = Table[{x + I y, Exp[x + y I ]}, {x, 0, 1, .1}, {y, 0, 1, .1}]; > d = Flatten[d, 1]; > pol = Fit[d, {1, x, x^2}, x] > yc = pol /. x -> d[[All, 1]]; > ListPlot[{Re[#], Im[#]} & /@ (yc - d[[All, 2]]), PlotRange -> All] > Daniel > >> Does anyone know how I could extend the domain of Mathematica's >> function-fitting functions so I can use complex-valued data? > -- Daniel Huber Metrohm Ltd. Oberdorfstr. 68 CH-9100 Herisau Tel. +41 71 353 8585, Fax +41 71 353 8907 E-Mail: Internet: === Subject: Re: complex function fitting? Hi Ned, Mathematica works by default with complex numbres. E.g. using Fit: d = Table[{x + I y, Exp[x + y I ]}, {x, 0, 1, .1}, {y, 0, 1, .1}]; d = Flatten[d, 1]; pol = Fit[d, {1, x, x^2}, x] yc = pol /. x -> d[[All, 1]]; ListPlot[{Re[#], Im[#]} & /@ (yc - d[[All, 2]]), PlotRange -> All] Daniel > Does anyone know how I could extend the domain of Mathematica's > function-fitting functions so I can use complex-valued data? > === Subject: Re: complex function fitting? Just a clarification of my original question: I'm referring to a specific issue I'm having using the NonlinearModelFit function, which fits lists of data-points to functions of a type specified by the user (for example, say I knew that my data fit an exponential equation (it doesn't, by the way, this is just an example) with x as an independent variable: NonLinearModelFit could find the constant A in the equation A*e^x that would give the function that most closely approximated my data). My list of data is complex-valued (with non-zero imaginary components). Mathematica returned an error message saying I could only use real numbers. I was wondering whether there was a way to get around this. -----Original Message----- === Subject: Re: complex function fitting? Hi Ned, Mathematica works by default with complex numbres. E.g. using Fit: d = Table[{x + I y, Exp[x + y I ]}, {x, 0, 1, .1}, {y, 0, 1, .1}]; d = Flatten[d, 1]; pol = Fit[d, {1, x, x^2}, x] yc = pol /. x -> d[[All, 1]]; ListPlot[{Re[#], Im[#]} & /@ (yc - d[[All, 2]]), PlotRange -> All] Daniel > Does anyone know how I could extend the domain of Mathematica's > function-fitting functions so I can use complex-valued data? > === Subject: PlotLegends bug? I wanted to export some ListLogLinearPlots with legends (using = PlotLegends package) as images today, but Mathematica exports just blank images (on display the images are OK). Here is example code (in reality I have more curves in one image so I realy need the legends): Needs[PlotLegends`] data = {{16.`, -24.`}, {20.`, -23.`}, {25.`, -22.`}, {31.5`, -21.`}, {40.`, -20.`}, {50.`, -20.`}, {63.`, -19.`}, {80.`, -18.`}, {100.`, -13.`}, {125.`, -12.`}, {160.`, -10.`}, {200.`, -8.`}, {250.`, -6.`}, {315.`, -5.`}, {400.`, -3.`}, {500.`, -2.`}, {630.`, -1.`}, {800.`, -0.5`}, {1000.`, 0.`}, {1250.`, -0.5`}, {1600.`, -0.5`}, {2000.`, -1.`}, {2500.`, -1.5`}, {3150.`, -2.5`}, {4000.`, -3.5`}, {5000.`, -5.`}, {6300.`, -6.5`}, {8000.`, -8.`}, {10000.`, -10.`}, {12500.`, -12.`}, {16000.`, -14.`}, {20000.`, -15.`}, {25000.`, -17.`}, {31500.`, -19.`}, {40000.`, -20.`}, {50000.`, -21.`}, {63000.`, -22.`}, {80000.`, -23.`}, {100000.`, -24.`}}; image = ListLogLinearPlot[data, Joined -> True, InterpolationOrder -> 2, GridLines -> Automatic, LegendPosition -> {1.1, -0.4}, AxesLabel -> {Style[f [Hz], Bold, 18], Style[!(*SubscriptBox[A, u]) [dB], Bold, 18]}, LabelStyle -> Medium, PlotLegend -> Style[data, Bold, 18], PlotStyle -> Thick, LegendSize -> 0.5, ImageSize -> {1000, 600}] Export[image.png, image] If I comment out all the options related to PlotLegends, the Export = works just fine: image = ListLogLinearPlot[data, Joined -> True, InterpolationOrder -> 2, GridLines -> Automatic, (*LegendPosition->{1.1,-0.4},*) AxesLabel -> {Style[f [Hz], Bold, 18], Style[!(*SubscriptBox[A, u]) [dB], Bold, 18]}, LabelStyle -> Medium, (*PlotLegend->Style[data,Bold,18],*) PlotStyle -> Thick, (*LegendSize->0.5,*) ImageSize -> {1000, 600}] Export[image.png, image] Also it is not possible to Ctrl-C the image from the screen and paste it = to the image editor (the pasted result is also blank). Does somebody see any bug in my code or there is the bug in PlotLegends package? Jakub === Subject: Re: PlotLegends bug? Jakub, It works fine on my PC. What system and version are you using? > I wanted to export some ListLogLinearPlots with legends (using = > PlotLegends > package) as images today, but Mathematica exports just blank images (on > display the images are OK). Here is example code (in reality I have more > curves in one image so I realy need the legends): > Needs[PlotLegends`] > data = {{16.`, -24.`}, {20.`, -23.`}, {25.`, -22.`}, {31.5`, -21.`}, > {40.`, -20.`}, {50.`, -20.`}, {63.`, -19.`}, {80.`, -18.`}, {100.`, > -13.`}, {125.`, -12.`}, {160.`, -10.`}, {200.`, -8.`}, {250.`, -6.`}, > {315.`, -5.`}, {400.`, -3.`}, {500.`, -2.`}, {630.`, -1.`}, {800.`, > -0.5`}, {1000.`, > 0.`}, {1250.`, -0.5`}, {1600.`, -0.5`}, {2000.`, -1.`}, {2500.`, = > -1.5`}, {3150.`, -2.5`}, {4000.`, -3.5`}, {5000.`, -5.`}, {6300.`, > -6.5`}, {8000.`, -8.`}, {10000.`, -10.`}, {12500.`, -12.`}, {16000.`, > -14.`}, {20000.`, -15.`}, {25000.`, -17.`}, {31500.`, -19.`}, > {40000.`, -20.`}, {50000.`, -21.`}, {63000.`, -22.`}, {80000.`, > -23.`}, {100000.`, -24.`}}; > image = ListLogLinearPlot[data, > Joined -> True, > InterpolationOrder -> 2, > GridLines -> Automatic, > LegendPosition -> {1.1, -0.4}, > AxesLabel -> {Style[f [Hz], Bold, 18], > Style[!(*SubscriptBox[A, u]) [dB], Bold, 18]}, > LabelStyle -> Medium, > PlotLegend -> Style[data, Bold, 18], > PlotStyle -> Thick, > LegendSize -> 0.5, > ImageSize -> {1000, 600}] > Export[image.png, image] If I comment out all the options related to PlotLegends, the Export = > works > just fine: image = ListLogLinearPlot[data, > Joined -> True, > InterpolationOrder -> 2, > GridLines -> Automatic, > (*LegendPosition->{1.1,-0.4},*) > AxesLabel -> {Style[f [Hz], Bold, 18], > Style[!(*SubscriptBox[A, u]) [dB], Bold, 18]}, > LabelStyle -> Medium, > (*PlotLegend->Style[data,Bold,18],*) > PlotStyle -> Thick, > (*LegendSize->0.5,*) > ImageSize -> {1000, 600}] > Export[image.png, image] Also it is not possible to Ctrl-C the image from the screen and paste it = = > to > the image editor (the pasted result is also blank). > Does somebody see any bug in my code or there is the bug in PlotLegends > package? > Jakub === Subject: Re: PlotLegends bug? let me guess, you are using Mathematica 6.0 with the broken PNG export ? Just save TIF or an other bitmap format and it will work. Jens > I wanted to export some ListLogLinearPlots with legends (using = > PlotLegends > package) as images today, but Mathematica exports just blank images (on > display the images are OK). Here is example code (in reality I have more > curves in one image so I realy need the legends): > Needs[PlotLegends`] > data = {{16.`, -24.`}, {20.`, -23.`}, {25.`, -22.`}, {31.5`, -21.`}, > {40.`, -20.`}, {50.`, -20.`}, {63.`, -19.`}, {80.`, -18.`}, {100.`, > -13.`}, {125.`, -12.`}, {160.`, -10.`}, {200.`, -8.`}, {250.`, -6.`}, > {315.`, -5.`}, {400.`, -3.`}, {500.`, -2.`}, {630.`, -1.`}, {800.`, > -0.5`}, {1000.`, > 0.`}, {1250.`, -0.5`}, {1600.`, -0.5`}, {2000.`, -1.`}, {2500.`, > -1.5`}, {3150.`, -2.5`}, {4000.`, -3.5`}, {5000.`, -5.`}, {6300.`, > -6.5`}, {8000.`, -8.`}, {10000.`, -10.`}, {12500.`, -12.`}, {16000.`, > -14.`}, {20000.`, -15.`}, {25000.`, -17.`}, {31500.`, -19.`}, > {40000.`, -20.`}, {50000.`, -21.`}, {63000.`, -22.`}, {80000.`, > -23.`}, {100000.`, -24.`}}; > image = ListLogLinearPlot[data, > Joined -> True, > InterpolationOrder -> 2, > GridLines -> Automatic, > LegendPosition -> {1.1, -0.4}, > AxesLabel -> {Style[f [Hz], Bold, 18], > Style[!(*SubscriptBox[A, u]) [dB], Bold, 18]}, > LabelStyle -> Medium, > PlotLegend -> Style[data, Bold, 18], > PlotStyle -> Thick, > LegendSize -> 0.5, > ImageSize -> {1000, 600}] > Export[image.png, image] If I comment out all the options related to PlotLegends, the Export = > works > just fine: image = ListLogLinearPlot[data, > Joined -> True, > InterpolationOrder -> 2, > GridLines -> Automatic, > (*LegendPosition->{1.1,-0.4},*) > AxesLabel -> {Style[f [Hz], Bold, 18], > Style[!(*SubscriptBox[A, u]) [dB], Bold, 18]}, > LabelStyle -> Medium, > (*PlotLegend->Style[data,Bold,18],*) > PlotStyle -> Thick, > (*LegendSize->0.5,*) > ImageSize -> {1000, 600}] > Export[image.png, image] Also it is not possible to Ctrl-C the image from the screen and paste it = > to > the image editor (the pasted result is also blank). > Does somebody see any bug in my code or there is the bug in PlotLegends > package? > Jakub > === Subject: Re: PlotLegends bug? > I wanted to export some ListLogLinearPlots with legends (using = > PlotLegends > package) as images today, but Mathematica exports just blank images (on > display the images are OK). Here is example code (in reality I have more > curves in one image so I realy need the legends): > Needs[PlotLegends`] > data = {{16.`, -24.`}, {20.`, -23.`}, {25.`, -22.`}, {31.5`, -21.`}, > {40.`, -20.`}, {50.`, -20.`}, {63.`, -19.`}, {80.`, -18.`}, {100.`, > -13.`}, {125.`, -12.`}, {160.`, -10.`}, {200.`, -8.`}, {250.`, -6.`}, > {315.`, -5.`}, {400.`, -3.`}, {500.`, -2.`}, {630.`, -1.`}, {800.`, > -0.5`}, {1000.`, > 0.`}, {1250.`, -0.5`}, {1600.`, -0.5`}, {2000.`, -1.`}, {2500.`, = > -1.5`}, {3150.`, -2.5`}, {4000.`, -3.5`}, {5000.`, -5.`}, {6300.`, > -6.5`}, {8000.`, -8.`}, {10000.`, -10.`}, {12500.`, -12.`}, {16000.`, > -14.`}, {20000.`, -15.`}, {25000.`, -17.`}, {31500.`, -19.`}, > {40000.`, -20.`}, {50000.`, -21.`}, {63000.`, -22.`}, {80000.`, > -23.`}, {100000.`, -24.`}}; > image = ListLogLinearPlot[data, > Joined -> True, > InterpolationOrder -> 2, > GridLines -> Automatic, > LegendPosition -> {1.1, -0.4}, > AxesLabel -> {Style[f [Hz], Bold, 18], > Style[!(*SubscriptBox[A, u]) [dB], Bold, 18]}, > LabelStyle -> Medium, > PlotLegend -> Style[data, Bold, 18], > PlotStyle -> Thick, > LegendSize -> 0.5, > ImageSize -> {1000, 600}] > Export[image.png, image] If I comment out all the options related to PlotLegends, the Export = > works > just fine: image = ListLogLinearPlot[data, > Joined -> True, > InterpolationOrder -> 2, > GridLines -> Automatic, > (*LegendPosition->{1.1,-0.4},*) > AxesLabel -> {Style[f [Hz], Bold, 18], > Style[!(*SubscriptBox[A, u]) [dB], Bold, 18]}, > LabelStyle -> Medium, > (*PlotLegend->Style[data,Bold,18],*) > PlotStyle -> Thick, > (*LegendSize->0.5,*) > ImageSize -> {1000, 600}] > Export[image.png, image] Also it is not possible to Ctrl-C the image from the screen and paste it = = > to > the image editor (the pasted result is also blank). > Does somebody see any bug in my code or there is the bug in PlotLegends > package? > Jakub On OS X 10.5.6 your graphic rendered with a legend and I was able to right click and select Copy Graphic and paste the graphic into Preview. Export[image.png, image] also worked fine so maybe this is something platform specific. Mike === > I haven't had fun like this since I typed in Barnley's original Byte > The Fern just blew me away > back then! Today this affine rearranged Sierpinski gasket is great work. > http://www.geocities.com/rlbagulatftn/barnsley_affine123.gif > http://www.geocities.com/rlbagulatftn/barnsley_affine_234.gif > http://www.geocities.com/rlbagulatftn/barnsley_affine_134.gif http://www.maa.org/pubs/monthly_apr09_toc.html > April 2009 *Transformations Between Self-Referential Sets* > By: Michael F. Barnsley > mbarnsley@aol.com fern onto a filled square? Also, there are functions of a similar wild > character that map from a filled triangle onto itself. We prove that > these /fractal transformations/ may be homeomorphisms, under simple > conditions, and that they may be calculated readily by means of a > coupled Chaos Game. We illustrate several examples of these beautiful > functions and show how they exemplify basic notions in topology, > probability, analysis, and geometry. Thus they are worthy of the > attention of the mathematics community, both for aesthetic and > pedagogical reasons. Mathematica: > Clear[f, dlst, pt, cr, ptlst, M, p, a, b, c] > n0 = 3; > dlst = Table[ Random[Integer, {1, n0}], {n, 100000}]; > a = 0.65; b = 0.3; c = 0.4; > M = {{{-1 + b, -1/2 + b/2 + a/2}, {0, a}}, {{b + c/ > 2 - 1/2, b/2 - c/4 + 1/4}, {1 - c, c/2 - 1/2}}, {{c/2, -1/2 + a/2 - > c/4}, {-c, -1 + a + c/2}}, {{b + c/2 - 1/2, -3/4 + b/4 + a/2 - 1/4}, { > 1 - c, a - 1/2 - c/4}}} > in = {{1 - b, 0}, {1 - b, 0}, {1/2, 1}, {1 - b, 0}}; > Length[in] > f[j_, {x_, y_}] := M[[j]]. {x, y} + in[[j]] > pt = {0.5, 0.5}; > cr[n_] := Flatten[Table[If[i == j == k == 1, {}, RGBColor[i, j, k]], {i, 0, > 1}, {j, 0, 1}, {k, 0, 1}]][[1 + Mod[n, 7]]]; > ptlst[n_] := Table[{cr[dlst[[j]]], Point[pt = f[dlst[[j]], Sequence[pt]]]}, > {j, Length[dlst]}]; > Show[Graphics[Join[{PointSize[.001]}, > ptlst[n]]], AspectRatio -> Automatic, PlotRange -> All] Roger, Which parameter do you vary to go between the two types of fractal - your calculation takes a bit too long to figure this out by guesswork! David Bailey http://www.dbaileyconsultancy.co.uk === > >Roger, Which parameter do you vary to go between the two types of fractal - >your calculation takes a bit too long to figure this out by guesswork! David Bailey >http://www.dbaileyconsultancy.co.uk > David Bailey You can speed it up by changing: dlst = Table[ Random[Integer, {1, n0}], {n, 100000}]; to dlst = Table[ Random[Integer, {1, n0}], {n, 25000}]; I use a and b and c instead. Besides the Sierpinski gasket a=b=c=1/2 special symmetrical form there is this one a=b=c=1/3 and the a=b=c=2/3 with is the same one rotated. http://www.geocities.com/rlbagulatftn/triangle3rdsaffine.jpg The code here is very slow for the better graphics: remove one zero for a fast result. Clear[f, dlst, pt, cr, ptlst, M, p, a, b, c, x0, x, y] n0 = 3; dlst = Table[ Random[Integer, {1, n0}], {n, 250000}]; rotate[theta_] := {{Cos[theta], -Sin[theta]}, {Sin[theta], Cos[theta]}}; a = b = c = N[1/3] M = {{{-1 + b, -1/2 + b/2 + a/2}, {0, a}}, {{b + c/2 - 1/2, b/2 - c/4 + 1/4}, {1 - c, c/2 - 1/2}}, {{c/2, -1/2 + a/ 2 - c/4}, {-c, -1 + a + c/2}}} a0 = Table[Det[M[[i]]], {i, 1, 3}] Apply[Plus, a0] in = {{1 - b, 0}, {1 - b, 0}, {1/2, 1}}; Length[in] f[j_, {x_, y_}] := M[[j]]. {x, y} + in[[j]] pt = {0.5, 0.5}; cr[n_] := Flatten[Table[If[i == j == k == 1, {}, RGBColor[i, j, k]], { i, 0, 1}, {j, 0, 1}, {k, 0, 1}]][[1 + Mod[n, 7]]]; ptlst[n_] := Table[{cr[dlst[[j]]], Point[pt = f[dlst[[j]], Sequence[pt]]]}, {j, Length[dlst]}]; Show[Graphics[Join[{PointSize[.001]}, ptlst[n]]], AspectRatio -> Automatic, PlotRange -> All] === Subject: Palette Editor?? I am curious if anyone ever made a palette editor within Mathematica? It seems doable, yes? And it would make things go much faster ;-) === Subject: Hyperlinks Hyperlinks in notebooks can only link to tagged cells in the notebook or to URLs on the web, or so it seems. I would find it useful to be able to link to an external file (not a notebook nor a text file) and having the file opened by the default external application that handles the given file type. Would it be possible to implement this, maybe programmatically (functions sending commands to the operating system ? Applescript ?) ? A. Berkani === Subject: Re: Hyperlinks > Hyperlinks in notebooks can only link to tagged cells in the notebook or to > URLs on the web, or so it seems. > I would find it useful to be able to link to an external file (not a > notebook nor a text file) and having the file opened by the default external > application that handles the given file type. > Would it be possible to implement this, maybe programmatically (functions > sending commands to the operating system ? Applescript ?) ? Have you tried the standard way to encode local filenames as an URI: file://(full path to your file with leading /) like: file:///tmp/file.pdf I would be quite confident that this would just work on a Mac, although I can't test it... hth, albert === Subject: Re: Hyperlinks If you have v.7 you're lucky because you'll be able to use the new SystemOpen function. Hyperlinks in notebooks can only link to tagged cells in the notebook or to > URLs on the web, or so it seems. > I would find it useful to be able to link to an external file (not a > notebook nor a text file) and having the file opened by the default external > application that handles the given file type. > Would it be possible to implement this, maybe programmatically (functions > sending commands to the operating system ? Applescript ?) ? A. Berkani === Subject: Re: Hyperlinks hello, the macbook has core duo intel processors. Peter 2009/4/8 A. B. : I think that if mathematica had the superb help facilities of another system or Igor > Pro (Wavemetrics), it would surely become a fantastic tool. I feel that > things have worsened in this area since version 6. As a side note to Peter: do you think there is any chance that your > favourite note-taking application will make it some day to the Intel > processors ? All the best. > A. Berkani >> I'm no expert, as many will happily testify. However, as an example: >> SystemOpen[noggin1.flv] >> Opens a favourite children's animation sequence on my macbook using >> the application VLC. >> Or >> SystemOpen[tbx2.tbx] >> Opens a file tbx2 written in my favourite note-taking application. >> Hope this is what you were looking for >> Peter >> 2009/4/8 A. B. : Hyperlinks in notebooks can only link to tagged cells in the notebook or to > URLs on the web, or so it seems. > I would find it useful to be able to link to an external file (not a > notebook nor a text file) and having the file opened by the default external > application that handles the given file type. > Would it be possible to implement this, maybe programmatically (functions > sending commands to the operating system ? Applescript ?) ? A. Berkani > -- Peter Lindsay 2009/4/8 A. B. : Hyperlinks in notebooks can only link to tagged cells in the notebook or to > URLs on the web, or so it seems. > I would find it useful to be able to link to an external file (not a > notebook nor a text file) and having the file opened by the default external > application that handles the given file type. > Would it be possible to implement this, maybe programmatically (functions > sending commands to the operating system ? Applescript ?) ? A. Berkani > -- Peter Lindsay === Subject: Re: Hyperlinks I'm no expert, as many will happily testify. However, as an example: SystemOpen[noggin1.flv] Opens a favourite children's animation sequence on my macbook using the application VLC. Or SystemOpen[tbx2.tbx] Opens a file tbx2 written in my favourite note-taking application. Hope this is what you were looking for Peter 2009/4/8 A. B. : Hyperlinks in notebooks can only link to tagged cells in the notebook or to > URLs on the web, or so it seems. > I would find it useful to be able to link to an external file (not a > notebook nor a text file) and having the file opened by the default external > application that handles the given file type. > Would it be possible to implement this, maybe programmatically (functions > sending commands to the operating system ? Applescript ?) ? A. Berkani > -- Peter Lindsay === Subject: Re: Hyperlinks > Hyperlinks in notebooks can only link to tagged cells in the notebook or = to > URLs on the web, or so it seems. > I would find it useful to be able to link to an external file (not a > notebook nor a text file) and having the file opened by the default exter= nal > application that handles the given file type. > Would it be possible to implement this, maybe programmatically (functions > sending commands to the operating system ? Applescript ?) ? Hyperlink[file:///full/path/to/file.ext] -Rob === Subject: Table Format Problem I would like to export the results of an NDSolve simulation but I can not seem to figure out how to export my data in the format I want. Here is a simplified version of my code. I have two variables: R1 and P1. I am solving the system from t = 100 to 110 for values of J = 1 to 5. I want my data to be in the following format: Each column is a solution to a variable for a given time (time are the rows). I would have 10 columns (R1[J=1], P1[J=1],R1[J=2],P1[J=2]...R1 [J=5],P1[J=5]) and 11 rows (one for each time step). The closest I could get was having 2 columns (R1, P1) with the rows being solutions for J=1, then J=2, etc. Here is my code: a1=1; d1=.3; l1=.15; T=110; dR1=J-l1*R1[t]-a1*R1[t]*P1[t]; dP1=a1*R1[t]*P1[t]-d1*P1[t]; Flatten[Map[({R1[110],(P1[110])}/.#)&,Table[sol[J]=NDSolve[{R1'[t] ==dR1,P1'[t]==dP1,R1[0]==1,P1[0]==1},{R1,P1},{t,100,T},MaxSteps- >100000],{J,1,5,1}]],1]//Transpose; A=Flatten[Table[Evaluate[({R1[t],P1[t]}/.sol[J]),{J,1,5,1}],{t,100,T, 1}],2]; Export[Data.csv,A]; I appreciate any help you can provide! Shawn === Subject: Re: Table Format Problem Shawn, Only one line needs to be changed an it should work: A = Partition[ Flatten[Table[({R1[t], P1[t]} /. sol[J]), {t, 100, T, 1}, {J, 1, 5, 1}]], 10] I would like to export the results of an NDSolve simulation but I can > not seem to figure out how to export my data in the format I want. > Here is a simplified version of my code. I have two variables: R1 and > P1. I am solving the system from t = 100 to 110 for values of J = 1 t= o > 5. I want my data to be in the following format: > Each column is a solution to a variable for a given time (time are the > rows). I would have 10 columns (R1[J=1], P1[J=1],R1[J=2],P1[J=2].= ..R1 > [J=5],P1[J=5]) and 11 rows (one for each time step). The closest I > could get was having 2 columns (R1, P1) with the rows being solutions > for J=1, then J=2, etc. > Here is my code: a1=1; > d1=.3; > l1=.15; > T=110; dR1=J-l1*R1[t]-a1*R1[t]*P1[t]; > dP1=a1*R1[t]*P1[t]-d1*P1[t]; Flatten[Map[({R1[110],(P1[110])}/.#)&,Table[sol[J]=NDSolve[{R1'[t] > ==dR1,P1'[t]==dP1,R1[0]==1,P1[0]==1},{R1,P1},{t,100,T},Ma= xSteps- 100000],{J,1,5,1}]],1]//Transpose; A=Flatten[Table[Evaluate[({R1[t],P1[t]}/.sol[J]),{J,1,5,1}],{t,100,T, > 1}],2]; Export[Data.csv,A]; I appreciate any help you can provide! Shawn === Subject: Re: Table Format Problem A = Table[ Join @@ Table[({R1[t], P1[t]} /. sol[J][[1]]), {J, 1, 5, 1}], {t, 100, T, 1}]; ? Jens I would like to export the results of an NDSolve simulation but I can > not seem to figure out how to export my data in the format I want. > Here is a simplified version of my code. I have two variables: R1 and > P1. I am solving the system from t = 100 to 110 for values of J = 1 to > 5. I want my data to be in the following format: > Each column is a solution to a variable for a given time (time are the > rows). I would have 10 columns (R1[J=1], P1[J=1],R1[J=2],P1[J=2]...R1 > [J=5],P1[J=5]) and 11 rows (one for each time step). The closest I > could get was having 2 columns (R1, P1) with the rows being solutions > for J=1, then J=2, etc. > Here is my code: a1=1; > d1=.3; > l1=.15; > T=110; dR1=J-l1*R1[t]-a1*R1[t]*P1[t]; > dP1=a1*R1[t]*P1[t]-d1*P1[t]; Flatten[Map[({R1[110],(P1[110])}/.#)&,Table[sol[J]=NDSolve[{R1'[t] > ==dR1,P1'[t]==dP1,R1[0]==1,P1[0]==1},{R1,P1},{t,100,T},MaxSteps- >> 100000],{J,1,5,1}]],1]//Transpose; A=Flatten[Table[Evaluate[({R1[t],P1[t]}/.sol[J]),{J,1,5,1}],{t,100,T, > 1}],2]; Export[Data.csv,A]; I appreciate any help you can provide! Shawn > === Subject: Re: Table Format Problem to format your data, try the following: tab = Table[ Flatten@Table[{R1[t], P1[t]} /. sol[J], {J, 1, 5, 1}], {t, 100, T, 1}]; TableForm[tab, TableHeadings -> {Range[100, T], Flatten@Table[{R1[J], P1[J]}, {J, 1, 5}]}] Daniel I would like to export the results of an NDSolve simulation but I can > not seem to figure out how to export my data in the format I want. > Here is a simplified version of my code. I have two variables: R1 and > P1. I am solving the system from t = 100 to 110 for values of J = 1 to > 5. I want my data to be in the following format: > Each column is a solution to a variable for a given time (time are the > rows). I would have 10 columns (R1[J=1], P1[J=1],R1[J=2],P1[J=2]...R1 > [J=5],P1[J=5]) and 11 rows (one for each time step). The closest I > could get was having 2 columns (R1, P1) with the rows being solutions > for J=1, then J=2, etc. > Here is my code: a1=1; > d1=.3; > l1=.15; > T=110; dR1=J-l1*R1[t]-a1*R1[t]*P1[t]; > dP1=a1*R1[t]*P1[t]-d1*P1[t]; Flatten[Map[({R1[110],(P1[110])}/.#)&,Table[sol[J]=NDSolve[{R1'[t] > ==dR1,P1'[t]==dP1,R1[0]==1,P1[0]==1},{R1,P1},{t,100,T},MaxSteps- >> 100000],{J,1,5,1}]],1]//Transpose; A=Flatten[Table[Evaluate[({R1[t],P1[t]}/.sol[J]),{J,1,5,1}],{t,100,T, > 1}],2]; Export[Data.csv,A]; I appreciate any help you can provide! Shawn > === Subject: Re: Fast Access to Installed Packages > I like to have fast ways to access a package documentation. One thing that > would be helpful is if the 'Add-Ons and Packages' and 'Standard Extra > Packages' were actually on the drop down Help menu list so we didn't have to > go through the documentation center or type in the package name. I would use > these much more than most of the other items on the menu. For example, why > is 'Find Selected Function' on the menu list since we can do it much faster > directly from a notebook? In lieu of that, I would like to put a command in a package such as > 'PackageNameHelp' such that it it were evaluated it would bring up Version 6 > documentation. I know how to do it for Version 5 Help Browser documentation. One uses: PacletManager`Package`helpBrowserLookup[packagename]; But I don't know how to write such a statement for Version 6 documentation. Can anyone help? David Park djmp...@comcast.net http://home.comcast.net/~djmpark/ I can't help, but I sure do agree with you about getting to Add-On packages. I have already suggested a faster way to Wolfram over a year ago. Gary === Subject: Re: Fast Access to Installed Packages > I like to have fast ways to access a package documentation. One thing that > would be helpful is if the 'Add-Ons and Packages' and 'Standard Extra > Packages' were actually on the drop down Help menu list so we didn't have to > go through the documentation center or type in the package name. I would use > these much more than most of the other items on the menu. For example, why > is 'Find Selected Function' on the menu list since we can do it much faster > directly from a notebook? In lieu of that, I would like to put a command in a package such as > 'PackageNameHelp' such that it it were evaluated it would bring up Version 6 > documentation. I know how to do it for Version 5 Help Browser documentation. One uses: PacletManager`Package`helpBrowserLookup[packagename]; But I don't know how to write such a statement for Version 6 documentation. Can anyone help? > Yes, I have been hacking into the documentation system a bit in order to document my DebugTrace package. You can load that by using: Documentation`HelpLookupPacletURI[DebugTrace] This works for GUIKit and Quantum (my version is only partially interfaced with the DC) - so I guess it is general. You can also pull up the documentation for a particular function, for example Documentation`HelpLookupPacletURI[GUIKit/ref/CloseGUIObject] David Bailey http://www.dbaileyconsultancy.co.uk === Subject: Re: Fast Access to Installed Packages The following is a partial answer. This opens the Documentation Center at the page where the add ons are listed: FrontEndExecute[ FrontEndToken[ OpenHelpLink, {paclet:guide/InstalledAddOns, Null}]] There are also (more obscure and undocumented) commands that add entities (and commands) to menus. I use these to modify the Palettes menu in http://scientificarts.com/worklife. It uses the FrontEnd command FrontEnd`AddMenuCommands Best, David > I like to have fast ways to access a package documentation. One thing tha= t > would be helpful is if the 'Add-Ons and Packages' and 'Standard Extra > Packages' were actually on the drop down Help menu list so we didn't have= to > go through the documentation center or type in the package name. I would = use > these much more than most of the other items on the menu. For example,= why > is 'Find Selected Function' on the menu list since we can do it much fast= er > directly from a notebook? In lieu of that, I would like to put a command in a package such as > 'PackageNameHelp' such that it it were evaluated it would bring up Versio= n 6 > documentation. I know how to do it for Version 5 Help Browser documentation. One uses: PacletManager`Package`helpBrowserLookup[packagename]; But I don't know how to write such a statement for Version 6 documentatio= n. Can anyone help? David Park djmp...@comcast.net http://home.comcast.net/~djmpark/ === Subject: Re: Fast Access to Installed Packages > The following is a partial answer. This opens the Documentation > Center at the page where the add ons are listed: FrontEndExecute[ > FrontEndToken[ > OpenHelpLink, {paclet:guide/InstalledAddOns, Null}]] There are also (more obscure and undocumented) commands that add > entities (and commands) to menus. I use these to modify the Palettes > menu in http://scientificarts.com/worklife. It uses the FrontEnd command FrontEnd`AddMenuCommands > As I remember it, the big problem with using AddMenuCommands, was/is that if you kill the kernel and re-run the code, there didn't seem to be any way to avoid adding the same menu item a second time, etc. Have you found any way to avoid this problem? For personal use, I just extend the MENUSETUP.TR file - but that technique is not really suitable for software going to other users. David Bailey http://www.dbaileyconsultancy.co.uk === Subject: Show[list] does not work - details of the script i am kind of newbie in Mathematica programming, There are some errors which I am not able to troubleshoot... I would be very thankful, if someone can look into it.... I have pasted the whole script and the errors- Clear[Global` *] ClearSystemCache[Numeric]; Clear[l]; plot1 = {}; plot2 = {}; myPlots = {}; $RecursionLimit = 10000; as = {}; lst = {}; hg = 0; Clear[k]; Data = {}; dataFilenames1 = Flatten[Table[FileNames[*.new], {1}]]; Data = Table[ ToString[ StringJoin[/home/venki/ten1/BMRB_files/, ToString[dataFilenames1[[vh]]]]], {vh, 1, 100}]; Do[ ToString[Data[[m]]] Clear[mat]; Clear[k]; Clear[l]; Clear[x]; Clear[z]; k = Import[ToString[Data[[m]]], Table]; Grid[k]; mat = k; MatrixForm[mat]; l = Transpose[mat]; x = l[[1, All]]; z = l[[2, All]]; Clear[kj]; lst = {}; For[i = 1, i <= 220, i = i + 1, If[x[[i]] == hg, lst = Append[{z[[i]]}, lst]]]; (*For[i=1,i<=220,i=i+1,If[MemberQ[lst,x[[i]]]==True &&x[[i]]==j ,lst=Append[{z[[i]]},lst],Delete[lst,i]]];*) kj = Flatten[lst]; x1 = kj[[1]]; y1 = kj[[2]]; y2 = kj[[3]]; (*Print[MemberQ[kj,y2]] If[MemberQ[kj,y2]== False,Print[you are great],Print[You are still great]] If[MemberQ[kj,y2]-> False,Print[you are great],Print[You are still great]]*) If[MemberQ[kj, x1] == True, If[ MemberQ[kj, y2] == False, plot1 = Flatten[Append[{ListPlot[{x1, y1}]}, plot1]] , plot2 = Flatten[Append[{ListPlot[{{x1, y1}, {x1, y2}}]}, plot2]]; ]] myPlots = Join[plot1, plot2]; , {m, 2}] Show[plot2] Errors and output Part::partw: Part All of {} does not exist. >> Part::partw: Part All of {} does not exist. >> Part::partw: Part 4 of {}[[1,All]] does not exist. >> General::stop: Further output of Part::partw will be suppressed during this calculation. >> Set::write: Tag Times in Null {} is Protected. >> Set::write: Tag Times in Null {} is Protected. >> Show::shx: No graphical objects to show. >> Show[{}] === Subject: Re: Show[list] does not work - details of the script Frankly, this code is a bit of a mess. I'll go through it line by line. Unfortunately, since it needs external data I cannot verify the final result. >Clear[Global` *] >ClearSystemCache[Numeric]; >Clear[l]; Lots of Clears here. Usually, this is not necessary unless you're afraid that you have made multiple (overloaded) definitions with the same name. I'd suggest you remove all Clears from the program. There are even Clears in the loop! >plot1 = {}; >plot2 = {}; >myPlots = {}; Many initializations as well. In programming courses it is often advised to initialize all the variables you use (if the programming language you use not already does this by default). In my opinion, in Mathematica it is better not to initialize variables if there isn't a good reason to do that. If you make the error of assuming your variable has a value when, in fact, it has not, your variable will end up in the end result as a symbol without value, or it will cause an error in between which will be a signal of a programming logic error. In both ways, it is much clearer to see what caused the error than when you had initialized the variable. Of course, if you write everything in one large notebook you run the risk of variables of one part being used inadvertently in another. It's better to work with local variables using constructions like Module or Block. In your code, you sometimes set a variable to a specific value just after initialization. Happens with Data. Pretty senseless. > $RecursionLimit = 10000; This is a very high value. Usually, recursion quickly leads to a combinatoric explosion. The number of calculations is often proportinal to a constant to the power $RecursionLimit. > as = {}; > lst = {}; > hg = 0; > Clear[k]; > Data = {}; See above. hg is used in an Equals test once. Is its definition as a variable necessary? > dataFilenames1 = Flatten[Table[FileNames[*.new], {1}]]; The Flatten and Table are superfluous, as FileNames already generates a flat list. > Data = Table[ > ToString[ > StringJoin[/home/venki/ten1/BMRB_files/, > ToString[dataFilenames1[[vh]]]]], {vh, 1, 100}]; > You use ToString on things that are already strings. The path is a string and the names in dataFilenames1 are also strings. If the goal of this code is to get the whole path of the file attached to its name you could have written Data = FileNames[*.new,/home/venki/ten1/BMRB_files/] > Do[ > ToString[Data[[m]]] Again, superfluous use of ToString and a missing '; ' > Clear[mat]; > Clear[k]; > Clear[l]; > Clear[x]; > Clear[z]; Unnecessary, remove. > k = Import[ToString[Data[[m]]], Table]; Again, superfluous use of ToString. > Grid[k]; > MatrixForm[mat]; Two lines that do nothing because their output is suppressed by ; > mat = k; > l = Transpose[mat]; > x = l[[1, All]]; > z = l[[2, All]]; Calculation of x and z could be written somewhat shorter as: x=mat[[1]]; z=mat[[2]]; Actually, I don't see why you introduce 'mat' here. It is identical to k and is used in the assignment to l only. Could have used k there as well. > Clear[kj]; > lst = {}; > For[i = 1, i <= 220, i = i + 1, > If[x[[i]] == hg, lst = Append[{z[[i]]}, lst]]]; lst = Append[{z[[i]]}, lst] could be written just as easily as lst = {z [[i]], lst}. Your original line could be written better as lst = Append [lst,z[[i]]] since you seem to want z[[i]] in the List lst and not the other way around. Using lst = {lst,z[[i]]} is often much faster. > kj = Flatten[lst]; > x1 = kj[[1]]; > y1 = kj[[2]]; > y2 = kj[[3]]; I have the impression something goes wrong here. lst is a list with possibly up to 220 members, but it is not guranteed to be longer than 3. That depends upon the values in the vector x. Hence, the code here may generate errors. Not sure if the first three are special here. > If[MemberQ[kj, x1] == True, This is pretty silly. Tou assigned x1 to the first member of list kj. If you then test whether x1 is in kj this must of course be true. The '==True' part of of the test is not necessary. If the member test yields True you end up with True==True, which is True. If it yields False, you get False==True which equals False. In both cases, that's just the result of the member test itself. > If[ MemberQ[kj, y2] == False, You picked y2 from kj so the member test will yield true. The result will be True == False, which will always be False. > plot1 = Flatten[Append[{ListPlot[{x1, y1}]}, plot1]] Assuming that you want a scatter plot of x1 vs y1, and assuming x1 and y1 are one-dimensional lists you want ListPlot[Transpose[{x1,y1}]] since ListPlot needs a one dimensional array of values or of pairs of values. But perhaps you want two plots of x1 and y1, then it's OK. As above, you may avoid Append: plot1 = Flatten[{ListPlot[{x1, y1}], plot1]}] > , plot2 = > Flatten[Append[{ListPlot[{{x1, y1}, {x1, y2}}]}, plot2]]; Still looks like you want a scatter plot of y1 or y2 against x. ListPlot should then be used as: ListPlot[{Transpose[{x1, y1}], Transpose[{x1, y2}]}] >]] Missing ';' > myPlots = Join[plot1, plot2]; You don't use myPlots in the remainder of the code... > Part::partw: Part All of {} does not exist. > Part::partw: Part All of {} does not exist. >> It looks like the matrix isn't two-dimensional. Did you check whether the Import succeed in getting k the correct matrix? On Apr 8, 11:02 am, Venkatesh Ramakrishnan i am kind of newbie in Mathematica programming, > There are some errors which I am not able to troubleshoot... I would be very thankful, if someone can look into it.... I have pasted the whole script and the errors- > Clear[Global` *] > ClearSystemCache[Numeric]; > Clear[l]; > plot1 = {}; > plot2 = {}; > myPlots = {}; > $RecursionLimit = 10000; > as = {}; > lst = {}; > hg = 0; > Clear[k]; > Data = {}; > dataFilenames1 = Flatten[Table[FileNames[*.new], {1}]]; > Data = Table[ > ToString[ > StringJoin[/home/venki/ten1/BMRB_files/, > ToString[dataFilenames1[[vh]]]]], {vh, 1, 100}]; Do[ > ToString[Data[[m]]] > Clear[mat]; > Clear[k]; > Clear[l]; > Clear[x]; > Clear[z]; > k = Import[ToString[Data[[m]]], Table]; > Grid[k]; > mat = k; > MatrixForm[mat]; > l = Transpose[mat]; > x = l[[1, All]]; > z = l[[2, All]]; Clear[kj]; > lst = {}; > For[i = 1, i <= 220, i = i + 1, > If[x[[i]] == hg, lst = Append[{z[[i]]}, lst]]]; > (*For[i=1,i<=220,i=i+1,If[MemberQ[lst,x[[i]]]==True &&x[[i]]= ==j > ,lst=Append[{z[[i]]},lst],Delete[lst,i]]];*) > kj = Flatten[lst]; > x1 = kj[[1]]; > y1 = kj[[2]]; > y2 = kj[[3]]; (*Print[MemberQ[kj,y2]] > If[MemberQ[kj,y2]== False,Print[you are great],Print[You are > still great]] > If[MemberQ[kj,y2]-> False,Print[you are great],Print[You are > still great]]*) If[MemberQ[kj, x1] == True, > If[ MemberQ[kj, y2] == False, > plot1 = Flatten[Append[{ListPlot[{x1, y1}]}, plot1]] > , plot2 = > Flatten[Append[{ListPlot[{{x1, y1}, {x1, y2}}]}, plot2]]; > ]] > myPlots = Join[plot1, plot2]; > , {m, 2}] > Show[plot2] Errors and output Part::partw: Part All of {} does not exist. > Part::partw: Part All of {} does not exist. > Part::partw: Part 4 of {}[[1,All]] does not exist. > General::stop: Further output of Part::partw will be suppressed during > this calculation. > Set::write: Tag Times in Null {} is Protected. > Set::write: Tag Times in Null {} is Protected. > Show::shx: No graphical objects to show. > Show[{}] === Subject: ListContourPlot3D I have data of density for a 32*64*64 box. I use ListContourPlot3D to draw a surface that density equals some value (say 0.5). It turns out that the plot is very rough. How can I make it smoother? There is no InterpolationOrder parameter for ListContourPlot3D. === Subject: Re: ListContourPlot3D > I have data of density for a 32*64*64 box. I use ListContourPlot3D to draw a > surface that density equals some value (say 0.5). It turns out that the plot > is very rough. How can I make it smoother? There is no InterpolationOrder > parameter for ListContourPlot3D. You could interpolate manually using Interpolation, and plot with ContourPlot3D. === Subject: Re: ListContourPlot3D take the volume data and convolve it in 3d with a low pass filter. Jens > I have data of density for a 32*64*64 box. I use ListContourPlot3D to draw a > surface that density equals some value (say 0.5). It turns out that the plot > is very rough. How can I make it smoother? There is no InterpolationOrder > parameter for ListContourPlot3D. === Subject: Re: ListContourPlot3D I guess the Method option would have helped you. Unfortunately, the documentation of ListContourPlot3D fails to reveal its permitted values. You must be member of Skull and Bones before you are entrusted with this information. > I have data of density for a 32*64*64 box. I use ListContourPlot3D to draw a > surface that density equals some value (say 0.5). It turns out that the plot > is very rough. How can I make it smoother? There is no InterpolationOrder > parameter for ListContourPlot3D. === Subject: Re: Difficulties with Re Assuming[x > 0 && y > 0, Re[Exp[(x + I y)^2]] /. Exp[a_] :> Exp[Expand[a]] // Simplify] ? Jens Of the following two expressions, the first works, while the second > doesn't. How does one make it work? Assuming[x > 0 && y > 0, Re[Exp[x + I y]] // Simplify] > Assuming[x > 0 && y > 0, Re[Exp[(x + I y)^2]] // Simplify] > Aaron > === Subject: Re: Difficulties with Re It works if you expand (x + I y)^2, as follows. Assuming[x > 0 && y > 0, Re[Exp[Expand[(x + I y)^2]]] // Simplify] I am not sure why it doesn't work if you don't expand. Re can be finicky about evaluating sometimes. === Subject: Re: Difficulties with Re Positivity is not essential in your problem. ComplexExpand does what you want: In[3]:= ComplexExpand[Re[Exp[(x + I*y)^2]]] Out[3]= E^(x^2 - y^2)*Cos[2*x*y] In[4]:= ComplexExpand[Re[Exp[x + I*y]]] Out[4]= E^x*Cos[y] Adriano Pascoletti 2009/4/6 Aaron Fude Of the following two expressions, the first works, while the second > doesn't. How does one make it work? Assuming[x > 0 && y > 0, Re[Exp[x + I y]] // Simplify] > Assuming[x > 0 && y > 0, Re[Exp[(x + I y)^2]] // Simplify] > Aaron === Subject: Re: Difficulties with Re Hi Aaron, You could argue that it worksin the second example as well. What would you think Simplify should do? Look at TreeForm[Re[Exp[(x + I y) ^2]] ] and TreeForm[E^(x^2 - y^2) Cos[2 x y]] . The latter (which you would consider the Simplified version) contains 17 boxes, whereas the former (Mathematica's output) contains only 12. Ergo, your desired result is not the most simple representation and Mathematica is right not to simplify it that way. You can force Mathematica to do it your way: Assuming[x > 0 && y > 0, Re[E^Expand[(x + I y)^2]] // Simplify] Of the following two expressions, the first works, while the second > doesn't. How does one make it work? Assuming[x > 0 && y > 0, Re[Exp[x + I y]] // Simplify] > Assuming[x > 0 && y > 0, Re[Exp[(x + I y)^2]] // Simplify] > Aaron === Subject: Re: Difficulties with Re Of the following two expressions, the first works, while the second > doesn't. How does one make it work? Assuming[x > 0 && y > 0, Re[Exp[x + I y]] // Simplify] > Assuming[x > 0 && y > 0, Re[Exp[(x + I y)^2]] // Simplify] > Why don't you use ComplexExpand instead? Also note that after applying ComplexExpand to your second expression, the LeafCount *increases*, so it's no wonder Simplify doesn't do the transformation. === Subject: Re: Difficulties with Re Try this: ComplexExpand[Re[Exp[x + I y]]] ComplexExpand[Re[Exp[(x + I y)^2]]] Ailing Of the following two expressions, the first works, while the second > doesn't. How does one make it work? Assuming[x > 0 && y > 0, Re[Exp[x + I y]] // Simplify] > Assuming[x > 0 && y > 0, Re[Exp[(x + I y)^2]] // Simplify] > Aaron === Subject: Re: Difficulties with Re > Of the following two expressions, the first works, while the second > doesn't. How does one make it work? > Assuming[x > 0 && y > 0, Re[Exp[x + I y]] // Simplify] > Assuming[x > 0 && y > 0, Re[Exp[(x + I y)^2]] // Simplify] Try ComplexExpand[] instead of Simplify[]. You shouldn't even need to use Assuming[], since ComplexExpand[] explicitly tells Mathematica to assume all unspecified variables are real. Pillsy === Subject: Re: Difficulties with Re Of the following two expressions, the first works, while the second > doesn't. How does one make it work? Assuming[x > 0 && y > 0, Re[Exp[x + I y]] // Simplify] > Assuming[x > 0 && y > 0, Re[Exp[(x + I y)^2]] // Simplify] > Aaron > Your second one will not be changed, because Mathematica considers Re[Exp(x+I y)^2] to be the simplest form. You might insert an ExpandAll to get the desired result of Exp[x^2-y^2]Cos[2 x y] -- _________________________________________________________________ Peter Breitfeld, Bad Saulgau, Germany -- http://www.pBreitfeld.de === Subject: Re: Difficulties with Re ComplexExpand is your friend: ComplexExpand[Re[Exp[x + I y]]] E^x*Cos[y] ComplexExpand[Re[Exp[(x + I y)^2]]] E^(x^2 - y^2)*Cos[2*x*y] Of the following two expressions, the first works, while the second > doesn't. How does one make it work? Assuming[x > 0 && y > 0, Re[Exp[x + I y]] // Simplify] > Assuming[x > 0 && y > 0, Re[Exp[(x + I y)^2]] // Simplify] > Aaron > -- 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: Re: Difficulties with Re Of the following two expressions, the first works, while the second > doesn't. How does one make it work? Assuming[x > 0 && y > 0, Re[Exp[x + I y]] // Simplify] > Assuming[x > 0 && y > 0, Re[Exp[(x + I y)^2]] // Simplify] > Aaron This is a case for ComplexExpand: Re[Exp[(x + I y)^2]] // ComplexExpand You could also do this: Assuming[x > 0 && y > 0, Re[Exp[(x + I y)^2]] // ExpandAll // Simplify] Jens === Subject: Re: Difficulties with Re > Assuming[x > 0 && y > 0, Re[Exp[x + I y]] // Simplify] > Assuming[x > 0 && y > 0, Re[Exp[(x + I y)^2]] // Simplify] If you check the expansion of the second expression, you'll notice that it contains a part proportional to Exp[2ix*y]. This is generally complex for x>0 and y>0; if x*y is an integer multiple of pi, then the entire expression reduces to a real number; otherwise, the whole expression is imaginary. Unless you provide Mathematica (or anyone) more constraints on x and y, there is no way to tell you whether the whole thing has a real part, or whether the real part is zero. -- Curtis Osterhoudt cfo@remove_this.lanl.and_this.gov PGP Key ID: 0x4DCA2A10 === Subject: Re: Difficulties with Re Assuming[Element[{x, y}, Reals], Re[Exp[x + I y]] // Simplify] E^x*Cos[y] Assuming[Element[{x, y}, Reals], Re[ComplexExpand[Exp[(x + I y)^2]]] // Simplify] E^(x^2 - y^2)*Cos[2*x*y] Bob Hanlon Of the following two expressions, the first works, while the second doesn't. How does one make it work? Assuming[x > 0 && y > 0, Re[Exp[x + I y]] // Simplify] Assuming[x > 0 && y > 0, Re[Exp[(x + I y)^2]] // Simplify] Aaron === Subject: how to build pattern for a square matrix of reals? As in subject: how to build a pattern that will specify that given argument of a function has to be square matrix of reals? Tried with following for square matrix part: f[x_?MatrixQ[#] && Dimensions[#][[1]] == Dimensions[#][[2]] &] := ... but it doesn't seem to be working... === Subject: Re: how to build pattern for a square matrix of reals? > As in subject: how to build a pattern that will specify that given > argument of a function has to be square matrix of reals? Tried with > following for square matrix part: > f[x_?MatrixQ[#] && Dimensions[#][[1]] == Dimensions[#][[2]] > &] := ... > but it doesn't seem to be working... > One way is f[mat_] /; MatrixQ[mat, Im[#] == 0 &] && SameQ @@ Dimensions [mat] = ... You forgot the & from the end of your pure functions. === Subject: Re: how to build pattern for a square matrix of reals? > As in subject: how to build a pattern that will specify that given > argument of a function has to be square matrix of reals? Tried with > following for square matrix part: > f[x_?MatrixQ[#] && Dimensions[#][[1]] == Dimensions[#][[2]] > &] := ... > but it doesn't seem to be working... > Regarding the type checking, a fast way to do that is to use MatchQ[#, _Real]& as the test in MatrixQ. It is recognized as a special case and for packed arrays it'll be O(1): In[1]:= m = RandomReal[1, {4*^3, 4*^3}]; In[2]:= Timing[MatchQ[m, {{_Real..}..}]] Out[2]= {0.906, True} In[3]:= Timing[MatrixQ[m, MatchQ[#, _Real]&]] Out[3]= {0., True} Maxim Rytin m.r@inbox.ru === Subject: Re: how to build pattern for a square matrix of reals? > As in subject: how to build a pattern that will specify that given > argument of a function has to be square matrix of reals? Tried with > following for square matrix part: > f[x_?MatrixQ[#] && Dimensions[#][[1]] == Dimensions[#][[2]] > &] := ... > but it doesn't seem to be working... > Regarding the type checking, a fast way to do that is to use MatchQ[#, > _Real]& as the test in MatrixQ. It is recognized as a special case and > for packed arrays it'll be O(1): In[1]:= m = RandomReal[1, {4*^3, 4*^3}]; In[2]:= Timing[MatchQ[m, {{_Real..}..}]] Out[2]= {0.906, True} In[3]:= Timing[MatrixQ[m, MatchQ[#, _Real]&]] Out[3]= {0., True} Maxim Rytin > m...@inbox.ru That is a useful bit of information. How did you find that out? I wish more information like this was available about other Mathematica functions. === Subject: Re: how to build pattern for a square matrix of reals? > As in subject: how to build a pattern that will specify that given > argument of a function has to be square matrix of reals? Tried with > following for square matrix part: > f[x_?MatrixQ[#] && Dimensions[#][[1]] == Dimensions[#][[2]] > &] := ... > but it doesn't seem to be working... > squareRealMatrixQ[___] = False; squareRealMatrixQ[m_?MatrixQ] := SameQ @@ Dimensions[m] && VectorQ[m, Element[#, Reals] &]; === Subject: Re: how to build pattern for a square matrix of reals? > As in subject: how to build a pattern that will specify that given > argument of a function has to be square matrix of reals? Tried with > following for square matrix part: > f[x_?MatrixQ[#] && Dimensions[#][[1]] == Dimensions[#][[2]] > &] := ... > but it doesn't seem to be working... > you are just missing some brackets: f[x_?((MatrixQ[#] && Dimensions[#][[1]] == Dimensions[#][[2]]) &)] := match hth, albert === Subject: Re: how to build pattern for a square matrix of reals? f[_?(MatrixQ[#,NumberQ] &)]:= .. but usual better is f[_?(MatrixQ[#,NumericQ] &)]:= .. but this test not only reals. Jens > As in subject: how to build a pattern that will specify that given > argument of a function has to be square matrix of reals? Tried with > following for square matrix part: > f[x_?MatrixQ[#] && Dimensions[#][[1]] == Dimensions[#][[2]] > &] := ... > but it doesn't seem to be working... === Subject: Re: how to build pattern for a square matrix of reals? Sorry, I still have some related issues: if I have say two vectors (lists) as function arguments, how to build pattern that will verify that the length of the second vector is equal to the size of the first vector? Also, how to check that specific element of some vector have specific value? I tried something like: Foo[v1:{_Real..}/;Length[Dimensions[v1]]==1&&v1[[1]]==0,v2: {_Real..}/;Length[Dimensions[v2]]==1&&Dimensions[v2][[1]]==Dimensions [v1][[1]]]:=OK but it doesn't work... === Subject: Re: how to build pattern for a square matrix of reals? fully get what I wanted. I guess it would be better if I explained initially what is all about: I have some simple Fortran routines for solving tri-diagonal, and then regular, system of linear equations, that I'm wrapping, through Mathlink, for use from Mathematica. I want Mathematica to do arguments checking for me, and this could be achieved through specifying corresponding patterns for functions signature in the MathLink template file. So, my functions are: TridiagonalSolve[l, d, u, b] - for tridiagonal solver Solve[A, b] - for regular solver If the dimension of system is n in both cases, then here: l - lower diagonal vector, of size n, with first element set to 0 d - diagonal vector, of size n u - upper diagonal vector, of size n, with last element set to 0 b - right-side vector, of size n A - matrix of the system, of size nxn So, I want to check that dimensions of all vectors match, for tridiagonal solver function, and also that vector l has 0 as first, and vector u has 0 as last element. Also, for regular solver function, I want to check that dimensions of system matrix, and the length of the right-side vector match. Of course, I also want to check that A is matrix of reals, and that l, d,u and b are vectors of reals. So here are final patterns I came up with (these seem to work fine, but I'd appreciate any further suggestions on improvement): TridiagonalSolve[l_/;(VectorQ[l,MatchQ[#,_Real]&]&&l[[1]] ==0),d_/;VectorQ[d,MatchQ[#,_Real]&],u_/;(VectorQ[u,MatchQ[#,_Real]&] &&u[[-1]]==0),b_/;VectorQ[b,MatchQ[#,_Real]&]]/;Length[l]==Length[d] ==Length[u]==Length[b]:=OK Solve[A_/;(MatrixQ[A,MatchQ[#,_Real]&]&&Equal@@Dimensions [A]),b_/;VectorQ[b,MatchQ[#,_Real]&]]/;Dimensions[A][[2]]==Length [b]:=OK === Subject: Re: how to build pattern for a square matrix of reals? > Sorry, I still have some related issues: if I have say two vectors > (lists) as function arguments, how to build pattern that will verify > that the length of the second vector is equal to the size of the first > vector? Also, how to check that specific element of some vector have > specific value? I tried something like: > Foo[v1:{_Real..}/;Length[Dimensions[v1]]==1&&v1[[1]]==0,v2: > {_Real..}/;Length[Dimensions[v2]]==1&&Dimensions[v2][[1]]==Dimensions > [v1][[1]]]:=OK > but it doesn't work... This is what I would do: foo[v1_?(VectorQ[#, NumericQ] &), v2_?(VectorQ[#, NumericQ] &)] /; And[v1[[1]] == 0, Length[v1] == Length[v2]] := OK hth, albert === Subject: Re: how to build pattern for a square matrix of reals? === Subject: Re: how to build pattern for a square matrix of reals? f[m : {{_Real ..} ..} /; Length[Dimensions[m]] == 2 [And] Equal @@ Dimensions[m]] := You have entered a real square matrix. f[{{1, 2}, {3, 4}} // N] f[{{1, 2}, {3, 4, 5}} // N] f[{{1, 2}, {3, 4}}] David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ As in subject: how to build a pattern that will specify that given argument of a function has to be square matrix of reals? Tried with following for square matrix part: f[x_?MatrixQ[#] && Dimensions[#][[1]] == Dimensions[#][[2]] &] := ... but it doesn't seem to be working... === Subject: Re: how to build pattern for a square matrix of reals? Add an ampersand and a couple of parentheses: In[1]:= f[(m_)?(MatrixQ[#1, NumericQ] && SameQ @@ Dimensions[#1] & )] := Good! In[2]:= f[RandomReal[{-1, 1}, {2, 2}]] Out[2]= Good! In[3]:= f[RandomReal[{-1, 1}, {2, 3}]] Out[3]= f[{{0.7458917724579508, -0.9549183202849245, 0.010947478301726044}, {-0.14117283873516007, 0.6198728660624302, 0.07598523139890823}}] Adriano Pascoletti 2009/4/8 argument of a function has to be square matrix of reals? Tried with > following for square matrix part: > f[x_?MatrixQ[#] && Dimensions[#][[1]] == Dimensions[#][[2]] > &] := ... > but it doesn't seem to be working... === Subject: Re: how to build pattern for a square matrix of reals? you are nearly there. PatternTest (?) takes a function, therefore, you must write a&: Clear[f]; f[x_?(MatrixQ [#] && Equal @@ Dimensions[#] & )] := Print[Matrix seen]; Daniel > As in subject: how to build a pattern that will specify that given > argument of a function has to be square matrix of reals? Tried with > following for square matrix part: > f[x_?MatrixQ[#] && Dimensions[#][[1]] == Dimensions[#][[2]] > &] := ... > but it doesn't seem to be working... === Subject: Re: how to build pattern for a square matrix of reals? You were almost there, but forgot the ampersand (&) which is necessary to complete the full pure function syntax. The whole part behind the ? should also be wrapped in an extra set of parentheses (this is also often necessary in cases where you use a pure function as an option): f[x_?((MatrixQ[#]) && Dimensions[#][[1]] == Dimensions[#][[2]] &)] > As in subject: how to build a pattern that will specify that given > argument of a function has to be square matrix of reals? Tried with > following for square matrix part: > f[x_?MatrixQ[#] && Dimensions[#][[1]] == Dimensions[#][[2]] > &] := ... > but it doesn't seem to be working... > === Subject: Re: overlay of multiple plots Show command does not work lst = Table[ With[{a = RandomReal[{1, 6}]}, Plot[Sin[a*x], {x, 0, 2 Pi}]], {100}]; and Show @@ lst work as it should. Can you be more specific ? Jens I generated a list of plots, which I want to overlay. (say around 100 > plots). I tried to read in the list inside the Show[] command. > But somehow it does not seem to work. Any suggestions? I would be very grateful. Venkatesh Ramakrishnan > National Facility for High Field NMR > Tata Institute of Fundamental Research > Mumbai 400 005 > India > === Subject: Re: overlay of multiple plots Show command does not work On Apr 6, 12:02 pm, Venkatesh Ramakrishnan I generated a list of plots, which I want to overlay. (say around 100 > plots). I tried to read in the list inside the Show[] command. > But somehow it does not seem to work. Any suggestions? > Try to pose the question more precisely---does not work doesn't tell us much. Try PlotRange -> All in Show. === Subject: Re: overlay of multiple plots Show command does not work Could you please post your code, instead of having us guess what you might have done wrong? On Apr 6, 11:02 am, Venkatesh Ramakrishnan I generated a list of plots, which I want to overlay. (say around 100 > plots). I tried to read in the list inside the Show[] command. > But somehow it does not seem to work. Any suggestions? I would be very grateful. Venkatesh Ramakrishnan > National Facility for High Field NMR > Tata Institute of Fundamental Research > Mumbai 400 005 > India === Subject: Re: overlay of multiple plots Show command does not work I generated a list of plots, which I want to overlay. (say around 100 > plots). I tried to read in the list inside the Show[] command. > But somehow it does not seem to work. Any suggestions? I would be very grateful. Venkatesh Ramakrishnan > National Facility for High Field NMR > Tata Institute of Fundamental Research > Mumbai 400 005 > India Here is a guess: Try it with Show[list, PlotRange->All] where list is your list of plots. If this doesn't work, you should give a more specific example of the problem. Jens === Subject: Re: Computing resources no, because I know what ParallelTable[], ParallelMap[] ... are good for. And I love that Mathematica use only more than a single processor when *I* tell Mathematica that it should do so. Regadrs Jens > During a long computation I opened the taskmanager in windows and I > realized that Mathematica (7) uses only one out of 4 cores on my > machine. > Do you know why this is happening? Do you have the same problem? > is is something that has to do with mathematica or with windows? > Filippo PS I'm running Mathematica 7 on a Quad core Xeon, 16Gb of ram, windows > professional 64 bit edition. > === Subject: Re: Computing resources > During a long computation I opened the taskmanager in windows and I > realized that Mathematica (7) uses only one out of 4 cores on my > machine. > Do you know why this is happening? Do you have the same problem? > is is something that has to do with mathematica or with windows? > Filippo PS I'm running Mathematica 7 on a Quad core Xeon, 16Gb of ram, windows > professional 64 bit edition. There are two different ways to take advantage of a multi-core machine with Mathematica. You can assign kernels to specific notebook windows (Mathematica does not do this automatically for you no matter how many cores or license slots you have) using the Evaluation/Notebook's Kernel menu command or even to specific cells (highlight a cell and use the Evaluation/Kernel Configuration menu to assign a specific kernel) and in both cases they need to have been previously created with the Evaluation/Kernel Configuration Options/Add. There are also the new parallel routines in version 7 that will do things automatically for you, but you need to write your code using these parallel routines. Before version 7, you had to use an optional package called Parallel Computing Toolkit (PCT) which was about $1000. Look at the Documentation Center for help with the new version 7 parallel routines (see guide/ParallelComputing in the DC or on the web at http://www.wolfram.com/products/mathematica/newin7/content/BuiltInParallelCom puting/ ). To learn how to create and assign a kernel to a specific notebook read about it at http://www.wolfram.com/broadcast/screencasts/howtoconnecttoaremotekernel/?w=7 76&h=632 (this video talks about remote kernels but the concepts are similar using local kernels) and also ParallelTools/tutorial/ ConfiguringAndMonitoring#25777216 in the DC. You can easily define several local kernels with the Evaluation/Kernel Configuration Options menu and call them local-2, local-3, local-4 or whatever. Then with the Evaluation/Notebooks Kernel menu assign one of the unused local-x kernels to another notebook and then execute this notebook, and then look at the running processes and you should see two math kernels running at maximum CPU (assuming that the first one did not finish by the time you started the second notebook running. You need to be careful about variables colliding with multiple running notebooks so look at the use of contexts with variable names. To use multiple kernels at the cell level look at how to use the Evaluator command in the DC in ref/Evaluator - there is a keyword called Evaluator that is by default set to Local but could be set to any predefined kernel you created previously. Hope that helps... -Bob === Subject: Re: Computing resources Filippo, This is not strange. Most of the programs you have only use one core. Only a few will use more than one. Some games can do it, some photoshop filters... The Mathematica kernel also runs in one core. However, as of 7, Mathematica has parallelism built-in. This is not an automatic process though, and many programs and algorithms are not suited for parallelization. For an overview of parallelization functions, see guide/ParallelComputing or http://wolfram.com/products/mathematica/newin7/content/BuiltInParallelCompu= ting/ > During a long computation I opened the taskmanager in windows and I > realized that Mathematica (7) uses only one out of 4 cores on my > machine. > Do you know why this is happening? Do you have the same problem? > is is something that has to do with mathematica or with windows? > Filippo PS I'm running Mathematica 7 on a Quad core Xeon, 16Gb of ram, windows = > professional 64 bit edition. === Subject: Re: Computing resources >windows and I realized that Mathematica (7) uses only one out of 4 >cores on my machine. Do you know why this is happening? Do you have >the same problem? is is something that has to do with mathematica or >with windows? That is the way things are supposed to work. Multiple cores are equivalent to multiple processors from Mathematica's perspective. Unless you make use of parallel computing, Mathematica only runs the kernel on a single processor. To make use of all of the cores you have available you need to use the various functions which have names that start with Parallel. === Subject: Re: Fast Access to Installed Packages Once you have the paclet URI, you can programmatically bring up the help for any page by doing, e.g.,... FrontEndExecute[ FrontEnd`FrontEndToken[OpenHelpLink, {guide/InstalledAddOns, Automatic}]] This will open a new window if necessary, or reuse an existing window if available. If you'd like to always open a new window, just remove the Automatic. Incidentally, Find Selected Function is in the menus as a reminder to people what the shortcut key is. John Fultz jfultz@wolfram.com User Interface Group Wolfram Research, Inc. > I like to have fast ways to access a package documentation. One thing > that would be helpful is if the 'Add-Ons and Packages' and 'Standard > Extra Packages' were actually on the drop down Help menu list so we > didn't have to go through the documentation center or type in the package > name. I would use these much more than most of the other items on the > menu. For example, why is 'Find Selected Function' on the menu list > since we can do it much faster directly from a notebook? > In lieu of that, I would like to put a command in a package such as > 'PackageNameHelp' such that it it were evaluated it would bring up > Version 6 > documentation. > I know how to do it for Version 5 Help Browser documentation. One uses: > PacletManager`Package`helpBrowserLookup[packagename]; > But I don't know how to write such a statement for Version 6 > documentation. > Can anyone help? > David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ === Subject: Re: Is there a BNF for Mathematica? > I have been looking for a Backus-Naur Form grammar for Mathematica. Is > there one out there?? When reading these kinds of questions, one always think: what is he really trying to achieve? If you say *why* you need that, you will surely get more useful answers. === Subject: Re: Is there a BNF for Mathematica? Ok, after reading the posts, I will just sorta make my own. Great way to learn Mathematica! ;-) === Subject: Re: Show[list] does not work Do try to give an example of what you are attempting. It is very difficult to answer such a question posed as generally as you have done. --David I am trying to overlay multiple plots using Show[list] where list > contains my plots. But the command always draws a blank plot. Can someone let me know why? > Venkatesh Ramakrishnan > Department of Chemical Sciences > Tata Institute of Fundamental Research > Mumbai 400005 > India === Subject: Re: Show[list] does not work it^s hard to tell without an example. What you describe is working as the following shows: g1 = Plot[Cos[x], {x, 0, 3}]; g2 = Plot[Sin[x], {x, 0, 3}]; Show[{g1, g2}] Daniel I am trying to overlay multiple plots using Show[list] where list > contains my plots. But the command always draws a blank plot. Can someone let me know why? > Venkatesh Ramakrishnan > Department of Chemical Sciences > Tata Institute of Fundamental Research > Mumbai 400005 > India === Subject: Re: Show[list] does not work Please give an example. Your question is too general. David I am trying to overlay multiple plots using Show[list] where list > contains my plots. But the command always draws a blank plot. Can someone let me know why? > Venkatesh Ramakrishnan > Department of Chemical Sciences > Tata Institute of Fundamental Research > Mumbai 400005 > India === Subject: Re: Show[list] does not work Can you provide more detail about the plots? I believe that certain graphical elements, like Epilogs, don't get combined by Show. Michael I am trying to overlay multiple plots using Show[list] where list > contains my plots. But the command always draws a blank plot. Can someone let me know why? > Venkatesh Ramakrishnan > Department of Chemical Sciences > Tata Institute of Fundamental Research > Mumbai 400005 > India === Subject: Re: Show[list] does not work can you write the list you're talking about? I am trying to overlay multiple plots using Show[list] where list > contains my plots. But the command always draws a blank plot. Can someone let me know why? > Venkatesh Ramakrishnan > Department of Chemical Sciences > Tata Institute of Fundamental Research > Mumbai 400005 > India === Subject: Re: Show[list] does not work >I am trying to overlay multiple plots using Show[list] where list >contains my plots. >But the command always draws a blank plot. >Can someone let me know why? Not until you post more detail which ought to include the Mathematica code used to generate the plots you are trying to overlay. === Subject: Re: Integrating package documentation with the documentation center mentioned on the group) some while ago: http://www.scientificarts.com/mathematicatools/blog/BE3448096684/BE344809668 4.html It gives you an overview of the process. --David http://alpha-tips.com/alphatips/blog http://scientificarts.com/worklife > On Apr 1, 8:52 pm, Jens-Peer Kuska and it seems that you have just overlooked this excellent Mathematica > development tool. Jens It seems to me that you - Jens - have overlooked the fact that many > users do not have/use workbench Go ahead David with your how to guide, we all look forward to > reading it === Subject: Re: Hyperlinks Use the function SystemOpen Bob Hanlon Hyperlinks in notebooks can only link to tagged cells in the notebook or to URLs on the web, or so it seems. I would find it useful to be able to link to an external file (not a notebook nor a text file) and having the file opened by the default external application that handles the given file type. Would it be possible to implement this, maybe programmatically (functions sending commands to the operating system ? Applescript ?) ? A. Berkani === Subject: Re: how to build pattern for a square matrix of reals? You need parentheses f[x_?(MatrixQ[#] && Dimensions[#][[1]] == Dimensions[#][[2]] &)] := ,,, or more compactly f[x_?(MatrixQ[#] && Equal @@ Dimensions[#] &)] := ... Bob Hanlon As in subject: how to build a pattern that will specify that given argument of a function has to be square matrix of reals? Tried with following for square matrix part: f[x_?MatrixQ[#] && Dimensions[#][[1]] == Dimensions[#][[2]] &] := ... but it doesn't seem to be working... === Subject: Re: nostalgia for old behaviour: graphics re-sizing My experience with Mathematica 7.0.1 on Windows Vista is that if a graphic is resized and the input statement reevaluated, the resized size remains. However, if one deletes the output graphic and reevaluates then the default size returns. David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ In all versions of Mathematica, you can re-size graphical output with a click and a drag. However, prior to v6 (or maybe even v7), once you re-sized an output, that new size remained coupled to its input. So that if you were to re-evaluate the input, possibly even tweaking it in some way, the new output would have the new size. This doesn't seem to work anymore. Now, all new outputs are given the default size. Is there anyway to get Mathematica to revert to the old behaviour? j === Subject: nostalgia for old behaviour: graphics re-sizing In all versions of Mathematica, you can re-size graphical output with a click and a drag. However, prior to v6 (or maybe even v7), once you re-sized an output, that new size remained coupled to its input. So that if you were to re-evaluate the input, possibly even tweaking it in some way, the new output would have the new size. This doesn't seem to work anymore. Now, all new outputs are given the default size. Is there anyway to get Mathematica to revert to the old behaviour? j === Subject: Re: nostalgia for old behaviour: graphics re-sizing > In all versions of Mathematica, you can re-size graphical output with a c= lick and a > drag. However, prior to v6 (or maybe even v7), once you re-sized an outpu= t, > that new size remained coupled to its input. So that if you were to > re-evaluate the input, possibly even tweaking it in some way, the new out= put > would have the new size. This doesn't seem to work anymore. Now, all new > outputs are given the default size. Is there anyway to get Mathematica to= revert to > the old behaviour? > j On my Mac with Mathematica version 7.0.1 the sizes get reset every time the cell is re-executed, so guess this is yet another difference in behavior of Mathematica between Mac's and Windows. Personally, I think the behavior on Window's is correct, as if I go to the trouble of clicking/dragging to make an output cell's graphics bigger, I think that effort should not be lost by re-executing the input cell again, with or without changes to some of the cell's parameters. So, Wolfram what is the correct behavior?? What kind of system are you doing this on Joshua? I will bet it's not a Window's system. How does this work on Linux? On Solaris, and others?? -Bob === Subject: Re: nostalgia for old behaviour: graphics re-sizing > In all versions of Mathematica, you can re-size graphical output with a click and a > drag. However, prior to v6 (or maybe even v7), once you re-sized an output, > that new size remained coupled to its input. So that if you were to > re-evaluate the input, possibly even tweaking it in some way, the new output > would have the new size. This doesn't seem to work anymore. Now, all new > outputs are given the default size. Is there anyway to get Mathematica to revert to > the old behaviour? It does work for me in 6 and 7. === Subject: Re: nostalgia for old behaviour: graphics re-sizing On my PC it is still the same as before. Perhaps it's system related? > In all versions of Mathematica, you can re-size graphical output with a click and a > drag. However, prior to v6 (or maybe even v7), once you re-sized an output, > that new size remained coupled to its input. So that if you were to > re-evaluate the input, possibly even tweaking it in some way, the new output > would have the new size. This doesn't seem to work anymore. Now, all new > outputs are given the default size. Is there anyway to get Mathematica to revert to > the old behaviour? > j === Subject: Plotting 3d-mesh files / Isosurfaces Supppose I have data of the form {{x,y,z,value_at_coordinate},...}? How could I generate a plot of isosurfaces (i.e. surfaces of constant mesh-value). Any other suggestions for visualization of the data would be also appreciated. Yours Wolfgang === Subject: Re: Plotting 3d-mesh files / Isosurfaces does ListContourPlot3D[] does not work anymore ? Jens Supppose I have data of the form {{x,y,z,value_at_coordinate},...}? > How could I generate a plot of isosurfaces (i.e. surfaces of constant > mesh-value). Any other suggestions for visualization of the data would > be also appreciated. > Yours Wolfgang > === Subject: Efficient construction of a correlation matrix Hello all, have a response: is there a fast way to generate a matrix of correlation coefficients given a list of vectors? I have about fifty vectors that are each around 1300 elements long and I'd like to correlate them with each other to get a 50x50 matrix. I know that I can do this with loops or tables but I thought that perhaps there exists a fast and computationally inexpensive way to do this. Any thoughts? Dan === Subject: Re: Efficient construction of a correlation matrix > Hello all, to have a response: is there a fast way to generate a matrix of > correlation coefficients given a list of vectors? I have about > fifty vectors that are each around 1300 elements long and I'd like > to correlate them with each other to get a 50x50 matrix. I know > that I can do this with loops or tables but I thought that perhaps > there exists a fast and computationally inexpensive way to do this. > Any thoughts? Dan If you're using 6 or 7, Correlation[data] will give you the 50 x 50 correlation matrix. If you're pre-6, < Hello all, have a response: is there a fast way to generate a matrix of > correlation coefficients given a list of vectors? I have about fifty > vectors that are each around 1300 elements long and I'd like to > correlate them with each other to get a 50x50 matrix. I know that I > can do this with loops or tables but I thought that perhaps there > exists a fast and computationally inexpensive way to do this. Any > thoughts? Dan fastCorrMatrix[m_?(MatrixQ[#, NumericQ] &)] := Block[ {vMean = Mean /@ m, vMean2 = Mean /@ (m^2), vStdev, t}, vStdev = Sqrt[vMean2 - vMean^2]; t = PadRight[ Table[(Mean[m[[i]]*m[[j]]] - vMean[[i]]*vMean[[j]])/vStdev[[i]]/ vStdev[[j]], {i, Length[m]}, {j, 1, i - 1}], {Length[m], Length[m]}]; t + Transpose[t] + IdentityMatrix@Length[m] ]; === Subject: Re: Efficient construction of a correlation matrix Outer[] and Correlate[] may help. sample = Table[RandomReal[], {50}, {10}]; Outer[Correlation, sample, sample, 1] ? Jens > Hello all, have a response: is there a fast way to generate a matrix of > correlation coefficients given a list of vectors? I have about fifty > vectors that are each around 1300 elements long and I'd like to > correlate them with each other to get a 50x50 matrix. I know that I > can do this with loops or tables but I thought that perhaps there > exists a fast and computationally inexpensive way to do this. Any > thoughts? Dan > === Subject: Re: Fast Access to Installed Packages > I like to have fast ways to access a package documentation. One thing >> that would be helpful is if the 'Add-Ons and Packages' and 'Standard >> Extra Packages' were actually on the drop down Help menu list so we >> didn't have to go through the documentation center or type in the >> package name. I would use these much more than most of the other items >> on the menu. For example, why is 'Find Selected Function' on the menu >> list since we can do it much faster directly from a notebook? >> In lieu of that, I would like to put a command in a package such as >> 'PackageNameHelp' such that it it were evaluated it would bring up >> Version 6 documentation. >> I know how to do it for Version 5 Help Browser documentation. One uses: >> PacletManager`Package`helpBrowserLookup[packagename]; >> But I don't know how to write such a statement for Version 6 >> documentation. >> Can anyone help? > > Yes, I have been hacking into the documentation system a bit in order to > document my DebugTrace package. You can load that by using: Documentation`HelpLookupPacletURI[DebugTrace] This works for GUIKit and Quantum (my version is only partially > interfaced with the DC) - so I guess it is general. You can also pull up the documentation for a particular function, for > example Documentation`HelpLookupPacletURI[GUIKit/ref/CloseGUIObject] David Bailey > http://www.dbaileyconsultancy.co.uk > Once you have the paclet URI, you can programmatically bring up the help > for any page by doing, e.g.,... FrontEndExecute[ > FrontEnd`FrontEndToken[OpenHelpLink, {guide/InstalledAddOns, > Automatic}]] I just thought I'd point out that my version actually calls the function Documentation`HelpLookup, which calls Documentation`HelpLookupPacletURI. The difference is that my solution use the same code used by Find Selected Function to attempt to reuse an existing help window rather than to always produce a new help window. If you're fine with always producing a new window, then David's solution is fine and unlikely to require any changes in future versions of Mathematica. John Fultz jfultz@wolfram.com User Interface Group Wolfram Research, Inc. === Subject: Open interval The Mathematica uses the comand Interval for Closed Interval. Does anyone Knows if there is a comand to open intevals? Sofia === Subject: Re: Hyperlinks Hyperlinks in notebooks can only link to tagged cells in the notebook or > to > URLs on the web, or so it seems. > I would find it useful to be able to link to an external file (not a > notebook nor a text file) and having the file opened by the default > external > application that handles the given file type. > Would it be possible to implement this, maybe programmatically (functions > sending commands to the operating system ? Applescript ?) ? A. Berkani A file: URL passed to the Hyperlink[] command should work fine if you're okay with specifying an absolute path. Otherwise, you could pass a SystemOpen command (which is the programmatic way to do this) to a Button styled to look like a hyperlink. For example, Button[abcd, SystemOpen[FileNameJoin[{NotebookDirectory[], xxx.doc}]], BaseStyle -> Hyperlink, Appearance -> None] where xxx.doc would be relative to the path of the notebook itself. John Fultz jfultz@wolfram.com User Interface Group Wolfram Research, Inc. === Subject: combining contourplot and regionplot Given a complex function (say the Gamma function), I would like to plot all points (x,y), -101. Solutions to the equation can be plotted with ContourPlot. Solutions to the inequality can be plotted with RegionPlot. But how do I plot points that satisfy BOTH the equation and the inequality? A similar question has been asked on the Forum before but did not receive Cristina === Subject: Re: combining contourplot and regionplot ContourPlot[ Arg[Gamma[x + I*y]] == 0, {x, -5, 5}, {y, -5, 5}, RegionFunction -> Function[{x, y, z}, Abs[Gamma[x + I*y]] > 1] ] Jens > Given a complex function (say the Gamma function), I would like to plot > all points (x,y), -10 infinity). I need to plot all points with Arg[Gamma[x+I*y]]==0 and > Abs[Gamma[x+I*y]]>1. Solutions to the equation can be plotted with > ContourPlot. Solutions to the inequality can be plotted with RegionPlot. > But how do I plot points that satisfy BOTH the equation and the inequality? > A similar question has been asked on the Forum before but did not receive Cristina > === Subject: Comparison Grapher v1.0 Here is my contribution to the community of my data visualization library, version 1.0. In its current state, it facilitates comparing logged data of multiple parameters from multiple sources. It graphs each source's version of a given parameter on the same X-Y plot. It has a tab for each parameter's plot, and two copies of this graph to correlate one parameter with another in time. It also provides a time-legend with dynamic time range selection and Y-axis auto-zooming, inspired by chronoscope < http://timepedia.org/chronoscope>. I'm not yet releasing the real data-importing stuff, but I'm attaching a small bit that generates data of the correct form, of the intended nature. I have three motivations in releasing this: 1. To share it with anyone who might care. 2. To get ideas on how to improve it, specifically: a. Any ways to improve the performance of the dynamic plot scaling b. Ideas on how to put the grapher in a dialog window. My newbie skills aren't up to figuring it out at the moment. c. Ideas on approaches for mouse-over annotating something this complex (in similar style to chronoscope) d. Ideas on sub-sampling the data, so that it could scale to 200k+ points per parameter per source and still maintain performance (again, like chronoscope) I'd also like to eventually make the ui even more like Chronoscope, allowing graphs to be panned horizontally by mouse-dragging and zoomed by mouse-scrolling. You can grab the files at http://drop.io/comparisongrapher -- Bryce Schober === Subject: Re: ListContourPlot3D >I have data of density for a 32*64*64 box. I use ListContourPlot3D >to draw a surface that density equals some value (say 0.5). It turns >out that the plot is very rough. How can I make it smoother? There >is no InterpolationOrder parameter for ListContourPlot3D. Use Interpolation to create an interpolation function with the desired InterpolationOrder then uuse ContourPlot3D to plot that interpolation function. === Subject: Re: how to build pattern for a square matrix of reals? >As in subject: how to build a pattern that will specify that given >argument of a function has to be square matrix of reals? Tried with >following for square matrix part: >f[x_?MatrixQ[#] && Dimensions[#][[1]] == Dimensions[#][[2]] >&] := ... but it doesn't seem to be working... You don't need the [#] after MatrixQ. Probably the simplest way to achieve the behavior you want is to specify a condition after the body of the function. For example, f[x_?MatrixQ] := Tr[x] /; SameQ @@ Dimensions[x] will compute the trace of any square matrix and be unevaluated for any argument other than a square matrix. === Subject: Re: Are there Arrow-like objects in 3D In Mathematica 7, Arrow, with a list of triples of numbers as arguments, does give a 3D arrow thatyou can include in a Graphics3D expression In the 3D graphics one can draw lines. I did not find however, such > objects as arrows. Are there operators which would enable one to > incorporate an arrow into a 3D graphics object (analogously to Arrow and > Arrowheads in 2D)? To be more concrete, I would like to draw > programmatically a sphere together with its radius-vector to show its > radius on a sketch, or a cylinder together with an arrow with two heads > aside of it to indicate its height and this kind of things. > > More generally, some graphics objects have their 3D versions (as say, > Polygon and Line), but others (such as say, Disk) seem not to have. Is > there however, some trick to programmatically combine a 2D graphical > object (that has no 3D analog) with a 3D one (say, to draw a disk > together with a sphere)? I use Math 6/WinXP Best, Alexei > -- 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: Re: Are there Arrow-like objects in 3D Since Mathematica Version 7 Arrow and Arrowheads can be used in 3D plots. The Presentations package has had since Mathematica Version 4, and still has, an Arrow3D primitive. David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ In the 3D graphics one can draw lines. I did not find however, such objects as arrows. Are there operators which would enable one to incorporate an arrow into a 3D graphics object (analogously to Arrow and Arrowheads in 2D)? To be more concrete, I would like to draw programmatically a sphere together with its radius-vector to show its radius on a sketch, or a cylinder together with an arrow with two heads aside of it to indicate its height and this kind of things. More generally, some graphics objects have their 3D versions (as say, Polygon and Line), but others (such as say, Disk) seem not to have. Is there however, some trick to programmatically combine a 2D graphical object (that has no 3D analog) with a 3D one (say, to draw a disk together with a sphere)? I use Math 6/WinXP Best, Alexei -- Alexei Boulbitch, Dr., habil. Senior Scientist IEE S.A. ZAE Weiergewan 11, rue Edmond Reuter L-5326 Contern Luxembourg Phone: +352 2454 2566 Fax: +352 2454 3566 Website: www.iee.lu This e-mail may contain trade secrets or privileged, undisclosed or otherwise confidential information. If you are not the intended recipient and have received this e-mail in error, you are hereby notified that any review, copying or distribution of it is strictly prohibited. Please inform you for your co-operation. === Subject: Are there Arrow-like objects in 3D In the 3D graphics one can draw lines. I did not find however, such objects as arrows. Are there operators which would enable one to incorporate an arrow into a 3D graphics object (analogously to Arrow and Arrowheads in 2D)? To be more concrete, I would like to draw programmatically a sphere together with its radius-vector to show its radius on a sketch, or a cylinder together with an arrow with two heads aside of it to indicate its height and this kind of things. More generally, some graphics objects have their 3D versions (as say, Polygon and Line), but others (such as say, Disk) seem not to have. Is there however, some trick to programmatically combine a 2D graphical object (that has no 3D analog) with a 3D one (say, to draw a disk together with a sphere)? I use Math 6/WinXP Best, Alexei -- Alexei Boulbitch, Dr., habil. Senior Scientist IEE S.A. ZAE Weiergewan 11, rue Edmond Reuter L-5326 Contern Luxembourg Phone: +352 2454 2566 Fax: +352 2454 3566 Website: www.iee.lu === Subject: Re: Are there Arrow-like objects in 3D PS: real 3D arrows are a v7 feature In the 3D graphics one can draw lines. I did not find however, such > objects as arrows. Are there operators which would enable one to > incorporate an arrow into a 3D graphics object (analogously to Arrow and > Arrowheads in 2D)? To be more concrete, I would like to draw > programmatically a sphere together with its radius-vector to show its > radius on a sketch, or a cylinder together with an arrow with two heads > aside of it to indicate its height and this kind of things. More generally, some graphics objects have their 3D versions (as say, > Polygon and Line), but others (such as say, Disk) seem not to have. Is > there however, some trick to programmatically combine a 2D graphical > object (that has no 3D analog) with a 3D one (say, to draw a disk > together with a sphere)? I use Math 6/WinXP Best, Alexei -- > Alexei Boulbitch, Dr., habil. > Senior Scientist IEE S.A. > ZAE Weiergewan > 11, rue Edmond Reuter > L-5326 Contern > Luxembourg Phone: +352 2454 2566 > Fax: +352 2454 3566 Website:www.iee.lu This e-mail may contain trade secrets or privileged, undisclosed or other= wise confidential information. If you are not the intended recipient and ha= ve received this e-mail in error, you are hereby notified that any review, = copying or distribution of it is strictly prohibited. Please inform us imme= r your co-operation. === Subject: Re: Are there Arrow-like objects in 3D Hi Alexei, Restricting your question to 3D arrows: yes it's possible. It's documented on the Arrow page. Graphics3D[Arrow[Tube[{{3, 3, -1}, {4, 4, 0}}]]] gives you a real 3D arrow. In the 3D graphics one can draw lines. I did not find however, such > objects as arrows. Are there operators which would enable one to > incorporate an arrow into a 3D graphics object (analogously to Arrow and > Arrowheads in 2D)? To be more concrete, I would like to draw > programmatically a sphere together with its radius-vector to show its > radius on a sketch, or a cylinder together with an arrow with two heads > aside of it to indicate its height and this kind of things. More generally, some graphics objects have their 3D versions (as say, > Polygon and Line), but others (such as say, Disk) seem not to have. Is > there however, some trick to programmatically combine a 2D graphical > object (that has no 3D analog) with a 3D one (say, to draw a disk > together with a sphere)? I use Math 6/WinXP Best, Alexei -- > Alexei Boulbitch, Dr., habil. > Senior Scientist IEE S.A. > ZAE Weiergewan > 11, rue Edmond Reuter > L-5326 Contern > Luxembourg Phone: +352 2454 2566 > Fax: +352 2454 3566 Website:www.iee.lu This e-mail may contain trade secrets or privileged, undisclosed or other= wise confidential information. If you are not the intended recipient and ha= ve received this e-mail in error, you are hereby notified that any review, = copying or distribution of it is strictly prohibited. Please inform us imme= r your co-operation. === Subject: exponential moving average with a varying exponents. I have a function with calculates an exponential moving average with a varying exponent. EMAVariableExponent[data_, exponents_]:=Module[{ema}, ema = {data[[1]]}; Do[ema =Append[ema,ema[[t-1]] + exponents[[t]] * (data[[t]] - ema[[t-1]])], {t,2,Length[data]}] ]; You supply the function with a list of data and with a list of exponents used at each step in the calculations. This seems to work OK but I'd like to replace it with a clearer and more elegant functional construct. I wish ExponentialMovingAverage[] could take a list of exponents rather than a constant, something like: ExponentialMovingAverage[list, exponentList] I tried the following to try to Map an ExponentialMovingAverage[] across the list of exponents. ExponentialMovingAverage[data, #]&/@ exponents but it gives me a list of lists, each of which has mapped each exponent in exponents to the list of data. Any suggestions much appreciated. === Subject: escaping quote for use with a selectionplaceholder I am trying to figure out how to make a typesetting action that wraps quotes ( ) around the selection in a cell. I cant seem to get a proper escape for quote to put around a selectionplaceholder symbol so Mathematica can use in NoteBookApply. btw, is there a function that puts quotes around any expression passed to it?? Can what am wanting to do as a typesetting action doable?? === Subject: Re: escaping quote for use with a selectionplaceholder > I am trying to figure out how to make a typesetting action that wraps > quotes ( ) around the selection in a cell. > I cant seem to get a proper escape for quote to put around a > selectionplaceholder symbol so Mathematica can use in NoteBookApply. > btw, is there a function that puts quotes around any expression passed > to it?? > Can what am wanting to do as a typesetting action doable?? > this is a first try, which of course only handles some simple cases correctly, but maybe it is good enough as a starting point. To make it work for the cases you are interested in, you should post some examples... Button[Wrap with , NotebookWrite[ButtonNotebook[], RowBox[{, NotebookRead[ButtonNotebook[]], }]] ] hth, albert === Subject: Simplifying an expression for computational, not aesthetic My small grudge is that Simplify[x^2/y^2] does not result in (x/y)^2 even though Mathematica is evidently aware the two are equivalent -- An input of (x/y)^2 results in an output of x^2/y^2. This seems to be because of the brackets, which mathematica prefers to avoid. My question is, is there a way to specify that Simplify produces the SIMPLEST expression it has found, not just the simplest which can most conveniently be expressed. There's nothing in the documentation as far as I can tell. === Subject: Re: Simplifying an expression for computational, not aesthetic > My small grudge is that Simplify[x^2/y^2] does not result in (x/y)^2 > even though Mathematica is evidently aware the two are equivalent -- > An input of (x/y)^2 results in an output of x^2/y^2. This seems to be > because of the brackets, which mathematica prefers to avoid. My question is, is there a way to specify that Simplify produces the > SIMPLEST expression it has found, not just the simplest which can most > conveniently be expressed. There's nothing in the documentation as far > as I can tell. The problem is what is the definition of SIMPLEST? If you are interested in simplification based on length of expression, may be you can use ComplexityFunction -> LeafCount Simplify[theExpression, ComplexityFunction -> LeafCount] But for the example at hand, using r=HoldForm[(x/y)^2] Can keep it in the form you want. But then to use r later on, one must use ReleaseHold. --Nasser === Subject: Re: Simplifying an expression for computational, not aesthetic > The problem is what is the definition of SIMPLEST? I presumed the least number of operations. That is probably not the formal definition but it would suit me just fine :) My problem isn't being able to hold a form, but getting that form from Simplify directly. Don't understand how leafcount functions but doesn't seem to be effective here. It doesn't seem to be a big issue, the trivial stuff can be simplified mentally, nevertheless it is important when implementing the functions in an application that they run as fast as possible. Sometimes a little thing like this can be overlooked and the result ends up being sub-optimal. This is clearly a trivial case, my concern is for more complicated expressions where it is not apparent to the human eye that an equivalent expression with a smaller number of operations exists. Didn't turn out to be a problem so far, if the rabbit hole doesn't go much deeper than this then I am happy. === Subject: dynamic popupmenu help needed hi I can't figure out how to get the second popup to insert into a the cell where the insertion cursor is: f[e_] := Switch[e, hey, 1, you, 2, now, 3]; stuff = {{a, 1, r}, {b, ee, 23}, {0}}; CreatePalette[ PopupMenu[Dynamic[x], {hey, you, now}] Dynamic@PopupMenu[Dynamic[y], stuff[[f[x]]]]] NotebookApply[InputNotebook[], Dynamic[y]] menus were supported ;-p thank you. === Subject: Re: dynamic popupmenu help needed > hi I can't figure out how to get the second popup to insert into a the > cell where the insertion cursor is: f[e_] := Switch[e, hey, 1, you, 2, now, 3]; > stuff = {{a, 1, r}, {b, ee, 23}, {0}}; > CreatePalette[ > PopupMenu[Dynamic[x], {hey, you, now}] > Dynamic@PopupMenu[Dynamic[y], stuff[[f[x]]]]] > NotebookApply[InputNotebook[], Dynamic[y]] NotebookApply[InputNotebook[], y] -Rob === Subject: Re: dynamic popupmenu help needed > I can't figure out how to get the second popup to insert into a the > cell where the insertion cursor is: actually I don't understand what you want to achieve, > f[e_] := Switch[e, hey, 1, you, 2, now, 3]; > stuff = {{a, 1, r}, {b, ee, 23}, {0}}; > CreatePalette[ > PopupMenu[Dynamic[x], {hey, you, now}] > Dynamic@PopupMenu[Dynamic[y], stuff[[f[x]]]]] > NotebookApply[InputNotebook[], Dynamic[y]] ... the above doesn't do anything reasonable on my machine... Start with something simple. This seems to be clear: f[e_] := Switch[e, hey, 1, you, 2, now, 3]; stuff = {{a, 1, r}, {b, ee, 23}, {0}}; make sure you understand the building blocks of what you do. This sets x to the desired value and shows that value: {PopupMenu[Dynamic[x], {hey, you, now}], Dynamic[x]} and this gives a popup menu whose content dynamically changes and shows which is the current value: {Dynamic[PopupMenu[Dynamic[y], stuff[[f[x]]]]], Dynamic[y]} now there are various ways with which you can initialize that PopupMenu to one of the selectable values, with the default, y will just stay what it was, so cannot be found in the list of possible values which will make the content of the PopupMenu be viewed as empty. A very simple way to change that would be to first set y to the first entry in the new list, e.g.: { Dynamic[y = stuff[[f[x], 1]]; PopupMenu[Dynamic[y], stuff[[f[x]]]]], Dynamic[y] } Of course you can insert any code you wish to make that entry appear when changing x that you wish. Once that works as you want, you can create a palette that controls y: CreatePalette[{ Row[{ PopupMenu[Dynamic[x], {hey, you, now}], Dynamic[y = stuff[[f[x], 1]]; PopupMenu[Dynamic[y], stuff[[f[x]]]]] }, Spacer[5]] }] or maybe you want to make that a little more robust using a local (dynamic) variable for x: CreatePalette[{DynamicModule[{x}, Row[{ PopupMenu[Dynamic[x], {hey, you, now}], Dynamic[y = stuff[[f[x], 1]]; PopupMenu[Dynamic[y], stuff[[f[x]]]]] }, Spacer[5]] ]}] > Sure wish hierarchical menus were supported ;-p I think everything is there to build that, but you should be more precise in defining what these hierarchical menus should behave like... hth, albert === Subject: Re: dynamic popupmenu help needed rereading your post and ragfields suggestionm, I think I now understand what you probably are trying to achieve. Is that close to what you want? CreatePalette[{ Row[{ PopupMenu[Dynamic[x], {hey, you, now}], Dynamic[y = stuff[[f[x], 1]]; PopupMenu[Dynamic[y], stuff[[f[x]]]]], Button[Insert, NotebookWrite[InputNotebook[], y]], Button[Wrap, NotebookApply[InputNotebook[], RowBox[{y, [, [SelectionPlaceholder], ]}]]] }, Spacer[5] ] }] note that for just inserting NotebookWrite seems to be good enough, with NotebookApply you can do something with the current selection, e.g. wrap a function around it as I do above... hth, albert === Subject: Re: combining contourplot and regionplot Show[RegionPlot[Abs[Gamma[x + I*y]] > 1, {x, -10, 10}, {y, -10, 10}], ContourPlot[Arg[Gamma[x + I*y]] == 0, {x, -10, 10}, {y, -10, 10}]] ContourPlot[Arg[Gamma[x + I*y]] == 0, {x, -10, 10}, {y, -10, 10}, RegionFunction -> Function[{x, y}, Abs[Gamma[x + I*y]] > 1]] Bob Hanlon Given a complex function (say the Gamma function), I would like to plot all points (x,y), -101. Solutions to the equation can be plotted with ContourPlot. Solutions to the inequality can be plotted with RegionPlot. But how do I plot points that satisfy BOTH the equation and the inequality? A similar question has been asked on the Forum before but did not receive Cristina === Subject: Re: Plotting 3d-mesh files / Isosurfaces Map {Take[#, 3], Last[#]} & onto your list. Use Interpolation. Use ContourPlot3D. David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ Supppose I have data of the form {{x,y,z,value_at_coordinate},...}? How could I generate a plot of isosurfaces (i.e. surfaces of constant mesh-value). Any other suggestions for visualization of the data would be also appreciated. Yours Wolfgang === Subject: Re: Plotting 3d-mesh files / Isosurfaces In v6 or later use ListContourPlot3D Bob Hanlon Supppose I have data of the form {{x,y,z,value_at_coordinate},...}? How could I generate a plot of isosurfaces (i.e. surfaces of constant mesh-value). Any other suggestions for visualization of the data would be also appreciated. Yours Wolfgang === Subject: Re: complicated list selector data = {{11, {121, 122}}, {21, {221, 222}}, {31, {321, 322}}}; {First[#], Part[#, 2, 2]} & /@ data {{11, 122}, {21, 222}, {31, 322}} David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ I have the following list data = { {11, {121, 122}}, {21, {221, 222}}, {31, {321, 322}} }; element of the second sub-sub-list that is: wanted_result={ {11, 122}, {21, 222}, {31, 322} } I tried data[[All, {1, {2,1}}]] but it gives me error. What is the right selector ? === Subject: complicated list selector I have the following list data = { {11, {121, 122}}, {21, {221, 222}}, {31, {321, 322}} }; wanted_result={ {11, 122}, {21, 222}, {31, 322} } I tried data[[All, {1, {2,1}}]] but it gives me error. What is the right selector ? === Subject: Re: complicated list selector > I have the following list data = { {11, {121, 122}}, {21, {221, 222}}, {31, {321, 322}}= }; > ement of the second sub-sub-list that is: wanted_result={ {11, 122}, {21, 222}, {31, 322} } I tried data[[All, {1, {2,1}}]] but it gives me error. What is the right selector ? Transpose@{data[[All, 1]], data[[All, 2, 1]]} === Subject: Re: complicated list selector {#[[1]], #[[2, 2]]} & /@ data Jens > I have the following list data = { {11, {121, 122}}, {21, {221, 222}}, {31, {321, 322}} }; > wanted_result={ {11, 122}, {21, 222}, {31, 322} } I tried data[[All, {1, {2,1}}]] but it gives me error. What is the right selector ? > === Subject: Re: complicated list selector In[2]:= data /. {x_, {y_, _}} :> {x, y} Out[2]= {{11, 121}, {21, 221}, {31, 321}} In[3]:= ({#1[[1]], #1[[2, 2]]} & ) /@ data Out[3]= {{11, 122}, {21, 222}, {31, 322}} Adriano Pascoletti 2009/4/9 summer I have the following list data = { {11, {121, 122}}, {21, {221, 222}}, {31, {321, 322}} }; > wanted_result={ {11, 122}, {21, 222}, {31, 322} } I tried data[[All, {1, {2,1}}]] but it gives me error. What is the right selector ? > === Subject: Re: combining contourplot and regionplot [Addendum] One other variant Show[RegionPlot[Abs[Gamma[x + I*y]] > 1, {x, -10, 10}, {y, -10, 10}], ContourPlot[Arg[Gamma[x + I*y]] == 0, {x, -10, 10}, {y, -10, 10}], ContourPlot[Arg[Gamma[x + I*y]] == 0, {x, -10, 10}, {y, -10, 10}, RegionFunction -> Function[{x, y}, Abs[Gamma[x + I*y]] > 1], ContourStyle -> Red]] Bob Hanlon Show[RegionPlot[Abs[Gamma[x + I*y]] > 1, {x, -10, 10}, {y, -10, 10}], ContourPlot[Arg[Gamma[x + I*y]] == 0, {x, -10, 10}, {y, -10, 10}]] ContourPlot[Arg[Gamma[x + I*y]] == 0, {x, -10, 10}, {y, -10, 10}, RegionFunction -> Function[{x, y}, Abs[Gamma[x + I*y]] > 1]] Bob Hanlon Given a complex function (say the Gamma function), I would like to plot all points (x,y), -101. Solutions to the equation can be plotted with ContourPlot. Solutions to the inequality can be plotted with RegionPlot. But how do I plot points that satisfy BOTH the equation and the inequality? A similar question has been asked on the Forum before but did not receive Cristina === Subject: Re: passing both arbitary and defined options Something like the following, which I haven't actually tested. Use a definition: Options[NewPlot] = Join[Options[ListPlot],{NewPlot -> value}] Write you NewPlot definition: NewPlot[data_,opts:OptionsPattern[]]:= Module[ {newplotvalue = OptionValue[NewPlot], fopts = FilterRules[opts, Options[ListPlot]}, Do something with newplotvalue, Call ListPlot using fopts ] David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ So I'm building a plotting function, and I want it to be able to inherit the same options that a ListPlot[] command can inherit, so my prototype looks like this: NewPlot[data_List,options___Rule]:=Module[{},blah blah blah ListPlot[fancy stuff,options] ] Here's the rub, if I additionally want to create a NewPlot-specific option, it doesn't mesh. For example: NewPlot[data_List,OptionsPattern[{newOption->newValue}],options___Rule] := etc Options contains the rule for newOption when NewPlot is called with that option utilized, and ListPlot throws an error because it's not a recognized option for ListPlot. Is there a way I can have my personally declared options and the wildcard options both present and working? Is there a way to Drop the rule that matches the user-defined option from 'options'? === Subject: passing both arbitary and defined options So I'm building a plotting function, and I want it to be able to inherit the same options that a ListPlot[] command can inherit, so my prototype looks like this: NewPlot[data_List,options___Rule]:=Module[{},blah blah blah ListPlot[fancy stuff,options] ] Here's the rub, if I additionally want to create a NewPlot-specific option, it doesn't mesh. For example: NewPlot[data_List,OptionsPattern[{newOption->newValue}],options___Rule] := etc Options contains the rule for newOption when NewPlot is called with that option utilized, and ListPlot throws an error because it's not a recognized option for ListPlot. Is there a way I can have my personally declared options and the wildcard options both present and working? Is there a way to Drop the rule that matches the user-defined option from 'options'? === Subject: Re: passing both arbitary and defined options the old package FilterOptions` is the bes solution, the new clumsy FilterRules[] should do the same in a more long winded way. Jens > So I'm building a plotting function, and I want it to be able to inherit the same options that a ListPlot[] command can inherit, so my prototype looks like this: NewPlot[data_List,options___Rule]:=Module[{},blah > blah > blah > ListPlot[fancy stuff,options] > ] Here's the rub, if I additionally want to create a NewPlot-specific option, it doesn't mesh. For example: NewPlot[data_List,OptionsPattern[{newOption->newValue}],options___Rule] := etc Options contains the rule for newOption when NewPlot is called with that option utilized, and ListPlot throws an error because it's not a recognized option for ListPlot. Is there a way I can have my personally declared options and the wildcard options both present and working? Is there a way to Drop the rule that matches the user-defined option from 'options'? > === Subject: Re: dual y-axis plotting - is it possible in mathematica? The Presentations package ($50) among many other things has a CustomTicks command that allows you to use ticks on any axis that have a 1-1 mapping to the underlying plot values. You could then scale your error data, using Rescale say, and provide matching tick values on one y-axis with normal tick values on the other y-axis. With Presentations it is also easy to draw multiple plot items along with primitives all in one plotting statement without using Show or Epilog or having to switch graphics levels. You just draw one thing after another. The following page at my web site shows an example of a two y-axis graphic. http://home.comcast.net/~djmpark/DrawGraphicsPage.html David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ I'm trying to figure out how to create a dual y-axis scatterplot, but there doesn't seem to be any documentation about how to do this in Mathematica's help or anywhere online that comes up in a search engine quickly. Anyone here know how to do it? By dual y-axis plot, I mean a plot which has one y-axis on the left and one on the right, with different scales, but with a common x-axis. I need to be able to make such a plot because I would like to illustrate the measurement error of a plot of measured values, where the error is much smaller than the measured values. Because the data is this way, it's difficult to see variation in the error unless you have a second y-axis that's on a much smaller scale (say 0 to 0.1) vs. a scale of 0 to 50 for the measurement data. There does seem to be plenty of documentation about how to do this in other systems, and I already know how to do it in Excel. I'm rather surprised there isn't an easily accessible way to do it in Mathematica... so, any ideas? === Subject: dual y-axis plotting - is it possible in mathematica? I'm trying to figure out how to create a dual y-axis scatterplot, but there doesn't seem to be any documentation about how to do this in Mathematica's help or anywhere online that comes up in a search engine quickly. Anyone here know how to do it? By dual y-axis plot, I mean a plot which has one y-axis on the left and one on the right, with different scales, but with a common x-axis. I need to be able to make such a plot because I would like to illustrate the measurement error of a plot of measured values, where the error is much smaller than the measured values. Because the data is this way, it's difficult to see variation in the error unless you have a second y-axis that's on a much smaller scale (say 0 to 0.1) vs. a scale of 0 to 50 for the measurement data. There does seem to be plenty of documentation about how to do this in other systems, and I already know how to do it in Excel. I'm rather surprised there isn't an easily accessible way to do it in Mathematica... so, any ideas? === Subject: Re: dual y-axis plotting - is it possible in mathematica? > I'm trying to figure out how to create a dual y-axis scatterplot, but there doesn't seem to be any documentation about how to do this in Mathematica's help or anywhere online that comes up in a search engine quickly. Anyone here know how to do it? By dual y-axis plot, I mean a plot which has one y-axis on the left and one on the right, with different scales, but with a common x-axis. I need to be able to make such a plot because I would like to illustrate the measurement error of a plot of measured values, where the error is much smaller than the measured values. Because the data is this way, it's difficult to see variation in the error unless you have a second y-axis that's on a much smaller scale (say 0 to 0.1) vs. a scale of 0 to 50 for the measurement data. There does seem to be plenty of documentation about how to do this in other systems, and I already know how to do it in Excel. I'm rather surprised there isn't an easily accessible way to do it in Mathematica... so, any ideas? David, Did you try searching this group for previous examples? This is really a great group and searching for a question usually provides a previous asked question and several answers. I tried and came across several suggestions: 1. One method involved using the Frame attribute and defining specific tick marks, e.g. Plot[{Sin[x], 3*Sin[x]}, {x, 0, 2*Pi}, PlotStyle -> {RGBColor[1, 0, 0], RGBColor[0, 0, 1]}, Frame -> True, FrameTicks -> {Automatic, {{-3, -3 M}, {-2, -2 M}, {-1, -1 M}, {1, 1 M}, {2, 2 M}, {3, 3 M}}, Automatic, {{-3, -30 T}, {-20, -2 T}, {-1, -10 T}, {1, 10 T}, {2, 20 T}, {3, 30 T}}}] 2. Another method involved writing a user defined routine like: TwoAxisPlot[{f_, g_}, {x_, x0_, x1_}, color1_, color2_, opts : OptionsPattern[]] := Module[{f0, f1, g0, g1, gp, scale, gticks}, {f0, f1} = Options[Plot[f, {x, x0, x1}, Frame -> True, opts], PlotRange][[1, 2, 2]]; {g0, g1} = Options[gp = Plot[g, {x, x0, x1}, Frame -> True, opts], PlotRange][[1, 2, 2]]; scale[y_] := f0 + ((f1 - f0) (y - g0))/(g1 - g0); gticks = Apply[{scale[#1], ##2} &, AbsoluteOptions[gp, FrameTicks][[1, 2, 2]], {1}]; Plot[{f, scale[g]}, {x, x0, x1}, PlotRange -> 1.001 {f0, f1}, Frame -> True, FrameTicks -> {{Automatic, gticks}, {Automatic, Automatic}}, PlotStyle -> {{color1}, {color2}}, FrameStyle -> {{color1, color2}, {{}, {}}}, opts]] TwoAxisPlot[{Sin[x], 0.1 Cos[x]}, {x, -[Pi], [Pi]}, Red, Blue] 3. And a third suggested using David Parks Presentations package which is available from him at http://home.comcast.net/~djmpark/DrawGraphicsPage.html One thing I thought was surprising was that I could not find a single example of doing this on Wolfram's web site. The links that I came across in Googling the topic all came up with links that have been moved/deleted on Wolfram's web site and had no redirect to take me to where they are now. So either they are gone from Wolfram's site or they didn't bother to put the redirect in. Sad to see that Wolfram has again chosen to remove useful content from their web site. -Bob === Subject: Re: 2-defensive prime number > 2-defensive odd number is defined as: > n=2k+1 is an odd number, k>0, if Mod[2^i+1,n] != 0 for any natural > number i , then n is 2-defensive odd number. If n is prime too, then n > is 2-defensive prime number. My questions are: > 1. Have 2-defensive odd numbers some special form? > 2. ratio = all 2-defensive odd numbers / all odd numbers >1/2 ? > ratio = all 2-defensive prime numbers / all odd prime numbers < > 1/2 ? > Euler's Theorem: If (a,m)=1, then m|a^EulerPhi[m] -1 > so , m | a^(i+EulerPhi[m]) - a^i for any natural number i. > therefor, if Mod[2^i+1,n] != 0 for i between [1, EulerPhi[n])] , then > n is 2-defensive odd number. for example, > 3|2^1+1 5|2^2+1 7 is 2 defensive prime number 9|2^3+1 11|2^5+1 13|2^6+1 15 is 2 defensive odd number > ... > 23 is 2 defensive prime number My program code is: Table[ > For[i = 1, i < p, i++, > If[Mod[2^i + 1, p] == 0, Print[p, |2^, i, +1]; Break[]] > ] > If[i == p, Print[p, is 2 defensive number]] > , > {p, Table[Prime[i], {i, 100}]}] Here is code that will be a bit faster in finding these. It covers the first 10,000 primes, takes around 450 seconds on my desktop machine. Timing[twodef10k = Reap[Do[ p = Prime[j]; res = 1; Catch[ Do [res = Mod[2*res,p]; If [res==p-1, Throw[False], If [res==1, Sow[p]; Throw[False]]],{p}]; ]; , {j, 10000}]][[2,1]];] Seems that the ratio in question might be stailizing around .29 or so. As for what is known about these, might want to check the OEIS entry and references therein: http://www.research.att.com/~njas/sequences/A072936 Here is code that is much faster. It uses built in MultiplicativeOrder, Timing[twodef = Reap[Do[ p = Prime[j]; If [OddQ[MultiplicativeOrder[2,p]], Sow[p]]; , {j, 10000}]][[2,1]];] Daniel Lichtblau Wolfram Research === Subject: 2-defensive prime number 2-defensive odd number is defined as: n=2k+1 is an odd number, k>0, if Mod[2^i+1,n] != 0 for any natural number i , then n is 2-defensive odd number. If n is prime too, then n is 2-defensive prime number. My questions are: 1. Have 2-defensive odd numbers some special form? 2. ratio = all 2-defensive odd numbers / all odd numbers >1/2 ? ratio = all 2-defensive prime numbers / all odd prime numbers < 1/2 ? Euler's Theorem: If (a,m)=1, then m|a^EulerPhi[m] -1 so , m | a^(i+EulerPhi[m]) - a^i for any natural number i. therefor, if Mod[2^i+1,n] != 0 for i between [1, EulerPhi[n])] , then n is 2-defensive odd number. for example, 3|2^1+1 5|2^2+1 7 is 2 defensive prime number 9|2^3+1 11|2^5+1 13|2^6+1 15 is 2 defensive odd number ... 23 is 2 defensive prime number My program code is: Table[ For[i = 1, i < p, i++, If[Mod[2^i + 1, p] == 0, Print[p, |2^, i, +1]; Break[]] ] If[i == p, Print[p, is 2 defensive number]] , {p, Table[Prime[i], {i, 100}]}] === Subject: Re: Integrate and Piecewise > Below I make a piecewise function that is continuous. Then I integrate > it to make another piecewise function. However, the integrated > function is not continuous. Presumable because I do indefinite > integration and each part of the piecewise function needs a constant > of integration. Is there anyway of doing the integration and getting a > continuous function? I would like the function to be zero at minus > infinity. Do I have to break the function out into its parts or can I > keep it all as a Piecewise function? Hugh Goyder f4[t_, a_, t0_] := Piecewise[{ > {0, t - t0 <= -a}, > { 4 (t - t0 + a)/a, -a < t - t0 <= -(3/4) a}, > {1 - 4/a (t - t0 + (3 a)/4), -(3/4) a < t - t0 <= -(1/4) a}, > {-1 + 4/a (t - t0 + a/4), -(1/4) a < t - t0 <= 0}, > {-(4/a) (t - t0 ), 0 < t - t0 <= 1/4 a}, > {-1 + 4/a (t - t0 - 1/4 a), 1/4 a < t - t0 <= 3/4 a}, > {1 - 4/a (t - t0 - 3/4 a), 3/4 a < t - t0 <= a} > }] Plot[f4[t, 1, 0], {t, -3, 3}] f3[t_, a_, t0_] := Evaluate[Integrate[f4[t, a, t0], t]] Plot[f3[t, 1, 0], {t, -3, 3}, PlotRange -> All] Formulate f3 as a definite integral from -Infinity to t. f3[t_, a_, t0_] := Evaluate[Integrate[f4[x, a, t0], {x, -Infinity, t}, Assumptions -> Element[{a, t0, t}, Reals]]] Daniel Lichtblau Wolfram Research === Subject: Integrate and Piecewise Below I make a piecewise function that is continuous. Then I integrate it to make another piecewise function. However, the integrated function is not continuous. Presumable because I do indefinite integration and each part of the piecewise function needs a constant of integration. Is there anyway of doing the integration and getting a continuous function? I would like the function to be zero at minus infinity. Do I have to break the function out into its parts or can I keep it all as a Piecewise function? Hugh Goyder f4[t_, a_, t0_] := Piecewise[{ {0, t - t0 <= -a}, { 4 (t - t0 + a)/a, -a < t - t0 <= -(3/4) a}, {1 - 4/a (t - t0 + (3 a)/4), -(3/4) a < t - t0 <= -(1/4) a}, {-1 + 4/a (t - t0 + a/4), -(1/4) a < t - t0 <= 0}, {-(4/a) (t - t0 ), 0 < t - t0 <= 1/4 a}, {-1 + 4/a (t - t0 - 1/4 a), 1/4 a < t - t0 <= 3/4 a}, {1 - 4/a (t - t0 - 3/4 a), 3/4 a < t - t0 <= a} }] Plot[f4[t, 1, 0], {t, -3, 3}] f3[t_, a_, t0_] := Evaluate[Integrate[f4[t, a, t0], t]] Plot[f3[t, 1, 0], {t, -3, 3}, PlotRange -> All] === Subject: Re: Integrate and Piecewise f3[t_, a_, t0_] := Evaluate[Integrate[f4[tau, a, t0], {tau, -Infinity, t}]] ? Jens > Below I make a piecewise function that is continuous. Then I integrate > it to make another piecewise function. However, the integrated > function is not continuous. Presumable because I do indefinite > integration and each part of the piecewise function needs a constant > of integration. Is there anyway of doing the integration and getting a > continuous function? I would like the function to be zero at minus > infinity. Do I have to break the function out into its parts or can I > keep it all as a Piecewise function? Hugh Goyder f4[t_, a_, t0_] := Piecewise[{ > {0, t - t0 <= -a}, > { 4 (t - t0 + a)/a, -a < t - t0 <= -(3/4) a}, > {1 - 4/a (t - t0 + (3 a)/4), -(3/4) a < t - t0 <= -(1/4) a}, > {-1 + 4/a (t - t0 + a/4), -(1/4) a < t - t0 <= 0}, > {-(4/a) (t - t0 ), 0 < t - t0 <= 1/4 a}, > {-1 + 4/a (t - t0 - 1/4 a), 1/4 a < t - t0 <= 3/4 a}, > {1 - 4/a (t - t0 - 3/4 a), 3/4 a < t - t0 <= a} > }] Plot[f4[t, 1, 0], {t, -3, 3}] f3[t_, a_, t0_] := Evaluate[Integrate[f4[t, a, t0], t]] Plot[f3[t, 1, 0], {t, -3, 3}, PlotRange -> All] > === Subject: Re: PlotLegends bug? I get the same blank exported image file as you do on my M7.0, WinXP machine. Don't know why. === Subject: Re: PlotLegends bug? > I get the same blank exported image file as you do on my M7.0, WinXP machine. Don't know why. I also get a blank image on a Mac with Mathematica 7.0.0 from Rasterize[image] Exporting as PNG or TIFF has the same blank outcome. Same if I just try to COPY the output graphic. The documentation is not consistent in this case... There are two ways to use the functions in this package [PlotLegend and ShowLegend] to place a legend in a graphic: the first can only be used as an option to the built-in functions Plot, ListPlot and ListLinePlot, while the second can be applied to any graphic. If this is true, then the entry in PlotLegends/ref/PlotLegend is misleading: PlotLegend is an option for Plot, ListPlot, and related functions... According to the tutorial, there are a grand total of 1 related functions. But then why doesn't the use in ListLogLinearPlot trigger an error? Most likely, the tutorial is wrong and the PNG export failure is really a bug. The workaround on my OS X system is: 1) highlight the output cell bracket 2) Select from the menu: Cell > Convert To > Bitmap (or PDF) 3) highlight the result again 4) select menu: File > Save Selection as... > Format PNG This worked for me. Jens === Subject: Why does ImageCompose degrade the result and can you do anything I wanted to play around with one of the new version 7 image routines, called ImageCompose[], which can be used to add images together. When I was trying to use it, the resultant image was a much degraded image for some of the examples I was playing with, compared to the originals (looked like the resolution was significantly less than the originals), so when you change the magnification the resultant image gets worse and worse and worse as you increase the magnification. Especially noticeable was the text on the tick labels, and the jaggies in the curves and the rasterization becomes more and more prominent, even though the original images don't show this. So, anyone have an idea of why ImageCompose does this and is there a way to use it to add two images together and have the result be as good as the originals, as long as the two have the same resolution? Here is an simple example that shows what I mean: i1 = Plot[Sin[x], {x, -3 Pi, 3 Pi}] i2 = Plot[Cos[x], {x, -3 Pi, 3 Pi}] ImageCompose[i1, i2] So if you up the magnification the ImageCompose version gets more and more jaggies, as well as the axes and ticks and tick labels getting worse and worse. -Bob === Subject: Re: Why does ImageCompose degrade the result and can you do anything > I wanted to play around with one of the new version 7 image routines, > called ImageCompose[], which can be used to add images together. When I was trying to use it, the resultant image was a much degraded > image for some of the examples I was playing with, compared to the > originals (looked like the resolution was significantly less than the > originals), so when you change the magnification the resultant image > gets worse and worse and worse as you increase the magnification. > Especially noticeable was the text on the tick labels, and the jaggies > in the curves and the rasterization becomes more and more prominent, > even though the original images don't show this. So, anyone have an idea of why ImageCompose does this and is there a > way to use it to add two images together and have the result be as > good as the originals, as long as the two have the same resolution? Here is an simple example that shows what I mean: i1 = Plot[Sin[x], {x, -3 Pi, 3 Pi}] > i2 = Plot[Cos[x], {x, -3 Pi, 3 Pi}] > ImageCompose[i1, i2] So if you up the magnification the ImageCompose version gets more and > more jaggies, as well as the axes and ticks and tick labels getting > worse and worse. ImageCompose (and all other Image* operations) work on raster images. Since you're passing Graphics[] objects to Image compose, they are first rasterized at a specific resolution then the two resulting raster images are overlaid. When you magnify the resulting raster image you will see jaggies. If your goal is to combine to Graphics[] objects use Show[]. If you want to perform image processing functions on a Graphics[] object, explicitly rasterize it at your desired resolution first if you are unhappy with the default resolution. -Rob === Subject: Re: Why does ImageCompose degrade the result and can you do anything > I wanted to play around with one of the new version 7 image routines, > called ImageCompose[], which can be used to add images together. When I was trying to use it, the resultant image was a much degraded > image for some of the examples I was playing with, compared to the > originals (looked like the resolution was significantly less than the > originals), so when you change the magnification the resultant image > gets worse and worse and worse as you increase the magnification. > Especially noticeable was the text on the tick labels, and the jaggies > in the curves and the rasterization becomes more and more prominent, > even though the original images don't show this. So, anyone have an idea of why ImageCompose does this and is there a > way to use it to add two images together and have the result be as > good as the originals, as long as the two have the same resolution? Here is an simple example that shows what I mean: i1 = Plot[Sin[x], {x, -3 Pi, 3 Pi}] > i2 = Plot[Cos[x], {x, -3 Pi, 3 Pi}] > ImageCompose[i1, i2] So if you up the magnification the ImageCompose version gets more and > more jaggies, as well as the axes and ticks and tick labels getting > worse and worse. > -Bob You can find the answer in my old posts in this newsgroop: http://tinyurl.com/clncz3 http://tinyurl.com/c5ddew === Subject: NetLink SEHException in getDefaultLaunchString Recently I have gotten this error a couple of times when running a compute command through NetLink: System.Exception: System.Runtime.InteropServices.SEHException: External component has thrown an exception. at Wolfram.NETLink.Internal.NativeLink.getDefaultLaunchString() at Wolfram.NETLink.Internal.NativeLink..ctor(String cmdLine) at Wolfram.NETLink.MathKernel.Connect() at Wolfram.NETLink.MathKernel.Compute() at Wolfram.NETLink.MathKernel.Compute(String input) at... Restarting the machine fixes this, but it has come back at least once, eventually, requiring another restart. Any ideas about what would cause this and how best to recover from it to avoid having to restart the machine? === Subject: Re: Integrate and Piecewise How about: f3[s_, a_, t0_] := Evaluate[Integrate[f4[t, a, t0], {t, -Infinity, s}]] Plot[f3[s, 1, 0], {s, -3, 3}, PlotRange -> All] The integration and plotting seems a tad slow. One could use Piecewise to define f3 by making it zero for s I use the following two functions to analyze time series: mm[data_,period_] := Table[Sum[(Log[data[[t]]] - Log[data[[t-i]]])/ > Sqrt[i], {i,1,period}] / period, {t, period+1, Length[data]}] mr[data_,period_] := Table[Sum[Log[data[[t-i]]/data[[-i + t-1]]] * > (Sqrt[i] - Sqrt[i-1]), {i,1,period}],{t, period+2, Length[data]}] They have a similar structure, Table[Sum[...]...], which sums a > bunch of stuff from the time series at each point in the series. I'd like to convert them into functional programing constructs, but > as the increments in the Table function come into play in the Sum, > I haven't been able to figure out a way to do it. I've tried Map with Partition and a bunch of other things, > but I could use some pointers. Any help much appreciated. These should be faster than my earlier suggestions: mm[data_, period_] := (Last@#-Most@# & /@ Partition[Log@data,period+1,1]). (1/(Reverse@Sqrt@Range[period]*period)) mr[data_, period_] := (Rest@#-Most@#& /@ Partition[Log@data,period+1,1]). (Reverse[Rest@#-Most@#]&@Sqrt@Range[0,period]) === Subject: Re: Replace Table[Sum...]...] with Functional code > I use the following two functions to analyze time series: mm[data_,period_] := Table[Sum[(Log[data[[t]]] - Log[data[[t-i]]])/ > Sqrt[i], {i,1,period}] / period, {t, period+1, Length[data]}] mr[data_,period_] := Table[Sum[Log[data[[t-i]]/data[[-i + t-1]]] * > (Sqrt[i] - Sqrt[i-1]), {i,1,period}],{t, period+2, Length[data]}] They have a similar structure, Table[Sum[...]...], which sums a > bunch of stuff from the time series at each point in the series. I'd like to convert them into functional programing constructs, but > as the increments in the Table function come into play in the Sum, > I haven't been able to figure out a way to do it. I've tried Map with Partition and a bunch of other things, > but I could use some pointers. Any help much appreciated. I think these will do the job, but I haven't tested them. Note that my version of mr gives one more value than yours, as if the Table limits were {t, period+2, Length[data]+1}. mm[data_, period_] := Module[ {s = Reverse@Sqrt@Range[period] * period}, Tr[(Last@# - Most@#)/s]& /@ Partition[Log@data, period+1, 1] ] mr[data_, period_] := Module[ {t = Reverse[Rest@# - Most@#]&@Sqrt@Range[0,period]}, Tr[(Rest@# - Most@#)*t]& /@ Partition[Log@data, period+1, 1] ] === Subject: Re: Fast Access to Installed Packages > The following is a partial answer. This opens the Documentation >> Center at the page where the add ons are listed: >> FrontEndExecute[ >> FrontEndToken[ >> OpenHelpLink, {paclet:guide/InstalledAddOns, Null}]] >> There are also (more obscure and undocumented) commands that add >> entities (and commands) to menus. I use these to modify the Palettes >> menu in http://scientificarts.com/worklife. >> It uses the FrontEnd command FrontEnd`AddMenuCommands > As I remember it, the big problem with using AddMenuCommands, was/is > that if you kill the kernel and re-run the code, there didn't seem to be > any way to avoid adding the same menu item a second time, etc. Have you found any way to avoid this problem? For personal use, I just extend the MENUSETUP.TR file - but that > technique is not really suitable for software going to other users. David Bailey > http://www.dbaileyconsultancy.co.uk You can completely reset the menus using... FrontEndExecute[FrontEnd`ResetMenusPacket[{Automatic}]] You'll get some ugly flicker, but that would work. You can also put the AddMenuCommands function in a front end init.m which can be found someplace on the path specified in the ConfigurationPath option. In that case, the init.m file will get executed by the FE as it starts, not the kernel, and so it won't matter how many kernels you start or quit. John Fultz jfultz@wolfram.com User Interface Group Wolfram Research, Inc. === Subject: Re: complicated list selector >I have the following list >data = { {11, {121, 122}}, {21, {221, 222}}, {31, {321, 322}} }; >element of the second sub-sub-list that is: >wanted_result={ {11, 122}, {21, 222}, {31, 322} } >I tried >data[[All, {1, {2,1}}]] >but it gives me error. >What is the right selector ? Here are three ways to achieve your desired result In[3]:= data[[All, 2]] Out[3]= {{121, 122}, {221, 222}, {321, 322}} In[4]:= Last /@ data Out[4]= {{121, 122}, {221, 222}, {321, 322}} In[5]:= data /. {a_, b_} -> b Out[5]= {{121, 122}, {221, 222}, {321, 322}} === Subject: Re: Efficient construction of a correlation matrix >have a response: is there a fast way to generate a matrix of >correlation coefficients given a list of vectors? I have about >fifty vectors that are each around 1300 elements long and I'd like >to correlate them with each other to get a 50x50 matrix. I know >that I can do this with loops or tables but I thought that perhaps >there exists a fast and computationally inexpensive way to do >this. Any thoughts? Here is a simple way to accomplish what you want without using loops or tables: In[1]:= data = RandomReal[1, {5, 5}]; Partition[Correlation @@@ Tuples[Transpose@data, 2], 5] Out[2]= {{1., -0.56854, -0.304609, 0.829355, -0.137128}, {-0.56854, 1., 0.844872, -0.668716, 0.220838}, {-0.304609, 0.844872, 1., -0.205393, 0.00860996}, {0.829355, -0.668716, -0.205393, 1., -0.41979}, {-0.137128, 0.220838, 0.00860996, -0.41979, 1.}} I transposed the data since Tuples will generate all pairs of rows in the data matrix. And Partition is used since Tuples generates a flat list (length = 25) of pairs rather than a n x n array. Note, while this is simple, it is not the most computationally efficient method since it does more than twice the amount of work needed. All elements of the resulting matrix with indices n,m will be one when n=m and element[[n,m]] will always equal element[[m,n]] === Subject: Re: passing both arbitary and defined options >So I'm building a plotting function, and I want it to be able to >inherit the same options that a ListPlot[] command can inherit, so >my prototype looks like this: >NewPlot[data_List,options___Rule]:=Module[{},blah blah blah >ListPlot[fancy stuff,options] >] >Here's the rub, if I additionally want to create a NewPlot-specific >option, it doesn't mesh. For example: >NewPlot[data_List,OptionsPattern[{newOption->newValue}], >options___Rule] := etc >Options contains the rule for newOption when NewPlot is called with >that option utilized, and ListPlot throws an error because it's not >a recognized option for ListPlot. >Is there a way I can have my personally declared options and the >wildcard options both present and working? Is there a way to Drop >the rule that matches the user-defined option from 'options'? Use the function FilterRules introduced in version 6. For earlier versions of Mathematica, the same functionality can be had by loading the Utilities`FilterOptions`. See the documentation for examples and syntax. === Subject: Animate ListPlot of a table for Evolutionary Model === Subject: FindRoot and evaluation control Good day, help me please with good advice about the problem below. need to solve equation (Eigenvalues can not be calculated symbolically): FindRoot[x==Eigenvalues[hamiltonM/.{a->-103., b->600., j->75., jE- >75., tau->x}][[1]],{x,-1}] got errors: Eigenvalues::eival: Unable to find all roots of the characteristic polynomial. === Subject: Re: complicated list selector data = {{11, {121, 122}}, {21, {221, 222}}, {31, {321, 322}}}; data /. {x_, y_?NumericQ} :> y {{11, 122}, {21, 222}, {31, 322}} MapAt[Last, #, 2] & /@ data {{11, 122}, {21, 222}, {31, 322}} (Flatten /@ data)[[All, {1, 3}]] {{11, 122}, {21, 222}, {31, 322}} Flatten[#][[{1, 3}]] & /@ data {{11, 122}, {21, 222}, {31, 322}} Bob Hanlon I have the following list data = { {11, {121, 122}}, {21, {221, 222}}, {31, {321, 322}} }; wanted_result={ {11, 122}, {21, 222}, {31, 322} } I tried data[[All, {1, {2,1}}]] but it gives me error. What is the right selector ? === Subject: Re: Efficient construction of a correlation matrix Outer[Correlation, list, list, 1] Correlation is new in v6 Bob Hanlon Hello all, have a response: is there a fast way to generate a matrix of correlation coefficients given a list of vectors? I have about fifty vectors that are each around 1300 elements long and I'd like to correlate them with each other to get a 50x50 matrix. I know that I can do this with loops or tables but I thought that perhaps there exists a fast and computationally inexpensive way to do this. Any thoughts? Dan === Subject: Help with ScriptSource in GUIKit Anyone out there familiar with GUIKit? Here is a simple GUI that Prints Clicked when you push the button. In[1829]:= ref = GUIRun[Widget[Button, {text -> Update, BindEvent[action, Script[{Print[Clicked]}]]}], IncludedScriptContexts -> {$Context}]; I want the button to execute a large block of code, and the GUIKit documentation suggests I use the ScriptSource function: In[1827]:= Needs[GUIKit`]; ref = GUIRun[Widget[Button, {text -> Update, BindEvent[action, Script[{}, ScriptSource -> targetNB.m]]}], IncludedScriptContexts -> {$Context}]; In this test case, targetNB.m just has the code Print[Clicked] in it. Nothing happens when I click the button, no error message, no clicked gets printed. I have put the GUI notebook and the targetNB.m file in the same folder, and set Directory to that folder. The documentation for ScriptSource is appalling (no surprise there), but I assume that the contents of targetNB.m will effectively be pasted into the Script function. Is this too naive? Note that if I specify a non-existent m file for ScriptSource, I get no error message. Am I doing something clearly dumb? Is there a better way to make some GUI action run a separate notebook or m file? BTW, I realise that GUIKit is (pretty much) obsolete, and I will be (am, in parallel) developing a V7 GUI from built-in code, but we have a lot of legacy V5 notebooks, and GUIKit is actually a pretty easy way to interface with them (apart from little issues like this one!). Paul. Dr. Paul A. Ellsmore Nanion Limited Oxford Centre for Innovation Mill Street Oxford United Kingdom OX2 0JX Tel: +44 (0) 1865 811175 Fax: +44 (0) 1865 248594 ------=_NextPart_000_000E_01C9B9E6.D9DCC270

Anyone out there familiar with = GUIKit?

 

Here is a simple GUI that Prints "Clicked" = when you push the button.

 

In[1829]:=

ref = GUIRun[Widget["Button", = {"text" -> "Update", BindEvent["action", Script[{Print["Clicked"]}]]}],

    IncludedScriptContexts -> = {$Context}];

 

I want the button to execute a large block of code, = and the GUIKit documentation suggests I use the ScriptSource = function:

 

In[1827]:=

Needs["GUIKit`"]; =

ref = GUIRun[Widget["Button", = {"text" -> "Update", BindEvent["action", Script[{}, = ScriptSource -> "targetNB.m"]]}],

    IncludedScriptContexts -> = {$Context}];

 

In this test case, targetNB.m just has the code Print["Clicked"] in it. Nothing happens when I click the = button, no error message, no “clicked” gets printed. I have put the GUI notebook and the targetNB.m file in the same folder, and set Directory = to that folder. The documentation for ScriptSource is appalling (no surprise = there), but I assume that the contents of targetNB.m will effectively be pasted = into the Script function. Is this too naive?

 

Note that if I specify a non-existent m file for ScriptSource, I get no error message. Am I doing something clearly dumb? = Is there a better way to make some GUI "action" run a separate = notebook or m file?

 

BTW, I realise that GUIKit is (pretty much) obsolete, = and I will be (am, in parallel) developing a V7 GUI from built-in code, but we = have a lot of legacy V5 notebooks, and GUIKit is actually a pretty easy way to interface with them (apart from little issues like this = one!).

 

 

Paul.

 

Dr. Paul A. Ellsmore

 

Nanion Limited

Oxford Centre for Innovation

Mill = Street

Oxford

United Kingdom

OX2 0JX

 

Tel: +44 (0) 1865 811175

Fax: +44 (0) 1865 248594

 

------=_NextPart_000_000E_01C9B9E6.D9DCC270-- === Subject: Re: Scaling JPEGs or TIFFs inside PDF slides (using Illustrator)? AES, Nobody is in a position to 'insist' that a person should stay entirely within Mathematica! And, in fact, today the dominant mode for communication of technical material is to go outside of it. Mathematica notebooks are not even an acceptable mode of publication. Nevertheless, in the aspects of learning, research, development and communication Mathematica has and is becoming better and better. The active and dynamic features of Mathematica are ORDERS OF MAGNITUDE better than static documents, or even documents that link to animations or deployed demonstrations. Consider using Workbench to write an application that contains not only one or more packages but also folders of notebooks or slideshows that are relatively finished and that present various common topics or developed results of your subject matter. The folders could also contain other kinds of files - maybe a PDF paper you have written on the subject matter. You might even have an organized directory of folders. The packages would contain the accumulated routines and documentation that were a major result of your efforts. There is no reason to let this active knowledge slip through your fingers - or have it scattered in many unorganized notebooks. If you were giving a lecture and someone asked a question outside a fixed presentation, using the active knowledge in the application, you could often quickly redo the presentation or even do new ones on the fly. Instead of writing on a whiteboard you might write in a new Mathematica notebook and obtain neat results without all the typos and sloppiness that can creep into static hand written material. It is much easier to bring outside static material into a Mathematica application than to bring Mathematica into a basically static medium. But, for the most part, this is for the future because not everybody can read Mathematica applications as they can read PDF files. David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ My question for the PDF profis here is: When I do this rescaling of a raster image within a PDF document, using Illustrator, is Illustrator actually building a complete new (rescaled) raster image inside the PDF document, and keeping it in the PDF along with the originally placed version? Or does it just keep the rescaled version and discard the original one? Or does it just insert a brief command for the image to be rescaled on the fly any time the PDF is projected or printed? ------------- [And as an addendum, I'm copying this post to cssmm frankly to tweak some of the people who argue that all presentations in the future should and must be done directly from Mathematica notebooks and nothing else (and, secondarily, that _all_ of the capabilities I've mentioned above should and must be built into and carried out from one single, massive, eventually un-learnable and un-documentable Mathematica application. I have no objection at all to making presentations direct from a live Mathematica notebook in situations for example where this might be a not too lengthy, single-topic or one-shot discussion, maybe in a class or group meeting or informal situation, of material that can be covered from a single Mathematica notebook. That makes total sense. But suppose you have a collection of literally many hundreds if not thousands of slides and graphics, some generated by Mathematica, others collected from all over the place, over many years; and you're continually re-organizing and re-purposing and revising these (or copies of them), for presentations at different levels, to different audiences, or in different formats, on screen, in reports, in papers, in books. Suppose, as would be the case if you insisted on the Mathematica notebook only approach, that these materials may have come from many dozens of different Mathematica notebooks, assembled over a dozen plus years, in a half-dozen successive versions of Mathematica (so that some of these notebooks will not even execute any more; and those that still do are likely produce different results than they originally did). So, to do this repurposing, or assembling a new presentation from a lot of varied existing sources, you're going to try to pull out and reassemble bits and pieces from these dozens of notebooks, into a new notebook for your upcoming presentation? And debug that? And then, every time you want to make even some small but significant change in one or a few slides in a many megabyte notebook, you have to re-edit and re-run it? Insane!! In the approach I'm suggesting, and using, any time I want to add a live or interactive demo as one part of a presentation -- and I've been programming interactive onscreen demos for teaching, for research, for professional presentations, and for my own education, using multiple computer tools, since the late 1980s[1] -- it's trivially easy to just add a link to that Mathematica demo or animation (or Flash or QuickTime or whatever material) from within the PDF (or PowerPoint, or Keynote, or whatever) presentation or online document. Mathematica has long been a truly great (even insanely great) tool, overall approach, documentation, and interface, strikes me as just plain insane. ----------------- topic of this post (and which I think is still pretty good nearly two decades later), you can take a look at the link below. Those of you too junior to recall Apple's Knowledge Navigator buzz-phrase, or MIT's Athena Experiment, or the concept of the 3M-3K computer, may find it interesting. [also at ] === Subject: Scaling JPEGs or TIFFs inside PDF slides (using Illustrator)? I often place JPEG or TIFF images (color or B&W) into PDF files, then add or edit title lines, text annotations, arrows, and the like in vector format using Illustrator 11, in order to make PDF slides for projection. This has proven to be a very convenient technique for me to organize and repurpose graphics for presentation -- especially if I start out by cataloging all the slides, or potential slides, that I may want for a certain presentation into an iView MediaPro catalog specifically for that presentation; and then use the very convenient tools and interface in IVMP to organize and manage the presentation, as well as to open the individual slides in Acrobat and Illustrator, edit them or touch them up, and save them back into the presentation. The primary purpose of this note is to ask a minor technical question about that process. That is, sometimes I want to rescale an image in a slide up or down in size by, say, 10 or 20 percent. One way is to go back to the original JPEG or TIFF, make a resized copy of the image in Photoshop Elements, and then replace it in the PDF. An alternative is to rescale the image directly in the PDF document using Illustrator -- and my experience is that Illustrator does an extremely good job of doing this kind of rescaling, even on nasty things like scanned images of B&W printed documents. (They may not look so good when viewed in Illustrator -- but they look extremely good after being saved back to PDF and opened in Acrobat.) My question for the PDF profis here is: When I do this rescaling of a raster image within a PDF document, using Illustrator, is Illustrator actually building a complete new (rescaled) raster image inside the PDF document, and keeping it in the PDF along with the originally placed version? Or does it just keep the rescaled version and discard the original one? Or does it just insert a brief command for the image to be rescaled on the fly any time the PDF is projected or printed? ------------- [And as an addendum, I'm copying this post to cssmm frankly to tweak some of the people who argue that all presentations in the future should and must be done directly from Mathematica notebooks and nothing else (and, secondarily, that _all_ of the capabilities I've mentioned above should and must be built into and carried out from one single, massive, eventually un-learnable and un-documentable Mathematica application. I have no objection at all to making presentations direct from a live Mathematica notebook in situations for example where this might be a not too lengthy, single-topic or one-shot discussion, maybe in a class or group meeting or informal situation, of material that can be covered from a single Mathematica notebook. That makes total sense. But suppose you have a collection of literally many hundreds if not thousands of slides and graphics, some generated by Mathematica, others collected from all over the place, over many years; and you're continually re-organizing and re-purposing and revising these (or copies of them), for presentations at different levels, to different audiences, or in different formats, on screen, in reports, in papers, in books. Suppose, as would be the case if you insisted on the Mathematica notebook only approach, that these materials may have come from many dozens of different Mathematica notebooks, assembled over a dozen plus years, in a half-dozen successive versions of Mathematica (so that some of these notebooks will not even execute any more; and those that still do are likely produce different results than they originally did). So, to do this repurposing, or assembling a new presentation from a lot of varied existing sources, you're going to try to pull out and reassemble bits and pieces from these dozens of notebooks, into a new notebook for your upcoming presentation? And debug that? And then, every time you want to make even some small but significant change in one or a few slides in a many megabyte notebook, you have to re-edit and re-run it? Insane!! In the approach I'm suggesting, and using, any time I want to add a live or interactive demo as one part of a presentation -- and I've been programming interactive onscreen demos for teaching, for research, for professional presentations, and for my own education, using multiple computer tools, since the late 1980s[1] -- it's trivially easy to just add a link to that Mathematica demo or animation (or Flash or QuickTime or whatever material) from within the PDF (or PowerPoint, or Keynote, or whatever) presentation or online document. Mathematica has long been a truly great (even insanely great) tool, overall approach, documentation, and interface, strikes me as just plain insane. ----------------- topic of this post (and which I think is still pretty good nearly two decades later), you can take a look at the link below. Those of you too junior to recall Apple's Knowledge Navigator buzz-phrase, or MIT's Athena Experiment, or the concept of the 3M-3K computer, may find it interesting. [also at ] === Subject: Re: Scaling JPEGs or TIFFs inside PDF slides (using Illustrator)? > I often place JPEG or TIFF images (color or B&W) into PDF files, then > add or edit title lines, text annotations, arrows, and the like in > vector format using Illustrator 11, in order to make PDF slides for > projection. This has proven to be a very convenient technique for me to organize and > repurpose graphics for presentation -- especially if I start out by > cataloging all the slides, or potential slides, that I may want for a > certain presentation into an iView MediaPro catalog specifically for > that presentation; and then use the very convenient tools and interface > in IVMP to organize and manage the presentation, as well as to open the > individual slides in Acrobat and Illustrator, edit them or touch them > up, and save them back into the presentation. The primary purpose of this note is to ask a minor technical question > about that process. That is, sometimes I want to rescale an image in a > slide up or down in size by, say, 10 or 20 percent. One way is to go > back to the original JPEG or TIFF, make a resized copy of the image in > Photoshop Elements, and then replace it in the PDF. An alternative is to rescale the image directly in the PDF document > using Illustrator -- and my experience is that Illustrator does an > extremely good job of doing this kind of rescaling, even on nasty things > like scanned images of B&W printed documents. (They may not look so > good when viewed in Illustrator -- but they look extremely good after > being saved back to PDF and opened in Acrobat.) My question for the PDF profis here is: When I do this rescaling of a > raster image within a PDF document, using Illustrator, is Illustrator > actually building a complete new (rescaled) raster image inside the PDF > document, and keeping it in the PDF along with the originally placed > version? Or does it just keep the rescaled version and discard the > original one? Or does it just insert a brief command for the image = to > be rescaled on the fly any time the PDF is projected or printed? > ------------- [And as an addendum, I'm copying this post to cssmm frankly to tweak > some of the people who argue that all presentations in the future should > and must be done directly from Mathematica notebooks and nothing else > (and, secondarily, that _all_ of the capabilities I've mentioned above > should and must be built into and carried out from one single, massive, > eventually un-learnable and un-documentable Mathematica application. I have no objection at all to making presentations direct from a live > Mathematica notebook in situations for example where this might be a not > too lengthy, single-topic or one-shot discussion, maybe in a class or > group meeting or informal situation, of material that can be covered > from a single Mathematica notebook. That makes total sense. But suppose you have a collection of literally many hundreds if not > thousands of slides and graphics, some generated by Mathematica, others > collected from all over the place, over many years; and you're > continually re-organizing and re-purposing and revising these (or copies > of them), for presentations at different levels, to different audiences, > or in different formats, on screen, in reports, in papers, in books. Suppose, as would be the case if you insisted on the Mathematica > notebook only approach, that these materials may have come from many > dozens of different Mathematica notebooks, assembled over a dozen plus > years, in a half-dozen successive versions of Mathematica (so that some > of these notebooks will not even execute any more; and those that still > do are likely produce different results than they originally did). So, to do this repurposing, or assembling a new presentation from a lot > of varied existing sources, you're going to try to pull out and > reassemble bits and pieces from these dozens of notebooks, into a new > notebook for your upcoming presentation? And debug that? And then, > every time you want to make even some small but significant change in > one or a few slides in a many megabyte notebook, you have to re-edit and > re-run it? Insane!! In the approach I'm suggesting, and using, any time I want to add a live > or interactive demo as one part of a presentation -- and I've been > programming interactive onscreen demos for teaching, for research, for > professional presentations, and for my own education, using multiple > computer tools, since the late 1980s[1] -- it's trivially easy to just > add a link to that Mathematica demo or animation (or Flash or QuickTime > or whatever material) from within the PDF (or PowerPoint, or Keynote, or > whatever) presentation or online document. Mathematica has long been a truly great (even insanely great) tool, > overall approach, documentation, and interface, strikes me as just plain > insane. > ----------------- > topic of this post (and which I think is still pretty good nearly two > decades later), you can take a look at the link below. Those of you to= o > junior to recall Apple's Knowledge Navigator buzz-phrase, or MIT's > Athena Experiment, or the concept of the 3M-3K computer, may find it > interesting. [also at ] Is there a particular reason you are using JPEG/TIFF and not vector images? On the occasions that I have imported mathematica graphics into illustrator (and freehand) they were EPS or PDF images. One worked well and one was jnot so well but I can't remember which. Resizing was easy -- just group all the points in the image and resize. === Subject: Re: Scaling JPEGs or TIFFs inside PDF slides (using Illustrator)? > My question for the PDF profis here is: When I do this rescaling of a > raster image within a PDF document, using Illustrator, is Illustrator > actually building a complete new (rescaled) raster image inside the PDF > document, and keeping it in the PDF along with the originally placed > version? Or does it just keep the rescaled version and discard the > original one? Or does it just insert a brief command for the image = to > be rescaled on the fly any time the PDF is projected or printed? I don't have Illustrator, but I would guess that it simply scales the image rather than actually resampling it to a lower resolution. You can use Mathematica to verify. This code will show you the natural dimensions of all raster images on the given page (in this case page 1) of the specified PDF file: Cases[ Import[~/Desktop/GoogleNews.pdf, {PDF, Pages, 1}], x_Raster :> Dimensions[First[x]], Infinity ] -Rob === Subject: Advanced Mathematica Summer School 2009--deadline The April 15 application deadline for the Advanced Mathematica The two-week program is intended for sstudents and professors or professionals with significant Mathematica projects and experience. The foundation of the program is intensive project-work, during which you and your private mentor will map out a strategy and move your project toward completion. As a friendly reminder, only a limited number of slots are available. Click here to apply: http://www.wolfram.com/summerschool/application.cgi http://www.wolfram.com/summerschool 2009 in Champaign, Illinois! Wolfram Research summerschool@wolfram.com === Subject: Variable-name dependence in NDSolve Please, try the following lines one by one. eqs = {x'[t] == -x[t], y'[t] == -y[t], x[0] == x0, y[0] == y0}; NDSolve[eqs /. {x0 -> {1., 1.}, y0 -> 1.}, {x, y}, {t, 0, 1}] (* 1: good *) NDSolve[eqs /. {x0 -> {1., 1.}, y0 -> {1.}}, {x, y}, {t, 0, 1}] (* 2: bad *) NDSolve[eqs /. {x0 -> {1.}, y0 -> {1., 1.}}, {x, y}, {t, 0, 1}] (* 3: good *) NDSolve[eqs /. {x0 -> 1., y0 -> {1., 1.}}, {x, y}, {t, 0, 1}] (* 4: bad *) Note that (2) does not give error messages but does not compute anything. So, sometimes, a real number works better than a one-dimensional list (c.f. 1 and 2); sometimes a one-dimensional list works better than a real number (c.f. 3 and 4) and there is no consistency . This strange result depends on the variable names. This particular result is because x is alphabetically earlier than y. When I replaced the variable name x by z, then the opposite happens. === Subject: Help with Recursive Minimization I tried to minimize a function which itself is a minimum value function. I can plot the function, but cannot get a numerical solution: V1[y_] := Minimize[{0.5 x, x >= 2, x >= y}, {x}][[1]]; Plot[ V1[y] + 3/y, {y, 1, 5}] Minimize[ V1[y] + 3/y, {y, 1, 5}] Appreciate your help Owen === Subject: what went wrong in this ordinary differential eq s = NDSolve[{(x*y'[x])'[x] + Sin[y[x]]*y[x] == 0, y[0] == 1, y'[0] == 0}, y[x], {x, 0, 30}]; Plot[Evaluate[{y[x]} /. s], {x, 0, 30}, PlotStyle -> Automatic] === Subject: ODE problem What went wrong in the foolwoing s = NDSolve[{(x*y'[x])'[x] + Sin[y[x]]*y[x] == 0, y[0] == 1, y'[0] == 0}, y[x], {x, 0, 30}]; Plot[Evaluate[{y[x]} /. s], {x, 0, 30}, PlotStyle -> Automatic] === Subject: Re: UNDO and Mathematica - how useless The backup functions in A WorkLife FrameWork are certainly a help here (also note that there is a cell level backup functton there as well). But it is not quite the solution needed for basic editing and textual input. But I think that a basic Undo functionality in Mathematica is essential. At the very least it needs to be implemented for editing. It is probably not reasonable for it to take into account execution since this can generally involve very large amounts of content. (Actually there is a functionality in A WorkLife FrameWork that allows you to track the execution history in your Mathematica session in the order executed). There is currently a single level immediate undo for textual input. One basic thing that I feel really needs to be implemented is a single Redo at this level. I have very often undone something and then have had to retype everything that I undid because I cannot immediately redo its input. (Note that there is a Global level option in the option inspector that governs how large an Undo can be: MaxUndoSize.) This has burned and frustrated me quite a few times: and I use Mathematica as my primary means for writing as well as computing. So, this is, I feel, a reasonable request and helps promote Mathematica's use more broadly. I am sure that I probably could create a function that does all of this at the level of particular cell styles using CellEventActions. But I think that something along these lines should be implemented at the top level--with Global option inspector settings that govern the number, size, and CellStyles that the undo/redo operate at. I hope that these comments help in thinking these issues through... --David > Ordinary saving the notebook keeps overwriting with the new version. A > much better solution, in the absence of a more complete undo/redo > facility, would be DrMajorBob's Bare Bones Backup button or, for more > complete control, the backup facilities in David Riess' WorkLife FrameWor= k. > -- > Murray Eisenberg mur...@math.umas= s.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: Re: UNDO and Mathematica - how useless is it? As a novice myself, I waste hours because of this. What I try to do, if I remember (!!!) is save my notebook before every edit (or after every successful execution) to a filename with _x added to it. So, notebook.nb has my latest clean, working code in it, and notebook_1.nb has edited code that I'm not sure about. I might keep this numbering going even for successful edits, if I am exploring an idea that I might want to drop at some point. I don't know how to do it, but surely someone out there could write a little bit of code that would do what I do manually for every execution (or you could probably think of better events to trigger it). It wouldn't bother me if I ended up with dozens of similar notebooks, and I would be happy to manually reset the system at sensible intervals. Thinking about it, this sounds a little bit like what I imagine Version Control would do. I do have WorkBench, but found it to be so much more complicated than I expected that I haven't really worked out how to use it. Would any WorkBench experts out there recommend it for an Undo workaround? If so, I might put some effort into learning it. Paul. -----Original Message----- === Subject: Re: UNDO and Mathematica - how useless is it? An open letter to WRI, struggling with undo. I am a disabled user (but am creative and intelligent) and a prospective Home Edition buyer (I have finally got the funds in place today). I *need* an Undo that really works. I make lots of typing errors and yes logical errors too. Besides, being creative and learning is making big and small mistakes and rethinking ones direction. Forgiving software was part of the tech paradigm shift in the 80s and 90s. Did WRI miss that while mastering CA patterns? While learning Mathematica using a trial version, I already lost time/code and become frustrated several times dealing with undo (sometimes it sorta works sometimes its just stupid). Why make it so hard to undo? Does not your QA fight for a real undo? Does not marketing understand undo is a key selling feature? Perhaps for many all the power of Mathematica alone compensates for its limited undo. I have owned hundreds of software apps, beta-tested just as many over my 30 years. I have never seen software that just fails so badly at understanding undo. Perhaps a tutorial on how to deal with undo is wanting, does one already exist?. At least document well how undo works now. Offer tips and tricks how to manage mistakes/errors in one's work other than the brute force of save as and duplicating cells. Finally, As a Mac user, undo is one of the prime directives of OS X gui guidelines. WRI, don't you like having and using a real undo for all your Mac apps (and later for Windows too). Yes, doing a real undo is hard, but it is worth it and shows real respect to your users both new and old. Come on guys, you are all smart enough! If you are wanting to make the Home Edition market succeed, than you need a reasonable undo working shortly in 3-5 months, not 2 years later. I do not need to buy now Home Edition but I really want it now but at the cost of dealing with unpleasant software? I value my time and efforts, and yes undoing mistakes. Important features matter to overall productivity and a sense of polish -- undo is one of them. You want a sale, I want software that works as expected. I can wait it out, for I waited 20 years for Mathematica to be within my reach at age 50. A few more months or years is ok with me. I can set aside those funds for another day. Maybe a formal petition is needed for a proper undo?? If I have erred in my reasoning or understanding how undo currently works, please educate me to be a better productive user of Mathematica. I am willing to learn from my mistakes. Forgiveness in people or software is cool. now... === Subject: Re: UNDO and Mathematica - how useless is it? > As a novice myself, I waste hours because of this. What I try to do, if I > remember (!!!) is save my notebook before every edit (or after every > successful execution) to a filename with _x added to it. So, notebook.nb has > my latest clean, working code in it, and notebook_1.nb has edited code that > I'm not sure about. I might keep this numbering going even for successful > edits, if I am exploring an idea that I might want to drop at some point. I don't know how to do it, but surely someone out there could write a little > bit of code that would do what I do manually for every execution (or you > could probably think of better events to trigger it). It wouldn't bother me > if I ended up with dozens of similar notebooks, and I would be happy to > manually reset the system at sensible intervals. Thinking about it, this sounds a little bit like what I imagine Version > Control would do. I do have WorkBench, but found it to be so much more > complicated than I expected that I haven't really worked out how to use it. > Would any WorkBench experts out there recommend it for an Undo workaround? > If so, I might put some effort into learning it. I think for just having backups for your notebooks the possibility to use a full featured version control system from within the workbench is overkill. The automatic history which eclipse offers for textfiles is AFAIK not something that automatically works for mathematica notebooks (does it? can it work for an external editor at all? I use SVN with workbench which turns automatic local backups off). The following will add a simple menubar to your notebook which will let you save a backup with the current date/time encoded into the filename. Just press the backup button whenever you think is appropriate to create a version. This could of course be further improved and adopted to your needs, maybe a directory hierarchy would be handy to make it easy to delete backups of certain periods that you don't need anymore. Also some additional buttons to manage the versions directly would also be nice and some error checking would certainly also be a good idea. There are no guarantees that this way you will never loose work, but it should basically do what it is supposed to... SetOptions[EvaluationNotebook[], DockedCells -> Append[ DeleteCases[ DockedCells /. Options[EvaluationNotebook[], DockedCells], HoldPattern[Cell[___, CellTags -> {BackupMenuBar}, ___]] ], Cell[BoxData[ToBoxes@Row[{Button[backup, Module[{backupname, backupnb}, backupname = StringReplace[ ToFileName[ FileName /. NotebookInformation[ButtonNotebook[]]], fname___ ~~ .nb :> fname <> _ <> Hour, -, Minute, -, Second}] <> .nb ]; SelectionMove[ButtonNotebook[], All, Notebook]; backupnb = NotebookPut[ Notebook[NotebookRead[ButtonNotebook[]], Visible -> False]]; NotebookSave[backupnb, backupname]; MessageDialog[backup saved to: <> backupname]; NotebookClose[backupnb]; ], Method -> Queued ] }] ], DockedCell, CellTags -> {BackupMenuBar}] ] ] hth, albert === Subject: Re: UNDO and Mathematica - how useless Ordinary saving the notebook keeps overwriting with the new version. A much better solution, in the absence of a more complete undo/redo facility, would be DrMajorBob's Bare Bones Backup button or, for more complete control, the backup facilities in David Riess' WorkLife FrameWork. > The best advice I can givi is save early and often... but I admit that's > not a replacement for Undo. I've gotten used to the situation, as most of us have, but Meitnik still > has a point. Bobby >> An open letter to WRI, struggling with undo. >> I am a disabled user (but am creative and intelligent) and a >> prospective Home Edition buyer (I have finally got the funds in place >> today). I *need* an Undo that really works. I make lots of typing >> errors and yes logical errors too. Besides, being creative and >> learning is making big and small mistakes and rethinking ones >> direction. Forgiving software was part of the tech paradigm shift in >> the 80s and 90s. Did WRI miss that while mastering CA patterns? While >> learning Mathematica using a trial version, I already lost time/code >> and become frustrated several times dealing with undo (sometimes it >> sorta works sometimes its just stupid). Why make it so hard to undo? >> Does not your QA fight for a real undo? Does not marketing understand >> undo is a key selling feature? Perhaps for many all the power of >> Mathematica alone compensates for its limited undo. >> I have owned hundreds of software apps, beta-tested just as many over >> my 30 years. I have never seen software that just fails so badly at >> understanding undo. Perhaps a tutorial on how to deal with undo is >> wanting, does one already exist?. At least document well how undo >> works now. Offer tips and tricks how to manage mistakes/errors in >> one's work other than the brute force of save as and duplicating >> cells. Finally, As a Mac user, undo is one of the prime directives of >> OS X gui guidelines. WRI, don't you like having and using a real undo >> for all your Mac apps (and later for Windows too). Yes, doing a real >> undo is hard, but it is worth it and shows real respect to your users >> both new and old. Come on guys, you are all smart enough! >> If you are wanting to make the Home Edition market succeed, than you >> need a reasonable undo working shortly in 3-5 months, not 2 years >> later. I do not need to buy now Home Edition but I really want it now >> but at the cost of dealing with unpleasant software? I value my time >> and efforts, and yes undoing mistakes. Important features matter to >> overall productivity and a sense of polish -- undo is one of them. You >> want a sale, I want software that works as expected. I can wait it >> out, for I waited 20 years for Mathematica to be within my reach at >> age 50. A few more months or years is ok with me. I can set aside >> those funds for another day. Maybe a formal petition is needed for a >> proper undo?? >> If I have erred in my reasoning or understanding how undo currently >> works, please educate me to be a better productive user of >> Mathematica. I am willing to learn from my mistakes. Forgiveness in >> people or software is cool. >> now... > -- 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: Re: UNDO and Mathematica - how useless is it? The best advice I can givi is save early and often... but I admit that's not a replacement for Undo. I've gotten used to the situation, as most of us have, but Meitnik still has a point. Bobby > An open letter to WRI, struggling with undo. I am a disabled user (but am creative and intelligent) and a > prospective Home Edition buyer (I have finally got the funds in place > today). I *need* an Undo that really works. I make lots of typing > errors and yes logical errors too. Besides, being creative and > learning is making big and small mistakes and rethinking ones > direction. Forgiving software was part of the tech paradigm shift in > the 80s and 90s. Did WRI miss that while mastering CA patterns? While > learning Mathematica using a trial version, I already lost time/code > and become frustrated several times dealing with undo (sometimes it > sorta works sometimes its just stupid). Why make it so hard to undo? > Does not your QA fight for a real undo? Does not marketing understand > undo is a key selling feature? Perhaps for many all the power of > Mathematica alone compensates for its limited undo. I have owned hundreds of software apps, beta-tested just as many over > my 30 years. I have never seen software that just fails so badly at > understanding undo. Perhaps a tutorial on how to deal with undo is > wanting, does one already exist?. At least document well how undo > works now. Offer tips and tricks how to manage mistakes/errors in > one's work other than the brute force of save as and duplicating > cells. Finally, As a Mac user, undo is one of the prime directives of > OS X gui guidelines. WRI, don't you like having and using a real undo > for all your Mac apps (and later for Windows too). Yes, doing a real > undo is hard, but it is worth it and shows real respect to your users > both new and old. Come on guys, you are all smart enough! If you are wanting to make the Home Edition market succeed, than you > need a reasonable undo working shortly in 3-5 months, not 2 years > later. I do not need to buy now Home Edition but I really want it now > but at the cost of dealing with unpleasant software? I value my time > and efforts, and yes undoing mistakes. Important features matter to > overall productivity and a sense of polish -- undo is one of them. You > want a sale, I want software that works as expected. I can wait it > out, for I waited 20 years for Mathematica to be within my reach at > age 50. A few more months or years is ok with me. I can set aside > those funds for another day. Maybe a formal petition is needed for a > proper undo?? If I have erred in my reasoning or understanding how undo currently > works, please educate me to be a better productive user of > Mathematica. I am willing to learn from my mistakes. Forgiveness in > people or software is cool. now... > -- DrMajorBob@bigfoot.com === Subject: Re: UNDO and Mathematica - how useless is it? An open letter to WRI, struggling with undo. I am a disabled user (but am creative and intelligent) and a prospective Home Edition buyer (I have finally got the funds in place today). I *need* an Undo that really works. I make lots of typing errors and yes logical errors too. Besides, being creative and learning is making big and small mistakes and rethinking ones direction. Forgiving software was part of the tech paradigm shift in the 80s and 90s. Did WRI miss that while mastering CA patterns? While learning Mathematica using a trial version, I already lost time/code and become frustrated several times dealing with undo (sometimes it sorta works sometimes its just stupid). Why make it so hard to undo? Does not your QA fight for a real undo? Does not marketing understand undo is a key selling feature? Perhaps for many all the power of Mathematica alone compensates for its limited undo. I have owned hundreds of software apps, beta-tested just as many over my 30 years. I have never seen software that just fails so badly at understanding undo. Perhaps a tutorial on how to deal with undo is wanting, does one already exist?. At least document well how undo works now. Offer tips and tricks how to manage mistakes/errors in one's work other than the brute force of save as and duplicating cells. Finally, As a Mac user, undo is one of the prime directives of OS X gui guidelines. WRI, don't you like having and using a real undo for all your Mac apps (and later for Windows too). Yes, doing a real undo is hard, but it is worth it and shows real respect to your users both new and old. Come on guys, you are all smart enough! If you are wanting to make the Home Edition market succeed, than you need a reasonable undo working shortly in 3-5 months, not 2 years later. I do not need to buy now Home Edition but I really want it now but at the cost of dealing with unpleasant software? I value my time and efforts, and yes undoing mistakes. Important features matter to overall productivity and a sense of polish -- undo is one of them. You want a sale, I want software that works as expected. I can wait it out, for I waited 20 years for Mathematica to be within my reach at age 50. A few more months or years is ok with me. I can set aside those funds for another day. Maybe a formal petition is needed for a proper undo?? If I have erred in my reasoning or understanding how undo currently works, please educate me to be a better productive user of Mathematica. I am willing to learn from my mistakes. Forgiveness in people or software is cool. now... === Subject: Re: StringJoin with ToString Istvan, actually toString was not meant to replace ToString, but only to support your StringJoin functionality in a hidden way. Also, StringJoin[{1, 2, 3}] gives 123, so that only ToString[{1, 2, 3}] can return {1,2,3}. In any case, I would also support David Bailey's suggestion. When I had to do similar things in the past, I used exactly CirclePlus, which is also rather handy to type in the GUI: c+. In the same category, you also find CircleMinus c-, CircleDot c., CircleTimes c* and perhaps some more. So you can avoid tampering with built-in functions and keep effective shorthands. Unfortunately, only <> works also in the text interface, but you might use NonCommutativeMultiply (**), if you do not already use it for other reasons: Unprotect[NonCommutativeMultiply]; NonCommutativeMultiply[expr___]:=StringJoin@@(toString/@{expr}); Protect[NonCommutativeMultiply]; 1 ** b ** c // InputForm 1bc ADL > I was too hasty posting my reply: First, I'm extremely sorry to mix up your name, ADL. > Second: this code of you does only half of the job: It can not convert > lists to strings verbatim, > that is toString[{1,2,3}] gives {1,2,3} instead of {1,2,3}. > ... > Istvan Zachar === Subject: Re: StringJoin with ToString I was too hasty posting my reply: First, I'm extremely sorry to mix up your name, ADL. Second: this code of you does only half of the job: It can not convert lists to strings verbatim, that is toString[{1,2,3}] gives {1,2,3} instead of {1,2,3}. Which (as it seems to me) is exactly the problem causing the wrong pinting of Messages. Still I wonder whether there is a reliable solution to apply ToString to inputs of StringJoin without explicitely writing it each time I call StringJoin. If I use a different name (e.g. ExtendedStringJoin, as it was suggested), I loose the effective shorthand version (<>), as it would still use the original function. Is there a way to overwrite at least the definitions of the infix operator? Istvan > With the following definitions, your idea appears to work (at least in > a few examples I tested): ClearAll[toString]; > toString[x_?NumericQ, format___] := ToString[x, format]; > toString[x_[y__], format___] := x @@ (toString /@ {y}); > toString[x_Symbol, format___] := ToString[x, format]; > toString[x_, format___] := x; Unprotect[System`StringJoin]; > Unprotect[$UseNewStringJoin]; > $UseNewStringJoin = True; > System`StringJoin[expr___] := > Block[{$UseNewStringJoin = False}, > StringJoin@@ (toString /@ {expr})] /; TrueQ[$UseNewStringJoin]; > Protect[$UseNewStringJoin]; > Protect[System`StringJoin]; The problem was the way ToString works, which is incompatible with > intermediate formatting functions. The definition of toString does > the job. In[12]:=StringJoin[{1, 2, 3}] // InputForm Out[12]//InputForm= > 123 In[13]:=StringJoin[1, a, 3] // InputForm Out[13]//InputForm= > 1a3 In[17]:=StringJoin[1, 2, [Pi]] // InputForm Out[17]//InputForm= > 12Pi In[15]:= Append[dummy, 2] During evaluation of In[15]:= Append::normal: Nonatomic expression > expected at position 1 in Append[dummy,2]. > > Out[15]= Append[dummy,2] ADL > It is quite interesting whyStringJoindoes not apply ToString to > those arguments which are non-string. I've overridden the built-in >StringJoin, to save a few unnecessary ToStrings by the standard method > (the context specifications are necessary for packaging): ... > Istvan Zachar === Subject: Re: StringJoin with ToString > If I use a different name (e.g. ExtendedStringJoin, as it was > suggested), I loose the effective shorthand version (<>), as it would > still use the original function. Is there a way to overwrite at least > the definitions of the infix operator? You can't overwrite it (as far as I know), and in some ways that would be as bad as redefining the actual function, but you can co-opt an unused operator: In[1]:= SetAttributes[CirclePlus, Flat]; SetAttributes[CirclePlus, OneIdentity]; In[3]:= CirclePlus[x___] := f[x] In[4]:= a[CirclePlus]b[CirclePlus]c[CirclePlus]d Out[4]= f[a, b, c, d] David Bailey http://www.dbaileyconsultancy.co.uk === Subject: Re: StringJoin with ToString with your extension the code works fine so far. For those who warned me not to play with system symbols: I use this modified StringJoin in a program where it can produce onyl two types of string outputs: either one that is printed for verbosing (i.e. just for me to check behaviour of the code) or a string that is used as a path of some file to be saved. In both situations any erroneous behaviour would be immediatley recognized, since either the text printed would be garbled, or the file/directory would not be created, thus I do not afraid using the modified StringJoin in this controlled environment. Istvan === Subject: Change in NSolve algorithm Has anyone noticed that the algorithm used by NSolve has changed in V7? I think the change is mostly for the better, but not exclusively. To see the change, enter the following in both V7 (7.0.0 or 7.0.1) and any version < 7.0: Abs[sols = z /. NSolve[z^200 == 1, z]] In V7, Mathematica correctly generates a list of 1.0s. In versions prior to V7, numerical error creeps in so you get numbers ranging from 0.004 to 2.55. V7 is noticeably faster, too. To visualize the error in V6, you can enter ListPlot[{Re[#], Im[#]} & /@ sols, AspectRatio -> Automatic] Of course, you should get a circle. On the other hand, V7 fares slightly worse with Wilkinson's polynomial: sols = x/.NSolve[Expand[Product[x-i, {i,1,20}] == 0,x]]; Norm[Table[sols[[i]] - i, {i, 1, 20}]] I get 0.087351 from V6 and 0.26578 in V7. Also, V6 returns all real solutions, while V7 returns some complex. Of course, the change is platform independent. I haven't played with it extensively, but I think this is probably a net big improvement. Mark McClure === Subject: Re: Constructing Lists: Alternating accumulation? Here is one method, but I hope you will get something more direct. Make a list of increments that is long enough. increments = Table[{3, 2}, {5}] // Flatten {3, 2, 3, 2, 3, 2, 3, 2, 3, 2} Then use FoldList and chop off elements greater than the cutoff. FoldList[#1 + #2 &, 0, increments]; % /. x_Integer /; x > 16 -> Sequence[] {0, 3, 5, 8, 10, 13, 15} David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ problem: data: start = 0; a = 3; b = 2; cutoff = 16; needed output: {0, 3, 5, 8, 10, 13, 15} a different start value must shift the entire list accordingly. === Subject: Re: Constructing Lists: Alternating accumulation? start = 0; a = 3; b = 2; cutoff = 16; Riffle[Range[start, cutoff, a + b], Range[start + a, cutoff, a + b]] {0, 3, 5, 8, 10, 13, 15} Bobby > problem: data: > start = 0; a = 3; b = 2; cutoff = 16; needed output: > {0, 3, 5, 8, 10, 13, 15} a different start value must shift the entire list accordingly. -- DrMajorBob@bigfoot.com === Subject: Constructing Lists: Alternating accumulation? problem: data: start = 0; a = 3; b = 2; cutoff = 16; needed output: {0, 3, 5, 8, 10, 13, 15} a different start value must shift the entire list accordingly. === Subject: Re: Constructing Lists: Alternating accumulation? May not be very elegant, but has its generality: increments={3,2}; cutoff=16; list={0}; i=0; While[(element=Last[list]+increments[[Mod[i,Length[increments]]+1]]) <=cutoff, AppendTo[list,element];i++ ]; list ==> {0,3,5,8,10,13,15} increments={4,3,2,1}; cutoff=60; list={0}; i=0; While[(element=Last[list]+increments[[Mod[i,Length[increments]]+1]]) <=cutoff, AppendTo[list,element];i++ ]; list ==> {0,4,7,9,10,14,17,19,20,24,27,29,30,34,37,39,40,44,47,49,50,54,57,59,60} ADL > problem: data: > start = 0; a = 3; b = 2; cutoff = 16; needed output: > {0, 3, 5, 8, 10, 13, 15} a different start value must shift the entire list accordingly. > === Subject: Re: Constructing Lists: Alternating accumulation? start = 0; increments = {3, 2}; cutoff = 16; max = start; result = {start}; While[(max = max + increments[[1]]) <= cutoff, AppendTo[result, max]; increments = RotateLeft[increments]] result {0, 3, 5, 8, 10, 13, 15} -Francesco > problem: data: > start = 0; a = 3; b = 2; cutoff = 16; needed output: > {0, 3, 5, 8, 10, 13, 15} a different start value must shift the entire list accordingly. === Subject: Brace, bracket pretty format needed Hi Due to my visual limitations, trying to keep track of all the braces/ brackets can become very frustrating for me. I need some button on a palette that will indent and clean up the braces/brackets so I can tell what is going on. The color change for unmatched stuff is good but what I really want is a different color for each level of you === Subject: Mathematica behavior using highlighting and keyboard arrows - BUG??? I have been puzzled by the way that Mathematica handles highlighting when using the keyboard arrow keys. For example if the cursor is in an Input cell in the middle of any expression and you press and hold the Shift key and then press the right-arrow key to highlight each character for each press of the right-arrow key, and then if you accidently go one or more characters too far (the repeat rate of the key faster than my reaction time), and then I try and back up to the intended correct position by letting go of the right-arrow key and press the left-arrow key while still pressing the Shift, the highlighting is extended to the left of the original starting position, not the current position of the cursor, so instead of correcting the overshoot you end up with even more unwanted highlighted portion of an expression or text. And the most bizarre thing about this is that the behavior is different depending on whether it's a Text or an Input style cell, in that Input style cells do it this way and Text style cells do it as I would expect. The net result is that you have to start all over to correctly highlight the portion of the cell expression you wanted to highlight for subsequent Copy/Paste operation somewhere else for these Input cells. Is this a bug or a feature? Does this work the same on Windows and Linux and all the other versions of Mathematica? I am on a Mac OS X system. When you use the mouse to drag the current position cursor this behavior does not occur either, in that there is an original start position and as you drag the mouse to the left or right of this start position, the intervening text is highlighted as you would expect. So why the difference? The Up/Down arrow keys DO NOT have this same behavior when trying to highlight multiple cells, so this also seems inconsistent if this is a feature rather than a bug. I even looked up in the old Stephen Wolfram Mathematica book and it talks about the using the arrow keys to highlight two-dimensional expressions (on the bottom of page 180 if you wish to look), and it says that the definitions for the arrow keys are move to the next character for the right-arrow and move to the previous character for the left-arrow. So on that basis it would appear this is indeed a bug. I agree that it's not talking specifically about high-lighting, but the fact that highlighting seems to break this definition of what right-arrow and left-arrow do, seems to be another reason this behavior a bug. Would some of the people who have been using Mathematica for many, many years please comment on whether this has always been the way this highlighting with arrow keys has worked? Has it been this way since version 1.0? If not, when did it change and why? What is the reason for this seemingly inconsistent behaviour? (inconsistent between the way highlighting works between left-right and up-down and mouse- dragging highlighting) Comments??? -Bob === Subject: Importing a large image... So, my fellow denizens of the group. I have a very large TIFF image--roughly 700MB in size. Its dimension are 43201 by 15601. It is single color with a bit depth of 8. without maxing out the memory. I actually do not need to read in the whole file: I'd be happen with being able to break the file into a number of smaller TIFFs which tile it completely and then process each on independently (I am needing to act on the data in various ways to yield a processed result for further analysis down the line). This is all for a larger project for a consulting client of mine. Any suggestions for how to programmatically carve up the image without having to completely read it in first? I am looking for quick solutions rather than ones that require a lot of programming. Either it can be done pretty simply, or (more likely) Mathematica chokes on these very large files. (Photoshop, on the other hand, does not choke on it at all, nor do some other programs that are optimized for image analysis such as ENVI (http://www.ittvis.com/ProductServices/ENVI.aspx): but I don't want to work with these... nor do I have them....) Of course this leads to a suggestion for the Import function: to allow reading in only a part of an image at a time. Feel free to respond to the list, but also CC me on the replies so that I get them sooner than the usual turnaround. --David === Subject: Re: Controlling axes lengths in Plots The Presentations package should be able to do that. It has the primitives XTickScale and YTickScale for drawing free standing scales. It also makes it easy to combine various elements in one drawing statement. So think of a piece of paper. 1) Make your plots without a frame or ticks, FrameLabel or PlotLabel. 2) Inset each plot in a fixed 'frame' on the piece of paper. 3) For each plot you can then draw tick scales just outside the frame region. The TickScale routines allow you specify that a given length on the piece of paper corresponds to a given scale. 4) You can add any other things on the piece of paper such as Text labels. This might require a certain amount of work if each plot has different scales and labels around it. David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ Has anybody found a good technique to assume absolute control over the lengths of the axes in a 2D plot? I often have to build several graphs to be overlaid using transitions in presentation software and want to keep the plot area consistent for smooth transitions. ImageSize only gives control over dimensions of the resulting graphic. If there are frame labels or legends that change in size from one graph to the next than the whole graphic is constrained by ImageSize, shrinking my plot area. I have several workarounds, all of which break eventually. What I would really like is a FrameSize->{} option that overrides ImageSize and lets me set the dimensions of the plot area directly. Daniel === Subject: Re: Controlling axes lengths in Plots Hi Daniel, > Has anybody found a good technique to assume absolute control > over the lengths of the axes in a 2D plot? I often have to > build several graphs to be overlaid using transitions in > presentation software and want to keep the plot area > consistent for smooth transitions. ImageSize only gives control over dimensions of the resulting > graphic. If there are frame labels or legends that change in > size from one graph to the next than the whole graphic is > constrained by ImageSize, shrinking my plot area. I have several workarounds, all of which break eventually. > What I would really like is a FrameSize->{} option that > overrides ImageSize and lets me set the dimensions of the > plot area directly. It's not a good technique, but playing with AspectRatio and ImageSize gets me a lot of the way. YMMV, Dave === Subject: Controlling axes lengths in Plots Has anybody found a good technique to assume absolute control over the lengths of the axes in a 2D plot? I often have to build several graphs to be overlaid using transitions in presentation software and want to keep the plot area consistent for smooth transitions. ImageSize only gives control over dimensions of the resulting graphic. If there are frame labels or legends that change in size from one graph to the next than the whole graphic is constrained by ImageSize, shrinking my plot area. I have several workarounds, all of which break eventually. What I would really like is a FrameSize->{} option that overrides ImageSize and lets me set the dimensions of the plot area directly. Daniel === Subject: Re: Controlling axes lengths in Plots Hi Daniel: I too, have wished it were easier. The closest thing I found from Wolfram is to use Image padding, and even then it might only apply to things like GraphicsGrid. The online documentation is found here: http://reference.wolfram.com/mathematica/howto/AlignPlotsWithEachOther.html The alternative is to get David Park's Presentations package which provides a different approach for graphics customization. Great bang for your buck. http://home.comcast.net/~djmpark/DrawGraphicsPage= .html And some examples are here: http://blackbook.mcs.st-and.ac.uk/~Peter/djmpar= k/html/ I find David's approach is more natural for customization in graphics than using Mathematica's built in functions. While Mathematica makes some of the best visualizations going, it seems that if it's not specific function built for your purpose, the tweaking can be painful. For example, using the ImagePadding option I mentioned above, it seems that you'll have to calculate yourself what the padding values should be. If you come across anything better, let me know... t. > Has anybody found a good technique to assume absolute control over the > lengths of the axes in a 2D plot? I often have to build several > graphs to be overlaid using transitions in presentation software and > want to keep the plot area consistent for smooth transitions. ImageSize only gives control over dimensions of the resulting > graphic. If there are frame labels or legends that change in size > from one graph to the next than the whole graphic is constrained by > ImageSize, shrinking my plot area. I have several workarounds, all of which break eventually. What I > would really like is a FrameSize->{} option that overrides ImageSize > and lets me set the dimensions of the plot area directly. Daniel === Subject: Re: complicated list selector that was educational for me === Subject: Re: Constructing Lists: Alternating accumulation? >problem: >data: start = 0; a = 3; b = 2; cutoff = 16; >needed output: {0, 3, 5, 8, 10, 13, 15} >a different start value must shift the entire list accordingly. >how to? In[9]:= Accumulate@ Join[{start}, Flatten@Table[{a, b}, {Floor[cutoff/(a + b)]}]] Out[9]= {0,3,5,8,10,13,15} === Subject: Re: Why does ImageCompose degrade the result and can you do anything >I wanted to play around with one of the new version 7 image >routines, called ImageCompose[], which can be used to add images >together. >When I was trying to use it, the resultant image was a much degraded >image for some of the examples I was playing with, compared to the >originals (looked like the resolution was significantly less than >the originals), so when you change the magnification the resultant >image gets worse and worse and worse as you increase the >magnification. Especially noticeable was the text on the tick >labels, and the jaggies in the curves and the rasterization becomes >more and more prominent, even though the original images don't show >this. >So, anyone have an idea of why ImageCompose does this and is there a >way to use it to add two images together and have the result be as >good as the originals, as long as the two have the same resolution? >Here is an simple example that shows what I mean: >i1 = Plot[Sin[x], {x, -3 Pi, 3 Pi}] >i2 = Plot[Cos[x], {x, -3 Pi, 3 Pi}] >ImageCompose[i1, i2] >So if you up the magnification the ImageCompose version gets more >and more jaggies, as well as the axes and ticks and tick labels >getting worse and worse. The issue is certain to be the difference between vector graphics and bit-mapped graphics. Although the documentation does not explicitly state graphics are converted to bit-mapped versions before ImageCompose does its thing, it seems fairly clear this must be the case. Else, the documentation which discusses pixel by pixel overlay or maintaining the same pixel size would make no sense. In the particular example you give, neither i1 nor i2 are bit-mapped. So, you are free to increase the magnification without getting jaggies. But once these graphics get changed to bit-mapped by ImageCompose increased magnification will expose jaggies etc as is the case with any bit-mapped graphic. The documentation makes it clear the size of the image returned by ImageCompose is determined by the first argument. So, to achieve the resolution you want in the final image you will need to set the size of first image appropriately. === Subject: Re: Replace Table[Sum...]...] with Functional code mm[data_, period_] := Table[ Sum[(Log[data[[t]]] - Log[data[[t - i]]])/Sqrt[i], {i, 1, period}]/period, {t, period + 1, Length[data]}] mm2[data_, period_] := Module[ {logData = Log[data], d = Sqrt[Range[period, 1, -1]]}, Mean[#/d] & /@ (Drop[logData, period] - Most[Partition[logData, period, 1]])] data = Array[x, {500}]; period = Random[Integer, {20, 100}] 41 Timing[r1 = mm[data, period];] {0.459393,Null} Timing[r2 = mm2[data, period];] {0.228474,Null} %/%% {0.497339,1} r1 == r2 True Bob Hanlon I use the following two functions to analyze time series: mm[data_, period_] := Table[Sum[(Log[data[[t]]] - Log[data[[t - i]]]) / Sqrt[i], {i, 1, period}] / period, {t, period + 1, Length[data]}] mr[data_, period_] := Table[Sum[Log[data[[t - i]] / data[[-i + t - 1]]] * (Sqrt[i] - Sqrt[i - 1]), {i, 1, period}],{t, period + 2, Length[data]}] They have a similar structure, Table[Sum[...]...], which sums a bunch of stuff from the time series at each point in the series. I'd like to convert them into functional programing constructs, but as the increments in the Table function come into play in the Sum, I haven't been able to figure out a way to do it. I've tried Map with Partition and a bunch of other things, but I could use some pointers. Any help much appreciated. === Subject: Contour Plots of Lists I'm familiar with the straightforward and simple commands of Mathematica, but am a bit unsure of how to do this. I have a complicated function f(z) that must be integrated from a known point to a parameter, z = s. Call this F(s). Mathematica can do the integral provided I tell it how to do it on a case-by-case basis. I need a contour plot of F(s) (s is complex). So I would need to program something like this: Create 100x100 mesh in [x, y] For 1:100 --For 1:100 ----Calculate F(x + iy) using specific fashion --end end ContourPlot[x, y, Abs[F]] Is there a way to do ContourPlots on discrete meshes? (I guess they're called Lists in Mathematica) === Subject: Re: Problem with Import[] and math.exe Finally, David M. from the technical support team contacted me. I can now schedule a task using the following syntax: C:Program FilesWolfram ResearchMathematica7.0math.exe -run < C: Temptest.m === Subject: Re: Problem with Import[] and math.exe > I encountered a bug withImport(confirmed by someone at WRI) under > these conditions using version 6.0. My current method of starting > MathKernel is to use a small C program (which has an icon that can sit > on the desktop) which starts the kernel via MathLink, and passes it a > Get command on a file of Mathematica commands. There are several ways to start Math - such as piping the input, or > using one of the other command line options, and I don't remember > exactly what worked and what didn't (there seemed to be various > gotcha's), but I ended up with the above solution, which works well. David Baileyhttp://www.dbaileyconsultancy.co.uk Hi David! === Subject: Re: Map to nested list Map[IntegerQ, list, {2}] {{True, False}, {True, False}} David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ this expression IntegerQ/@{1,1/5} outputs {True, False} which operator is used for nested list? so IntegerQ ? {{1,1/5},{1,1/5}} outputs {{True, False},{True, False}} thankyou :) === Subject: Map to nested list this expression IntegerQ/@{1,1/5} outputs {True, False} which operator is used for nested list? so IntegerQ ? {{1,1/5},{1,1/5}} outputs {{True, False},{True, False}} thankyou :) === Subject: Re: Can't figure out how to export strictly speaking, you don't export to LaTeX. All LaTeX will do [ beautifully ] is pick up the image you've saved to disk from Mathematica and include it within your final compiled document [ probably a PDF ]. Peter 2009/4/3 Gerry Flanagan : > I believe the only direct path (no intermediate third-party software) is > to copy-as an image, such as bit-map, and paste. I just started > experimenting with MathType 6.5 (not the version that ships with Word). > It will allow you to paste in a Mathematica equation. It seems to do a > reasonable job, at least for moderate size and complexity equations. The > best answer is to probably to export to LaTex, then find some software > to use the tex in word, but I'm less familiar with that route. > Gerry F. > I help out my lab partners in one of my classes by exporting out the dat= a and equations we worked on from mathematica. They use microsoft word so I= need to copy or export things into rtf first or copy things directly into = microsoft word. The problem is that many symbols come out strangely when I = try to export or even copy them the tables and math notation comes out like= --- >> {[Null], !(*SubscriptBox[(F), (1)]), !(*SubscriptBox[= (d), (1)]), !(*SubscriptBox[(=83=E4), (1)]), !(*Subscrip= tBox[(F), (2)]), >> It seems like there is something not set up the way I want to in the exp= ort or copy functions... Also, when exporting to rtf, the tables come out a= s a list of data instead of being in the correct form. Another system used = to export this stuff out to rtf correctly by default... How do I set up mat= hematica to do the same? > -- Peter Lindsay === Subject: Re: Please help, factorisation question thank you for your solution I regret to say that i had failed to specify that the elements of the list nn are rationals a/b, not integers can you think of a way to modify the algorithm so it gives a result in this case ? === Subject: Re: Interpolation -> segfault? . > your InterpolationFunction[] cause the kernel crash and it would helpful > to find out where it come from .. The input seems to be nonsense and it is no wonder that the kernel > crashes. > Nonsensical? It's a standard InterpolatingFunction object. I don't know what you mean. The function is made by (1) using FunctionInterpolation on a very complicated, slow-to-evaluate expression to create an object f1; (2) wrapping it with If[#1<... || #1> ..., 0, fn]; and then (3) using 'Save'. That'sit. The original function, before saving, does evaluate fine: I've used it to create other data products (e.g., with NIntegrate). Just hangs when restoring it. Also, I recently discovered that the function as above works fine if you manually change only a few of the very small numbers (10^(-316) !) to 0. And, going back to the original code, adding 'Chop' before I do the FunctionInterpolation yields an object that saves and restores without trouble. I therefore *strongly suspect* this is an issue pertaining to the precision with which the object was saved. === Subject: Re: Styling the selected Tab's label in TabView > Bryce, If your labels are just strings then why use Graphics and Text to display > them? > Because I was starting from that example, I guess... since you've suggested that I don't need to use Graphics+Text, I've tried this: labels = {Bill, Susan}; DynamicModule[ {selected}, TabView[ Table[ With[ {i = i}, Style[ Text[labels[[i]]], ] -> (Hello <> labels[[i]] <> !) ], {i, Length[labels]} ], Dynamic[selected] ] ] It doesn't have the sizing issue, but now it doesn't style dynamically either. -- Bryce Schober === Subject: Re: Styling the selected Tab's label in TabView > It seems that you can't set the LabelStyle of individual tabs in a TabView. What is wrong with: labels = {Bill, Susan}; DynamicModule[{selected}, TabView[Table[ With[{i = i}, Style[labels[[i]], FontWeight -> labels[[i]] <> !)], {i, Length[labels]}], Dynamic[selected]]] Which version are you using? hth, albert === Subject: Re: Styling the selected Tab's label in TabView Bryce, If your labels are just strings then why use Graphics and Text to display them? labels = {Bill, Susan}; DynamicModule[{selected}, TabView[Table[ With[{i = i}, Style[labels[[i]], FontWeight -> labels[[i]] <> !)], {i, Length[labels]}], Dynamic[selected]]] But if you want to use Graphics then use the ImageSize Option to control the size. labels = {Bill, Susan}; DynamicModule[{selected}, TabView[Table[ With[{i = i}, Graphics[ Style[Text[labels[[i]]], ImageSize -> 25, PlotRangePadding -> .5] -> (Hello <> labels[[i]] <> !)], {i, Length[labels]}], Dynamic[selected]]] David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ It seems that you can't set the LabelStyle of individual tabs in a TabView. Starting with the example in my TabView->Examples->Scope->Control documentation, I got to: labels = {Bill, Susan}; DynamicModule[ {selected}, TabView[ Table[ With[ {i = i}, Graphics[ Style[ Text[labels[[i]]], FontWeight -> Dynamic[ Bold, Plain ] ] ], ImageSize -> All, PlotRangePadding -> .5 ] -> (Hello <> labels[[i]] <> !) ], {i, Length[labels]} ], Dynamic[selected] ] ] This manages to bold the selected tab, but ImageSize -> All isn't limiting itself to the size of the Text[], and I'm not sure how to limit the resulting tab size to only that required for the text display... -- Bryce Schober === Subject: Re: Graphics and DisplayFunction > I would forget about the DisplayFunction option - it is more or > less obsolete. If DisplayFunction -> f is used as an option to a Plot function or Show, then f is applied to the result. Since the default value of DisplayFunction is $DisplayFunction, this makes $DisplayFunction something like $Post for graphical commands. This can be quite handy. Here are three example settings for $DisplayFunction. * Create a tooltip when hovering over a graph: $DisplayFunction = Tooltip[#, On graph!] &; * Show graph and also auto-export to a file: cnt = 0; $DisplayFunction = ( Export[pic <> ToString[++cnt] <> .png,#]; # )&; * Send graphics to another program: df[g_] := Module[ {strm}, strm = OpenWrite[!open -f -a /Applications/Preview.app]; WriteString[strm, ExportString[g, EPS]]; Close[strm] ]; $DisplayFunction = df; After defining $DisplayFunction by entering any of these commands, simply enter a graphical command, like Plot[x^2, {x,-2,2}], to see it in action. The last example is set up to pipe the output to Preview.app on the Mac, but I suppose that something similar would work on the PC. This last one is most interesting if you're running a text based interface, like the Mac Terminal. To get it to work in that context you need to install a front end as well by first entering: Developer`InstallFrontEnd[]; I actually do this frequently when manipulating Mathematica from other programs. So, have fun with DisplayFunction, Mark McClure === Subject: Re: Graphics and DisplayFunction Of course one can forget about DisplayFunction and use Print, but for me a more elaborate function does the job: Since I have plotting functions deeply embedded in code and in packages (and for other reasons), I actually have to maintain a DisplayFunction, which - through user-defined switches - redirects results to various outputs, possibly not just to the actual notebook, but simultaneously to notebook AND multiple files as well. Also a problem with your method is that by Printing a Graphics, you end up with something that is NOT a Graphics object, but in my case (I don't want to get to the complex details) I definitely need something in return that is a Graphics object. I have everything working for years now, just this bit (the topic, i.e. Graphics are not affected by DisplayFunction) caused some malfunctions in the previous days. Istvan I would forget about the DisplayFunction option - it is more or less > obsolete. Just think of graphics as output - just like numbers or equatio= ns. If you do a calculation, and then as the last step generate a graphical > output (either explicitly with Graphics, or indirectly using Plot (say), > then providing you don't terminate that command with a semicolon, you > will get your graphical output, for example: xx = 10; > yy = 20; > Graphics[{Line[{{-xx/2, 0}, {xx/2, 0}}], > Line[{{0, -yy/2}, {0, yy/2}}]}] If, however, you want to go on and calculate something else (or make > another graph), simply print your graphical output (again, exactly as > you would for text): xx = 10; > yy = 20; > Print[Graphics[{Line[{{-xx/2, 0}, {xx/2, 0}}], > Line[{{0, -yy/2}, {0, yy/2}}]}]]; > Print[Something else ,Sqrt[xx]]; === Subject: Re: help in constructing a binomial consequence Hi Galina, I'm not sure why your topic title uses the word binomial. It suggests the coefficients of your sequence should be binomial but your example doesn't show any such coefficients. Furthermore, your series is a bit irregular. The first few start with x having the highest power, then decreasing, but F[7] - F[9] do not adhere to that pattern. Assuming you're mistaken here and F[7] should be x^3, F[8] x^2 y, F[9] x y^2 and F[10] y^3, F can be given by F[n_] := Module[{t, m}, t = [LeftFloor]1/2 (-1 + Sqrt[1 + 8 (-1 + n)])[RightFloor]; m = n - 1 - 1/2 t (1 + t); x ^(t - m) y^m ] I leave it as an exercise to you to determine why the variables t and m have these specific values. A brute-force approach, but easier to understand, would be F[i_] := Flatten[Table[x ^(n - r) y^r, {n, 0, i}, {r, 0, n}]][[i]]. It does more calculations than necessary, but I assume i will never get very high. > Hello all, > I need to find an eigenvalues of the matrix M [N*N] where elements > are of the type F[i]*F[j]. I need help to construct the elements F[i] > which must be in the following order: F[1]=1, F[2]=x, F[3]=y, F[4] > =x^2, F[5]=x*y, F[6]=y^2, F[7]=y*x^2, F[8]=x*y^2, F[9]=x^3 an= d etc.... > Could someone help, please? Galina === Subject: Re: help in constructing a binomial consequence if it must be that order and you cant give us the rule for that order you have to type it by hand otherwise With[{n = 3}, lst = Flatten[ Outer[Times, Table[x^i, {i, 0, n}], Table[y^j, {j, 0, n}]], 1] ] exponentSum[expr_] := Block[{ex, ey}, ex = Exponent[expr, x]; ey = Exponent[expr, y]; ex + ey ] and Sort[lst, exponentSum[#1] < exponentSum[#2] || OrderedQ[{#1, #2}] &] will do something that is very close to your ordering. Jens > Hello all, > I need to find an eigenvalues of the matrix M [N*N] where elements > are of the type F[i]*F[j]. I need help to construct the elements F[i] > which must be in the following order: F[1]=1, F[2]=x, F[3]=y, F[4] > =x^2, F[5]=x*y, F[6]=y^2, F[7]=y*x^2, F[8]=x*y^2, F[9]=x^3 and etc.... > Could someone help, please? Galina > === Subject: Re: help in constructing a binomial consequence > I need to find an eigenvalues of the matrix M [N*N] where elements > are of the type F[i]*F[j]. I need help to construct the elements F[i] > which must be in the following order: F[1]=1, F[2]=x, F[3]=y, F[4] > =x^2, F[5]=x*y, F[6]=y^2, F[7]=y*x^2, F[8]=x*y^2, F[9]=x^3 an= d etc.... Your pattern seems a bit off. I'm guessing you mean: 1, x, y, x^2, x y, y^2, x^3, x^2 y, x y^2, y^3 In this case, you can define your F like so: biRow[n_] := Table[x^(n - k)*y^k, {k, 0, n}]; Clear[F]; m = 0; Do[F[++m] = binom, {binom, Flatten[Table[biRow[n], {n, 0, 3}]]}]; Then, you can define your matrix via: M = Table[F[i]*F[j], {i, 1, m}, {j, 1, m}]; I'm guessing these matrices all have rank 1. Thus, you can find the only non-zero eigenvalue via: Eigenvalues[M] // Last Mark McClure === Subject: Re: Deleting entire row and/or column Really? I wish I could see it. Bobby > Ah, I like the Nest/Transpose solution. > -- DrMajorBob@bigfoot.com === Subject: Re: Deleting entire row and/or column Ah, I like the Nest/Transpose solution. === Subject: Re: passing an array variable as a file name string to FindList Hi Venkatesh, There must be many ways to do this. I'll provide you with three examples, two of them the Fortran way and one the Mathematica way (don't worry, they all work in Mathematica). myFileNames = FileNames[]; (* Classis Fortran style; long; i is an index in the list*) Do[ FindList[myFileNames[[i]], top secret] // Print, {i, 1, Length[myFileNames]} ] (*Fortran style; slightly shorter; i itself gets the successive values of the list*) Do[ FindList[i, top secret] // Print, {i, myFileNames} ] (*Mathematica functional programming style, /@ is shorthand infix notation for Map; # and & are used to make a pure function*) FindList[#, top secret] & /@ myFileNames On Apr 3, 11:05 am, Venkatesh Ramakrishnan 2. I wish to read each one of them and extract some information. Now, Flatten[Table[FileNames[]]] will give me all the file names in a table. So, An array variable with the subscript that contains the loop counter > will > give me the filenames one by one. The question is, how do I pass the array variable as a String argument > to functions like - FindList[] > ReadList[] and other text file manipulation commands? If anybody can shed some light on this, I would be very thankful. Venkatesh === Subject: Re: passing an array variable as a file name string to FindList FileNames[] alone is sufficient instead of Flatten[Table[FileNames[]]] and FindList[#,Humpty Dumpty] & /@ FileNames[] will search for the giant goose egg in you files. Jens > Hi Everybody > > I have this problem for which I have to write a code - > > 1. There is a directory that contains around 30,000 text files. > 2. I wish to read each one of them and extract some information. > > Now, > > Flatten[Table[FileNames[]]] > > will give me all the file names in a table. > > So, > > An array variable with the subscript that contains the loop counter > will > give me the filenames one by one. The question is, how do I pass the array variable as a String argument > to functions like - > > FindList[] > ReadList[] > > and other text file manipulation commands? > > If anybody can shed some light on this, I would be very thankful. > > Venkatesh === Subject: Re: cell bracket symbols In the Option Inspector (ctrl-shft-I on PC) in Cell options/Display Options you'll find CellBracketOptionsOn. You can improve visibility there, though in this way it is not possible to make the bracket color depend on the type of bracket. Due to my poor vision, several of the visual clues for cell bracket > types are very hard to see. Anyway for me at the style sheet level or > using the options inspector to set the color of the cell bracket > depending on what kind of bracket it is? Or even using a different > size for the visual clues on the bracket? > === Subject: Re: Problem with Import[] and math.exe > Hi all! I spend several hours with a simple issue I don't understand. I would > like to create a daily task on WinXP; I have already shortened my > complex package to a very simple one, but it still doesn't work: This code works fine in the regular front end: In[1]:= > ps=$PathnameSeparator; > data=Import[FileNameJoin[{C:,ps,Temp,ps,data.TSV}]]; > Length[data] > Export[FileNameJoin[{C:,ps,Temp,ps,output.txt}],data] > Pause[2]; > Quit[]; Out[3]= 1996 > Out[4]= C:Tempoutput.txt It also works fine using math.exe or mathkernel.exe by typing in > everything manually. I have created a package c:temptest.m > containing the code above. I can start math.exe and load the package and output.txt is created. > The same happens with mathkernel.exe: Mathematica 7.0 for Microsoft Windows (32-bit) > Copyright 1988-2009 Wolfram Research, Inc. In[1]:= Get[c:temptest.m] > However, if I try C:Program FilesWolfram ResearchMathematica7.0math.exe -initfile > c:temptest.m > or > C:Program FilesWolfram ResearchMathematica7.0mathkernel.exe - > initfile c:temptest.m (which are my batch commands for the daily task) , I get an error > message: Mathematica 7.0 for Microsoft Windows (32-bit) > Copyright 1988-2009 Wolfram Research, Inc. Import::infer: Cannot infer format of file data.TSV. Output.txt now contains Null. I also tried to give explicit importing > information (Table, TSV, FieldSeparator, encoding information > etc.), but it doesn't work. I don't understand this. Do I need to load other .m-files (e.g. some > init.m) too? > The rest of my complex package (including SQL communication, > statistical calculations, graphics generation) works fine, but I > cannot load a simple tsv-file. My system: > $Version = 7.0 for Microsoft Windows (32-bit) (February 18, 2009) > $OperatingSystem = Windows Are there any good references for notebook automation and evaluation > I encountered a bug with Import (confirmed by someone at WRI) under these conditions using version 6.0. My current method of starting MathKernel is to use a small C program (which has an icon that can sit on the desktop) which starts the kernel via MathLink, and passes it a Get command on a file of Mathematica commands. There are several ways to start Math - such as piping the input, or using one of the other command line options, and I don't remember exactly what worked and what didn't (there seemed to be various gotcha's), but I ended up with the above solution, which works well. David Bailey http://www.dbaileyconsultancy.co.uk === Subject: Re: Styling the selected Tab's label in TabView The only reason for the Graphics[] in the example you started with is because that example requires the use of Disk[]/Circle[] to produce the intended effect. You don't need a Graphics[] wrapper in your case, and removing it makes your code more comprehensible and as well as making it work as I believe you intended. DynamicModule[{selected}, TabView[Table[ With[{i = i}, Style[labels[[i]], FontWeight -> labels[[i]] <> !)], {i, Length[labels]}], Dynamic[selected]]] John Fultz jfultz@wolfram.com User Interface Group Wolfram Research, Inc. > It seems that you can't set the LabelStyle of individual tabs in a > TabView. Starting with the example in my TabView->Examples->Scope->Control > documentation, I got to: labels = {Bill, Susan}; > DynamicModule[ > {selected}, > TabView[ > Table[ > With[ > {i = i}, > Graphics[ > Style[ > Text[labels[[i]]], > FontWeight -> Dynamic[ > Bold, > Plain > ] > ] > ], > ImageSize -> All, > PlotRangePadding -> .5 > ] -> (Hello <> labels[[i]] <> !) > ], > {i, Length[labels]} > ], > Dynamic[selected] > ] > ] This manages to bold the selected tab, but ImageSize -> All isn't= limiting > itself to the size of the Text[], and I'm not sure how to limit the > resulting tab size to only that required for the text display... === Subject: Re: Can't figure out how to export Mathematica into Word Actually, MathType 6.5 works quite well for exporting Mathematica equations and using them in Word. Others have suggested MathML, and this is the key to using a Mathematica equation in MathType. We have more detailed instructions on our website: http://dessci.com/en/support/mathtype/workswith/mathematica.htm Bob Mathews Director of Training Design Science, Inc. www.dessci.com ~ Makers of MathType, MathFlow, MathPlayer, MathDaisy, Equation Editor ~ > I help out my lab partners in one of my classes by exporting out the data= and equations we worked on from mathematica. They use microsoft word so I = need to copy or export things into rtf first or copy things directly into m= icrosoft word. The problem is that many symbols come out strangely when I t= ry to export or even copy them the tables and math notation comes out like = --- > =C2 =C2 {[Null], !(*SubscriptBox[(F), (1)]), !(*Subsc= riptBox[(d), (1)]), !(*SubscriptBox[(=EF=81=B4), (1)]), != (*SubscriptBox[(F), (2)]), It seems like there is something not set up the way I want to in the expo= rt or copy functions... Also, when exporting to rtf, the tables come out as= a list of data instead of being in the correct form. Another system used t= o export this stuff out to rtf correctly by default... How do I set up math= ematica to do the same? === Subject: Re: Can't figure out how to export Mathematica into Word Since no fewer than three people pointed this out, I just wanted to make sure that people know that, as of 7.0.1, regular copy/paste uses MathML automatically when appropriate (i.e. when copying either a single typesetting cell, in part or in whole, that contains math or code, but no graphics). So, it will generally be the case that using Copy As is not required. John Fultz jfultz@wolfram.com User Interface Group Wolfram Research, Inc. > If you have Word 2007 you can copy the equation as MathML and paste it > straight in Word. It is editable in Word's equation editor. Otherwise, try a copy as picture. > I help out my lab partners in one of my classes by exporting out the >> data= > and equations we worked on from mathematica. They use microsoft word so I > = > need to copy or export things into rtf first or copy things directly into > m= > icrosoft word. The problem is that many symbols come out strangely when I > t= > ry to export or even copy them the tables and math notation comes out > like = > --- >> =C2 =C2 {[Null], !(*SubscriptBox[(F), (1)]), !(*Subsc= > riptBox[(d), (1)]), !(*SubscriptBox[(=EF=81=B4), (1)]), > != > (*SubscriptBox[(F), (2)]), > It seems like there is something not set up the way I want to in the >> expo= > rt or copy functions... Also, when exporting to rtf, the tables come out > as= > a list of data instead of being in the correct form. Another system used > t= > o export this stuff out to rtf correctly by default... How do I set up > math= > ematica to do the same? === Subject: Re: Map to nested list >this expression >IntegerQ/@{1,1/5} >outputs {True, False} >which operator is used for nested list? I think this is what you are looking for In[1]:= Map[IntegerQ, {{1, 1/5}, {1, 1/5}}, {2}] Out[1]= {{True, False}, {True, False}} === Subject: Re: release memory >I am doing a long memory consuming calculation. At certain point I >get variable contaning huge amount of numerical data. I process it >and don't need it anymore. >Is there a way to delete it and RELEASE the memory it takes, i. e. >make it available? >I tried ClearAll[...], it deletes the variable but the memory >doesn't become available - I watch the Windows Task Manager and it >doesn't show increase in the available memory. If you haven't read the following tutorials you should tutorial/BasicInternalArchitecture tutorial/MemoryManagement One of the keys is to realize memory will not be released until there are no references to it in the current session. In particular, if you have not set $HistoryLength = 0 in the session, you likely will have references to things you are not aware of and find it difficult to reclaim all memory. One convenient way to release memory for several variables at a time is create a context before creating those variables. Then the utility CleanSlate can be used to delete the context with all of the variables it contains, releasing the memory associated with them. === Subject: cell bracket symbols Due to my poor vision, several of the visual clues for cell bracket types are very hard to see. Anyway for me at the style sheet level or using the options inspector to set the color of the cell bracket depending on what kind of bracket it is? Or even using a different size for the visual clues on the bracket? === Subject: Re: Dynamic 2D ListLinePlot PlotRange data = Table[{x, Sin[x] + RandomReal[{-0.1, 0.1}]}, {x, 0, 2 Pi, 2 Pi/512}]; Manipulate[ ListLinePlot[data, PlotRange -> {{xmin, xmax}, All}], {{xmin, 0, !(*SubscriptBox[x, min])}, 0, 2 Pi}, {{xmax, 2 Pi, !(*SubscriptBox[x, max])}, 0, 2 Pi}] ? Jens > I'm a bit of a newbie here, trying to build up some data visualization > tools. I've already gotten a ListLinePlot working well with slider to adjust > xmin and xmax. I was hoping that I could set PlotRange to All for the Y axis > and it would adjust for the Y-values in the dynamically specified x range, > but no such luck. Is there some other way to not have to do the y-axis range > calculation myself? I suppose some explanation of the dataset is desired. I have something like: > { > {{x11,y11},{x12,y12},{x13,y13},...,{x1m,y1m}}, > {{x21,y21},{x22,y22},{x23,y23},...,{x2n,y2n}}, > } > , where the x values and lengths are heterogeneous between xy lists 1 and 2 This makes the calculation of ymin and ymax very non-straightforward to me, > and re-calculation unacceptably slow on 20k+ data points per list. The > dynamic x-axis plot scaling actually goes very smoothly, by using a > construct like: Show[ > ListLinePlot[data,PlotRange -> All,], > PlotRange ->Dynamic[{{curxmin, curxmax},All}], > ] I've tried various ways to get at the problem, and the closest I've gotten > is something like: Map[ > {Min[#], Max[#]} &, > Map[ > (Select[ > #, > ( > #[[1]] > tmin > && #[[1]] < tmax > ) & > ]) &, > mydata > ][[All, All, 2]] > ] Which get me basically the result I want, but is really slow to evaluate, > making it undesirable as Dynamic[]. Any ideas? > === Subject: Re: Dynamic 2D ListLinePlot PlotRange I think I've solved my own problem! First, I used a binary search to find the x-axis min and max position in each of my X-Y data sets. I'm using the binary search that was posted by Sseziwa Mukasa in an old thread titled Finding the closest number from a I have to do a fair number of machinations to get from there to the xmin/max-constrained ymin/max list for each datatype for each recorded instrument, but it calculates at a reasonable speed. Another critical point for me was to use nested dynamic modules, because I have multiple graphs (one for each data type) on different tabs, each with different dynamic ybounds indexed by their tab. The nested dynamic module was required to hold onto the iterator for the TabView's table, so that same iterator could be used to grab the correct ymin/max. This construct looked something like: TabView[ Table[ label[[thiscol]] -> DynamicModule[ {mycol = thiscol}, Show[ ListLinePlot[ plotdata[[All, thiscol]], ], PlotRange -> Dynamic[{{curxmin, curxmax}, ybounds[[mycol]]}], ] ], {thiscol, Range[Dimensions[efisdata][[2]]]} ] I plan on posting the entire data graphing solution for everyone to enjoy, when I get it cleaned up and a few more kinks worked out. -- Bryce Schober === Subject: Re: Dynamic 2D ListLinePlot PlotRange You haven't explained tmin or tmax, but ignoring that, here's some sample data and code to compute the minimum and maximum x values: test = RandomInteger[{1, 10000}, {2, 50, 2}]; minMax = Through[{Min, Max}@Flatten[test, 1][[All, 1]]] {52, 9885} If you want the first element to be no less than tmin and the second to be no more than tmax, you can do this: {curmin, curmax} = {tmin, tmax} = Sort@RandomInteger[{1, 10000}, 2] Apply @@@ Transpose@{{Max, Min}, Transpose@{{tmin, tmax}, minMax}} {5877, 7951} {5877, 7951} or the simpler {Max@#[[1]], Min@#[[2]]} &@Transpose@{{tmin, tmax}, minMax} {5877, 7951} Bobby > I'm a bit of a newbie here, trying to build up some data visualization > tools. I've already gotten a ListLinePlot working well with slider to > adjust > xmin and xmax. I was hoping that I could set PlotRange to All for the Y > axis > and it would adjust for the Y-values in the dynamically specified x > range, > but no such luck. Is there some other way to not have to do the y-axis > range > calculation myself? I suppose some explanation of the dataset is desired. I have something > like: > { > {{x11,y11},{x12,y12},{x13,y13},...,{x1m,y1m}}, > {{x21,y21},{x22,y22},{x23,y23},...,{x2n,y2n}}, > } > , where the x values and lengths are heterogeneous between xy lists 1 > and 2 This makes the calculation of ymin and ymax very non-straightforward to > me, > and re-calculation unacceptably slow on 20k+ data points per list. The > dynamic x-axis plot scaling actually goes very smoothly, by using a > construct like: Show[ > ListLinePlot[data,PlotRange -> All,], > PlotRange ->Dynamic[{{curxmin, curxmax},All}], > ] I've tried various ways to get at the problem, and the closest I've > gotten > is something like: Map[ > {Min[#], Max[#]} &, > Map[ > (Select[ > #, > ( > #[[1]] > tmin > && #[[1]] < tmax > ) & > ]) &, > mydata > ][[All, All, 2]] > ] Which get me basically the result I want, but is really slow to evaluate, > making it undesirable as Dynamic[]. Any ideas? > -- DrMajorBob@bigfoot.com === Subject: Partial derivatives for implicit functions Hi I have a function f(x,y,z)=0. I would like to find dx/dy and dx/dz (where I am using d for partial derivatives, I'm not sure how to get the actual symbol in this edit box), where both would be functions of x, y and z. Unfortunately, I cannot get an explicit solution x=g(y,z). Any ideas on how I'd go about solving this? Srikanth === Subject: Re: Partial derivatives for implicit functions Srikanth, Use implicit differentiation. Copy and evaluate the following in one cell. Print[Find dy/dx for the equation:] eqn1 = 2 y == x^2 + Sin[y] Print[To calculate dy/dx implicitly write equation with y as a function of x.] eqn2 = eqn1 /. y -> y[x] Print[Differentiate with respect to x] step1 = D[eqn, x] Print[Solve the equation for y'[x].] step2 = Equal @@ Part[Solve[step1, y'[x]], 1, 1] Print[Change y[x] back to y.] step3 = step2 /. y[x] -> y Print[Get rid of the extra minus signs.] MapAt[Minus, step3, {{2, 1}, {2, 3, 1}}] If you have Presentations you could also get rid of the minus signs with: Needs[Presentations`Master`] MapAt[MultiplyByOne[-1], step3, 2] which multiplies numerator and denominator by -1. David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ Hi I have a function f(x,y,z)=0. I would like to find dx/dy and dx/dz (where I am using d for partial derivatives, I'm not sure how to get the actual symbol in this edit box), where both would be functions of x, y and z. Unfortunately, I cannot get an explicit solution x=g(y,z). Any ideas on how I'd go about solving this? Srikanth === Subject: Re: Partial derivatives for implicit functions df = Dt[f[x, y, z]] == 0 /. {Dt[x] -> dx, Dt[y] -> dy, Dt[z] -> dz} ; (x'[y] == (dx /dy /. Solve[df , dx] // Expand )) /. dz :> z'[y]*dy ? Jens > Hi > I have a function f(x,y,z)=0. I would like to find dx/dy and dx/dz > (where I am using d for partial derivatives, I'm not sure how to get > the actual symbol in this edit box), where both would be functions of > x, y and z. Unfortunately, I cannot get an explicit solution x=g(y,z). > Any ideas on how I'd go about solving this? > Srikanth > === Subject: Re: Partial derivatives for implicit functions according to the impicite function theorem, we get: dx/dy= -fy/fx and dx/dz= -fz/fx Therefore, using D we get: -D[f[x, y, z], y]/D[f[x, y, z], x] and -D[f[x, y, z], z]/D[f[x, y, z], x] , Daniel > Hi > I have a function f(x,y,z)=0. I would like to find dx/dy and dx/dz > (where I am using d for partial derivatives, I'm not sure how to get > the actual symbol in this edit box), where both would be functions of > x, y and z. Unfortunately, I cannot get an explicit solution x=g(y,z). > Any ideas on how I'd go about solving this? > Srikanth > === Subject: Re: release memory Here is an example program that fails to release the memory: In[1]:= $HistoryLength = 0; tbl = Table[{r, t}, {t, 0, 1, 1/1000}, {r, 0, 1, 1/1000}]; ByteCount[tbl] MemoryInUse[] Out[3]= 188 184 024 Out[4]= 94 058 160 In[5]:= ClearAll[tbl]; MemoryInUse[] Out[5]= 9 885 560 First notice that the numbers shown by ByteCount and MemoryInUse are inconsistent ??? === Subject: Re: Map to nested list Map[IntegerQ, {{1, 1/5}, {1, 1/5}}, {2}] {{True, False}, {True, False}} Bobby > this expression IntegerQ/@{1,1/5} outputs {True, False} which operator is used for nested list? so IntegerQ ? {{1,1/5},{1,1/5}} outputs {{True, False},{True, False}} > thankyou :) -- DrMajorBob@bigfoot.com === Subject: Re: Map to nested list Specify the second level Map[IntegerQ, {{1, 1/5}, {1, 1/5}}, {2}] Adriano Pascoletti 2009/4/3 athanase thankyou :) === Subject: Re: Map to nested list Map[IntegerQ,{{1,1/5},{1,1/5}},{2}] > this expression IntegerQ/@{1,1/5} outputs {True, False} which operator is used for nested list? so IntegerQ ? {{1,1/5},{1,1/5}} outputs {{True, False},{True, False}} > thankyou :) > === Subject: Re: Map to nested list Athanase, Map takes a third levelspec argument: Map[IntegerQ, {{1, 1/5}, {1, 1/5}}, {2}] {{True, False}, {True, False}} Yves > this expression IntegerQ/@{1,1/5} outputs {True, False} which operator is used for nested list? so IntegerQ ? {{1,1/5},{1,1/5}} outputs {{True, False},{True, False}} > thankyou :) > === Subject: Re: Map to nested list in = {{1, 1/5}, {1, 1/5}}; Unprotect[IntegerQ]; SetAttributes[IntegerQ, Listable]; IntegerQ[#] & /@ in -Francesco > this expression IntegerQ/@{1,1/5} outputs {True, False} which operator is used for nested list? so IntegerQ ? {{1,1/5},{1,1/5}} outputs {{True, False},{True, False}} > thankyou :) > === Subject: Re: Map to nested list Map[IntegerQ, {{1, 1/5}, {1, 1/5}}, {2}] > this expression IntegerQ/@{1,1/5} outputs {True, False} which operator is used for nested list? so IntegerQ ? {{1,1/5},{1,1/5}} outputs {{True, False},{True, False}} thankyou :) === Subject: Re: Map to nested list In[1] = Map[IntegerQ, {{1, 1/5}, {1, 1/5}}, {-1}] Out[1] = {{True, False}, {True, False}} Will work for any depth as long as leaves are numbers. Leonid > this expression IntegerQ/@{1,1/5} outputs {True, False} which operator is used for nested list? so IntegerQ ? {{1,1/5},{1,1/5}} outputs {{True, False},{True, False}} > thankyou :) === Subject: Re: Map to nested list >-----Original Message----- === >Subject: Map to nested list this expression IntegerQ/@{1,1/5} outputs {True, False} which operator is used for nested list? so IntegerQ ? {{1,1/5},{1,1/5}} outputs {{True, False},{True, False}} >thankyou :) Well usually it's Map, it depends a bit on your nesting, e.g.: In[3]:= Map[IntegerQ, {{1, 1/5}, {1, 1/5}}, {2}] Out[3]= {{True, False}, {True, False}} If nesting is different, map differently, e.g.: In[16]:= Map[IntegerQ, {1, {2., {3, {4., 5}}}}, {-1}] Out[16]= {True, {False, {True, {False, True}}}} This might wreak havoc however, with In[14]:= Map[IntegerQ, {{1, 1/5}, {{1, 1/5}, 1/f[5]}}, {-1}] Out[14]= {{True, False}, {{True, False}, Power[f[True],True]}} If you only want to map within Lists descending, you might try In[19]:= th[IntegerQ,{{1, 1/5},{{1,1/5},1/f[5]}}] Out[19]= {{True,False},{{True,False},False}} In[17]:= th[IntegerQ, {1, {2., {3, {4., 5}}}}] Out[17]= {True, {False, {True, {False, True}}}} Where th maps recursively at List: In[11]:= th[f_, a_] /; Head[a] == List := th[f, #] & /@ a In[12]:= th[f_, a_] := f[a] -- Hartmut === Subject: Re: Map to nested list > this expression IntegerQ/@{1,1/5} outputs {True, False} which operator is used for nested list? so IntegerQ ? {{1,1/5},{1,1/5}} outputs {{True, False},{True, False}} > Map[IntegerQ,{{1,1/5},{1,1/5}},{ArrayDepth[{{1,1/5},{1,1/5}}]}] === Subject: Re: Map to nested list Map[IntegerQ, {{1, 1/5}, {1, 1/5}}, {2}] {{True, False}, {True, False}} IntegerQ /@ # & /@ {{1, 1/5}, {1, 1/5}} {{True, False}, {True, False}} Bob Hanlon this expression IntegerQ/@{1,1/5} outputs {True, False} which operator is used for nested list? so IntegerQ ? {{1,1/5},{1,1/5}} outputs {{True, False},{True, False}} thankyou :) === Subject: Re: release memory setting $HistoryLength=0 in the begining of session DOES NOT WORK. Windows task manager does NOT show released memory when I ClearAll or Remove the variable. === Subject: Plot3D, show and text Is there an expert over there, who would able to add, using mathematica: a text abc at position 1,1,2 and a text def at position 2,2,4, by : keeping same looking at the original plot (no changing of ratio x, y, z) keeping Show (because i need to put other stuff inside) Show[Plot3D[-8*(x*x+y*y)+(x*x+y*y)*(x*x+y*y),{x,-3,3},{y,-3,3},BoxRatios-= >{3,4,2},Mesh->None,ClippingStyle->None,RegionFunction->Function[{x,y,z},= x^2+y^2<9 && x<2],Boxed->False,Axes->True,AxesOrigin->{0,0,-16.5}] thank you === Subject: Re: Plot3D, show and text Easy: Show[{Plot3D[-8*(x*x + y*y) + (x*x + y*y)*(x*x + y*y), {x, -3, 3}, {y, -3, 3}, BoxRatios -> {3, 4, 2}, Mesh -> None, ClippingStyle -> None, RegionFunction -> Function[{x, y, z}, x^2 + y^2 < 9 && x < 2], Boxed -> False, Axes -> True, AxesOrigin -> {0, 0, -16.5}], Graphics3D[{Text[abc, {1, 1, 2}], Text[def, {2, 2, 4}]}]} ] Is there an expert over there, who would able to add, using mathematica: > a text abc at position 1,1,2 and > a text def at position 2,2,4, by : keeping same looking at the original plot (no changing of ratio x, y, z) > keeping Show (because i need to put other stuff inside) Show[Plot3D[-8*(x*x+y*y)+(x*x+y*y)*(x*x+y*y),{x,-3,3},{y,-3,3},BoxRatios-= =>{3,4,2},Mesh->None,ClippingStyle->None,RegionFunction->Function[{x,y,z}= ,= x^2+y^2<9 && x<2],Boxed->False,Axes->True,AxesOrigin->{0,0,-16.5}] thank you === Subject: Re: Plot3D, show and text Is there an expert over there, who would able to add, using mathematica: > a text abc at position 1,1,2 and > a text def at position 2,2,4, by : keeping same looking at the original plot (no changing of ratio x, y, z) > keeping Show (because i need to put other stuff inside) Show[Plot3D[-8*(x*x+y*y)+(x*x+y*y)*(x*x+y*y),{x,-3,3},{y,-3,3},BoxRatios-= >> {3,4,2},Mesh->None,ClippingStyle->None,RegionFunction->Function[{x,y,z},= > x^2+y^2<9 && x<2],Boxed->False,Axes->True,AxesOrigin->{0,0,-16.5}] hm, actually I would think you need Show to do this, anyway: Show[ Plot3D[ -8*(x*x + y*y) + (x*x + y*y)*(x*x + y*y), {x, -3, 3}, {y, -3, 3}, BoxRatios -> {3, 4, 2}, Mesh -> None, ClippingStyle -> None, RegionFunction -> Function[{x, y, z}, x^2 + y^2 < 9 && x < 2], Boxed -> False, Axes -> True, AxesOrigin -> {0, 0, -16.5} ], Graphics3D[{Text[abc, {1, 1, 2}], Text[def, {2, 2, 4}]}] ] note that the ordering of Plot3D and Graphics3D is relevant, using the ordering as above will use the BoxRatios of Plot3D even when the Text[]-Primitives don't fit into the resulting plot. In version 6 and 7 Show will use the options of the first thing to show by default, this has changed from version 5.x and was discussed more than once in this group. Of course I can't tell whether it will change in future versions. Using AbsoluteOptions you could enforce Show to use options of another object in the arguments, but as long as you stay with version 6 and 7 putting the relevant object as the first argument should do the trick. hth, albert === Subject: Re: Plot3D, show and text Here is a solution using the Presentations package. This gives you real 3D text that is in the right position, rotates with the image, and hides behind surfaces. You can also easily add any other items to the graphic. The 3D text can be rotated, styled with Style, and scaled. Needs[Presentations`Master`] Draw3DItems[ {(* Draw the surface *) Draw3D[-8 (x^2 + y^2) + (x^2 + y^2)^2, {x, -3, 3}, {y, -3, 3}, Mesh -> None, RegionFunction -> Function[{x, y, z}, x^2 + y^2 < 9 && x < 2], MaxRecursion -> 3], (* Draw the labels with Text3D *) Black, VerticalText3D[abc, {1, 1, 2}, 90 [Degree], {.2, 1}], VerticalText3D[def, {2, 2, 4}, 90 [Degree], {.2, 1}] (* Draw any other objects that you wish... *)}, NiceRotation, Boxed -> False, BoxRatios -> {3, 4, 2}, Axes -> True, AxesOrigin -> {0, 0, -16.5}, ImageSize -> 500 ] David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ Is there an expert over there, who would able to add, using mathematica: a text abc at position 1,1,2 and a text def at position 2,2,4, by : keeping same looking at the original plot (no changing of ratio x, y, z) keeping Show (because i need to put other stuff inside) Show[Plot3D[-8*(x*x+y*y)+(x*x+y*y)*(x*x+y*y),{x,-3,3},{y,-3,3},BoxRatios-= >{3,4,2},Mesh->None,ClippingStyle->None,RegionFunction->Function[{x,y,z},= x^2+y^2<9 && x<2],Boxed->False,Axes->True,AxesOrigin->{0,0,-16.5}] thank you === Subject: Re: Plot3D, show and text Show[ Plot3D[-8*(x*x + y*y) + (x*x + y*y)*(x*x + y*y), {x, -3, 3}, {y, -3, 3}, BoxRatios -> {3, 4, 2}, Mesh -> None, ClippingStyle -> None, RegionFunction -> Function[{x, y, z}, x^2 + y^2 < 9 && x < 2], Boxed -> False, Axes -> True, AxesOrigin -> {0, 0, -16.5}], Graphics3D[{ Text[Style[abc, Section], {1, 1, 2}], Text[Style[def, Section], {2, 2, 4}]}] ] ? Jens Is there an expert over there, who would able to add, using mathematica: > a text abc at position 1,1,2 and > a text def at position 2,2,4, by : keeping same looking at the original plot (no changing of ratio x, y, z) > keeping Show (because i need to put other stuff inside) Show[Plot3D[-8*(x*x+y*y)+(x*x+y*y)*(x*x+y*y),{x,-3,3},{y,-3,3},BoxRatios-= >> {3,4,2},Mesh->None,ClippingStyle->None,RegionFunction->Function[{x,y,z},= > x^2+y^2<9 && x<2],Boxed->False,Axes->True,AxesOrigin->{0,0,-16.5}] thank you > === Subject: Re: Plot3D, show and text try the following: Show[Plot3D[-8*(x*x + y*y) + (x*x + y*y)*(x*x + y*y), {x, -3, 3}, {y, -3, 3}, BoxRatios -> {3, 4, 2}, Mesh -> None, ClippingStyle -> None, RegionFunction -> Function[{x, y, z}, x^2 + y^2 < 9 && x < 2], Boxed -> False, Axes -> True, AxesOrigin -> {0, 0, -16.5}], Graphics3D[{Text[abc, {1, 1, 2}], Text[def, {2, 2, 4}]}]] Daniel Is there an expert over there, who would able to add, using mathematica: > a text abc at position 1,1,2 and > a text def at position 2,2,4, by : keeping same looking at the original plot (no changing of ratio x, y, z) > keeping Show (because i need to put other stuff inside) Show[Plot3D[-8*(x*x+y*y)+(x*x+y*y)*(x*x+y*y),{x,-3,3},{y,-3,3},BoxRatios-= >> {3,4,2},Mesh->None,ClippingStyle->None,RegionFunction->Function[{x,y,z},= > x^2+y^2<9 && x<2],Boxed->False,Axes->True,AxesOrigin->{0,0,-16.5}] thank you > === Subject: Re: StringJoin with ToString > It is quite interesting why StringJoin does not apply ToString to > those arguments which are non-string. I've overridden the built-in > StringJoin, to save a few unnecessary ToStrings by the standard method > (the context specifications are necessary for packaging): Unprotect[System`StringJoin]; > $UseNewStringJoin = True; > System`StringJoin[expr___] := > Block[{$UseNewStringJoin = False}, > StringJoin@(ToString /@ {expr})] /; TrueQ[$UseNewStringJoin]; > Protect[$UseNewStringJoin]; > Protect[System`StringJoin]; This seems to work (after loading the package) for any cases, e.g.: In[2]:= StringJoin[1, 2, 3] Out[2]= 123 In[3]:= 4 <> 5 <> 6 Out[3]= 456 but has a strange effect on messages: In[5]:= Append[dummy, 2] During evaluation of In[5]:= Append::normal: {Nonatomic expression > expected at position , {1}, in , {Append[dummy,2]}, .} Out[5]= Append[dummy, 2] that is: the message strings are displayed in a non-joined list > format. > The code below shows an other modified StringJoin, that gives the > exact same results (after initiating a fresh kernel): Unprotect[System`StringJoin]; > System`StringJoin[expr___]:=Module[{str=}, > Scan[(Print[#]; str=StringInsert[str,ToString[#],-1])&,{expr}]; > str > ]; > Protect[System`StringJoin]; Now I've inserted a Print[#]; inside the function to see what's > happening. This reveals some internal calculation that is done during > the evaluation of the erroneous call of Append[dummy, 2], which I > don't really understand (did not copy here for size constraints). > Apart from this strange sideeffect on messages (which seems to be > harmless), both functions work as expected. Does anyone have any idea > what is the exact cause of this behaviour and how to overcome it? > Istvan Zachar > I would never routinely override built-in commands - even to extend their functionality. There are lots of reasons for this, but not least is the fact that code that uses this trick is very hard to read. Why not simply write a function ExtendedStringJoin. Part of Mathematica is written using other Mathematica functions - so problems such as you report are not unexpected. On the face of it, adding extra functionality to a built-in might not be expected to cause problems, but it is easy to write code that would be disrupted by your change: ss = Quiet[2 <> 3]; Map[ToString[#^2] &, ss] Who knows what sort of code lies inside Mathematica :) David Bailey http://www.dbaileyconsultancy.co.uk === Subject: Re: StringJoin with ToString With the following definitions, your idea appears to work (at least in a few examples I tested): ClearAll[toString]; toString[x_?NumericQ, format___] := ToString[x, format]; toString[x_[y__], format___] := x @@ (toString /@ {y}); toString[x_Symbol, format___] := ToString[x, format]; toString[x_, format___] := x; Unprotect[System`StringJoin]; Unprotect[$UseNewStringJoin]; $UseNewStringJoin = True; System`StringJoin[expr___] := Block[{$UseNewStringJoin = False}, StringJoin @@ (toString /@ {expr})] /; TrueQ[$UseNewStringJoin]; Protect[$UseNewStringJoin]; Protect[System`StringJoin]; The problem was the way ToString works, which is incompatible with intermediate formatting functions. The definition of toString does the job. In[12]:= StringJoin[{1, 2, 3}] // InputForm Out[12]//InputForm= 123 In[13]:= StringJoin[1, a, 3] // InputForm Out[13]//InputForm= 1a3 In[17]:= StringJoin[1, 2, [Pi]] // InputForm Out[17]//InputForm= 12Pi In[15]:= Append[dummy, 2] During evaluation of In[15]:= Append::normal: Nonatomic expression expected at position 1 in Append[dummy,2]. >> Out[15]= Append[dummy,2] ADL > It is quite interesting why StringJoin does not apply ToString to > those arguments which are non-string. I've overridden the built-in > StringJoin, to save a few unnecessary ToStrings by the standard method > (the context specifications are necessary for packaging): > ... > Istvan Zachar === Subject: Re: StringJoin with ToString H, . > It is quite interesting why StringJoin does not apply ToString to > those arguments which are non-string. I've overridden the built-in > StringJoin, to save a few unnecessary ToStrings by the standard method > (the context specifications are necessary for packaging): Unprotect[System`StringJoin]; > $UseNewStringJoin = True; > System`StringJoin[expr___] := > Block[{$UseNewStringJoin = False}, > StringJoin@(ToString /@ {expr})] /; TrueQ[$UseNewStringJoin]; > Protect[$UseNewStringJoin]; > Protect[System`StringJoin]; This seems to work (after loading the package) for any cases, e.g.: In[2]:= StringJoin[1, 2, 3] Out[2]= 123 In[3]:= 4 <> 5 <> 6 Out[3]= 456 but has a strange effect on messages: In[5]:= Append[dummy, 2] During evaluation of In[5]:= Append::normal: {Nonatomic expression > expected at position , {1}, in , {Append[dummy,2]}, .} Out[5]= Append[dummy, 2] that is: the message strings are displayed in a non-joined list > format. > The code below shows an other modified StringJoin, that gives the > exact same results (after initiating a fresh kernel): Unprotect[System`StringJoin]; > System`StringJoin[expr___]:=Module[{str=}, > Scan[(Print[#]; str=StringInsert[str,ToString[#],-1])&,{expr}]; > str > ]; > Protect[System`StringJoin]; Now I've inserted a Print[#]; inside the function to see what's > happening. This reveals some internal calculation that is done during > the evaluation of the erroneous call of Append[dummy, 2], which I > don't really understand (did not copy here for size constraints). > Apart from this strange sideeffect on messages (which seems to be > harmless), both functions work as expected. Does anyone have any idea > what is the exact cause of this behaviour and how to overcome it? > I think you would be much better off to leave the System functions as they are and define a tostring or mytostring that behaves as you want. I have no idea what causes the problems with messages that you see, but I suspect that there are many more problems that eventually could arise but you haven't yet discovered because you presumably only tried a very limited part of Mathematica's full functionality. On the other hand it is very easy to construct cases where your improved ToString behaves different from the original and so will potentially cause troubles, here is just one: If[Head[Quiet[StringJoin[1,2,3]]] == StringJoin, Print[this was no string!]] hth, albert === Subject: StringJoin with ToString It is quite interesting why StringJoin does not apply ToString to those arguments which are non-string. I've overridden the built-in StringJoin, to save a few unnecessary ToStrings by the standard method (the context specifications are necessary for packaging): Unprotect[System`StringJoin]; $UseNewStringJoin = True; System`StringJoin[expr___] := Block[{$UseNewStringJoin = False}, StringJoin@(ToString /@ {expr})] /; TrueQ[$UseNewStringJoin]; Protect[$UseNewStringJoin]; Protect[System`StringJoin]; This seems to work (after loading the package) for any cases, e.g.: In[2]:= StringJoin[1, 2, 3] Out[2]= 123 In[3]:= 4 <> 5 <> 6 Out[3]= 456 but has a strange effect on messages: In[5]:= Append[dummy, 2] During evaluation of In[5]:= Append::normal: {Nonatomic expression expected at position , {1}, in , {Append[dummy,2]}, .} >> Out[5]= Append[dummy, 2] that is: the message strings are displayed in a non-joined list format. The code below shows an other modified StringJoin, that gives the exact same results (after initiating a fresh kernel): Unprotect[System`StringJoin]; System`StringJoin[expr___]:=Module[{str=}, Scan[(Print[#]; str=StringInsert[str,ToString[#],-1])&,{expr}]; str ]; Protect[System`StringJoin]; Now I've inserted a Print[#]; inside the function to see what's happening. This reveals some internal calculation that is done during the evaluation of the erroneous call of Append[dummy, 2], which I don't really understand (did not copy here for size constraints). Apart from this strange sideeffect on messages (which seems to be harmless), both functions work as expected. Does anyone have any idea what is the exact cause of this behaviour and how to overcome it? Istvan Zachar === Subject: Re: How to remove all cycles n = 13; A = Array[a, 2^(n + 1)]; B = Array[b, {2, 2^n}]; Do[Do[A[[j + BitShiftLeft[k - 1, 1]]] = B[[j, k]], {j, 1, 2}], {k, 1, 2^n}] // Timing {0.616373,Null} A2 = Flatten[Transpose[B]]; // Timing {0.008281,Null} A == A2 True Bob Hanlon I want to write the following code using functional programming, i.e. to remove all Do's. There are two arrays: A[[i]], i=1,...,2^(n+1) B[[j,k]], j=1,2; k=1,...,2^n. I need to assign B to A setting the first bit of the index i to be the index j. Explicitly Do[Do[A[[ j + BitShiftLeft[k-1,1] ]]= B[[j,k]], {j,1,2}],{k,1,2^n}] I need to do it for multi-dimensional large arrays. Is it possible to write it without Do's ? -- Bob Hanlon === Subject: Re: Minimize goes into infinite loop? I included all the vars in Minimize and changed the conditions to avoid divisions by zero: In:= Minimize[{m1 w1 + m2 w2, w1 > 0 && p1 - m2 p1 + p2 - m1 p2 == (1 + m) (-1 + m1) (-1 + m2) && m1 >= 0 && m2 > m1 && w2 > 0 && w1 + w2 == 1 && 1 > m > 0 && p1 > 0 && p2 > 0 && p1 + p2 == 1}, {m, m1, m2, p1, p2, w1, w2}] During evaluation of In[16]:= Minimize::wksol: Warning: There is no minimum in the region in which the objective function is defined and the constraints are satisfied; returning a result on the boundary. >> Out= {0,{m->0,m1->0,m2->0,p1->1,p2->0,w1->1,w2->0}} Does this make sense for your problem? ADL > Hello group, I wonder why the following problem force Mathematica to run into > infinite loop? Minimize[ > {m1*w1 + m2*w2 > , w1 > 0 && w2 > 0 && w1 + w2 == 1 > && (p1/(1 - m1) + p2/(1 - m2) - 1 - m) == 0 > && m1 >= 0 && m2 > m1 && 1 > m > 0 > && p1 > 0 && p2 > 0 && p1 + p2 == 1 > }, {m1, m2}, Reals > ] -Andrey === Subject: Re: Minimize goes into infinite loop? How do you know it's infinite? Maybe it's just taking long > Hello group, I wonder why the following problem force Mathematica to run into > infinite loop? Minimize[ > {m1*w1 + m2*w2 > , w1 > 0 && w2 > 0 && w1 + w2 == 1 > && (p1/(1 - m1) + p2/(1 - m2) - 1 - m) == 0 > && m1 >= 0 && m2 > m1 && 1 > m > 0 > && p1 > 0 && p2 > 0 && p1 + p2 == 1 > }, {m1, m2}, Reals > ] -Andrey === Subject: Minimize goes into infinite loop? Hello group, I wonder why the following problem force Mathematica to run into infinite loop? Minimize[ {m1*w1 + m2*w2 , w1 > 0 && w2 > 0 && w1 + w2 == 1 && (p1/(1 - m1) + p2/(1 - m2) - 1 - m) == 0 && m1 >= 0 && m2 > m1 && 1 > m > 0 && p1 > 0 && p2 > 0 && p1 + p2 == 1 }, {m1, m2}, Reals ] -Andrey === Subject: Re: Is there a BNF for Mathematica? It's not at all clear to me that a BNF would be of any great use for Mathematica : after all, everything is an expression and so if you avoid any of the special input forms such as =, :=, /@, {}, [[]], etc., along with prefix, infix, and postfix special forms, then the grammar is utterly simple. The complexities arise from (1) Attributes, such as Hold, which do not explicitly appear as part of the syntax one uses in entering expressions but affect the evaluation; and (2) the special input forms, where you have to begin worrying about order of precedence. > I have been looking for a Backus-Naur Form grammar for Mathematica. Is > there one out there?? > -- 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: Is there a BNF for Mathematica? I have been looking for a Backus-Naur Form grammar for Mathematica. Is there one out there?? === Subject: Re: Is there a BNF for Mathematica? I don't think there is one. I can't imagine it would be very useful either. Since *every* construct in Mathematica is actually just a function in disguise (even the data types, more or less) it could be rather short. On the other hand, given the enormous amount of reserved words (a couple of thousands), it would be rather tedious to list them all. > I have been looking for a Backus-Naur Form grammar for Mathematica. Is > there one out there?? === Subject: Re: Is there a BNF for Mathematica? >I have been looking for a Backus-Naur Form grammar for Mathematica. Is > there one out there?? > No. But there are number of places in documentation where it takes about the Mathematica grammar. http://reference.wolfram.com/mathematica/tutorial/SpecialWaysToInputExpressi ons.html The Mathematica language has a definite grammar which specifies how your input should be converted to internal form. One aspect of the grammar is that it specifies how pieces of your input should be grouped. Also, in the documentation center, under core language -> Language review. --Nasser === Subject: Re: How to remove all cycles With[{n = 4}, B = Table[Prime[2*j*k], {j, 1, 2}, {k, 1, 2^n}] ] A=Flatten[Transpose[B]] ? Jens > I want to write the following code using functional > programming, i.e. to remove all Do's. > There are two arrays: A[[i]], i=1,...,2^(n+1) > B[[j,k]], j=1,2; k=1,...,2^n. I need to assign B to A setting the first bit of the index i > to be the index j. Explicitly Do[Do[A[[ j + BitShiftLeft[k-1,1] ]]= B[[j,k]], > {j,1,2}],{k,1,2^n}] I need to do it for multi-dimensional large arrays. > Is it possible to write it without Do's ? === Subject: Re: How to remove all cycles here is a fast way to do it: A = Riffle @@ B; Daniel > I want to write the following code using functional > programming, i.e. to remove all Do's. > There are two arrays: A[[i]], i=1,...,2^(n+1) > B[[j,k]], j=1,2; k=1,...,2^n. I need to assign B to A setting the first bit of the index i > to be the index j. Explicitly Do[Do[A[[ j + BitShiftLeft[k-1,1] ]]= B[[j,k]], > {j,1,2}],{k,1,2^n}] I need to do it for multi-dimensional large arrays. > Is it possible to write it without Do's ? === Subject: Re: How to remove all cycles This looks like an April fools joke if you ask me. You've gone to great lengths to obfuscate what you are doing, but a BitShiftLeft is a simple times 2. Effectively, you're almost directly assigning B to A: A=Flatten[Transpose[B]] For multi-dimensional matrices check the extended syntax of Transpose. > I want to write the following code using functional > programming, i.e. to remove all Do's. > There are two arrays: A[[i]], i=1,...,2^(n+1) > B[[j,k]], j=1,2; k=1,...,2^n. I need to assign B to A setting the first bit of the index i > to be the index j. Explicitly Do[Do[A[[ j + BitShiftLeft[k-1,1] ]]= B[[j,k]], > {j,1,2}],{k,1,2^n}] I need to do it for multi-dimensional large arrays. > Is it possible to write it without Do's ? > === Subject: How to remove all cycles I want to write the following code using functional programming, i.e. to remove all Do's. There are two arrays: A[[i]], i=1,...,2^(n+1) B[[j,k]], j=1,2; k=1,...,2^n. I need to assign B to A setting the first bit of the index i to be the index j. Explicitly Do[Do[A[[ j + BitShiftLeft[k-1,1] ]]= B[[j,k]], {j,1,2}],{k,1,2^n}] I need to do it for multi-dimensional large arrays. Is it possible to write it without Do's ? === Subject: Re: release memory >Here is an example program that fails to release the memory: >In[1]:= $HistoryLength = 0; >tbl = Table[{r, t}, {t, 0, 1, 1/1000}, {r, 0, 1, 1/1000}]; >ByteCount[tbl] >MemoryInUse[] >Out[3]= 188 184 024 >Out[4]= 94 058 160 >In[5]:= ClearAll[tbl]; MemoryInUse[] >Out[5]= 9 885 560 >First notice that the numbers shown by ByteCount and MemoryInUse are >inconsistent ??? ByteCount returns the memory needed to store a given expression. MemoryInUse returns the total memory store all data in the current kernel session. These are simply not the same things. Clearly, what is occurring here is there is memory being used in addition to that needed to store the data for tb1 that is not released when you clear tb1. >Anyways, after ClearAll, the MemoryInUse decreased with about 85 MB >indeed but Windows Task Manager does not show any decrease of the I would assume the Windows Task Manager reports the memory allocated from Windows to Mathematica There is no way for a system level tool to know how memory allocated to an application is used by that application. The functions Clear, ClearAll etc free memory for subsequent use in Mathematica. This doesn't mean that memory is returned to the system. Which means Windows Task Manager still sees the same memory being used by Mathematica. === Subject: Re: release memory it looks like MemoryInUse[] and Windows task manager report different numnbers. Internally Mathematica seems to release memory after e.g. remove or ClearAll if one believes MemoryInUse []. However, externally these memory releases are not visible, the task manager still reports the released memory. I faintly remember having once read that the Mathematica Kernel never gives up memory it once assigned to variables. But I am currently not able to find some relevant info. Does anybody (Wolfram?) now more about this issue? Daniel > I am doing a long memory consuming calculation. At certain point I get variable contaning huge amount of numerical data. I process it and don't need it anymore. Is there a way to delete it and RELEASE the memory it takes, i. e. make it available? I tried ClearAll[...], it deletes the variable but the memory doesn't become available - I watch the Windows Task Manager and it doesn't show increase in the available memory. I know quitting the kernel releases all the used memory but it stops the calculation which I don't want. If I don't release the memory of variables I no longer need, soon I ran out of memory, that's why I need to know how to make the memory available again during calculation. > === Subject: Re: release memory The result is also in the Out[..] variable. You can clear that (see tutorial/MemoryManagement). Alternatively, you could prevent that the history is stored by setting $HistoryLength to zero before you start. > I am doing a long memory consuming calculation. At certain point I get va= riable contaning huge amount of numerical data. I process it and don't need= it anymore. Is there a way to delete it and RELEASE the memory it takes, i. e. make i= t available? I tried ClearAll[...], it deletes the variable but the memory doesn't bec= ome available - I watch the Windows Task Manager and it doesn't show increa= se in the available memory. I know quitting the kernel releases all the used memory but it stops the = calculation which I don't want. If I don't release the memory of variables = I no longer need, soon I ran out of memory, that's why I need to know how t= o make the memory available again during calculation. === Subject: Re: release memory $HistoryLength=0 in the begining of the session and then deleting the variable with ClearAll[name] or Remove[name] does NOT show any release of memory in Windows Task Manager. === Subject: Re: BarChart in v. 7 Hi Julian, What's difficult in BarChart[{{1, 2, 3}, {1, 2, 3}}[Transpose], ChartLabels -> {{2007, 2008, 2009}, {mac, pc}}] or BarChart[{{1, 2, 3}, {1, 2, 3}}[Transpose], ChartLabels -> {{2007, 2008, 2009}, None}] ? > I have found that BarChart has changed quite a lot in v7. In v6, > BarChart[{1,2,3},{1,2,3}] produces a chart with six bars, grouped > 1,1,2,2,3,3. In v7, the correct syntax is BarChart[{{1,2,3},{1,2,3}}], > and gives a chart also with six bars but grouped 1,2,3,1,2,3. I would > like to revert to the v6 behaviour. It can be done with BarChart > [Transpose[{{1,2,3},{1,2,3}}], but labelling the chart with a label > under each group of two data (that is, one label under the columns > 1,1,...) becomes a pain, specially for large sets of data. Do you know > of a simpler method other than reverting to v6? > Juli=E1n === Subject: Show[list] does not work I am trying to overlay multiple plots using Show[list] where list contains my plots. But the command always draws a blank plot. Can someone let me know why? Venkatesh Ramakrishnan Department of Chemical Sciences Tata Institute of Fundamental Research Mumbai 400005 India === Subject: Computing resources During a long computation I opened the taskmanager in windows and I realized that Mathematica (7) uses only one out of 4 cores on my machine. Do you know why this is happening? Do you have the same problem? is is something that has to do with mathematica or with windows? Filippo PS I'm running Mathematica 7 on a Quad core Xeon, 16Gb of ram, windows professional 64 bit edition. === Subject: overlay of multiple plots Show command does not work I generated a list of plots, which I want to overlay. (say around 100 plots). I tried to read in the list inside the Show[] command. But somehow it does not seem to work. Any suggestions? I would be very grateful. Venkatesh Ramakrishnan National Facility for High Field NMR Tata Institute of Fundamental Research Mumbai 400 005 India === I haven't had fun like this since I typed in Barnley's original Byte The Fern just blew me away back then! Today this affine rearranged Sierpinski gasket is great work. http://www.geocities.com/rlbagulatftn/barnsley_affine123.gif http://www.geocities.com/rlbagulatftn/barnsley_affine_234.gif http://www.geocities.com/rlbagulatftn/barnsley_affine_134.gif http://www.maa.org/pubs/monthly_apr09_toc.html April 2009 *Transformations Between Self-Referential Sets* By: Michael F. Barnsley mbarnsley@aol.com Did you know that there are continuous transformations from a fractal fern onto a filled square? Also, there are functions of a similar wild character that map from a filled triangle onto itself. We prove that these /fractal transformations/ may be homeomorphisms, under simple conditions, and that they may be calculated readily by means of a coupled Chaos Game. We illustrate several examples of these beautiful functions and show how they exemplify basic notions in topology, probability, analysis, and geometry. Thus they are worthy of the attention of the mathematics community, both for aesthetic and pedagogical reasons. Mathematica: Clear[f, dlst, pt, cr, ptlst, M, p, a, b, c] n0 = 3; dlst = Table[ Random[Integer, {1, n0}], {n, 100000}]; a = 0.65; b = 0.3; c = 0.4; M = {{{-1 + b, -1/2 + b/2 + a/2}, {0, a}}, {{b + c/ 2 - 1/2, b/2 - c/4 + 1/4}, {1 - c, c/2 - 1/2}}, {{c/2, -1/2 + a/2 - c/4}, {-c, -1 + a + c/2}}, {{b + c/2 - 1/2, -3/4 + b/4 + a/2 - 1/4}, { 1 - c, a - 1/2 - c/4}}} in = {{1 - b, 0}, {1 - b, 0}, {1/2, 1}, {1 - b, 0}}; Length[in] f[j_, {x_, y_}] := M[[j]]. {x, y} + in[[j]] pt = {0.5, 0.5}; cr[n_] := Flatten[Table[If[i == j == k == 1, {}, RGBColor[i, j, k]], {i, 0, 1}, {j, 0, 1}, {k, 0, 1}]][[1 + Mod[n, 7]]]; ptlst[n_] := Table[{cr[dlst[[j]]], Point[pt = f[dlst[[j]], Sequence[pt]]]}, {j, Length[dlst]}]; Show[Graphics[Join[{PointSize[.001]}, ptlst[n]]], AspectRatio -> Automatic, PlotRange -> All] === Subject: Re: Joust in Mathematica Hi David, > Maybe a horizontal scrollbar, and then what are the chances of adding an > invisible locator or EventHandler to alter the width of the left hand panel? the additional scrollbars are not so difficult, it takes a little effort to make the two panes behave more user friendly, but it is rather straightforward (but could probably be improved further). Using locators or EventHandler for this might work but I think it is much easier and probably more robust to stick with the resize areas that the Pane shows with Scrollbars->True. The following has some improvements, but still is more of a demonstration that I think you can probably do what the original poster asked for, although I'm not sure whether I fully understood what that was :-) This defines a function that shows an outline with content in an extra window: Moust[outline_, content_] := CreateDialog[{ DynamicModule[{ widthleft = 150, widthright = 600, height = 400, selectedkey = Level[outline, -1][[1]], outlineview }, Dynamic[ Row[{ Panel[Pane[ outlineview[outline], ImageSize -> Dynamic[{widthleft, height}, ( height = #[[2]]; widthright = widthright + widthleft - #[[1]]; widthleft = #[[1]]; # ) &], Scrollbars -> True ] ], Panel[Pane[ Dynamic[content[selectedkey]], ImageSize -> Dynamic[{widthright, height}, ( height = #[[2]]; widthright = #[[1]]; # ) & ], Scrollbars -> True, Alignment -> {Center, Center} ]] }] ], Initialization :> ( outlineview[key_] := Button[key, selectedkey = key, Appearance -> None]; outlineview[expr_?(StringQ[Head[#]] &)] := OpenerView[{Head[expr], Column[outlineview /@ (List @@ expr)]}]; ) ]} ] This defines an expression which can be shown with the above function: outline = Functions[ Arithmetic[x, x^2, x^3, x^4, Sqrt[x]], Elementary[Log[x], Exp[x]], Trigonometric[Sin[x], Cos[x], Tan[x], Cot[x]], Hyperbolic[Sinh[x], Cosh[x], Tanh[x]] ] This defines a function which will be used to create the content for the right hand side of the window: content[key_] := Plot[Evaluate[key], {x, 0, 3}, Frame -> True, PlotLabel -> key, Background -> White, ImageSize -> 500 ] This will create the window: Moust[outline, content] hth, albert === Subject: Re: Joust in Mathematica > I too was wanting some kind of outliner mode in the notebooks. I > sometimes find the forced way via stylesheets/cells to be restrictive. > Btw, there is no way to drag/drop cells around in a notebook. I was > told I would have to cut/copy then paste. Thats so 80s! LOL By the way there is a global option for Drag and Drop which can be set in the Option Inspector. It is set to False by default. --David === Subject: Re: Joust in Mathematica Albert is on the right track and I'll put some effort into the use of OpenerView. If I can create something functional I'll post it here to see if we can improve it. I can't see a way of showing lines for the joust (i.e. a sideways tree) but can easily forgo that at this stage. The open - closed carret is presumably just displaying and hiding a Cell so in principel I could place a graphic at the start followed by a hyperlink or expression. In principle, we would be able to create something far more useful than the Joust. At first I was simply thinking of using it for navigation much in the same way that the Help Menu works, but there seems to be an opportunity to create something with more intelligence built in. At this stage I am just scouting for ideas and trying to avoid heading down the wrong track. The use of Head to frame the tree was certainly less than obvious! I would have expected a nested list - something like {Continent, {Europe, { UK, Germany, Spain, France...}}, {America,{ Argentina, Brazil, Peru, .....}}, {Asia,..{}}, {Australia....{}}, {Africa...{}}} I can appreciate Davids point about making money using Mathematica. I've been slowly introducing Mathematica 7 into my daily work flow after having given up on it for nearly a decade. The last time I used it seriously was in 2000!! The current bottleneck seems to be graphics speed. Robert ----- Original Message ---- === Subject: Re: Joust in Mathematica It was sort of difficult to see what Joust is from looking at its website and documentation. There wasn't a quick explaination of what it does. My sense is that it was a navigation tool of some sort. Creating things of that general sort in Mathematica should be quite doable. The front end is very plastic in terms of what you cn create in it (though it certainly does have limitations...). But the key issue is that anything of this sort takes considerable time to create. So one (one who does not have lots of free time) needs a business model that supports its creation. Sadly, in my experience with http://scientificarts.com/worklife there is very little interest in general tools. And so, thes things only can get created in one's spare time. Any thoughts on how viable businesses can get created based on Mathematica? My experience over the years is that it's quite difficult to do... I've been wondering how to set up something that behaves like the Java = Joust > in Mathematica: http://www.ivanpeters.com/ we all use them every d= ay > on on > windows machines, so I am wondering how to implement something like it = in > Mathematica. At first, I thought of using GraphPlot or TreePlot, but > then started to wonder if OpenerView and Opener could be trained to beh= ave in > a more > general way. Has anyone thought about this already, or got some working examples? I think OpenerView isn't providing the looks, but the functionality, > depending of course what exactly you have in mind. What exactly are you > missing? Here is some code for Mathematica 7 you might want to play with: tree = A[B[x, y, z], C[f[g[asdf]]]] ov[a_String] := Button[a, content = a] ov[expr_] := OpenerView[{Head[expr], Column[ov /@ (List @@ expr)]}] CreateDialog[{Dynamic[ > Row[{Panel[ > Pane[ov[tree], ImageSize -> {100, 200}, > Scrollbars -> {False, True}]], > Panel[Pane[Dynamic[content], ImageSize -> {200, 200}]]}]]}] hth, albert === Subject: Re: Joust in Mathematica > I can't see a way of showing lines for the joust > (i.e. a sideways tree) but can easily forgo that > at this stage. The open - closed carret is presumably > just displaying and hiding a Cell so in principel > I could place a graphic at the start followed by a > hyperlink or expression. I don't know joust at all, but if I correctly understand what you are after, you just could place Row[]-Expressions within the Buttons, I have enclosed an example in the code below. The carrets are not displaying/hiding cells, they are just part of OpenerView-Expression which will be transformed to PaneSelectorBox-es (and some more) as you can see when looking at the underlying output expressions. Using these low level constructs it would probably even be possible to use different graphical representations than the carrets, but I don't see much value in that... > In principle, we would > be able to create something far more useful than > the Joust. yes, at least within the Mathematica context, of course it would address a different class of problems/documents than joust (and e.g. not run in a browser...). > At first I was simply thinking of using > it for navigation much in the same way that the > Help Menu works, but there seems to be an opportunity > to create something with more intelligence built in. > At this stage I am just scouting for ideas and trying > to avoid heading down the wrong track. If you look for further ideas you might have a look at tiddly wiki which is characterised as a nonlinear notebook somewhere. I think that something like that, where information not (only) is available through the structure that the author originally had in mind would also be something to be very useful in Mathematica Notebooks. It would probably take somewhat more effort to program something like that, but sometimes with a good idea it turns out to be easier than originally thought... > The use of Head to frame the tree was certainly less than > obvious! ... but it is by no means of any relevance, of course you can create a function that works on any other structure which can be interpreted as a tree expression... > I would have expected a nested list - something like {Continent, > {Europe, { UK, Germany, Spain, France...}}, {America,{ Argentina, Brazil, Peru, .....}}, {Asia,..{}}, {Australia....{}}, {Africa...{}}} ... nested lists, (Symbolic) XML, ... you would just need to change some definitions. Here is a version that understands nested lists of rules (a common and useful format within Mathematica code) and shows formatted rows in the outline. Since precreating all the content in this case takes several seconds on my machine I have also changed the code so that the Columns will only be created on the fly when opening one of the OpenerViews, which is achieved with a simple additional Dynamic: Moust[outline_, content_, icon_] := CreateDialog[{ DynamicModule[{ widthleft = 150, widthright = 600, height = 400, selectedkey = Level[outline, -1][[1]], outlineview }, Dynamic[ Row[{ Panel[Pane[ outlineview[outline], ImageSize -> Dynamic[{widthleft, height}, ( height = #[[2]]; widthright = widthright + widthleft - #[[1]]; widthleft = #[[1]]; # ) &], Scrollbars -> True ] ], Panel[Pane[ Dynamic[content[selectedkey]], ImageSize -> Dynamic[{widthright, height}, ( height = #[[2]]; widthright = #[[1]]; # ) & ], Scrollbars -> True, Alignment -> {Center, Center} ]] }] ], Initialization :> ( outlineview[key_] := Button[Row[{ Style[[KernelIcon], Gray], Spacer[5], Show[icon[key], ImageSize -> {Automatic, 10}], Spacer[5], key }], selectedkey = key, Appearance -> None ]; outlineview[rule_Rule] := OpenerView[{rule[[1]], Dynamic[Column[outlineview /@ rule[[2]]]]}]; ) ]} ] outline = World -> Map[ (# -> CountryData[#]) &, {Europe, Asia, NorthAmerica, SouthAmerica, Africa} ]; Moust[outline, CountryData[#, Shape] &, CountryData[#, Flag] &] > I can appreciate Davids point about making money using Mathematica. > I've been slowly introducing Mathematica 7 into my daily work flow > after having given up on it for nearly a decade. The last time I used > it seriously was in 2000!! The current bottleneck seems to be graphics > speed. I think David is correct about his remarks with making money using Mathematica. My experience is that it is possible when focusing on the content you provide and probably not even mention the fact that your deliverables are based on Mathematica, but there is hardly a real market for Mathematica consultancy per se at this time (it could be possible in finance, but that's not a field I know very well, and the question is whether you want to depend on money spent for financial mathematics at these times :-). I'm undecided whether that has to do with Mathematicas standing to merely be an academic tool with only special usages in industry compared to other tools which are considered industrial strength standards and if/how WRI could/should help to change that. industrial strong as needed, but obviously not its standing/image. My feeling is that changing the image in that respect is just not at WRIs (Stevens?) highest priority, probably just not amazing enough in respect to content compared to NKS, Wolfram Alpha and what else might be on their/his mind... And yes, if you want to donate for the above code, I'm happy to provide you with the necessary information :-) hth, albert === Subject: Re: Joust in Mathematica It was sort of difficult to see what Joust is from looking at its website and documentation. There wasn't a quick explaination of what it does. My sense is that it was a navigation tool of some sort. Creating things of that general sort in Mathematica should be quite doable. The front end is very plastic in terms of what you cn create in it (though it certainly does have limitations...). But the key issue is that anything of this sort takes considerable time to create. So one (one who does not have lots of free time) needs a business model that supports its creation. Sadly, in my experience with http://scientificarts.com/worklife there is very little interest in general tools. And so, thes things only can get created in one's spare time. Any thoughts on how viable businesses can get created based on Mathematica? My experience over the years is that it's quite difficult to do... I've been wondering how to set up something that behaves like the Java = Joust > in Mathematica: http://www.ivanpeters.com/ we all use them every d= ay > on on > windows machines, so I am wondering how to implement something like it = in > Mathematica. At first, I thought of using GraphPlot or TreePlot, but > then started to wonder if OpenerView and Opener could be trained to beh= ave in > a more > general way. Has anyone thought about this already, or got some working examples? I think OpenerView isn't providing the looks, but the functionality, > depending of course what exactly you have in mind. What exactly are you > missing? Here is some code for Mathematica 7 you might want to play with: tree = A[B[x, y, z], C[f[g[asdf]]]] ov[a_String] := Button[a, content = a] ov[expr_] := OpenerView[{Head[expr], Column[ov /@ (List @@ expr)]}] CreateDialog[{Dynamic[ > Row[{Panel[ > Pane[ov[tree], ImageSize -> {100, 200}, > Scrollbars -> {False, True}]], > Panel[Pane[Dynamic[content], ImageSize -> {200, 200}]]}]]}] hth, albert === Subject: Re: Joust in Mathematica I too was wanting some kind of outliner mode in the notebooks. I sometimes find the forced way via stylesheets/cells to be restrictive. Btw, there is no way to drag/drop cells around in a notebook. I was told I would have to cut/copy then paste. Thats so 80s! LOL === Subject: Re: Plot3D, show and text Show[ Plot3D[ -8*(x*x + y*y) + (x*x + y*y)^2, {x, -3, 3}, {y, -3, 3}, BoxRatios -> {3, 4, 2}, Mesh -> None, ClippingStyle -> None, RegionFunction -> Function[{x, y, z}, x^2 + y^2 < 9 && x < 2], Boxed -> False, Axes -> True, AxesOrigin -> {0, 0, -16.5}], Graphics3D[{ Text[abc, {1, 1, 2}], Text[def, {2, 2, 4}]}]] Bob Hanlon Is there an expert over there, who would able to add, using mathematica: a text abc at position 1,1,2 and a text def at position 2,2,4, by : keeping same looking at the original plot (no changing of ratio x, y, z) keeping Show (because i need to put other stuff inside) Show[Plot3D[-8*(x*x+y*y)+(x*x+y*y)*(x*x+y*y),{x,-3,3},{y,-3,3},BoxRatios-= >{3,4,2},Mesh->None,ClippingStyle->None,RegionFunction->Function[{x,y,z},= x^2+y^2<9 && x<2],Boxed->False,Axes->True,AxesOrigin->{0,0,-16.5}] thank you === Subject: Fast Access to Installed Packages I like to have fast ways to access a package documentation. One thing that would be helpful is if the 'Add-Ons and Packages' and 'Standard Extra Packages' were actually on the drop down Help menu list so we didn't have to go through the documentation center or type in the package name. I would use these much more than most of the other items on the menu. For example, why is 'Find Selected Function' on the menu list since we can do it much faster directly from a notebook? In lieu of that, I would like to put a command in a package such as 'PackageNameHelp' such that it it were evaluated it would bring up Version 6 documentation. I know how to do it for Version 5 Help Browser documentation. One uses: PacletManager`Package`helpBrowserLookup[packagename]; But I don't know how to write such a statement for Version 6 documentation. Can anyone help? David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ === Subject: Re: Can nobody help me? Re: selecting a column in a grid Paul, I wouldn't have thought my little program was that difficult to understand. If you'd follow the code closely you'd see that it generates a table of event handlers. Each event handler is wrapped around a piece of styled data. I've also wrapped a DynamicModule around every table entry, which causes the variable pos to be localized. If you examine the start of the module you can see that it is initializes pos with the value {i,j}, i.e. the values of the indices which are use to build up the table. Therefore, each event handler in each table cell has its own value of pos and this is the reason it knows its own position in the table. To address your other questions: myData = {{aasdfpppppppppppp, bbbbbbbbb, c}, {dasdf, , f}, {gasdf, h, i}}; Dynamic[clickpos] longest = Select[#, Function[{x}, Composition [StringLength, ToString][x] == Max[Composition [StringLength, ToString] /@ #]], 1] & /@ (myData[Transpose]); Grid[ Table[ DynamicModule[{col = White, pos = {i, j}}, EventHandler[ Graphics[ { Text[longest[[j, 1]] // Invisible], Text[myData[[i, j]]] }, Background -> Dynamic[col], ImageSize -> {Automatic, 14} ], {MouseDown :> (clickpos = pos; col = Red), MouseUp :> (col = White)} ] ], {i, Length[myData]}, {j, Length[myData[[1]]]} ], Frame -> All, BaseStyle -> {Editable -> False, Selectable -> False} ] > -----Original Message----- > Cc: mathgroup@smc.vnet.net === > Subject: RE: Re: Can nobody help me? Re: selecting a column > in a grid > Unfortunately, this approach has a problem for me, and I have to admit > I > don't know why it works at all! The following example shows my problem (I think I have adapted your > code to > use a user-defined list of data properly): > myData = {{aasdfpppppppppppp, bbbbbbbbb, c}, {dasdf, , f}, > {gasdf, h, i}}; > Dynamic[clickpos] > Grid[Table[DynamicModule[{col = Black, pos = {i, j}}, > EventHandler[Style[myData[[i, j]], FontColor -> Dynamic[col]], > {MouseDown :> (clickpos = pos; col = Red), > MouseUp :> (col = Black)}]], {i, 3}, {j, 3}], > Frame -> All, > BaseStyle -> {Editable -> False, Selectable -> False}] In the grid that results, the cell selection only works if the mouse is > clicked inside the text in the cell, not in any whitespace, and the > empty > cell cannot be selected at all. This is a problem for me. But how does > it > work anyway? Eventhandler seems to be wrapped around the cell contents, > rather than the cell itself, but why is there a dynamic value of {i,j} > associated with the cell? I assume that it is something to do with the > fact > that pos is defined within Dynamic, but how does the code know what > value of > {i,j} is associated with each block of displayed text? Is this some > normal > behaviour of Table that I was not aware of, and where would I look to > find > more information about this behaviour? More to the point, is there a > way of > forcing each CELL to take the value of {i,j}, because this would solve > my > problem instantly? Incidentally, if you double-click in the empty cell, the whole table > goes > blue - why is that? proving > to be so complicated. > Paul. -----Original Message----- === > Subject: Re: Can nobody help me? Re: selecting a column in a > grid Hi Paul, Cool down ;-) Try this for inspiration: Dynamic[clickpos] > Grid[ > Table[ > DynamicModule[ > {col=Black, pos = {i, j}}, > EventHandler[ > Style[RandomInteger[{0, 1000000}], FontColor -> Dynamic[col]], > {MouseDown :> (clickpos = pos; col = Red), > MouseUp :> (col = Black)} > ] > ], {i, 5}, {j, 5}] > ] > The key point in this problem is that the columns are not equal > widths, a= > nd > in fact are variable width, depending on the particular data > displayed. S= > o I > set ItemSize to automatic, so that each column width is defined by > the da= > ta. > The trouble is that MousePosition gives me coordinates that are a > linear > function of the position in the grid, but the columns are not > linearly > spaced in the Grid, so how do I know which column the mouse is in? I need one of three things, all three of which are beyond my skills: 1) I could get the actual values that ItemSize is set to when > Automatic i= > s > used. CurrentValue[ItemSize] doesn't work. Anyone got an alternative? > 2) I could calculate what values ItemSize will be set to by looking > at th= > e > type and number of characters in each grid cell, knowing the font > size= > , > font family, cell margins, frame linewidth etc. But I don't have > access t= > o > the information needed - how many pixels does a Courier Size 10 n > take = > up? > 3) I could use EventHandler in a better way. Currently I wrap it > around t= > he > whole Grid, but if I could wrap it around a cell, that would work for > me.= > No > syntax that I have tried works - should I try using GridBox, or is > there = > an > obvious better idea? Nobody got any ideas at all? What kind of language is this, where you > can= > 't > even select a column in a table? > Paul. -----Original Message----- === > Subject: selecting a column in a grid > I have a tricky problem with a graphical user interface. I have a > grid of > data, and I want to be able to MouseClick in the grid to either > select a = > row > or a column. Using GUIKit, this is trivial, but I want to be able to > distribute my program using PlayerPro, which won't support GUIKit. Selecting a row is straightforward using EventHandler and > EventHandlerScaled, since I know how many rows there are and they are > all > one line in height. However, the column widths change according to > the da= > ta, > since I have set ItemSize to Auto. So is there some way of retrieving > the > actual values used in ItemSize, when Auto is used? I have tried > CurrentValue[ItemSize] in many variations, but it always fails. I could, of course, look at the data that will be in the grid, and > comput= > e > the widths of each column accordingly, and synthesize the values that > ItemSize will take. To do that, though, I would need to know what the > pix= > el > width of a particular text string will be, which varies with font > family, > size etc. Is there an easy way to do this? This is essentially what > Mathematica does when ItemSize is set to Auto, but I have no idea how > to = > do > it myself. Currently I have EventHandler wrapped around the whole grid. Is it > possib= > le > to wrap it around each individual cell in a grid? I have tried a few > idea= > s, > but they don't seem to work. The documentation suggests that > EventHandler > can be wrapped around any expression, but that doesn't seem to be the > cas= > e, > or at least the wrapped expression doesn't seem to display properly > insid= > e > other constructs, such as Grid, Column etc. Is there some better approach I could take, rather than using > EventHandle= > r? All ideas gratefully received. > Paul. Dr. Paul A. Ellsmore Nanion Limited Oxford Centre for Innovation Mill Street Oxford United Kingdom OX2 0JX Tel: +44 (0) 1865 811175 Fax: +44 (0) 1865 248594 === Subject: Re: Can nobody help me? Re: selecting a column in a grid Hi Albert, Actually, I have looked at this again, and I have a problem. If you use the following data to populate the grid myData = {{aasdfpppppppppppp, bbbbbbbbb, c}, {dasdf, , f}, {gasdf, h, i}} You will see that the cell can only be selected by clicking in the text, not in any whitespace, and the empty cell cannot be selected at all. This is the same problem as I have with another suggested solution, which also looked promising. You mentioned an issue with Spacing, but I don't see why that matters. Eventhandler is wrapped around each Pane, so mouseclicked should be recognized anywhere in each Pane. Possibly your ImageMargin setting is making the Pane only extend as far as the text, does that sound right? I will try changing those settings, or using a different construct to Pane, but any advice would be welcome. Incidentally, just to show my ignorance, I am confused about #1 and #2. I think #1 means that Pane is applied to each element in the data list at level 2, but I don't understand what #2[[2]] means, could you explain? Paul. -----Original Message----- === Subject: Re: Can nobody help me? Re: selecting a column in a grid > Currently I have EventHandler wrapped around the whole grid. Is it possible > to wrap it around each individual cell in a grid? I have tried a few ideas, > but they don't seem to work. The documentation suggests that EventHandler > can be wrapped around any expression, but that doesn't seem to be the case, > or at least the wrapped expression doesn't seem to display properly inside > other constructs, such as Grid, Column etc. I think using EventHandler for the content of individual cells will work much better and it works as documented, see below. The problem is that a cell in a grid is not something that exists as an individual expression (Item would actually be, but this indeed doesn't work, it looks like Grid doesn't recognize the Item as such if it is wrapped with EventHandler). > Is there some better approach I could take, rather than using EventHandler? Would this be close to what you want? Admittedly it is a little hacky, since one needs to play with the ImageMargins and Spacings options to get a result that has no blind spots for the mouse clicks and looks decent. The possibility to wrap Item in Grid with EventHandler would be nicer, or an option for Item that would allow the handling of events... Deploy[Grid[ MapIndexed[ Item[ EventHandler[ Pane[#1, ImageMargins -> {3*{1, 1}, {0, 0}}], {MouseClicked :> (selectedcolumn = #2[[2]])}], Background -> Dynamic[If[selectedcolumn == #2[[2]], LightGray, White]] ] &, {{aasdf, b, c}, {dasdf, e, f}, {gasdf, h, i}}, {2} ], Dividers -> All, Spacings -> 0.15 ]] note that I needed to set a small value for Spacings, otherwise when clicking in the Spacing-area, the events won't be triggered. Using Spacings->0 will make the Dividers become invisible which may or may not be a problem for you. To get back the normal look of the table with decent margins for the contents of the cells I am using a Pane with individual ImageMargins options, which you might adopt to your taste. I was choosing something that is close to the default spacings Grid will use with no options. Without using Deploy it can happen that instead of triggering the MouseClick Event you end up selecting some content of the cell without changing the column selection, so I think usually using Deploy will be a good choice for an interactive graphical user interface. Changing the background color for the selected column is just to demonstrate that it works... Here is the same thing for selecting cells: Deploy[Grid[ MapIndexed[ Item[ EventHandler[ Pane[#1, ImageMargins -> {3*{1, 1}, {0, 0}}], {MouseClicked :> (selectedcell = #2)}], Background -> Dynamic[Switch[selectedcell, #2, LightRed,{#2[[1]], _}, LightBlue, {_, #2[[2]]}, LightGreen,_, White]] ] &, {{aasdf, b, c}, {dasdf, e, f}, {gasdf, h, i}}, {2} ], Dividers -> All, Spacings -> 0.15 ]] hth, albert === Subject: Re: Can nobody help me? Re: selecting a column in a grid positively elegant compared to the stuff I write! Paul. -----Original Message----- === Subject: Re: Can nobody help me? Re: selecting a column in a grid > Currently I have EventHandler wrapped around the whole grid. Is it possible > to wrap it around each individual cell in a grid? I have tried a few ideas, > but they don't seem to work. The documentation suggests that EventHandler > can be wrapped around any expression, but that doesn't seem to be the case, > or at least the wrapped expression doesn't seem to display properly inside > other constructs, such as Grid, Column etc. I think using EventHandler for the content of individual cells will work much better and it works as documented, see below. The problem is that a cell in a grid is not something that exists as an individual expression (Item would actually be, but this indeed doesn't work, it looks like Grid doesn't recognize the Item as such if it is wrapped with EventHandler). > Is there some better approach I could take, rather than using EventHandler? Would this be close to what you want? Admittedly it is a little hacky, since one needs to play with the ImageMargins and Spacings options to get a result that has no blind spots for the mouse clicks and looks decent. The possibility to wrap Item in Grid with EventHandler would be nicer, or an option for Item that would allow the handling of events... Deploy[Grid[ MapIndexed[ Item[ EventHandler[ Pane[#1, ImageMargins -> {3*{1, 1}, {0, 0}}], {MouseClicked :> (selectedcolumn = #2[[2]])}], Background -> Dynamic[If[selectedcolumn == #2[[2]], LightGray, White]] ] &, {{aasdf, b, c}, {dasdf, e, f}, {gasdf, h, i}}, {2} ], Dividers -> All, Spacings -> 0.15 ]] note that I needed to set a small value for Spacings, otherwise when clicking in the Spacing-area, the events won't be triggered. Using Spacings->0 will make the Dividers become invisible which may or may not be a problem for you. To get back the normal look of the table with decent margins for the contents of the cells I am using a Pane with individual ImageMargins options, which you might adopt to your taste. I was choosing something that is close to the default spacings Grid will use with no options. Without using Deploy it can happen that instead of triggering the MouseClick Event you end up selecting some content of the cell without changing the column selection, so I think usually using Deploy will be a good choice for an interactive graphical user interface. Changing the background color for the selected column is just to demonstrate that it works... Here is the same thing for selecting cells: Deploy[Grid[ MapIndexed[ Item[ EventHandler[ Pane[#1, ImageMargins -> {3*{1, 1}, {0, 0}}], {MouseClicked :> (selectedcell = #2)}], Background -> Dynamic[Switch[selectedcell, #2, LightRed,{#2[[1]], _}, LightBlue, {_, #2[[2]]}, LightGreen,_, White]] ] &, {{aasdf, b, c}, {dasdf, e, f}, {gasdf, h, i}}, {2} ], Dividers -> All, Spacings -> 0.15 ]] hth, albert === Subject: Re: Can nobody help me? Re: selecting a column in a grid Unfortunately, this approach has a problem for me, and I have to admit I don't know why it works at all! The following example shows my problem (I think I have adapted your code to use a user-defined list of data properly): myData = {{aasdfpppppppppppp, bbbbbbbbb, c}, {dasdf, , f}, {gasdf, h, i}}; Dynamic[clickpos] Grid[Table[DynamicModule[{col = Black, pos = {i, j}}, EventHandler[Style[myData[[i, j]], FontColor -> Dynamic[col]], {MouseDown :> (clickpos = pos; col = Red), MouseUp :> (col = Black)}]], {i, 3}, {j, 3}], Frame -> All, BaseStyle -> {Editable -> False, Selectable -> False}] In the grid that results, the cell selection only works if the mouse is clicked inside the text in the cell, not in any whitespace, and the empty cell cannot be selected at all. This is a problem for me. But how does it work anyway? Eventhandler seems to be wrapped around the cell contents, rather than the cell itself, but why is there a dynamic value of {i,j} associated with the cell? I assume that it is something to do with the fact that pos is defined within Dynamic, but how does the code know what value of {i,j} is associated with each block of displayed text? Is this some normal behaviour of Table that I was not aware of, and where would I look to find more information about this behaviour? More to the point, is there a way of forcing each CELL to take the value of {i,j}, because this would solve my problem instantly? Incidentally, if you double-click in the empty cell, the whole table goes blue - why is that? to be so complicated. Paul. -----Original Message----- === Subject: Re: Can nobody help me? Re: selecting a column in a grid Hi Paul, Cool down ;-) Try this for inspiration: Dynamic[clickpos] Grid[ Table[ DynamicModule[ {col=Black, pos = {i, j}}, EventHandler[ Style[RandomInteger[{0, 1000000}], FontColor -> Dynamic[col]], {MouseDown :> (clickpos = pos; col = Red), MouseUp :> (col = Black)} ] ], {i, 5}, {j, 5}] ] > The key point in this problem is that the columns are not equal widths, a= nd > in fact are variable width, depending on the particular data displayed. S= o I > set ItemSize to automatic, so that each column width is defined by the da= ta. > The trouble is that MousePosition gives me coordinates that are a linear > function of the position in the grid, but the columns are not linearly > spaced in the Grid, so how do I know which column the mouse is in? I need one of three things, all three of which are beyond my skills: 1) I could get the actual values that ItemSize is set to when Automatic i= s > used. CurrentValue[ItemSize] doesn't work. Anyone got an alternative? > 2) I could calculate what values ItemSize will be set to by looking at th= e > type and number of characters in each grid cell, knowing the font size= , > font family, cell margins, frame linewidth etc. But I don't have access t= o > the information needed - how many pixels does a Courier Size 10 n take = up? > 3) I could use EventHandler in a better way. Currently I wrap it around t= he > whole Grid, but if I could wrap it around a cell, that would work for me.= No > syntax that I have tried works - should I try using GridBox, or is there = an > obvious better idea? Nobody got any ideas at all? What kind of language is this, where you can= 't > even select a column in a table? > Paul. -----Original Message----- === > Subject: selecting a column in a grid > I have a tricky problem with a graphical user interface. I have a grid of > data, and I want to be able to MouseClick in the grid to either select a = row > or a column. Using GUIKit, this is trivial, but I want to be able to > distribute my program using PlayerPro, which won't support GUIKit. Selecting a row is straightforward using EventHandler and > EventHandlerScaled, since I know how many rows there are and they are all > one line in height. However, the column widths change according to the da= ta, > since I have set ItemSize to Auto. So is there some way of retrieving the > actual values used in ItemSize, when Auto is used? I have tried > CurrentValue[ItemSize] in many variations, but it always fails. I could, of course, look at the data that will be in the grid, and comput= e > the widths of each column accordingly, and synthesize the values that > ItemSize will take. To do that, though, I would need to know what the pix= el > width of a particular text string will be, which varies with font family, > size etc. Is there an easy way to do this? This is essentially what > Mathematica does when ItemSize is set to Auto, but I have no idea how to = do > it myself. Currently I have EventHandler wrapped around the whole grid. Is it possib= le > to wrap it around each individual cell in a grid? I have tried a few idea= s, > but they don't seem to work. The documentation suggests that EventHandler > can be wrapped around any expression, but that doesn't seem to be the cas= e, > or at least the wrapped expression doesn't seem to display properly insid= e > other constructs, such as Grid, Column etc. Is there some better approach I could take, rather than using EventHandle= r? All ideas gratefully received. > Paul. Dr. Paul A. Ellsmore Nanion Limited Oxford Centre for Innovation Mill Street Oxford United Kingdom OX2 0JX Tel: +44 (0) 1865 811175 Fax: +44 (0) 1865 248594 === Subject: Re: Can nobody help me? Re: selecting a column in a grid > Currently I have EventHandler wrapped around the whole grid. Is it possible > to wrap it around each individual cell in a grid? I have tried a few ideas, > but they don't seem to work. The documentation suggests that EventHandler > can be wrapped around any expression, but that doesn't seem to be the case, > or at least the wrapped expression doesn't seem to display properly inside > other constructs, such as Grid, Column etc. I think using EventHandler for the content of individual cells will work much better and it works as documented, see below. The problem is that a cell in a grid is not something that exists as an individual expression (Item would actually be, but this indeed doesn't work, it looks like Grid doesn't recognize the Item as such if it is wrapped with EventHandler). > Is there some better approach I could take, rather than using EventHandler? Would this be close to what you want? Admittedly it is a little hacky, since one needs to play with the ImageMargins and Spacings options to get a result that has no blind spots for the mouse clicks and looks decent. The possibility to wrap Item in Grid with EventHandler would be nicer, or an option for Item that would allow the handling of events... Deploy[Grid[ MapIndexed[ Item[ EventHandler[ Pane[#1, ImageMargins -> {3*{1, 1}, {0, 0}}], {MouseClicked :> (selectedcolumn = #2[[2]])}], Background -> Dynamic[If[selectedcolumn == #2[[2]], LightGray, White]] ] &, {{aasdf, b, c}, {dasdf, e, f}, {gasdf, h, i}}, {2} ], Dividers -> All, Spacings -> 0.15 ]] note that I needed to set a small value for Spacings, otherwise when clicking in the Spacing-area, the events won't be triggered. Using Spacings->0 will make the Dividers become invisible which may or may not be a problem for you. To get back the normal look of the table with decent margins for the contents of the cells I am using a Pane with individual ImageMargins options, which you might adopt to your taste. I was choosing something that is close to the default spacings Grid will use with no options. Without using Deploy it can happen that instead of triggering the MouseClick Event you end up selecting some content of the cell without changing the column selection, so I think usually using Deploy will be a good choice for an interactive graphical user interface. Changing the background color for the selected column is just to demonstrate that it works... Here is the same thing for selecting cells: Deploy[Grid[ MapIndexed[ Item[ EventHandler[ Pane[#1, ImageMargins -> {3*{1, 1}, {0, 0}}], {MouseClicked :> (selectedcell = #2)}], Background -> Dynamic[Switch[selectedcell, #2, LightRed,{#2[[1]], _}, LightBlue, {_, #2[[2]]}, LightGreen,_, White]] ] &, {{aasdf, b, c}, {dasdf, e, f}, {gasdf, h, i}}, {2} ], Dividers -> All, Spacings -> 0.15 ]] hth, albert === Subject: Re: Can nobody help me? Re: selecting a column in a grid Hi Paul, Cool down ;-) Try this for inspiration: Dynamic[clickpos] Grid[ Table[ DynamicModule[ {col=Black, pos = {i, j}}, EventHandler[ Style[RandomInteger[{0, 1000000}], FontColor -> Dynamic[col]], {MouseDown :> (clickpos = pos; col = Red), MouseUp :> (col = Black)} ] ], {i, 5}, {j, 5}] ] > The key point in this problem is that the columns are not equal widths, a= nd > in fact are variable width, depending on the particular data displayed. S= o I > set ItemSize to automatic, so that each column width is defined by the da= ta. > The trouble is that MousePosition gives me coordinates that are a linear > function of the position in the grid, but the columns are not linearly > spaced in the Grid, so how do I know which column the mouse is in? I need one of three things, all three of which are beyond my skills: 1) I could get the actual values that ItemSize is set to when Automatic i= s > used. CurrentValue[ItemSize] doesn't work. Anyone got an alternative? > 2) I could calculate what values ItemSize will be set to by looking at th= e > type and number of characters in each grid cell, knowing the font size= , > font family, cell margins, frame linewidth etc. But I don't have access t= o > the information needed - how many pixels does a Courier Size 10 n take = up? > 3) I could use EventHandler in a better way. Currently I wrap it around t= he > whole Grid, but if I could wrap it around a cell, that would work for me.= No > syntax that I have tried works - should I try using GridBox, or is there = an > obvious better idea? Nobody got any ideas at all? What kind of language is this, where you can= 't > even select a column in a table? > Paul. -----Original Message----- === > Subject: selecting a column in a grid > I have a tricky problem with a graphical user interface. I have a grid of > data, and I want to be able to MouseClick in the grid to either select a = row > or a column. Using GUIKit, this is trivial, but I want to be able to > distribute my program using PlayerPro, which won't support GUIKit. Selecting a row is straightforward using EventHandler and > EventHandlerScaled, since I know how many rows there are and they are all > one line in height. However, the column widths change according to the da= ta, > since I have set ItemSize to Auto. So is there some way of retrieving the > actual values used in ItemSize, when Auto is used? I have tried > CurrentValue[ItemSize] in many variations, but it always fails. I could, of course, look at the data that will be in the grid, and comput= e > the widths of each column accordingly, and synthesize the values that > ItemSize will take. To do that, though, I would need to know what the pix= el > width of a particular text string will be, which varies with font family, > size etc. Is there an easy way to do this? This is essentially what > Mathematica does when ItemSize is set to Auto, but I have no idea how to = do > it myself. Currently I have EventHandler wrapped around the whole grid. Is it possib= le > to wrap it around each individual cell in a grid? I have tried a few idea= s, > but they don't seem to work. The documentation suggests that EventHandler > can be wrapped around any expression, but that doesn't seem to be the cas= e, > or at least the wrapped expression doesn't seem to display properly insid= e > other constructs, such as Grid, Column etc. Is there some better approach I could take, rather than using EventHandle= r? All ideas gratefully received. > Paul. Dr. Paul A. Ellsmore Nanion Limited Oxford Centre for Innovation Mill Street Oxford United Kingdom OX2 0JX Tel: +44 (0) 1865 811175 Fax: +44 (0) 1865 248594 === Subject: Can nobody help me? Re: selecting a column in a grid The key point in this problem is that the columns are not equal widths, and in fact are variable width, depending on the particular data displayed. So I set ItemSize to automatic, so that each column width is defined by the data. The trouble is that MousePosition gives me coordinates that are a linear function of the position in the grid, but the columns are not linearly spaced in the Grid, so how do I know which column the mouse is in? I need one of three things, all three of which are beyond my skills: 1) I could get the actual values that ItemSize is set to when Automatic is used. CurrentValue[ItemSize] doesn't work. Anyone got an alternative? 2) I could calculate what values ItemSize will be set to by looking at the type and number of characters in each grid cell, knowing the font size, font family, cell margins, frame linewidth etc. But I don't have access to the information needed - how many pixels does a Courier Size 10 n take up? 3) I could use EventHandler in a better way. Currently I wrap it around the whole Grid, but if I could wrap it around a cell, that would work for me. No syntax that I have tried works - should I try using GridBox, or is there an obvious better idea? Nobody got any ideas at all? What kind of language is this, where you can't even select a column in a table? Paul. -----Original Message----- === Subject: selecting a column in a grid I have a tricky problem with a graphical user interface. I have a grid of data, and I want to be able to MouseClick in the grid to either select a row or a column. Using GUIKit, this is trivial, but I want to be able to distribute my program using PlayerPro, which won't support GUIKit. Selecting a row is straightforward using EventHandler and EventHandlerScaled, since I know how many rows there are and they are all one line in height. However, the column widths change according to the data, since I have set ItemSize to Auto. So is there some way of retrieving the actual values used in ItemSize, when Auto is used? I have tried CurrentValue[ItemSize] in many variations, but it always fails. I could, of course, look at the data that will be in the grid, and compute the widths of each column accordingly, and synthesize the values that ItemSize will take. To do that, though, I would need to know what the pixel width of a particular text string will be, which varies with font family, size etc. Is there an easy way to do this? This is essentially what Mathematica does when ItemSize is set to Auto, but I have no idea how to do it myself. Currently I have EventHandler wrapped around the whole grid. Is it possible to wrap it around each individual cell in a grid? I have tried a few ideas, but they don't seem to work. The documentation suggests that EventHandler can be wrapped around any expression, but that doesn't seem to be the case, or at least the wrapped expression doesn't seem to display properly inside other constructs, such as Grid, Column etc. Is there some better approach I could take, rather than using EventHandler? All ideas gratefully received. Paul. Dr. Paul A. Ellsmore Nanion Limited Oxford Centre for Innovation Mill Street Oxford United Kingdom OX2 0JX Tel: +44 (0) 1865 811175 Fax: +44 (0) 1865 248594 === Subject: complex function fitting? Does anyone know how I could extend the domain of Mathematica's function-fitting functions so I can use complex-valued data? === Subject: Difficulties with Re Of the following two expressions, the first works, while the second doesn't. How does one make it work? Assuming[x > 0 && y > 0, Re[Exp[x + I y]] // Simplify] Assuming[x > 0 && y > 0, Re[Exp[(x + I y)^2]] // Simplify] Aaron === Subject: Re: Map to nested list Map[IntegerQ, list, {2}] {{True, False}, {True, False}} David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ this expression IntegerQ/@{1,1/5} outputs {True, False} which operator is used for nested list? so IntegerQ ? {{1,1/5},{1,1/5}} outputs {{True, False},{True, False}} thankyou :) === Subject: Re: Can't figure out how to export strictly speaking, you don't export to LaTeX. All LaTeX will do [ beautifully ] is pick up the image you've saved to disk from Mathematica and include it within your final compiled document [ probably a PDF ]. Peter 2009/4/3 Gerry Flanagan : > I believe the only direct path (no intermediate third-party software) is > to copy-as an image, such as bit-map, and paste. I just started > experimenting with MathType 6.5 (not the version that ships with Word). > It will allow you to paste in a Mathematica equation. It seems to do a > reasonable job, at least for moderate size and complexity equations. The > best answer is to probably to export to LaTex, then find some software > to use the tex in word, but I'm less familiar with that route. > Gerry F. > I help out my lab partners in one of my classes by exporting out the dat= a and equations we worked on from mathematica. They use microsoft word so I= need to copy or export things into rtf first or copy things directly into = microsoft word. The problem is that many symbols come out strangely when I = try to export or even copy them the tables and math notation comes out like= --- >> {[Null], !(*SubscriptBox[(F), (1)]), !(*SubscriptBox[= (d), (1)]), !(*SubscriptBox[(=83=E4), (1)]), !(*Subscrip= tBox[(F), (2)]), >> It seems like there is something not set up the way I want to in the exp= ort or copy functions... Also, when exporting to rtf, the tables come out a= s a list of data instead of being in the correct form. Another system used = to export this stuff out to rtf correctly by default... How do I set up mat= hematica to do the same? > -- Peter Lindsay === Subject: Re: Please help, factorisation question thank you for your solution I regret to say that i had failed to specify that the elements of the list nn are rationals a/b, not integers can you think of a way to modify the algorithm so it gives a result in this case ? === Subject: How to remove all cycles I want to write the following code using functional programming, i.e. to remove all Do's. There are two arrays: A[[i]], i=1,...,2^(n+1) B[[j,k]], j=1,2; k=1,...,2^n. I need to assign B to A setting the first bit of the index i to be the index j. Explicitly Do[Do[A[[ j + BitShiftLeft[k-1,1] ]]= B[[j,k]], {j,1,2}],{k,1,2^n}] I need to do it for multi-dimensional large arrays. Is it possible to write it without Do's ? === Subject: Re: Interpolation -> segfault? On Apr 1, 3:50 pm, Jens-Peer Kuska your InterpolationFunction[] cause the kernel crash and it would helpful > to find out where it come from .. The input seems to be nonsense and it is no wonder that the kernel > crashes. > Nonsensical? It's a standard InterpolatingFunction object. I don't know what you mean. The function is made by (1) using FunctionInterpolation on a very complicated, slow-to-evaluate expression to create an object f1; (2) wrapping it with If[#1<... || #1> ..., 0, fn]; and then (3) using 'Save'. That'sit. The original function, before saving, does evaluate fine: I've used it to create other data products (e.g., with NIntegrate). Just hangs when restoring it. Also, I recently discovered that the function as above works fine if you manually change only a few of the very small numbers (10^(-316) !) to 0. And, going back to the original code, adding 'Chop' before I do the FunctionInterpolation yields an object that saves and restores without trouble. I therefore *strongly suspect* this is an issue pertaining to the precision with which the object was saved. === Subject: Can nobody help me? Re: selecting a column in a grid The key point in this problem is that the columns are not equal widths, and in fact are variable width, depending on the particular data displayed. So I set ItemSize to automatic, so that each column width is defined by the data. The trouble is that MousePosition gives me coordinates that are a linear function of the position in the grid, but the columns are not linearly spaced in the Grid, so how do I know which column the mouse is in? I need one of three things, all three of which are beyond my skills: 1) I could get the actual values that ItemSize is set to when Automatic is used. CurrentValue[ItemSize] doesn't work. Anyone got an alternative? 2) I could calculate what values ItemSize will be set to by looking at the type and number of characters in each grid cell, knowing the font size, font family, cell margins, frame linewidth etc. But I don't have access to the information needed - how many pixels does a Courier Size 10 n take up? 3) I could use EventHandler in a better way. Currently I wrap it around the whole Grid, but if I could wrap it around a cell, that would work for me. No syntax that I have tried works - should I try using GridBox, or is there an obvious better idea? Nobody got any ideas at all? What kind of language is this, where you can't even select a column in a table? Paul. -----Original Message----- === Subject: selecting a column in a grid I have a tricky problem with a graphical user interface. I have a grid of data, and I want to be able to MouseClick in the grid to either select a row or a column. Using GUIKit, this is trivial, but I want to be able to distribute my program using PlayerPro, which won't support GUIKit. Selecting a row is straightforward using EventHandler and EventHandlerScaled, since I know how many rows there are and they are all one line in height. However, the column widths change according to the data, since I have set ItemSize to Auto. So is there some way of retrieving the actual values used in ItemSize, when Auto is used? I have tried CurrentValue[ItemSize] in many variations, but it always fails. I could, of course, look at the data that will be in the grid, and compute the widths of each column accordingly, and synthesize the values that ItemSize will take. To do that, though, I would need to know what the pixel width of a particular text string will be, which varies with font family, size etc. Is there an easy way to do this? This is essentially what Mathematica does when ItemSize is set to Auto, but I have no idea how to do it myself. Currently I have EventHandler wrapped around the whole grid. Is it possible to wrap it around each individual cell in a grid? I have tried a few ideas, but they don't seem to work. The documentation suggests that EventHandler can be wrapped around any expression, but that doesn't seem to be the case, or at least the wrapped expression doesn't seem to display properly inside other constructs, such as Grid, Column etc. Is there some better approach I could take, rather than using EventHandler? All ideas gratefully received. Paul. Dr. Paul A. Ellsmore Nanion Limited Oxford Centre for Innovation Mill Street Oxford United Kingdom OX2 0JX Tel: +44 (0) 1865 811175 Fax: +44 (0) 1865 248594 === Subject: Re: Styling the selected Tab's label in TabView > Bryce, If your labels are just strings then why use Graphics and Text to display > them? > Because I was starting from that example, I guess... since you've suggested that I don't need to use Graphics+Text, I've tried this: labels = {Bill, Susan}; DynamicModule[ {selected}, TabView[ Table[ With[ {i = i}, Style[ Text[labels[[i]]], ] -> (Hello <> labels[[i]] <> !) ], {i, Length[labels]} ], Dynamic[selected] ] ] It doesn't have the sizing issue, but now it doesn't style dynamically either. -- Bryce Schober === Subject: Re: Styling the selected Tab's label in TabView > It seems that you can't set the LabelStyle of individual tabs in a TabView. What is wrong with: labels = {Bill, Susan}; DynamicModule[{selected}, TabView[Table[ With[{i = i}, Style[labels[[i]], FontWeight -> labels[[i]] <> !)], {i, Length[labels]}], Dynamic[selected]]] Which version are you using? hth, albert === Subject: Re: Styling the selected Tab's label in TabView Bryce, If your labels are just strings then why use Graphics and Text to display them? labels = {Bill, Susan}; DynamicModule[{selected}, TabView[Table[ With[{i = i}, Style[labels[[i]], FontWeight -> labels[[i]] <> !)], {i, Length[labels]}], Dynamic[selected]]] But if you want to use Graphics then use the ImageSize Option to control the size. labels = {Bill, Susan}; DynamicModule[{selected}, TabView[Table[ With[{i = i}, Graphics[ Style[Text[labels[[i]]], ImageSize -> 25, PlotRangePadding -> .5] -> (Hello <> labels[[i]] <> !)], {i, Length[labels]}], Dynamic[selected]]] David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ It seems that you can't set the LabelStyle of individual tabs in a TabView. Starting with the example in my TabView->Examples->Scope->Control documentation, I got to: labels = {Bill, Susan}; DynamicModule[ {selected}, TabView[ Table[ With[ {i = i}, Graphics[ Style[ Text[labels[[i]]], FontWeight -> Dynamic[ Bold, Plain ] ] ], ImageSize -> All, PlotRangePadding -> .5 ] -> (Hello <> labels[[i]] <> !) ], {i, Length[labels]} ], Dynamic[selected] ] ] This manages to bold the selected tab, but ImageSize -> All isn't limiting itself to the size of the Text[], and I'm not sure how to limit the resulting tab size to only that required for the text display... -- Bryce Schober === Subject: Re: Graphics and DisplayFunction > I would forget about the DisplayFunction option - it is more or > less obsolete. If DisplayFunction -> f is used as an option to a Plot function or Show, then f is applied to the result. Since the default value of DisplayFunction is $DisplayFunction, this makes $DisplayFunction something like $Post for graphical commands. This can be quite handy. Here are three example settings for $DisplayFunction. * Create a tooltip when hovering over a graph: $DisplayFunction = Tooltip[#, On graph!] &; * Show graph and also auto-export to a file: cnt = 0; $DisplayFunction = ( Export[pic <> ToString[++cnt] <> .png,#]; # )&; * Send graphics to another program: df[g_] := Module[ {strm}, strm = OpenWrite[!open -f -a /Applications/Preview.app]; WriteString[strm, ExportString[g, EPS]]; Close[strm] ]; $DisplayFunction = df; After defining $DisplayFunction by entering any of these commands, simply enter a graphical command, like Plot[x^2, {x,-2,2}], to see it in action. The last example is set up to pipe the output to Preview.app on the Mac, but I suppose that something similar would work on the PC. This last one is most interesting if you're running a text based interface, like the Mac Terminal. To get it to work in that context you need to install a front end as well by first entering: Developer`InstallFrontEnd[]; I actually do this frequently when manipulating Mathematica from other programs. So, have fun with DisplayFunction, Mark McClure === Subject: Re: Graphics and DisplayFunction Of course one can forget about DisplayFunction and use Print, but for me a more elaborate function does the job: Since I have plotting functions deeply embedded in code and in packages (and for other reasons), I actually have to maintain a DisplayFunction, which - through user-defined switches - redirects results to various outputs, possibly not just to the actual notebook, but simultaneously to notebook AND multiple files as well. Also a problem with your method is that by Printing a Graphics, you end up with something that is NOT a Graphics object, but in my case (I don't want to get to the complex details) I definitely need something in return that is a Graphics object. I have everything working for years now, just this bit (the topic, i.e. Graphics are not affected by DisplayFunction) caused some malfunctions in the previous days. Istvan I would forget about the DisplayFunction option - it is more or less > obsolete. Just think of graphics as output - just like numbers or equatio= ns. If you do a calculation, and then as the last step generate a graphical > output (either explicitly with Graphics, or indirectly using Plot (say), > then providing you don't terminate that command with a semicolon, you > will get your graphical output, for example: xx = 10; > yy = 20; > Graphics[{Line[{{-xx/2, 0}, {xx/2, 0}}], > Line[{{0, -yy/2}, {0, yy/2}}]}] If, however, you want to go on and calculate something else (or make > another graph), simply print your graphical output (again, exactly as > you would for text): xx = 10; > yy = 20; > Print[Graphics[{Line[{{-xx/2, 0}, {xx/2, 0}}], > Line[{{0, -yy/2}, {0, yy/2}}]}]]; > Print[Something else ,Sqrt[xx]]; === Subject: Re: help in constructing a binomial consequence Hi Galina, I'm not sure why your topic title uses the word binomial. It suggests the coefficients of your sequence should be binomial but your example doesn't show any such coefficients. Furthermore, your series is a bit irregular. The first few start with x having the highest power, then decreasing, but F[7] - F[9] do not adhere to that pattern. Assuming you're mistaken here and F[7] should be x^3, F[8] x^2 y, F[9] x y^2 and F[10] y^3, F can be given by F[n_] := Module[{t, m}, t = [LeftFloor]1/2 (-1 + Sqrt[1 + 8 (-1 + n)])[RightFloor]; m = n - 1 - 1/2 t (1 + t); x ^(t - m) y^m ] I leave it as an exercise to you to determine why the variables t and m have these specific values. A brute-force approach, but easier to understand, would be F[i_] := Flatten[Table[x ^(n - r) y^r, {n, 0, i}, {r, 0, n}]][[i]]. It does more calculations than necessary, but I assume i will never get very high. > Hello all, > I need to find an eigenvalues of the matrix M [N*N] where elements > are of the type F[i]*F[j]. I need help to construct the elements F[i] > which must be in the following order: F[1]=1, F[2]=x, F[3]=y, F[4] > =x^2, F[5]=x*y, F[6]=y^2, F[7]=y*x^2, F[8]=x*y^2, F[9]=x^3 an= d etc.... > Could someone help, please? Galina === Subject: Re: help in constructing a binomial consequence if it must be that order and you cant give us the rule for that order you have to type it by hand otherwise With[{n = 3}, lst = Flatten[ Outer[Times, Table[x^i, {i, 0, n}], Table[y^j, {j, 0, n}]], 1] ] exponentSum[expr_] := Block[{ex, ey}, ex = Exponent[expr, x]; ey = Exponent[expr, y]; ex + ey ] and Sort[lst, exponentSum[#1] < exponentSum[#2] || OrderedQ[{#1, #2}] &] will do something that is very close to your ordering. Jens > Hello all, > I need to find an eigenvalues of the matrix M [N*N] where elements > are of the type F[i]*F[j]. I need help to construct the elements F[i] > which must be in the following order: F[1]=1, F[2]=x, F[3]=y, F[4] > =x^2, F[5]=x*y, F[6]=y^2, F[7]=y*x^2, F[8]=x*y^2, F[9]=x^3 and etc.... > Could someone help, please? Galina > === Subject: Re: help in constructing a binomial consequence > I need to find an eigenvalues of the matrix M [N*N] where elements > are of the type F[i]*F[j]. I need help to construct the elements F[i] > which must be in the following order: F[1]=1, F[2]=x, F[3]=y, F[4] > =x^2, F[5]=x*y, F[6]=y^2, F[7]=y*x^2, F[8]=x*y^2, F[9]=x^3 an= d etc.... Your pattern seems a bit off. I'm guessing you mean: 1, x, y, x^2, x y, y^2, x^3, x^2 y, x y^2, y^3 In this case, you can define your F like so: biRow[n_] := Table[x^(n - k)*y^k, {k, 0, n}]; Clear[F]; m = 0; Do[F[++m] = binom, {binom, Flatten[Table[biRow[n], {n, 0, 3}]]}]; Then, you can define your matrix via: M = Table[F[i]*F[j], {i, 1, m}, {j, 1, m}]; I'm guessing these matrices all have rank 1. Thus, you can find the only non-zero eigenvalue via: Eigenvalues[M] // Last Mark McClure === Subject: Re: Deleting entire row and/or column Really? I wish I could see it. Bobby > Ah, I like the Nest/Transpose solution. > -- DrMajorBob@bigfoot.com === Subject: Re: Deleting entire row and/or column Ah, I like the Nest/Transpose solution. === Subject: Re: passing an array variable as a file name string to FindList Hi Venkatesh, There must be many ways to do this. I'll provide you with three examples, two of them the Fortran way and one the Mathematica way (don't worry, they all work in Mathematica). myFileNames = FileNames[]; (* Classis Fortran style; long; i is an index in the list*) Do[ FindList[myFileNames[[i]], top secret] // Print, {i, 1, Length[myFileNames]} ] (*Fortran style; slightly shorter; i itself gets the successive values of the list*) Do[ FindList[i, top secret] // Print, {i, myFileNames} ] (*Mathematica functional programming style, /@ is shorthand infix notation for Map; # and & are used to make a pure function*) FindList[#, top secret] & /@ myFileNames On Apr 3, 11:05 am, Venkatesh Ramakrishnan 2. I wish to read each one of them and extract some information. Now, Flatten[Table[FileNames[]]] will give me all the file names in a table. So, An array variable with the subscript that contains the loop counter > will > give me the filenames one by one. The question is, how do I pass the array variable as a String argument > to functions like - FindList[] > ReadList[] and other text file manipulation commands? If anybody can shed some light on this, I would be very thankful. Venkatesh === Subject: Re: passing an array variable as a file name string to FindList FileNames[] alone is sufficient instead of Flatten[Table[FileNames[]]] and FindList[#,Humpty Dumpty] & /@ FileNames[] will search for the giant goose egg in you files. > I have this problem for which I have to write a code - > > 1. There is a directory that contains around 30,000 text files. > 2. I wish to read each one of them and extract some information. > > Now, > > Flatten[Table[FileNames[]]] > > will give me all the file names in a table. > > An array variable with the subscript that contains the loop counter > will > give me the filenames one by one. The question is, how do I pass the array variable as a String argument > to functions like - > > FindList[] > ReadList[] > > and other text file manipulation commands? > > If anybody can shed some light on this, I would be very thankful. > > Venkatesh === Subject: Re: release memory The result is also in the Out[..] variable. You can clear that (see tutorial/MemoryManagement). Alternatively, you could prevent that the history is stored by setting $HistoryLength to zero before you start. > I am doing a long memory consuming calculation. At certain point I get va= riable contaning huge amount of numerical data. I process it and don't need= it anymore. Is there a way to delete it and RELEASE the memory it takes, i. e. make i= t available? I tried ClearAll[...], it deletes the variable but the memory doesn't bec= ome available - I watch the Windows Task Manager and it doesn't show increa= se in the available memory. I know quitting the kernel releases all the used memory but it stops the = calculation which I don't want. If I don't release the memory of variables = I no longer need, soon I ran out of memory, that's why I need to know how t= o make the memory available again during calculation. === Subject: Re: release memory $HistoryLength=0 in the begining of the session and then deleting the variable with ClearAll[name] or Remove[name] does NOT show any release of memory in Windows Task Manager. === Subject: Re: cell bracket symbols In the Option Inspector (ctrl-shft-I on PC) in Cell options/Display Options you'll find CellBracketOptionsOn. You can improve visibility there, though in this way it is not possible to make the bracket color depend on the type of bracket. Due to my poor vision, several of the visual clues for cell bracket > types are very hard to see. Anyway for me at the style sheet level or > using the options inspector to set the color of the cell bracket > depending on what kind of bracket it is? Or even using a different > size for the visual clues on the bracket? > === Subject: Re: Problem with Import[] and math.exe > Hi all! I spend several hours with a simple issue I don't understand. I would > like to create a daily task on WinXP; I have already shortened my > complex package to a very simple one, but it still doesn't work: This code works fine in the regular front end: In[1]:= > ps=$PathnameSeparator; > data=Import[FileNameJoin[{C:,ps,Temp,ps,data.TSV}]]; > Length[data] > Export[FileNameJoin[{C:,ps,Temp,ps,output.txt}],data] > Pause[2]; > Quit[]; Out[3]= 1996 > Out[4]= C:Tempoutput.txt It also works fine using math.exe or mathkernel.exe by typing in > everything manually. I have created a package c:temptest.m > containing the code above. I can start math.exe and load the package and output.txt is created. > The same happens with mathkernel.exe: Mathematica 7.0 for Microsoft Windows (32-bit) > Copyright 1988-2009 Wolfram Research, Inc. In[1]:= Get[c:temptest.m] > However, if I try C:Program FilesWolfram ResearchMathematica7.0math.exe -initfile > c:temptest.m > or > C:Program FilesWolfram ResearchMathematica7.0mathkernel.exe - > initfile c:temptest.m (which are my batch commands for the daily task) , I get an error > message: Mathematica 7.0 for Microsoft Windows (32-bit) > Copyright 1988-2009 Wolfram Research, Inc. Import::infer: Cannot infer format of file data.TSV. Output.txt now contains Null. I also tried to give explicit importing > information (Table, TSV, FieldSeparator, encoding information > etc.), but it doesn't work. I don't understand this. Do I need to load other .m-files (e.g. some > init.m) too? > The rest of my complex package (including SQL communication, > statistical calculations, graphics generation) works fine, but I > cannot load a simple tsv-file. My system: > $Version = 7.0 for Microsoft Windows (32-bit) (February 18, 2009) > $OperatingSystem = Windows Are there any good references for notebook automation and evaluation > I encountered a bug with Import (confirmed by someone at WRI) under these conditions using version 6.0. My current method of starting MathKernel is to use a small C program (which has an icon that can sit on the desktop) which starts the kernel via MathLink, and passes it a Get command on a file of Mathematica commands. There are several ways to start Math - such as piping the input, or using one of the other command line options, and I don't remember exactly what worked and what didn't (there seemed to be various gotcha's), but I ended up with the above solution, which works well. David Bailey http://www.dbaileyconsultancy.co.uk === Subject: Re: Minimize goes into infinite loop? How do you know it's infinite? Maybe it's just taking long > Hello group, I wonder why the following problem force Mathematica to run into > infinite loop? Minimize[ > {m1*w1 + m2*w2 > , w1 > 0 && w2 > 0 && w1 + w2 == 1 > && (p1/(1 - m1) + p2/(1 - m2) - 1 - m) == 0 > && m1 >= 0 && m2 > m1 && 1 > m > 0 > && p1 > 0 && p2 > 0 && p1 + p2 == 1 > }, {m1, m2}, Reals > ] -Andrey === Subject: Minimize goes into infinite loop? Hello group, I wonder why the following problem force Mathematica to run into infinite loop? Minimize[ {m1*w1 + m2*w2 , w1 > 0 && w2 > 0 && w1 + w2 == 1 && (p1/(1 - m1) + p2/(1 - m2) - 1 - m) == 0 && m1 >= 0 && m2 > m1 && 1 > m > 0 && p1 > 0 && p2 > 0 && p1 + p2 == 1 }, {m1, m2}, Reals ] -Andrey === Subject: Re: Map to nested list >this expression >IntegerQ/@{1,1/5} >outputs {True, False} >which operator is used for nested list? I think this is what you are looking for In[1]:= Map[IntegerQ, {{1, 1/5}, {1, 1/5}}, {2}] Out[1]= {{True, False}, {True, False}} === Subject: Re: release memory >I am doing a long memory consuming calculation. At certain point I >get variable contaning huge amount of numerical data. I process it >and don't need it anymore. >Is there a way to delete it and RELEASE the memory it takes, i. e. >make it available? >I tried ClearAll[...], it deletes the variable but the memory >doesn't become available - I watch the Windows Task Manager and it >doesn't show increase in the available memory. If you haven't read the following tutorials you should tutorial/BasicInternalArchitecture tutorial/MemoryManagement One of the keys is to realize memory will not be released until there are no references to it in the current session. In particular, if you have not set $HistoryLength = 0 in the session, you likely will have references to things you are not aware of and find it difficult to reclaim all memory. One convenient way to release memory for several variables at a time is create a context before creating those variables. Then the utility CleanSlate can be used to delete the context with all of the variables it contains, releasing the memory associated with them. === Subject: cell bracket symbols Due to my poor vision, several of the visual clues for cell bracket types are very hard to see. Anyway for me at the style sheet level or using the options inspector to set the color of the cell bracket depending on what kind of bracket it is? Or even using a different size for the visual clues on the bracket? === Subject: Re: Dynamic 2D ListLinePlot PlotRange data = Table[{x, Sin[x] + RandomReal[{-0.1, 0.1}]}, {x, 0, 2 Pi, 2 Pi/512}]; Manipulate[ ListLinePlot[data, PlotRange -> {{xmin, xmax}, All}], {{xmin, 0, !(*SubscriptBox[x, min])}, 0, 2 Pi}, {{xmax, 2 Pi, !(*SubscriptBox[x, max])}, 0, 2 Pi}] ? Jens > I'm a bit of a newbie here, trying to build up some data visualization > tools. I've already gotten a ListLinePlot working well with slider to adjust > xmin and xmax. I was hoping that I could set PlotRange to All for the Y axis > and it would adjust for the Y-values in the dynamically specified x range, > but no such luck. Is there some other way to not have to do the y-axis range > calculation myself? I suppose some explanation of the dataset is desired. I have something like: > { > {{x11,y11},{x12,y12},{x13,y13},...,{x1m,y1m}}, > {{x21,y21},{x22,y22},{x23,y23},...,{x2n,y2n}}, > } > , where the x values and lengths are heterogeneous between xy lists 1 and 2 This makes the calculation of ymin and ymax very non-straightforward to me, > and re-calculation unacceptably slow on 20k+ data points per list. The > dynamic x-axis plot scaling actually goes very smoothly, by using a > construct like: Show[ > ListLinePlot[data,PlotRange -> All,], > PlotRange ->Dynamic[{{curxmin, curxmax},All}], > ] I've tried various ways to get at the problem, and the closest I've gotten > is something like: Map[ > {Min[#], Max[#]} &, > Map[ > (Select[ > #, > ( > #[[1]] > tmin > && #[[1]] < tmax > ) & > ]) &, > mydata > ][[All, All, 2]] > ] Which get me basically the result I want, but is really slow to evaluate, > making it undesirable as Dynamic[]. Any ideas? > === Subject: Re: Dynamic 2D ListLinePlot PlotRange I think I've solved my own problem! First, I used a binary search to find the x-axis min and max position in each of my X-Y data sets. I'm using the binary search that was posted by Sseziwa Mukasa in an old thread titled Finding the closest number from a I have to do a fair number of machinations to get from there to the xmin/max-constrained ymin/max list for each datatype for each recorded instrument, but it calculates at a reasonable speed. Another critical point for me was to use nested dynamic modules, because I have multiple graphs (one for each data type) on different tabs, each with different dynamic ybounds indexed by their tab. The nested dynamic module was required to hold onto the iterator for the TabView's table, so that same iterator could be used to grab the correct ymin/max. This construct looked something like: TabView[ Table[ label[[thiscol]] -> DynamicModule[ {mycol = thiscol}, Show[ ListLinePlot[ plotdata[[All, thiscol]], ], PlotRange -> Dynamic[{{curxmin, curxmax}, ybounds[[mycol]]}], ] ], {thiscol, Range[Dimensions[efisdata][[2]]]} ] I plan on posting the entire data graphing solution for everyone to enjoy, when I get it cleaned up and a few more kinks worked out. -- Bryce Schober === Subject: Re: Dynamic 2D ListLinePlot PlotRange You haven't explained tmin or tmax, but ignoring that, here's some sample data and code to compute the minimum and maximum x values: test = RandomInteger[{1, 10000}, {2, 50, 2}]; minMax = Through[{Min, Max}@Flatten[test, 1][[All, 1]]] {52, 9885} If you want the first element to be no less than tmin and the second to be no more than tmax, you can do this: {curmin, curmax} = {tmin, tmax} = Sort@RandomInteger[{1, 10000}, 2] Apply @@@ Transpose@{{Max, Min}, Transpose@{{tmin, tmax}, minMax}} {5877, 7951} {5877, 7951} or the simpler {Max@#[[1]], Min@#[[2]]} &@Transpose@{{tmin, tmax}, minMax} {5877, 7951} Bobby > I'm a bit of a newbie here, trying to build up some data visualization > tools. I've already gotten a ListLinePlot working well with slider to > adjust > xmin and xmax. I was hoping that I could set PlotRange to All for the Y > axis > and it would adjust for the Y-values in the dynamically specified x > range, > but no such luck. Is there some other way to not have to do the y-axis > range > calculation myself? I suppose some explanation of the dataset is desired. I have something > like: > { > {{x11,y11},{x12,y12},{x13,y13},...,{x1m,y1m}}, > {{x21,y21},{x22,y22},{x23,y23},...,{x2n,y2n}}, > } > , where the x values and lengths are heterogeneous between xy lists 1 > and 2 This makes the calculation of ymin and ymax very non-straightforward to > me, > and re-calculation unacceptably slow on 20k+ data points per list. The > dynamic x-axis plot scaling actually goes very smoothly, by using a > construct like: Show[ > ListLinePlot[data,PlotRange -> All,], > PlotRange ->Dynamic[{{curxmin, curxmax},All}], > ] I've tried various ways to get at the problem, and the closest I've > gotten > is something like: Map[ > {Min[#], Max[#]} &, > Map[ > (Select[ > #, > ( > #[[1]] > tmin > && #[[1]] < tmax > ) & > ]) &, > mydata > ][[All, All, 2]] > ] Which get me basically the result I want, but is really slow to evaluate, > making it undesirable as Dynamic[]. Any ideas? > -- DrMajorBob@bigfoot.com === Subject: Re: Map to nested list Specify the second level Map[IntegerQ, {{1, 1/5}, {1, 1/5}}, {2}] Adriano Pascoletti 2009/4/3 athanase thankyou :) === Subject: Re: Map to nested list In[1] = Map[IntegerQ, {{1, 1/5}, {1, 1/5}}, {-1}] Out[1] = {{True, False}, {True, False}} Will work for any depth as long as leaves are numbers. Leonid > this expression IntegerQ/@{1,1/5} outputs {True, False} which operator is used for nested list? so IntegerQ ? {{1,1/5},{1,1/5}} outputs {{True, False},{True, False}} > thankyou :) === Subject: Re: Map to nested list >-----Original Message----- === >Subject: Map to nested list this expression IntegerQ/@{1,1/5} outputs {True, False} which operator is used for nested list? so IntegerQ ? {{1,1/5},{1,1/5}} outputs {{True, False},{True, False}} >thankyou :) Well usually it's Map, it depends a bit on your nesting, e.g.: In[3]:= Map[IntegerQ, {{1, 1/5}, {1, 1/5}}, {2}] Out[3]= {{True, False}, {True, False}} If nesting is different, map differently, e.g.: In[16]:= Map[IntegerQ, {1, {2., {3, {4., 5}}}}, {-1}] Out[16]= {True, {False, {True, {False, True}}}} This might wreak havoc however, with In[14]:= Map[IntegerQ, {{1, 1/5}, {{1, 1/5}, 1/f[5]}}, {-1}] Out[14]= {{True, False}, {{True, False}, Power[f[True],True]}} If you only want to map within Lists descending, you might try In[19]:= th[IntegerQ,{{1, 1/5},{{1,1/5},1/f[5]}}] Out[19]= {{True,False},{{True,False},False}} In[17]:= th[IntegerQ, {1, {2., {3, {4., 5}}}}] Out[17]= {True, {False, {True, {False, True}}}} Where th maps recursively at List: In[11]:= th[f_, a_] /; Head[a] == List := th[f, #] & /@ a In[12]:= th[f_, a_] := f[a] -- Hartmut === Subject: Re: Map to nested list > this expression IntegerQ/@{1,1/5} outputs {True, False} which operator is used for nested list? so IntegerQ ? {{1,1/5},{1,1/5}} outputs {{True, False},{True, False}} > Map[IntegerQ,{{1,1/5},{1,1/5}},{ArrayDepth[{{1,1/5},{1,1/5}}]}] === Subject: Re: Map to nested list Map[IntegerQ, {{1, 1/5}, {1, 1/5}}, {2}] {{True, False}, {True, False}} IntegerQ /@ # & /@ {{1, 1/5}, {1, 1/5}} {{True, False}, {True, False}} Bob Hanlon this expression IntegerQ/@{1,1/5} outputs {True, False} which operator is used for nested list? so IntegerQ ? {{1,1/5},{1,1/5}} outputs {{True, False},{True, False}} thankyou :) === Subject: Re: Joust in Mathematica It was sort of difficult to see what Joust is from looking at its website and documentation. There wasn't a quick explaination of what it does. My sense is that it was a navigation tool of some sort. Creating things of that general sort in Mathematica should be quite doable. The front end is very plastic in terms of what you cn create in it (though it certainly does have limitations...). But the key issue is that anything of this sort takes considerable time to create. So one (one who does not have lots of free time) needs a business model that supports its creation. Sadly, in my experience with http://scientificarts.com/worklife there is very little interest in general tools. And so, thes things only can get created in one's spare time. Any thoughts on how viable businesses can get created based on Mathematica? My experience over the years is that it's quite difficult to do... I've been wondering how to set up something that behaves like the Java = Joust > in Mathematica: http://www.ivanpeters.com/ we all use them every d= ay > on on > windows machines, so I am wondering how to implement something like it = in > Mathematica. At first, I thought of using GraphPlot or TreePlot, but > then started to wonder if OpenerView and Opener could be trained to beh= ave in > a more > general way. Has anyone thought about this already, or got some working examples? I think OpenerView isn't providing the looks, but the functionality, > depending of course what exactly you have in mind. What exactly are you > missing? Here is some code for Mathematica 7 you might want to play with: tree = A[B[x, y, z], C[f[g[asdf]]]] ov[a_String] := Button[a, content = a] ov[expr_] := OpenerView[{Head[expr], Column[ov /@ (List @@ expr)]}] CreateDialog[{Dynamic[ > Row[{Panel[ > Pane[ov[tree], ImageSize -> {100, 200}, > Scrollbars -> {False, True}]], > Panel[Pane[Dynamic[content], ImageSize -> {200, 200}]]}]]}] hth, albert === Subject: Re: Joust in Mathematica I too was wanting some kind of outliner mode in the notebooks. I sometimes find the forced way via stylesheets/cells to be restrictive. Btw, there is no way to drag/drop cells around in a notebook. I was told I would have to cut/copy then paste. Thats so 80s! LOL === Subject: Re: Joust in Mathematica Very nice, Albert! Maybe a horizontal scrollbar, and then what are the chances of adding an invisible locator or EventHandler to alter the width of the left hand panel? David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ > I've been wondering how to set up something that behaves like the Java Joust > in Mathematica: http://www.ivanpeters.com/ we all use them every day on on > windows machines, so I am wondering how to implement something like it in > Mathematica. At first, I thought of using GraphPlot or TreePlot, but > then started to wonder if OpenerView and Opener could be trained to behave in a more > general way. Has anyone thought about this already, or got some working examples? I think OpenerView isn't providing the looks, but the functionality, depending of course what exactly you have in mind. What exactly are you missing? Here is some code for Mathematica 7 you might want to play with: tree = A[B[x, y, z], C[f[g[asdf]]]] ov[a_String] := Button[a, content = a] ov[expr_] := OpenerView[{Head[expr], Column[ov /@ (List @@ expr)]}] CreateDialog[{Dynamic[ Row[{Panel[ Pane[ov[tree], ImageSize -> {100, 200}, Scrollbars -> {False, True}]], Panel[Pane[Dynamic[content], ImageSize -> {200, 200}]]}]]}] hth, albert === Subject: Re: Styling the selected Tab's label in TabView The only reason for the Graphics[] in the example you started with is= because that example requires the use of Disk[]/Circle[] to produce the intended= effect. You don't need a Graphics[] wrapper in your case, and removing it makes your= code more comprehensible and as well as making it work as I believe you intended. DynamicModule[{selected}, TabView[Table[ With[{i = i}, Style[labels[[i]], FontWeight -> labels[[i]] <> !)], {i, Length[labels]}], Dynamic[selected]]] John Fultz jfultz@wolfram.com User Interface Group Wolfram Research, Inc. > It seems that you can't set the LabelStyle of individual tabs in a > TabView. Starting with the example in my TabView->Examples->Scope->Control > documentation, I got to: labels = {Bill, Susan}; > DynamicModule[ > {selected}, > TabView[ > Table[ > With[ > {i = i}, > Graphics[ > Style[ > Text[labels[[i]]], > FontWeight -> Dynamic[ > Bold, > Plain > ] > ] > ], > ImageSize -> All, > PlotRangePadding -> .5 > ] -> (Hello <> labels[[i]] <> !) > ], > {i, Length[labels]} > ], > Dynamic[selected] > ] > ] This manages to bold the selected tab, but ImageSize -> All isn't= limiting > itself to the size of the Text[], and I'm not sure how to limit the > resulting tab size to only that required for the text display... === Subject: Re: Can't figure out how to export Mathematica into Word Actually, MathType 6.5 works quite well for exporting Mathematica equations and using them in Word. Others have suggested MathML, and this is the key to using a Mathematica equation in MathType. We have more detailed instructions on our website: http://dessci.com/en/support/mathtype/workswith/mathematica.htm Bob Mathews Director of Training Design Science, Inc. www.dessci.com ~ Makers of MathType, MathFlow, MathPlayer, MathDaisy, Equation Editor ~ > I help out my lab partners in one of my classes by exporting out the data= and equations we worked on from mathematica. They use microsoft word so I = need to copy or export things into rtf first or copy things directly into m= icrosoft word. The problem is that many symbols come out strangely when I t= ry to export or even copy them the tables and math notation comes out like = --- > =C2 =C2 {[Null], !(*SubscriptBox[(F), (1)]), !(*Subsc= riptBox[(d), (1)]), !(*SubscriptBox[(=EF=81=B4), (1)]), != (*SubscriptBox[(F), (2)]), It seems like there is something not set up the way I want to in the expo= rt or copy functions... Also, when exporting to rtf, the tables come out as= a list of data instead of being in the correct form. Another system used t= o export this stuff out to rtf correctly by default... How do I set up math= ematica to do the same? === Subject: Re: Can't figure out how to export Mathematica into Word Since no fewer than three people pointed this out, I just wanted to make sure that people know that, as of 7.0.1, regular copy/paste uses MathML automatically when appropriate (i.e. when copying either a single typesetting cell, in part or in whole, that contains math or code, but no graphics). So, it will generally be the case that using Copy As is not required. John Fultz jfultz@wolfram.com User Interface Group Wolfram Research, Inc. > If you have Word 2007 you can copy the equation as MathML and paste it > straight in Word. It is editable in Word's equation editor. Otherwise, try a copy as picture. > I help out my lab partners in one of my classes by exporting out the >> data= > and equations we worked on from mathematica. They use microsoft word so I > = > need to copy or export things into rtf first or copy things directly into > m= > icrosoft word. The problem is that many symbols come out strangely when I > t= > ry to export or even copy them the tables and math notation comes out > like = > --- >> =C2 =C2 {[Null], !(*SubscriptBox[(F), (1)]), !(*Subsc= > riptBox[(d), (1)]), !(*SubscriptBox[(=EF=81=B4), (1)]), > != > (*SubscriptBox[(F), (2)]), > It seems like there is something not set up the way I want to in the >> expo= > rt or copy functions... Also, when exporting to rtf, the tables come out > as= > a list of data instead of being in the correct form. Another system used > t= > o export this stuff out to rtf correctly by default... How do I set up > math= > ematica to do the same? === Subject: StringJoin with ToString It is quite interesting why StringJoin does not apply ToString to those arguments which are non-string. I've overridden the built-in StringJoin, to save a few unnecessary ToStrings by the standard method (the context specifications are necessary for packaging): Unprotect[System`StringJoin]; $UseNewStringJoin = True; System`StringJoin[expr___] := Block[{$UseNewStringJoin = False}, StringJoin@(ToString /@ {expr})] /; TrueQ[$UseNewStringJoin]; Protect[$UseNewStringJoin]; Protect[System`StringJoin]; This seems to work (after loading the package) for any cases, e.g.: In[2]:= StringJoin[1, 2, 3] Out[2]= 123 In[3]:= 4 <> 5 <> 6 Out[3]= 456 but has a strange effect on messages: In[5]:= Append[dummy, 2] During evaluation of In[5]:= Append::normal: {Nonatomic expression expected at position , {1}, in , {Append[dummy,2]}, .} >> Out[5]= Append[dummy, 2] that is: the message strings are displayed in a non-joined list format. The code below shows an other modified StringJoin, that gives the exact same results (after initiating a fresh kernel): Unprotect[System`StringJoin]; System`StringJoin[expr___]:=Module[{str=}, Scan[(Print[#]; str=StringInsert[str,ToString[#],-1])&,{expr}]; str ]; Protect[System`StringJoin]; Now I've inserted a Print[#]; inside the function to see what's happening. This reveals some internal calculation that is done during the evaluation of the erroneous call of Append[dummy, 2], which I don't really understand (did not copy here for size constraints). Apart from this strange sideeffect on messages (which seems to be harmless), both functions work as expected. Does anyone have any idea what is the exact cause of this behaviour and how to overcome it? Istvan Zachar === Subject: Re: Map to nested list Map[IntegerQ,{{1,1/5},{1,1/5}},{2}] ? Jens > this expression IntegerQ/@{1,1/5} outputs {True, False} which operator is used for nested list? so IntegerQ ? {{1,1/5},{1,1/5}} outputs {{True, False},{True, False}} > thankyou :) > === Subject: Re: Map to nested list Map[IntegerQ, {{1, 1/5}, {1, 1/5}}, {2}] > this expression IntegerQ/@{1,1/5} outputs {True, False} which operator is used for nested list? so IntegerQ ? {{1,1/5},{1,1/5}} outputs {{True, False},{True, False}} thankyou :) === Subject: Re: Map to nested list Athanase, Map takes a third levelspec argument: Map[IntegerQ, {{1, 1/5}, {1, 1/5}}, {2}] {{True, False}, {True, False}} Yves > this expression IntegerQ/@{1,1/5} outputs {True, False} which operator is used for nested list? so IntegerQ ? {{1,1/5},{1,1/5}} outputs {{True, False},{True, False}} > thankyou :) > === Subject: Re: Map to nested list in = {{1, 1/5}, {1, 1/5}}; Unprotect[IntegerQ]; SetAttributes[IntegerQ, Listable]; IntegerQ[#] & /@ in -Francesco > this expression IntegerQ/@{1,1/5} outputs {True, False} which operator is used for nested list? so IntegerQ ? {{1,1/5},{1,1/5}} outputs {{True, False},{True, False}} === Subject: Map to nested list this expression IntegerQ/@{1,1/5} outputs {True, False} which operator is used for nested list? so IntegerQ ? {{1,1/5},{1,1/5}} outputs {{True, False},{True, False}} thankyou :)