A130 === Subject: Re: integrate problem consider: Integrate[1/(s[t] + a), t] here the integration variable is t and s[t] is a unknown function. Therefore the argument, that contains an unknown function s[t], can not be integrated. In Integrate[1/(s[t] + a), s[t]] the integration variable simply has a funny name of s[t] Daniel > I'm having some issues understanding this... Following works as > expected. s is the variable in time. a is a parameter. Integrate[1/(s + a), s] gives Log[a + s] But the following gives the integral itself. Integrate[1/(s[t] + a), t] If the function that needs to be integrated w.r.t time is 1/(s[t] + > a), how do I accomplish that? It seems like if integrate it wrt to s > [t] it will work. Integrate[1/(s[t] + a), s[t]] > But does that sound about right? Any thoughts appreciated. Sean > === Subject: Re: integrate problem Sean, What you are really asking is: how can I integrate an unknown function of t? The short answer is: you can't. If you are going to integrate something, the least prerequisite is that you know what this something is. Just try s[t] = t and s[t]=Sin[t] to see what an enormous difference this makes for the answer. It is clear that a general answer in terms of s[t] would not be very possible or useful. > I'm having some issues understanding this... Following works as > expected. s is the variable in time. a is a parameter. Integrate[1/(s + a), s] gives Log[a + s] But the following gives the integral itself. Integrate[1/(s[t] + a), t] If the function that needs to be integrated w.r.t time is 1/(s[t] + > a), how do I accomplish that? It seems like if integrate it wrt to s > [t] it will work. Integrate[1/(s[t] + a), s[t]] But does that sound about right? Any thoughts appreciated. Sean === Subject: Re: integrate problem > I'm having some issues understanding this... Following works as > expected. s is the variable in time. a is a parameter. Integrate[1/(s + a), s] gives Log[a + s] But the following gives the integral itself. Integrate[1/(s[t] + a), t] If the function that needs to be integrated w.r.t time is 1/(s[t] + > a), how do I accomplish that? It seems like if integrate it wrt to s > [t] it will work. Integrate[1/(s[t] + a), s[t]] But does that sound about right? Any thoughts appreciated. In your examples, is a constant, but s[t] is a function of t. You haven't specified what that function is, so Mathematica can't simplify it beyond recognizing that you're asking for a symbolic integral. Specify what s[t] is either inline in the Integrate function or separately with a definition before trying to integrate 1/(s[t] + a). -- Erik Max Francis && max@alcyone.com && http://www.alcyone.com/max/ San Jose, CA, USA && 37 18 N 121 57 W && AIM, Y!M, Skype erikmaxfrancis Whom God has put asunder, why should man put together? -- Ralph Waldo Emerson === Subject: recognition typesetted mathematical text? Did anyone try to convert bitmap format mathematical formulas to typesetted mathematical text? There is a possiblitiy for Window 7 users to convert hand written text, but alas, I have a Mac. P_ter === Subject: Re: Imaginary numbers - most interesting points I have (perhaps unwisely!) decided to do a 'Pecha Kucha' on > imagination .... or at least imaginary numbers. The audience are all > engineers with hazy recollection of undergrad maths. If you are not familiar with Pecha Kucha, then its worth checking > Youtube and doing some googling. Simplistically the concept is to > share understanding of something using 20 slides. Each slide should > convey as much as possible with as few words as possible, with the > message limited to 20 seconds! So, what is the most interesting thing about the imaginary number > 'i' that you can think of, and how can it most simply be conveyed > using Mathematica 7 in Slide presentation form? I've started with the notion of polynomial roots, de Moivre, > reflections etc. but would appreciate a wider view. R Well, if You have time for it, read Roger Penrose Road to Reality. He is using complex number magic all the time :) With the best, J=E1nos= === Subject: Mathematica for gifted elementary school children My son, almost 6, is good at math and inquisitive. Is there a math curriculum for elementary school children that uses Mathematica? He understands the four arithemetic operations and the concept of powers. I have Mathematica installed on my home PC and could teach him myself. I have written computer programs in Fortran in front of him to demonstrate concepts such as cubes and cube roots. We had fun, but I don't want to explain right now why 1000000000**3 gives -402653184 or 1/2 gives 0. He is interested in the number centillion (10^303) and thought it was cool to see the 101 zeros when we asked Mathematica to compute centillion^(1/3). I see there are some math courseware at http://library.wolfram.com/infocenter/Courseware/Mathematics/ , but those topics are too advanced for him at present. Maybe I should give him Wolfram's huge book and let him play when he wants. === Subject: Re: Mathematica for gifted elementary school children > My son, almost 6, is good at math and inquisitive. Is there a math > curriculum for elementary school children that uses Mathematica? He > understands the four arithemetic operations and the concept of powers. > I have Mathematica installed on my home PC and could teach him myself. I have written computer programs in Fortran in front of him to > demonstrate concepts such as cubes and cube roots. We had fun, but I > don't want to explain right now why 1000000000**3 gives -402653184 or > 1/2 gives 0. He is interested in the number centillion (10^303) and thought it > was cool to see the 101 zeros when we asked Mathematica to compute > centillion^(1/3). I see there are some math courseware athttp://library.wolfram.com/infocenter/Courseware/Mathematics/ > , but those topics are too advanced for him at present. Maybe I should > give him Wolfram's huge book and let him play when he wants. Try looking thru the demonstrations web site (at http://demonstrations.wolfram.com ). There are some really nice things and some are very well illustrated and fun to play with. There is even a Kids and Fun section at http://demonstrations.wolfram.com/topics.html#10 Enjoy... -Bob === Subject: multiple plots I have plotted graph in mathematica for various voltages ListPlot[{r1, r2, r3, r4, r5}, AxesOrigin -> {28, 1.5 10^12}, PlotStyle -> {Dashed, Thick}, AxesLabel -> {Temp!(*SuperscriptBox[ , o])C, !(*SubscriptBox[[Sigma], [UpTee]])}, PlotMarkers -> {[FilledCircle], [FilledCircle], [FilledCircle], [FilledCircle], [FilledCircle], Medium}, PlotLabel -> Style[!(*SubscriptBox[[Sigma], [UpTee]]) Vs Temp!( *SuperscriptBox[ , o])C, Blue, 20], LabelStyle -> {Bold, Red, 18}] I need to label r1 r2 r3 r4 & r5 separately in the same plot. please somebody help me === Subject: Re: multiple plots in version 7, you may either label the plot by hand using the DrawongTool (right click the plot) or you may use a plot legend like e.g.: d = RandomReal[{-1, 1}, {3, 10}]; Needs[PlotLegends`] ListLinePlot[d, PlotLegend -> {One, Two, Three}, PlotMarkers -> Automatic, LegendPosition -> {1.1, -0.4}] Daniel > I have plotted graph in mathematica for various voltages ListPlot[{r1, r2, r3, r4, r5}, AxesOrigin -> {28, 1.5 10^12}, > PlotStyle -> {Dashed, Thick}, > AxesLabel -> {Temp!(*SuperscriptBox[ , o])C, > !(*SubscriptBox[[Sigma], [UpTee]])}, > PlotMarkers -> {[FilledCircle], [FilledCircle], > [FilledCircle], [FilledCircle], [FilledCircle], Medium}, > PlotLabel - Style[!(*SubscriptBox[[Sigma], [UpTee]]) Vs Temp!( > *SuperscriptBox[ , o])C, Blue, 20], > LabelStyle -> {Bold, Red, 18}] I need to label r1 r2 r3 r4 & r5 separately in the same plot. please > somebody help me > === Subject: Creating a sign chart Is it possible to render a sign chart in Mathematica 10? Typically a sign chart is used with the first and second derivatives to identify extrema. I know there are other ways to convey this information. However, in my case I need to demonstrate a sign chart by means of an illustation. I can create a graphic in Visio and import into Mathematica but I would prefer if there were a means of generating such a chart directly in Mathematica. Something like: +++++++++++++++------------ Dave x2373 === Subject: Re: Creating a sign chart > Is it possible to render a sign chart in Mathematica 10? Typically a sign chart is used with the first and second derivatives > to identify extrema. I know there are other ways to convey this > information. However, in my case I need to demonstrate a sign chart by > means of an illustation. I can create a graphic in Visio and import into > Mathematica but I would prefer if there were a means of generating such > a chart directly in Mathematica. Something like: +++++++++++++++------------ Something like this? f[x_] = 10 + 108 x - 27 x^2 + 2 x^3 first[x_] := If[f'[x] == 0, x, If[Sign[f'[x]] > 0, +, -]]; second[x_] := If[f''[x] == 0, x, If[Sign[f''[x]] > 0, +, -]]; Labeled[Row[Table[first[x], {x, 0, 10, 1/2}]], First derivative] Labeled[Row[Table[second[x], {x, 0, 10, 1/2}]], Second derivative] -- Helen Read University of Vermont === Subject: Getting the height and width of controls? I trying to find a way to get the height/width of a control item or the whole control itself. I know I can set stuff, but looking for some function that would return me the pixel measurements passing it a control expression. I am wanting to adjust me code based on these measurements. I tried looking in the docs but found nothing that would andrew === Subject: Re: Getting the height and width of controls? ok, so far this is what I stumbled upon, but it dones't work right: t = Button[Click Here, Print[10!]] AbsoluteCurrentValue[bt, ImageSize] That code always gives {350,350}. Lots of other options work, but not getting the height/width of a control. I can't use CurrentValue for that works only when I actually click the button, but it too gives only the same answer. I didnt think getting the simple height/width of a control to be that Andrew === Subject: Compositing, 3D graphics, and KDE 4.2 There used to be a big problem working with Mathematica on systems (at least those using XOrg) which had compositing turned on (fonts being faded, 3D plots not showing up, etc.). That all seemed to have been solved until recently. I have version 7.0.0 running on a 32-bit linux system, in KDE 4.2 (radeonhd driver). Now, most of the stuff is esoteric, and I'm quite happy to have gotten everything running fast and stably and prettily, including Mathematica looking great. However, I've just noticed today that if I produce any 3D graphics (using Plot3D, or Graphics3D[Cylinder[{{0, 0, 0}, {0, 1, 0}}]], for example) that the 3D object shows up only if I'm actively rotating it or resizing it with the mouse. Otherwise, it disappears and looks like just a big blank space on the screen. I might try updating to 7.0.2 just in case that fixes things. I can happily provide more details if anyone thinks they can help (though I'd have to be told which details might be important). Curtis O. -- Curtis Osterhoudt cfo@remove_this.lanl.and_this.gov PGP Key ID: 0x4DCA2A10 === Subject: Help with a possible bug At work we seem to have stumbled on a strange bug between Table and Part. We can reproduce the bug on differently configured Mac and Linux boxes. I tried Wolfram support, but they claim they cannot reproduce the bug. So I was hoping someone could try it out and For us, the bug is new in 7.0.1. It does not show up in version 6. To reproduce it, fill up a 17 x 267 matrix with 3s. Compute the sum of some of the columns and you get the result 51 (17 x 3). But if one computes the sum for the last few columns, the result is completely off. The bug seems to arise from the interaction of optimizations in Table and the use of All inside of Part. ------------ code mat = Table[3, {i, 1, 17}, {j, 1, 267}]; sum = Table[Total[mat[[All, j]]], {j, 1, 249}] sum1 = Table[Total[mat[[All, j]]], {j, 1, 252}]; sum2 = Table[Total[mat[[All, j]]], {j, 1, 252}] ------------ end code If you look at sum1, it will be correct on a fresh copy of the Kernel. The problem only arise from the second time on. Papin Email: ImportString[cGFwaW5AY294Lm5ldA==, Base64] === Subject: Re: Help with a possible bug > At work we seem to have stumbled on a strange bug between Table and > Part. We can reproduce the bug on differently configured Mac and > Linux boxes. I tried Wolfram support, but they claim they cannot > reproduce the bug. So I was hoping someone could try it out and For us, the bug is new in 7.0.1. It does not show up in version 6. > To reproduce it, fill up a 17 x 267 matrix with 3s. Compute the sum > of some of the columns and you get the result 51 (17 x 3). But if one > computes the sum for the last few columns, the result is completely > off. The bug seems to arise from the interaction of optimizations i= n > Table and the use of All inside of Part. ------------ code mat = Table[3, {i, 1, 17}, {j, 1, 267}]; sum = Table[Total[mat[[All, j]]], {j, 1, 249}] sum1 = Table[Total[mat[[All, j]]], {j, 1, 252}]; > sum2 = Table[Total[mat[[All, j]]], {j, 1, 252}] ------------ end code If you look at sum1, it will be correct on a fresh copy of the > Kernel. The problem only arise from the second time on. > Papin Email: ImportString[cGFwaW5AY294Lm5ldA==, Base64] How bizarre!! On my Mac with version 7.0.1 every sum for the last 18 columns is bogus, and it appears that the bogus values keep changing in some sort of random way. For example if you tried mat = Table[3, {i, 1, 17}, {j, 1, 267}]; Manipulate[ sum = Table[Total[mat[[All, jj]]], {jj, 1, mm}], {mm, 1, 267, 1}] everything is OK up thru 249th column (and even thru the 267th the first time on a fresh kernel just like you described), then as soon as you select any other of the 250th thru 267th columns - they total goes squirrely from then on for all subsequent TOTAL's that are calculated, and changes every time you look at any of the last 18 (even looking at the same column total the numbers are different, ie look at column 267, then 266, then 267 again and the numbers are different from the first time you looked), so there is apparently some sort of random gibberish it is picking up when the totals are calculated. Try sending Wolfram the Manipulate command and it's trivial to reproduce on a Mac -- make sure you stay on the phone with them while they try it on a Mac. To make it even more obvious, change the starting index on the Manipulate to 248 and start playing the manipulate and watch it go bonkers. The numbers seem to always be 9 digits and are between the upper 200 millions and the middle to upper 300 millions in magnitude, but didn't seem to get much different even after letting the Manipulate play for quite a while at the highest speed. Let us know what they say. -Bob === Subject: Re: integrate problem > I'm having some issues understanding this... Following works as > expected. s is the variable in time. a is a parameter. Integrate[1/(s + a), s] gives Log[a + s] But the following gives the integral itself. Integrate[1/(s[t] + a), t] If the function that needs to be integrated w.r.t time is 1/(s[t] + > a), how do I accomplish that? You can't accomplish that unless you give Mathematica an explicit expression for s[t] (and you will have to be lucky then too). How could you possible expect this to work in general? If this did, you could integrate practically any function f[t] by using a suitable s[t]. This has nothing to do with Mathematica, its just basic mathematics. > It seems like if integrate it wrt to s > [t] it will work. Integrate[1/(s[t] + a), s[t]] > But does that sound about right? Right? In what sense right? It's a completely different thing from your first case. Here you might as well write t (or s) instead of s[t] as it has nothing whatever to do with s[t]. Note that this also gives an answer: Integrate[s'[t]/(a + s[t]), t] Log[a+s[t] ] but this also has nothing to do with your original integral... Andrzej Kozlowski === Subject: Re: integrate problem > But the following gives the integral itself. Integrate[1/(s[t] + a), t] As it should. This isn't a problem with Mathematica---it's a problem with your understanding of integration. > If the function that needs to be integrated w.r.t time is 1/(s[t] + > a), how do I accomplish that? You don't. At least, you don't without knowing the function s[t]. For example, if s[t] = t, the integral is Log[t + a], while if s[t] = t^2, the integral is Arctan[t/Sqrt[a]]/Sqrt[a]. --Louis A. Talman Department of Mathematical & Computer Sciences Metropolitan State College of Denver === Subject: Re: integrate problem >I'm having some issues understanding this... Following works as >expected. >s is the variable in time. a is a parameter. >Integrate[1/(s + a), s] >gives Log[a + s] >But the following gives the integral itself. >Integrate[1/(s[t] + a), t] If I asked you to integrate an arbitrary function of time and *did not* specify any details of the function could you do it? Note, this is exactly what you are asking Mathematica to do. >If the function that needs to be integrated w.r.t time is 1/(s[t] + >a), how do I accomplish that? define s[t] before asking Mathematica to do the integration >It seems like if integrate it wrt to s [t] it will work. >Integrate[1/(s[t] + a), s[t]] This is no different than Integrate[1/(s + a), s] If you want a solution in terms of t, you first have to define s[t]. There is no other way. === Subject: Re: Looking for more Mathematica online user groups/forums One point of clarification to the points you raise in your last paragraph. Almost every post from a WRI staffer on this forum *is* voluntary, excepting product announcements and job ads, of course. Not even Dan Lichtblau and I, the most prolific WRI posters here, have anything to do with MathGroup as part of our official job description, and certainly not the many other staffers who have posted less often. Aside from promoting the forum and supporting its moderation, the company expends little official effort, so I don't think you have much to worry about there. And the company benefits significantly because it allows us collectively (including a great many staff members who lurk on this forum) to keep a metaphorical finger on the pulse of the Mathematica user community. But as for the postings from WRI staffers, Wolfram's biggest contribution is to leave us unfettered to do so. John Fultz jfultz@wolfram.com User Interface Group Wolfram Research, Inc. > I asked the same question at a summer school last year. In the past Sarah > Flannery?? worked on an online collaboration tool but I gather there were > security problems and risks from malware being sneaked onto our systems > via Mathematica commands. As far as I can see, MathGroup is the best forum but the information > exchange mechanism is a little outdated. Luuk B. tried to get a Wiki > going but I couldn't see a clear reason for using it and not MG. I occasionally wonder if there will be a point when Steve gets tired of > supporting the group and what would happen at that point - I suspect > there is a significant amount of effort on his part. It seems odd that > WRI don't host something with voluntary support from staff. It could be > something as simple as standard Forum - that would give us all the chance > to have Profiles, share files etc. It would also make it easier for Steve > and others to moderate. Robert > ----- Original Message ---- === > Subject: Looking for more Mathematica online user > groups/forums WRI, Since Home edition offers me only 30 days tech support and I am not a > student around other Mathematica using students on a campus. And > buying expensive books does only cover so much (And many are outdated > or does not cover areas outside of math like the Frontend), where on > the internet do I find help thats more real time? This group has been > very helpful, but I want more rapid turn around time, and someone to > teach why some code is good and mine is bad so I learn from mistakes . I do find it strange there is not a more active WRI collection of > people part of a tech support forum somewhere. A whiteboard version of > the FE to aid in support could be a good direction. Collaborative > editing FE in real time somehow? How about a Home Ed users forum on > WRI site?? Or perhaps allow Home Edition users email support; if it is so, be > clear it is so and how long the turn around time for a reply. Or > encourage local universities to create local Mathematica support > groups. Mathematics is a social activity as much as any other creative one; > helping each other is a great way to enjoy learning. Andrew, seeking some shoulders to stand on ;-) === Subject: Re: Looking for more Mathematica online user groups/forums > One point of clarification to the points you raise in your last paragraph= . > Almost every post from a WRI staffer on this forum *is* voluntary, except= ing > product announcements and job ads, of course. Not even Dan Lichtblau a= nd I, > the most prolific WRI posters here, have anything to do with MathGroup > as part of our official job description, and certainly not the many other > staffers who have posted less often. Aside from promoting the forum and supporting its moderation, the company > expends little official effort, so I don't think you have much to worry > about there. And the company benefits significantly because it allows > us collectively (including a great many staff members who lurk on this > forum) to keep a metaphorical finger on the pulse of the Mathematica > user community. But as for the postings from WRI staffers, Wolfram's biggest contribution > is to leave us unfettered to do so. > John Fultz > jfu...@wolfram.com > User Interface Group > Wolfram Research, Inc. > I personally hope and pray that Wolfram keeps it that way. I think a forum that is controlled by the company would be much less useful and beneficial to Mathematica users. And I am very thankful to those at Wolfram who help and reply to all the questions and issues posed on this group and for hosting the MathGroup Archive, especially since they do it on their own time. And I am most especially thankful to all the countless Mathematica users, experts and novices and everyone in between who keeps this list alive and going strong. And the biggest thank you of all to Steven Christensen who keeps all sure that the content keeps flowing and organized and everything else that he does behind the scenes. I am so happy not to have to wade through the countless ads for all the drivel and porn and scams and everything else that gets so old on many other newsgroups. For those people who don't know about him, he has been doing this since 1988 (but the oldest post in the MathGroup Archive I could find is Feb 14, 1989)!!! We all owe a giant debt of gratitude to him and anyone who helps him - this group might not exist and be as useful as it is without his help for all these years (the first reply on the MathGroup Archive was from him, so that is it's own badge of honor, or is that better described as scars of battle ;-) THANK YOU STEVE!! -Bob === Subject: Alignment of Graphics Within Expressions Here are two BarCharts within a CirclePlus (but it might be any kind of expression). g1 = BarChart[{1, 2, 3}, Axes -> {True, False}, BaselinePosition -> Axis, Ticks -> None, ImageSize -> 40]; g2 = BarChart[{-1, 2, -3}, BaselinePosition -> Axis, Axes -> {True, False}, Ticks -> None, ImageSize -> 40]; CirclePlus[g1, g2] The x axis of the bar charts are aligned with the baseline (approximately the bottom) of the CirclePlus symbol. Would it be possible to align the axes with the center line of the CirclePlus symbol without going into any Row constructions or modifying the CirclePlus expression? David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ === Subject: Mathematica in conjunction with outside program; NMinimize fails. Symbolic v. numeric evaluation problem? Hello mathgroup. I am using Mathematica in conjunction with an outside program (Netlogo is the program.) In a nutshell, my error is the following: I can call the outside program with a numeric value successfully, and Plot can call the outside program as one would expect. However, NMinimize calls the outside program with the variable name, not a value, so it fails. In short, I need to force NMinimize to pass a numeric value to the objective function, not a variable name. More details: I have the following functions defined in Mathematica: SingleModelRun[ parametervalue_ ] := ....(definition irrelevant) This function (successfully) runs the outside program, setting a parameter equal to parametervalue (which is some number when I call the function). It returns a value from the model. Plot[ SingleModelRun[ x ], {x , 0, 1} ] Does what you expect: runs SingleModelRun for parameter values 0 through 1, and plots the resulting return value each time. NMinimize[ - SingleModelRun[ myvalue ], {myvalue} ] Does not work. Returns the following error: NetLogo`Private`NetLogo::compilerException : Nothing named MYVALUE has been defined (Note: NetLogo is the name of the outside program.) Which means that, oddly, NMinimize passes the *variable name* (myvalue) instead of the *variable value* to the function SingleModelRun; otherwise, there is no way the outside program would be aware of the variable name. Is there a way to force Mathematica to evaluate the function with a numeric value, not the variable name? (I thought that's what N in NMinimize meant, but apparently not.) In case you were wondering, this fails in an identical way with: NMaximize, FindMaximum, FindMimimum, etc. Andreas Duus Pape === Subject: Re: Passing arrays to MathLink without extra memory allocation To further clarify Jens' points...it's a fundamental principle of modern operating system design that separate processes are absolutely protected from each other. If one process is allowed to access another process's memory, then you've set up the preconditions which allow a rogue process to destabilize the OS, or to create considerable security violations. The reason why modern operating systems like Linux, MacOS X, and the Windows NT line (2000, XP, Vista) are so much less likely to crash than operating systems such as Mac System 9 and the Windows 9x line are because of these protections. Obviously, the OS itself and anything mapped into the OS (most notably, hardware drivers) can still cause problems. But modern OS architecture is very good at preventing a single application from bringing down your entire machine. I, for one, remember the days of Win9x and Mac System 9 (or, worse yet, Win 3.1 and System 6), and believe me, we live in a *much* better world, now. There are two abstract possibilities for doing what you want, neither of which can presently be done in Mathematica. One is to use memory-mapped files. This allows you to map a file (a real, properly named file, or some temporary thing in the swap space) into memory, and explicitly give other processes permissions to map the same file into their own memory space. That is, incidentally, one of the methods MathLink uses for communicating (but in a buffered way...it's not directly mapping internal structures). The second is to write your code as a DLL and have Mathematica run your code in its own process space. In both, there are significant risks, as you now open up the list of things that can crash Mathematica to not just issues in Mathematica, but also to bugs which exist in the external code. There are also some other considerable complications which I'm glossing over a bit (Jens rightly points out one of those...the internal data structures may be quite sophisticated). Nonetheless, I wouldn't go so far as to say that the problem is insurmountable or that we'll never have other solutions. But it's certainly not there now. Depending on your problem, though, other solutions may very well be feasible. John Fultz jfultz@wolfram.com User Interface Group Wolfram Research, Inc. > Are there any other solutions for passing pointers to big data from >> mathematica to external programs? > No In this context, an 'external >> program' does not need to be a separate process, it could simply be a >> loadable shared library. The way another system deals with its c- >> extensions is >> a good example of what I mean by this. > A MahtLink program can run on a second computer, that will not work > with dynamic librarys > It seems like those official mathematica functions implemented in >> native code do not have the above constraint and it is possible to >> pass pointers without deep copying, is this correct? > What is a official Mathematica function ? Why do you assume that the kernel store your data in the same way as > your code does ? Since Mathematica can store symbols, expressions, > integers, multi-precision numbers in its lists your program would never > know what is in the memory location. MathLink is the only way to > unfold the internal structures and to send it to an external program. > If so, how is it >> possible to implement a function like this? > > *IT IS NOT POSSIBLE* And with a little cleverness in cen C-code it is not necessary. > I have C-programs that deal with several GByte of data for visualization > and image processing tasks and I have no idea for what this should be > good for. Jens > On 18 Apr, 08:37, Jens-Peer Kuska a) MathLink is always buffered and > b) it must copy the data into a memory area > that bot programs can access > c) your C-program can never access the memory space > of an other program/process. The operating system is > responsible to hinder/prevent such operations Jens > When passing a list/array from mathematica to c using mathlink, eg >> when calling MLReleaseInteger32List(), it seems mathlink allocates >> some memory which later has to be freed, eg using >> MLReleaseInteger32List(). The question is, how is it possible to >> pass >> a list from mathematica to c without this c memory allocation? >> This example helps to make the question more clear: Assume >> MyFunction >> [BigList] to be a function implemented in c using mathlink, where >> BigList is a list of integers. Since BigList has been already >> created >> in mathematica and its corresponding memory has been allocated, we >> do >> not wish to allocate memory once again in c. It looks like one >> option >> is to pass BigList by reference, that is: >> SetProperties[MyFunction, HoldAll] >> In this case, does mathlink still allocate memory and copy BigList >> in >> the c side? === Subject: Re: Installation Problem with Mathematica 4.2 under Windows XP because TechSupport of WRI (who would be primary addressee) does not > respond to my inquiry I redirect my question to MathGroup hoping that > someone may have come across the same problem and knows a work-around. On my laptop where I have (only) recently upgraded the operating system > from Windowxs 2000 to XP Professional 2002 SP3 I want to reinstall > Mathematica V 4.2.1 (besides other versions 3.0., 5.2, 6.0 and 7.0) in > order to compare the sometimes different behavior of various versions of > Mathematica with respect to specific procedures / packages e.g. Limit etc. Under Windows 2000 there was no problem installing previous versions of > Mathematica (e.g. 3.0, 4.2, 5.2, 6.0 and 7.0) > whereas with Windows XP there occurs an installation problem with > Mathematica V 4.2.1 ONLY (not with the much older version 3.0 from 1998 > !). The corresponding MathInstaller (08/2002) for version 4.2.1 starts > a wizard but after about 18% the following message appears : MathInstaller is unable to run a program needed to proceed with the > installation. Restart your system and try again ErroR 105. > When I press the OK button then in an Application Error window the > following message is displayed : > ISSET_SE caused a general protection fault in module ... Does anyone know what to do in order to enforce the installation of > Mathematica 4.2.1 under Windows XP Professional. (As emphasized above, > no problem under OS Windows 2000 ) Robert Kragler > I am sure people here would be interested in what you have discovered from your comparisons of all those versions of Mathematica. Do please tell us more of your results. David Bailey http://www.dbaileyconsultancy.co.uk === Subject: Re: Plot Axis Unit Conversions As a follow-up to my previous post: The concept is easy to generalize to other unit scale conversions using the Units package. Needs[Units`] convertedScale[oldUnit_, newUnit_][min_, max_] := Apply[{#1/(Convert[oldUnit, newUnit]/newUnit ), ##2} &, AbsoluteOptions[ Plot[x, {x, Convert[oldUnit, newUnit]/newUnit min, Convert[oldUnit, newUnit]/newUnit max}, Frame -> True, FrameTicks -> {Automatic, None, None, None}], FrameTicks][[1, 2, 1]], 1] Now you can go wild: Plot[0.25 Sin[x], {x, 0, 100}, Frame -> True, FrameTicks -> {convertedScale[Meter, LightYear], convertedScale[Meter, Centi Meter], convertedScale[Meter, Mile], convertedScale[Meter, Yard]}, FrameLabel -> {x-axis (in LightYear), y-axis (in cm), x-axis (in Miles), y-axis (in yards)}] Works for every unit listed in Units/guide/UnitsPackage except temperatures. For these you have to replace Convert for ConvertTemperature. > Hello everyone, I am working on a notebook involving a flutter analysis of a flat > plate in a wind tunnel. All of the equations involve metric units, but > most of the physical measurements of size I have are in inches. In > order to maintain a consistent system of units, I would like to plot > the axis units in metric and English units. Specifically, I have a > plot for the critical flutter speed in units of m/s versus the chord > length in meters, and I want to overlay an x-axis, possibly on the > top, that will display the equivalent length in inches (i.e, > xinches=x*10000/254) without messing up the graph. At the very least, > I would like to display it in centimeters instead of meters for better > clarity. I do NOT want to recalculate the function using inches - just > display the conversion. It would be nice if I could display it in both > inches and centimeters at the same time. This is an absolute breeze to do in another system, but I haven't been > able to find anything specifically dealing with scaling of axes for > Mathematica. Anyone have any ideas? > === Subject: Re: Plot Axis Unit Conversions It is pretty easy to generate a figure with axes both in meters and in inches using FrameTicks. However, getting the ticks look good, i.e. choosing nice values (preferably automatically) is a different matter. But I've got a solution for you: Apart from values as Automatic and None, FrameTicks can be given a function as parameter which gets the minimum and maximum value for the given axis and which then should generate the major and minor ticks based on these values. My trick involves using Plot itself for picking nice values. This is my FrameTicks function inchScale: inchScale[min_, max_] := Apply[{2.54/100 #1, ##2} &, AbsoluteOptions[ Plot[x, {x, 100/2.54 min, 100/2.54 max}, Frame -> True, FrameTicks -> {Automatic, None, None, None}], FrameTicks][[1, 2, 1]], 1] and this is how you use it: Plot[Sin[x], {x, 0, 10}, Frame -> True, FrameTicks -> {Automatic, Automatic, inchScale, inchScale}, FrameLabel -> {x-axis (in m), y-axis (in m), x-axis (in inch), y-axis (in inch)}] Pretty easy, eh? To explain the inchScale gibberish: I first let Mathematica generate a simple plot of f[x]=x with the range min,max converted to inches (it is not necessary that it's the same plot as long ast ist has the same range; for speed it'd better be a simple plot). inchScale gets min,max from your actual plot. I then have Mathematica generate the plot with FrameTicks and use AbsoluteOptions to get a peek at the value of FrameTicks used in this plot. The [[1, 2, 1]] part is to peel off some superfluous levels of brackets and stuff. The last step involves scaling the inches back to meters so that they fit in the same plot. Hope this helps. > Hello everyone, I am working on a notebook involving a flutter analysis of a flat > plate in a wind tunnel. All of the equations involve metric units, but > most of the physical measurements of size I have are in inches. In > order to maintain a consistent system of units, I would like to plot > the axis units in metric and English units. Specifically, I have a > plot for the critical flutter speed in units of m/s versus the chord > length in meters, and I want to overlay an x-axis, possibly on the > top, that will display the equivalent length in inches (i.e, > xinches=x*10000/254) without messing up the graph. At the very least, > I would like to display it in centimeters instead of meters for better > clarity. I do NOT want to recalculate the function using inches - just > display the conversion. It would be nice if I could display it in both > inches and centimeters at the same time. This is an absolute breeze to do in another system, but I haven't been > able to find anything specifically dealing with scaling of axes for > Mathematica. Anyone have any ideas? > === Subject: Re: Plot Axis Unit Conversions > Hello everyone, I am working on a notebook involving a flutter analysis of a flat > plate in a wind tunnel. All of the equations involve metric units, but > most of the physical measurements of size I have are in inches. In > order to maintain a consistent system of units, I would like to plot > the axis units in metric and English units. Specifically, I have a > plot for the critical flutter speed in units of m/s versus the chord > length in meters, and I want to overlay an x-axis, possibly on the > top, that will display the equivalent length in inches (i.e, > xinches=x*10000/254) without messing up the graph. At the very least, > I would like to display it in centimeters instead of meters for better > clarity. I do NOT want to recalculate the function using inches - just > display the conversion. It would be nice if I could display it in both > inches and centimeters at the same time. This is an absolute breeze to do in another system, but I haven't been > able to find anything specifically dealing with scaling of axes for > Mathematica. Anyone have any ideas? > What would be nice in a case like this, would be to have say metric unit ticks on eg. the outside of the axis and imperial units on the inside. (or any other units combination) ...or maybe everyone could just use SI units! Mike === Subject: Re: Plot Axis Unit Conversions here is an example where we have 2 x-axes, one from 0..1 the other from 0..Pi: Plot[Sin[Pi t], {t, 0, 1}, Frame -> True, FrameTicks -> {{True, True}, {True, Table[{x, Rationalize[x] Pi}, {x, 0, 1, .2}]}}] Daniel > Hello everyone, I am working on a notebook involving a flutter analysis of a flat > plate in a wind tunnel. All of the equations involve metric units, but > most of the physical measurements of size I have are in inches. In > order to maintain a consistent system of units, I would like to plot > the axis units in metric and English units. Specifically, I have a > plot for the critical flutter speed in units of m/s versus the chord > length in meters, and I want to overlay an x-axis, possibly on the > top, that will display the equivalent length in inches (i.e, > xinches=x*10000/254) without messing up the graph. At the very least, > I would like to display it in centimeters instead of meters for better > clarity. I do NOT want to recalculate the function using inches - just > display the conversion. It would be nice if I could display it in both > inches and centimeters at the same time. This is an absolute breeze to do in another system, but I haven't been > able to find anything specifically dealing with scaling of axes for > Mathematica. Anyone have any ideas? === Subject: Help with Speeding up a For loop I am using an Intel MacBook with OS X 10.5.6. I am trying to create 2 lists: Ideal and Resolution. This is basically a Monte Carlo Integration technique. Ideal should simulate the curve. Resolution should simulate the curve convoluted with a normal distribution. I want to do this for n=10 000 000 or more, but it takes far too long right now. I can do n=100 000 in about 1 minute, but 1 000 000 takes more than an hour. I haven't waited long enough for 10 000 000 to finish (it has been 5 days). Adam Dally Here is the code: ClearAll[E0, Eb1, m, DeltaE, Sigma, k, n, y3, Ideal, Resolution, i, normalizer, maxE, minE] Eb1 = 0; k = 0; n = 10000; E0 = 2470; m = 0.2; DeltaE = 50; Sigma = 5; maxE = E0 - m; minE = E0 - DeltaE; Resolution = {Eb1}; Ideal = {Eb1}; (*Setup all constants, lists and ranges*) Eb1 = RandomReal[{minE, maxE}, n]; (*create a list of 'n' random Eb1 values*) k = -RandomReal[TriangularDistribution[{-2470, 0}, -0.1], n]; (*create a list of 'n' random k values; triangle distribution gives more successful results*) For[i = 0, i < n, i++, If[k[[i]] < Re[(E0 - Eb1[[i]])^2*Sqrt[1 - m^2/(E0 - Eb1[[i]])^2]], (*check if the {k,Eb1} value is under the curve*) AppendTo[Ideal, Eb1[[i]]]; (*Keep events under curve in 'Ideal'*) y3 = Eb1[[i]]; (*cast element to a number*) Eb1[[i]] = RandomReal[NormalDistribution[y3, Sigma], 1]; (*choose a random number from a normal distribution about that point*) AppendTo[Resolution, Eb1[[i]]]; ]] (*Keep that event in 'Resolution'*) === Subject: Re: Looking for a scrolling list control, or how to eyes/fingers. I review but it's not always easy to spot them, eventually I do. Um, is there a syntax checker around I can use to find some typos?? ;-) Good code to ponder (the Join tip was very cool!) and your note on Dynamic was great. An improved version is forth coming soon. Btw, any examples of creating a custom control like I am doing and returning its value for use by other code like native controls do in Mathematica? Or point me to the right doc section to chew through. Are andrew, happy little man === Subject: Preserving Notebook Changes Two weeks ago there was discussion about UNDO function. I have spent some time trying to find out a reasonable solution. As I understand currently there is no solution to have two or more channels to control the notebook selection. Thus there is no =93real multiple UNDO=94 can be realized on the level of language of Kernel and FronEnd. The only strategy I have found is automatic saving of the modified cells to a separate notebook within given time interval. Below is the code of the button to be placed in the Docked Cell. The notebook with preserved cells can be later investigated with some tools like NotebookDiff from AuthorTools`. I would appreciate if anybody can improve the code and combine it with the comparison tool. dockedCellsBtn[] := Cell[BoxData@{ToBoxes@ DynamicModule[ {NotebookPreserve, initialize, nb, t0, q = False, sty = Input | Text}, NotebookPreserve[__] := Null; NotebookPreserve[True, nb_NotebookObject, sty_, t0_] := Module[{cls, ops, ps, lastUpd}, cls = First@NotebookGet[ButtonNotebook[]]; cls = Cases[cls, Cell[_, sty, ___], [Infinity]]; ops = Drop[#, 2] & /@ List @@@ cls; ps = CellChangeTimes /. ops /. CellChangeTimes :> {{0}}; lastUpd = Map[Max, ps]; cls = Extract[cls, Position[lastUpd - If[NumberQ@t0, t0, 0], _?Positive]]; SelectionMove[nb, After, Notebook]; NotebookWrite[nb, cls]; NotebookSave[nb]; Max@lastUpd]; initialize[] := Module[{nbobj, fn}, SetOptions[ButtonNotebook[], {TrackCellChangeTimes -> True}]; fn = StringInsert[NotebookFileName[], Preserved., -3]; If[FileExistsQ[fn], nbobj = NotebookOpen[fn, Visible -> False], nbobj = NotebookPut@Notebook[{}, Visible -> False]; NotebookSave[nbobj, fn]]; SetOptions[nbobj, WindowMargins -> {{Automatic, 0}, {Automatic, 0}}, ClosingAutoSave -> True, TrackCellChangeTimes -> False, WindowTitle -> (WindowTitle /. AbsoluteOptions[ButtonNotebook[], WindowTitle]) <> .Preserved]; nbobj]; Button[ Dynamic[Refresh[ t0 = NotebookPreserve[q, nb, sty, t0]; Notebook Preserve: <> If[q, On, Off], TrackedSymbols -> Full, UpdateInterval -> 60]], q = ! q; t0 = If[q, nb = initialize[]; Module[{cls, tt}, cls = First@NotebookGet[nb]; cls = Drop[#, 2] & /@ List @@@ cls; tt = CellChangeTimes /. cls /. CellChangeTimes :> {{0}}; Max@Flatten@tt], SetOptions[nb, Visible -> True]; NotebookSave[nb]; NotebookClose[nb]]]; ]]}] If[NotebookFileName[] =!= $Failed, SetOptions[InputNotebook[], TrackCellChangeTimes -> True, DockedCells -> dockedCellsBtn[]]] Yuri Kandrashkin === Subject: Re: Any way to make help browser remember the last position? Ok. the mathgroup, so I decided to share it. ----- In V7.0 1.) Open the Options Inspector dialog 2.) Set the scope to Global 3.) In the tree, go to Global Options > Dialog Settings > Help Viewer Settings 4.) Set the Enabled option to True Ian ------ Now the problem is when you minimize the help window and press F1 to look up a function, what happens is that instead of restoring the 'size' it will go to the upper right position but stay in minimized size. What is the fix for that? === Subject: Re: Any way to make help browser remember the last position? > Ok. the mathgroup, so I decided to share it. ----- > In V7.0 1.) Open the Options Inspector dialog > 2.) Set the scope to Global > 3.) In the tree, go to Global Options > Dialog Settings > Help Viewer > Settings > 4.) Set the Enabled option to True Ian > ------ Now the problem is when you minimize the help window and press F1 to > look up a function, what happens is that instead of restoring the > 'size' it will go to the upper right position but stay in minimized > size. What is the fix for that? I tried this (set Enabled to True) and nothing happened on my Mac. The DC window still came up in the middle of the screen at the same size it always did. I moved the DC to where I wanted and sized it to what I wanted and then exited. Started up again and still the same centered position and still the same default size. So I tried setting the WindowSize and WindowMargins parameters (in the same GlobalOptions/DialogSettings/HelpViewerSettings section) to what the OptionInspector told me they were for the DC window when I got it into a size and position I liked (along with the Enabled to True) and then the DC window did come up where I last left it, but only when manually clicking the Help/DocumentationCenter menu option, so it doesn't bring up the DC window when first starting Mathematica. Trying to use the AutoOpenNotebooks in addition to these HelpViewerSettings parameters did bring up the DC window when starting up, but in the same centered position and the same default size, and when I clicked on the DC menu item another DC window came up at the saved position and size as before - so apparently the AutoOpenNotebooks doesn't pay any attention to the HelpViewerSettings paramaters. So is there a way to have both an automatically started DC window and have it at the size and position you want every time Mathematica starts up?? Is the F1 key specific to Windows version of Mathematica? Trying F1 or Shift-F1 on my Mac laptop does nothing to Mathematica (think that the equivalent Mac key is the Help key on an expanded large style keyboard, so not sure what the equivalent command is on a laptop keyboard without the extra keypads on the right), so can't figure out what Sean is talking about in the last paragraph. -Bob === Subject: Re: running mathematica notebooks without interface > This is a very good idea and it works. > However I would like to use graphics command such as contourPlot and > others, and this seems not to be possible using a .m package run > without a frontend? > maybe the UsingFrontEnd command may help? actually that is what it is for, so yes, it may help... > But it's quite undocumented! It is part of JLink and an essential part of webmathematica, so you should look in the documentation of these to learn more about it and why it is there. Actually if everything is set up correctly, its usage is trivial, since you only wrap it around parts of code which need the frontend to work. The complicated part is the setup, which is described in the JLink tutorial. > It seems there is no way to run a .nb file without a front-end and > save the output of the cells (including graphics) without having the > actual frontend running... it can be done with UseFrontEnd, but you need to be able to run a graphical interface on the server, which is not per se possible on all platforms when logging in via ssh. E.g. on a unix machine you need to have X installed and an X server of some sort running, e.g. a vncserver. For tips on how you can make UseFrontEnd work you need to give more details about the server you are trying to access. On the other hand, if you have the possibility to run something like e.g. vncserver on the server, I would recommend using that to start the frontend on the server in a vnc-session, start the evaluation and reconnect when the evaluation of the notebook has finished. > Someone suggested me to use the Kernel remotely, which could be an idea! > However I have some troubles addressing the remote kernel since it is > located in a private network and I usually reach it by a double ssh > session (ssh user1@gateway and then ssh user2@server) > Any quick trick to tell mathematica to load a remote kernel using ssh > tunnel? you could set up a tunnel which connects a free port on your local host to port 22 on 'server' via 'gateway'. This is independent from mathematica, you can do the setup and testing without even touching mathematica, and you can also tunnel any protocol for remote access like e.g. vnc this way, too. Then when this works you would just need to connect to 'localhost' on the new port which should make the configuration of mathematica much simpler. You should read the documentation of the ssh-flavour you are using to learn how to do that. Maybe it would also be a good idea to ask your system administrators what their suggestions are to access the server, since it was them who hided the server, so probably they have a working solution already... hth, albert === Subject: Re: representing the dihedral group {1,r,r^2...s,sr^2...} Don't use Times to represent group multiplication, or modify Times and Power. Instead use something like SmallCircle. SmallCircle[s, s^2] You might leave that unevaluated, but then write an EvaluateGroupProducts routine to evaluate the products from a group table or using an algorithm. David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ in mathematica so I can do for example: s^3 and get s. I tried this code: Unprotect[Times, Power]; n = 4; ClearAll[r, s, Times, Power]; SetAttributes[Times, {Flat}] s^2 = 1; r^n = 1; Protect[Times, Power]; But this doesn't work for, for example, s^3. It is not able to simplify it. Otto === Subject: Re: representing the dihedral group {1,r,r^2...s,sr^2...} > {1,r,r^2...s,sr^2...} in mathematica so I can > do for example: > s^3 > and get s. First, you should understand that the general problem you suggest is *very* hard - impossible, in fact. For some specific groups, however, there algorithms to reduce an arbitrary product to a canonical form and this is the case for the dihedral group. The dihedral group of order 2n may be represented as . If you start with an arbitrary finite string of as and bs, simply remove each consecutive pair of identical symbols. You will be left with a product in one of the following four forms: (a*b)^m (a*b)^m * b (b*a)^m (b*a)^m * a The exponent m may then be reduced modulo n. To implement this in Mathematica, it is best to use NonCommutativeMultiply, or it's infix form **. Here's how: a /: a ** a = 1; b /: b ** b = 1; a /: a ** 1 = a; b /: b ** 1 = b; a /: 1 ** a = a; b /: 1 ** b = b; Now, let's generate a long product of as and bs. w = NonCommutativeMultiply@@RandomChoice[{a, b}, 100] You should notice that the string is far shorter than 100 now let's put it in it's final form. Assuming you're working in D_6, you can do the following: n = 3; finalForm[w : NonCommutativeMultiply[a, ___, b]] := (a**b)^Mod[Length[w]/2, n]; finalForm[w : NonCommutativeMultiply[a, ___, a]] := (a**b)^Mod[(Length[w] - 1)/2, n] ** a; finalForm[w : NonCommutativeMultiply[b, ___, a]] := (b**a)^Mod[Length[w]/2, n]; finalForm[w : NonCommutativeMultiply[b, ___, b]] := (b**a)^Mod[(Length[w] - 1)/2, n] ** b; finalForm[w] Now, my ab is your r, my ba is your r^(n-1), my b is your s, and (I think) my a is your r^(n-2)s. Thus, you should be able to use this code to reduce in the alternative presentation . One final comment: If you are planning to work with more general group presentations, then I strongly recommend that you check out Gap: http://www.gap-system.org/ Hope that helps, Mark McClure === Subject: Re: representing the dihedral group {1,r,r^2...s,sr^2...} it calls for troubles changing the rules for built in functions. Instead assigne the rule to your symbols. E.g.: s /: s^2 = 1; s /: s^n_ := s s^(n - 1) /. n > 2; r /: r^4 = 1; r /: r^n_ := r r^(n - 1) /; n > 4; Daniel > in mathematica so I can do for example: s^3 and get s. I tried this code: Unprotect[Times, Power]; > n = 4; > ClearAll[r, s, Times, Power]; > SetAttributes[Times, {Flat}] > s^2 = 1; > r^n = 1; > Protect[Times, Power]; But this doesn't work for, for example, s^3. It is not able to > simplify it. > Otto > === Subject: Re: representing the dihedral group {1,r,r^2...s,sr^2...} NCAlgebra can be used to do what you want http://www.math.ucsd.edu/~ncalg/ Send questions to ncalg@gmail.com > in mathematica so I can do for example: s^3 and get s. I tried this code: Unprotect[Times, Power]; > n = 4; > ClearAll[r, s, Times, Power]; > SetAttributes[Times, {Flat}] > s^2 = 1; > r^n = 1; > Protect[Times, Power]; But this doesn't work for, for example, s^3. It is not able to > simplify it. > Otto === step1 = p'[t] == (e0 s[t] k1 k2)/(s[t] k1 + k1 Km) MapAt[Cancel, step1, 2] David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ Hello group. I'm trying to do a little algebra which i can do in my head using Mathematica. Why? Well, it's neater. Consider the following. p'[t] == (e0 s[t] k1 k2 )/ (s[t] k1 + k1 Km) difficult to accomplish in mathematica? Following does nothing. p'[t] == (e0 s[t] k1 k2 )/ (s[t] k1 + k1 Km) // Assuming[k1 > 0, {Collect[#, k1]}] & Sean === mathematica thought k1 could be = 0. So i figured, if I told it that k1>0, it may work. But now I see that Assuming probably has some other application... > Factor[(e0*s[t]*k1*k2)/(s[t]*k1 + k1*Km)] > (e0*k2*s[t])/(Km + s[t]) or Cancel[(e0*s[t]*k1*k2)/(s[t]*k1 + k1*Km)] > (e0*k2*s[t])/(Km + s[t]) Difficult ? Give an example of easy. And by the way, where did you get the idea that Assuming does anything = > at all with Collect? Andrzej Kozlowski > Hello group. I'm trying to do a little algebra which i can do in my head using > Mathematica. Why? Well, it's neater. Consider the following. p'[t] == (e0 s[t] k1 k2 )/ (s[t] k1 + k1 Km) difficult to accomplish in mathematica? Following does nothing. p'[t] == (e0 s[t] k1 k2 )/ (s[t] k1 + k1 Km) // > Assuming[k1 > 0, {Collect[#, k1]}] & > Sean === Subject: Re: Plot Axis Unit Conversions You could write you own Ticks option to specify the tick marks at the top of a Frame plot. The Mathematica function Rescale might be useful in this regard. Look up Ticks and FrameTicks in Help. The Presentations package ($50) at my web site does include a CustomTicks function that allows one to generate new scales that have any 1-1 mapping between the tick values and the underlying coordinates. It also does both the labeled and unlabeled ticks. There is an example on the following page at my web site. http://home.comcast.net/~djmpark/DrawGraphicsPage.html David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ Hello everyone, I am working on a notebook involving a flutter analysis of a flat plate in a wind tunnel. All of the equations involve metric units, but most of the physical measurements of size I have are in inches. In order to maintain a consistent system of units, I would like to plot the axis units in metric and English units. Specifically, I have a plot for the critical flutter speed in units of m/s versus the chord length in meters, and I want to overlay an x-axis, possibly on the top, that will display the equivalent length in inches (i.e, xinches=x*10000/254) without messing up the graph. At the very least, I would like to display it in centimeters instead of meters for better clarity. I do NOT want to recalculate the function using inches - just display the conversion. It would be nice if I could display it in both inches and centimeters at the same time. This is an absolute breeze to do in another system, but I haven't been able to find anything specifically dealing with scaling of axes for Mathematica. Anyone have any ideas? === Subject: Re: Plot Axis Unit Conversions Plot[x, {x, 0, 0.1}, Frame -> True, FrameLabel -> {chord length (m), flutter speed (m/s), chord length (in), None}, FrameTicks -> {Automatic, Automatic, Join[Table[{254 n/10000, n, {0.016, 0.}, {GrayLevel[0.], AbsoluteThickness[0.25]}}, {i, 0, n}], Table[{254 n/100000, , {0.01375, 0.}, {GrayLevel[0.], AbsoluteThickness[0.125]}}, {n, 0, 40, 5}], Table[{254 n/100000, , {0.008, 0.}, {GrayLevel[0.], AbsoluteThickness[0.125]}}, {n, 0, 40}]], Automatic}, Axes -> False] Bob Hanlon Hello everyone, I am working on a notebook involving a flutter analysis of a flat plate in a wind tunnel. All of the equations involve metric units, but most of the physical measurements of size I have are in inches. In order to maintain a consistent system of units, I would like to plot the axis units in metric and English units. Specifically, I have a plot for the critical flutter speed in units of m/s versus the chord length in meters, and I want to overlay an x-axis, possibly on the top, that will display the equivalent length in inches (i.e, xinches=x*10000/254) without messing up the graph. At the very least, I would like to display it in centimeters instead of meters for better clarity. I do NOT want to recalculate the function using inches - just display the conversion. It would be nice if I could display it in both inches and centimeters at the same time. This is an absolute breeze to do in another system, but I haven't been able to find anything specifically dealing with scaling of axes for Mathematica. Anyone have any ideas? === Subject: Re: Creating a sign chart f[x_] = Expand[(x - 1) (x - 3) (x - 7)] x^3 - 11*x^2 + 31*x - 21 xmin = 0; xmax = 8; Plot[{f[x], f'[x], f''[x]}, {x, xmin, xmax}] Transpose[Join[{{f[x], f'[x], f''[x]}}, Table[If[# > 0, +, If[# == 0, 0, -]] & /@ {f[x], f'[x], f''[x]}, {x, xmin, xmax, 1/4}]]] // Grid Bob Hanlon Is it possible to render a sign chart in Mathematica 10? Typically a sign chart is used with the first and second derivatives to identify extrema. I know there are other ways to convey this information. However, in my case I need to demonstrate a sign chart by means of an illustation. I can create a graphic in Visio and import into Mathematica but I would prefer if there were a means of generating such a chart directly in Mathematica. Something like: +++++++++++++++------------ Dave x2373 === Subject: Re: Help with a possible bug $Version 7.0 for Mac OS X x86 (64-bit) (February 19, 2009) mat = Table[3, {i, 1, 17}, {j, 1, 267}]; sum = Union[Table[Total[mat[[All, j]]], {j, 1, 249}]] {51} sum1 = Union[Table[Total[mat[[All, j]]], {j, 1, 252}]] {143234937} sum2 = Union[Table[Total[mat[[All, j]]], {j, 1, 252}]] {319400391} Bob Hanlon At work we seem to have stumbled on a strange bug between Table and Part. We can reproduce the bug on differently configured Mac and Linux boxes. I tried Wolfram support, but they claim they cannot reproduce the bug. So I was hoping someone could try it out and For us, the bug is new in 7.0.1. It does not show up in version 6. To reproduce it, fill up a 17 x 267 matrix with 3s. Compute the sum of some of the columns and you get the result 51 (17 x 3). But if one computes the sum for the last few columns, the result is completely off. The bug seems to arise from the interaction of optimizations in Table and the use of All inside of Part. ------------ code mat = Table[3, {i, 1, 17}, {j, 1, 267}]; sum = Table[Total[mat[[All, j]]], {j, 1, 249}] sum1 = Table[Total[mat[[All, j]]], {j, 1, 252}]; sum2 = Table[Total[mat[[All, j]]], {j, 1, 252}] ------------ end code If you look at sum1, it will be correct on a fresh copy of the Kernel. The problem only arise from the second time on. Papin Email: ImportString[cGFwaW5AY294Lm5ldA==, Base64] === Subject: Re: Looking for more Mathematica online user groups/forums > WRI, Since Home edition offers me only 30 days tech support and I am not a > student around other Mathematica using students on a campus. And > buying expensive books does only cover so much (And many are outdated > or does not cover areas outside of math like the Frontend), where on > the internet do I find help thats more real time? This group has been > very helpful, but I want more rapid turn around time, and someone to > teach why some code is good and mine is bad so I learn from mistakes . I do find it strange there is not a more active WRI collection of > people part of a tech support forum somewhere. A whiteboard version of > the FE to aid in support could be a good direction. Collaborative > editing FE in real time somehow? How about a Home Ed users forum on > WRI site?? Or perhaps allow Home Edition users email support; if it is so, be > clear it is so and how long the turn around time for a reply. Or > encourage local universities to create local Mathematica support > groups. Mathematics is a social activity as much as any other creative one; > helping each other is a great way to enjoy learning. Andrew, seeking some shoulders to stand on ;-) > The newsgroup sci.math.symbolic does not have the expertise of comp.soft-sys.math.mathematica, but there are many people (some WRI employees) who know Mathematica and will respond to requests there. You might get a certain professor moaning about Mathematica questions there, but people tend to ignore him. for a while. Within a 30 day period, I somewhat doubt you will be needing too many difficult questions answered, so sci.math.symbolic might be a useful complimentary group. Be aware, if you multi-post (copy your message to both sci.math.symbolic and comp.soft-sys.math.mathematica at the exact same time, so there are sci.math.symbolic until Steve has approved it. I've never understood the logic of that!! Since the newsgroup sci.math.symbolic is unmoderated, why should a message copied to both have to wait for approval? If you want to send to both newsgroups, do it to one, then do it to the second. [My approval has nothing to do with sci.math.symbolic. If a message does not appear there, it has nothing to do with me - Steve C.] === Subject: Re: Looking for more Mathematica online user groups/forums IMO this group is one of the best in terms of: understanding the question quality of follow-up no interest in what edition you have offering example code or even fixing my bad code > WRI, Since Home edition offers me only 30 days tech support and I am not a > === Subject: Re: Looking for more Mathematica online user groups/forums I would also recommend excellent (and free) on-line book written by Leonid Shifrin. See either his original post /thread/b92f38e2f0f00632/263ac099c018117e?lnk=gst&q=book#263ac099c01811= 7e or the site with his PDF format book: http://www.mathprogramming-intro.org He has really put a lot of effort and thought into the book and its example - a real treasure. Mac > WRI, Since Home edition offers me only 30 days tech support and I am not a > student around other Mathematica using students on a campus. And > buying expensive books does only cover so much (And many are outdated > or does not cover areas outside of math like the Frontend), where on > the internet do I find help thats more real time? This group has been > very helpful, but I want more rapid turn around time, and someone to > teach why some code is good and mine is bad so I learn from mistakes . I do find it strange there is not a more active WRI collection of > people part of a tech support forum somewhere. A whiteboard version of > the FE to aid in support could be a good direction. Collaborative > editing FE in real time somehow? How about a Home Ed users forum on > WRI site?? Or perhaps allow Home Edition users email support; if it is so, be > clear it is so and how long the turn around time for a reply. Or > encourage local universities to create local Mathematica support > groups. Mathematics is a social activity as much as any other creative one; > helping each other is a great way to enjoy learning. Andrew, seeking some shoulders to stand on ;-) === Subject: Re: Looking for a scrolling list control, or how to create/simulate andrew === Subject: Re: Looking for a scrolling list control, or how to create/simulate I'd give x a starting value and the ld in the beginning should be lt ListField[wd_, tz_, ls_] := DynamicModule[{x, lt}, x = ls[[1]]; lt = Length[ls]; Framed[Pane[ Column[Table[ With[{i = i}, Button[Style[ls[[i]], FontSize -> tz], Dynamic[x = ls[[i]]], Appearance -> None, ImageSize -> {wd, tz + 2}, ImageMargins -> 0, Alignment -> Left]], {i, lt}], Spacings -> 0], ImageSize -> {wd, Round[(ld*tz/2) + (ld*2) - 4]}, ImageMargins -> {{1, 0}, {0, 0}}, Scrollbars -> {False, True}, AppearanceElements -> None], FrameMargins -> {{1, 0}, {0, -1}}] Dynamic[x]] mm = {yes, no, Andrew Merit, Marvin Honks, Pam Bakes, Marie loves, Anne jo Ann}; ListField[120, 14, mm] === Subject: Re: Looking for a scrolling list control, or how to create/simulate > OK, here is what I have come up with so far. Any corrections or improvements? And how do I reuse my custom control outside of the > current notebook cell? That is how do I install it for use in other ListField[wd_, tz_, ls_] := > DynamicModule[{x}, > ld = Length[ls]; > Framed[ > Pane[ > Column[ > Table[ > With[ > {i = i} > , > Button[Style[ls[[i]], FontSize -> tz], Dynamic[x = ls[[i]]] > , Appearance -> None > , ImageSize -> {wd, tz + 2} > , ImageMargins -> 0 > , Alignment -> Left] > ], {i, lt} > ], Spacings -> 0 > ] > , ImageSize -> {wd, Round[(ld*tz/2) + (ld*2) - 4]} > , ImageMargins -> {{1, 0}, {0, 0}} > , Scrollbars -> {False, True} > , AppearanceElements -> None > ] > , FrameMargins -> {{1, 0}, {0, -1}} > ] Dynamic[x] > ] mm = {yes, no, Andrew Merit, Marvin Honks, Pam Bakes, > Marie loves, Anne jo Ann}; > ListField[120, 14, mm] That's not bad. Aside from a couple of typos, the one bad thing that I see in there is that the second argument of Button[] should *not* have Dynamic wrapped around it. Dynamic has no purpose here, and there's no guarantee that it would have worked. Read this post of mine if you wish to understand further. http://forums.wolfram.com/mathgroup/archive/2009/Feb/msg00424.html Your interface could be improved by having it draw the currently selected item. Here's a modified implementation I created. However, the appearance is tailored for Windows...it might not have the right colors for other platforms. The magic happens in BaseStyle (and note that I moved your Style[] command to the BaseStyle option as well, just to make it cleaner). ListField[wd_, tz_, ls_] := DynamicModule[{x}, ld = Length[ls]; Framed[ Pane[Column[ Table[With[{i = i}, Button[ls[[i]], x = ls[[i]], Appearance -> None, ImageSize -> {wd, tz + 2}, ImageMargins -> 0, Alignment -> Left, BaseStyle -> Dynamic[ Join[{GenericButton, tz}, DrawHighlighted -> True}, {}]]]]], {i, ld}], Spacings -> 0], ImageSize -> {wd, Round[(ld*tz/2) + (ld*2) - 4]}, ImageMargins -> {{1, 0}, {0, 0}}, Scrollbars -> {False, True}, AppearanceElements -> None], FrameMargins -> {{1, 0}, {0, -1}}] ] John Fultz jfultz@wolfram.com User Interface Group Wolfram Research, Inc. === Subject: Re: Parallel processing downgrade > The change from Mathematica 7.0.0 to 7.0.1 seems to be a > downgrade in the area of parallel processing. Try > LaunchKernels[8] in both. Back in good old 7.0.0 you > get: > {KernelObject[1, local], KernelObject[2, local], > KernelObject[3, local], KernelObject[4, local], > KernelObject[5, local], KernelObject[6, local], > KernelObject[7, local], KernelObject[8, local]} Eight kernels - cool! In 7.0.1, you get {KernelObject[1, local], KernelObject[2, local], > KernelObject[3, local], KernelObject[4, local], > $Failed, $Failed, $Failed, $Failed} A little disappointing. The results are independent of how many processors your > computer has. Mark McClure Did you change passwords between 7.0.0 and 7.0.1? Seems odd that without a different password that has a different number of kernels allowed encoded into it, that you would see this kind of difference. What platform are you on (Windows, Mac, etc)?? I don't know about the 7.0.0 having 8 kernels available (dont have it installed any more), but one thing to keep in mind with the new default of 4 computation processes in version 7.0 -- these are NOT full kernels, they are special Parallel-Only-kernels (well the first two are regular but the second two are parallel routines only). In other words try and run 4 notebooks and assign each their own kernel - you CANNOT do it with the standard license with it's four computatoin processes. You can do two, but that is it. If you want to use four you have to use the new parallel routines in 7.0. So keep this in mind when you talk about how many kernels that Mathematica now has. They only let 4 of them run if two or more were invoked from the new 7.0 parallel routines, not from the front end or from the command line. Notice that Wolfram now refers to these as Computation Processes not as Processes like they did on version 6 and earlier I think. I think these were often called concurrent kernel processes or kernels, and now you have to be careful when comparing the newer computation processes and controlling processes. You can purchase additional kernels (in blocks of 4 I believe) if you need more -- call your Wolfram sales person and get the whole story if you need more kernels. -Bob === Subject: Re: Mathematica documentation - for newest and older versions A mere $370, more or less, for the complete set of printed documentation! Now if only the PDF versions of the Documentation Center content for > version 7.0 were done, life would be grand indeed!!!! (but they are > are on their way the web site says -- see http://www.wolfram.com/learningcenter/tutorialcollection/ > to see what they are intending to have if you have not seen this > before. It appears that you will be able to order hardcopies (for a > fee) of all the 7.0 documentation as well as download free versions of > the PDF files for each of the sections.... Kudo's to Wolfram for providing these sorts of tools!! -- 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: Mathematica documentation - for newest and older versions Options are always good, but actually I don't see how having a PDF would be better than having the doc centre. For starters, if you intend to read the PDF on your computer: the doc centre already has a Virtual Book built-in and if you like it on paper: this PDF is so huge that you're never going to print it (it's going to cost you at least $150). > I just discovered that Wolfram now has all the documentation collected > in one place for older versions of Mathematica and webMathematica and > gridMathematica and Mathematica CalcCenter and Publicon, apparently in > English, Japanese, Chinese, French, and German, along with about 20 > packages. It is located athttp://reference.wolfram.com/siteindex.html > -- and there is even a PDF version of Stephen Wolfram's classic > Mathematica Book for version 5 athttp://reference.wolfram.com/legacy/v5= _2/Mathematica_V5_Book.zip > if you don't already have a copy (this is the 1464 page book that is > no longer in print and is a wonderful source of information IMHO). I have not noticed this before, but think it's a great resource that > nice web site tree like this!!! Now if only the PDF versions of the Documentation Center content for > version 7.0 were done, life would be grand indeed!!!! (but they are > are on their way the web site says -- seehttp://www.wolfram.com/learningc= enter/tutorialcollection/ > to see what they are intending to have if you have not seen this > before. It appears that you will be able to order hardcopies (for a > fee) of all the 7.0 documentation as well as download free versions of > the PDF files for each of the sections. I am hoping that they also > have one complete PDF file that has everything in it to make searching > for things in the Mathematica documentation possible without the > Documentation Center, although I agree that not having the ability to > treat the documentation as a normal Mathematica notebook to play > around with, will be hard to get used to not having. But I think it > will provide a nice addition to the family of tools available to help > with learning and using Mathematica!! Kudo's to Wolfram for providing these sorts of tools!! -Bob === Subject: Re: NumberForm spaces and commas in v7.0.1 In Mathematica 7.0.1, from the menu select Edit > Preferences. Select the Appearance tab and then its Numbers tab. On the Formatting tab there, you'll see an option Digit block separator. You may change that to a thin comma, a comma, or a period. The same option may be set directly in the Options Inspector. Search for NumberSeparator there. If you change from the default, [ThinSpace], you can opt to set this just for the current selection, just for the current notebook, or globally. > hello, in Mathematica v4 and 5.2 to print long numbers separated by commas in blocks > of 3, i used to use something like this for example: NumberForm[N[Pi, 10], DigitBlock -> 3] which gave: 3.141,592,654 i.e. commas to the right of the decimal point. but in Mathematica v7.0.1 the > same statement generates number blocks separated by spaces, i.e: 3.141 592 654 i can recover the commas by using something like: NumberForm[N[Pi, 10], DigitBlock -> 3, NumberSeparator -> ,] but does anyone know if there is a quick fix to get the old style > commas back without having to change all my old programs in this way? thankyou, f.c. > -- 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: NumberForm spaces and commas in v7.0.1 I actually prefer Mathematica's new formatting, but if you like ye olde version you could try putting SetOptions[NumberForm, NumberSeparator -> {,, ,}] in an kernel/init.m file in the Autoload directory located at $UserBaseDirectory. > hello, in Mathematica v4 and 5.2 to print long numbers separated by commas in bl= ocks > of 3, i used to use something like this for example: NumberForm[N[Pi, 10], DigitBlock -> 3] which gave: 3.141,592,654 i.e. commas to the right of the decimal point. but in Mathematica v7.0.1 = the > same statement generates number blocks separated by spaces, i.e: 3.141 592 654 i can recover the commas by using something like: NumberForm[N[Pi, 10], DigitBlock -> 3, NumberSeparator -> ,] but does anyone know if there is a quick fix to get the old style > commas back without having to change all my old programs in this way? thankyou, f.c. === Subject: Re: NumberForm spaces and commas in v7.0.1 > hello, in Mathematica v4 and 5.2 to print long numbers separated by commas in blocks > of 3, i used to use something like this for example: NumberForm[N[Pi, 10], DigitBlock -> 3] which gave: 3.141,592,654 i.e. commas to the right of the decimal point. but in Mathematica v7.0.1 the > same statement generates number blocks separated by spaces, i.e: 3.141 592 654 i can recover the commas by using something like: NumberForm[N[Pi, 10], DigitBlock -> 3, NumberSeparator -> ,] but does anyone know if there is a quick fix to get the old style > commas back without having to change all my old programs in this way? This will do it globally (for the current session), so that it will affect all other functionality, too. So you need to decide whether it is what you want or not: SetOptions[NumberForm, NumberSeparator -> ,] if you put that line in your init.m it will be changed in all your sessions... hth, albert === Subject: Re: NumberForm spaces and commas in v7.0.1 > hello, in Mathematica v4 and 5.2 to print long numbers separated by commas in blocks > of 3, i used to use something like this for example: NumberForm[N[Pi, 10], DigitBlock -> 3] which gave: 3.141,592,654 i.e. commas to the right of the decimal point. but in Mathematica v7.0.1 the > same statement generates number blocks separated by spaces, i.e: 3.141 592 654 i can recover the commas by using something like: NumberForm[N[Pi, 10], DigitBlock -> 3, NumberSeparator -> ,] but does anyone know if there is a quick fix to get the old style > commas back without having to change all my old programs in this way? You can set the number formatting in the Preferences. Look under Appearance, and pick the Numbers tab, then Formatting. -- Helen Read University of Vermont === Subject: Re: NumberForm spaces and commas in v7.0.1 in version 7 the default NumberSeparator is , before the decimal point and space after it. If you want , everywhere e.g.: NumberForm[10^5 N[Pi, 15], DigitBlock -> 3] Look it up in the manual. Daniel > hello, in Mathematica v4 and 5.2 to print long numbers separated by commas in blocks > of 3, i used to use something like this for example: NumberForm[N[Pi, 10], DigitBlock -> 3] which gave: 3.141,592,654 i.e. commas to the right of the decimal point. but in Mathematica v7.0.1 the > same statement generates number blocks separated by spaces, i.e: 3.141 592 654 i can recover the commas by using something like: NumberForm[N[Pi, 10], DigitBlock -> 3, NumberSeparator -> ,] but does anyone know if there is a quick fix to get the old style > commas back without having to change all my old programs in this way? thankyou, f.c. > === Subject: Re: NumberForm spaces and commas in v7.0.1 sorry I copied the wrong example. It should read: NumberForm[10^5 N[Pi, 15], DigitBlock -> 3, NumberSeparator -> ,] You can find this in the manual under: NumberSeparator Daniel in version 7 the default NumberSeparator is , before the decimal point and space after it. If you want , everywhere e.g.: NumberForm[10^5 N[Pi, 15], DigitBlock -> 3] Look it up in the manual. Daniel >> hello, >> in Mathematica v4 and 5.2 to print long numbers separated by commas in blocks > >> of 3, i used to use something like this for example: >> NumberForm[N[Pi, 10], DigitBlock -> 3] >> which gave: >> 3.141,592,654 >> i.e. commas to the right of the decimal point. but in Mathematica v7.0.1 the > >> same statement generates number blocks separated by spaces, i.e: >> 3.141 592 654 >> i can recover the commas by using something like: >> NumberForm[N[Pi, 10], DigitBlock -> 3, NumberSeparator -> ,] >> but does anyone know if there is a quick fix to get the old style > >> commas back without having to change all my old programs in this way? >> thankyou, >> f.c. === Subject: Re: Advanced plotting Inspired by Bill Rowe's code, I think we can do it like this. The key point here is that the common Y axes is in a separated Inset object. Plot[-3, {x, -0.5, 10}, PlotRange -> {-1.1, 1.1}, Axes -> None, AspectRatio -> Automatic, Epilog -> {Inset[ Plot[-3, {x, 0, 10}, PlotRange -> {-1.1, 1.1}, Axes -> {False, True}, Frame -> None, AspectRatio -> Automatic], {0, 0}, {0, 0}, 10], Inset[Plot[Sin[2 x], {x, 0, 4}, PlotRange -> {-1.1, 1.1}, Axes -> {True, False}, Frame -> None, AspectRatio -> Automatic], {0, 0}, {0, 0}, 4], Inset[Plot[Cos[2 x], {x, 6, 10}, PlotRange -> {-1.1, 1.1}, Axes -> {True, False}, Frame -> None, AspectRatio -> Automatic], {5.2, 0}, {6, 0}, 4], Inset[Style[Rotate[[TildeTilde], 90 Degree], FontSize -> 20], {4.6, 0}]}] -- Li Zhengji ------------------------------------------------------------- If all you have is a hammer, everything is a nail. ------------------------------------------------------------- === Subject: Mathematica SIG (Washington DC Area) Mathematica SIG (web.mac.com/hrbishop.pmsi/DCSIG.m/DCSIG.html) MEETING: 24 April 2009, 7:30 am Science Applications International Corporation (SAIC) 8301 Greensboro Drive McLean VA Southern Corner of Westpark Drive and Greensboro Drive Agenda 1. Prepared Talks Using Mathematica to Imagine, Prototype, and Build Integrated Systems, by Eric Bynum ABSTRACT. Mathematica's new interface elements and dynamic capabilities have launched it into a language/application for building entire systems. It's no longer necessary to learn Java, Swing, C#, Windows programming etc. Since its inception in 1988, Mathematica has helped users imagine, experiment, prototype, and build up calculations. Now it can now be used to imagine, experiment, prototype, and build up entire systems -- systems integrated with mathematical and graphical power never before realized with Java, C#, etc. What I will illustrate simply scratches the surface of what Mathematica can now do: a Task Manager system to help me keep track of tasks, notes and projects. The backend is a simple hsqldb database with custom designed tables. The connection layer and interface are both Mathematica using its built-in DatabaseLink technology. How Mathematica was Used to Develop a New Search Model, by Mel Friedman ABSTRACT. The long term objective of this work is to develop a model for the detection of improvised explosive devices. Mathematica was an important tool that helped enormously in the model's development. The first part of the talk will give background helpful for relating to this work and describe the first and last Mathematica notebooks used in the model development. If there is sufficient interest, the remainder of the talk will describe model content and the simulation used to test the model. (Note: This talk is based upon one recently given to The International Society for Optical Engineering.) 2. Mathematica Gems and Discoveries - Sharing of Mathematica programming oddities - Applications of Mathematica to some areas of science - Something recently read and worth sharing 3. Mathematica Questions, Possible Approaches and Discussion 4. New Business: Select next meeting presentation, time and place Directions to 8301 Greensboro Drive, McLean VA (tall, boxy and white SAIC Enterprise Building at south corner of Westpark Drive and Greensboro Drive): Route 123 (Chain Bridge Road). Turn right onto Westpark Drive (Gosnell Road in the other direction). Turn right at the next light onto Greensboro Drive and then right into the parking lot. Visitor's Parking is adjacent to Westpark Drive. A SIG representative will meet you in the lobby. officer will ask for a driver's license before issuing a visitor's badge. === Subject: Re: Alignment of Graphics Within Expressions I ended up doing that, which worked approximately well enough for my various cases. But I was hoping there might be something equivalent to a hypothetical option CenterPosition -> Axis. David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ Using brute force to push them into place: g1 = BarChart[{1, 2, 3}, Axes -> {True, False}, BaselinePosition -> Scaled[-0.15], Ticks -> None, ImageSize -> 40]; g2 = BarChart[{-1, 2, -3}, Axes -> {True, False}, BaselinePosition -> Scaled[0.4], Ticks -> None, ImageSize -> 40]; CirclePlus[g1, g2] Bob Hanlon Here are two BarCharts within a CirclePlus (but it might be any kind of expression). g1 = BarChart[{1, 2, 3}, Axes -> {True, False}, BaselinePosition -> Axis, Ticks -> None, ImageSize -> 40]; g2 = BarChart[{-1, 2, -3}, BaselinePosition -> Axis, Axes -> {True, False}, Ticks -> None, ImageSize -> 40]; CirclePlus[g1, g2] The x axis of the bar charts are aligned with the baseline = (approximately the bottom) of the CirclePlus symbol. Would it be possible to align the = axes with the center line of the CirclePlus symbol without going into any Row constructions or modifying the CirclePlus expression? David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ === Subject: Re: Alignment of Graphics Within Expressions Using brute force to push them into place: g1 = BarChart[{1, 2, 3}, Axes -> {True, False}, BaselinePosition -> Scaled[-0.15], Ticks -> None, ImageSize -> 40]; g2 = BarChart[{-1, 2, -3}, Axes -> {True, False}, BaselinePosition -> Scaled[0.4], Ticks -> None, ImageSize -> 40]; CirclePlus[g1, g2] Bob Hanlon Here are two BarCharts within a CirclePlus (but it might be any kind of expression). g1 = BarChart[{1, 2, 3}, Axes -> {True, False}, BaselinePosition -> Axis, Ticks -> None, ImageSize -> 40]; g2 = BarChart[{-1, 2, -3}, BaselinePosition -> Axis, Axes -> {True, False}, Ticks -> None, ImageSize -> 40]; CirclePlus[g1, g2] The x axis of the bar charts are aligned with the baseline (approximately the bottom) of the CirclePlus symbol. Would it be possible to align the axes with the center line of the CirclePlus symbol without going into any Row constructions or modifying the CirclePlus expression? David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ === Subject: Re: problem with replace all and functions it can't work. Because when you Subscript[punto, i_][t_]:= Evaluate[{Subscript[x, i][t],Subscript[y, i][t]}/.sol3[[1]]] Evaluate[] it, i is a symbol and not 1,2,3, .. so the replacement can't find a pattern and will do nothing You need Subscript[punto, i_Integer][t_] := Subscript[punto, i][ t] = {Subscript[y, i][t], Subscript[y, i + 1][t]} /. sol3[[1]] Jens > I've a lot of rules created by NDSolve: {{Subscript[x, 1][t]->InterpolatingFunction[{{0.`,213.43887344465708`}}, > <>][t], > Subscript[y, 1][t]->InterpolatingFunction[{{0.`,213.43887344465708`}}, <>] > [t], > Subscript[x, 2][t]->InterpolatingFunction[{{0.`,213.43887344465708`}}, <>] > [t], > Subscript[y, 2][t]->InterpolatingFunction[{{0.`,213.43887344465708`}}, <>] > [t], > ... }} I have defined: Subscript[punto, 1][t_]:= > Evaluate[{Subscript[x, 1][t],Subscript[y, 1][t]}/.sol3[[1]]] Subscript[punto, 2][t_]:= > Evaluate[{Subscript[x, 2][t],Subscript[y, 2][t]}/.sol3[[1]]] Subscript[punto, 3][t_]:= > Evaluate[{Subscript[x, 3][t],Subscript[y, 3][t]}/.sol3[[1]]] > it works, but it's not very good, I've want something like this: Subscript[punto, i_][t_]:= > Evaluate[{Subscript[x, i][t],Subscript[y, i][t]}/.sol3[[1]]] but it doesn't work === Subject: getting data points instead of a plot in ListContourPlot ? Using Mathematica, I have determined the level zero of a 3D plot using ListContourPlot[ matrix , Contours -> {0}, ContourShading -> False ]. Now I would like to exploit these data instead of making a plot of it, namely I would like to get the couples of points corresponding to the level zeo of the 3D plot of matrix. Is there any way to force mathematica to give data instead of making a plot, i.e. to change the nature of the output from a plot to data points ? Or do you have any idea to get these ? === Subject: Re: Simplify Ignore my answer, please. Made a silly mistake On Apr 16, 10:16 am, Sjoerd C. de Vries for x and -1 for y. > Sjoerd can somebody explain, why Simplify[x^2/y^2,ComplexityFunction->LeafCount] does not simplify to (x/y)^2, although the LeafCount is: LeafCount[Hold[x^2/y^2]] gives 10 and LeafCount[Hold[(x/y)^2]] gives 8 Daniel === Subject: Re: Been doing real-time measurements with Mathematica! (Wii Balance Mathematica actually finds and reads quite a variety of controllers automatically (probably through the standard Windows game controller and HID APIs). This ranges from my son's gamepad to my tabletPC pen. I think you shouldn't be looking for Mathematica drivers but for the standard Windows drivers. > Anyone else find it a little limiting that one needs to virtualize > devices to a joystick before Mathematica can access it through > controller-state? Perhaps I've been looking in the wrong places, > but I'd very much appreciate documentation towards writing new Mathematic= a > drivers for unrecognized controllers. Barring that, anyone familiar with similar joystick virtualization > under mac os X? Best, JJ === Subject: Re: Strange Output!!!Please help me thank you. Combine both Reduces: Reduce[{Element[{i, j}, Integers], i <= iP, j >= jP, j + i == jP + = iP, Element[{n, iP}, Integers], Not[(iP < n)], Exists[{iPP}, (iPP < n) && iP == iPP + 1]}, {iP, jP}, Backsubstitution -> True] > Hi Mathematica community, > I have to solve this system: > Reduce[{Element[{i, j}, Integers], i <= iP, j >= jP, > 1*j + 1*i == 1*jP + 1*iP, > Reduce[{Element[{N, iP}, Integers], Not[(iP < N)], > Exists[{iPP}, (iPP < N) && iP == iPP + 1]}]}, {iP, jP}, > Backsubstitution -> True] the output should be:( i | j | N | iP) are Integers && i <= N && iP == = > N && > jP == i + j - N > but mathematica gave me this output: > (C[1] | C[2] | C[3] | C[4]) are Integers && C[1] >= 0 && > C[2] >= 0 && C[3] >= 0 && C[4] >= 0 && i == C[1] - C[2] - C[= 3] && > iP == C[1] - C[2] + C[4] && N == C[1] - C[2] + C[4] && > jP == j - C[3] - C[4] which is not understandable at all! and I dont want the output to be > like that. I have observed that when I remove i from Element[{i, j}, Integers] > mathematica give me the output I want and which is :iP == N && jP = == > i + j - N So how can I have this same output without removing i from Element[{i, > j}, Integers]? > === Subject: Re: Strange Output!!!Please help me thank you. may be you should stop to use N as a variable because N[] is the function to convert a analytic number into a floating point number. Jens > Hi Mathematica community, > I have to solve this system: > Reduce[{Element[{i, j}, Integers], i <= iP, j >= jP, > 1*j + 1*i == 1*jP + 1*iP, > Reduce[{Element[{N, iP}, Integers], Not[(iP < N)], > Exists[{iPP}, (iPP < N) && iP == iPP + 1]}]}, {iP, jP}, > Backsubstitution -> True] the output should be:( i | j | N | iP) are Integers && i <= N && iP == > N && > jP == i + j - N > but mathematica gave me this output: > (C[1] | C[2] | C[3] | C[4]) are Integers && C[1] >= 0 && > C[2] >= 0 && C[3] >= 0 && C[4] >= 0 && i == C[1] - C[2] - C[3] && > iP == C[1] - C[2] + C[4] && N == C[1] - C[2] + C[4] && > jP == j - C[3] - C[4] which is not understandable at all! and I dont want the output to be > like that. I have observed that when I remove i from Element[{i, j}, Integers] > mathematica give me the output I want and which is :iP == N && jP == > i + j - N So how can I have this same output without removing i from Element[{i, > j}, Integers]? === Subject: Re: Exporting animations The Export of AVIs can make use of the FrameRate option. Have you tried this? On Apr 16, 10:15 am, Hannes Kessler is there a possibility to adjust the animation rate or speed when > exporting a Manipulate / ControllerManipulate / Animate object with a > fixed number of plots to an .avi file? In Mathematica the > AnimationRate option of Animate works fine, but in the avi-player the > animation runs much too fast. Hannes Kessler === Subject: Re: tooltip - evaluate function at point Here is the start of one sort of approach. It seems ot have some bugginess though. But perhaps this will get you going: With[{plot = ContourPlot[Arg[Gamma[x + I*y]] == 0, {x, -10, 10}, {y, -10, 10}, PlotPoints -> 20]}, Dynamic@Tooltip[ plot, (With[{z = Complex @@ MousePosition[Graphics]}, {z, Gamma[z]}]) ] ] I suspect that someone else will give you a more stable approach.... --David On Apr 16, 4:18 am, Cristina Ballantine add a tooltip that evaluates a different function at the points on the > solution. In particular, for the plot ContourPlot[Arg[Gamma[x + I*y]] == 0, {x, -10, 10}, {y, -10, 10}, Plo= tPoints -> 20] when the cursor is over a solution point I would like the ToolTip to > display the value of Gamma at that point. Is this possible? If so, any > suggestion is greatly appreciated. Cristina === Subject: Re: tooltip - evaluate function at point > I would like to plot the solutions to an equation using ContourPlot and > add a tooltip that evaluates a different function at the points on the > solution. In particular, for the plot ContourPlot[Arg[Gamma[x + I*y]] == 0, {x, -10, 10}, {y, -10, 10}, PlotPoints -> 20] when the cursor is over a solution point I would like the ToolTip to > display the value of Gamma at that point. Is this possible? If so, any > suggestion is greatly appreciated. Cristina > Do you want something like this: ContourPlot[ Tooltip[Arg[Gamma[x + I y]] == 0, ToString[N[Gamma[x + I y]]]], {x, -10, 10}, {y, -10, 10}, PlotPoints -> 20] -- _________________________________________________________________ Peter Breitfeld, Bad Saulgau, Germany -- http://www.pBreitfeld.de === Subject: Re: FindRoot >Hi all, How can I to find the reals roots of a cubic equation in >simbolic form: For example, >Find the roots of x^3-4a^2x-2a^3==0 >where a is real and a>0. Solve[x^3 - 4 a^2 x - 2 a^3 == 0, x] === Subject: Passing arrays to MathLink without extra memory allocation When passing a list/array from mathematica to c using mathlink, eg when calling MLReleaseInteger32List(), it seems mathlink allocates some memory which later has to be freed, eg using MLReleaseInteger32List(). The question is, how is it possible to pass a list from mathematica to c without this c memory allocation? This example helps to make the question more clear: Assume MyFunction [BigList] to be a function implemented in c using mathlink, where BigList is a list of integers. Since BigList has been already created in mathematica and its corresponding memory has been allocated, we do not wish to allocate memory once again in c. It looks like one option is to pass BigList by reference, that is: SetProperties[MyFunction, HoldAll] In this case, does mathlink still allocate memory and copy BigList in the c side? === Subject: Re: Problems in plotting Lyapunov Exponents: you should read the manual about Compile. n and ndrop should be integer not complex numbers. Further you need to declare the complex list xlist. Here is a corrected version: > LypHS = Compile[{l, xinit, {n, _Integer}, {ndrop, _Integer}}, xlist = Drop[ NestList[-30000 l + (1 - l) # + l*(2858.16/(# - 500)^0.82) &, xinit, n] , ndrop + 1]; Apply[Plus, Log[Abs[(1 - l) - l (2343.71/(xlist - 500)^1.82)]]]/ Length[xlist] , {{xlist, _Complex, 1}}]; Plot[LypHS[l, 10, 5000, 100], {l, 0.0, 1.0}] > Daniel Hi > I have been trying to debug the following piece of code > to plot Lyapunov Exponents, but getting several errors. > -----------------------------------------------------------------------= ------------------------ > In[1]:=LypHS=Compile[{l, xinit, {n, _Complex}, {ndrop, _Complex}}, > xlist=Drop[ > NestList[-30000l+(1-l)#+l*(2858.16/(#-500)^0.82)&, = xinit, > n], > ndrop+1]; > Apply[Plus, Log[Abs[(1-l)-l(2343.71/(xlist-500)^1.82)]]]/ > Length[xlist]]; Plot[LypHS[l, 10, 5000, 100], {l, 0.0, 1.0}] > -----------------------------------------------------------------------= ------------------------ > Can anyone try to run it and help me to fix these errors ? > Or is any better code is possible for this problem ? > -----------------------------------------------------------------------= ------------------------ ---------------------------------------------------------------------------= ------------------------ === Subject: Re: Finding all n-partitions of a set Needs[Combinatorica`]; Union[Sort /@ KSetPartitions[{a, a, b, b}, 2]] {{{a}, {a, b, b}}, {{b}, {a, a, b}}, {{a, a}, {b, b}}, {{a, b}, {a, b}}} Bob Hanlon Please how can I find all n-partions of a set ? Say, i want partitions of the set (no order) {a,a,b,b} into 2, so we have { {{a,a,b,},{b}}, {{a,b,b},{a}}, {{a,a},{b,b}}, {{a,b},{a,b}} } is there already a built in function in mathematica ? i need so n can be any number === Subject: Re: Exporting animations is there a possibility to adjust the animation rate or speed when exporting a Manipulate / ControllerManipulate / Animate object with a fixed number of plots to an .avi file? In Mathematica the AnimationRate option of Animate works fine, but in the avi-player the animation runs much too fast. Hannes Kessler when exporting to a movie you can play with FrameRate option. Have a look here: http://forums.wolfram.com/mathgroup/archive/2008/Nov/msg00197.html for some further details. Success, 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: hyperlink problem in a ActionMenu function palette: Insert :> NotebookWrite[InputNotebook[], y], Wrap :> NotebookApply[InputNotebook[], RowBox[{y, [, [SelectionPlaceholder], ]}]], Info :> FrontEndExecute[ FrontEnd`FrontEndToken[ OpenHelpLink, {StringJoin[ref/, ToString[y]], Automatic}]] Note, OpenHelpLink is not documented. andrew === Subject: Re: Any way to make help browser remember the last position? Has it ever occurred to you that it you had any Mathematica expressions in TraditionalForm or even in StandardForm in a pdf, you would not be able to copy and paste them into Mathematica and get a useable Mathematica expression? For the majority of Mathematica users this loss completely outweighs all the (supposed) advantages that you list below. The fact is that the way you use Mathematica is very different from the way most users do (well, I guess I can't prove that, so let's say its very different from the way anyone I know uses Mathematica), which is why almost all your arguments are (and should be) completely ignored by both WRI and other users of this forum. Andrzej Kozlowski > What bugs me, no, drives me mad, is the fact that, every time I > press > F1 key to invoke the help or 'documentation center,' it goes > straight > to the center of the screen instead of to the right like it did v4 > and > 5. > jka replies: > I am very interested in what makes people mad. The Linux version of >> Mathematica 7.0.1.0 I use leaves the help browser in place as long as >> you don't close it. So an easy advise for your problem would be: >> don't >> close the help browser. If you want to hide using it, place an other >> window over it. > If the Help material (and other documentation) for Mathematica were > written and displayed in another app and format (like, for example, > Adobe PDF), as is the case with most other major applications, you > could > jump back and forth between your active Mathematica windows and your > currently active documentation window(s), leaving both of them > absolutely stable and unchanged in between viewings, with a single > keystroke, Cmd-Tab (on a Mac, anyway). Works like a charm; I do it all the time with other apps. And, > documentation in the form of a PDF file can be scanned, viewed, > searched, enlarged, read, and generally used _immensely_ more > effectively and easily in, say, Adobe Acrobat (or probably Reader, > though I don't use that) than documentation in Mathematica's cramped > and > awkward format. [Of course, one can only imagine what documentation for, say Excel, > would be like, if MS insisted that _all_ the documentation for Excel > also had to be _written_ only in Excel . . . ] [Did I add, that selected pages or sections of documentation in PDF > can > also be printed out, if you'd prefer to have a few particularly > relevant > pages of the documentation sitting on your (physical) desktop, beside > your keyboard -- where you can just glance over at it, without > having to > close or open anything on screen.] > === Subject: Re: Any way to make help browser remember the last > [...] > If the Help material (and other documentation) for Mathematica were > written and displayed in another app and format (like, for example, > Adobe PDF), as is the case with most other major applications, you could > jump back and forth between your active Mathematica windows and your > currently active documentation window(s), leaving both of them > absolutely stable and unchanged in between viewings, with a single > keystroke, Cmd-Tab (on a Mac, anyway). Works like a charm; I do it all the time with other apps. And, > documentation in the form of a PDF file can be scanned, viewed, > searched, enlarged, read, and generally used _immensely_ more > effectively and easily in, say, Adobe Acrobat (or probably Reader, > though I don't use that) than documentation in Mathematica's cramped and > awkward format. These other applications and their documentation display tools, how well do they handle input and evaluation of mathematical content? > [Of course, one can only imagine what documentation for, say Excel, > would be like, if MS insisted that _all_ the documentation for Excel > also had to be _written_ only in Excel . . . ] [Did I add, that selected pages or sections of documentation in PDF can > also be printed out, if you'd prefer to have a few particularly relevant > pages of the documentation sitting on your (physical) desktop, beside > your keyboard -- where you can just glance over at it, without having to > close or open anything on screen.] Last time I checked (which was today), one can still print Mathematica notebooks. This would apply to e.g. Help browser pages. In the Help browser notebooks one can also click on URLs to the corresponding (html) web pages, bring them up, print them, etc. Maybe not suitable for framing (unless you print on really good paper). But useful all the same. Daniel Lichtblau Wolfram Research === Subject: running mathematica notebooks without interface Hi mathematica people! I have a notebook with some heavy numerics which is supposed to produce several plots and output files. I have been recently granted access to a server with two quad-cores where mathematica 7.0 is installed, however I can access it only through some tedious ssh sessions (which can't be really called tunneling) and of course I will have troubles automatizing the ssh- tunnel. Since I would like to run a parallelized version of my code on this new machine.. the question is: how can I run the notebook in the remote computer (using shell commands such as math < notebook.nb I don't know) as if I was running them on the local machine with the graphic interface? in such a way that it loads the notebook, it evaluate cells and it saves it so that I can download it and open it on another machine to watch the plots and everything? thank you very much in advance, Davide === Subject: Re: FindRoot Hi Miguel, divide your equation by a^3 and solve for y=x/a: Reduce[y^3 - 4 y - 2 == 0, y] // N and you see that all 3 roots are real. Daniel > Hi all, > How can I to find the reals roots of a cubic equation in simbolic > form: For example, Find the roots of > x^3-4a^2x-2a^3==0 where a is real and a>0. === Subject: Re: FindRoot Solve[x^3 - 4 a^2 x - 2 a^3 == 0, x] ? but nobody can tell you which one is real. Jens > Hi all, > How can I to find the reals roots of a cubic equation in simbolic > form: For example, Find the roots of > x^3-4a^2x-2a^3==0 where a is real and a>0. === Subject: Re: Imaginary numbers - most interesting points That this subject [imaginary numbers] has hitherto been surrounded by mysterious obscurity, is to be attributed largely to an ill adapted notation. If, for example, +1, -1, and the square root of -1 had been called direct, inverse and lateral units, instead of positive, negative and imaginary (or even impossible), such an obscurity would have been out of the question. -Gauss Peter 2009/4/15 robert prince-wright I have (perhaps unwisely!) decided to do a 'Pecha Kucha' on imagination > .... or at least imaginary numbers. The audience are all engineers with hazy > recollection of undergrad maths. If you are not familiar with Pecha Kucha, then its worth checking Youtube > and doing some googling. Simplistically the concept is to share > understanding of something using 20 slides. Each slide should convey as much > as possible with as few words as possible, with the message limited to 20 > seconds! So, what is the most interesting thing about the imaginary number 'i' that > you can think of, and how can it most simply be conveyed using Mathematica 7 > in Slide presentation form? I've started with the notion of polynomial roots, de Moivre, reflections > etc. but would appreciate a wider view. R > -- Peter Lindsay === Subject: Re: Imaginary numbers - most interesting points its amazing to realise how bad maths teaching is. If you were taught how multiplying by 'i' is effectively a 90 degree rotation and that i squared added another 90 deg then Cauchy Riemann, stream and potential functions all make more sense... ________________________________ Cc: mathgroup@smc.vnet.net === Subject: Re: Imaginary numbers - most interesting points That this subject [imaginary numbers] has hitherto been surrounded by mysterious obscurity, is to be attributed largely to an ill adapted notation. If, for example, +1, -1, and the square root of -1 had been called direct, inverse and lateral units, instead of positive, negative and imaginary (or even impossible), such an obscurity would have been out of the question. -Gauss Peter 2009/4/15 robert prince-wright I have (perhaps unwisely!) decided to do a 'Pecha Kucha' on imagination .... or at least imaginary numbers. The audience are all engineers with hazy recollection of undergrad maths. If you are not familiar with Pecha Kucha, then its worth checking Youtube and doing some googling. Simplistically the concept is to share understanding of something using 20 slides. Each slide should convey as much as possible with as few words as possible, with the message limited to 20 seconds! So, what is the most interesting thing about the imaginary number 'i' that you can think of, and how can it most simply be conveyed using Mathematica 7 in Slide presentation form? I've started with the notion of polynomial roots, de Moivre, reflections etc. but would appreciate a wider view. R -- Peter Lindsay === Subject: Re: Should I be using Mathematica at all? hello Joseph, I see what you mean, your crucial words are in practice. I use a mac and linux and have no such problems. With Windows, especially if you are using visual studio or something [ ? ], I agree it is a nightmare to separate out the real C++ from the Microsoft obfuscation. 2009/4/16 Joseph Gwinn respectfully, I don't think this is quite right although I see what > you are getting at. C++ is platform independent and free, unless you > chose to tie yourself in to particular proprietary Libraries or IDEs. C++ in practice is not platform independent at all, unless one goes to > considerable effort to ensure independence. You put your finger right > on it when you mentioned particular proprietary Libraries or IDEs. On Windows in particular, it can be very difficult to avoid things like > ActiveX controls from creeping in and defeating portability and platform > independence. And forcing one onto the upgrade treadmill. C, being at least ten times simpler, has far less of this problem, but > even so vigilance is required. Joe Gwinn > 2009/4/14 Joseph Gwinn : > Hello again, >> I have had several questions answered by this group, for which I am > very >> grateful. Now I have a more general topic, which I know will not have >> single, clear answers. I just would like to hear your opinions. >> I have some (fairly complicated) legacy Mathematica v5 software which > we >> currently use in-house. Our intention is to turn this software into a >> saleable product. At the moment, I am contemplating upgrading to V7, > wri= > ting >> a GUI for our code (which has no compatibility issues with V7) and >> distributing it using PlayerPro. What is the nature of this product? >> To protect our IP, I will be using Encode to make it impossible for it > t= > o be >> reverse engineered. Does anyone know how secure this will actually be? > I= > s it >> more or less secure than a compiled C++ program would be, for > instance? = > Are >> there any particular issues I should be aware of? >> It turns out that there are some serious problems for us using > PlayerPro >> (apart from the price!) which are making us reconsider using > Mathematica= > at >> all. Top of the list is the inability of Wolfram to offer a trial > licens= > e >> for PlayerPro. What this would mean is that we would be losing 100 or > so >> every time someone ordered a trial version but did not subsequently > buy = > the >> package, because there is no way for us to get our PlayerPro license > bac= > k. >> This is not viable. The best Wolfram can offer is to give our > prospectiv= > e >> client a trial version of the full Mathematica package (say for 15 > days)= > . As >> a workaround, this is very clunky, when I requested my trial of V7 > it= > took >> 4 days to get the license. I think that, these days, people expect to > go= > to >> a website, download a trial version and start working with it > immediatel= > y. >> So, I am considering our options, in particular open source code, such > a= > s >> C++, and I'd be interested in your opinions about this. Our V5 code > does= > n't >> involve any exotic maths, but it makes extensive use of SetDelayed, > and >> these definitions are frequently nested within long and complicated Do >> loops. Speed is crucial to our application, so is there any, in > principl= > e, >> reason why Mathematica might be able to do things significantly faster > t= > han >> a compiled C++ program (assuming the C++ code is written by someone > who >> knows what they are doing)? Is there a better language than C++, > bearing= > in >> mind the need to compile (or encode in some way) and distribute the >> resulting code? I know there used to be a compiler for Mathematica > once = > upon >> a time, is there any easy way to get from mathematica code to a > compilab= > le >> program. I should stress that we are very happy with Mathematica in > term= > s of >> developing our application, it's just generating anything that we > could = > sell >> that is problematical. >> I have some experience of writing VB, Visual C and similar > applications,= > but >> these never had a large graphical content. Our code will require a lot > o= > f >> plotting of data (2D only, but lots of curves which need to be > interacti= > ve >> in some sense). Mathematica can do everything we want in this respect, > b= > ut I >> am less sure about the open source code. I am sure there are add-on >> packages, but never having used them I don't know whether they can > match >> Mathematica's built in abilities, any comments? The big issue with translation to C++ or any other language to to avoid > lock-in to either Windows or to the compiler make and model. If > lock-i= > n > is permitted, especially to Windows, every time MS burps you will be > forced to play catch-up. While C++ is in theory standardized, there > ar= > e > significant differences in what C++ compilers will accept. Use of the > = > C > subset of C++ is usually far less stressful, and allows for graceful > transition should the compiler vendor go to find his guru. Platform independence also helps when negotiating with platform and > compiler vendors. To avoid lock-in, one must do all testing on at least two platform > kinds > using compilers from at least two makers. It isn't enough to make > platform independence a goal, one must directly test for independence, > as its very easy for dependencies to creep in unnoticed. Choice of platforms: If one covers Windows, MacOS, and UNIX/Linux, one > has covered 99%. Going from one platform to two is the big step. > Adding the third isn't that much harder to achieve, although testing is > still an expense. Joe Gwinn -- > Peter Lindsay -- Peter Lindsay === Subject: Re: FindRoot eqn = x^3 - 4 a^2 x - 2 a^3 == 0; r = Simplify[x /. Solve[eqn, x], a > 0] {((4*3^(1/3) + (9 + I*Sqrt[111])^ (2/3))*a)/(3^(2/3)* (9 + I*Sqrt[111])^(1/3)), (I*(-12 + 4*I*Sqrt[3] + I*3^(1/6)*(9 + I*Sqrt[111])^ (2/3) + (27 + 3*I*Sqrt[111])^ (2/3))*a)/(2*3^(5/6)* (9 + I*Sqrt[111])^(1/3)), ((12*I - 4*Sqrt[3] - 3^(1/6)*(9 + I*Sqrt[111])^ (2/3) - I*(27 + 3*I*Sqrt[111])^(2/3))* a)/(2*3^(5/6)*(9 + I*Sqrt[111])^ (1/3))} Plot[r, {a, 0, 5}] Bob Hanlon Hi all, How can I to find the reals roots of a cubic equation in simbolic form: For example, Find the roots of x^3-4a^2x-2a^3==0 where a is real and a>0. === Subject: Axes in 3D? I'm using Mathematica 7.0 and would like to put the axes at the origin in a 3D graph instead of showing them on a bounding box. I have the 3D-Axes.nb (found on http://library.wolfram.com/infocenter/MathSource/528/ ) but would like a source that can determine the ranges automatically. This seems like an obvious option for any 3D plot--especially since version 7.0 seems to be very receptive to making things look just like students would expect to see them. HHulett === Subject: Re: Finding all n-partitions of a set Your question seems unclear. After all, mathematically, the SET {a,a,b,b} actually is identical to the set {a,b}. What you seem to have is some base set, in this case, {a,b}, along with a specified frequency for each member of the set, in this case a frequency of 2 for each of the two elements. Moreover, if there is no order implicit here, then why would you not also expect in the output some additional two-member non-empty lists, e.g., the following: { {b,b}, {a,a} } { {b,a}, {b,a} } > Please how can I find all n-partions of a set ? > Say, i want partitions of the set (no order) {a,a,b,b} into 2, so we have > { > {{a,a,b,},{b}}, > {{a,b,b},{a}}, > {{a,a},{b,b}}, > {{a,b},{a,b}} > } is there already a built in function in mathematica ? i need so n can be any number > -- 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: Finding all n-partitions of a set Hi Joe, You can load the DiscreteMath`Combinatorica` package (or, just Combinatorica`, in v.6.0+). In[1] = < Please how can I find all n-partions of a set ? > Say, i want partitions of the set (no order) {a,a,b,b} into 2, so we have > { > {{a,a,b,},{b}}, > {{a,b,b},{a}}, > {{a,a},{b,b}}, > {{a,b},{a,b}} > } is there already a built in function in mathematica ? i need so n can be any number === Subject: Re: Finding all n-partitions of a set My previous message was truncated. Joe, you are requesting the n-partitions of a set but {a,a,b,b} isn't a set. Look at the built in functions Subsets and ReplaceList In[1]:= ReplaceList[{a, a, b, b}, {x__, y__} :> {{x}, {y}}] Out[1]= {{{a}, {a, b, b}}, {{a, a}, {b, b}}, {{a, a, b}, {b}}} Adriano Pascoletti 2009/4/16 Joe.Mapasapam Say, i want partitions of the set (no order) {a,a,b,b} into 2, so we have > { > {{a,a,b,},{b}}, > {{a,b,b},{a}}, > {{a,a},{b,b}}, > {{a,b},{a,b}} > } is there already a built in function in mathematica ? i need so n can be any number === Subject: Re: Finding all n-partitions of a set In[1]:= ReplaceList[{a, a, b, b}, {x__, y__} :> {{x}, {y}}] Out[1]= {{{a}, {a, b, b}}, {{a, a}, {b, b}}, {{a, a, b}, {b}}} Adriano Pascoletti 2009/4/16 Joe.Mapasapam Say, i want partitions of the set (no order) {a,a,b,b} into 2, so we have > { > {{a,a,b,},{b}}, > {{a,b,b},{a}}, > {{a,a},{b,b}}, > {{a,b},{a,b}} > } is there already a built in function in mathematica ? i need so n can be any number === Subject: Scaling a part of a composite image In an image composed of at least two (or more) parts combined using Show, I would like to programmatically scale one of these two images with respect to the size of the whole composite image. Do you know, how to do this in Mathematica 6? Is it possible in Mathematica 6 to determine programmatically the total size of the Image? To be more concrete: the function below draws a 3D trajectory - a solution of a system of three ODE. In addition it draws a triangle attached to the trajectory. The latter plays the role of an arrow head showing the direction of the trajectory. Parameters in the argument are: point is a list of initial values {x0,y0,z0} of the trajectory, tmax is the calculation time, col is the color of both the trajectory and the arrow head, arrpos is the time fixing the position of the arrow on the trajectory, and arrsize scales the arrow size. The subfunction arr defines the arrow using 2 closely-lying points taken on the trajectory. directedTrajectory3D[point_List, tmax_, col_, arrpos_, arrsize_] := Module[{p0, eq4, eq5, eq6, pt1, pt2, s}, arr[pt1_List, pt2_List] := Module[{r}, r = (pt1 - pt2)2 /. List -> Plus // Sqrt; Graphics3D[ {col, Polygon[{pt1, {pt2[[1]], pt2[[2]] - 0.2*r, pt2[[3]] - 0.2*r}, {pt2[[1]], pt2[[2]] + 0.3*r, pt2[[3]] + 0.2*r} }]}]]; eq4 = x[0] == point[[1]]; eq5 = y[0] == point[[2]]; eq6 = z[0] == point[[3]]; s = NDSolve[{eq1, eq2, eq3, eq4, eq5, eq6}, {x, y, z}, {t, 0, tmax}]; p0 = ParametricPlot3D[ Evaluate[{x[t], y[t], z[t]} /. s], {t, 0, 30}, PlotRange -> All, PlotStyle -> col, AxesLabel -> {x, y, z}]; Show[{p0, arr[Evaluate[{x[arrpos], y[arrpos], z[arrpos]} /. s] // Flatten, Evaluate[{x[arrpos - 0.5*arrsize], y[arrpos - 0.5*arrsize], z[arrpos - 0.5*arrsize]}] /. s // Flatten]}] ]; One can try with the example of Lorentz system from help: Clear[eq1, eq2, eq3]; eq1 = !(*SuperscriptBox[x, [Prime], MultilineFunction->None])[t] == -3 (x[t] - y[t]); eq2 = !(*SuperscriptBox[y, [Prime], MultilineFunction->None])[t] == -x[t] z[t] + 26.5 x[t] - y[t]; eq3 = !(*SuperscriptBox[z, [Prime], MultilineFunction->None])[t] == x[t] y[t] - z[t]; directedTrajectory3D[{1, 0, 1}, 30, Red, 5, 0.1] A strong drawback is that in this function one needs to rescale the arrow sizes by hand each time. Compare two images with the same trajectory in which the arrow is placed the first time at t=5 and then at t=15 with the same arrsize=0.1. directedTrajectory3D[{1, 0, 1}, 30, Red, 5, 0.1] directedTrajectory3D[{1, 0, 1}, 30, Red, 15, 0.1] I would like to find a programmatic way of scaling the arrows so that they would be always visible and the same size. -- 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: Mathematica 7 power consumption on Linux Recently I was playing around with Intel's powertop utility and noticed that Mathematica causes a significant number of CPU wakeups from idle. For example, a completely idle Linux Gnome desktop without any additional applications running causes ~ 15 wakeups from idle per second. When Mathematica is running, powertop reports ~ 14.000 wakeups! Thus, when Mathematica is running the CPU remains in the C2 power saving state for a considerable time, instead of switching to the C4 or C6 power saving modes. These are the results reported by Intel's powertop: Mathematica running, on AC power: http://omploader.org/vMWsxZw Mathematica running, on battery: http://omploader.org/vMWsxaA No Mathematica running, on battery: http://omploader.org/vMWsxaQ As you can image, failure to switch to C6 power state significantly reduces battery runtime. I tested this on my ThinkPad X200 with Linux x86_64 and Kernel 2.6.29 (wireless turned off, screen brightness at 50%, no screen dimming, blank screens, screen savers, etc.): Idle desktop, no applications running: ~ 5h 15min Idle desktop, Mathematica 7.0.1 running (one empty notebook): ~ 3h 20min Has anyone else noticed this behavior? So far Mathematica is the only application I've encountered which keeps the CPU in C2 state for a considerable time, and I don't understand why this is the case. Is there anything I can do about this (such as modifying the kernel configuration)? Richard === Subject: Re: Mathematica 7.0.1 system load when idleing so, after a lot of testing, I have finally found out that this problem is related to my installation of the OpenVPN client. After upgrading to the latest version of OpenVPN (not hiding the TAP Ethernet adapter), the system load of Mathematica is indeed 0% when it's idleing. === Subject: converting binary data How can we convert the binary data (with the extension .z or .3z) to another format like ASCII or netcdf or .dat to be able to plot thses data in Mathematica 6? Pasha === Subject: Re: converting binary data no Mathematica con only uncompress ZIP,GZIP,TAR, BZIP2 formats but *.Z is the standard unix compress and any unix box should ba able to decompress it. Jens How can we convert the binary data (with the extension .z or .3z) to > another format like ASCII or netcdf or .dat to be able to plot thses data > in Mathematica 6? > Pasha === Subject: Re: converting binary data Hi Pashs, ...z files are compressed TAR files from Unix. Therefore, you first need to uncompress it using e.g. the Unix utility uncompress. Then you may import it into mathematica using Import. But as a ...z file may contain all sort of different files you should at least have an idea what files you have. As far as I know, ...3z files are created by WinAmp. Daniel How can we convert the binary data (with the extension .z or .3z) to > another format like ASCII or netcdf or .dat to be able to plot thses data > in Mathematica 6? > Pasha === Subject: Application GUI in Mathematica Hello everyone, I would have the following question: Is there a way how to construct a window with panes, buttons, charts, checkboxes, listboxes, etc. in Mathematica? All I have found are separate components which are rendered into a notebook but nothing else. There is a way how to display a window (again, with a notebook inside) and a dialog box but that's it. I could not find any example putting all the bits and pieces together. Mirek ___ Information from ESET Mail Security, ver. 4025 (20090421) ___ The message was checked by ESET Mail Security. www.eset.com === Subject: Re: Application GUI in Mathematica > I would have the following question: Is there a way how to construct a window with panes, buttons, charts, checkboxes, listboxes, etc. in Mathematica? yes, and it is easy, too... > All I have found are separate components which are rendered into a notebook but nothing else. There is a way how to > display a window (again, with a notebook inside) and a dialog box but that's it. that is because there is essentially no difference between a notebook and another window. There are helper functions like CreateDialog, but actually they just create notebook-windows with some of the many options of Notebook set to specific values, so the windows look and behave differently. > I could not find any example putting all the bits and pieces together. try this: CreateDialog[DynamicModule[{f = Sin}, Grid[{ {PopupMenu[Dynamic[f], {Sin, Cos, Exp, Log, Tan}], Panel[Dynamic@Plot[f[x], {x, 0, 1}, Background -> White, Frame -> True, ImageSize -> 400]]}, {, Manipulate[ Plot[Sin[n x], {x, 0, 2 [Pi]}, Frame -> True, ImageSize -> 400], {n, 0, 1}, AppearanceElements -> None ]}, }]]] hth, albert === Subject: Re: Application GUI in Mathematica Hi Miroslav, note that a Notebook IS a window. You may create a notebook programaticalmly using native mathematica commands or you may use GUI kit with an additional language. Here is an example using native commands: CreateDocument[ {Grid[{{Button[Button1], Text[This is some text.]}, {Pane[Pane1], PieChart3D[{1, 2, 3, 4}]}, {Checkbox[False], Checkbox[True]}} ] , Button[Close, NotebookClose[]] } , WindowSize -> {350, 250} ] Daniel > Hello everyone, I would have the following question: Is there a way how to construct a window with panes, buttons, charts, checkboxes, listboxes, etc. in Mathematica? All I have found are separate components which are rendered into a notebook but nothing else. There is a way how to > display a window (again, with a notebook inside) and a dialog box but that's it. I could not find any example putting all the bits and pieces together. > Mirek > ___ Information from ESET Mail Security, ver. 4025 (20090421) ___ > The message was checked by ESET Mail Security. www.eset.com > === Subject: How to get values from Manipulate Hi guys, just a simple question related to Manipulate[] - is there a way how to access the values set by slider in Manipulate? For example, I have the following code: m = Manipulate[ ListLinePlot[{ data, {{xmin, 0}, {xmin, 100}} }], {xmin, 1, 10} ] and after the user sets a value 'xmin', I would like to read it out. How? Mirek ___ Information from ESET Mail Security, ver. 4025 (20090421) ___ The message was checked by ESET Mail Security. www.eset.com === Subject: Re: How to get values from Manipulate > just a simple question related to Manipulate[] - is there a way how to access the values set by slider in Manipulate? For example, I have the following code: m = Manipulate[ > ListLinePlot[{ > data, > {{xmin, 0}, {xmin, 100}} > }], > {xmin, 1, 10} > ] and after the user sets a value 'xmin', I would like to read it out. How? It really depends on what you want to achieve, but the most simple solution is to just set a global variable within the Manipulate: Manipulate[ parameter1 = n; Plot[Sin[n x], {x, 0, 2 [Pi]}, Frame -> True, ImageSize -> 400], {n, 0, 1}, ] whenever you now access parameter1 it will have the value that is shown in Manipulate. To refer to your other question, you can also make e.g. a modal dialog which returns that value like so: newvalue = DialogInput[DynamicModule[{parameter1 = 0}, Column[{ Manipulate[ parameter1 = n; Plot[Sin[n x], {x, 0, 2 [Pi]}, Frame -> True, ImageSize -> 400] , {n, 0, 1}, AppearanceElements -> None ], Button[OK, DialogReturn[parameter1]] }]] ] hth, albert === Subject: Re: How to get values from Manipulate simply set some global variable to xmin. >E.g.: Manipulate[t = xmin; ListLinePlot[{1, 3, 2, 3, 2}, Epilog -> Line[{{xmin, 0}, {xmin, 5}}]], {xmin, 1, 3}] > Hi guys, just a simple question related to Manipulate[] - is there a way how to access the values set by slider in Manipulate? For example, I have the following code: m = Manipulate[ > ListLinePlot[{ > data, > {{xmin, 0}, {xmin, 100}} > }], > {xmin, 1, 10} > ] and after the user sets a value 'xmin', I would like to read it out. How? > Mirek > ___ Information from ESET Mail Security, ver. 4025 (20090421) ___ > The message was checked by ESET Mail Security. www.eset.com > === Subject: Re: How to get values from Manipulate Manipulate[m = xmin; ListLinePlot[{data, {{xmin, 0}, {xmin, 100}}}], {xmin, 1, 10}] and Dynamic[m] will show you that m is update when you change it in Manipulate[]. Jens > Hi guys, just a simple question related to Manipulate[] - is there a way how to access the values set by slider in Manipulate? For example, I have the following code: m = Manipulate[ > ListLinePlot[{ > data, > {{xmin, 0}, {xmin, 100}} > }], > {xmin, 1, 10} > ] and after the user sets a value 'xmin', I would like to read it out. How? > Mirek > ___ Information from ESET Mail Security, ver. 4025 (20090421) ___ > The message was checked by ESET Mail Security. www.eset.com > === Subject: Using the slider values in a Manipulate How can I use the values adjusted with the sliders in a Manipulate later in the notebook? The only way seems to be the DynamicModule, but that's not exactly what I want. To be more specific: I'm trying to write a notebook for fitting a model function to experimental data, and I want it to be reusable since I'll have to use it on different data files again and again. I want to plot the data and the model inside a Manipulate, and use the sliders to adjust reasonable startig values for my parameters. That does work very well, but the next step would be to insert these starting values (from the slider adjustments) as starting values in FindFit. How do I achieve this? I don't understand how I could use DynamicModule to do this, but what other options do I have. === Subject: Re: Using the slider values in a Manipulate > How can I use the values adjusted with the sliders in a Manipulate > later in the notebook? > The only way seems to be the DynamicModule, but that's not exactly > what I want. > To be more specific: I'm trying to write a notebook for fitting a > model function to experimental data, and I want it to be reusable > since I'll have to use it on different data files again and again. > I want to plot the data and the model inside a Manipulate, and use the > sliders to adjust reasonable startig values for my parameters. That > does work very well, but the next step would be to insert these > starting values (from the slider adjustments) as starting values in > FindFit. How do I achieve this? I don't understand how I could use > DynamicModule to do this, but what other options do I have. there was another post just today which asks exactly the same thing, so you might want to check that thread for solutions, too. Here is a short answer: Manipulate[ parameter1 = n; Plot[Sin[n x], {x, 0, 2 [Pi]}, Frame -> True, ImageSize -> 400] , {n, 0, 1} ] you can just set a global variable within the Manipulate body and use that in the rest of the notebook... hth, albert === Subject: Has Fourier been fixed in Mathematica 7 I am interested in upgrading to Mathematica 7 in order to support our Mathematica Add-On for time-frequency analysis: http://www.ffconsultancy.com/products/CWT/index.html?mma I tried an early version of Mathematica 7 and it was quite fragile due to a bug in the Fourier routine. Is there a new release of Mathematica 7 that fixes this and, if so, are there any remaining issues with Fourier? -- Dr Jon D Harrop, Flying Frog Consultancy Ltd. http://www.ffconsultancy.com/?u === Subject: Re: Help with Speeding up a For loop The following code does 10 million iterations in 4 minutes: Ideal = ConstantArray[0, n + 1]; Resolution = ConstantArray[0, n + 1]; For[i = 0, i < n, i++, If[k[[i]] < Re[(E0 - Eb1[[i]])^2*Sqrt[1 - m^2/(E0 - Eb1[[i]])^2]], Eb1[[i]] = RandomReal[NormalDistribution[(Ideal[[i + 1]] = Eb1[[i]]), Sigma]]; Resolution[[i + 1]] = Eb1[[i]] ]; ] It can be sped up even more, but I think this meets your requirements. > I am using an Intel MacBook with OS X 10.5.6. I am trying to create 2 lists: Ideal and Resolution. This is basic= ally > a Monte Carlo Integration technique. Ideal should simulate the curve. > Resolution should simulate the curve convoluted with a normal distributio= n. > I want to do this for n=10 000 000 or more, but it takes far too long r= ight > now. I can do n=100 000 in about 1 minute, but 1 000 000 takes more tha= n an > hour. I haven't waited long enough for 10 000 000 to finish (it has been = 5 > days). Adam Dally Here is the code: ClearAll[E0, Eb1, m, DeltaE, Sigma, k, n, y3, Ideal, Resolution, i, > normalizer, maxE, minE] > Eb1 = 0; k = 0; n = 10000; E0 = 2470; m = 0.2; DeltaE = 50; S= igma = 5; maxE > = E0 - m; minE = E0 - DeltaE; Resolution = {Eb1}; Ideal = {Eb1}; = (*Setup > all constants, lists and ranges*) Eb1 = RandomReal[{minE, maxE}, n]; (*create a list of 'n' random Eb1 > values*) > k = -RandomReal[TriangularDistribution[{-2470, 0}, -0.1], n]; (*create = a > list of 'n' random k values; triangle distribution gives more successful > results*) For[i = 0, i < n, i++, If[k[[i]] < Re[(E0 - Eb1[[i]])^2*Sqrt[1 - m^2/(E0 - Eb1[[i]])^2]], (*c= heck > if the {k,Eb1} value is under the curve*) > AppendTo[Ideal, Eb1[[i]]]; (*Keep events under curve in 'Id= eal'*) > y3 = Eb1[[i]]; (*cast element to a number*) > Eb1[[i]] = RandomReal[NormalDistribution[y3, Sigma], 1]; (*c= hoose a > random number from a normal distribution about that point*) > AppendTo[Resolution, Eb1[[i]]]; ]] (*Keep that event in 'Resol= ution'*) === Subject: Re: Help with Speeding up a For loop > I am using an Intel MacBook with OS X 10.5.6. I am trying to create 2 lists: Ideal and Resolution. This is basically > a Monte Carlo Integration technique. Ideal should simulate the curve. > Resolution should simulate the curve convoluted with a normal distribution. > I want to do this for n=10 000 000 or more, but it takes far too long right > now. I can do n=100 000 in about 1 minute, but 1 000 000 takes more than an > hour. I haven't waited long enough for 10 000 000 to finish (it has been 5 > days). Adam Dally Here is the code: ClearAll[E0, Eb1, m, DeltaE, Sigma, k, n, y3, Ideal, Resolution, i, > normalizer, maxE, minE] > Eb1 = 0; k = 0; n = 10000; E0 = 2470; m = 0.2; DeltaE = 50; Sigma = 5; maxE > = E0 - m; minE = E0 - DeltaE; Resolution = {Eb1}; Ideal = {Eb1}; (*Setup > all constants, lists and ranges*) Eb1 = RandomReal[{minE, maxE}, n]; (*create a list of 'n' random Eb1 > values*) > k = -RandomReal[TriangularDistribution[{-2470, 0}, -0.1], n]; (*create a > list of 'n' random k values; triangle distribution gives more successful > results*) For[i = 0, i < n, i++, If[k[[i]] < Re[(E0 - Eb1[[i]])^2*Sqrt[1 - m^2/(E0 - Eb1[[i]])^2]], (*check > if the {k,Eb1} value is under the curve*) > AppendTo[Ideal, Eb1[[i]]]; (*Keep events under curve in 'Ideal'*) > y3 = Eb1[[i]]; (*cast element to a number*) > Eb1[[i]] = RandomReal[NormalDistribution[y3, Sigma], 1]; (*choose a > random number from a normal distribution about that point*) > AppendTo[Resolution, Eb1[[i]]]; ]] (*Keep that event in 'Resolution'*) > Best to avoid AppendTo for large list constructions (it will give quadratic complexity). Instead use either Sow/Reap or list nesting followed by Flatten. In this particular example, one can also just preinitialize arrays to full length, change elements as needed, and remove the extras before returning. The code below does this and uses Compile, hence is fairly fast. randomRealNormal[eb1j_,sigma_] := RandomReal[NormalDistribution[eb1j,sigma]] randomRealTriangular[lo_,hi_,max_,n_] := RandomReal[TriangularDistribution[{lo,hi},max], n] fTriangle = Compile[{{n,_Integer}}, Module[ {ideal, resolution, eb1, e0=2470., m=.2, deltaE=50., sigma=5., maxE, minE, kvec, i=1, eb1j, eminus}, {maxE,minE} = e0-{m,deltaE}; ideal = Table[0.,{n}]; resolution = Table[0.,{n}]; eb1 = RandomReal[{minE,maxE}, n]; kvec = -randomRealTriangular[-e0, 0., -.1, n]; Do [ eb1j = eb1[[j]]; eminus = (e0 - eb1j)^2; If [kvec[[j]] < eminus*Sqrt[1-m^2/eminus], i++; ideal[[i]] = eb1j; eb1j = randomRealNormal[eb1j,sigma]; resolution[[i]] = eb1j; ]; , {j,n}]; ideal = Take[ideal,i]; resolution = Take[resolution,i]; {ideal,resolution} ], {{randomRealTriangular[___], _Real, 1}, {randomRealNormal[___], _Real} }]; In[9]:= Timing[{id,res} = fTriangle[10^7];] Out[9]= {45.857, Null} Daniel Lichtblau Wolfram Research === Subject: Re: Help with Speeding up a For loop > I am using an Intel MacBook with OS X 10.5.6. I am trying to create 2 lists: Ideal and Resolution. This is basically > a Monte Carlo Integration technique. Ideal should simulate the curve. > Resolution should simulate the curve convoluted with a normal distribution. > I want to do this for n=10 000 000 or more, but it takes far too long right > now. I can do n=100 000 in about 1 minute, but 1 000 000 takes more than an > hour. I haven't waited long enough for 10 000 000 to finish (it has been 5 > days). Adam Dally Here is the code: ClearAll[E0, Eb1, m, DeltaE, Sigma, k, n, y3, Ideal, Resolution, i, > normalizer, maxE, minE] > Eb1 = 0; k = 0; n = 10000; E0 = 2470; m = 0.2; DeltaE = 50; Sigma = 5; maxE > = E0 - m; minE = E0 - DeltaE; Resolution = {Eb1}; Ideal = {Eb1}; (*Setup > all constants, lists and ranges*) Eb1 = RandomReal[{minE, maxE}, n]; (*create a list of 'n' random Eb1 > values*) > k = -RandomReal[TriangularDistribution[{-2470, 0}, -0.1], n]; (*create a > list of 'n' random k values; triangle distribution gives more successful > results*) For[i = 0, i < n, i++, If[k[[i]] < Re[(E0 - Eb1[[i]])^2*Sqrt[1 - m^2/(E0 - Eb1[[i]])^2]], (*check > if the {k,Eb1} value is under the curve*) > AppendTo[Ideal, Eb1[[i]]]; (*Keep events under curve in 'Ideal'*) > y3 = Eb1[[i]]; (*cast element to a number*) > Eb1[[i]] = RandomReal[NormalDistribution[y3, Sigma], 1]; (*choose a > random number from a normal distribution about that point*) > AppendTo[Resolution, Eb1[[i]]]; ]] (*Keep that event in 'Resolution'*) > This can certainly be sped up (the biggest problem is that AppendTo has linear complexity, the larger the list, the longer appending takes. Use Sow/Reap for collecting results). But I don't see a reason for speeding up the Mathematica version of the program. The program looks like as if it were translated from C/Java or some similar language. So implement it in one of these languages. I think that it is a waste of time waiting 5 days for Mathematica when you are not using any of the built in special algorithms. There are plenty of C/C++/Java/Fortran libraries for drawing random numbers from a normal/triangular distribution (but implementing the algorithms for it yourself takes much less than 5 days too). === Subject: Re: Help with Speeding up a For loop Hi Adam, I have a number of comments on your code, which will hopefully clarify the main sources of confusion and inefficiency. Here is the version of your code which I modified somewhat. The function is introduced for convenience, to be able to perform these operations many times, with different number of points. Same with . I also changed the names Ideal -> IdealLoop, Resolution -> ResolutionLoop. In[1] = initialize[num_Integer?Positive] := Module[{}, Eb1 = 0; k = 0; n = num; E0 = 2470; m = 0.2; DeltaE = 50; Sigma = 5; maxE = E0 - m; minE = E0 - DeltaE; (*Setup all constants,lists and ranges*) Eb1 = RandomReal[{minE, maxE}, n];(*create a list of'n' random Eb1 values*) k = -RandomReal[TriangularDistribution[{-2470, 0}, -0.1], n]; ]; In[2] = runSimpleLoop[] := Block[{Eb1 = Eb1, k = k, y3}, ResolutionLoop = {}; IdealLoop = {}; For[i = 1, i <= n, i++, If[k[[i]] < Re[(E0 - Eb1[[i]])^2* Sqrt[1 - m^2/(E0 - Eb1[[i]])^2]],(*check if the {k, Eb1} value is under the curve*) AppendTo[IdealLoop, Eb1[[i]]];(*Keep events under curve in'Ideal'*) y3 = Eb1[[i]];(*cast element to a number*) Eb1[[i]] = First@RandomReal[NormalDistribution[y3, Sigma], 1];(*choose a random number from a normal distribution about that point*) AppendTo[ResolutionLoop, Eb1[[i]]];]] ](*Keep that event in'Resolution'*) Comments so far: These reflect changes in the code above compared to your original version: 1. You place in your lists Resolution and Ideal 0 to start with. This is not correct, since this point does not belong there. Start with {} instead. 2. This is not C, array index starts from 1, not 0 3. Try to avoid side effects and stay away from global variables. They make life harder. Block[{Eb1 = Eb1}, loop ] makes Eb1 dynamically local while produces the same end result. (Generally, use Module, not Block - I just wanted to keep the code as much close to yours as possible. 4. RandomReal[..., 1] produces a number wrapped in a list. You don' t need that - take First of that list. These two are not dealt with so far: 5. Redundancy of y3. 6. No need to change Eb1 in place. Now, the reason your code is slow: the main culprit of your implementation is AppendTo. Avoid it in loops at all costs - leads to quadratic in the size of the list complexity. Use Reap - Sow if you insist on using loops at all. Below is the code that uses Reap - Sow: In[3] = runLoopWithReapSow[] := Block[{Eb1 = Eb1, k = k, y3}, Reap[For[i = 1, i <= n, i++, y3 = Eb1[[i]]; If[k[[i]] < Re[(E0 - y3)^2*Sqrt[1 - m^2/(E0 - y3)^2]], Sow[y3, ideal]; Sow[First@RandomReal[NormalDistribution[y3, Sigma], 1], resolution]; ]], _, List][[2]]]; This loop produces the result - the lists of interest combined together, with the string tags: ideal and resolution. The names of the labels (tags) are completely arbitrary, I could even use just numbers 0 and 1 for them. Let us look at a simple example: In[4] = initialize[20]; runSimpleLoop[]; In[5] = IdealLoop Out[5] = {2431.1, 2442.78, 2445.85, 2447.74, 2429.49, 2448.45, 2434.79, 2425.95}; In[6] = ResolutionLoop Out[6] = {2436.17, 2443.8, 2432.54, 2433.07, 2420.16, 2439.93, 2418.47, 2423.48, 2436.35} In[7] = runLoopWithReapSow[] Out[7] = {{ideal, {2431.1, 2442.78, 2445.85, 2447.74, 2429.49, 2448.45, 2434.79, 2425.95}}, {resolution, {2433.86, 2443.81, 2446.62, 2450.4, 2426.98, 2442.91, 2436.05, 2436.48}}} We only can compare the part - it is of course the same. Now, the timing test: In[8] = initialize[10000]; Print[runSimpleLoop[]; // Timing]; Print[newResult = runLoopWithReapSow[]; // Timing]; {IdealLoopNew, ResolutionLoopNew} = Part[newResult, All, 2]; {8.893,Null} {0.892,Null} Already here we get a 10-times speed-up. The results for Ideal are, of course, the same: In[9] = IdealLoopNew == IdealLoop Out[9]= True Finally, let me show you a more idiomatic way to approach your problem, where we will vectorize it and get rid of loop at all: In[10] = (Ideal = Pick[Eb1, (Re[(E0 - Eb1)^2*Sqrt[1 - m^2/(E0 - Eb1)^2]] - k) /. _?Positive :> True]; Resolution = Map[RandomReal[NormalDistribution[#, Sigma], 1] &, Ideal];) // Timing {0.21, Null} In[11] = IdealLoopNew == Ideal Out[11] = True We got another 4-fold speedup, AND we don't need explicit loops, with all the garbage associated with them. Basically, this code first selects all points in Eb1 that are below the curve, and then computes the Resolution vector on these points only. Perhaps, wise use of Compile could further speed it up somewhat (2-4 times, my guess). Anyway, this code gets you 10000 points in 0.2 seconds (on my 5 years old PIV 1.8 Ghz single core), should be probably good enough for you. If you need around 10 000 000 or more, watch out for the memory usage - you may be better off doing some binning as the program runs, by splitting this large number into sycles of smaller lengths. As to the programming, try to avoid loops in Mathematica, and also global variables - even those you use in initialization can be made local to only the function(s) that need them. Generally, for anything longer than a couple of lines, try to write functions whose bodies only contain system symbols and formal parameters. Leonid > I am using an Intel MacBook with OS X 10.5.6. I am trying to create 2 lists: Ideal and Resolution. This is basically > a Monte Carlo Integration technique. Ideal should simulate the curve. > Resolution should simulate the curve convoluted with a normal distribution. > I want to do this for n=10 000 000 or more, but it takes far too long right > now. I can do n=100 000 in about 1 minute, but 1 000 000 takes more than an > hour. I haven't waited long enough for 10 000 000 to finish (it has been 5 > days). Adam Dally Here is the code: ClearAll[E0, Eb1, m, DeltaE, Sigma, k, n, y3, Ideal, Resolution, i, > normalizer, maxE, minE] > Eb1 = 0; k = 0; n = 10000; E0 = 2470; m = 0.2; DeltaE = 50; Sigma = 5; maxE > = E0 - m; minE = E0 - DeltaE; Resolution = {Eb1}; Ideal = {Eb1}; (*Setup > all constants, lists and ranges*) Eb1 = RandomReal[{minE, maxE}, n]; (*create a list of 'n' random Eb1 > values*) > k = -RandomReal[TriangularDistribution[{-2470, 0}, -0.1], n]; (*create a > list of 'n' random k values; triangle distribution gives more successful > results*) For[i = 0, i < n, i++, If[k[[i]] < Re[(E0 - Eb1[[i]])^2*Sqrt[1 - m^2/(E0 - Eb1[[i]])^2]], (*check > if the {k,Eb1} value is under the curve*) > AppendTo[Ideal, Eb1[[i]]]; (*Keep events under curve in 'Ideal'*) > y3 = Eb1[[i]]; (*cast element to a number*) > Eb1[[i]] = RandomReal[NormalDistribution[y3, Sigma], 1]; (*choose a > random number from a normal distribution about that point*) > AppendTo[Resolution, Eb1[[i]]]; ]] (*Keep that event in 'Resolution'*) > === Subject: Re: Help with Speeding up a For loop Hi Adam, first note that indices in Mathematica start at 1, not 0. Then I set the start value of Ideal and Resolution to an empty list. With this changes, your loop can be replaced by: Ideal = Pick[Eb1, Thread@Less[k, Re[(E0 - Eb1)^2*Sqrt[1 - m^2/(E0 - Eb1)^2]]] ]; Resolution = RandomReal[NormalDistribution[#, Sigma]] & /@ Ideal; For n=10^7, this takes 7.5 sec. Daniel > I am using an Intel MacBook with OS X 10.5.6. I am trying to create 2 lists: Ideal and Resolution. This is basically > a Monte Carlo Integration technique. Ideal should simulate the curve. > Resolution should simulate the curve convoluted with a normal distribution. > I want to do this for n=10 000 000 or more, but it takes far too long right > now. I can do n=100 000 in about 1 minute, but 1 000 000 takes more than an > hour. I haven't waited long enough for 10 000 000 to finish (it has been 5 > days). Adam Dally Here is the code: ClearAll[E0, Eb1, m, DeltaE, Sigma, k, n, y3, Ideal, Resolution, i, > normalizer, maxE, minE] > Eb1 = 0; k = 0; n = 10000; E0 = 2470; m = 0.2; DeltaE = 50; Sigma = 5; maxE > = E0 - m; minE = E0 - DeltaE; Resolution = {Eb1}; Ideal = {Eb1}; (*Setup > all constants, lists and ranges*) Eb1 = RandomReal[{minE, maxE}, n]; (*create a list of 'n' random Eb1 > values*) > k = -RandomReal[TriangularDistribution[{-2470, 0}, -0.1], n]; (*create a > list of 'n' random k values; triangle distribution gives more successful > results*) For[i = 0, i < n, i++, If[k[[i]] < Re[(E0 - Eb1[[i]])^2*Sqrt[1 - m^2/(E0 - Eb1[[i]])^2]], (*check > if the {k,Eb1} value is under the curve*) > AppendTo[Ideal, Eb1[[i]]]; (*Keep events under curve in 'Ideal'*) > y3 = Eb1[[i]]; (*cast element to a number*) > Eb1[[i]] = RandomReal[NormalDistribution[y3, Sigma], 1]; (*choose a > random number from a normal distribution about that point*) > AppendTo[Resolution, Eb1[[i]]]; ]] (*Keep that event in 'Resolution'*) === Subject: Looking for a custom control example that support dynamic arguments I want to learn how to support dynamic arguments for dynamic modules. Any sample code or where I should read on doing this? I would like to do the same kind of stuff as am able to do wth PopupMenu as shown Lists = {Lists, Elements}; ListsMenu = {{Nice, Table, Chair}, {Part, Spin, First}}; gt[e_, f_, h_] := Flatten[h[[Flatten[Position[f, e]]]]] ob[Ls_, LsM_] := DynamicModule[ {x, y}, PopupMenu[Dynamic[x], Ls] Dynamic[y = gt[x, Ls, LsM][[1]]; PopupMenu[Dynamic[y], gt[x, Ls, LsM]]] ] ob[Lists, ListsMenu] === Subject: Re: Creating a sign chart f[x_, y_] := x*y*Exp[-x^2 - y^2] Plot3D[Evaluate[ Sign[Det[{{D[f[x, y], {x, 2}], D[f[x, y], x, y]}, {D[f[x, y], x, y], D[f[x, y], {y, 2}]}}]]], {x, -2, 2}, {y, -2, 2}] ?? or what ever a sign chart is .. Jens > Is it possible to render a sign chart in Mathematica 10? Typically a sign chart is used with the first and second derivatives to identify extrema. I know there are other ways to convey this information. However, in my case I need to demonstrate a sign chart by means of an illustation. I can create a graphic in Visio and import into Mathematica but I would prefer if there were a means of generating such a chart directly in Mathematica. Something like: +++++++++++++++------------ > Dave > x2373 > === Subject: Re: Getting the height and width of controls? Cool, thank you. It was not clear from docs if that would work on Gui controls so did''t try. This tip open some doors for me. :-) As a QA guy, nice I found a bug. ;-) andrew === Subject: Re: Getting the height and width of controls? AbsoluteCurrentValue should (but as you point out, doesn't) work. In lieu of that, you can use Rasterize. In[1]:= Rasterize[Button[Click Here, Print[10!]], RasterSize] Out[1]= {64, 27} John Fultz jfultz@wolfram.com User Interface Group Wolfram Research, Inc. > ok, so far this is what I stumbled upon, but it dones't work right: t = Button[Click Here, Print[10!]] > AbsoluteCurrentValue[bt, ImageSize] That code always gives {350,350}. Lots of other options work, but not > getting the height/width of a control. > I can't use CurrentValue for that works only when I actually click the > button, but it too gives only the same answer. > I didnt think getting the simple height/width of a control to be that Andrew === Subject: Re: Mathematica documentation - for newest now, if they were to supply a free Stephen Wolfram cuddly toy along with the order - that would be different. 2009/4/21 Murray Eisenberg Now if only the PDF versions of the Documentation Center content for > version 7.0 were done, life would be grand indeed!!!! (but they are > are on their way the web site says -- see > http://www.wolfram.com/learningcenter/tutorialcollection/ > to see what they are intending to have if you have not seen this > before. It appears that you will be able to order hardcopies (for a > fee) of all the 7.0 documentation as well as download free versions of > the PDF files for each of the sections.... Kudo's to Wolfram for providing these sorts of tools!! -- > 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 -- Peter Lindsay === Subject: Re: Compositing, 3D graphics, and KDE 4.2 > I have version 7.0.0 running on a 32-bit linux system, in KDE 4.2 > (radeonhd driver). Now, most of the stuff is esoteric, and I'm quite > happy to have gotten everything running fast and stably and prettily, > including Mathematica looking great. However, I've just noticed today > that if I produce any 3D graphics (using Plot3D, or > Graphics3D[Cylinder[{{0, 0, 0}, {0, 1, 0}}]], for example) that the 3D > object shows up only if I'm actively rotating it or resizing it with > the mouse. Otherwise, it disappears and looks like just a big blank > space on the screen. I might try updating to 7.0.2 just in case that > fixes things. I have tested this on 64bit KDE 4.2.2 with kwin compositing and Mathematica 7.0.1 on two different machines, one using the proprietary Nvidia drivers, the other the Intel graphics drivers. In either case, 3D graphs worked without actively manipulating them. Therefore this might be an issue with you ATI drivers. I have no idea whether this will help, but you might try different drivers, e.g. the proprietary ATI driver (Catalyst 9.4 for Linux has been released recently, IIRC). === Subject: pure function with optional number of arguments I have two definitions for a function, one in the case it has one argument and another one if it has two. Efun[x_]:=x^2 Efun[x_,y_]:=x^2+y^2 Then I want to construct a pure function that does the same thing as this non-pure function myint[params__] := Integrate[z*Efun[params], {z, 0, #}] & /@ {1, 2, 3} I tried to accomplish it with myintpure= Function[params, Integrate[z*Efun[params], {z, 0, #}] & /@ {1, 2, 3}], but myintpure[x,y] gives not the same as myint[x,y], so this pure function I have constructed seems to be not right. Ruth Lazkoz === Subject: Re: pure function with optional number of arguments Hi Ruth, in short syntax, all parameters are written by: ##. This can not be done with the long syntax: Function[..]. You have nested functions and you need the ## in the outer function. Therefore, you need to write the inner functions in long syntax: Function[{x},..]. here is one possibility: purefun = (Function[{x}, Integrate[z*Efun[##], {z, 0, x}]] /@ {1,2,3}) & Daniel I have two definitions for a function, one in the case it has one > argument and another one if it has two. Efun[x_]:=x^2 > Efun[x_,y_]:=x^2+y^2 Then I want to construct a pure function that does the same thing as > this non-pure function myint[params__] := Integrate[z*Efun[params], {z, 0, #}] & /@ {1, 2, 3} I tried to accomplish it with myintpure= Function[params, Integrate[z*Efun[params], {z, 0, #}] & /@ > {1, 2, 3}], but myintpure[x,y] gives not the same as myint[x,y], so this pure > function I have constructed seems to be not right. > Ruth Lazkoz > === Subject: Re: pure function with optional number of arguments I have two definitions for a function, one in the case it has one > argument and another one if it has two. Efun[x_]:=x^2 > Efun[x_,y_]:=x^2+y^2 Then I want to construct a pure function that does the same thing as > this non-pure function myint[params__] := Integrate[z*Efun[params], {z, 0, #}] & /@ {1, 2, 3} I tried to accomplish it with myintpure= Function[params, Integrate[z*Efun[params], {z, 0, #}] & /@ > {1, 2, 3}], but myintpure[x,y] gives not the same as myint[x,y], so this pure > function I have constructed seems to be not right. > The trick is to use ## as argument, like this: myintpure = Function[ Function[{xmax}, Integrate[z*Efun[##], {z, 0, xmax}]] /@ {1, 2, 3} ] where I have changed the inner pure function to use a named argument to avoid confusion. Of course you are in trouble when needing deeply nested constructs of this sort, but that is something you probably want to avoid (for readability) anyway. hth, albert === Subject: Re: pure function with optional number of arguments Hi Ruth, You can use the undocumented form of the pure function which can take any number of arguments: Function[Null, body[##]]. (note the SlotSequence (##)).You will have to re-name the variable of the internal pure function though, from slot to a named var, to avoid name collision with the slot variables ## of the external Function: In[1] = mypureint = Function[Null, Function[limit, Integrate[z*Efun[##], {z, 0, limit}]] /@ {1, 2, 3}]; In[2] = mypureint[1] Out[2] = {1/2, 2, 9/2} In[3] = mypureint[1, 2] Out[3] = {5/2, 10, 45/2} Leonid I have two definitions for a function, one in the case it has one > argument and another one if it has two. Efun[x_]:=x^2 > Efun[x_,y_]:=x^2+y^2 Then I want to construct a pure function that does the same thing as > this non-pure function myint[params__] := Integrate[z*Efun[params], {z, 0, #}] & /@ {1, 2, 3} I tried to accomplish it with myintpure= Function[params, Integrate[z*Efun[params], {z, 0, #}] & /@ > {1, 2, 3}], but myintpure[x,y] gives not the same as myint[x,y], so this pure > function I have constructed seems to be not right. > Ruth Lazkoz === Subject: Re: pure function with optional number of arguments I have two definitions for a function, one in the case it has one > argument and another one if it has two. Efun[x_]:=x^2 > Efun[x_,y_]:=x^2+y^2 Then I want to construct a pure function that does the same thing as > this non-pure function myint[params__] := Integrate[z*Efun[params], {z, 0, #}] & /@ {1, 2, 3} I tried to accomplish it with myintpure= Function[params, Integrate[z*Efun[params], {z, 0, #}] & /@ > {1, 2, 3}], but myintpure[x,y] gives not the same as myint[x,y], so this pure > function I have constructed seems to be not right. > Try this: myintpure = Function[upper, Integrate[z*Efun[##], {z, 0, upper}]] /@ {1, 2, 3} & ## stands for multiple arguments. Here I use the Function[...] notation for the inner function, and the (...)& notation for the outer one. === Subject: Re: pure function with optional number of arguments myintpure = (Function[{ze}, Integrate[z*Efun[##], {z, 0, ze}]] /@ {1, 2, 3}) & ? Jens I have two definitions for a function, one in the case it has one > argument and another one if it has two. Efun[x_]:=x^2 > Efun[x_,y_]:=x^2+y^2 Then I want to construct a pure function that does the same thing as > this non-pure function myint[params__] := Integrate[z*Efun[params], {z, 0, #}] & /@ {1, 2, 3} I tried to accomplish it with myintpure= Function[params, Integrate[z*Efun[params], {z, 0, #}] & /@ > {1, 2, 3}], but myintpure[x,y] gives not the same as myint[x,y], so this pure > function I have constructed seems to be not right. > Ruth Lazkoz > === Subject: Re: Alignment of Graphics Within Expressions > Here are two BarCharts within a CirclePlus (but it might be any kind of > expression). g1 = BarChart[{1, 2, 3}, Axes -> {True, False}, BaselinePosition -> Axis, Ticks -> None, ImageSize -> 40]; g2 = BarChart[{-1, 2, -3}, BaselinePosition -> Axis, Axes -> {True, False}, Ticks -> None, ImageSize -> 40]; CirclePlus[g1, g2] The x axis of the bar charts are aligned with the baseline (approximately > the bottom) of the CirclePlus symbol. Would it be possible to align the axes > with the center line of the CirclePlus symbol without going into any Row > constructions or modifying the CirclePlus expression? How about: g1 = BarChart[{1, 2, 3}, Axes -> {True, False}, BaselinePosition -> Axis -> Center, Ticks -> None, ImageSize -> 40]; g2 = BarChart[{-1, 2, -3}, BaselinePosition -> Axis -> Center, Axes -> {True, False}, Ticks -> None, ImageSize -> 40]; CirclePlus[g1, g2] Carl > David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ === Subject: fit a complex function I have data in the following form xi , Fi (xi is real but Fi is complex) i want to determine a fit by using function F(x, a , b,c, d)= a Exp(- x^2/b) + c Sin( d x) a, b, c and d are complex numbers to be determined so as to accurately represent the data. How to do this problem? === Subject: Re: Help with a possible bug responses one could conclude that the issue does manifest itself on some machines with the 7.0.1 Kernel, but not all. Your help gave me the confidence that I had not overlooked some obvious thing, so I tried contacting WRI again. I spoke with several support people from WRI and they were very helpful and responsive. They told me they had recently become aware of the problem and that they are working to resolve it. Papin Email: ImportString[cGFwaW5AY294Lm5ldA==, Base64] === Subject: Re: Help with a possible bug At work we seem to have stumbled on a strange bug between Table and > Part. We can reproduce the bug on differently configured Mac and > Linux boxes. I tried Wolfram support, but they claim they cannot > reproduce the bug. So I was hoping someone could try it out and For us, the bug is new in 7.0.1. It does not show up in version 6. > To reproduce it, fill up a 17 x 267 matrix with 3s. Compute the sum > of some of the columns and you get the result 51 (17 x 3). But if on= e > computes the sum for the last few columns, the result is completely > off. The bug seems to arise from the interaction of optimizations = i= > n > Table and the use of All inside of Part. ------------ code mat = Table[3, {i, 1, 17}, {j, 1, 267}]; sum = Table[Total[mat[[All, j]]], {j, 1, 249}] sum1 = Table[Total[mat[[All, j]]], {j, 1, 252}]; > sum2 = Table[Total[mat[[All, j]]], {j, 1, 252}] ------------ end code If you look at sum1, it will be correct on a fresh copy of the > Kernel. The problem only arise from the second time on. > Papin Email: ImportString[cGFwaW5AY294Lm5ldA==, Base64] How bizarre!! On my Mac with version 7.0.1 every sum for the last 18 > columns is bogus, and it appears that the bogus values keep changing > in some sort of random way. For example if you tried mat = Table[3, {i, 1, 17}, {j, 1, 267}]; > Manipulate[ > sum = Table[Total[mat[[All, jj]]], {jj, 1, mm}], {mm, 1, 267, 1}] everything is OK up thru 249th column (and even thru the 267th the > first time on a fresh kernel just like you described), then as soon as > you select any other of the 250th thru 267th columns - they total goes > squirrely from then on for all subsequent TOTAL's that are calculated, > and changes every time you look at any of the last 18 (even looking at > the same column total the numbers are different, ie look at column > 267, then 266, then 267 again and the numbers are different from the > first time you looked), so there is apparently some sort of random > gibberish it is picking up when the totals are calculated. Try sending Wolfram the Manipulate command and it's trivial to > reproduce on a Mac -- make sure you stay on the phone with them while > they try it on a Mac. To make it even more obvious, change the starting index on the > Manipulate to 248 and start playing the manipulate and watch it go > bonkers. The numbers seem to always be 9 digits and are between the > upper 200 millions and the middle to upper 300 millions in magnitude, > but didn't seem to get much different even after letting the > Manipulate play for quite a while at the highest speed. Let us know what they say. -Bob It is definitely a bug with auto-compilation. SetSystemOptions[CompileOptions -> TableCompileLength -> Infinity] will restore expected operation. === Subject: Re: Help with a possible bug And the results for my wife's mac: 7.0 for Mac OS X x86 (64-bit) (February 19, 2009): Out[8]= {51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, Out[9]= {143167313, 143167313, 143167313, 143167313, 143167313, 143167313, 143167313, Out[10]= {319157559, 319157559, 319157559, 319157559, 319157559, 319157559, 319157559, It goes wrong even on a fresh kernel. > At work we seem to have stumbled on a strange bug between Table and > Part. We can reproduce the bug on differently configured Mac and > Linux boxes. I tried Wolfram support, but they claim they cannot > reproduce the bug. So I was hoping someone could try it out and For us, the bug is new in 7.0.1. It does not show up in version 6. > To reproduce it, fill up a 17 x 267 matrix with 3s. Compute the sum > of some of the columns and you get the result 51 (17 x 3). But if one > computes the sum for the last few columns, the result is completely > off. The bug seems to arise from the interaction of optimizations i= n > Table and the use of All inside of Part. ------------ code mat = Table[3, {i, 1, 17}, {j, 1, 267}]; sum = Table[Total[mat[[All, j]]], {j, 1, 249}] sum1 = Table[Total[mat[[All, j]]], {j, 1, 252}]; > sum2 = Table[Total[mat[[All, j]]], {j, 1, 252}] ------------ end code If you look at sum1, it will be correct on a fresh copy of the > Kernel. The problem only arise from the second time on. > Papin Email: ImportString[cGFwaW5AY294Lm5ldA==, Base64] === Subject: Re: Help with a possible bug Probably mac-related. I don't get this behavior on my $Version 7.0 for Microsoft Windows (32-bit) (February 18, 2009) > At work we seem to have stumbled on a strange bug between Table and > Part. We can reproduce the bug on differently configured Mac and > Linux boxes. I tried Wolfram support, but they claim they cannot > reproduce the bug. So I was hoping someone could try it out and For us, the bug is new in 7.0.1. It does not show up in version 6. > To reproduce it, fill up a 17 x 267 matrix with 3s. Compute the sum > of some of the columns and you get the result 51 (17 x 3). But if one > computes the sum for the last few columns, the result is completely > off. The bug seems to arise from the interaction of optimizations i= n > Table and the use of All inside of Part. ------------ code mat = Table[3, {i, 1, 17}, {j, 1, 267}]; sum = Table[Total[mat[[All, j]]], {j, 1, 249}] sum1 = Table[Total[mat[[All, j]]], {j, 1, 252}]; > sum2 = Table[Total[mat[[All, j]]], {j, 1, 252}] ------------ end code If you look at sum1, it will be correct on a fresh copy of the > Kernel. The problem only arise from the second time on. > Papin Email: ImportString[cGFwaW5AY294Lm5ldA==, Base64] === Subject: Re: Help with a possible bug work fine on a Windows Vista machine. Jens > At work we seem to have stumbled on a strange bug between Table and > Part. We can reproduce the bug on differently configured Mac and > Linux boxes. I tried Wolfram support, but they claim they cannot > reproduce the bug. So I was hoping someone could try it out and For us, the bug is new in 7.0.1. It does not show up in version 6. > To reproduce it, fill up a 17 x 267 matrix with 3s. Compute the sum > of some of the columns and you get the result 51 (17 x 3). But if one > computes the sum for the last few columns, the result is completely > off. The bug seems to arise from the interaction of optimizations in > Table and the use of All inside of Part. > ------------ code mat = Table[3, {i, 1, 17}, {j, 1, 267}]; sum = Table[Total[mat[[All, j]]], {j, 1, 249}] sum1 = Table[Total[mat[[All, j]]], {j, 1, 252}]; > sum2 = Table[Total[mat[[All, j]]], {j, 1, 252}] ------------ end code If you look at sum1, it will be correct on a fresh copy of the > Kernel. The problem only arise from the second time on. > Papin Email: ImportString[cGFwaW5AY294Lm5ldA==, Base64] > === Subject: Re: Help with a possible bug Seems to be a problem with Total and packing. If one does unpack mat, things are o.k.: sum = Union[Table[Total[mat[[All, j]]], {j, 1, 249}]] sum1 = ReleaseHold[Union[Table[Total[d[mat[[All, j]]]], {j, 1, 252}]]] sum2 = ReleaseHold[Union[Table[Total[d[mat[[All, j]]]], {j, 1, 252}]]] Rolf Mertig GluonVision GmbH http://www.gluonvision.com === Subject: Re: Help with a possible bug > At work we seem to have stumbled on a strange bug between Table and > Part. We can reproduce the bug on differently configured Mac and > Linux boxes. I tried Wolfram support, but they claim they cannot > reproduce the bug. So I was hoping someone could try it out and For us, the bug is new in 7.0.1. It does not show up in version 6. > To reproduce it, fill up a 17 x 267 matrix with 3s. Compute the sum > of some of the columns and you get the result 51 (17 x 3). But if one > computes the sum for the last few columns, the result is completely > off. The bug seems to arise from the interaction of optimizations in > Table and the use of All inside of Part. > ------------ code mat = Table[3, {i, 1, 17}, {j, 1, 267}]; sum = Table[Total[mat[[All, j]]], {j, 1, 249}] sum1 = Table[Total[mat[[All, j]]], {j, 1, 252}]; > sum2 = Table[Total[mat[[All, j]]], {j, 1, 252}] ------------ end code If you look at sum1, it will be correct on a fresh copy of the > Kernel. The problem only arise from the second time on. > Papin Email: ImportString[cGFwaW5AY294Lm5ldA==, Base64] > I can't reproduce the problem in Windows. I'm just writing to say that the magic number 250 appears in some of the system options controlling automatic compilation and array packing (see e.g. TableCompileLength). You can see or set with SystemOptions[]. Perhaps this information will help you work around the problem until it gets fixed. === Subject: Modifying List Elements. how can i add a value to an element in lists? data: {{0,1},{1,2}} needed output: {{0,1.5},{1,2.5}} === Subject: Re: Modifying List Elements. > how can i add a value to an element in lists? data: > {{0,1},{1,2}} needed output: > {{0,1.5},{1,2.5}} In place modification: In[1]:= list = {{0, 1}, {1, 2}} Out[1]= {{0, 1}, {1, 2}} In[2]:= list[[All, 2]] += 0.5 Out[2]= {1.5, 2.5} In[3]:= list Out[3]= {{0, 1.5}, {1, 2.5}} Some functional ways: In[1]:= list = {{0, 1}, {1, 2}} Out[1]= {{0, 1}, {1, 2}} In[2]:= {#1, #2 + 0.5} & @@@ list Out[2]= {{0, 1.5}, {1, 2.5}} In[3]:= # + {0, 0.5} & /@ list Out[3]= {{0, 1.5}, {1, 2.5}} In[4]:= Transpose[Transpose[list] + {0, 0.5}] Out[4]= {{0, 1.5}, {1, 2.5}} === Subject: Re: Modifying List Elements. data = {{0, 1}, {1, 2}}; with: {0, 0.5 } + # & /@ data or data /. {a_?NumericQ, b_?NumericQ} :> {a, b + 0.5} or ReplacePart[#, 2 -> #[[2]] + 0.5] & /@ data Jens > how can i add a value to an element in lists? data: > {{0,1},{1,2}} needed output: > {{0,1.5},{1,2.5}} === Subject: Re: Advanced plotting >Inspired by Bill Rowe's code, I think we can do it like this. >The key point here is that the common Y axes is in a separated Inset >object. >Plot[-3, {x, -0.5, 10}, PlotRange -> {-1.1, 1.1}, Axes -> None, >AspectRatio -> Automatic, >Epilog -> {Inset[ >Plot[-3, {x, 0, 10}, PlotRange -> {-1.1, 1.1}, >Axes -> {False, True}, Frame -> None, >AspectRatio -> Automatic], {0, 0}, {0, 0}, 10], >Inset[Plot[Sin[2 x], {x, 0, 4}, PlotRange -> {-1.1, 1.1}, >Axes -> {True, False}, Frame -> None, >AspectRatio -> Automatic], {0, 0}, {0, 0}, 4], >Inset[Plot[Cos[2 x], {x, 6, 10}, PlotRange -> {-1.1, 1.1}, >Axes -> {True, False}, Frame -> None, >AspectRatio -> Automatic], {5.2, 0}, {6, 0}, 4], >Inset[Style[Rotate[[TildeTilde], 90 Degree], >FontSize -> 20], {4.6, 0}]}] While I agree Inset can be used to create more complex graphics and I am glad code I've posted here has been found useful, the effect of having a common Y axis with a broken X-axis can be done more simply as follows: Grid@{{Plot[Sin[2 x], {x, 0, 4}, PlotRange -> {-1.1, 1.1}, AxesOrigin -> {0, 0}], Style[Rotate[[TildeTilde], 90 Degree], 20], Plot[Cos[2 x], {x, 6, 10}, PlotRange -> {-1.1, 1.1}, Axes -> {True, False}]}} === Subject: Re: representing the dihedral group {1,r,r^2...s,sr^2...} > The dihedral group of order 2n may be represented as > . If you start with an > arbitrary finite string of as and bs, simply remove > each consecutive pair of identical symbols. You will > be left with a product in one of the following four > forms: > (a*b)^m > (a*b)^m * b > (b*a)^m > (b*a)^m * a The exponent m may then be reduced modulo n. > Now, my ab is your r, my ba is your r^(n-1), my b is your s, > and (I think) my a is your r^(n-2)s. Thus, you should be > able to use this code to reduce in the alternative presentation > . > Hope that helps, > Mark McClure Hmm.. I don't see how is isomorphic to the dihedral group of order 2n. Using generators {r,s}, the relationship rs=s(r^-1) is satisfied. But abb = a which does not equal b(ab)^-1 = b*b^-1*a^-1 = a^-1. Can you explain? Otto === Subject: Re: Getting the height and width of controls? OK, I was told to use RasterSize instead. It works for now. andrew === Subject: Re: Getting the height and width of controls? > ok, so far this is what I stumbled upon, but it dones't work right: t = Button[Click Here, Print[10!]] > AbsoluteCurrentValue[bt, ImageSize] That code always gives {350,350}. Lots of other options work, but not > getting the height/width of a control. > I can't use CurrentValue for that works only when I actually click the > button, but it too gives only the same answer. > I didnt think getting the simple height/width of a control to be that > hard?? unfortunatly it is not easy to get that information. The reason is I think that the visual representation of the Button lives in the frontend, so the kernel has no idea of what sizes it may have. Only for objects like notebooks, where the kernel has a handle to the actual object you can use AbsoluteOptions the way you did. for controls like Button there is only one way I know to get the information you want: you need to Rasterize it, which gives you a Graphics-Object, which you can then ask for its ImageSize in the usual way. bt = Button[Click Here, Print[10!]]; Options[Rasterize[bt], ImageSize] This also works for other things that are formatted by the Frontend like Grid for example: grid = Grid[RandomInteger[{0, 200}, {2, 8}], Dividers -> All] Options[Rasterize[grid], ImageSize] hth, albert === Subject: Re: Getting the height and width of controls? > I trying to find a way to get the height/width of a control item or > the whole control itself. I know I can set stuff, but looking for some > function that would return me the pixel measurements passing it a > control expression. I am wanting to adjust me code based on these > measurements. I tried looking in the docs but found nothing that would I don't know whether there is a way to do this or not. I will note, however, that in my experience most controls in Mathematica look the best by far at their default/natural sizes (i.e. no ImageSize or other explicit options to change the size). The exception to this are the symbolic Appearance values of Tiny, Small, Medium, Large, which typically look okay. If you tweak the control size and it looks correct on your platform it will almost certainly look incorrect on different platforms due to differences in the way controls are drawn, differences in the system control font metrics, etc. -Rob === Subject: Remote Kernel Connection Error Hi! I am trying to use a remote kernel, installed on a Linux machine. I have no problem in setting up the ssh link with this machine using the Windows Vista version of mathematica 7.0, but with the mathematica which is installed on Linux (opensuse 11.1) I get this error (after I specify the kernel host in notebook kernel, and I authenticate with the password): The kernel REMOTEKERNEL failed to connect to the front end. (Error = MLECONNECT). You should try running the kernel connection outside the front end. Any Idea how to workaround this? Maybe I have some permission/firewall problem (actually the firewall is unloaded)? Davide === Subject: Re: Mathematica for gifted elementary school children Try with http://demonstrations.wolfram.com/topics.html and check what is attracting his interest. For the really interested kid this could be a treasure of gold. (Other kids might find it frustrating and boring to death.) Unfortunately my own kids were too grown-up when this site appeared, but there is still hope for my grandson. I would appreciate to hear about the reaction of your son to this site. Ingolf Dahl ingolf.dahl@telia.com -----Original Message----- === Subject: Mathematica for gifted elementary school children My son, almost 6, is good at math and inquisitive. Is there a math curriculum for elementary school children that uses Mathematica? He understands the four arithemetic operations and the concept of powers. I have Mathematica installed on my home PC and could teach him myself. I have written computer programs in Fortran in front of him to demonstrate concepts such as cubes and cube roots. We had fun, but I don't want to explain right now why 1000000000**3 gives -402653184 or 1/2 gives 0. He is interested in the number centillion (10^303) and thought it was cool to see the 101 zeros when we asked Mathematica to compute centillion^(1/3). I see there are some math courseware at http://library.wolfram.com/infocenter/Courseware/Mathematics/ , but those topics are too advanced for him at present. Maybe I should give him Wolfram's huge book and let him play when he wants. === Subject: Re: Mathematica for gifted elementary school children But interacting with the demonstrations, while it can be educational, is not really being very creative or being engaged in learning Mathematica (unless one studies the code -- which tends to be rather more sophisticated than a rank beginner would want to see). Doing computations oneself, building graphic images oneself -- those things can be educational and creative and contribute toward learning Mathematica and learning how to learn Mathematica. Sort of the difference between playing a video game and creating a video game. >> My son, almost 6, is good at math and inquisitive. Is there a math >> curriculum for elementary school children that uses Mathematica? He >> understands the four arithemetic operations and the concept of powers. >> I have Mathematica installed on my home PC and could teach him myself. >> I have written computer programs in Fortran in front of him to >> demonstrate concepts such as cubes and cube roots. We had fun, but I >> don't want to explain right now why 1000000000**3 gives -402653184 or >> 1/2 gives 0. >> He is interested in the number centillion (10^303) and thought it >> was cool to see the 101 zeros when we asked Mathematica to compute >> centillion^(1/3). >> I see there are some math courseware athttp://library.wolfram.com/infocenter/Courseware/Mathematics/ >> , but those topics are too advanced for him at present. Maybe I should >> give him Wolfram's huge book and let him play when he wants. Try looking thru the demonstrations web site (at http://demonstrations.wolfram.com > ). There are some really nice things and some are very well > illustrated and fun to play with. There is even a Kids and Fun > section at http://demonstrations.wolfram.com/topics.html#10 Enjoy... -Bob > -- 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: Mathematica in conjunction with outside program; NMinimize fails. Hi Andreas, functions without the attribute HoldFirst/HoldAll do evaluate their arguments before the function call. Therefore, mma tries to evaluate SingleModelRun[ myvalue ] with the symbolic value myvalue . You must prevent this by defining: SingleModelRun[ parametervalue_?NumericQ ] :=... Daniel > Hello mathgroup. I am using Mathematica in conjunction with an > outside program (Netlogo is the program.) In a nutshell, my error is > the following: I can call the outside program with a numeric value > successfully, and Plot can call the outside program as one would > expect. However, NMinimize calls the outside program with the > variable name, not a value, so it fails. In short, I need to force > NMinimize to pass a numeric value to the objective function, not a > variable name. More details: I have the following functions defined in Mathematica: SingleModelRun[ parametervalue_ ] := ....(definition irrelevant) > This function (successfully) runs the outside program, setting a > parameter equal to parametervalue (which is some number when I call > the function). It returns a value from the model. Plot[ SingleModelRun[ x ], {x , 0, 1} ] > Does what you expect: runs SingleModelRun for parameter values 0 > through 1, and plots the resulting return value each time. NMinimize[ - SingleModelRun[ myvalue ], {myvalue} ] > Does not work. Returns the following error: NetLogo`Private`NetLogo::compilerException : Nothing named > MYVALUE has been defined (Note: NetLogo is the name of the outside program.) Which means that, oddly, NMinimize passes the *variable name* > (myvalue) instead of the *variable value* to the function > SingleModelRun; otherwise, there is no way the outside program would > be aware of the variable name. Is there a way to force Mathematica to evaluate the function with a > numeric value, not the variable name? (I thought that's what N in > NMinimize meant, but apparently not.) > > In case you were wondering, this fails in an identical way with: > NMaximize, FindMaximum, FindMimimum, etc. > Andreas Duus Pape === Subject: Re: Mathematica in conjunction with outside program; NMinimize fails. no the definition is not irrelevant. You just define SingleModelRun[ parametervalue_?NumericQ ] := ....(definition irrelevant) and better you write a MathLink program to do the calculation. Jens > Hello mathgroup. I am using Mathematica in conjunction with an > outside program (Netlogo is the program.) In a nutshell, my error is > the following: I can call the outside program with a numeric value > successfully, and Plot can call the outside program as one would > expect. However, NMinimize calls the outside program with the > variable name, not a value, so it fails. In short, I need to force > NMinimize to pass a numeric value to the objective function, not a > variable name. More details: I have the following functions defined in Mathematica: SingleModelRun[ parametervalue_ ] := ....(definition irrelevant) > This function (successfully) runs the outside program, setting a > parameter equal to parametervalue (which is some number when I call > the function). It returns a value from the model. Plot[ SingleModelRun[ x ], {x , 0, 1} ] > Does what you expect: runs SingleModelRun for parameter values 0 > through 1, and plots the resulting return value each time. NMinimize[ - SingleModelRun[ myvalue ], {myvalue} ] > Does not work. Returns the following error: NetLogo`Private`NetLogo::compilerException : Nothing named > MYVALUE has been defined (Note: NetLogo is the name of the outside program.) Which means that, oddly, NMinimize passes the *variable name* > (myvalue) instead of the *variable value* to the function > SingleModelRun; otherwise, there is no way the outside program would > be aware of the variable name. Is there a way to force Mathematica to evaluate the function with a > numeric value, not the variable name? (I thought that's what N in > NMinimize meant, but apparently not.) > > In case you were wondering, this fails in an identical way with: > NMaximize, FindMaximum, FindMimimum, etc. > Andreas Duus Pape === Subject: Re: Mathematica in conjunction with outside program; NMinimize fails. Hi ANdreas, NMinimize as a first step tries to evaluate the function symbolicaly. You can see this by using a function like In[39]:= f[x_] := Module[{}, Print[x]; x] In[40]:= NMinimize[f[y^2], y] y^2 Out[40]= {0., {y -> 0.}} You can prevent this behaviour by explicitely defining the function as numeric: g[x_?NumberQ] := Module[{}, Print[x]; x] NMinimize[g[y^2], y] 0.0929857 0.0708309 0.133682 ... So, in your case you should write your function as: SingleModelRun[ parametervalue_?NumberQ ] := etc. > Hello mathgroup. I am using Mathematica in conjunction with an > outside program (Netlogo is the program.) In a nutshell, my error is = > the following: I can call the outside program with a numeric value > successfully, and Plot can call the outside program as one would > expect. However, NMinimize calls the outside program with the > variable name, not a value, so it fails. In short, I need to force > NMinimize to pass a numeric value to the objective function, not a > variable name. More details: I have the following functions defined in Mathematica: SingleModelRun[ parametervalue_ ] := ....(definition ir= relevant) > This function (successfully) runs the out= side program, setting a > parameter equal to parametervalue (which is some number when I call > the function). It returns a value from the model. Plot[ SingleModelRun[ x ], {x , 0, 1} ] > Does what you expect: runs SingleModelRun= for parameter values 0 > through 1, and plots the resulting return value each time. NMinimize[ - SingleModelRun[ myvalue ], {myvalue} ] > Does not work. Returns the following e= rror: NetLogo`Private`NetLogo::compilerExcepti= on : Nothing named > MYVALUE has been defined (Note: NetLogo is the name of the outside program.) Which means that, oddly, NMinimize passes the *variable name* > (myvalue) instead of the *variable value* to the function > SingleModelRun; otherwise, there is no way the outside program would > be aware of the variable name. Is there a way to force Mathematica to evaluate the funct= ion with a > numeric value, not the variable name? (I thought that's what N in = > NMinimize meant, but apparently not.) In case you were wondering, this fails in an identical wa= y with: > NMaximize, FindMaximum, FindMimimum, etc. > Andreas Duus Pape === Subject: Re: Mathematica in conjunction with outside program; NMinimize fails. > Hello mathgroup. I am using Mathematica in conjunction with an > outside program (Netlogo is the program.) In a nutshell, my error is > the following: I can call the outside program with a numeric value > successfully, and Plot can call the outside program as one would > expect. However, NMinimize calls the outside program with the > variable name, not a value, so it fails. In short, I need to force > NMinimize to pass a numeric value to the objective function, not a > variable name. More details: I have the following functions defined in Mathematica: SingleModelRun[ parametervalue_ ] := ....(definition irrelevant) Use singleModelRun[parametervalue_?NumericQ] := (definition) This will do exactly what you asked for. Make sure you Clear[singleModelRun] before you use this definition. Szabolcs === Subject: Re: Parallel processing downgrade > I believe the default license only supports 4? kernels. Yes, that's what the documentation says. I had assumed that this was 4 sub-kernels per process allowed so I had eight, since my premier license allows 2 concurrent kernels to run. I'm now pretty sure that the 8 processes in V7.0.0 was simply a bug. To be clear, I'm not particularly complaining about this; I just thinks it's a potentially useful piece of information for many Mathematica users. Mark === Subject: Re: Looking for more Mathematica online user groups/forums > I Iam very thankful to those at > Wolfram who help and reply to all the questions and issues posed on > this group and for hosting the MathGroup Archive, especially since > they do it on their own time. And the biggest thank you of all to Steven Christensen who keeps all > sure that the content keeps flowing and organized and everything else > that he does behind the scenes. I am so happy not to have to wade > through the countless ads for all the drivel and porn and scams and > everything else that gets so old on many other newsgroups. I may beat up pretty aggressively on some of Mathematica's and Wolfram's looney [1] policies from time to time in this group; but I'd also like to strongly endorse both of the sentiments expressed just above [2]. ------------- NOTES: [1] I've more often tended to describe some of these policies as insane, but one of the recent supportive emails I received from another lurker on the group (and I do get a modest number of such private but supportive communications) used instead the term looney, and I think that's even better, or at least more picturesque. [2] And I didn't know any of this background information about Steven Christensen and had sometimes wondered just who Steven M. Christensen and Associates, Inc. really was. Other moderated groups often have a brief FAQ message that's auto-posted monthly by the moderator, saying who the moderator is and giving a few of his or her key policies and requests with respect to the operation of the group. Maybe that would be a useful idea hereÉ? === Subject: Re: Looking for more Mathematica online user groups/forums On Apr 21, 5:08 am, Dr. David Kirkby student around other Mathematica using students on a campus. And > buying expensive books does only cover so much (And many are outdated > or does not cover areas outside of math like the Frontend), where on > the internet do I find help thats more real time? This group has been > very helpful, but I want more rapid turn around time, and someone to > teach why some code is good and mine is bad so I learn from mistakes . I do find it strange there is not a more active WRI collection of > people part of a tech support forum somewhere. A whiteboard version of > the FE to aid in support could be a good direction. Collaborative > editing FE in real time somehow? How about a Home Ed users forum on > WRI site?? Or perhaps allow Home Edition users email support; if it is so, be > clear it is so and how long the turn around time for a reply. Or > encourage local universities to create local Mathematica support > groups. Mathematics is a social activity as much as any other creative one; > helping each other is a great way to enjoy learning. Andrew, seeking some shoulders to stand on ;-) The newsgroup sci.math.symbolic does not have the expertise of > comp.soft-sys.math.mathematica, but there are many people (some WRI > employees) who know Mathematica and will respond to requests there. You might get a certain professor moaning about Mathematica questions > there, but people tend to ignore him. for a while. Within a 30 day period, I somewhat doubt you will be needing too many > difficult questions answered, so sci.math.symbolic might be a useful > complimentary group. Be aware, if you multi-post (copy your message to both sci.math.symbolic > and comp.soft-sys.math.mathematica at the exact same time, so there are > sci.math.symbolic until Steve has approved it. I've never understood the > logic of that!! Since the newsgroup sci.math.symbolic is unmoderated, > why should a message copied to both have to wait for approval? If you > want to send to both newsgroups, do it to one, then do it to the second. [My approval has nothing to do with sci.math.symbolic. If a message > does not appear there, it has nothing to do with me - Steve C.]- Hide = quoted text - - Show quoted text - I wonder if there are any plans for Wolfram Alpha to be able to accept a non-trivial textural/mathematical description of a sub-problem, then think about it and finally return a solution in the form of Mathematica code ? Version 2.0 would return optimized Mathematica code. This may seem ambitious but isn't that what the folks at Wolfram do ? http://blog.wolfram.com/2009/03/05/wolframalpha-is-coming/ === Subject: pure function with an NIntegrate command I posted a question yesterday about pure functions. Probably when you receive this message someone would have posted a solution. While I was waiting I managed to come closer to a possible solution, and the encountered another problem. This is my problem. I define a function Efun[x_, y_, z_] := x + y + z and then this other one, which does an integral using the previous function fintnp[list_, y_, z_] :=NIntegrate[Efun[x, y, z], {x, 0, #}] & /@ list In my computer I run fintnp[{1, 2, 3, 4}, 0.2, 0.3] // Timing and get {0.020001, {1., 3., 6., 10.}} Now I want to construct a pure version of fintnp so that when the list is long I save a good load of time. My first approach is fint = Integrate[Efun[x, ##2], {x, 0, #1}] & It gives the correct results but it is significantly slower because I use Integrate instead of NIntegrate, so I naively define fintn= NIntegrate[Efun[x, ##2], {x, 0, #1}] & and then get errors indicating the definition is not good. Can someone help me? Ruth PD: Mathgroup is awesome, it has been amazingly useful for my work, and all the things I learn here made me a stronger Mathematica advocate anyday. === Subject: Bug in Rational arithmetic? I am running Mathematica 5.1 for Linux. I know that this is an old version and don't expect a fix to my software. It would be good to know whether anyone can reproduce this problem with mine or any other version of the software. If the members of this list (and the moderator) don't object, I could post the 900+ line input file as a follow-up. Otherwise, does anyone know a good place to upload this file? SYMPTOM: I have a file foo.m written by Mathematica, which contains 2 statements: x = y = The rational numbers have large numerators and denominators. When I add x and y, I get a segmentation fault. ------------------------------------------------------------------------ $ uname -a Linux diamond 2.6.26.8-57.fc8 #1 SMP Thu Dec 18 18:59:49 EST 2008 x86_64 x86_64 x86_64 GNU/Linux $ wc foo.m 932 935 73456 foo.m $ math Mathematica 5.1 for Linux -- Motif graphics initialized -- In[1]:= << foo.m; In[2]:= Head /@ {x,y} Out[2]= {Rational, Rational} In[3]:= {Numerator[#],Denominator[#]}& /@ {x,y} // N 18090 18097 Out[3]= {{-2.979268317140882 10 , 2.075577927018556 10 }, 17691 17700 > {-7.573697850202144 10 , 8.012808242587755 10 }} In[4]:= x+y Segmentation fault $ ------------------------------------------------------------------------ DIAGNOSIS: I am not running into any memory limits that I'm aware of. The virtual memory size after loading foo.m is only 25MB. I've increased the stack limit from the default 10MB to 100MB with no effect. x*=1/2; y*=1/2; 2(x+y) works. x+=1/2; y-=1/2; x+y segfaults. x+=1/3; y-=1/3; x+y segfaults. x+=1/5; y-=1/5; x+y segfaults. x+=1/7; y-=1/7; x+y segfaults. x+=1/999999893; y-=1/999999893; x+y works. x*=2; y*=2; (x+y)/2 works. CURE: I don't have a cure, but for this particular addition problem, I can work around the problem by multiplying the two addends by 2, then dividing their sum by 2. Scott -- Scott Hemphill hemphill@alumni.caltech.edu This isn't flying. This is falling, with style. -- Buzz Lightyear === Subject: 3D Agent Problem I am trying to set up a 3D environment having 'agents' and 'stuff' whose coordinates are random real numbers. The program should then move the agents towards the closest stuff in increments of, say, .1 units. I was able to create a program that did what I need for one iteration, but am having problems making it iterative... below is the code. I'm inexperienced and learning quickly but would really appreciate any guidance on iterating this system. ***************** Making a World of Agents and Stuff MakeNewWorld[Agents_] := Partition[Flatten[ Riffle[Table[RandomReal[{-10, 10}, {Agents, 3}]], Table[RandomInteger[9, 3], {Agents}]]], 6, 6] MakeNewStuff[Resources_] := Table[RandomReal[{-10, 10}, {Resources, 3}]] agentpos1 = MakeNewWorld[10][[All, 1 ;; 3]]; stuffpos1 = MakeNewStuff[5]; ListPointPlot3D[{agentpos1, stuffpos1 }, PlotStyle -> PointSize[Large]] ***** 3D plot of agent positions and stuff positions ******* The Problem of Movement Agents search for nearest stuff and move along the vector between their current position and that of the stuff. Ax = agentpos1[[All, 1]]; Bx = stuffpos1[[All, 1]]; Ay = agentpos1[[All, 2]]; By = stuffpos1[[All, 2]]; Az = agentpos1[[All, 3]]; Bz = stuffpos1[[All, 3]]; dx = Part[Ax, #] - Bx &; dy = Part[Ay, #] - By &; dz = Part[Az, #] - Bz &; TOTdx = dx /@ {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; TOTdy = dy /@ {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; TOTdz = dz /@ {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; squared = #^2 &; distance = (squared /@ TOTdx + squared /@ TOTdy + squared /@ TOTdz)^.5; mindistance = Min /@ distance; stufffinder = Flatten[Position[distance, #]] &; stuffpositions = Flatten[stufffinder ] /@ mindistance; newstuff = stuffpositions[[All, 2]]; coords = Part[stuffpos1, #] &; stuffcoords = coords /@ newstuff; WalkFunct2 = If[Part[Flatten[agentpos1], #] < Part[Flatten[stuffcoords], #], Part[Flatten[agentpos1], #] + .5, Part[Flatten[agentpos1], #] - .5] &; newagentcoords = WalkFunct2 /@ {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30}; agentpos2 = Partition[newagentcoords, 3, 3, {1, 3}]; ListPointPlot3D[{agentpos2, stuffpos1 }, PlotStyle -> PointSize[Large]] === Subject: Re: Help with a possible bug 7.0 for Mac OS X x86 (32-bit) (February 18, 2009) {691894176, 691894176, 691894176, 691894176, 691894176, 691894176, 691894176, 691894176, 691894176, 691894176, 691894176, 691894176, 691894176, 2009/4/22 Raffy At work we seem to have stumbled on a strange bug between Table and > Part. We can reproduce the bug on differently configured Mac and > Linux boxes. I tried Wolfram support, but they claim they cannot > reproduce the bug. So I was hoping someone could try it out and For us, the bug is new in 7.0.1. It does not show up in version 6. > To reproduce it, fill up a 17 x 267 matrix with 3s. Compute the sum > of some of the columns and you get the result 51 (17 x 3). But if on= > e > computes the sum for the last few columns, the result is completely > off. The bug seems to arise from the interaction of optimizations = > i= > n > Table and the use of All inside of Part. ------------ code mat = Table[3, {i, 1, 17}, {j, 1, 267}]; sum = Table[Total[mat[[All, j]]], {j, 1, 249}] sum1 = Table[Total[mat[[All, j]]], {j, 1, 252}]; > sum2 = Table[Total[mat[[All, j]]], {j, 1, 252}] ------------ end code If you look at sum1, it will be correct on a fresh copy of the > Kernel. The problem only arise from the second time on. > Papin Email: ImportString[cGFwaW5AY294Lm5ldA==, Base64] How bizarre!! On my Mac with version 7.0.1 every sum for the last 18 > columns is bogus, and it appears that the bogus values keep changing > in some sort of random way. For example if you tried mat = Table[3, {i, 1, 17}, {j, 1, 267}]; > Manipulate[ > sum = Table[Total[mat[[All, jj]]], {jj, 1, mm}], {mm, 1, 267, 1}] everything is OK up thru 249th column (and even thru the 267th the > first time on a fresh kernel just like you described), then as soon as > you select any other of the 250th thru 267th columns - they total goes > squirrely from then on for all subsequent TOTAL's that are calculated, > and changes every time you look at any of the last 18 (even looking at > the same column total the numbers are different, ie look at column > 267, then 266, then 267 again and the numbers are different from the > first time you looked), so there is apparently some sort of random > gibberish it is picking up when the totals are calculated. Try sending Wolfram the Manipulate command and it's trivial to > reproduce on a Mac -- make sure you stay on the phone with them while > they try it on a Mac. To make it even more obvious, change the starting index on the > Manipulate to 248 and start playing the manipulate and watch it go > bonkers. The numbers seem to always be 9 digits and are between the > upper 200 millions and the middle to upper 300 millions in magnitude, > but didn't seem to get much different even after letting the > Manipulate play for quite a while at the highest speed. Let us know what they say. -Bob It is definitely a bug with auto-compilation. SetSystemOptions[CompileOptions -> TableCompileLength -> Infinity] > will restore expected operation. -- Peter Lindsay === Subject: Re: Alignment of Graphics Within Expressions > Here are two BarCharts within a CirclePlus (but it might be any kind of > expression). g1 = BarChart[{1, 2, 3}, Axes -> {True, False}, BaselinePosition -> Axis, Ticks -> None, ImageSize -> 40]; g2 = BarChart[{-1, 2, -3}, BaselinePosition -> Axis, Axes -> {True, False}, Ticks -> None, ImageSize -> 40]; CirclePlus[g1, g2] The x axis of the bar charts are aligned with the baseline (approximately > the bottom) of the CirclePlus symbol. Would it be possible to align the a= xes > with the center line of the CirclePlus symbol without going into any Row > constructions or modifying the CirclePlus expression? David Park djmp...@comcast.net http://home.comcast.net/~djmpark/ BaselinePosition -> (Axis -> Center) does the trick. === Subject: Q: How to print with line wrap AND syntax coloring? How do I edit the printout environment so that it includes line wrapping AND syntax coloring? === Subject: Re: Mathematica for gifted elementary I have no doubt as to the efficacy of some such demos for learning some things about some mathematical concepts. Indeed, many math concepts that are otherwise procedural or symbolic as ordinarily taught become clearer or more transparent with proper manipulable graphical representations. > Maybe the demonstration site cannot teach him to DO mathematics, but it > could teach to LEARN mathematical concepts, THINK in terms of them, TALK > about mathematics and see mathematics put into contexts. There are a lot of > educational and funny software for teaching basic math (the digits and > addition up to 100 or so), and small children books where Barbapapa shows > different shapes and colors, but the young man mentioned in the letter > evidently has passed that stage. At the level just above the most basic it > is very difficult to find something good and interesting. Some other kids > learns everything worth to learn about different kinds of dinosaurs. He has > probably already learnt about triangles and rectangles. Then, if there is > something like a video game, telling him about dodecahedra, icosahedra, > convex hulls, diagrams, coordinate systems, RGB colors, musical sounds, you > name it, why should he as a six years old investigator not use it? Then his > father and mother can see what catches his interest, and guide him further. > It might be a bit complicated to modify the demonstrations, but it might be > possible to find the relevant related commands, and use the examples in the > help system to do simple experiments. Then he could get into Mathematica > programming quite easy, if he is interested. But that is the point of the > demonstrations - they might be a way to get him and keep him interested. And > that is the most important point. Another thing is that good images might go straight into your mind, creating > strong visual memories and silent knowledge. If you see a square of 4 times > 4 dots (or two standard Lego pieces side by side) do you need a conscious > multiplication to know that there are 16 dots (or knobs)? There you might > have silent knowledge, and that could be of great value. The demonstrations > are full of good images. And what is doing computations? Consider these cases: > 1) Our young genius open Mathematica and evaluates Sqrt[2] > 2) He opens the Travelling Salesman demonstration and enters a number of > points interactively, and looks at the result. > Is he doing computations himself in any of the cases? > Ingolf Dahl > >> -----Original Message----- === >> Subject: Re: Re: Mathematica for gifted >> elementary school children >> But interacting with the demonstrations, while it can be >> educational, is not really being very creative or being >> engaged in learning Mathematica (unless one studies the code >> -- which tends to be rather more sophisticated than a rank >> beginner would want to see). >> Doing computations oneself, building graphic images oneself >> -- those things can be educational and creative and >> contribute toward learning Mathematica and learning how to >> learn Mathematica. >> Sort of the difference between playing a video game and >> creating a video game. >> My son, almost 6, is good at math and inquisitive. Is there a math >> curriculum for elementary school children that uses >> Mathematica? He >> understands the four arithemetic operations and the >> concept of powers. >> I have Mathematica installed on my home PC and could teach >> him myself. >> I have written computer programs in Fortran in front of him to >> demonstrate concepts such as cubes and cube roots. We had >> fun, but I >> don't want to explain right now why 1000000000**3 gives >> -402653184 or >> 1/2 gives 0. >> He is interested in the number centillion (10^303) and >> thought it >> was cool to see the 101 zeros when we asked Mathematica to compute >> centillion^(1/3). >> I see there are some math courseware >> athttp://library.wolfram.com/infocenter/Courseware/Mathematics/ >> , but those topics are too advanced for him at present. Maybe I >> should give him Wolfram's huge book and let him play when he wants. > Try looking thru the demonstrations web site (at > http://demonstrations.wolfram.com ). There are some really >> nice things > and some are very well illustrated and fun to play with. >> There is even a Kids and Fun > section at http://demonstrations.wolfram.com/topics.html#10 Enjoy... -Bob > -- >> 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 -- 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: Mathematica for gifted elementary school children Maybe the demonstration site cannot teach him to DO mathematics, but it could teach to LEARN mathematical concepts, THINK in terms of them, TALK about mathematics and see mathematics put into contexts. There are a lot of educational and funny software for teaching basic math (the digits and addition up to 100 or so), and small children books where Barbapapa shows different shapes and colors, but the young man mentioned in the letter evidently has passed that stage. At the level just above the most basic it is very difficult to find something good and interesting. Some other kids learns everything worth to learn about different kinds of dinosaurs. He has probably already learnt about triangles and rectangles. Then, if there is something like a video game, telling him about dodecahedra, icosahedra, convex hulls, diagrams, coordinate systems, RGB colors, musical sounds, you name it, why should he as a six years old investigator not use it? Then his father and mother can see what catches his interest, and guide him further. It might be a bit complicated to modify the demonstrations, but it might be possible to find the relevant related commands, and use the examples in the help system to do simple experiments. Then he could get into Mathematica programming quite easy, if he is interested. But that is the point of the demonstrations - they might be a way to get him and keep him interested. And that is the most important point. Another thing is that good images might go straight into your mind, creating strong visual memories and silent knowledge. If you see a square of 4 times 4 dots (or two standard Lego pieces side by side) do you need a conscious multiplication to know that there are 16 dots (or knobs)? There you might have silent knowledge, and that could be of great value. The demonstrations are full of good images. And what is doing computations? Consider these cases: 1) Our young genius open Mathematica and evaluates Sqrt[2] 2) He opens the Travelling Salesman demonstration and enters a number of points interactively, and looks at the result. Is he doing computations himself in any of the cases? Ingolf Dahl > -----Original Message----- === > Subject: Re: Re: Mathematica for gifted > elementary school children But interacting with the demonstrations, while it can be > educational, is not really being very creative or being > engaged in learning Mathematica (unless one studies the code > -- which tends to be rather more sophisticated than a rank > beginner would want to see). Doing computations oneself, building graphic images oneself > -- those things can be educational and creative and > contribute toward learning Mathematica and learning how to > learn Mathematica. Sort of the difference between playing a video game and > creating a video game. > >> My son, almost 6, is good at math and inquisitive. Is there a math >> curriculum for elementary school children that uses > Mathematica? He >> understands the four arithemetic operations and the > concept of powers. >> I have Mathematica installed on my home PC and could teach > him myself. >> I have written computer programs in Fortran in front of him to >> demonstrate concepts such as cubes and cube roots. We had > fun, but I >> don't want to explain right now why 1000000000**3 gives > -402653184 or >> 1/2 gives 0. >> He is interested in the number centillion (10^303) and > thought it >> was cool to see the 101 zeros when we asked Mathematica to compute >> centillion^(1/3). >> I see there are some math courseware >> athttp://library.wolfram.com/infocenter/Courseware/Mathematics/ >> , but those topics are too advanced for him at present. Maybe I >> should give him Wolfram's huge book and let him play when he wants. Try looking thru the demonstrations web site (at > http://demonstrations.wolfram.com ). There are some really > nice things > and some are very well illustrated and fun to play with. > There is even a Kids and Fun > section at http://demonstrations.wolfram.com/topics.html#10 Enjoy... -Bob > -- > 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: Advanced plotting Hi Bill, Oh, not exactly. At least on my machine (Windows XP SP2, Mathematica 7.0.0), the peak value in the 2nd graph is a little higher than that in the 1st one. To keep the scaling of 2 graphs exactly the same, I have to use the same Axes setting in both graphs, so the common Y axes is in a separate one. Any easier solution for this? While I agree Inset can be used to create more complex graphics > and I am glad code I've posted here has been found useful, the > effect of having a common Y axis with a broken X-axis can be > done more simply as follows: Grid@{{Plot[Sin[2 x], {x, 0, 4}, PlotRange -> {-1.1, 1.1}, > AxesOrigin -> {0, 0}], > Style[Rotate[[TildeTilde], 90 Degree], 20], > Plot[Cos[2 x], {x, 6, 10}, PlotRange -> {-1.1, 1.1}, > Axes -> {True, False}]}} -- Li Zhengji ------------------------------------------------------------- If all you have is a hammer, everything is a nail. ------------------------------------------------------------- === Subject: FindFit tips === Subject: Re: Brace, bracket pretty format needed um, can that keyboard action you mentioned be put into a button, and work repeatedly as I click it each time?? I am just so surprised that there is not a pretty print/formating menuitem, button, or code around. Anyone up for the challenge? Am doing the reformatting by hand that uses up time and energy on my disabled fingers. ;( andrew === Subject: Re: Brace, bracket pretty format needed I'm sorry for the late reply. Daniel's colored matching brackets code was what I originally thought of, but there is a possibly quicker way to check for matching brackets, which I use quite often: Put your cursor in the midst of a nasty bit of code, and press (at least on linux) the combination of Ctrl-Shift-B one or more times. The highlight should expand to successively more general levels of the expressions -- this is often useful to me to see where a function argument ends, and so forth. Best wishes, C.O. > 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 -- Curtis Osterhoudt cfo@remove_this.lanl.and_this.gov PGP Key ID: 0x4DCA2A10 === Subject: Re: Has Fourier been fixed in Mathematica 7 [note: message sent to comp.soft-sys.math.mathematica] > I am interested in upgrading to Mathematica 7 in order to support our > Mathematica Add-On for time-frequency analysis: http://www.ffconsultancy.com/products/CWT/index.html?mma I tried an early version of Mathematica 7 and it was quite fragile due to a > bug in the Fourier routine. Is there a new release of Mathematica 7 that fixes this and, if so, are > there any remaining issues with Fourier? > If you post an example of Fourier misbehaving in an earlier version, then we can test it on 7.0.1 and see if the problem is fixed. -- Szabolcs === Subject: Re: Has Fourier been fixed in Mathematica 7 Could you be a little more specific wrt the bug you're referring to? An example of code that is supposed to suffer from it would be helpful. > I am interested in upgrading to Mathematica 7 in order to support our > Mathematica Add-On for time-frequency analysis: http://www.ffconsultancy.com/products/CWT/index.html?mma I tried an early version of Mathematica 7 and it was quite fragile due to= a > bug in the Fourier routine. Is there a new release of Mathematica 7 that fixes this and, if so, are > there any remaining issues with Fourier? -- > Dr Jon D Harrop, Flying Frog Consultancy Ltd.http://www.ffconsultancy.com= /?u === Subject: fitting surface with Mathematica 6.0.3 and range of fitted values I'm trying to fit a surface with a Fit command and a 4th order polynomial and I can get the fit and the model but then I try to evaluate some data through the model and they are out of the range of the original data, I have looked around but I could not find an option to pass into Fit command to keep the fitted values in the range of the possible cases Simone === Subject: Re: Using the slider values in a Manipulate Don't use Manipulate. Just set up some free standing sliders, maybe with InputFields to provide alternative methods to enter the values. Then write a Dynamic statement where you want to use the slider values. Column[ {Row[ {parm1: , Slider[Dynamic[parm1], {0, 10}], Spacer[5], InputField[Dynamic[parm1], FieldSize -> {5, 1}]}](* Row 1 *), Row[ {parm2: , Slider[Dynamic[parm2], {0, 10}], Spacer[5], InputField[Dynamic[parm2], FieldSize -> {5, 1}]}](* Row 2 *) }] Dynamic[parm1] + Dynamic[parm2] x Dynamic[parm1 + parm2 x] David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ How can I use the values adjusted with the sliders in a Manipulate later in the notebook? The only way seems to be the DynamicModule, but that's not exactly what I want. To be more specific: I'm trying to write a notebook for fitting a model function to experimental data, and I want it to be reusable since I'll have to use it on different data files again and again. I want to plot the data and the model inside a Manipulate, and use the sliders to adjust reasonable startig values for my parameters. That does work very well, but the next step would be to insert these starting values (from the slider adjustments) as starting values in FindFit. How do I achieve this? I don't understand how I could use DynamicModule to do this, but what other options do I have. === Subject: Re: pure function with an NIntegrate command Hi Ruth, Can't see the problem with NIntegrate: In[1] = Efun[x_, y_, z_] :=x + y + z; fintn = NIntegrate[Efun[x, ##3], {x, #1, #2}] &; I have redefined your function a bit so that it takes the lower limit explicitly, but this does not matter here. In[2] = fintn[0, #, 0.2, 0.3] & /@ Range[150] // Short // Timing {1.171,{1.,<<148>>,11325.}} I don't see however what do you gain by insisting on the use of pure functions - the speed-up is marginal: In[3] = fintnp[list_, y_, z_] := NIntegrate[Efun[x, y, z], {x, 0, #}] & /@ list; In[4] = fintnp[Range[150], 0.2, 0.3] // Short // Timing Out[4] ={1.182,{1.,<<148>>,11325.}} This does not really seem to be the case where the use of pure functions will lead to a major speed-up, since the main time is spent anyway by the integration routine. One suggestion would be to integrate the function analytically if possible, and only once. Here is the code that does this, and automatically takes int= o account the variable number of arguments: In[5] = Clear[integr]; integr[f_, x_, pars___] := With[{params = Table[Unique[], {Length[{pars}]}]}, With[{patterns = Sequence @@ Map[Pattern[#, Blank[]] &, params]}, integr[f, x1_, patterns] = Integrate[f[x1, Sequence @@ params], x1]; integr[f, x, pars]]]; Clear[integratedFunction]; integratedFunction[f_, {lower_, higher_}, params___] := integr[f, higher, params] - integr[f, lower, params] ; It takes the function name as a first explicit argument. It uses a generalized memoization (dynamic programming) with patterns, to compute the integral upon the first call with this function and this number of parameters, and stores the result as a formula. The function is auxilliary and could be made local in principle. Now: In[6] = Clear[Efun]; Efun[x_, y_] := x + y; Efun[x_, y_, z_] :=x + y + z; In[7] = integratedFunction[Efun, #, 0.2, 0.3] & /@ Table[{0, i}, {i, 150}= ] // Short // Timing Out[7] = {0.01,{1.,3.,6.,10.,<<143>>,11026.,11175.,11325.}} In[8] = integratedFunction[Efun, #, 0.2] & /@ Table[{0, i}, {i, 150}] // Short // Timing Out[8] = {2.16493*10^-15,{0.7,2.4,5.1,<<144>>,10981.6,11130.3,11280.}} If explicit (analytical) integration is not an option, I have 2 more suggestions. First, you may try to use Compile in defining your Efun function for each particular set of parameters. Second, you may use the additive nature of integration, and for every limit compute only the integral from the previous limit to this one rather than from 0 to this one= . You then use FoldList to accumulate the results (you can also combine these two improvements, of course). Here is the code that does it: In[9] = Clear[integrateVariousLimits]; integrateVariousLimits[f_, {params___}, limits_List, lowerLimit_: 0]:= Rest@FoldList[#1 + f[Sequence @@ #2, params] &, 0, Partition[Prepend[Sort@limits, lowerLimit], 2, 1]]; Note that here by we mean the integrator function (like your fintn). Note that by default all your integrals have 0 as their lower limit. Example: In[10] = integrateVariousLimits[fintn, {0.2, 0.3}, Range[150]] // Short // Timing Out[10] = {1.021,{1.,<<148>>,11325.}} This latter method does not buy you much in this example, but can be especially useful if the integrated function contains one or more regions where integration slows down significantly (say, singularities), since the= n such regions are only encountered once for your list of limits (assuming that such regions are well-localized). Leonid te: I posted a question yesterday about pure functions. Probably when you > receive this message someone would have > posted a solution. While I was waiting I managed to come closer to a > possible solution, and the encountered another > problem. This is my problem. I define a function Efun[x_, y_, z_] := x + y + z and then this other one, which does an integral using the previous functi= on fintnp[list_, y_, z_] :=NIntegrate[Efun[x, y, z], {x, 0, #}] & /@ list In my computer I run fintnp[{1, 2, 3, 4}, 0.2, 0.3] // Timing and get {0.020001, {1., 3., 6., 10.}} Now I want to construct a pure version of fintnp so that when the list > is long I save a good load of time. My first approach is fint = Integrate[Efun[x, ##2], {x, 0, #1}] & It gives the correct results but it is significantly slower because I > use Integrate instead of NIntegrate, so I naively define fintn= NIntegrate[Efun[x, ##2], {x, 0, #1}] & and then get errors indicating the definition is not good. Can someone > help me? > Ruth PD: Mathgroup is awesome, it has been amazingly useful for my work, and > all the things I learn here made me a stronger Mathematica advocate anyda= y. === Subject: Re: pure function with optional number of arguments Yes indeed you are right, sorry for the confusion - just a stupid mistake. I had in mind an (irrelevant to this problem) possibility to use Function[Null, body[##],Attributes] to give attributes to pure functions defined with slots, which I believe is an undocumented feature (at least, according to Roman Maeder as of v.4 - may be now it is, but I did not see it). Leonid 2009/4/22 Szabolcs Horv=E1t > Hi Ruth, >> You can use the undocumented form of the pure function which can take an= y >> number of arguments: >> Function[Null, body[##]]. > > This is a standard documented feature. See these doc pages: http://reference.wolfram.com/mathematica/ref/Function.html#29126 > http://reference.wolfram.com/mathematica/ref/SlotSequence.html > === Subject: Re: pure function with optional number of arguments > Hi Ruth, You can use the undocumented form of the pure function which can take any > number of arguments: Function[Null, body[##]]. This is a standard documented feature. See these doc pages: http://reference.wolfram.com/mathematica/ref/Function.html#29126 http://reference.wolfram.com/mathematica/ref/SlotSequence.html === Subject: Re: Looking for more Mathematica online user groups/forums > I've more often tended to describe some of these policies as > insane, but one of the recent supportive emails I received from > another lurker on the group (and I do get a modest number of such > private but supportive communications) used instead the term looney, > and I think that's even better, or at least more picturesque. Yes, indeed. Actually, this reminds me a lot of the following famous exchange: LE VICOMTE: Maraud, faquin, butor de pied plat ridicule! CYRANO: Ah?...Et moi, Cyrano-Svinien-Hercule De Bergerac. Andrzej Kozlowski === Subject: Using a jpg picture for a 2D plot background Hi: I would like to use a jpg picture as a background for a 2D plot in Mathematica 6.0.1, on a PC using Win XP. I'm not sure if this can be done. If this can be done, can someone please give me the code to do this? WDW === Subject: Re: Modifying List Elements. data = {{0, 1}, {1, 2}}; # + {0, 0.5} & /@ data {{0, 1.5}, {1, 2.5}} That's a pure Function, which you can find out about by looking up Function in Help, if you are not already familiar with it. And /@ is Map. David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ how can i add a value to an element in lists? data: {{0,1},{1,2}} needed output: {{0,1.5},{1,2.5}} === Subject: Re: Modifying List Elements. data = {{0, 1}, {1, 2}}; {0, 0.5} + # & /@ data {{0, 1.5}, {1, 2.5}} Bob Hanlon how can i add a value to an element in lists? data: {{0,1},{1,2}} needed output: {{0,1.5},{1,2.5}} === Subject: Re: Mathematica in conjunction with outside program; NMinimize fails. > Hello mathgroup. I am using Mathematica in conjunction with an > outside program (Netlogo is the program.) In a nutshell, my error is = > the following: I can call the outside program with a numeric value > successfully, and Plot can call the outside program as one would > expect. However, NMinimize calls the outside program with the > variable name, not a value, so it fails. In short, I need to force > NMinimize to pass a numeric value to the objective function, not a > variable name. More details: I have the following functions defined in Mathematica: SingleModelRun[ parametervalue_ ] := ....(definition ir= relevant) > This function (successfully) runs the out= side program, setting a > parameter equal to parametervalue (which is some number when I call > the function). It returns a value from the model. Plot[ SingleModelRun[ x ], {x , 0, 1} ] > Does what you expect: runs SingleModelRun= for parameter values 0 > through 1, and plots the resulting return value each time. NMinimize[ - SingleModelRun[ myvalue ], {myvalue} ] > Does not work. Returns the following e= rror: NetLogo`Private`NetLogo::compilerExcepti= on : Nothing named > MYVALUE has been defined (Note: NetLogo is the name of the outside program.) Which means that, oddly, NMinimize passes the *variable name* > (myvalue) instead of the *variable value* to the function > SingleModelRun; otherwise, there is no way the outside program would > be aware of the variable name. Is there a way to force Mathematica to evaluate the funct= ion with a > numeric value, not the variable name? (I thought that's what N in = > NMinimize meant, but apparently not.) In case you were wondering, this fails in an identical wa= y with: > NMaximize, FindMaximum, FindMimimum, etc. > Andreas Duus Pape answer at the end if you do not abort it. kamil === Subject: Re: fit a complex function you can not directly fit a complex function. But you may defined an error function of the parameters, that returns a real number, specifying the error. If you then search the minimum of this function over the parameters, you have solved your problem. here is a simplified version with 1 dim. where we fit Exp[I a x]: d = Table[{x, Exp[2 I x]}, {x, 0, Pi, Pi/10}]; err[a_] := Total[Abs[ d[[All, 2]] - ( Exp[a I #] & /@ d[[All, 1]])]^2]; FindMinimum[err[a], a] Daniel > I have data in the following form xi , Fi (xi is real but Fi is complex) i want to determine a fit by using function F(x, a , b,c, d)= a Exp(- x^2/b) + c Sin( d x) a, b, c and d are complex numbers to be determined so as to accurately > represent the data. How to do this problem? === Subject: Re: fit a complex function I may be wrong here, but I don't think that you can do a non-linear fit with complex numbers. > I have data in the following form xi , Fi (xi is real but Fi is complex) i want to determine a fit by using function F(x, a , b,c, d)= a Exp(- x^2/b) + c Sin( d x) a, b, c and d are complex numbers to be determined so as to accurately > represent the data. How to do this problem? === Subject: Re: Help with Speeding up a For loop A smaller additional speedup can be had by using one call to RandomReal to get the normals, e.g. Resolution = RandomReal[NormalDistribution[0, Sigma], Length[Ideal]] + Ideal This uses the fact that if z follows NormalDistribution[0,sigma], mu+z follows NormalDistribution[mu,sigma]. This is more efficient because it is faster to get a bunch of random numbers in one call than to get them one at a time and the addition of Ideal is comparatively very fast. Darren Glosemeyer Wolfram Research > Hi Adam, first note that indices in Mathematica start at 1, not 0. Then I set the start value of Ideal and Resolution to an empty list. With this changes, your loop can be replaced by: Ideal = Pick[Eb1, Thread@Less[k, Re[(E0 - Eb1)^2*Sqrt[1 - m^2/(E0 - Eb1)^2]]] ]; Resolution = RandomReal[NormalDistribution[#, Sigma]] & /@ Ideal; For n=10^7, this takes 7.5 sec. Daniel > >> I am using an Intel MacBook with OS X 10.5.6. >> >> I am trying to create 2 lists: Ideal and Resolution. This is basically >> >> a Monte Carlo Integration technique. Ideal should simulate the curve. >> >> Resolution should simulate the curve convoluted with a normal distribution. >> >> I want to do this for n=10 000 000 or more, but it takes far too long right >> >> now. I can do n=100 000 in about 1 minute, but 1 000 000 takes more than an >> >> hour. I haven't waited long enough for 10 000 000 to finish (it has been 5 >> >> days). >> >> >> Adam Dally >> >> Here is the code: >> >> ClearAll[E0, Eb1, m, DeltaE, Sigma, k, n, y3, Ideal, Resolution, i, >> >> normalizer, maxE, minE] >> >> Eb1 = 0; k = 0; n = 10000; E0 = 2470; m = 0.2; DeltaE = 50; Sigma = 5; maxE >> >> = E0 - m; minE = E0 - DeltaE; Resolution = {Eb1}; Ideal = {Eb1}; (*Setup >> >> all constants, lists and ranges*) >> >> Eb1 = RandomReal[{minE, maxE}, n]; (*create a list of 'n' random Eb1 >> >> values*) >> >> k = -RandomReal[TriangularDistribution[{-2470, 0}, -0.1], n]; (*create a >> >> list of 'n' random k values; triangle distribution gives more successful >> >> results*) >> >> For[i = 0, i < n, i++, >> >> If[k[[i]] < Re[(E0 - Eb1[[i]])^2*Sqrt[1 - m^2/(E0 - Eb1[[i]])^2]], (*check >> >> if the {k,Eb1} value is under the curve*) >> >> AppendTo[Ideal, Eb1[[i]]]; (*Keep events under curve in 'Ideal'*) >> >> y3 = Eb1[[i]]; (*cast element to a number*) >> >> Eb1[[i]] = RandomReal[NormalDistribution[y3, Sigma], 1]; (*choose a >> >> random number from a normal distribution about that point*) >> >> AppendTo[Resolution, Eb1[[i]]]; ]] (*Keep that event in 'Resolution'*) >> > === Subject: Re: representing the dihedral group >> The dihedral group of order 2n may be represented as >> . Hmm.. I don't see how is isomorphic to > the dihedral group of order 2n. Using generators {r,s}, the > relationship rs=s(r^-1) is satisfied. But abb = a which does not equal > b(ab)^-1 = b*b^-1*a^-1 = a^-1. Can you explain? First, a does equal a^(-1), right? There is a fairly obvious homomorphism from your representation to mine generated by r -> ab s -> a We can show this homomorphism is surjective using the canonical forms in my representation. There was, however, a typo in my previous message. The four canonical forms should be (a*b)^m (a*b)^m * a (b*a)^m (b*a)^m * b Note that I had the trailing a and b switched before. Now we simply have to show that some element in your representation maps to each possible form. It's not too hard to check that r^m -> (a*b)^m r^m * s -> (a*b)^m * a r^(-m) -> (b*a)^m r^(-m) * s*r -> (b*a)^-m * b Mark === Subject: Change Figure according to Session Time Hi community, First,some definitions following: (*define a dancer figure*) dancer[n_Integer: 1, v_Integer, figure_List] := Graphics@{Line[{figure[[v, 1]] - {0, 0.25} + {2 n, 0}, figure[[v, 7]] + {2 n, 0}, figure[[v, 2]] + {2 n, 0}}],(*torso*) Line[{figure[[v, 2]] + {2 n, 0}, figure[[v, 3]] + {2 n, 0}, figure[[v, 4]] + {2 n, 0}}],(*right leg*) Line[{figure[[v, 2]] + {2 n, 0}, figure[[v, 5]] + {2 n, 0}, figure[[v, 6]] + {2 n, 0}}],(*left leg*) Line[{figure[[v, 7]] + {2 n, 0}, figure[[v, 8]] + {2 n, 0}, figure[[v, 9]] + {2 n, 0}}],(*right arm*) Line[{figure[[v, 7]] + {2 n, 0}, figure[[v, 10]] + {2 n, 0}, figure[[v, 11]] + {2 n, 0}}],(*left arm*)White, Disk[figure[[v, 1]] + {2 n, 0}, 0.25],(*head-- eclipses neck/ shoulders if necessary*)Black, Circle[figure[[v, 1]] + {2 n, 0}, 0.25] (*head*)}; locators = {(*1*){(*head*){0, 0.75},(*groin*){0, 0},(*right knee*){-0.3, -0.4}, {-0.2, -0.9},(*left knee*){0.2, -0.4}, {0.3, -0.9},(*collar*){0, 0.4},(*elbows*){-0.4, 0.3}, {-0.8, 0.5},(*hands*){0.6, 0.4}, {0, 0}},(*=D7=F3=CA=D6=B2=E6=D1=FC*)(*2*){(*= head*){-0.07, 0.75},(*groin*){0., 0.},(*right knee*){-0.4, -0.07}, {-0.07, -0.5},(*left knee*){0.1, -0.4}, {0.1, -0.9},(*collar*){0, 0.3},(*right arm*){-0.4, 0.25}, {-0.9, 0.3},(*left arm*){0.3, 0.7}, {0.3, 1.2}},(*=BD=F0=BC=A6=B6=C0=C1=A2*)(*3*){(*head*){0, 0.75},(*groin*){0.= , 0.},(*right knee*){-0.3, -0.3}, {-0.7, -0.6},(*left knee*){0.4, -0.3}, {0.8, -0.6},(*collar*){0, 0.3},(*right arm*){-0.7, 1.1}, {-0.85, 1.15},(*left arm*){0.6, 0.7}, {0.2, 1.1}},(*=CB=C4=D6=AB=D5=B9=BF=AA*)(*4*){(*head*){0, 0.75},(*groin*){0.= , 0.},(*right knee*){-0.4, -0.2}, {-0.3, -0.6},(*left knee*){0.4, -0.2}, {0.3, -0.6},(*collar*){0, 0.3},(*right arm*){-0.5, 0.4}, {-0.4, 0.8},(*left arm*){0.5, 0.4}, {0.4, 0.8}},(*=C2=DE=C8=A6=CD=C8=BE=D9=CA=D6*)(*5*){(*head*){0, 0.75},(*groi= n*){0, 0},(*right knee*){-0.2, -0.4}, {-0.3, -0.9},(*left knee*){0.3, -0.4}, {0.2, -0.9},(*collar*){0, 0.4},(*elbows*){-0.6, 0.4}, {0, 0},(*hands*){0.4, 0.3}, {0.8, 0.5}},(*=D3=D2=CA=D6=B2=E6=D1=FC*)(*6*){= (*head*){0, 0.75},(*groin*){0., 0.},(*right knee*){-0.2, -0.4}, {-0.3, -0.9},(*left knee*){0.2, -0.4}, {0.3, -0.9},(*collar*){0, 0.35},(*right arm*){-0.5, -0.1}, {-0.7, 0.1},(*left arm*){0.5, -0.1}, {0.7, 0.1}},(*=CB=AB=CA=D6=B5=CD=B7=C5*)(*7*){(*head*){0.07, 0.75},(*groin*)= {0., 0.},(*right knee*){-0.2, -0.4}, {-0.3, -0.9},(*left knee*){0.2, -0.4}, {0.3, -0.9},(*collar*){0, 0.3},(*right arm*){-0.25, 0.6}, {-0.2, 1.2},(*left arm*){0.15, 0.15}, {0.3, -0.3}},(*=BE=D9=C6=F0=D2=BB=D6=BB=CA=D6*)(*8*){(*head*){-= 0.07, 0.75},(*groin*){0., 0.},(*right knee*){-0.3, -0.5}, {-0.4, -0.4},(*left knee*){0.1, -0.4}, {-0.2, -0.8},(*collar*){0, 0.3},(*right arm*){-0.5, 0.1}, {-0.6, 0.2},(*left arm*){0.1, 1.1}, {-0.03, 1.15}},(*=CE=D2=D2=AA=B7=C9*)(*9*){(*head*){-0.07, 0.75},(*groin*){0., 0.},(*right knee*){-0.6, 0.6}, {-0.8, 0.76},(*left knee*){0.1, -0.4}, {0.2, -0.8},(*collar*){0, 0.3},(*right arm*){-0.3, 0.5}, {-0.45, 1.0},(*left arm*){0.3, 0.5}, {0.45, 1.0}},(*=CC=A7=C6=F0=D2=BB=CC=F5=CD=C8*)(*10*){(*head*){0= .2, 0.75},(*groin*){0., 0.},(*right knee*){0.1, -0.4}, {0.2, -0.8},(*left knee*){0.4, -0.3}, {0.8, -0.6},(*collar*){0.13, 0.325},(*right arm*){-0.3, 1.1}, {-0.4, 1.0},(*left arm*){0.5, 0.1}, {0.8, 0.05}},(*=B7=C9=CF=E8*)(*11*){(*head*){0.07, 0.75},(*groin*){0., 0.},(*right knee*){-0.2, -0.4}, {-0.3, -0.9},(*left knee*){0.2, -0.4}, {0.3, -0.9},(*collar*){0, 0.3},(*right arm*){-0.45, 0.45}, {-0.1, 0.65},(*left arm*){0.5, 0.15}, {0, 0.05}},(*=BD=BB=B2=E6=CA=D6*)(*12*){(*head*){0.145, 0.55},(*groin*){0.= , 0.},(*right knee*){-0.2, -0.4}, {-0.3, -0.9},(*left knee*){0.2, -0.4}, {0.3, -0.9},(*collar*){0, 0.3},(*right arm*){-0.5, 0.4}, {-0.4, 0.8},(*left arm*){0.5, 0.4}, {0.4, 0.8}},(*=D6=BB=BE=D9=CA=D6*)(*13*){(*head*){0.125, 0.75},(*groin*){0., 0.},(*right knee*){-0.2, -0.4}, {-0.3, -0.9},(*left knee*){0.2, -0.4}, {0.3, 0.3},(*collar*){0, 0.3},(*right arm*){-0.5, 0.4}, {-0.4, 0.8},(*left arm*){0.5, 0.4}, {0.4, 0.8}},(*=CC=A7=D3=D2=CD=C8=BE=D9=CA=D6*)(*14*){(*head*){0.135, 0.65},(= *groin*){0., 0.},(*right knee*){-0.2, -0.4}, {-0.3, 0.3},(*left knee*){0.2, -0.4}, {0.3, -0.9},(*collar*){0, 0.3},(*right arm*){-0.5, 0.4}, {-0.4, 0.8},(*left arm*){0.5, 0.4}, {0.4, 0.8}},(*=CC=A7=D7=F3=CD=C8=BE=D9=CA=D6*)(*15*){(*head*){0,= 0.75},(*groin*){0., 0.},(*right knee*){-0.2, -0.4}, {-0.3, -0.9},(*left knee*){0.2, -0.4}, {0.3, -0.9},(*collar*){0, 0.3},(*right arm*){-0.5, 0.6}, {0, 1.2},(*left arm*){0.5, 0.6}, {0, 1.2}},(*=CB=AB=CA=D6=BD=BB=B2=E6=D7=B4*)(*16*){(*head*){-0.125, 0.75},= (*groin*){0., 0.},(*right knee*){-0.2, -0.4}, {-0.3, -0.9},(*left knee*){0.2, -0.4}, {0.3, 0.3},(*collar*){0, 0.3},(*right arm*){-0.5, 0.6}, {0, 1.2},(*left arm*){0.5, 0.6}, {0, 1.2}},(*=CB=AB=CA=D6=BD=BB=B2=E6=CC=A7=D3=D2=CD=C8*)(*17*){(*head*){-0= .125, 0.75},(*groin*){0., 0.},(*right knee*){-0.2, -0.4}, {-0.3, 0.3},(*left knee*){0.2, -0.4}, {0.3, -0.9},(*collar*){0, 0.3},(*right arm*){-0.5, 0.6}, {0, 1.2},(*left arm*){0.5, 0.6}, {0, 1.2}},(*=CB=AB=CA=D6=BD=BB=B2=E6=CC=A7=D7=F3=CD=C8*)(*18*){(= *head*){-0.125, 0.75},(*groin*){0., 0.},(*right knee*){-0.2, -0.4}, {0, -0.9},(*left knee*){0.2, -0.4}, {0, -0.9},(*collar*){0, 0.3},(*right arm*){-0.5, 0.6}, {0, 1.2},(*left arm*){0.5, 0.6}, {0, 1.2}},(*=D0=A1=CC=EC=B6=EC=CE=E8=B2=BD*)(*19*){(*head*){0.125, 0.75},(= *groin*){0, 0},(*right knee*){-0.2, -0.4}, {-0.3, -0.9},(*left knee*){0.2, -0.4}, {0.3, -0.9},(*collar*){0, 0.4},(*elbows*){-0.6, 0.4}, {-0.6, 1.0},(*hands*){0.4, 0.3}, {0.8, 0.5}},(*=B7=C5=CF=C2=D3=D2=CA=D6*)(*20*){(*head*){-0.125, 0.75},(*groi= n*){0, 0},(*right knee*){-0.2, -0.4}, {-0.3, -0.9},(*left knee*){0.2, -0.4}, {0.3, -0.9},(*collar*){0, 0.4},(*elbows*){-0.4, 0.3}, {-0.8, 0.5},(*hands*){0.6, 0.5}, {0.6, 1.0}}(*=B7=C5=CF=C2=D7=F3=CA=D6*)}; (*sn1 for SoundNote pitch, sn2 for duration of according note*) sn1 = {-9, -9, -5, -5, -9, -9, -9, 3, -7, -7, -7, -4, -4, 0, -4, -7, -2, 5, 10, 10, 2, 2, 5, 2, -9, -9, -5, -5, -5, 3, -9, -2}; sn2 = {.00001, 1, 3, 3, 1, 1, 3, 3, 1, 1, 3, 3, 1, 1, 3, 3, 1, 1, 3, 3, 1, 1, 3, 3, 1, 1, 3, 3, 1, 1, 3, 3, 1, .00001}; sn2c = Accumulate@sn2/8; sn2s = Table[{sn2c[[i]], sn2c[[i + 1]]}, {i, Length[sn2c] - 1}]; (*pos changing according to Session Time, in order to get corresponding note in sn1*) pos := Position[sn2s, {_, _}?((#[[1]] < t <= #[[2]]) &)][[1, 1]]; pos1 = pos; pos2 = pos; (*offset as the name means, t for time starts form offset*) offset = SessionTime[]; t := SessionTime[] - offset; I'm really puzzled by the following codes: Dynamic[ Clock[1]; Panel[ If[pos2 != pos1 && t < 8.1, pos2 = pos; pd = dancer[1, RandomInteger[{1, 20}], locators]; EmitSound[ Sound[ SoundNote[ sn1[[pos]],sn2[[pos]] ] ] ] ] ] pos1 = pos; ] I meant to emit sound and display a dancer figure corresponding to every change of sound while time passing, but I can't realize it. How to do it? === Subject: Re: Remote Kernel Connection Error with the information you provide it is hard to diagose anything. (1) Does the kernel process start on the remote machine? You see this using top or the like... Does it die immediately? (2) If not, did you use the correct ip adresses, passwords, accounts. Are ssh connections allowed on the remote machine. (3) If yes, what is the exact command used to start the connection. Seen in the remote kernel configuration menu. In any case, I know that a configuration like you envisage, does work here. Michael > Hi! > I am trying to use a remote kernel, installed on a Linux machine. > I have no problem in setting up the ssh link with this machine using > the Windows Vista version of mathematica 7.0, but with the mathematica > which is installed on Linux (opensuse 11.1) I get this error (after I > specify the kernel host in notebook kernel, and I authenticate with > the password): The kernel REMOTEKERNEL failed to connect to the front end. (Error = > MLECONNECT). You should try running the kernel connection outside the > front end. Any Idea how to workaround this? > Maybe I have some permission/firewall problem (actually the firewall > is unloaded)? Davide > === Subject: Re: Remote Kernel Connection Error > Hi! > I am trying to use a remote kernel, installed on a Linux machine. > I have no problem in setting up the ssh link with this machine using > the Windows Vista version of mathematica 7.0, but with the mathematica > which is installed on Linux (opensuse 11.1) I get this error (after I > specify the kernel host in notebook kernel, and I authenticate with > the password): The kernel REMOTEKERNEL failed to connect to the front end. (Error = > MLECONNECT). You should try running the kernel connection outside the > front end. Any Idea how to workaround this? > Maybe I have some permission/firewall problem (actually the firewall > is unloaded)? Davide Perhaps the problem might have something to do with connecting to the correct ports? You might look at a post from last summer -- see http://forums.wolfram.com/mathgroup/archive/2008/Jul/msg00296.html for more details... -Bob === Subject: Re: fit a complex function I have data in the following form xi , Fi (xi is real but Fi is complex) i want to determine a fit by using function F(x, a , b,c, d)= a Exp(- x^2/b) + c Sin( d x) a, b, c and d are complex numbers to be determined so as to accurately represent the data. How to do this problem? In principle, FindFit should be able to solve your problem -- 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: 3D Agent Problem I am trying to set up a 3D environment having 'agents' and 'stuff' whose > coordinates are random real numbers. The program should then move the agents towards the closest stuff in > increments of, say, .1 units. I was able to create a program that did what I need for one iteration, but > am having problems making it iterative... below is the code. I'm > inexperienced and learning quickly but would really appreciate any guidance > on iterating this system. ***************** > Making a World of Agents and Stuff MakeNewWorld[Agents_] := > Partition[Flatten[ > Riffle[Table[RandomReal[{-10, 10}, {Agents, 3}]], > Table[RandomInteger[9, 3], {Agents}]]], 6, 6] MakeNewStuff[Resources_] := Table[RandomReal[{-10, 10}, {Resources, 3}]] agentpos1 = MakeNewWorld[10][[All, 1 ;; 3]]; > stuffpos1 = MakeNewStuff[5]; ListPointPlot3D[{agentpos1, stuffpos1 }, PlotStyle -> PointSize[Large]] ***** 3D plot of agent positions and stuff positions ******* The Problem of Movement Agents search for nearest stuff and move along the vector between their > current position and that of the stuff. Ax = agentpos1[[All, 1]]; > Bx = stuffpos1[[All, 1]]; > Ay = agentpos1[[All, 2]]; > By = stuffpos1[[All, 2]]; > Az = agentpos1[[All, 3]]; > Bz = stuffpos1[[All, 3]]; dx = Part[Ax, #] - Bx &; > dy = Part[Ay, #] - By &; > dz = Part[Az, #] - Bz &; TOTdx = dx /@ {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; > TOTdy = dy /@ {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; > TOTdz = dz /@ {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; squared = #^2 &; distance = (squared /@ TOTdx + squared /@ TOTdy + squared /@ TOTdz)^.5; mindistance = Min /@ distance; stufffinder = Flatten[Position[distance, #]] &; stuffpositions = Flatten[stufffinder ] /@ mindistance; newstuff = stuffpositions[[All, 2]]; coords = Part[stuffpos1, #] &; stuffcoords = coords /@ newstuff; WalkFunct2 = > If[Part[Flatten[agentpos1], #] < Part[Flatten[stuffcoords], #], > Part[Flatten[agentpos1], #] + .5, Part[Flatten[agentpos1], #] - .5] &; newagentcoords = > WalkFunct2 /@ {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, > 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30}; agentpos2 = Partition[newagentcoords, 3, 3, {1, 3}]; ListPointPlot3D[{agentpos2, stuffpos1 }, PlotStyle -> PointSize[Large]] > You are making this more complicated than necessary by focussing on breaking apart things into coordinates rather than operating on the lists as entire entities. Also some of the initialization code suffers from a bit of funk. I instead proceed as below. makeNewWorld[agents_] := Apply[Join, Partition[ Riffle[RandomReal[{-10, 10}, {agents, 3}], RandomInteger[9, {agents, 3}]], 2], 1] makeNewStuff[resources_] := RandomReal[{-10, 10}, {resources, 3}] agentlocations = makeNewWorld[10][[All, 1 ;; 3]]; stufflocations = makeNewStuff[5]; To iterate the incremental moves you could use NestList. One way to code this is shown below. Notice that all the action takes place in just a few lines. steplist = NestList[Function[{ll}, (distances = Outer[Norm[#1 - #2] &, ll, stufflocations, 1]; stuffpositions = Map[First[Ordering[#, 1]] &, distances]; stuffcoords = stufflocations[[stuffpositions]]; steps = .1*Sign[stuffcoords - ll]; ll + steps)], agentlocations, 60]; This next provides a simple way to vislauize the incremental moves as agents approach stuff. Manipulate[ ListPointPlot3D[{steplist[[j]], stufflocations}, PlotStyle -> PointSize[Large]], {j, 1, Length[steplist], 1}] Note that our incremental moves have discrete size of 0.1 and so we eventually get to locations where agents will step back and forth in the vicinity of the stuff. I assume this is the sort of thing you intend to refine later. Speaking of refinements, it might get quite interesting if agents also sense proximity of other agents, so they can adjust their notion of nearest to maybe move toward things that are not objects of great desire. (Okay, this would NEVER happen in the real world...) By the way, that NestList can be compactified, though doing so makes it ever the more difficult to follow. Anyway, for those who like such things, the variant below works. steplist = NestList[# + Sign[ stufflocations[[Map[First[Ordering[#, 1]] &, Outer[Norm[#1 - #2] &, #, stufflocations, 1]]]] - #]/10. &, agentlocations, 60]; I'd imagine one could squeeze still further. The main reason to do this is to avoid use of global variables, and a cleaner approach would be to skip compactification and put the whole mess inside a Module. Daniel Lichtblau Wolfram Research === Subject: Plot x to y and y to x I'm a complete newbie to Mathematica and I can't seem to get it to plot what I want. I need to plot a increase in temp. for x to y then I would like to see what happens when the temp. decreases from y to x. Is there an easy way to create these two plots? === Subject: Re: Using the slider values in a Manipulate > How can I use the values adjusted with the sliders in a Manipulate > later in the notebook? > The only way seems to be the DynamicModule, but that's not exactly > what I want. > To be more specific: I'm trying to write a notebook for fitting a > model function to experimental data, and I want it to be reusable > since I'll have to use it on different data files again and again. > I want to plot the data and the model inside a Manipulate, and use the > sliders to adjust reasonable startig values for my parameters. That > does work very well, but the next step would be to insert these > starting values (from the slider adjustments) as starting values in > FindFit. How do I achieve this? I don't understand how I could use > DynamicModule to do this, but what other options do I have. One very simple way of doing this is to pass the option LocalizeVariables->False to the Manipulate[] command. This option indicates to Manipulate that the variables associated with the various controls should be global variables rather than variables scoped in a DynamicModule[]. Of course, if you do this, you'll want to make sure not to choose names that are too generic and likely to be accidentally used elsewhere in your code. John Fultz jfultz@wolfram.com User Interface Group Wolfram Research, Inc. === Subject: Re: Bug in Rational arithmetic? > I am running Mathematica 5.1 for Linux. I know that this is an old > version and don't expect a fix to my software. It would be good to > know whether anyone can reproduce this problem with mine or any other > version of the software. If the members of this list (and the > moderator) don't object, I could post the 900+ line input file as a > follow-up. Otherwise, does anyone know a good place to upload this > file? Daniel Lichtblau followed this up with me offline. The short of it is that, yes, I uncovered a real bug that existed in Mathematica from versions. Scott -- Scott Hemphill hemphill@alumni.caltech.edu This isn't flying. This is falling, with style. -- Buzz Lightyear === Subject: Mathematica JLink and comm.javax.CommPortIdentifier I would like to use JLink to perform serial communication functions with Mathematica. It appears that javacomm api for Windows is no longer supported by Sun. So as an alternative I am attempting to use RxTx as a substitute. When I attempt to run: In[2]:= InstallJava[] Out[2]= LinkObject[C:Program FilesWolfram ResearchMathematica7.0SystemFilesJavaWindowsbinjavaw -classpath C:Program FilesWolfram ResearchMathematica7.0SystemFilesLinksJLinkJLink.jar -Xmx256m -Djava.system.class.loader=com.wolfram.jlink.JLinkSystemClassLoader com.wolfram.jlink.Install -init C:Documents and SettingsckoehlerLocal SettingsTempm19.tmp,4,4] I assume that I have installed the rxtx dll and jar files in the correct location. LoadJavaClass[comm.javax.CommPortIdentifier] I receive the following error: Java::excptn: A Java exception occurred: java.lang.ClassNotFoundException: comm.javax.CommPortIdentifier at java.net.URLClassLoader$1.run(URLClassLoader.java:200) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:188) at java.lang.ClassLoader.loadClass(ClassLoader.java:307) at java.lang.ClassLoader.loadClass(ClassLoader.java:252) at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:247). LoadJavaClass::fail: Java failed to load class comm.javax.CommPortIdentifier. >> I realize this is may not be the appropriate newsgroup for this, but the only documentation I could find regarding Jlink is out of data. Chuck Koehler === Subject: Re: Has Fourier been fixed in Mathematica 7 if you are referring to the kind of misbehaviour described in the post: http://forums.wolfram.com/mathgroup/archive/2008/Nov/msg00707.html the answer is yes, it has been fixed in the new release. Cordially Guy Lamouche I am interested in upgrading to Mathematica 7 in order to support our > Mathematica Add-On for time-frequency analysis: http://www.ffconsultancy.com/products/CWT/index.html?mma I tried an early version of Mathematica 7 and it was quite fragile due to > a > bug in the Fourier routine. Is there a new release of Mathematica 7 that fixes this and, if so, are > there any remaining issues with Fourier? -- > Dr Jon D Harrop, Flying Frog Consultancy Ltd. > http://www.ffconsultancy.com/?u > === Subject: MatrixPlot with color range bar I'd like to draw plots like http://www.gle-graphics.org/examples/3dplots/informationgain.png I know that MatrixPlot function draws such plots. My question is how to draw color range bar like that on the right side of the plot at the url. Is there any options of MatrixPlot or tricks to draw such color range bar ? === Subject: Re: Help with Speeding up a For loop Hi Darren, you are right of course. This was easy, but I hope you will not mind if I will ask you occasionally a question I can not get an answer. There are not too many knowledgeable people around. Daniel > A smaller additional speedup can be had by using one call to RandomReal > to get the normals, e.g. Resolution = RandomReal[NormalDistribution[0, Sigma], Length[Ideal]] + > Ideal This uses the fact that if z follows NormalDistribution[0,sigma], mu+z > follows NormalDistribution[mu,sigma]. This is more efficient because it > is faster to get a bunch of random numbers in one call than to get them > one at a time and the addition of Ideal is comparatively very fast. Darren Glosemeyer > Wolfram Research > >> Hi Adam, >> first note that indices in Mathematica start at 1, not 0. >> Then I set the start value of Ideal and Resolution to an empty list. >> With this changes, your loop can be replaced by: >> Ideal = Pick[Eb1, >> Thread@Less[k, Re[(E0 - Eb1)^2*Sqrt[1 - m^2/(E0 - Eb1)^2]]] ]; >> Resolution = RandomReal[NormalDistribution[#, Sigma]] & /@ Ideal; >> For n=10^7, this takes 7.5 sec. >> Daniel >> > I am using an Intel MacBook with OS X 10.5.6. > >> >> > I am trying to create 2 lists: Ideal and Resolution. This is > basically > >> > a Monte Carlo Integration technique. Ideal should simulate the curve. > >> > Resolution should simulate the curve convoluted with a normal > distribution. > >> > I want to do this for n=10 000 000 or more, but it takes far too long > right > >> > now. I can do n=100 000 in about 1 minute, but 1 000 000 takes more > than an > >> > hour. I haven't waited long enough for 10 000 000 to finish (it has > been 5 > >> > days). > >> >> > >> > Adam Dally > >> >> > Here is the code: > >> >> > ClearAll[E0, Eb1, m, DeltaE, Sigma, k, n, y3, Ideal, Resolution, i, > >> > normalizer, maxE, minE] > >> > Eb1 = 0; k = 0; n = 10000; E0 = 2470; m = 0.2; DeltaE = 50; Sigma = > 5; maxE > >> > = E0 - m; minE = E0 - DeltaE; Resolution = {Eb1}; Ideal = {Eb1}; > (*Setup > >> > all constants, lists and ranges*) > >> >> > Eb1 = RandomReal[{minE, maxE}, n]; (*create a list of 'n' random Eb1 > >> > values*) > >> > k = -RandomReal[TriangularDistribution[{-2470, 0}, -0.1], n]; (*create a > >> > list of 'n' random k values; triangle distribution gives more successful > >> > results*) > >> >> > For[i = 0, i < n, i++, > >> >> > If[k[[i]] < Re[(E0 - Eb1[[i]])^2*Sqrt[1 - m^2/(E0 - Eb1[[i]])^2]], > (*check > >> > if the {k,Eb1} value is under the curve*) > >> > AppendTo[Ideal, Eb1[[i]]]; (*Keep events under curve in 'Ideal'*) > >> > y3 = Eb1[[i]]; (*cast element to a number*) > >> > Eb1[[i]] = RandomReal[NormalDistribution[y3, Sigma], 1]; (*choose a > >> > random number from a normal distribution about that point*) > >> > AppendTo[Resolution, Eb1[[i]]]; ]] (*Keep that event in > 'Resolution'*) > >> >> >> -- Daniel Huber Metrohm Ltd. Oberdorfstr. 68 CH-9100 Herisau Tel. +41 71 353 8585, Fax +41 71 353 8907 E-Mail: Internet: === Subject: Re: fitting surface with Mathematica 6.0.3 and range of fitted values it would help if you give a simple example. Without knowing more, I would guess that your fit wiggles between data points. This happens mainly if you have a high degree polynomial and only a few data points. Daniel > I'm trying to fit a surface with a Fit command and a 4th order > polynomial and I can get the fit and the model but then I try to > evaluate some data through the model and they are out of the range of > the original data, > I have looked around but I could not find an option to pass into Fit > command to keep the fitted values in the range of the possible cases > Simone > === Subject: Re: Change Figure according to Session Time here is the cleaned up code for the dancer. The sound you can do yourself. Daniel Dynamic[ Panel[ dancer[1, RandomInteger[{1, 16}], locators] ] , UpdateInterval -> 0.1] > Hi community, First,some definitions following: (*define a dancer figure*) > dancer[n_Integer: 1, v_Integer, figure_List] := > Graphics@{Line[{figure[[v, 1]] - {0, 0.25} + {2 n, 0}, > figure[[v, 7]] + {2 n, 0}, figure[[v, 2]] + {2 n, 0}}],(*torso*) > Line[{figure[[v, 2]] + {2 n, 0}, figure[[v, 3]] + {2 n, 0}, > figure[[v, 4]] + {2 n, 0}}],(*right leg*) > Line[{figure[[v, 2]] + {2 n, 0}, figure[[v, 5]] + {2 n, 0}, > figure[[v, 6]] + {2 n, 0}}],(*left leg*) > Line[{figure[[v, 7]] + {2 n, 0}, figure[[v, 8]] + {2 n, 0}, > figure[[v, 9]] + {2 n, 0}}],(*right arm*) > Line[{figure[[v, 7]] + {2 n, 0}, figure[[v, 10]] + {2 n, 0}, > figure[[v, 11]] + {2 n, 0}}],(*left arm*)White, > Disk[figure[[v, 1]] + {2 n, 0}, 0.25],(*head-- eclipses neck/ > shoulders if necessary*)Black, > Circle[figure[[v, 1]] + {2 n, 0}, 0.25] (*head*)}; > locators = {(*1*){(*head*){0, 0.75},(*groin*){0, > 0},(*right knee*){-0.3, -0.4}, {-0.2, -0.9},(*left knee*){0.2, > -0.4}, {0.3, -0.9},(*collar*){0, 0.4},(*elbows*){-0.4, 0.3}, {-0.8, > 0.5},(*hands*){0.6, 0.4}, {0, 0}},(*=D7=F3=CA=D6=B2=E6=D1=FC*)(*2*){(*= > head*){-0.07, > 0.75},(*groin*){0., > 0.},(*right knee*){-0.4, -0.07}, {-0.07, -0.5},(*left > knee*){0.1, -0.4}, {0.1, -0.9},(*collar*){0, 0.3},(*right arm*){-0.4, > 0.25}, {-0.9, 0.3},(*left arm*){0.3, 0.7}, {0.3, > 1.2}},(*=BD=F0=BC=A6=B6=C0=C1=A2*)(*3*){(*head*){0, 0.75},(*groin*){0.= > , > 0.},(*right knee*){-0.3, -0.3}, {-0.7, -0.6},(*left knee*){0.4, > -0.3}, {0.8, -0.6},(*collar*){0, 0.3},(*right arm*){-0.7, > 1.1}, {-0.85, 1.15},(*left arm*){0.6, 0.7}, {0.2, > 1.1}},(*=CB=C4=D6=AB=D5=B9=BF=AA*)(*4*){(*head*){0, 0.75},(*groin*){0.= > , > 0.},(*right knee*){-0.4, -0.2}, {-0.3, -0.6},(*left knee*){0.4, > -0.2}, {0.3, -0.6},(*collar*){0, 0.3},(*right arm*){-0.5, 0.4}, {-0.4, > 0.8},(*left arm*){0.5, 0.4}, {0.4, > 0.8}},(*=C2=DE=C8=A6=CD=C8=BE=D9=CA=D6*)(*5*){(*head*){0, 0.75},(*groi= > n*){0, > 0},(*right knee*){-0.2, -0.4}, {-0.3, -0.9},(*left knee*){0.3, > -0.4}, {0.2, -0.9},(*collar*){0, 0.4},(*elbows*){-0.6, 0.4}, {0, > 0},(*hands*){0.4, 0.3}, {0.8, 0.5}},(*=D3=D2=CA=D6=B2=E6=D1=FC*)(*6*){= > (*head*){0, > 0.75},(*groin*){0., > 0.},(*right knee*){-0.2, -0.4}, {-0.3, -0.9},(*left knee*){0.2, > -0.4}, {0.3, -0.9},(*collar*){0, > 0.35},(*right arm*){-0.5, -0.1}, {-0.7, > 0.1},(*left arm*){0.5, -0.1}, {0.7, > 0.1}},(*=CB=AB=CA=D6=B5=CD=B7=C5*)(*7*){(*head*){0.07, 0.75},(*groin*)= > {0., > 0.},(*right knee*){-0.2, -0.4}, {-0.3, -0.9},(*left knee*){0.2, > -0.4}, {0.3, -0.9},(*collar*){0, 0.3},(*right arm*){-0.25, > 0.6}, {-0.2, 1.2},(*left arm*){0.15, > 0.15}, {0.3, -0.3}},(*=BE=D9=C6=F0=D2=BB=D6=BB=CA=D6*)(*8*){(*head*){-= > 0.07, > 0.75},(*groin*){0., > 0.},(*right knee*){-0.3, -0.5}, {-0.4, -0.4},(*left knee*){0.1, > -0.4}, {-0.2, -0.8},(*collar*){0, 0.3},(*right arm*){-0.5, > 0.1}, {-0.6, 0.2},(*left arm*){0.1, 1.1}, {-0.03, > 1.15}},(*=CE=D2=D2=AA=B7=C9*)(*9*){(*head*){-0.07, 0.75},(*groin*){0., > 0.},(*right knee*){-0.6, 0.6}, {-0.8, > 0.76},(*left knee*){0.1, -0.4}, {0.2, -0.8},(*collar*){0, > 0.3},(*right arm*){-0.3, 0.5}, {-0.45, 1.0},(*left arm*){0.3, > 0.5}, {0.45, 1.0}},(*=CC=A7=C6=F0=D2=BB=CC=F5=CD=C8*)(*10*){(*head*){0= > .2, > 0.75},(*groin*){0., > 0.},(*right knee*){0.1, -0.4}, {0.2, -0.8},(*left knee*){0.4, > -0.3}, {0.8, -0.6},(*collar*){0.13, 0.325},(*right arm*){-0.3, > 1.1}, {-0.4, 1.0},(*left arm*){0.5, 0.1}, {0.8, > 0.05}},(*=B7=C9=CF=E8*)(*11*){(*head*){0.07, 0.75},(*groin*){0., > 0.},(*right knee*){-0.2, -0.4}, {-0.3, -0.9},(*left knee*){0.2, > -0.4}, {0.3, -0.9},(*collar*){0, 0.3},(*right arm*){-0.45, > 0.45}, {-0.1, 0.65},(*left arm*){0.5, 0.15}, {0, > 0.05}},(*=BD=BB=B2=E6=CA=D6*)(*12*){(*head*){0.145, 0.55},(*groin*){0.= > , > 0.},(*right knee*){-0.2, -0.4}, {-0.3, -0.9},(*left knee*){0.2, > -0.4}, {0.3, -0.9},(*collar*){0, 0.3},(*right arm*){-0.5, 0.4}, {-0.4, > 0.8},(*left arm*){0.5, 0.4}, {0.4, > 0.8}},(*=D6=BB=BE=D9=CA=D6*)(*13*){(*head*){0.125, 0.75},(*groin*){0., > 0.},(*right knee*){-0.2, -0.4}, {-0.3, -0.9},(*left knee*){0.2, > -0.4}, {0.3, 0.3},(*collar*){0, 0.3},(*right arm*){-0.5, 0.4}, {-0.4, > 0.8},(*left arm*){0.5, 0.4}, {0.4, > 0.8}},(*=CC=A7=D3=D2=CD=C8=BE=D9=CA=D6*)(*14*){(*head*){0.135, 0.65},(= > *groin*){0., > 0.},(*right knee*){-0.2, -0.4}, {-0.3, > 0.3},(*left knee*){0.2, -0.4}, {0.3, -0.9},(*collar*){0, > 0.3},(*right arm*){-0.5, 0.4}, {-0.4, 0.8},(*left arm*){0.5, > 0.4}, {0.4, 0.8}},(*=CC=A7=D7=F3=CD=C8=BE=D9=CA=D6*)(*15*){(*head*){0,= > 0.75},(*groin*){0., > 0.},(*right knee*){-0.2, -0.4}, {-0.3, -0.9},(*left knee*){0.2, -0.4}, {0.3, -0.9},(*collar*){0, 0.3},(*right arm*){-0.5, 0.6}, {0, > 1.2},(*left arm*){0.5, 0.6}, {0, > 1.2}},(*=CB=AB=CA=D6=BD=BB=B2=E6=D7=B4*)(*16*){(*head*){-0.125, 0.75},= > (*groin*){0., > 0.},(*right knee*){-0.2, -0.4}, {-0.3, -0.9},(*left knee*){0.2, > -0.4}, {0.3, 0.3},(*collar*){0, 0.3},(*right arm*){-0.5, 0.6}, {0, > 1.2},(*left arm*){0.5, 0.6}, {0, > 1.2}},(*=CB=AB=CA=D6=BD=BB=B2=E6=CC=A7=D3=D2=CD=C8*)(*17*){(*head*){-0= > .125, 0.75},(*groin*){0., > 0.},(*right knee*){-0.2, -0.4}, {-0.3, > 0.3},(*left knee*){0.2, -0.4}, {0.3, -0.9},(*collar*){0, > 0.3},(*right arm*){-0.5, 0.6}, {0, 1.2},(*left arm*){0.5, > 0.6}, {0, 1.2}},(*=CB=AB=CA=D6=BD=BB=B2=E6=CC=A7=D7=F3=CD=C8*)(*18*){(= > *head*){-0.125, > 0.75},(*groin*){0., > 0.},(*right knee*){-0.2, -0.4}, {0, -0.9},(*left knee*){0.2, > -0.4}, {0, -0.9},(*collar*){0, 0.3},(*right arm*){-0.5, 0.6}, {0, > 1.2},(*left arm*){0.5, 0.6}, {0, > 1.2}},(*=D0=A1=CC=EC=B6=EC=CE=E8=B2=BD*)(*19*){(*head*){0.125, 0.75},(= > *groin*){0, > 0},(*right knee*){-0.2, -0.4}, {-0.3, -0.9},(*left knee*){0.2, > -0.4}, {0.3, -0.9},(*collar*){0, 0.4},(*elbows*){-0.6, 0.4}, {-0.6, > 1.0},(*hands*){0.4, 0.3}, {0.8, > 0.5}},(*=B7=C5=CF=C2=D3=D2=CA=D6*)(*20*){(*head*){-0.125, 0.75},(*groi= > n*){0, > 0},(*right knee*){-0.2, -0.4}, {-0.3, -0.9},(*left knee*){0.2, > -0.4}, {0.3, -0.9},(*collar*){0, 0.4},(*elbows*){-0.4, 0.3}, {-0.8, > 0.5},(*hands*){0.6, 0.5}, {0.6, 1.0}}(*=B7=C5=CF=C2=D7=F3=CA=D6*)}; > (*sn1 for SoundNote pitch, sn2 for duration of according note*) > sn1 = {-9, -9, -5, -5, -9, -9, -9, 3, -7, -7, -7, -4, -4, > 0, -4, -7, -2, 5, 10, 10, 2, 2, 5, 2, -9, -9, -5, -5, -5, > 3, -9, -2}; > sn2 = {.00001, 1, 3, 3, 1, 1, 3, 3, 1, 1, 3, 3, 1, 1, 3, 3, 1, 1, 3, > 3, 1, 1, 3, 3, 1, 1, 3, 3, 1, 1, 3, 3, 1, .00001}; > sn2c = Accumulate@sn2/8; > sn2s = Table[{sn2c[[i]], sn2c[[i + 1]]}, {i, Length[sn2c] - 1}]; (*pos changing according to Session Time, in order to get > corresponding note in sn1*) > pos := Position[sn2s, {_, _}?((#[[1]] < t <= #[[2]]) &)][[1, 1]]; > pos1 = pos; > pos2 = pos; (*offset as the name means, t for time starts form offset*) > offset = SessionTime[]; > t := SessionTime[] - offset; I'm really puzzled by the following codes: Dynamic[ > Clock[1]; > Panel[ > If[pos2 != pos1 && t < 8.1, > pos2 = pos; > pd = dancer[1, RandomInteger[{1, 20}], locators]; > EmitSound[ > Sound[ > SoundNote[ > sn1[[pos]],sn2[[pos]] > ] > ] > ] > ] > ] > pos1 = pos; ] I meant to emit sound and display a dancer figure corresponding to > every change of sound while time passing, but I can't realize it. How to do it? > === Subject: Re: Q: How to print with line wrap AND syntax coloring? > How do I edit the printout environment so that it includes line > wrapping AND syntax coloring? In your printout style: Cell[StyleData[All, Printout], ScreenStyleEnvironment->Printout, PageWidth->PaperWidth, PrivateEvaluationOptions->{OutputFormPageWidth->PaperWidth}, ShowSyntaxStyles->True, ShowAutoStyles->True, ... ] === Subject: Re: Mathematica documentation - for newest and older versions How did you discover that URL? I don't see any direct link to that page from the Learning Center. ... PDF versions of the Documentation Center content ... are [at] > http://www.wolfram.com/learningcenter/tutorialcollection/ > to see what they are intending to have if you have not seen this > before. It appears that you will be able to order hardcopies (for a > fee) of all the 7.0 documentation as well as download free versions of > the PDF files for each of the sections.... -- 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: pure function with optional number of arguments Check this, for example: In[1] = Function[Null, Head[Unevaluated[#]], HoldFirst][Print[1]] Out[1] = Print In[2] = Function[Null, Head[Unevaluated[#]], HoldFirst] &[Print[1]] 1 Out[2] = Function[Null, Head[Unevaluated[#1]], HoldFirst], v.6.0 Leonid > I don't see, in the documentation, anything like Function[Null, > body[##],Attributes] as a complete function -- that is, ##, #, or #n without > their inclusion in a pure function ending in &. Function[Null, body[##],Attributes]& perhaps, but not Function[Null, > body[##],Attributes] alone. Bobby Yes indeed you are right, sorry for the confusion - just a stupid mistake. >> I had in mind an (irrelevant to this problem) possibility to use >> Function[Null, body[##],Attributes] to give attributes to pure functions >> defined with slots, which I believe is an undocumented feature (at least, >> according to Roman Maeder as of v.4 - may be now it is, but I did not see >> it). >> Leonid >> 2009/4/22 Szabolcs Horv=E1t Hi Ruth, >> You can use the undocumented form of the pure function which can take >> an= > y > number of arguments: >> Function[Null, body[##]]. > This is a standard documented feature. See these doc pages: http://reference.wolfram.com/mathematica/ref/Function.html#29126 > http://reference.wolfram.com/mathematica/ref/SlotSequence.html > -- > DrMajorBob@bigfoot.com > === Subject: Re: pure function with optional number of arguments Fine. But where is the first form documented? Bobby > Check this, for example: In[1] = Function[Null, Head[Unevaluated[#]], HoldFirst][Print[1]] Out[1] = Print In[2] = Function[Null, Head[Unevaluated[#]], HoldFirst] &[Print[1]] 1 Out[2] = Function[Null, Head[Unevaluated[#1]], HoldFirst], v.6.0 Leonid >> I don't see, in the documentation, anything like Function[Null, >> body[##],Attributes] as a complete function -- that is, ##, #, or #n >> without >> their inclusion in a pure function ending in &. >> Function[Null, body[##],Attributes]& perhaps, but not Function[Null, >> body[##],Attributes] alone. >> Bobby >> Yes indeed you are right, sorry for the confusion - just a stupid >> mistake. > I had in mind an (irrelevant to this problem) possibility to use > Function[Null, body[##],Attributes] to give attributes to pure > functions > defined with slots, which I believe is an undocumented feature (at > least, > according to Roman Maeder as of v.4 - may be now it is, but I did not > see > it). > Leonid 2009/4/22 Szabolcs Horv=E1t > Hi Ruth, You can use the undocumented form of the pure function which can take > an= > y > number of arguments: Function[Null, body[##]]. >> This is a standard documented feature. See these doc pages: >> http://reference.wolfram.com/mathematica/ref/Function.html#29126 >> http://reference.wolfram.com/mathematica/ref/SlotSequence.html > > -- >> DrMajorBob@bigfoot.com >> -- DrMajorBob@bigfoot.com === Subject: Re: pure function with optional number of arguments I don't see, in the documentation, anything like Function[Null, body[##],Attributes] as a complete function -- that is, ##, #, or #n without their inclusion in a pure function ending in &. Function[Null, body[##],Attributes]& perhaps, but not Function[Null, body[##],Attributes] alone. Bobby > Yes indeed you are right, sorry for the confusion - just a stupid > mistake. > I had in mind an (irrelevant to this problem) possibility to use > Function[Null, body[##],Attributes] to give attributes to pure functions > defined with slots, which I believe is an undocumented feature (at least, > according to Roman Maeder as of v.4 - may be now it is, but I did not see > it). > Leonid 2009/4/22 Szabolcs Horv=E1t Hi Ruth, You can use the undocumented form of the pure function which can take > an= > y > number of arguments: Function[Null, body[##]]. > This is a standard documented feature. See these doc pages: >> http://reference.wolfram.com/mathematica/ref/Function.html#29126 >> http://reference.wolfram.com/mathematica/ref/SlotSequence.html > > -- DrMajorBob@bigfoot.com === Subject: Re: Mathematica for gifted elementary school children Structured educational programmes are rarely as effective as creative playing. If he goes to school like normal and decides to do his homework in Mathematica that should give him some play time that would be beneficial. > My son, almost 6, is good at math and inquisitive. Is there a math > curriculum for elementary school children that uses Mathematica? He > understands the four arithemetic operations and the concept of powers. > I have Mathematica installed on my home PC and could teach him myself. I have written computer programs in Fortran in front of him to > demonstrate concepts such as cubes and cube roots. We had fun, but I > don't want to explain right now why 1000000000**3 gives -402653184 or > 1/2 gives 0. He is interested in the number centillion (10^303) and thought it > was cool to see the 101 zeros when we asked Mathematica to compute > centillion^(1/3). I see there are some math courseware athttp://library.wolfram.com/infocen= ter/Courseware/Mathematics/ > , but those topics are too advanced for him at present. Maybe I should > give him Wolfram's huge book and let him play when he wants. Ar === Subject: Combine ErrorListPlot with another graphics Hello everyone, I want to combine an ErrorListPlot with another graphics but the Show [] command does not seem to work with ErrorListPlot[] ??? Any suggestions ? TIA === Subject: Re: Using a jpg picture for a 2D plot background > Hi: I would like to use a jpg picture as a background for a 2D plot in Mathematica 6.0.1, on a PC using Win XP. > I'm not sure if this can be done. If this can be done, can someone please give me the code to do this? SetDirectory[NotebookDirectory[]] (* set the working directory to the directory where the notebook lives *) pic=Import[picture.jpg] (* import your picture *) plot = Plot[x + 2 Sin[x], {x, -5 [Pi], 5 [Pi]}, PlotStyle -> {Thick, Red}] ImageCompose[pic, plot] -- Helen Read University of Vermont === Subject: Re: Using a jpg picture for a 2D plot background > Hi: I would like to use a jpg picture as a background for a 2D plot in Mathem= atica 6.0.1, on a PC using Win XP. > I'm not sure if this can be done. If this can be done, can someone please= give me the code to do this? > WDW Try Plot[Sin[x], {x, 0, 1}, Prolog -> Inset[pic]] (*pic is your own jpg pic, which should be imported*) === Subject: Re: Using a jpg picture for a 2D plot background Hi Bill, you may e.g. use Inset. But there is a slight problem consisting of sizing the picture. An example where the sizing is done by hand. : bg = Import[ExampleData/coneflower.jpg]; Plot[Sin[x], {x, 0, Pi}, PlotStyle -> {Thickness[0.05]}, Prolog -> Inset[bg, Center, Center, 3]] Daniel > Hi: I would like to use a jpg picture as a background for a 2D plot in Mathematica 6.0.1, on a PC using Win XP. > I'm not sure if this can be done. If this can be done, can someone please give me the code to do this? > WDW > === Subject: Re: Using a jpg picture for a 2D plot background img = Import[http://blog.wolfram.com/images/people/sw.jpg]; Graphics[ {Image`ToGraphicsRaster[img][[1]], Line[{{0, 0}, {50, 60}}]} ] in Mathematica 7, and Graphics[ {img[[1]], Line[{{0, 0}, {50, 60}}]} ] in Mathematica 6. Jens > Hi: I would like to use a jpg picture as a background for a 2D plot in Mathematica 6.0.1, on a PC using Win XP. > I'm not sure if this can be done. If this can be done, can someone please give me the code to do this? > WDW > === Subject: Re: Using a jpg picture for a 2D plot background In 7 this could be done easily with ImageCompose, but since you've got 6 this is less trivial. One approach would be: bg = ExampleData[{TestImage, Peppers}] pl = Plot[Sin[x], {x, -[Pi], [Pi]}]; t = RescalingTransform[{{1, 512}, {1, 512}}, {{-[Pi], [Pi]}, {-1, 1}}]; bg2 = GeometricTransformation[bg[[1]], t] // Graphics; Show[bg2, pl, AspectRatio -> 1, Frame -> True, BaseStyle -> {Thickness[0.02]}] There is a difference between imported pictures in 6 and 7. Whereas in 6 they're Graphics in 7 they're an Image. To have this example work in 7 one line should be different: bg2 = GeometricTransformation[Rasterize[bg][[1]], t] // Graphics; The 512 in the above code is the size of the image (both vertical and horizontal). In 7 you could use ImageDimensions to get this information. In 6 this can be gotten using either bg[[3]] or AbsoluteOptions[bg, PlotRange] Use the correct AspectRatio for the picture, otherwise it'll look distorted. Hope this helps. > Hi: I would like to use a jpg picture as a background for a 2D plot in Mathem= atica 6.0.1, on a PC using Win XP. > I'm not sure if this can be done. If this can be done, can someone please= give me the code to do this? > WDW === Subject: Re: FindFit tips It is difficult to help you if you don't put more details... cd 2009/4/23 Sean G. set by hand. I'm not smarter than mathematica, so I must be using FindFit > wrong. Any ideas? -- Por favor eviten enviarme archivos adjuntos de Word o Powerpoint ( http://www.gnu.org/philosophy/no-word-attachments.es.html ) === Subject: Re: FindFit tips Hi Sean, nonlinear fitting is not too easy. The problem comes from the fact that there can be many good fits, the error surface can have many local minima. To get the one you want, you may have to introduce constrictions of the parameters. E.g. p1>0. Daniel > === Subject: Re: Advanced plotting >Oh, not exactly. >At least on my machine (Windows XP SP2, Mathematica 7.0.0), the peak >value in the 2nd graph is a little higher than that in the 1st one. You are right. When I looked at the resulting plot, I failed to look carefully enough to notice the slight difference. And after thinking about this, I see what is occurring. To ensure the labels on the axis show correctly, Mathematica shrinks the graphic slightly. In fact, I have a dim memory of seeing somewhere the adjustment is 5% on both ends. This can be compensated for by adjusting the plot range on one graphic. For example: Grid@{{Plot[{Sin[2 x], 1}, {x, 0, 4}, PlotRange -> {-1.1, 1.1}, AxesOrigin -> {0, 0}], Style[Rotate[=E2=89=88, 90 Degree], 20], Plot[{Cos[2 x], 1}, {x, 6, 10}, PlotRange -> {-1.1, 1.1} 1.1, Axes -> {True, False}]}} Here, I've added a line at y = 1 to both plots to make any misalignment more apparent. === Subject: Jacobi polynomials in Mathematica I have a simple question: in Mathematica the Jacobi polynomials are implemented as JacobiP[n, a, b, z], see http://mathworld.wolfram.com/JacobiPolynomial.html Is JacobiP[n, a, b, z] also defined if n is not an integer? More general, is JacobiP[n, a, b, z] defined for all real n, a, b and z? === Subject: Paste image directly into V7 notebook on Linux/X11 Yesterday I called Wolfram Research to find out how to paste images into a version 7 notebook directly from the X11 clipboard on Linux. The tech stated that this is feature is supported only on windows and mac, not linux. So I implemented it myself. Here's how: I'm running KDE4.2, and Klipper does not paste image data, so dbus is not an option. I settled on using Qt: you will need the command getclipboardimage installed on your $PATH (Qt 4.4 source code and instructions available at http://www.phys.ucalgary.ca/~burchill). Perhaps someone could suggest how to do this from perl or python, etc... Adding the Paste Image to the edit menu involves editing a user-copy of $InstallationDirectory/SystemFiles/FrontEnd/TextResources/X/ MenuSetup.tr. Caution: a typo in this file can break mathematica. Add the following between the &Paste and Clea&rtDelete menu items: MenuItem[Paste &Image, KernelExecute[{Module[{tmpFile, image, file}, tmpFile = ToFileName [$TemporaryDirectory, clipboardimagefileformathematica.png]; DeleteFile[FileNames[tmpFile]]; file = Import[!getclipboardimage <> tmpFile, Lines]; If[Length[file] > 0, image = Import [file[[1]], Image]; NotebookWrite[InputNotebook[], Cell[BoxData [ToBoxes@image],Output]]]];]}], MenuKey[V, Modifiers->{Control}], MenuEvaluator- >Automatic], Restart mathematica. Try it out by opening a PDF file, selecting an image and copying it to the clipboard. In a notebook select Paste Image from the Edit menu. This inserts the image in-line. JB === Subject: Re: fitting surface with Mathematica 6.0.3 and range of fitted values >I'm trying to fit a surface with a Fit command and a 4th order >polynomial and I can get the fit and the model but then I try to >evaluate some data through the model and they are out of the range of >the original data, I have looked around but I could not find an option >to pass into Fit command to keep the fitted values in the range of the >possible cases. The fact you get a result using Fit is meaningless since Fit will always give you a result. But, there is no guarantee the result will be useful or meaningful. Nor is there any way to constrain the range of values returned by Fit for the fitted parameters. =46it only solves the linear regression problem. The solution to the linear regression problem can be expressed in closed form and requires no initial estimate of the solution. =46indFit accepts constraints on the fitted parameters. Alternatively, you can write you own function to compute the sum of squares or some other measure of goodness of fit and use NMimimize to find optimum values. NMimimize also accepts constaints on fitting parameters. But there is another issue here as well. While you did not specify what you are using as basis functions for Fit, I suspect you might be using simply powers of x, i.e., {1, x, x^2, x^3, x^4} as the set of functions to fit to your data. If so, this is a very bad idea. There are several issues here that will cause problems. First, the linear regression problem is increasingly numerically unstable when the degree of the polynomial increases when using powers of x as the set of basis functions. Since Fit does it thing by default with machine precision arithmetic, this means small changes in your data will result in large changes in the fitted values. Next, powers of x do not form an orthogonal set of basis functions. That means the fitted coefficients will not be independent of each other. Additionally, the variance in the fitted parameters scales as 1/(1-r) where r is the correlation coefficient between basis functions. If you absolutely need a polynomial fit, you should be using an orthogonal set of polynomials for your basis functions such as Chebyshev or Legendre polynomials. Chebyshev polynomials are particularly good. === Subject: Re: Change Figure according to Session Time > Hi community, First,some definitions following: : : > I'm really puzzled by the following codes: Dynamic[ > Clock[1]; > Panel[ > If[pos2 != pos1 && t < 8.1, > pos2 = pos; > pd = dancer[1, RandomInteger[{1, 20}], locators]; > EmitSound[ > Sound[ > SoundNote[ > sn1[[pos]],sn2[[pos]] > ] > ] > ] > ] > ] > pos1 = pos; ] I meant to emit sound and display a dancer figure corresponding to > every change of sound while time passing, but I can't realize it. How to do it? > You can't expect a Dynamic expression of the form... Dynamic[ =09; =09; =09 ] to produce a graphic. The graphic is hidden by being in the middle of a compound expression. This wouldn't show a graphic if you evaluated it without the Dynamic, so you certainly can't expect it to show a graphic inside a Dynamic. To better understand Dynamic, you should read the beginning and advanced Dynamic tutorials (linked to from the Dynamic documentation), as well as this post of mine from February... http://forums.wolfram.com/mathgroup/archive/2009/Feb/msg00424.html I snipped the .00001 values out of your sn2 and used the following code which illustrates a few different principles. All of this is well documented in the appropriate function documentation, so I won't go into much detail here. DynamicModule[{time, counter = 1, random = 1}, Panel[ Labeled[ Dynamic[ Which[ time < 0.01, counter = 0, counter == 0, counter++, counter == Length[sn2c], Null (* do nothing *), time > sn2c[[counter]], counter++; random = RandomInteger[{1, 20}]; EmitSound[Sound[SoundNote[sn1[[counter]], sn2[[counter]]]]] ]; dancer[1, random, locators]] , Trigger[Dynamic[time], {0, Last[sn2c]}, 1], Top]]] I also added an explicit ImageSize to the graphic to keep it from hopping around. Since the code was a little munged by the process of emailing it, and it was also a little long, I just put a notebook with the working demo here... http://download.wolfram.com/?key=U8N68F John Fultz jfultz@wolfram.com User Interface Group Wolfram Research, Inc. === Subject: Re: Help with a possible bug The issue discussed in this thread has been analyzed and fixed by our development team. A kernel binary for all affected platforms is currently being tested. The issue occurs for a somewhat rare class of inputs in Mathematica version 7.0.1 (not 7.0.0). Users affected by this problem can request a patch by emailing support@wolfram.com. We apologize for any inconvenience this issue may have caused. Arnoud Buzing arnoudb@wolfram.com Quality Assurance Manager Wolfram Research > At work we seem to have stumbled on a strange bug between Table and > Part. We can reproduce the bug on differently configured Mac and > Linux boxes. I tried Wolfram support, but they claim they cannot > reproduce the bug. So I was hoping someone could try it out and For us, the bug is new in 7.0.1. It does not show up in version 6. > To reproduce it, fill up a 17 x 267 matrix with 3s. Compute the sum > of some of the columns and you get the result 51 (17 x 3). But if one > computes the sum for the last few columns, the result is completely > off. The bug seems to arise from the interaction of optimizations in > Table and the use of All inside of Part. > ------------ code mat = Table[3, {i, 1, 17}, {j, 1, 267}]; sum = Table[Total[mat[[All, j]]], {j, 1, 249}] sum1 = Table[Total[mat[[All, j]]], {j, 1, 252}]; > sum2 = Table[Total[mat[[All, j]]], {j, 1, 252}] ------------ end code If you look at sum1, it will be correct on a fresh copy of the > Kernel. The problem only arise from the second time on. > Papin Email: ImportString[cGFwaW5AY294Lm5ldA==, Base64] === Subject: Re: MatrixPlot with color range bar you need e.g. ShowLegend. Look it up in the manual. Here is an example from the manual: Needs[PlotLegends`] ShowLegend[ DensityPlot[Sin[x y], {x, 0, [Pi]}, {y, 0, [Pi]}, Mesh -> False, PlotPoints -> 30], {ColorData[LakeColors][1 - #1] &, 10, 1, -1, LegendPosition -> {1.1, -.4}}] Daniel > I'd like to draw plots like > http://www.gle-graphics.org/examples/3dplots/informationgain.png > I know that MatrixPlot function draws such plots. > My question is how to draw color range bar like that on the right side of > the plot at the url. > Is there any options of MatrixPlot or tricks to draw such color range bar ? > === Subject: Re: MatrixPlot with color range bar GraphicsRow[{DensityPlot[ x^2*(1 - x)*y^2*(1 - y), {x, 0, 1}, {y, 0, 1}, ColorFunction -> Rainbow], DensityPlot[y, {x, 0, 0.2}, {y, 0, 1}, ColorFunction -> Rainbow, AspectRatio -> Automatic, FrameTicks -> {None, Automatic}, PlotRangePadding -> None]}] ?? Jens > I'd like to draw plots like > http://www.gle-graphics.org/examples/3dplots/informationgain.png > I know that MatrixPlot function draws such plots. > My question is how to draw color range bar like that on the right side = of > the plot at the url. > Is there any options of MatrixPlot or tricks to draw such color range b= ar ? > === Subject: Re: Combine ErrorListPlot with another graphics Show seems to work for me: Needs[ErrorBarPlots`] g1 = ErrorListPlot[d = Table[{i, RandomReal[0.5]}, {i, 10}]] g2 = Plot[x, {x, 1, 10}] Show[g1, g2] Daniel > Hello everyone, I want to combine an ErrorListPlot with another graphics but the Show > [] command does not seem to work with ErrorListPlot[] ??? > Any suggestions ? TIA > === Subject: Re: Combine ErrorListPlot with another graphics Needs[ErrorBarPlots`] plt = ErrorListPlot[Table[{i, RandomReal[0.5]}, {i, 10}]]; and Show[plt, Graphics[Table[{Hue[Random[]], Disk[RandomReal[{1, 10}, 2], RandomReal[]]}, {10}] ] ] work as it should. Jens > Hello everyone, I want to combine an ErrorListPlot with another graphics but the Show > [] command does not seem to work with ErrorListPlot[] ??? > Any suggestions ? TIA > === Subject: Re: Using a jpg picture for a 2D plot background Bill === Subject: Is this solvable using Mathematica? Supposed you want to define a second order derivative along with your ODEs. (So you can scale the second order term) Example shown below. k1 = 1; r1 = 1; NDSolve[{a'[t] == k1 b[t] - d, a''[t] == r1 b'[t], a'[0] == 0, a[0] == 1, b[0] == 0}, {a[t], b[t]}, {t, 1, 10} ] But I get an error. NDSolve::ntdvmm: Cannot solve to find an explicit formula for the derivatives. NDSolve will try solving the system using a mass matrix method. NDSolve::ndnum: Encountered non-numerical value for a derivative at t == 0.`. Maybe this is more of a math question than software. But I would be very interested in seeing if it's doable in Mathematica. === Subject: Re: Is this solvable using Mathematica? this is not solvable at all, because one equation (for a''[t] or b[t]) is missed. Jens > Supposed you want to define a second order derivative along with your > ODEs. (So you can scale the second order term) Example shown below. k1 = 1; > r1 = 1; > NDSolve[{a'[t] == k1 b[t] - d, a''[t] == r1 b'[t], a'[0] == 0, a[0] == > 1, b[0] == 0}, {a[t], b[t]}, {t, 1, 10} ] But I get an error. NDSolve::ntdvmm: > Cannot solve to find an explicit formula for the derivatives. NDSolve > will try solving the system using a mass matrix method. NDSolve::ndnum: Encountered non-numerical value for a derivative at t > == 0.`. Maybe this is more of a math question than software. But I would be > very interested in seeing if it's doable in Mathematica. > === Subject: Re: Is this solvable using Mathematica? Don't you need a value for d? David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ Supposed you want to define a second order derivative along with your ODEs. (So you can scale the second order term) Example shown below. k1 = 1; r1 = 1; NDSolve[{a'[t] == k1 b[t] - d, a''[t] == r1 b'[t], a'[0] == 0, a[0] == 1, b[0] == 0}, {a[t], b[t]}, {t, 1, 10} ] But I get an error. NDSolve::ntdvmm: Cannot solve to find an explicit formula for the derivatives. NDSolve will try solving the system using a mass matrix method. NDSolve::ndnum: Encountered non-numerical value for a derivative at t == 0.`. Maybe this is more of a math question than software. But I would be very interested in seeing if it's doable in Mathematica. === Subject: Re: Is this solvable using Mathematica? One problem is that d doesn't have a value... > Supposed you want to define a second order derivative along with your > ODEs. (So you can scale the second order term) Example shown below. k1 = 1; > r1 = 1; > NDSolve[{a'[t] == k1 b[t] - d, a''[t] == r1 b'[t], a'[0] == 0= , a[0] == > 1, b[0] == 0}, {a[t], b[t]}, {t, 1, 10} ] But I get an error. NDSolve::ntdvmm: > Cannot solve to find an explicit formula for the derivatives. NDSolve > will try solving the system using a mass matrix method. NDSolve::ndnum: Encountered non-numerical value for a derivative at t > == 0.`. Maybe this is more of a math question than software. But I would be > very interested in seeing if it's doable in Mathematica. > === Subject: Re: Paste image directly into V7 notebook on Linux/X11 Tested with pdf files from Okular, jpg images from GIMP. -Francesco Yesterday I called Wolfram Research to find out how to paste images > into a version 7 notebook directly from the X11 clipboard on Linux. > The tech stated that this is feature is supported only on windows and > mac, not linux. So I implemented it myself. Here's how: I'm running KDE4.2, and Klipper does not paste image data, so dbus is > not an option. I settled on using Qt: you will need the command > getclipboardimage installed on your $PATH (Qt 4.4 source code and > instructions available at http://www.phys.ucalgary.ca/~burchill). > Perhaps someone could suggest how to do this from perl or python, > etc... Adding the Paste Image to the edit menu involves editing a user-copy > of $InstallationDirectory/SystemFiles/FrontEnd/TextResources/X/ > MenuSetup.tr. Caution: a typo in this file can break mathematica. Add the following between the &Paste and Clea&rtDelete menu items: MenuItem[Paste &Image, > KernelExecute[{Module[{tmpFile, image, file}, > tmpFile = ToFileName > [$TemporaryDirectory, clipboardimagefileformathematica.png]; > DeleteFile[FileNames[tmpFile]]; > file = Import[!getclipboardimage > <> tmpFile, Lines]; > If[Length[file] > 0, image = Import > [file[[1]], Image]; > NotebookWrite[InputNotebook[], > Cell[BoxData > [ToBoxes@image],Output]]]];]}], > MenuKey[V, Modifiers->{Control}], MenuEvaluator- >> Automatic], Restart mathematica. Try it out by opening a PDF file, selecting an > image and copying it to the clipboard. In a notebook select Paste > Image from the Edit menu. This inserts the image in-line. JB > === Subject: Re: Help with a possible bug I am absolutely delighted to see that Wolfram has started a patch policy for bugs ! The next step would be a patch download page on the web site, available to all customers, and a mailing program for any new patches with associated release notes. Possibly next century? ADL > The issue discussed in this thread has been analyzed and fixed by our development team. A kernel binary for all affected platforms is currently being tested. The issue occurs for a somewhat rare class of inputs in Mathematica version 7.0.1 (not 7.0.0). Users affected by this problem can request a patch by emailing supp...@wolfram.com. We apologize for any inconvenience this issue may have caused. Arnoud Buzing > arno...@wolfram.com > Quality Assurance Manager > Wolfram Research === Subject: ContourPlot, equation and R.H. side of equation_Plotting problem Hi: 1a.) When I assign 3 x^2 + 6 y^2 == 6 to eqn1, in Mathematica like this: eqn1=3 x^2 + 6 y^2 == 6; I can't get ContourPlot to plot eqn1 using this code: ContourPlot[eqn1, {x, -2, 2}, {y, -2, 2}, Axes -> True] 1b.) If I assign the equation like this without the constant on the R.H. side in eqn2, ContourPlot will plot the equation as expected, using the following syntax: eqn2=3 x^2 + 6 y^2; ContourPlot[eqn2 == 6, {x, -2, 2}, {y, -2, 2}, Axes -> True] Question: How can I get method 1a to work? Could you please give me code for this? Bill PS. I'm using Mathematica 6.0.1 w/ Win XP on a PC. === Subject: Re: ContourPlot, equation and R.H. side of equation_Plotting problem ContourPlot[Evaluate[eqn1], {x, -2, 2}, {y, -2, 2}, Axes -> True] ? Jens > Hi: 1a.) When I assign 3 x^2 + 6 y^2 == 6 to eqn1, in Mathematica like this: eqn1=3 x^2 + 6 y^2 == 6; I can't get ContourPlot to plot eqn1 using this code: ContourPlot[eqn1, {x, -2, 2}, {y, -2, 2}, Axes -> True] > 1b.) If I assign the equation like this without the constant on the R.H. side in eqn2, > ContourPlot will plot the equation as expected, using the following syntax: eqn2=3 x^2 + 6 y^2; > ContourPlot[eqn2 == 6, {x, -2, 2}, {y, -2, 2}, Axes -> True] > Question: How can I get method 1a to work? Could you please give me code for this? > Bill > PS. I'm using Mathematica 6.0.1 w/ Win XP on a PC. > === Subject: Re: ContourPlot, equation and R.H. side of equation_Plotting problem This works: eqn1 = 3 x^2 + 6 y^2 == 6 ContourPlot[Evaluate@eqn1, {x, -2, 2}, {y, -2, 2}, Axes -> True] I think this is what might be called a feature. ContourPlot has the attribute HoldAll. Without the Evaluate it see no x and or y to substitute values. So you obtain no numeric result and no image. When you enter the form with the explicit equal sign, Mathematica follows a path that does evaluate and you get the image of the curve. The lesson is: when you don't obtain an image when you expect one, and the plotting parameters are not manifest in the expression, use Evaluate. David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ Hi: 1a.) When I assign 3 x^2 + 6 y^2 == 6 to eqn1, in Mathematica like this: eqn1=3 x^2 + 6 y^2 == 6; I can't get ContourPlot to plot eqn1 using this code: ContourPlot[eqn1, {x, -2, 2}, {y, -2, 2}, Axes -> True] 1b.) If I assign the equation like this without the constant on the R.H. side in eqn2, ContourPlot will plot the equation as expected, using the following syntax: eqn2=3 x^2 + 6 y^2; ContourPlot[eqn2 == 6, {x, -2, 2}, {y, -2, 2}, Axes -> True] Question: How can I get method 1a to work? Could you please give me code for this? Bill PS. I'm using Mathematica 6.0.1 w/ Win XP on a PC. === Subject: Re: ContourPlot, equation and R.H. side of equation_Plotting problem > Hi: 1a.) When I assign 3 x^2 + 6 y^2 == 6 to eqn1, in Mathematica like this: eqn1=3 x^2 + 6 y^2 == 6; I can't get ContourPlot to plot eqn1 using this code: ContourPlot[eqn1, {x, -2, 2}, {y, -2, 2}, Axes -> True] > 1b.) If I assign the equation like this without the constant on the R.H. side in eqn2, > ContourPlot will plot the equation as expected, using the following syntax: eqn2=3 x^2 + 6 y^2; > ContourPlot[eqn2 == 6, {x, -2, 2}, {y, -2, 2}, Axes -> True] > Question: How can I get method 1a to work? Could you please give me code for this? I'm not exactly sure why it's happening, but I see it too. Seeing that ContourPlot has attribute HoldAll, I'm guessing this is another misfiring heuristic that's attempting to determine what class of plot it's being asked to handle and failing. I found you can bypass the problem by putting an explicit Evaluate call in there: ContourPlot[Evaluate @ eqn1, {x, -2, 2}, {y, -2, 2}, Axes->True] -- Erik Max Francis && max@alcyone.com && http://www.alcyone.com/max/ San Jose, CA, USA && 37 18 N 121 57 W && AIM, Y!M, Skype erikmaxfrancis The hour which gives us life begins to take it away. -- Seneca === Subject: Re: formatting notebook contents messages, why so many in I observe this to happen to me a lot when I open a notebook containing recursive functions. === Subject: Re: Plot x to y and y to x Uncompress[1:eJwdisERgCAQxChlbcOnJaANLHCOjAgPDxm6F/ 0lk0yu2HUzxiwdif5E2RFEGdP9YTuo6KWCXitT6mjMCj0EJQ9jeKIXeGY4mWGF4Y8X89hf ppUf2Q==] I'm a complete newbie to Mathematica and I can't seem to get it to plot what I want. > I need to plot a increase in temp. for x to y then I would like to see what happens when the temp. decreases from y to x. Is there an easy way to create these two plots? === Subject: Re: Plot x to y and y to x if you want a decent answer, you have to write an accurate question. What do you want to plot, a function? data? DEQ? .... Daniel I'm a complete newbie to Mathematica and I can't seem to get it to plot what I want. > I need to plot a increase in temp. for x to y then I would like to see what happens when the temp. decreases from y to x. Is there an easy way to create these two plots? > === Subject: Re: Plot x to y and y to x absolutely - go right ahead and plot it.Peter 2009/4/24 zach I'm a complete newbie to Mathematica and I can't seem to get it to plot > what I want. > I need to plot a increase in temp. for x to y then I would like to see what > happens when the temp. decreases from y to x. Is there an easy way to > create these two plots? -- Peter Lindsay === Subject: issues with GraphPlot Hello group, A few things that I just can't figure out. 1. EdgeRenderingFunction ignores edge labels. GraphPlot[{{B -> A , +}, {A -> B, +}}, DirectedEdges -> True, VertexLabeling -> True, VertexRenderingFunction -> ({White, EdgeForm[Black], Disk[#, .05], Black, Text[#2, #1]} &), EdgeLabeling -> True, EdgeRenderingFunction -> ({ Arrowheads[Medium], Arrow[#1 , 0.07]} &), PlotStyle -> Thickness[0.005]] 2. As it is, above code produces a graph that is stretched horizontally a bit too much. About the half the horizontal width works better for me. How do I accomplish that? AspectRatio-> 1/GoldenRatio doesn't work since disk gets stretch also. 3. For node A to appear on the left, B-> A has to be defined first. If I reverse it, then the node B will appear on the left. What is the reason for this? Sean === Subject: Re: issues with GraphPlot For the label: this is something hat the EdgeRenderingFunction should do. Insert something like Inset[Text[#3], Mean[#1]] in what you already have. > Hello group, A few things that I just can't figure out. 1. EdgeRenderingFunction ignores edge labels. GraphPlot[{{B -> A , +}, {A -> B, +}}, > DirectedEdges -> True, VertexLabeling -> True, > VertexRenderingFunction -> ({White, EdgeForm[Black], Disk[#, .05], > Black, Text[#2, #1]} &), EdgeLabeling -> True, > EdgeRenderingFunction -> ({ Arrowheads[Medium], > Arrow[#1 , 0.07]} &), PlotStyle -> Thickness[0.005]] 2. As it is, above code produces a graph that is stretched > horizontally a bit too much. About the half the horizontal width works > better for me. How do I accomplish that? AspectRatio-> 1/GoldenRatio > doesn't work since disk gets stretch also. 3. For node A to appear on the left, B-> A has to be defined > first. If I reverse it, then the node B will appear on the left. What > is the reason for this? > Sean === Subject: Re: issues with GraphPlot Various folks on this list and at WRI showed me some (awkward) ways to render edge labels with GraphPlot. See the examples in the subsubsection use the EdgeRenderingFunction option to GraphPlot in notebook Graphs.nb at: http://www.math.umass.edu/~murray/Math_455_Eisenberg/Files/files.html I still regard GraphPlot as an only partially-baked Mathematica core function that is striving, but still falling short, of some of the functionality of the old Combinatorica package's ShowGraph. > Hello group, A few things that I just can't figure out. 1. EdgeRenderingFunction ignores edge labels. GraphPlot[{{B -> A , +}, {A -> B, +}}, > DirectedEdges -> True, VertexLabeling -> True, > VertexRenderingFunction -> ({White, EdgeForm[Black], Disk[#, .05], > Black, Text[#2, #1]} &), EdgeLabeling -> True, > EdgeRenderingFunction -> ({ Arrowheads[Medium], > Arrow[#1 , 0.07]} &), PlotStyle -> Thickness[0.005]] 2. As it is, above code produces a graph that is stretched > horizontally a bit too much. About the half the horizontal width works > better for me. How do I accomplish that? AspectRatio-> 1/GoldenRatio > doesn't work since disk gets stretch also. 3. For node A to appear on the left, B-> A has to be defined > first. If I reverse it, then the node B will appear on the left. What > is the reason for this? > Sean > -- 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: issues with GraphPlot > Hello group, A few things that I just can't figure out. 1. EdgeRenderingFunction ignores edge labels. GraphPlot[{{B -> A , +}, {A -> B, +}}, > DirectedEdges -> True, VertexLabeling -> True, > VertexRenderingFunction -> ({White, EdgeForm[Black], Disk[#, .05], > Black, Text[#2, #1]} &), EdgeLabeling -> True, > EdgeRenderingFunction -> ({ Arrowheads[Medium], > Arrow[#1 , 0.07]} &), PlotStyle -> Thickness[0.005]] 2. As it is, above code produces a graph that is stretched > horizontally a bit too much. About the half the horizontal width works > better for me. How do I accomplish that? AspectRatio-> 1/GoldenRatio > doesn't work since disk gets stretch also. 3. For node A to appear on the left, B-> A has to be defined > first. If I reverse it, then the node B will appear on the left. What > is the reason for this? > Sean Sean, Forgot to talk about issue #2 -- I think you can use ImageSize-{x,y} to help get what you want. For example: GraphPlot[{{A -> B, +}, {B -> A, +}}, DirectedEdges -> True, VertexLabeling -> True, Method -> SpringElectricalEmbedding, VertexRenderingFunction -> ({White, EdgeForm[Black], Disk[#, .15], Black, Text[#2, #1]} &), EdgeLabeling -> True, EdgeRenderingFunction -> ({Arrowheads[Medium], Arrow[#1, 0.15]} &), PlotStyle -> Thickness[0.005], ImageSize -> {100, 100}] gives a much narrower image, but you loose the curved arrows from before. HTH... -Bob === Subject: Re: issues with GraphPlot > Hello group, A few things that I just can't figure out. 1. EdgeRenderingFunction ignores edge labels. GraphPlot[{{B -> A , +}, {A -> B, +}}, > DirectedEdges -> True, VertexLabeling -> True, > VertexRenderingFunction -> ({White, EdgeForm[Black], Disk[#, .05], > Black, Text[#2, #1]} &), EdgeLabeling -> True, > EdgeRenderingFunction -> ({ Arrowheads[Medium], > Arrow[#1 , 0.07]} &), PlotStyle -> Thickness[0.005]] 2. As it is, above code produces a graph that is stretched > horizontally a bit too much. About the half the horizontal width works > better for me. How do I accomplish that? AspectRatio-> 1/GoldenRatio > doesn't work since disk gets stretch also. 3. For node A to appear on the left, B-> A has to be defined > first. If I reverse it, then the node B will appear on the left. What > is the reason for this? > Sean Sean, According to the Documentation Center info about GraphPlot, the order the nodes appear in is controlled by the Method that GraphPlot uses. There are seven methods with the default method being Automatic which uses the SpringElectricalEmbedding method, but uses the RadialDrawing method if the graph is a tree.. The seven methods are: CircularEmbedding, RandomEmbedding, HighDimensionalEmbedding, RadialDrawing, SpringEmbedding and SpringElectricalEmbedding. The method LinearEmbedding lays out all vertices on a single line. See the detailed writeup of GraphPlot for more info. Also here are the seven possiblities for a simple 2 vertex graph: GraphPlot[{0 -> 1, 1 -> 0}, DirectedEdges -> True, VertexLabeling -> True, Method -> CircularEmbedding] GraphPlot[{0 -> 1, 1 -> 0}, DirectedEdges -> True, VertexLabeling -> True, Method -> RandomEmbedding] GraphPlot[{0 -> 1, 1 -> 0}, DirectedEdges -> True, VertexLabeling -> True, Method -> HighDimensionalEmbedding] GraphPlot[{0 -> 1, 1 -> 0}, DirectedEdges -> True, VertexLabeling -> True, Method -> RadialDrawing] GraphPlot[{0 -> 1, 1 -> 0}, DirectedEdges -> True, VertexLabeling -> True, Method -> SpringEmbedding] GraphPlot[{0 -> 1, 1 -> 0}, DirectedEdges -> True, VertexLabeling -> True, Method -> SpringElectricalEmbedding] GraphPlot[{0 -> 1, 1 -> 0}, DirectedEdges -> True, VertexLabeling -> True, Method -> LinearEmbedding] -Bob === Subject: Position problem Why would this be happening? ln[2] is obviously contained in the list produced by ln[1], but the Position function does not find it... any suggestions? ln[1] = Round[stufflocations, .1] ln[2] = Round[Steplist[[400]][[1]], .1] Out[1] = {{-6.7, -5.7, 2.3}, {0.5, 8., -0.7}, {1.7, 1., 0.3}, {8.5, 4.2, -5.}, {1.5, 3.6, 5.4}} Out[2] = {1.7, 1.1, 0.3} ln[3] = Position[Round[stufflocations, .1], Round[Steplist[[400]][[1]], .1]] Out[3] = {} === Subject: Re: Position problem The middle number is 1.0 in stufflocations and 1.1 in steplist. Not the same therfore so no match. > Why would this be happening? ln[2] is obviously contained in the list > produced by ln[1], but the Position function does not find it... any > suggestions? ln[1] = Round[stufflocations, .1] ln[2] = Round[Steplist[[400]][[1]], .1] Out[1] = {{-6.7, -5.7, 2.3}, {0.5, 8., -0.7}, {1.7, 1., 0.3}, {8.5, 4.2= , > -5.}, {1.5, > 3.6, 5.4}} Out[2] = {1.7, 1.1, 0.3} ln[3] = Position[Round[stufflocations, .1], Round[Steplist[[400]][[1]],= .1]] Out[3] = {} === Subject: Re: Brace, bracket pretty format needed > um, can that keyboard action you mentioned be put into a button, and > work repeatedly as I click it each time?? > I am just so surprised that there is not a pretty print/formating > menuitem, button, or code around. Anyone up for the challenge? Am > doing the reformatting by hand that uses up time and energy on my > disabled fingers. ;( andrew This can be done easily: CreatePalette[Button[Balance, FrontEndTokenExecute[ Balance]]] Coloring the brackets is somewhat more involved, but also doable ( the code should be improved since editing the expression after applying the button will be unwanted colored eventually. There must be a trick to tell a StyleBox to not extend its reach to the right, but I could not figure this out.): CreatePalette[ Button[ColorBalance, Block[{c, col, color, n, r, s}, s = StyleBox[#1, FontColor -> #2, TaggingRules :> ColoredBracket] &; FrontEndTokenExecute[Balance]; r = NotebookRead[SelectedNotebook[]]; c = 1 + Mod[Count[r, ColoredBracket, -1], 9]; col = ColorData[DarkBands][0.1 c]; color = Function[x, x /. {i : [ | ] :> s[i, col], j : ( | ) :> s[j, col], k : { | } :> s[k, col], m : [LeftDoubleBracket] | [RightDoubleBracket] :> s[m, col]}]; n = Replace[r, RowBox[{a_, b___, c_}] :> RowBox[{color[a], b, color[c]}]]; NotebookWrite[SelectedNotebook[], n, All]]]] -- Rolf Mertig GluonVision GmbH Berlin, Germany === Subject: ZigZag matrix rearrange I'm trying to rearrange 8 x 8 matrix of numbers in ZigZag manner (as it is used in JPEG comprimation algorithm http://en.wikipedia.org/wiki/Jpeg). I have created function which does it without problems, but it does it by hand and it seems to me, that it could be done by some more elegant algorithm. Does somebody have any idea, how to do it more elegantly? My attempt: zigzag[t_] := { t[[1, 1]], t[[1, 2]], t[[2, 1]], t[[3, 1]], t[[2, 2]], t[[1, 3]], t[[1, 4]], t[[2, 3]], t[[3, 2]], t[[4, 1]], t[[5, 1]], t[[4, 2]], t[[3, 3]], t[[2, 4]], t[[1, 5]], t[[1, 6]], t[[2, 5]], t[[3, 4]], t[[4, 3]], t[[5, 2]], t[[6, 1]], t[[7, 1]], t[[6, 2]], t[[5, 3]], t[[4, 4]], t[[3, 5]], t[[2, 6]], t[[1, 7]], t[[1, 8]], t[[2, 7]], t[[3, 6]], t[[4, 5]], t[[5, 4]], t[[6, 3]], t[[7, 2]], t[[8, 1]], t[[8, 2]], t[[7, 3]], t[[6, 4]], t[[5, 5]], t[[4, 6]], t[[3, 7]], t[[2, 8]], t[[3, 8]], t[[4, 7]], t[[5, 6]], t[[6, 5]], t[[7, 4]], t[[8, 3]], t[[8, 4]], t[[7, 5]], t[[6, 6]], t[[5, 7]], t[[4, 8]], t[[5, 8]], t[[6, 7]], t[[7, 6]], t[[8, 5]], t[[8, 6]], t[[7, 7]], t[[6, 8]], t[[7, 8]], t[[8, 7]], t[[8, 8]]}; Jakub === Subject: Re: ZigZag matrix rearrange you may have a look at http://mathworld.wolfram.com/PairingFunction.html Jens > I'm trying to rearrange 8 x 8 matrix of numbers in ZigZag manner (as it is > used in JPEG comprimation algorithm http://en.wikipedia.org/wiki/Jpeg). I have created function which does it without problems, but it does it by > hand and it seems to me, that it could be done by some more elegant > algorithm. > Does somebody have any idea, how to do it more elegantly? My attempt: > zigzag[t_] := { > t[[1, 1]], > t[[1, 2]], t[[2, 1]], > t[[3, 1]], t[[2, 2]], t[[1, 3]], > t[[1, 4]], t[[2, 3]], t[[3, 2]], t[[4, 1]], > t[[5, 1]], t[[4, 2]], t[[3, 3]], t[[2, 4]], t[[1, 5]], > t[[1, 6]], t[[2, 5]], t[[3, 4]], t[[4, 3]], t[[5, 2]], t[[6, 1]], > t[[7, 1]], t[[6, 2]], t[[5, 3]], t[[4, 4]], t[[3, 5]], t[[2, 6]], > t[[1, 7]], > t[[1, 8]], t[[2, 7]], t[[3, 6]], t[[4, 5]], t[[5, 4]], t[[6, 3]], > t[[7, 2]], t[[8, 1]], > t[[8, 2]], t[[7, 3]], t[[6, 4]], t[[5, 5]], t[[4, 6]], t[[3, 7]], > t[[2, 8]], > t[[3, 8]], t[[4, 7]], t[[5, 6]], t[[6, 5]], t[[7, 4]], t[[8, 3]], > t[[8, 4]], t[[7, 5]], t[[6, 6]], t[[5, 7]], t[[4, 8]], > t[[5, 8]], t[[6, 7]], t[[7, 6]], t[[8, 5]], > t[[8, 6]], t[[7, 7]], t[[6, 8]], > t[[7, 8]], t[[8, 7]], > t[[8, 8]]}; > Jakub > === Subject: Re: ZigZag matrix rearrange > I'm trying to rearrange 8 x 8 matrix of numbers in ZigZag manner (as it is > used in JPEG comprimation algorithm http://en.wikipedia.org/wiki/Jpeg). I have created function which does it without problems, but it does it by > hand and it seems to me, that it could be done by some more elegant > algorithm. > Does somebody have any idea, how to do it more elegantly? My attempt: > zigzag[t_] := { > t[[1, 1]], > t[[1, 2]], t[[2, 1]], > t[[3, 1]], t[[2, 2]], t[[1, 3]], > t[[1, 4]], t[[2, 3]], t[[3, 2]], t[[4, 1]], > t[[5, 1]], t[[4, 2]], t[[3, 3]], t[[2, 4]], t[[1, 5]], > t[[1, 6]], t[[2, 5]], t[[3, 4]], t[[4, 3]], t[[5, 2]], t[[6, 1]], > t[[7, 1]], t[[6, 2]], t[[5, 3]], t[[4, 4]], t[[3, 5]], t[[2, 6]], > t[[1, 7]], > t[[1, 8]], t[[2, 7]], t[[3, 6]], t[[4, 5]], t[[5, 4]], t[[6, 3]], > t[[7, 2]], t[[8, 1]], > t[[8, 2]], t[[7, 3]], t[[6, 4]], t[[5, 5]], t[[4, 6]], t[[3, 7]], > t[[2, 8]], > t[[3, 8]], t[[4, 7]], t[[5, 6]], t[[6, 5]], t[[7, 4]], t[[8, 3]], > t[[8, 4]], t[[7, 5]], t[[6, 6]], t[[5, 7]], t[[4, 8]], > t[[5, 8]], t[[6, 7]], t[[7, 6]], t[[8, 5]], > t[[8, 6]], t[[7, 7]], t[[6, 8]], > t[[7, 8]], t[[8, 7]], > t[[8, 8]]}; > Jakub Can be done algorithmically using Reverse and Diagonal. mat = Array[t, {8, 8}]; Table[If[EvenQ[j], Identity, Reverse][ Diagonal[Reverse[mat, 2], j]], {j, Length[mat] - 1, -Length[mat] + 1, -1}] {{t[1, 1]}, {t[1, 2], t[2, 1]}, {t[3, 1], t[2, 2], t[1, 3]}, {t[1, 4], t[2, 3], t[3, 2], t[4, 1]}, {t[5, 1], t[4, 2], t[3, 3], t[2, 4], t[1, 5]}, {t[1, 6], t[2, 5], t[3, 4], t[4, 3], t[5, 2], t[6, 1]}, {t[7, 1], t[6, 2], t[5, 3], t[4, 4], t[3, 5], t[2, 6], t[1, 7]}, {t[1, 8], t[2, 7], t[3, 6], t[4, 5], t[5, 4], t[6, 3], t[7, 2], t[8, 1]}, {t[8, 2], t[7, 3], t[6, 4], t[5, 5], t[4, 6], t[3, 7], t[2, 8]}, {t[3, 8], t[4, 7], t[5, 6], t[6, 5], t[7, 4], t[8, 3]}, {t[8, 4], t[7, 5], t[6, 6], t[5, 7], t[4, 8]}, {t[5, 8], t[6, 7], t[7, 6], t[8, 5]}, {t[8, 6], t[7, 7], t[6, 8]}, {t[7, 8], t[8, 7]}, {t[8, 8]}} Daniel Lichtblau Wolfram Research === Subject: Re: ZigZag matrix rearrange Elegance isn't always fast, but here's a possibility: Clear[next] next[{1, 8}] = {2, 8}; next[{8, 1}] = {7, 2}; next[{x_, 1}] := next[{x, 1}] = If[OddQ@x, {x + 1, 1}, {x - 1, 2}] next[{1, y_}] := next[{1, y}] = If[EvenQ@y, {1, y + 1}, {2, y - 1}] next[{8, y_}] := next[{8, y}] = If[OddQ@y, {7, y + 1}, {8, y + 1}] next[{x_, 8}] := next[{x, 8}] = If[EvenQ@x, {x + 1, 7}, {x + 1, 8}] next[{x_, y_}] := next[{x, y}] = If[OddQ[x + y], {x - 1, y + 1}, {x + 1, y - 1}] Clear[zigzag, t] zigzag[t_] = t @@@ NestList[next, {1, 1}, 8*8 - 1] {t[1, 1], t[2, 1], t[1, 2], t[1, 3], t[2, 2], t[3, 1], t[4, 1], t[3, 2], t[2, 3], t[1, 4], t[1, 5], t[2, 4], t[3, 3], t[4, 2], t[5, 1], t[6, 1], t[5, 2], t[4, 3], t[3, 4], t[2, 5], t[1, 6], t[1, 7], t[2, 6], t[3, 5], t[4, 4], t[5, 3], t[6, 2], t[7, 1], t[8, 1], t[7, 2], t[6, 3], t[5, 4], t[4, 5], t[3, 6], t[2, 7], t[1, 8], t[2, 8], t[3, 7], t[4, 6], t[5, 5], t[6, 4], t[7, 3], t[8, 2], t[8, 3], t[7, 4], t[6, 5], t[5, 6], t[4, 7], t[3, 8], t[4, 8], t[5, 7], t[6, 6], t[7, 5], t[8, 4], t[8, 5], t[7, 6], t[6, 7], t[5, 8], t[6, 8], t[7, 7], t[8, 6], t[8, 7], t[7, 8], t[8, 8]} or this: Clear[bounce, next] bounce[{x_, 9}] := {x + 2, 8} bounce[{9, y_}] := {8, y + 2} bounce[{x_, 0}] := {x, 1} bounce[{0, y_}] := {1, y} bounce[{x_, y_}] := {x, y} next[{x_, y_}] := next[{x, y}] = bounce@If[OddQ[x + y], {x - 1, y + 1}, {x + 1, y - 1}] Clear[zigzag, t] zigzag[t_] = t @@@ NestList[next, {1, 1}, 8*8 - 1] I've switched x and y so that x is horizontal and y is vertical. Bobby > I'm trying to rearrange 8 x 8 matrix of numbers in ZigZag manner (as it > is > used in JPEG comprimation algorithm http://en.wikipedia.org/wiki/Jpeg). I have created function which does it without problems, but it does it > by > hand and it seems to me, that it could be done by some more elegant > algorithm. > Does somebody have any idea, how to do it more elegantly? My attempt: > zigzag[t_] := { > t[[1, 1]], > t[[1, 2]], t[[2, 1]], > t[[3, 1]], t[[2, 2]], t[[1, 3]], > t[[1, 4]], t[[2, 3]], t[[3, 2]], t[[4, 1]], > t[[5, 1]], t[[4, 2]], t[[3, 3]], t[[2, 4]], t[[1, 5]], > t[[1, 6]], t[[2, 5]], t[[3, 4]], t[[4, 3]], t[[5, 2]], t[[6, 1]], > t[[7, 1]], t[[6, 2]], t[[5, 3]], t[[4, 4]], t[[3, 5]], t[[2, 6]], > t[[1, 7]], > t[[1, 8]], t[[2, 7]], t[[3, 6]], t[[4, 5]], t[[5, 4]], t[[6, 3]], > t[[7, 2]], t[[8, 1]], > t[[8, 2]], t[[7, 3]], t[[6, 4]], t[[5, 5]], t[[4, 6]], t[[3, 7]], > t[[2, 8]], > t[[3, 8]], t[[4, 7]], t[[5, 6]], t[[6, 5]], t[[7, 4]], t[[8, 3]], > t[[8, 4]], t[[7, 5]], t[[6, 6]], t[[5, 7]], t[[4, 8]], > t[[5, 8]], t[[6, 7]], t[[7, 6]], t[[8, 5]], > t[[8, 6]], t[[7, 7]], t[[6, 8]], > t[[7, 8]], t[[8, 7]], > t[[8, 8]]}; > Jakub > -- DrMajorBob@bigfoot.com === Subject: Re: ZigZag matrix rearrange > I'm trying to rearrange 8 x 8 matrix of numbers in ZigZag manner (as it is > used in JPEG comprimation algorithmhttp://en.wikipedia.org/wiki/Jpeg). I have created function which does it without problems, but it does it by > hand and it seems to me, that it could be done by some more elegant > algorithm. > Does somebody have any idea, how to do it more elegantly? My attempt: > zigzag[t_] := { > t[[1, 1]], > t[[1, 2]], t[[2, 1]], > t[[3, 1]], t[[2, 2]], t[[1, 3]], > t[[1, 4]], t[[2, 3]], t[[3, 2]], t[[4, 1]], > t[[5, 1]], t[[4, 2]], t[[3, 3]], t[[2, 4]], t[[1, 5]], > t[[1, 6]], t[[2, 5]], t[[3, 4]], t[[4, 3]], t[[5, 2]], t[[6, 1]], > t[[7, 1]], t[[6, 2]], t[[5, 3]], t[[4, 4]], t[[3, 5]], t[[2, 6]], > t[[1, 7]], > t[[1, 8]], t[[2, 7]], t[[3, 6]], t[[4, 5]], t[[5, 4]], t[[6, 3]], > t[[7, 2]], t[[8, 1]], > t[[8, 2]], t[[7, 3]], t[[6, 4]], t[[5, 5]], t[[4, 6]], t[[3, 7]], > t[[2, 8]], > t[[3, 8]], t[[4, 7]], t[[5, 6]], t[[6, 5]], t[[7, 4]], t[[8, 3]], > t[[8, 4]], t[[7, 5]], t[[6, 6]], t[[5, 7]], t[[4, 8]], > t[[5, 8]], t[[6, 7]], t[[7, 6]], t[[8, 5]], > t[[8, 6]], t[[7, 7]], t[[6, 8]], > t[[7, 8]], t[[8, 7]], > t[[8, 8]]}; > Jakub zz[n_Integer?Positive] := Module[{s = If[OddQ@#,1,-1]&}, Abs[Rest/@Sort@Flatten[Table[{i+j,i*s[i+j],j*s[i+j]},{i,n},{j,n}],1]]] zz[8] {{1,1}, {1,2},{2,1}, {3,1},{2,2},{1,3}, {1,4},{2,3},{3,2},{4,1}, {5,1},{4,2},{3,3},{2,4},{1,5}, {1,6},{2,5},{3,4},{4,3},{5,2},{6,1}, {7,1},{6,2},{5,3},{4,4},{3,5},{2,6},{1,7}, {1,8},{2,7},{3,6},{4,5},{5,4},{6,3},{7,2},{8,1}, {8,2},{7,3},{6,4},{5,5},{4,6},{3,7},{2,8}, {3,8},{4,7},{5,6},{6,5},{7,4},{8,3}, {8,4},{7,5},{6,6},{5,7},{4,8}, {5,8},{6,7},{7,6},{8,5}, {8,6},{7,7},{6,8}, {7,8},{8,7}, {8,8}} zz[m_List /; ArrayDepth@m > 1 && Equal@@Take[Dimensions@m,2] ] := Extract[m,zz@Length@m] t = Table[t<>ToString[10i+j],{i,8},{j,8}] {{t11,t12,t13,t14,t15,t16,t17,t18}, {t21,t22,t23,t24,t25,t26,t27,t28}, {t31,t32,t33,t34,t35,t36,t37,t38}, {t41,t42,t43,t44,t45,t46,t47,t48}, {t51,t52,t53,t54,t55,t56,t57,t58}, {t61,t62,t63,t64,t65,t66,t67,t68}, {t71,t72,t73,t74,t75,t76,t77,t78}, {t81,t82,t83,t84,t85,t86,t87,t88}} zz[t] {t11, t12,t21, t31,t22,t13, t14,t23,t32,t41, t51,t42,t33,t24,t15, t16,t25,t34,t43,t52,t61, t71,t62,t53,t44,t35,t26,t17, t18,t27,t36,t45,t54,t63,t72,t81, t82,t73,t64,t55,t46,t37,t28, t38,t47,t56,t65,t74,t83, t84,t75,t66,t57,t48, t58,t67,t76,t85, t86,t77,t68, t78,t87, t88} === Subject: Re: ZigZag matrix rearrange Probably you will receive several beautiful one-liners. Anyway, my rough solution is: plist[n_] :=Module[ {lip, ulip}, Table[ lip = Rest@IntegerPartitions[i + 1, 2]; ulip = Union@Join[lip, Reverse /@ lip]; If[EvenQ[i], ulip, Reverse[ulip]], {i, 2 n - 1} ] /. {a_, b_} /; Max[a, b] > n :> Sequence[] ]; Apply[t[[##]] &, plist[8], {2}] produces your pattern with sublist Apply[t[[##]] &, Flatten[plist[8], 1], {1}] produces your pattern as a flat list By changing the parameter n in plist you can create bigger/smaller patterns. ADL > I'm trying to rearrange 8 x 8 matrix of numbers in ZigZag manner (as it is > used in JPEG comprimation algorithmhttp://en.wikipedia.org/wiki/Jpeg). I have created function which does it without problems, but it does it by > hand and it seems to me, that it could be done by some more elegant > algorithm. > Does somebody have any idea, how to do it more elegantly? > ... Jakub === Subject: Re: Plot x to y and y to x I'm trying to plot a function. 1-e^0.5*(250-T) I would like to plot a temperature rise of T = 200 to 300. Then I would like to plot a decrease in temp of T = 300 to 200. === Subject: Re: Plot x to y and y to x Zach, I have the feeling something is still missing. It doesn't make sense to me to plot both the function as it goes from 200 to 300 deg and as it goes from 300 to 200 deg. Those two are each others mirror image. Anyway, you should change e in E or in escape-ee-escape, because lowercase e doesn't have a built-in value. Generally, to plot a function f(t) you'd write Plot[f[t],{t, startingValue,endValue}]. In your case Plot[1-E^0.5*(250-T),{T,250,300}] BTW, are you sure about the parentheses? Not 1-E^(0.5*(250-T)) by any chance? Perhaps you intended time to enter the equation and forgot it? > I'm trying to plot a function. > 1-e^0.5*(250-T) > I would like to plot a temperature rise of T = 200 to 300. Then I wo= uld like to plot a decrease in temp of T = 300 to 200. === Subject: Re: Mathematica JLink and comm.javax.CommPortIdentifier > I would like to use JLink to perform serial communication functions with > Mathematica. It appears that javacomm api for Windows is no longer > supported by Sun. So as an alternative I am attempting to use RxTx as = a > substitute. You may be interested in the SerialIO package for Mathematica. http://library.wolfram.com/infocenter/MathSource/5726/ -Rob === Subject: Re: Mathematica JLink and comm.javax.CommPortIdentifier Hi Charles, I guess Java does not find your library. You have to tell Jva where it is located. You may e.g. use the option: -Djava.library.path=.... Daniel > > I would like to use JLink to perform serial communication functions with > Mathematica. It appears that javacomm api for Windows is no longer > supported by Sun. So as an alternative I am attempting to use RxTx as a > substitute. When I attempt to run: In[2]:= InstallJava[] > Out[2]= LinkObject[C:Program FilesWolfram > ResearchMathematica7.0SystemFilesJavaWindowsbinjavaw -classpath > C:Program FilesWolfram > ResearchMathematica7.0SystemFilesLinksJLinkJLink.jar -Xmx256m > -Djava.system.class.loader=com.wolfram.jlink.JLinkSystemClassLoader > com.wolfram.jlink.Install -init C:Documents and > SettingsckoehlerLocal SettingsTempm19.tmp,4,4] I assume that I have installed the rxtx dll and jar files in the correct > location. > > LoadJavaClass[comm.javax.CommPortIdentifier] I receive the following error: Java::excptn: A Java exception occurred: > java.lang.ClassNotFoundException: comm.javax.CommPortIdentifier > at java.net.URLClassLoader$1.run(URLClassLoader.java:200) > at java.security.AccessController.doPrivileged(Native Method) > at java.net.URLClassLoader.findClass(URLClassLoader.java:188) > at java.lang.ClassLoader.loadClass(ClassLoader.java:307) > at java.lang.ClassLoader.loadClass(ClassLoader.java:252) > at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320) > at java.lang.Class.forName0(Native Method) > at java.lang.Class.forName(Class.java:247). LoadJavaClass::fail: Java failed to load class > comm.javax.CommPortIdentifier. I realize this is may not be the appropriate newsgroup for this, but the > only documentation I could find regarding Jlink is out of data. > Chuck Koehler === Subject: Re: Jacobi polynomials in Mathematica > I have a simple question: in Mathematica the Jacobi polynomials are > implemented > as JacobiP[n, a, b, z], see > http://mathworld.wolfram.com/JacobiPolynomial.html Is JacobiP[n, a, b, z] also defined if n is not an integer? More > general, is > JacobiP[n, a, b, z] defined for all real n, a, b and z? Primary definitions can be found on the following functions web pages: http://functions.wolfram.com/Polynomials/JacobiP/02/ http://functions.wolfram.com/HypergeometricFunctions/JacobiPGeneral/02/ The first defines the function for natural number n, while the second does not place a restriction on n (nu on the page). Darren Glosemeyer Wolfram Research === Subject: Re: Jacobi polynomials in Mathematica [...] > Is JacobiP[n, a, b, z] also defined if n is not an integer? More > general, is JacobiP[n, a, b, z] defined for all real n, a, b and z? Look at the Scope section in the function's documentation, at http://reference.wolfram.com/mathematica/ref/JacobiP.html Pillsy === Subject: Re: Jacobi polynomials in Mathematica Hi Cora, at least the folllowing works: Plot[JacobiP[2.5, 1.5, 2.5, x], {x, 0, 10}] Daniel > I have a simple question: in Mathematica the Jacobi polynomials are > implemented > as JacobiP[n, a, b, z], see > http://mathworld.wolfram.com/JacobiPolynomial.html Is JacobiP[n, a, b, z] also defined if n is not an integer? More > general, is > JacobiP[n, a, b, z] defined for all real n, a, b and z? === Subject: Re: Jacobi polynomials in Mathematica a simple check JacobiP[n, a, b, z] /. {n -> 0.5, a -> 0.5, b -> 0.5, z -> 0.2} gives 0.767081 so, it may be defined. Jens > I have a simple question: in Mathematica the Jacobi polynomials are > implemented > as JacobiP[n, a, b, z], see > http://mathworld.wolfram.com/JacobiPolynomial.html Is JacobiP[n, a, b, z] also defined if n is not an integer? More > general, is > JacobiP[n, a, b, z] defined for all real n, a, b and z? === Subject: Re: Jacobi polynomials in Mathematica > On 24 Apr, 11:13, Jens-Peer Kuska a simple check >> JacobiP[n, a, b, z] /. {n -> 0.5, a -> 0.5, b -> 0.5, z -> 0.2} >> gives >> 0.767081 >> so, it may be defined. >> Jens >> I have a simple question: in Mathematica the Jacobi polynomials are >> implemented >> as JacobiP[n, a, b, z], see >>http://mathworld.wolfram.com/JacobiPolynomial.html >> Is JacobiP[n, a, b, z] also defined if n is not an integer? More >> general, is >> JacobiP[n, a, b, z] defined for all real n, a, b and z? > > Well, even if Mathematica is giving out a value I'm not too sure > whether it's correct or not. For example, > Product[j, {j, 1, 4}] gives 24 But > Product[j, {j, 1, 4.5}] also gives 24. Surely, the second answer is wrong. Not at all wrong. It is very much in accordance with documented behavior for Product and iterators in Mathematica. Checking the relevant documentation tutorial/SomeGeneralNotationsAndConventions#27272 one sees ...The iteration parameters Subscript[i, min],Subscript[i, max] and di do not need to be integers. The variable i is given a sequence of values starting at Subscript[i, min], and increasing in steps of di, stopping when the next value of i would be greater than Subscript[i, max]. The iteration parameters can be arbitrary symbolic expressions, so long as (Subscript[i, max]-Subscript[i, min])/di is a number... I will remark that this is common behavior for iterators in other languages as well. Your example, using Product, is not an apt analogy to JacobiP. The reason is that for specific iterator bounds (e.g. 1 to 4.5) it is reasonable to expect behavior that is procedural (or at least algorithmic), rather than some form of analytic result. A closer analogy to JacobiP might be the relation of Factorial (which can be represented algorithmically via Product) to Gamma. To put it a bit differently, there is no reason to expect Product evaluations in general to give closed-form functions that have nice continuations. Closed for functions such as Jacobi polynomials, in contrast, might have well established continuations to non-integer values. One last remark: The statement Well, even if... is lacking in contest. If you have no expectation of what JacobiP[noninteger,...] does or should do, it is axiomatic that you do not know whether specific values are correct or not. Without some background information it is really unclear what you are expecting from these evaluations. Daniel Lichtblau Wolfram Research === Subject: Re: Jacobi polynomials in Mathematica This is entirely correct: Product[j, {j, 1, 4.5}] 24 ...since j varies from the lower limit (1 in this case), adding 1 at each step, and stopping at OR BELOW the upper limit. In this case j takes on the values 1, 2, 3, and 4. Adding 1 again to get 5 would exceed the upper limit. But consider the calculations Product[j, {j, 1, n}] % /. n -> 4.5 Gamma[4.5 + 1] n! 52.3428 52.3428 The first result generalizes the Product to an arbitrary positive integer and returns Factorial, an INCORRECT result for non-integers such as 4.5. Yet it's a USEFUL result for non-integers, if we intend to use the Gamma function to extend Factorial. Bobby > On 24 Apr, 11:13, Jens-Peer Kuska a simple check >> JacobiP[n, a, b, z] /. {n -> 0.5, a -> 0.5, b -> 0.5, z -> 0.2} >> gives >> 0.767081 >> so, it may be defined. >> Jens >> I have a simple question: in Mathematica the Jacobi polynomials are >> implemented >> as JacobiP[n, a, b, z], see >>http://mathworld.wolfram.com/JacobiPolynomial.html >> Is JacobiP[n, a, b, z] also defined if n is not an integer? More >> general, is >> JacobiP[n, a, b, z] defined for all real n, a, b and z? > > Well, even if Mathematica is giving out a value I'm not too sure > whether it's correct or not. For example, > Product[j, {j, 1, 4}] gives 24 But > Product[j, {j, 1, 4.5}] also gives 24. Surely, the second answer is wrong. > -- DrMajorBob@bigfoot.com === Subject: Re: Jacobi polynomials in Mathematica On 24 Apr, 11:13, Jens-Peer Kuska a simple check JacobiP[n, a, b, z] /. {n -> 0.5, a -> 0.5, b -> 0.5, z -> 0.2} gives 0.767081 so, it may be defined. Jens I have a simple question: in Mathematica the Jacobi polynomials are > implemented > as JacobiP[n, a, b, z], see >http://mathworld.wolfram.com/JacobiPolynomial.html Is JacobiP[n, a, b, z] also defined if n is not an integer? More > general, is > JacobiP[n, a, b, z] defined for all real n, a, b and z? > Well, even if Mathematica is giving out a value I'm not too sure whether it's correct or not. For example, Product[j, {j, 1, 4}] gives 24 But Product[j, {j, 1, 4.5}] also gives 24. Surely, the second answer is wrong. === Subject: Replace elements in structured list how would you solve this problem in an elegant and effective way? My aim is to get a list of consecutive numbers, starting from 1, AND to retain the structure of the original list as well. In[49]:= data = {{1, {2, 2, 2, 2}, {2, 2, 2, 2}, 1}, {1, {2, 2, 2, 2}, {2, 2, 2, 2}, 1}}; c = 1; Replace[data, _?NumberQ :> c++, [Infinity]] Out[51]= {{37, {38, 39, 40, 41}, {42, 43, 44, 45}, 46}, {47, {48, 49, 50, 51}, {52, 53, 54, 55}, 56}} So the function should return a similar list, but starting at 1 instead of 37. Now I must note that the original data can have fewer/more levels, elements, etc. Istvan Zachar === Subject: Re: Replace elements in structured list Use ReplaceAll (/.) In[3]:= c = 1; data /. _?NumberQ :> c++ Out[3]= {{1, {2, 3, 4, 5}, {6, 7, 8, 9}, 10}, {11, {12, 13, 14, 15}, {16, 17, 18, 19}, 20}} Adriano Pascoletti 2009/4/25 how would you solve this problem in an elegant and effective way? > My aim is to get a list of consecutive numbers, starting from 1, AND > to retain the structure of the original list as well. In[49]:= data = {{1, {2, 2, 2, 2}, {2, 2, 2, 2}, 1}, {1, {2, 2, 2, 2}, > {2, 2, 2, 2}, 1}}; c = 1; Replace[data, _?NumberQ :> c++, [Infinity]] Out[51]= {{37, {38, 39, 40, 41}, {42, 43, 44, 45}, > 46}, {47, {48, 49, 50, 51}, {52, 53, 54, 55}, 56}} So the function should return a similar list, but starting at 1 > instead of 37. > Now I must note that the original data can have fewer/more levels, > elements, etc. Istvan Zachar === Subject: Re: Replace elements in structured list how would you solve this problem in an elegant and effective way? > My aim is to get a list of consecutive numbers, starting from 1, AND > to retain the structure of the original list as well. In[49]:= data = {{1, {2, 2, 2, 2}, {2, 2, 2, 2}, 1}, {1, {2, 2, 2, 2}, > {2, 2, 2, 2}, 1}}; c = 1; Replace[data, _?NumberQ :> c++, [Infinity]] Out[51]= {{37, {38, 39, 40, 41}, {42, 43, 44, 45}, > 46}, {47, {48, 49, 50, 51}, {52, 53, 54, 55}, 56}} So the function should return a similar list, but starting at 1 > instead of 37. > Now I must note that the original data can have fewer/more levels, > elements, etc. Istvan Zachar partitionedAz[s_List, t_List] /; Length@s >= Length@Flatten@t := ReplacePart[t, s, Position[t,_,{-1},Heads->False], Transpose@{Range@Length@Flatten@t}] data = {{1,{2,2,2,2},{2,2,2,2},1},{1,{2,2,2,2},{2,2,2,2},1}}; Range@Length@Flatten@data ~ partitionedAz ~ data {{1,{2,3,4,5},{6,7,8,9},10},{11,{12,13,14,15},{16,17,18,19},20}} partitionedAz[s,t] partitions the first level of a list s the same way that a list t is partitioned; i.e., so that Only the first Length@Flatten@t elements of s are used; any extras are dropped. This is the best of several solutions from the thread Insulating data from code that ran May 16-23, 2006: === Subject: Re: Replace elements in structured list c = 1; data /. _Integer :> c++ ? Jens how would you solve this problem in an elegant and effective way? > My aim is to get a list of consecutive numbers, starting from 1, AND > to retain the structure of the original list as well. In[49]:= data = {{1, {2, 2, 2, 2}, {2, 2, 2, 2}, 1}, {1, {2, 2, 2, 2}, > {2, 2, 2, 2}, 1}}; c = 1; Replace[data, _?NumberQ :> c++, [Infinity]] Out[51]= {{37, {38, 39, 40, 41}, {42, 43, 44, 45}, > 46}, {47, {48, 49, 50, 51}, {52, 53, 54, 55}, 56}} So the function should return a similar list, but starting at 1 > instead of 37. > Now I must note that the original data can have fewer/more levels, > elements, etc. Istvan Zachar > === Subject: Re: Replace elements in structured list Never mind, I've found the answer at -1: In[4]:= data = {{1, {2, 2, 2, 2}, {2, 2, 2, 2}, 1}, {1, {2, 2, 2, 2}, {2, 2, 2, 2}, 1}}; c = 1; Replace[data, _?NumberQ :> c++, {-1, [Infinity]}] Out[6]= {{1, {2, 3, 4, 5}, {6, 7, 8, 9}, 10}, {11, {12, 13, 14, 15}, {16, 17, 18, 19}, 20}} === Subject: Copy/paste selection of a pdf on Mac I think this has more to do with Apple than Mathematica: - Select a portion of a pdf file in Preview.app and copy to the clipboard, - Paste in Mathematica. This results in the whole pdf page being pasted in Mathematica. Researching on the web showed that this same behaviour was observed with Keynote at some point but it has since been fixed. It has to do with a new so-called non-destructive way that Preview now uses for cropping. The application where the pasting is done needs to be made aware of this change on the part of Apple. Thus, on my 10.5.6 system, pasting works well with Pages and Keynote (iWork 9). A workaround is to paste in one of these applications, copy the pdf image and paste it in Mathematica. This works as expected. A.B. === Subject: Re: Copy/paste selection of a pdf on Mac In Apple Preview.app, Leopard (10.5), the menu View:PDf Display: has two options, 'Media Box' and 'Crop Box'. If one selects and copies a portion of a pdf and creates in Preview a new pdf from the clipboard, then View Crop Box shows the selected part only while View Media Box shows the whole page. It means that applications such as Apple Pages and Keynote (and also TexShop) show the pasted portion of the pdf in Crop view, while Mathematica shows the whole pasted pdf page, ie the 'Media view'. A.B. > I think this has more to do with Apple than Mathematica: - Select a portion of a pdf file in Preview.app and copy to the clipboard, > - Paste in Mathematica. This results in the whole pdf page being pasted in Mathematica. Researching on > the web showed that this same behaviour was observed with Keynote at some > point but it has since been fixed. > It has to do with a new so-called non-destructive way that Preview now uses > for cropping. The application where the pasting is done needs to be made aware > of this change on the part of Apple. Thus, on my 10.5.6 system, pasting works > well with Pages and Keynote (iWork 9). > A workaround is to paste in one of these applications, copy the pdf image and > paste it in Mathematica. This works as expected. A.B. === Subject: Re: ContourPlot, equation and R.H. side of Try these ContourPlot[3 x^2 + 6 y^2 == 6, {x, -2, 2}, {y, -2, 2}, Axes -> True] Attributes[ContourPlot] {HoldAll,Protected} eqn1 = 3 x^2 + 6 y^2 == 6; ContourPlot[Evaluate[eqn1], {x, -2, 2}, {y, -2, 2}, Axes -> True] eqn2 = 3 x^2 + 6 y^2; ContourPlot[eqn2 == 6, {x, -2, 2}, {y, -2, 2}, Axes -> True] ContourPlot[eqn2, {x, -2, 2}, {y, -2, 2}, Axes -> True, Contours -> {6}] Bob Hanlon Hi: 1a.) When I assign 3 x^2 + 6 y^2 == 6 to eqn1, in Mathematica like this: eqn1=3 x^2 + 6 y^2 == 6; I can't get ContourPlot to plot eqn1 using this code: ContourPlot[eqn1, {x, -2, 2}, {y, -2, 2}, Axes -> True] 1b.) If I assign the equation like this without the constant on the R.H. side in eqn2, ContourPlot will plot the equation as expected, using the following syntax: eqn2=3 x^2 + 6 y^2; ContourPlot[eqn2 == 6, {x, -2, 2}, {y, -2, 2}, Axes -> True] Question: How can I get method 1a to work? Could you please give me code for this? Bill PS. I'm using Mathematica 6.0.1 w/ Win XP on a PC. === Subject: MaxValue Suppose I want to find supremum of {(-1)^n: n is natural}, MaxValue just returns the question itself. if I ask it sup of (1+2)^n, it givs infinity, but max of (1-2)^n it just returns the question itself. FindMaximum and FindMinimum also can't handle (-1)^n...how can it be done then? === Subject: A very large output was generated. Here is a sample of it: Hi there, I've recently upgraded to Mathematica 7.0. I find the box A very large output was generated. Here is a sample of it: quite annoying. I would like to copy and paste the output into a different Mathematica notebook. So I have to click on Show Full Output which takes ages to generate. Is there a default setting where I can force Mathematica to always give the Full Output rather than this annoying A very large output... box? === Subject: Re: MatrixPlot with color range bar But most custom graphics requires custom work. The built-in Mathematica =E2=80=98set-piece-plots=E2=80=99 only work well for restricted classes of plots. So in general one should expect to have to do the work. Usually, each graphics problem requires it own solution. Of course, if you had many different matrices that you wanted to plot, you could write a routine that would simplify it for you =E2=80=93 producing your own plot type so to speak. Often it is easier, and more rewarding, to put together detailed primitives in a custom graphic, than to try to tweak an existing WRI =E2=80=98set-piece-plot=E2=80=99. David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ ??? I tried your code. The plot looks very nice. Although it's very nice, i expect more simple method to be included in the next version of Mathematica. 2009/4/25 David Park My suggestion: data = Table[Cos[x y/150.], {x, -50, 50}, {y, -50, 50}]; matrixplot = MatrixPlot[data, ColorFunction -> Rainbow]; legend = DensityPlot[y, {x, 0, 1}, {y, -1, 1}, ColorFunction -> (ColorData[Rainbow][Rescale[#, {-1, 1}]] &), ColorFunctionScaling -> False, PlotPoints -> 51, AspectRatio -> Full, PlotRange -> {{0, 1}, {-1, 1}}, Background -> None, Frame -> True, FrameTicks -> {{None, Range[-1, 1, .25]}, {None, None}}, ImagePadding -> {{2, 30}, {5, 5}}, ImageSize -> {50, 400}]; Graphics[ {Inset[matrixplot, {4, 4.3}, {Center, Center}, {400, 450} 0.02], Inset[legend, {8.8, 4.2}, {Center, Center}, {5, 40} 0.17], Text[Style[Matrix Plot with Legend, Large], {5, 9.3}], Text[Style[Legend, 14, Bold], {8.5, 8.0}]}, PlotRange -> {{0, 10}, {0, 10}}, Frame -> False, ImageSize -> 500] David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ I'd like to draw plots like http://www.gle-graphics.org/examples/3dplots/informationgain.png I know that MatrixPlot function draws such plots. My question is how to draw color range bar like that on the right side = of the plot at the url. Is there any options of MatrixPlot or tricks to draw such color range = bar ? === Subject: Re: MatrixPlot with color range bar I tried your code. The plot looks very nice. Although it's very nice, i expect more simple method to be included in the next version of Mathematica. 2009/4/25 David Park My suggestion: data = Table[Cos[x y/150.], {x, -50, 50}, {y, -50, 50}]; matrixplot = MatrixPlot[data, ColorFunction -> Rainbow]; legend = DensityPlot[y, {x, 0, 1}, {y, -1, 1}, ColorFunction -> (ColorData[Rainbow][Rescale[#, {-1, 1}]] &), ColorFunctionScaling -> False, PlotPoints -> 51, AspectRatio -> Full, PlotRange -> {{0, 1}, {-1, 1}}, Background -> None, Frame -> True, FrameTicks -> {{None, Range[-1, 1, .25]}, {None, None}}, ImagePadding -> {{2, 30}, {5, 5}}, ImageSize -> {50, 400}]; Graphics[ {Inset[matrixplot, {4, 4.3}, {Center, Center}, {400, 450} 0.02], Inset[legend, {8.8, 4.2}, {Center, Center}, {5, 40} 0.17], Text[Style[Matrix Plot with Legend, Large], {5, 9.3}], Text[Style[Legend, 14, Bold], {8.5, 8.0}]}, PlotRange -> {{0, 10}, {0, 10}}, Frame -> False, ImageSize -> 500] David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ I'd like to draw plots like http://www.gle-graphics.org/examples/3dplots/informationgain.png I know that MatrixPlot function draws such plots. My question is how to draw color range bar like that on the right side of the plot at the url. Is there any options of MatrixPlot or tricks to draw such color range bar ? === Subject: Re: MatrixPlot with color range bar I tried your code. The plot looks very nice. Although it's very nice, i expect more simple method to be included in the next version of Mathematica. 2009/4/25 David Park MatrixPlot[data, ColorFunction -> Rainbow]; legend = > DensityPlot[y, {x, 0, 1}, {y, -1, 1}, > ColorFunction -> (ColorData[Rainbow][Rescale[#, {-1, 1}]] &), > ColorFunctionScaling -> False, > PlotPoints -> 51, > AspectRatio -> Full, > PlotRange -> {{0, 1}, {-1, 1}}, > Background -> None, > Frame -> True, > FrameTicks -> {{None, Range[-1, 1, .25]}, {None, None}}, > ImagePadding -> {{2, 30}, {5, 5}}, > ImageSize -> {50, 400}]; > Graphics[ > {Inset[matrixplot, {4, 4.3}, {Center, Center}, {400, 450} 0.02], > Inset[legend, {8.8, 4.2}, {Center, Center}, {5, 40} 0.17], > Text[Style[Matrix Plot with Legend, Large], {5, 9.3}], > Text[Style[Legend, 14, Bold], {8.5, 8.0}]}, > PlotRange -> {{0, 10}, {0, 10}}, > Frame -> False, > ImageSize -> 500] > David Park > djmpark@comcast.net > http://home.comcast.net/~djmpark/ http://www.gle-graphics.org/examples/3dplots/informationgain.png > I know that MatrixPlot function draws such plots. > My question is how to draw color range bar like that on the right side of > the plot at the url. > Is there any options of MatrixPlot or tricks to draw such color range bar= ? > === Subject: Re: MatrixPlot with color range bar My suggestion: data = Table[Cos[x y/150.], {x, -50, 50}, {y, -50, 50}]; matrixplot = MatrixPlot[data, ColorFunction -> Rainbow]; legend = DensityPlot[y, {x, 0, 1}, {y, -1, 1}, ColorFunction -> (ColorData[Rainbow][Rescale[#, {-1, 1}]] &), ColorFunctionScaling -> False, PlotPoints -> 51, AspectRatio -> Full, PlotRange -> {{0, 1}, {-1, 1}}, Background -> None, Frame -> True, FrameTicks -> {{None, Range[-1, 1, .25]}, {None, None}}, ImagePadding -> {{2, 30}, {5, 5}}, ImageSize -> {50, 400}]; Graphics[ {Inset[matrixplot, {4, 4.3}, {Center, Center}, {400, 450} 0.02], Inset[legend, {8.8, 4.2}, {Center, Center}, {5, 40} 0.17], Text[Style[Matrix Plot with Legend, Large], {5, 9.3}], Text[Style[Legend, 14, Bold], {8.5, 8.0}]}, PlotRange -> {{0, 10}, {0, 10}}, Frame -> False, ImageSize -> 500] David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ I'd like to draw plots like http://www.gle-graphics.org/examples/3dplots/informationgain.png I know that MatrixPlot function draws such plots. My question is how to draw color range bar like that on the right side = of the plot at the url. Is there any options of MatrixPlot or tricks to draw such color range = bar ? === Subject: Re: MatrixPlot with color range bar But ShowLegend doesn't work with MatrixPlot. I'd like to plot some numerical data not a function. So, I need MatrixPlot not DensityPlot. > you need e.g. ShowLegend. Look it up in the manual. > Here is an example from the manual: > Needs[PlotLegends`] > ShowLegend[ > DensityPlot[Sin[x y], {x, 0, [Pi]}, {y, 0, [Pi]}, Mesh -> False, > PlotPoints -> 30], {ColorData[LakeColors][1 - #1] &, 10, 1, > -1, LegendPosition -> {1.1, -.4}}] Daniel > I'd like to draw plots like > http://www.gle-graphics.org/examples/3dplots/informationgain.png > I know that MatrixPlot function draws such plots. > My question is how to draw color range bar like that on the right side of > the plot at the url. > Is there any options of MatrixPlot or tricks to draw such color range bar= ? === Subject: Re: MatrixPlot with color range bar > But ShowLegend doesn't work with MatrixPlot. > I'd like to plot some numerical data not a function. > So, I need MatrixPlot not DensityPlot. you need e.g. ShowLegend. Look it up in the manual. > Here is an example from the manual: == > Needs[PlotLegends`] > ShowLegend[ > DensityPlot[Sin[x y], {x, 0, [Pi]}, {y, 0, [Pi]}, Mesh -> False, > PlotPoints -> 30], {ColorData[LakeColors][1 - #1] &, 10, 1, > -1, LegendPosition -> {1.1, -.4}}] == Daniel > I'd like to draw plots like >http://www.gle-graphics.org/examples/3dplots/informationgain.png > I know that MatrixPlot function draws such plots. > My question is how to draw color range bar like that on the right side = of > the plot at the url. > Is there any options of MatrixPlot or tricks to draw such color range b= ar= > ? Inset is probably better than ShowLegend for this: colourmap = DensityPlot[y, {x, 0, 0.1}, {y, 0, 1}, ColorFunction -> Rainbow, AspectRatio -> Automatic, FrameTicks -> {None, Automatic}, PlotRangePadding -> None]; p1 = MatrixPlot[ Fourier[Table[ UnitStep[i, 4 - i] UnitStep[j, 7 - j], {i, -50, 50}, {j, -50, 50}]]]; Graphics[{Inset[colourmap, {.75, 0}, Center, {1, 1.35}], Inset[p1, {-.1, 0}, Center, {1.5, 1.5}]}, PlotRange -> 1., ImageSize -> 400] Mike === Subject: Re: ZigZag matrix rearrange Far simpler is: Clear[m] m=Array[{##}&,{8,8}] (t1=Table[If[OddQ@k,Reverse@#,#]&@Diagonal[Reverse@m,k],{k,-7,7}])//Column {{{1,1},{1,2},{1,3},{1,4},{1,5},{1,6},{1,7},{1,8}},{{2,1},{2,2},{2,3},{2,4}, {2,5},{2,6},{2,7},{2,8}},{{3,1},{3,2},{3,3},{3,4},{3,5},{3,6},{3,7},{3,8}},{{ 4,1},{4,2},{4,3},{4,4},{4,5},{4,6},{4,7},{4,8}},{{5,1},{5,2},{5,3},{5,4},{5,5 },{5,6},{5,7},{5,8}},{{6,1},{6,2},{6,3},{6,4},{6,5},{6,6},{6,7},{6,8}},{{7,1} ,{7,2},{7,3},{7,4},{7,5},{7,6},{7,7},{7,8}},{{8,1},{8,2},{8,3},{8,4},{8,5},{8 ,6},{8,7},{8,8}}} {{1,1}} {{2,1},{1,2}} {{1,3},{2,2},{3,1}} {{4,1},{3,2},{2,3},{1,4}} {{1,5},{2,4},{3,3},{4,2},{5,1}} {{6,1},{5,2},{4,3},{3,4},{2,5},{1,6}} {{1,7},{2,6},{3,5},{4,4},{5,3},{6,2},{7,1}} {{8,1},{7,2},{6,3},{5,4},{4,5},{3,6},{2,7},{1,8}} {{2,8},{3,7},{4,6},{5,5},{6,4},{7,3},{8,2}} {{8,3},{7,4},{6,5},{5,6},{4,7},{3,8}} {{4,8},{5,7},{6,6},{7,5},{8,4}} {{8,5},{7,6},{6,7},{5,8}} {{6,8},{7,7},{8,6}} {{8,7},{7,8}} {{8,8}} or Flatten[t1,1]//InputForm {{1, 1}, {2, 1}, {1, 2}, {1, 3}, {2, 2}, {3, 1}, {4, 1}, {3, 2}, {2, 3}, {1, 4}, {1, 5}, {2, 4}, {3, 3}, {4, 2}, {5, 1}, {6, 1}, {5, 2}, {4, 3}, {3, 4}, {2, 5}, {1, 6}, {1, 7}, {2, 6}, {3, 5}, {4, 4}, {5, 3}, {6, 2}, {7, 1}, {8, 1}, {7, 2}, {6, 3}, {5, 4}, {4, 5}, {3, 6}, {2, 7}, {1, 8}, {2, 8}, {3, 7}, {4, 6}, {5, 5}, {6, 4}, {7, 3}, {8, 2}, {8, 3}, {7, 4}, {6, 5}, {5, 6}, {4, 7}, {3, 8}, {4, 8}, {5, 7}, {6, 6}, {7, 5}, {8, 4}, {8, 5}, {7, 6}, {6, 7}, {5, 8}, {6, 8}, {7, 7}, {8, 6}, {8, 7}, {7, 8}, {8, 8}} Bobby > Elegance isn't always fast, but here's a possibility: Clear[next] > next[{1, 8}] = {2, 8}; > next[{8, 1}] = {7, 2}; > next[{x_, 1}] := next[{x, 1}] = If[OddQ@x, {x + 1, 1}, {x - 1, 2}] > next[{1, y_}] := next[{1, y}] = If[EvenQ@y, {1, y + 1}, {2, y - 1}] > next[{8, y_}] := next[{8, y}] = If[OddQ@y, {7, y + 1}, {8, y + 1}] > next[{x_, 8}] := next[{x, 8}] = If[EvenQ@x, {x + 1, 7}, {x + 1, 8}] > next[{x_, y_}] := > next[{x, y}] = If[OddQ[x + y], {x - 1, y + 1}, {x + 1, y - 1}] Clear[zigzag, t] > zigzag[t_] = t @@@ NestList[next, {1, 1}, 8*8 - 1] {t[1, 1], t[2, 1], t[1, 2], t[1, 3], t[2, 2], t[3, 1], t[4, 1], > t[3, 2], t[2, 3], t[1, 4], t[1, 5], t[2, 4], t[3, 3], t[4, 2], > t[5, 1], t[6, 1], t[5, 2], t[4, 3], t[3, 4], t[2, 5], t[1, 6], > t[1, 7], t[2, 6], t[3, 5], t[4, 4], t[5, 3], t[6, 2], t[7, 1], > t[8, 1], t[7, 2], t[6, 3], t[5, 4], t[4, 5], t[3, 6], t[2, 7], > t[1, 8], t[2, 8], t[3, 7], t[4, 6], t[5, 5], t[6, 4], t[7, 3], > t[8, 2], t[8, 3], t[7, 4], t[6, 5], t[5, 6], t[4, 7], t[3, 8], > t[4, 8], t[5, 7], t[6, 6], t[7, 5], t[8, 4], t[8, 5], t[7, 6], > t[6, 7], t[5, 8], t[6, 8], t[7, 7], t[8, 6], t[8, 7], t[7, 8], > t[8, 8]} or this: Clear[bounce, next] > bounce[{x_, 9}] := {x + 2, 8} > bounce[{9, y_}] := {8, y + 2} > bounce[{x_, 0}] := {x, 1} > bounce[{0, y_}] := {1, y} > bounce[{x_, y_}] := {x, y} > next[{x_, y_}] := > next[{x, y}] = bounce@If[OddQ[x + y], {x - 1, y + 1}, {x + 1, y - 1}] Clear[zigzag, t] > zigzag[t_] = t @@@ NestList[next, {1, 1}, 8*8 - 1] I've switched x and y so that x is horizontal and y is vertical. Bobby >> I'm trying to rearrange 8 x 8 matrix of numbers in ZigZag manner (as it >> is >> used in JPEG comprimation algorithm http://en.wikipedia.org/wiki/Jpeg). >> I have created function which does it without problems, but it does it >> by >> hand and it seems to me, that it could be done by some more elegant >> algorithm. >> Does somebody have any idea, how to do it more elegantly? >> My attempt: >> zigzag[t_] := { >> t[[1, 1]], >> t[[1, 2]], t[[2, 1]], >> t[[3, 1]], t[[2, 2]], t[[1, 3]], >> t[[1, 4]], t[[2, 3]], t[[3, 2]], t[[4, 1]], >> t[[5, 1]], t[[4, 2]], t[[3, 3]], t[[2, 4]], t[[1, 5]], >> t[[1, 6]], t[[2, 5]], t[[3, 4]], t[[4, 3]], t[[5, 2]], t[[6, 1]], >> t[[7, 1]], t[[6, 2]], t[[5, 3]], t[[4, 4]], t[[3, 5]], t[[2, 6]], >> t[[1, 7]], >> t[[1, 8]], t[[2, 7]], t[[3, 6]], t[[4, 5]], t[[5, 4]], t[[6, 3]], >> t[[7, 2]], t[[8, 1]], >> t[[8, 2]], t[[7, 3]], t[[6, 4]], t[[5, 5]], t[[4, 6]], t[[3, 7]], >> t[[2, 8]], >> t[[3, 8]], t[[4, 7]], t[[5, 6]], t[[6, 5]], t[[7, 4]], t[[8, 3]], >> t[[8, 4]], t[[7, 5]], t[[6, 6]], t[[5, 7]], t[[4, 8]], >> t[[5, 8]], t[[6, 7]], t[[7, 6]], t[[8, 5]], >> t[[8, 6]], t[[7, 7]], t[[6, 8]], >> t[[7, 8]], t[[8, 7]], >> t[[8, 8]]}; >> Jakub > -- DrMajorBob@bigfoot.com === Subject: Mathematica crashed -- where did my notebook go? Mathematica just crashed on me in the middle of writing a program, and of course everything I had done is gone. Is there any temporary file or anything still left on the disk that contains anything of what I was working on at the time of the crash? I tried to do a bit of investigating, but could not see any open files that exist while working on a new notebook, so where does Mathematica put everything I type into a notebook until I save it? If it doesn't write anything to a file - why not? My gosh, this happens often enough to people all over the world, that I would think that Wolfram would have some sort of recovery mechanism built in, but I haven't found anything so far. How many times have customers asked for something like this? How many people think the same thing when this happens? My guess is a quite a few. So Wolfram -- add this to your list of things to put in the next version -- your customers would truly appreciate not having to recreate that program they had been working on for a couple of hours when the crash occurred and they very quickly tell themselves -- Oh CRVPPPPP!!! WHY DIDN'T I SAVE THAT FILE!!!!! Anything would be better than nothing -- why not use the disk to write the new notebook contents to while it's being developed. Yes I should have known that a crash was imminent, but my crystal ball is in the shop getting a new LED display installed ;-) If this has happened to you and you wished that Wolfram had some sort of recovery mechanism, please add your 2 cents to this post and let Wolfram know how important, we the customers, think this is (or isn't). -Bob ps -- this was on a Mac OS X 10.5.6 system with Mathematica version 7.0.1 if it matters === Subject: Re: A very large output was generated. Here is a sample of it: > Hi there, I've recently upgraded to Mathematica 7.0. I find the box > A very large output was generated. Here is a sample of it: > quite annoying. I would like to copy and paste the output into a different Mathematica > notebook. > So I have to click on Show Full Output which takes ages to generate. Is there a default setting where I can force Mathematica to always > give the > Full Output rather than this annoying A very large output... box? > In the Preferences dialog (Edit->Preferences on Windows/X, or Preferences under the application menu on Mac), look in the Evaluation tab for the Maximum output size before truncation field. You can set the value to 'Infinity' to completely disable the truncation. John Fultz jfultz@wolfram.com User Interface Group Wolfram Research, Inc. === Subject: Projection of curley 3D curves to represent a cylindrical surface Hi: I have the following plot in 3D: Clear[T,pnt,M,g1,g2]; T[t_]:={t^2,t,1}; pnt={{{0,0,0},{1,0,0},{2,0,0}},{{0,1,0},{1,1,1}, {2,1,-0.5}},{{0,2,0},{1,2,0},{2,2,0}}}; M={{2,-4,2},{-3,4,-1},{1,0,0}}; pts=Graphics3D[{AbsolutePointSize[5], Table[Point[pnt[[i,j]]],{i,1,3},{j,1,3}]}]; comb[i_]:=(T[u].M.pnt)[[i]] (Transpose[M].T[w])[[i]]; surf=ParametricPlot3D[comb[1]+comb[2]+comb[3],{u,0,1},{w,0,1}, Mesh->False,BoundaryStyle->Directive[Magenta,Thickness[0.005]], PlotPoints->100,RegionFunction->(1/16+1/32 Sin[10 ArcTan[#4-1/2,#5-1/2]] <(#4-1/2)^2+(#5-1/2)^2<1/8+1/32 Sin[10 ArcTan[#4-1/2, #5-1/2]]&), Axes->True]//Quiet; pic1=Show[surf,ViewPoint->{0,0,2},BaseStyle->{10,FontFamily->cmr10}, AxesLabel->{x,y,z},ImageSize->500] I'd like to project the magenta colored curves from their z coordinate positions down to the x-y=0 plane, creating cylindrical walls that match the curves. Perhaps the plot and code that I've given above can be converted to 3D Graphics,and the function Scale could be used to do this. I've tried to do this but haven't had any success. However, I'm not sure that this is the right approach. As an end result, I'd like to show the above plot with the cylindrical surfaces in one 3D plot. Suggestions and Mathematica 6.0.1 code would be greatly appreciated. Bill === Subject: Re: Projection of curley 3D curves to represent a cylindrical surface Hi Bill, this gets a bit complicated because you have the bounding curves only implicitly. Therefore, we first make a contour plot to get the implicite curve. Then we extract the actual lines from the resulting graphics. Then we change the lines to rectangles giving the walls of the cylindrical object we are searching: Clear[T, pnt, M, g1, g2]; T[t_] := {t^2, t, 1}; pnt = {{{0, 0, 0}, {1, 0, 0}, {2, 0, 0}}, {{0, 1, 0}, {1, 1, 1}, {2, 1, -0.5}}, {{0, 2, 0}, {1, 2, 0}, {2, 2, 0}}}; M = {{2, -4, 2}, {-3, 4, -1}, {1, 0, 0}}; pts = Graphics3D[{AbsolutePointSize[5], Table[Point[pnt[[i, j]]], {i, 1, 3}, {j, 1, 3}]}]; comb[i_] := (T[u].M.pnt)[[i]] (Transpose[M].T[w])[[i]]; surf = ParametricPlot3D[ comb[1] + comb[2] + comb[3], {u, 0, 1}, {w, 0, 1}, Mesh -> False, BoundaryStyle -> Directive[Magenta, Thickness[0.005]], PlotPoints -> 100, RegionFunction -> (1/16 + 1/32 Sin[ 10 ArcTan[#4 - 1/2, #5 - 1/2]] < (#4 - 1/2)^2 + (#5 - 1/2)^2 < 1/8 + 1/32 Sin[10 ArcTan[#4 - 1/2, #5 - 1/2]] &), Axes -> True] // Quiet; t1 = ContourPlot[ Evaluate[{(1/16 + 1/32 Sin[ 10 ArcTan[#1 - 1/2, #2 - 1/2]] == (#1 - 1/2)^2 + (#2 - 1/2)^2 ), (#1 - 1/2)^2 + (#2 - 1/2)^2 == 1/8 + 1/32 Sin[10 ArcTan[#1 - 1/2, #2 - 1/2]]} &[u, w]], {u, 0, 1}, {w, 0, 1}]; t1 = Cases[t // Normal, Line[___], Infinity]; t1 = t1 /. {u_?NumericQ, w_?NumericQ} -> (comb[1] + comb[2] + comb[3]) ; t1 = t1 /. Line[x_] :> {EdgeForm[], Partition[Riffle[x, RotateLeft[x]], 2]}; t1 = t1 /. {{x1_, x2_, x3_}, {y1_, y2_, y3_}} -> Polygon[{{x1, x2, x3}, {y1, y2, y3}, {y1, y2, 0}, {x1, x2, 0}}]; cyl = Graphics3D[t1]; pic1 = Show[{surf, cyl}, ViewPoint -> {0, 0, 2}, BaseStyle -> {10, FontFamily -> cmr10}, AxesLabel -> {x, y, z}, ImageSize -> 500] > Hi: I have the following plot in 3D: Clear[T,pnt,M,g1,g2]; > T[t_]:={t^2,t,1}; > pnt={{{0,0,0},{1,0,0},{2,0,0}},{{0,1,0},{1,1,1}, > {2,1,-0.5}},{{0,2,0},{1,2,0},{2,2,0}}}; > M={{2,-4,2},{-3,4,-1},{1,0,0}}; > pts=Graphics3D[{AbsolutePointSize[5], > Table[Point[pnt[[i,j]]],{i,1,3},{j,1,3}]}]; > comb[i_]:=(T[u].M.pnt)[[i]] (Transpose[M].T[w])[[i]]; > surf=ParametricPlot3D[comb[1]+comb[2]+comb[3],{u,0,1},{w,0,1}, > Mesh->False,BoundaryStyle->Directive[Magenta,Thickness[0.005]], > PlotPoints->100,RegionFunction->(1/16+1/32 Sin[10 > ArcTan[#4-1/2,#5-1/2]] > <(#4-1/2)^2+(#5-1/2)^2<1/8+1/32 Sin[10 ArcTan[#4-1/2, > #5-1/2]]&), > Axes->True]//Quiet; > pic1=Show[surf,ViewPoint->{0,0,2},BaseStyle->{10,FontFamily->cmr10}, > AxesLabel->{x,y,z},ImageSize->500] I'd like to project the magenta colored curves from their z coordinate positions down to the x-y=0 plane, creating cylindrical walls that match the curves. Perhaps the plot and code that I've given above can be converted to 3D Graphics,and the function Scale could be used to do this. I've tried to do this but haven't had any success. However, I'm not sure that this is the right approach. As an end result, I'd like to show the above plot with the cylindrical surfaces in one 3D plot. Suggestions and Mathematica 6.0.1 code would be greatly appreciated. Bill > === Subject: Manipulate problems again Hello group, I'm having problems with this... ClearAll[Global`*] Manipulate[ { anpsol := NDSolve[{a''[t] == -k1 k2 a[t] - k1 a'[t] + k3 a'[t], a[0] == k2/k1, a'[0] == 0 }, {a[t], a'[t]}, {t, 0, 20}]; Plot[Evaluate[{a[t], a'[t]} /. anpsol], {t, 0, 20}, PlotRange -> All, FrameLabel -> {t, a and a'}, AspectRatio -> 1/GoldenRatio], ParametricPlot[Evaluate[{a[t], a'[t]} /. anpsol], {t, 0, 20}, PlotRange -> All, FrameLabel -> {a, a'}, AspectRatio -> 1/ GoldenRatio] }, {{k1, 0.1, 10}, {k2, 0.1, 10}, {k3,0.11, 10}, {b0, 0.1, 10}}] Sean === Subject: Re: Manipulate problems again Manipulate[ anpsol = NDSolve[{a''[t] == -k1 k2 a[t] - k1 a'[t] + k3 a'[t], a[0] == k2/k1, a'[0] == 0}, {a[t], a'[t]}, {t, 0, 20}]; GraphicsRow[{Plot[Evaluate[{a[t], a'[t]} /. anpsol], {t, 0, 20}, PlotRange -> All, FrameLabel -> {t, a and a'}, AspectRatio -> 1/GoldenRatio], ParametricPlot[Evaluate[{a[t], a'[t]} /. anpsol], {t, 0, 20}, PlotRange -> All, FrameLabel -> {a, a'}, AspectRatio -> 1/GoldenRatio]}], {k1, 0.1, 10}, {k2, 0.1, 10}, {k3, 0.11, 10}, {b0, 0.1, 10}] work fine. Jens > Hello group, I'm having problems with this... ClearAll[Global`*] Manipulate[ > { > anpsol := NDSolve[{a''[t] == -k1 k2 a[t] - k1 a'[t] + k3 a'[t], a[0] > == k2/k1, a'[0] == 0 }, {a[t], a'[t]}, {t, 0, 20}]; Plot[Evaluate[{a[t], a'[t]} /. anpsol], {t, 0, 20}, PlotRange -> All, > FrameLabel -> {t, a and a'}, AspectRatio -> 1/GoldenRatio], ParametricPlot[Evaluate[{a[t], a'[t]} /. anpsol], {t, 0, 20}, > PlotRange -> All, FrameLabel -> {a, a'}, AspectRatio -> 1/ > GoldenRatio] > }, > {{k1, 0.1, 10}, {k2, 0.1, 10}, {k3,0.11, 10}, {b0, 0.1, 10}}] Sean === Subject: Re: representing the dihedral group What about simplifying the canonical forms even more? (a*b)^m * a = r^(m+1)*s = s*r^mod(-m-1,n) = (b*a)^k * b for some k, and also (b*a)^m = s*r^(m+1)*s = r^mod(-m-1,n) = (a*b)^k for some k === Subject: Re: MaxValue Maximize[(-1)^n, n, Integers] Maximize[(-1)^n, n, Integers] and MaxValue[(-1)^n, n, Integers] MaxValue[(-1)^n, n, Integers] Utter failure. We know the answers but Mathematica, surprizingly, does not. Bobby > Suppose I want to find supremum of {(-1)^n: n is natural}, MaxValue > just returns the question itself. > if I ask it sup of (1+2)^n, it givs infinity, but max of (1-2)^n it > just returns the question itself. > FindMaximum and FindMinimum also can't handle (-1)^n...how can it be > done then? > -- DrMajorBob@bigfoot.com === Subject: Re: MaxValue > Suppose I want to find supremum of {(-1)^n: n is natural}, MaxValue > just returns the question itself. > [..] But something with NMinimize is not clicking for me: In[70]:= f[n_] := (-1)^n + (n + 1)/n; In[71]:= NMinimize[{f[n], Element[n, Integers] && n > 0}, n] Out[71]= {0.333333, {n -> 3}} In[72]:= f[999] Out[72]= 1/999 I tried playing with NMinimzie parameters, namely Method and MaxIterations(default is 100) and the various Precision's with no success; going the MaxValue way: In[81]:= MaxValue[Cos[Pi*n] + n + 1/n, n] Out[81]= MaxValue[1/n + n + Cos[n [Pi]], n] I am new to Mathematica, what is the preferred way to get sup/inf of f (N), (where f is the func above )? === Subject: Re: MaxValue > Suppose I want to find supremum of {(-1)^n: n is natural}, MaxValue > just returns the question itself. > [...] MaxValue...and the numerical solutions work as well. However, is there anything in Mathematica internals that prevents MaxValue from dealing with (-x)? The solutions I've got are all work-arounds. === Subject: Re: MatrixPlot with color range bar Good luck with that. Bobby > I tried your code. The plot looks very nice. > Although it's very nice, i expect more simple method to be included in > the next version of Mathematica. 2009/4/25 David Park My suggestion: data = Table[Cos[x y/150.], {x, -50, 50}, {y, -50, 50}]; matrixplot = > MatrixPlot[data, ColorFunction -> Rainbow]; legend = > DensityPlot[y, {x, 0, 1}, {y, -1, 1}, > ColorFunction -> (ColorData[Rainbow][Rescale[#, {-1, 1}]] &), > ColorFunctionScaling -> False, > PlotPoints -> 51, > AspectRatio -> Full, > PlotRange -> {{0, 1}, {-1, 1}}, > Background -> None, > Frame -> True, > FrameTicks -> {{None, Range[-1, 1, .25]}, {None, None}}, > ImagePadding -> {{2, 30}, {5, 5}}, > ImageSize -> {50, 400}]; > Graphics[ > {Inset[matrixplot, {4, 4.3}, {Center, Center}, {400, 450} 0.02], > Inset[legend, {8.8, 4.2}, {Center, Center}, {5, 40} 0.17], > Text[Style[Matrix Plot with Legend, Large], {5, 9.3}], > Text[Style[Legend, 14, Bold], {8.5, 8.0}]}, > PlotRange -> {{0, 10}, {0, 10}}, > Frame -> False, > ImageSize -> 500] > David Park > djmpark@comcast.net > http://home.comcast.net/~djmpark/ I'd like to draw plots like > http://www.gle-graphics.org/examples/3dplots/informationgain.png > I know that MatrixPlot function draws such plots. > My question is how to draw color range bar like that on the right side of > the plot at the url. > Is there any options of MatrixPlot or tricks to draw such color range > bar ? > -- DrMajorBob@bigfoot.com === Subject: Re: ContourPlot, equation and R.H. side of equation_Plotting Bill === Subject: Re: MaxValue Round about way (-1)^n // ComplexExpand Cos[Pi*n] + I*Sin[Pi*n] Simplify[(-1)^n == Cos[n*Pi], Element[n, Integers]] True MaxValue[Cos[n*Pi], n] 1 Bob Hanlon Suppose I want to find supremum of {(-1)^n: n is natural}, MaxValue just returns the question itself. if I ask it sup of (1+2)^n, it givs infinity, but max of (1-2)^n it just returns the question itself. FindMaximum and FindMinimum also can't handle (-1)^n...how can it be done then? === Subject: Re: A very large output was generated. Here is a sample > Hi there, > I've recently upgraded to Mathematica 7.0. I find the box > A very large output was generated. Here is a sample of it: > quite annoying. I would like to copy and paste the output into a different Mathematica > notebook. > So I have to click on Show Full Output which takes ages to generate. Is there a default setting where I can force Mathematica to always > give the > Full Output rather than this annoying A very large output... box? > Have a look at OutputSizeLimit and $OutputSizeLimit. You could try setting to Infinity. But...there is a very good chance this will not help at all to speed up the process. Reason being, if clicking Show Full Output then takes a long time, it is almost certainly because it in fact takes time to typeset or for other reasons to print the output in question. Hence automatically showing full output will still be slow; all it will save you in time is that checkbox click. This automatic output truncation behavior was introduced in version 6. Many people, including myself, are quite happy to have it. Saves endless time in outputting garbage, in situations where a typo or other user error would cause a huge result. Such a feature had been frequently requested prior to version 6. Daniel Lichtblau Wolfram Research === Subject: Re: A very large output was generated. Here is a sample of it: Hi Cora, Actually, I consider this to be a life saver. It is pretty easy to generate expressions by accidinnt that will cause a few thousands of pages to be printed in a notebook. This has happened a lot to me and generally causes lots of problems. If the notebooks share the same context you could assign the output to a common global variable. Otherwise assign it to a variable, use DumpSave in the first notebook to save the variable and read it in in the second notebook using <<. I would advise against switching off this 'large output' behaviour, but if you insist you can set $OutputSizeLimit to a higher value. > Hi there, > I've recently upgraded to Mathematica 7.0. I find the box > A very large output was generated. Here is a sample of it: > quite annoying. I would like to copy and paste the output into a different Mathematica > notebook. > So I have to click on Show Full Output which takes ages to generate. Is there a default setting where I can force Mathematica to always > give the > Full Output rather than this annoying A very large output... box? > === Subject: Re: A very large output was generated. Here is a sample of it: > Hi there, > I've recently upgraded to Mathematica 7.0. I find the box > A very large output was generated. Here is a sample of it: > quite annoying. I would like to copy and paste the output into a different Mathematica > notebook. > So I have to click on Show Full Output which takes ages to generate. Is there a default setting where I can force Mathematica to always > give the > Full Output rather than this annoying A very large output... box? > The $OutputSizeLimit option tells you the current limit - by default it is 1,048,576 bytes. $OutputSizeLimit can be set via SetOptions like (if you wanted a 10 meg limit for the current notebook) SetOptions[EvaluationNotebook[], OutputSizeLimit -> 10000000] or you can also set OutputSizeLimit in Options Inspector (in the Global Preferences) to Infinity or a specific number. You might want to set it to something big enough to handle what you want rather than infinity since that would fill up your entire disk and take forever. -Bob === Subject: Re: A very large output was generated. Here is a sample of it: > Hi there, > I've recently upgraded to Mathematica 7.0. I find the box > A very large output was generated. Here is a sample of it: > quite annoying. I would like to copy and paste the output into a different Mathematica > notebook. > So I have to click on Show Full Output which takes ages to generate. Is there a default setting where I can force Mathematica to always > give the > Full Output rather than this annoying A very large output... box? Most us find that message extremely useful! Before that mechanism was introduced, if you accidentally sent a vector of 10^7 elements to the FE, it was very hard to recover at all. All you had to do was accidentally omit one semicolon. There are almost certainly better ways to do what you are trying to do - for example, how about exporting your data in a suitable format, and importing it into the other notebook? Why not describe what you are trying to do in more detail. David Bailey http://www.dbaileyconsultancy.co.uk === Subject: Re: A very large output was generated. Here is a sample of it: > I've recently upgraded to Mathematica 7.0. I find the box > A very large output was generated. Here is a sample of it: > quite annoying. I would like to copy and paste the output into a different Mathematica > notebook. > So I have to click on Show Full Output which takes ages to generate. Is there a default setting where I can force Mathematica to always > give the > Full Output rather than this annoying A very large output... box? the fact that huge output will take ages to render (and sometime fails completley) is the reason why you see this box. If you would render it directly, it would take just as long, but you wouldn't have the choice to not see it. Since I have crashed older versions often just by forgetting an ; I think the new behavior is a huge improvement. If you want to reuse large output I would never do that via copy and paste from notebook to notebook, but rather use Put and Get to write the output to an extra file so you would never have to look at that large output and never have to wait for the FE to render that junk. ...and no, I don't know whether you can change the settings and I wouldn't recommend to do that even if it was possible... hth, albert === Subject: Re: A very large output was generated. Here is a sample of it: with this default setting every of your output take ages to generate. Got to the Edit|Preferences dialog and to the Evaluation-Tab there you can find a Maximum output size before truncation Change that value for your needs. Jens > Hi there, > I've recently upgraded to Mathematica 7.0. I find the box > A very large output was generated. Here is a sample of it: > quite annoying. I would like to copy and paste the output into a different Mathematica > notebook. > So I have to click on Show Full Output which takes ages to generate. Is there a default setting where I can force Mathematica to always > give the > Full Output rather than this annoying A very large output... box? === Subject: ListPlot ColorFunction first let me thank you for many nice zigzag solutions from my previous post. Today I have another question. I need to highlight some data points in ListPlot by changing their color. How to do it? I tried the similar solution which somebody have sent me time ago for the same problem which I had with Plot, but it doesn't work with ListPlot. In the example below I'm trying to make the zero points Red and all other Blue. ListPlot[{9, 4, 1, 0, 0, 0, 1, 4, 9}, Filling -> Axis, PlotStyle -> PointSize[0.02], ColorFunction -> (If[# == 0, RGBColor[1, 0, 0], RGBColor[0, 0, 1]] &)] Jakub === Subject: combine tabled graphics Hello Group, Suppose you have generated 2 graphics from Table[blah blah]. And now I want to combine the tabled graphics into a grid or row. Each Tabled graphics shows multiple graphs of expression evaliuated at different values of the parameters. Both GraphicsRow and GraphicsGrid will get rid of the tabling effect. For example, following occurs when I use them... gmn1 = Table[{Plot[ 1/2 (-k1 - k1 - Sqrt[k1^2 - 6 k2 k1 + k2^2]), {k1, 0, 30}, PlotRange -> All, FrameLabel -> {k1, l1}]}, {k2, 0, 10}]; gmn2 = Table[{Plot[ 1/2 (-k1 - k2 + Sqrt[k1^2 - 6 k2 k1 + k2^2]), {k1, 0, 30}, PlotRange -> All, FrameLabel -> {Subscript[k, 1], l2}]}, {k2, 0, 10}]; GraphicsGrid[{gmn1, gmn2}] GraphicsRow[{gmn1, gmn2}] How will I accomplish this? Sean === Subject: Re: Copy/paste selection of a pdf on Mac > In Apple Preview.app, Leopard (10.5), the menu View:PDf Display: has two > options, 'Media Box' and 'Crop Box'. If one selects and copies a portion of > a pdf and creates in Preview a new pdf from the clipboard, then View Crop > Box shows the selected part only while View Media Box shows the whole page. > It means that applications such as Apple Pages and Keynote (and also > TexShop) show the pasted portion of the pdf in Crop view, while Mathematica > shows the whole pasted pdf page, ie the 'Media view'. A.B. I think this has more to do with Apple than Mathematica: - Select a portion of a pdf file in Preview.app and copy to the clipboard, > - Paste in Mathematica. This results in the whole pdf page being pasted in Mathematica. Researching on > the web showed that this same behaviour was observed with Keynote at some > point but it has since been fixed. > It has to do with a new so-called non-destructive way that Preview now uses > for cropping. The application where the pasting is done needs to be made aware > of this change on the part of Apple. Thus, on my 10.5.6 system, pasting works > well with Pages and Keynote (iWork 9). > A workaround is to paste in one of these applications, copy the pdf image and > paste it in Mathematica. This works as expected. A.B. the problem is that the CropBox is being ignored by Mathematica. Perhaps the easiest workaround for this issue is to replace Preview with the free PDF reader and annotation application Skim (http://skim- app.sourceforge.net/). Copying from Skim to Mathematica works fine because it puts the crop information into the MediaBox dimensions. Another possibility, if you want to keep using Preview (e.g., because it's more versatile with non-PDF formats), would be based on a script earlier versions of Keynote. I now slightly modified my script to change the MediaBox as required by Mathematica, and I've posted it as an AppleScript bundle in the file clipPDF-noGS-1.2.zip which can be downloaded at http://www.uoregon.edu/~noeckel/PreviewLeopard.html#nogsMediaBox You would then copy a selection in Preview as usual, but before pasting into Mathematica invoke this script from the script menu bar. It directly modifies the current PDF clipboard contents, so that only cropped part of the PDF appears when you subsequently paste into Mathematica. To install this script, just follow the instructions in the accompanying README file (there's no need for any additional downloads). Jens === Subject: Re: issues with GraphPlot Where would the Inset line go? On Apr 25, 10:39 pm, Sjoerd C. de Vries do. Insert something like Inset[Text[#3], Mean[#1]] in what you > already have. Hello group, A few things that I just can't figure out. 1. EdgeRenderingFunction ignores edge labels. GraphPlot[{{B -> A , +}, {A -> B, +}}, > DirectedEdges -> True, VertexLabeling -> True, > VertexRenderingFunction -> ({White, EdgeForm[Black], Disk[#, .05], > Black, Text[#2, #1]} &), EdgeLabeling -> True, > EdgeRenderingFunction -> ({ Arrowheads[Medium], > Arrow[#1 , 0.07]} &), PlotStyle -> Thickness[0.005]] 2. As it is, above code produces a graph that is stretched > horizontally a bit too much. About the half the horizontal width works > better for me. How do I accomplish that? AspectRatio-> 1/GoldenRatio > doesn't work since disk gets stretch also. 3. For node A to appear on the left, B-> A has to be defined > first. If I reverse it, then the node B will appear on the left. What > is the reason for this? > Sean === Subject: Re: issues with GraphPlot Hi Sean, to get an narrower picture you ,may use ImageSize. But as this simply makes the picture smaller, you need to adapt the circle size and arrows. E.g.: GraphPlot[{{B -> A, +}, {A -> B, +}}, DirectedEdges -> True, VertexLabeling -> True, VertexRenderingFunction -> ({White, EdgeForm[Black], Disk[#, .1], Black, Text[#2, #1]} &), EdgeLabeling -> True, EdgeRenderingFunction -> ({Arrowheads[Medium], Arrow[#1, 0.12]} &), PlotStyle -> Thickness[0.005], ImageSize -> 200 ] Daniel > Hello group, A few things that I just can't figure out. 1. EdgeRenderingFunction ignores edge labels. GraphPlot[{{B -> A , +}, {A -> B, +}}, > DirectedEdges -> True, VertexLabeling -> True, > VertexRenderingFunction -> ({White, EdgeForm[Black], Disk[#, .05], > Black, Text[#2, #1]} &), EdgeLabeling -> True, > EdgeRenderingFunction -> ({ Arrowheads[Medium], > Arrow[#1 , 0.07]} &), PlotStyle -> Thickness[0.005]] 2. As it is, above code produces a graph that is stretched > horizontally a bit too much. About the half the horizontal width works > better for me. How do I accomplish that? AspectRatio-> 1/GoldenRatio > doesn't work since disk gets stretch also. 3. For node A to appear on the left, B-> A has to be defined > first. If I reverse it, then the node B will appear on the left. What > is the reason for this? > Sean > === Subject: Bug in Mathematica 7.0? Hello Mathematica-Experts, I'm using Mathematica 7.0 on a Windows XP machine and might have come across a bug in Mathematica 7.0. I define the following function as a product of Gamma functions: A[M_, r_] := Product[Gamma[M + j]*Gamma[1/2 + j]*Gamma[r + 1/2 + j]/ Gamma[r + M + j], {j, 0, M - 1}] To allow non-integer values M we re-write the above expression in terms of the Barnes G-function and so we obtain (we've checked the algebra many times!): B[M_, r_] := BarnesG[2 + M]/BarnesG[2]*BarnesG[1/2 + M]/BarnesG[1/2] *BarnesG[r + 1/2 + M]/ BarnesG[r + 1/2]*BarnesG[r + M]/BarnesG[r + 2*M] As a test I've chosen M = 2 and r = 1 and indeed I obtain A[2, 1] = Pi^2/32 and B[2, 1] = Pi^2/32 and so agreement in both functions. But choosing M = 3 and r = 1 gives A[3, 1] = 9*Pi^3/2048 B[3, 1] = 3^Pi^3/16384 So two different values for A[3, 1] and B[3, 1]. Also A[3, 0] and B[3, 0] would give different answers - and there are many other examples. Do you have any thoughts on what went wrong? Cheerio! === Subject: Re: Is this solvable using Mathematica? this system of equations is under determined. You have a second order DEQ in a, what needs 2 equation and 1 first order DEQ in b, what needs another equation. Therefore, you will need 3 equations. Daniel > Supposed you want to define a second order derivative along with your > ODEs. (So you can scale the second order term) Example shown below. k1 = 1; > r1 = 1; > NDSolve[{a'[t] == k1 b[t] - d, a''[t] == r1 b'[t], a'[0] == 0, a[0] == > 1, b[0] == 0}, {a[t], b[t]}, {t, 1, 10} ] But I get an error. NDSolve::ntdvmm: > Cannot solve to find an explicit formula for the derivatives. NDSolve > will try solving the system using a mass matrix method. NDSolve::ndnum: Encountered non-numerical value for a derivative at t > == 0.`. Maybe this is more of a math question than software. But I would be > very interested in seeing if it's doable in Mathematica. > === Subject: Buttons to interactively restart/finish a program I am writing a simple interactive teaching program to teach my child arithmetics. Here is a simplified example on addition from 1 to 4: Panel[DynamicModule[{a, b}, Clear[a, b, f]; a = RandomInteger[{1, 4}]; b = RandomInteger[{1, 4 - a}]; f = ?; g1 := (Clear[f]; f = a + b); g2 := (Clear[f]; f = ?); Column[{ Row[{ Dynamic@Button[Style[1, 30], If[a + b == 1, g1, g2]], Dynamic@Button[Style[2, 30], If[a + b == 2, g1, g2]], Dynamic@Button[Style[3, 30], If[a + b == 3, g1, g2]], Dynamic@Button[Style[4, 30], If[a + b == 4, g1, g2]] }], Panel[Row[{Text[Style[a, 50]], Text[Style[+, 50]], Text[Style[b, 50]], Text[Style[=, 50]], Text[Style[Dynamic[f], 50]]}]] }] ] ] In this program however, one needs to manually re-execute the program (e.g. via Shift+Enter) each time one wants to have a new execise. In order to avoid the manual restarting in addition to the above code I would like to include two buttons. First should restart the program, so that the task is renewed. The second button should close the panel when the game is finished. Thus, the program may be executed only once before the game starts. My idea to add a restart button the way shown below did not work: Label[aa]; Panel[DynamicModule[{a, b}, Clear[a, b, f]; a = RandomInteger[{1, 4}]; b = RandomInteger[{1, 4 - a}]; f = ?; g1 := (Clear[f]; f = a + b); g2 := (Clear[f]; f = ?); Column[{ Row[{ Dynamic@Button[Style[1, 30], If[a + b == 1, g1, g2]], Dynamic@Button[Style[2, 30], If[a + b == 2, g1, g2]], Dynamic@Button[Style[3, 30], If[a + b == 3, g1, g2]], Dynamic@Button[Style[4, 30], If[a + b == 4, g1, g2]] }], Panel[Row[{Text[Style[a, 50]], Text[Style[+, 50]], Text[Style[b, 50]], Text[Style[=, 50]], Text[Style[Dynamic[f], 50]]}]], Button[Restart, Goto[aa]] }] ] ] Could anybody give me an idea? 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: Selecting left hand sides from assignments Hi again, The following works as I wanted: it takes apart *lhs* and *rhs* of *Set* expressions while keeping the relation between the *lhs* to the *rhs* for further use. But, to get it to work one has to start working with a fresh kernel as to ensure the *lhs*(s) have not been assigned any value before the sequence of assignments *assign* is sent to the function *SplitSetSides*. However, since I am to use it as a meta-programming tool (not to be include in end user programs) this is not a big drawback, though a bit artificial. The first sublist in *Out[4]* contains the *lhs*(s) while the second contains the *rhs*(s). In[1]:= Clear@frhs frhs[rhs_][symbols_] := Module[{step}, step = Fold[Flatten[#1, Infinity, #2] &, rhs, symbols]; step = Union@Flatten@FixedPoint[Apply[List, #, Infinity] &, step]; step = List @@ step; ] In[2]:= Clear@SplitSetSides SplitSetSides[holdassignments_] := Quiet@Module[{symbols = Symbol[#] & /@ Names[System`*]}, {SymbolName[#] & /@ (List @@ Map[First, Map[Unevaluated, holdassignments]]), frhs[#][symbols] & /@ Apply[List, Map[Hold, holdassignments, {1}]]}] In[3]:= assign = Hold[a1 = Log[b1*c1^12], a2 = Sqrt[b2*c2], a3 = Log[b1*c1^12]*Sqrt[a2*c2]^b3*c3 ]; In[4]:= SplitSetSides[assign] Out[4]= {{a1, a2, a3}, {{a1, b1, c1}, {a2, b2, c2}, {a3, c3, b1, c1, a2, c2, b3}}} For now, this solution seems to be good enough for my needs. For instance, it will help me in building the data dependency graph for a large notebook meant to make dense computations involving many dynamic interrelated objects. The simplification of the data dependency graph helps in improving efficiency by eliminating superfluous or redundant computation paths which would slow down significantly the performance. Also would help in pointing out circularities. And, although it needs some additional testing it seems to be working ok under my conditions. One thing which is still left (among many others) is to take out the names in *symbols* which do not correspond to true symbols (operators) in the list generated by the expression *symbols = Symbol[#] & /@ Names[System`*]*} in the module of the function *SplitSetSides*. Any feed back will be appreciated. I hope it will be of any use to someone else. E. Martin-Serrano ------------------------------------------------------------ >I need help on the following. >assignmentslist = {LHS1 = RHS1, LHS2 = RHS2, LHS3 = RHS3, ..., LHSi = RHSi, ..., LHSn = RSHn} >I need to extract all the left hand sides (symbols) within a list like: >lhslist = {LHS, LHS2, LHS3, ..., LHSi, ..., LHSn} >Where the left hand sides are all symbols and the right hand sides are any expression. >E. Martin-Serrano ------------------------------------------- === Subject: Re: What's going on here (Table-generated lists)? It is because Plot has the Attribute HoldAll. It sees only one argument so it uses only one color. (But this is something of a feature!) The following works because the first argument is evaluated before the Plot algorithm goes into action. Plot[Evaluate@Table[k x, {k, 1, 5}], {x, -1, 1}] Or data = Table[k x, {k, 1, 5}] {x, 2 x, 3 x, 4 x, 5 x} Plot[data, {x, -1, 1}] But the following does not work because the Table is not evaluated first. data := Table[k x, {k, 1, 5}] Plot[data, {x, -1, 1}] David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ I'm seeing a difference in behavior with Plot in conjunction with Table, and I'm rather confused at the reason. If I use Plot to plot a list of functions, it works as expected, and I get a plot with each function in its own color: Plot[{x, 2 x, 3 x, 4 x, 5 x}, {x, -1, 1}] If I use Table, then this doesn't work the same way -- the five lines are all plotted with the same color: Plot[Table[k x, {k, 1, 5}], {x, -1, 1}] I verified that the both objects created have a Head of List, so I don't see anything obviously different about them. Here's what confuses me more: If I generate the table separately and then use that as a result in a later evaluation in the Plot, then I get the colors back: In[25]:= Table[k x, {k, 1, 5}] Out[25]= {x, 2 x, 3 x, 4 x, 5 x} In[26]:= Plot[%, {x, -1, 1}] What is going on here? Is it something like Plot does a special scan of its first argument before Evaluating it, and if it doesn't start out as a List, it concludes that it's all one thing and plots it with the same color, as opposed to an explicitly provided list of separate colors? -- Erik Max Francis && max@alcyone.com && http://www.alcyone.com/max/ San Jose, CA, USA && 37 18 N 121 57 W && AIM, Y!M erikmaxfrancis In this world, nothing is certain but death and taxes. -- Benjamin Franklin === Subject: Re: UNDO and Mathematica - how useless is it? I think that some, at least, of the important WRI developers do take notice of what is on MathGroup. So give detail and make a good case and I think they will consider it. They may not necessarily do it because it may be difficult, but there are a number of changes I've seen that did appear to come from MathGroup complaints and suggestions. David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ Totally agree! Another feature that i expected in 7 but it didn't show up was window tabs, it would be great to have multiple notepads opened without having to minimize/maximize windows all the time... Hope to see both in 8! Is there a way to discuss with developers about fatures/bugs? Filippo === Subject: Re: Read data structure from binary file if the file does not contain any information about the structure, it can be interpreted in many ways. Therefore, you have to specify the structure. Note that you may assemble the list of structures definition automatically, using e.b. Table, Append, Join... Daniel > I have a binary file which I would like to read into a data structure. > The data structure contains some simple data types like Integer16 and Integer32, but also a byte array of length 255. How can I read this byte array into mathematica along with the other data types as a complete data structure, without having to use BinaryReadList(file, {Integer32, Byte, Byte, Byte, Byte, Byte, ..., Byte, Integer16}) ? === Subject: Re: Read data structure from binary file > I have a binary file which I would like to read into a data structure. > The data structure contains some simple data types like Integer16 and Int= eger32, but also a byte array of length 255. How can I read this byte array into mathematica along with the other data= types as a complete data structure, without having to use BinaryReadList(f= ile, {Integer32, Byte, Byte, Byte, Byte, Byte, ..., Byte, In= teger16}) ? > Join[{Integer32}, Table[Byte, {255}], {Integer16}] -Rob === Subject: Re: coefficients but not from polynomial (variables does not work) Cases[Sin[x] + Sin[y], _Symbol, Infinity] may help. Jens Probably my question is very simple. Suppose that we have expression > a= Sin[x]+Sin[y]. I would like receive variables from which this > expression is dependent, so in this case {x,y}. The Variables does not > work of course in this because it is not a polynomial and it gives me > {Sin[x],Sin[y]}. Do anyone know how to solve my problem. I would be very grateful for quick response. Magdalena > === Subject: Re: coefficients but not from polynomial (variables does not work) Hi Magdalena, you may e.g. use Cases on the lowest level to pick out symbols. Union ensures that each variable appears only once: Union@Cases[Sin[x] + Sin[y], _Symbol, {-1}] hope this helps, Daniel Probably my question is very simple. Suppose that we have expression > a= Sin[x]+Sin[y]. I would like receive variables from which this > expression is dependent, so in this case {x,y}. The Variables does not > work of course in this because it is not a polynomial and it gives me > {Sin[x],Sin[y]}. Do anyone know how to solve my problem. I would be very grateful for quick response. Magdalena > === Subject: Re: animation in version 7.0 looks bad what is with [Psi][x_, t_] := Exp[-(x - t)^2/(2 (1 + t))]/Sqrt[1 + t]; Manipulate[ Plot[[Psi][x, t], {x, -2, 10}, AxesLabel -> {x, }, Ticks -> False, PlotLabel -> t = <> ToString[t], PlotRange -> {0, 1}], {{t, 0}, 0., 10., Appearance -> Open}] and than click the black |> symbol Jens > Folks -- maybe its just my old mac ( a G4 967 MHz) but animations > just don't look very good when using Animate or ListAnimate in > Mathematica Version 7.0.1. This is particularly true if the plots in > the animation are at all complicated. The animations run rather > slowly and look jumpy. It works better if I use the old method of > grouping a series of plots and then doing apple-Y . An example is > given below -- two different modes of animation, one using ListAnmate > and the other producing the same plots that must then be animated by > hand using Animate Selected Graphics. On my machine the second > method looks much smoother and also runs faster. How do I get Animate and/or ListAnimate to give > better-looking output (besides going out and buying a new machine)? [Psi][x_, t_] = Exp[-(x - t)^2/(2 (1 + t))]/Sqrt[1 + t]; ListAnimate[ > Table[Plot[[Psi][x, t], {x, -2, 10}, AxesLabel -> {x, }, > Ticks -> False, > PlotLabel - t = < ToString[t], PlotRange -> {0, 1}], {t, 0., 10, 1}], > DisplayAllSteps -> True, AnimationRate -> 5]; > Do[Print[ > Plot[[Psi][x, t], {x, -2, 10}, AxesLabel -> {x, }, > Ticks -> False, > PlotLabel - t = < ToString[t], PlotRange -> {0, 1}]], {t, 0., 10, 1}] === Subject: Solve problem I have a Solve[...] which gives me solutions like {{b1 -> -2, a1 -> -1 }, {b1 -> 0.5, a1 -> 3}} or like {{a1 -> 1, b1 -> 3}} How can I get the positive value for a1, which is 3 in the first case and 1 in the second one? Bruno === Subject: Solve problem I have a Solve[...] which gives me solutions like {{b1 -> -2, a1 -> -1 }, {b1 -> 0.5, a1 -> 3}} or like {{a1 -> 1, b1 -> 3}} How can I get the positive value for a1, which is 3 in the first case and 1 in the second one? Bruno === Subject: pdf export problem Hello All- I have been having problems exporting notebooks to pdf and was hoping someone might have some insight. I submitted a support request to Wolfram, but have not heard back. Quick background: Mathematica 7.0.0; Macintosh Front End (OS X Leopard 10.5.6). Quick summary: I am writing handouts for distribution in a math/ stats class. Some characters disappear when converting to pdf. Example that has been vexing me lately is the less-than-or-equal-to sign (unicode character 2264, I think). I just get blank spaces in its place. My theories (obviously wrong or I wouldn't be here asking!): I thought it was a problem with font installations, but I have tried different fonts without success. I also have noted that the problem occurs when the cells are text style, but goes away if I make the cell equation style. I can't decide if there is a problem in the style definitions, a bug that improperly defines fonts (and/or misses embedding) into pdf, or something to do with high unicode characters. Apologies if my perusal of the archives has missed another discussion help. I thought such font problems were well in my past, but no such luck. David David Elbert Department of Earth and Planetary Sciences & Environmental Science and Policy Program Johns Hopkins University 3400 N. Charles St Baltimore, MD 21218 elbert@jhu.edu === Subject: Bug in SeriesCoefficient in 7.0 There is an expression to obtain the order Nk[n] of the hyperdeterminant of 2^n matrix (http://en.wikipedia.org/wiki/Hyperdeterminant): Sum[Nk[n] z^n/n!, {n, 0, Infinity}] == Exp[-2z]/(1-z)^2 I'm trying to expand right hand side of this equation to obtain Nk[n] values. First, look for several low-order coefficients: In[1] = Ser = Series[Exp[-2 z]/(1 - z)^2, {z, 0, 9}] Out[1] = 1 + z^2 + (2 z^3)/3 + z^4 + (16 z^5)/15 + (11 z^6)/9 + ( 142 z^7)/105 + (67 z^8)/45 + (4604 z^9)/2835 + O[z^10] Extract Nk[n]: In[2] = Table[n! Coefficient[Ser, z, n], {n, 0, 9}] Out[2] = {1, 0, 2, 4, 24, 128, 880, 6816, 60032, 589312} This is correct. Then I'm trying to get general expression for Nk[n]: In[3] = SeriesCoefficient[Exp[-2 z]/(1 - z)^2, {z, 0, n}] Out[3] = Piecewise[{{(3 + n)/E^2, n >= 0}}, 0] THIS IS ABSOLUTELY WRONG ANSWER. But the correct answer is given by Mathematica 6.0.1: In[1] (Math 6.0.1) = Nk6[n_] = SeriesCoefficient[Exp[-2 z]/(1 - z)^2, {z, 0, n}] Out[1] (Math 6.0.1) = ((2 + n) ((-1)^n 2^(2 + n) E^2 + (3 + n) Gamma[2 + n, -2]))/(E^2 Gamma[3 + n]) In[2] (Math 6.0.1) = Table[n! Nk6[n], {n, 0, 9}] // FunctionExpand Out[2] (Math 6.0.1) = {1, 0, 2, 4, 24, 128, 880, 6816, 60032, 589312} This is again the correct answer. Maxim A. Dubinnyi, Shemiakin-Ovchinnikov Institue of Bioorganic Chemistry, Moscow, Russia === Subject: Re: help^please The only way you could be faced with a requirement > like that, is as a > college exercise! If you get help to solve your > exercises, that will > leave you no more skilled than before - so there > would not be any point, > would there? > True, but there are enough exercises around. The problem is that i have no teacher so sometimes things get on my nerves so to speak :) Now with the answers; at least i have an idea. The solutions could contain something totally beyond my imagination and this is where teachers come into play but as i said . . . no instructor nor a college education. > David Bailey > http://www.dbaileyconsultancy.co.uk > === Subject: Re: Detecting CD driver availability Hi Ignacia, if I understand correctly, you want to test the existence of a directory. This can be done using: DirectoryQ. Daniel I want Mathematica check the DVD presence into the CD-ROM driver and > execute myFunction[] when it become available, so I try something like SetDirectory[NotebookDirectory[]]; > Off[SetDirectory::cdir]; > Print[Start]; > While[SetDirectory[d:] == $Failed, Pause[1]]; > Print[Stop]; but it's an unsuccessful trick, because it makes the Retry, Abort, > Continue message box rise, invoking the user's act, just exactly what I > want to avoid. Any way out? > Ignacio Plazeta > === Subject: Printout stylesheet in V7 on Linux I'm trying to use a custom stylesheet when printing notebooks. If I use the built-in Article stylesheet, everything looks fine on screen as well as on the printout. If I create a custom stylesheet, everything looks fine on screen, but when printing, all text, headings, formulas, etc. use the Courier font. I've looked through the default stylesheets and it seem that a custom printing style can be defined using something like: Cell[StyleData[Section, Printout], CellDingbat->[FilledSmallSquare], FontFamily->Arial] However, this does not seem to work on Linux 64bit with Mathematica 7.0.1. On the other hand, the same document in Mathematica Player on Windows prints using the custom style just fine. Is this a bug? If not, can someone point out what I did wrong? TIA, Richard === Subject: Re: HoldAll for Integrate > The following commands yield unexpected output: x=10; > Integrate[x^2, {x,0,1}] That is because Integrate does not have attributes HoldAll, so that the > second command will be interpreted as Integrate[100, {10,0,1}] which is > not a command that Integrate can work with (so a warning message is > returned). However, I can add the attribute HoldAll to Integrate myself: SetAttributes[Integrate, HoldAll]; I'm not very sure what to expect when now trying the same experiment > (the correct answer 1/3 would be nice), but the actual output surprised > me: x=10; > Integrate[x^2, {x,0,1}] Yields as output: 0 (without any warnings). Could anyone explain why I > should have expected this result? On a side note, I found a similar in the Tech Support column of the > Mathematica Journal Volume 6, Issue 2, by Carl Roy. He tried the > integral without limits: x=10; > SetAttributes[Integrate, HoldAll]; > Integrate[x^2, x] In the journal, the output 1000/3 is mentioned, whereas in Mathematica > 7.0.1 this outputs 1000. Again, does anyone understand this? Changing an attribute for a function, is like making a change to its code - the effect is completely unpredictable! The purpose of the HoldAll attribute is to let the writer of the function get access to the original expression, but that expression may also get evaluated internally within the function, as the following example illustrates: SetAttributes[debugPrint,HoldAll]; debugPrint[x_]:=Print[Unevaluated[x],=,x]; (try it - it is quite useful) The correct way to perform your calculation, is x = 10; Integrate[y^2, {y, 0, x}] (where y does not have a value) David Bailey http://www.dbaileyconsultancy.co.uk === Subject: Re: HoldAll for Integrate compare x = 10; SetAttributes[Integrate, HoldAll]; Trace[Block[{x}, Integrate[x^2, x]]] with Trace[Integrate[x^2, x]] and you see, that x^2 is evaluated to 100 but x is preserved, than 100 dx is computed to 100*x and than x->10 is substituted again to give 1000 Jens > The following commands yield unexpected output: x=10; > Integrate[x^2, {x,0,1}] That is because Integrate does not have attributes HoldAll, so that the > second command will be interpreted as Integrate[100, {10,0,1}] which is > not a command that Integrate can work with (so a warning message is > returned). However, I can add the attribute HoldAll to Integrate myself: SetAttributes[Integrate, HoldAll]; I'm not very sure what to expect when now trying the same experiment > (the correct answer 1/3 would be nice), but the actual output surprised > me: x=10; > Integrate[x^2, {x,0,1}] Yields as output: 0 (without any warnings). Could anyone explain why I > should have expected this result? On a side note, I found a similar in the Tech Support column of the > Mathematica Journal Volume 6, Issue 2, by Carl Roy. He tried the > integral without limits: x=10; > SetAttributes[Integrate, HoldAll]; > Integrate[x^2, x] In the journal, the output 1000/3 is mentioned, whereas in Mathematica > 7.0.1 this outputs 1000. Again, does anyone understand this? === Subject: Re: HoldAll for Integrate Hi Tammo, what Integrate really does can only somebody from Wolfram explain. But it completely eludes me why the integration variable in Integrate is not localized. Maybe some can give a reason for this. For the rest of us, we may define a new Integrate that does localize and see if it creates troubles. Here is a possibility, where we use Hold and Replace to protect the variable by giving it another name: SetAttributes[myInt, HoldAll]; myInt[integ_, {var_, low_, high_}] := Module[{integ0, var0}, Integrate @@ (Hold[integ, {var, low, high}] /. HoldPattern[var] -> var0) ]; Here is another one using With to protect the integration variable: SetAttributes[myInt, HoldAll]; myInt[integ_, {var_, low_, high_}] := With[{var = Unevaluated@var}, Integrate[integ, {var, low, high}]]; Daniel > The following commands yield unexpected output: x=10; > Integrate[x^2, {x,0,1}] That is because Integrate does not have attributes HoldAll, so that the > second command will be interpreted as Integrate[100, {10,0,1}] which is > not a command that Integrate can work with (so a warning message is > returned). However, I can add the attribute HoldAll to Integrate myself: SetAttributes[Integrate, HoldAll]; I'm not very sure what to expect when now trying the same experiment > (the correct answer 1/3 would be nice), but the actual output surprised > me: x=10; > Integrate[x^2, {x,0,1}] Yields as output: 0 (without any warnings). Could anyone explain why I > should have expected this result? On a side note, I found a similar in the Tech Support column of the > Mathematica Journal Volume 6, Issue 2, by Carl Roy. He tried the > integral without limits: x=10; > SetAttributes[Integrate, HoldAll]; > Integrate[x^2, x] In the journal, the output 1000/3 is mentioned, whereas in Mathematica > 7.0.1 this outputs 1000. Again, does anyone understand this? === Subject: Re: HoldAll for Integrate I would never write a statement like x = 10; x is too common a symbol to give it a value and doing so just gets you into the kind of problem that you did get into. Localize variables like x. For example make it an argument in a function definition, f[x_] := something, or set it in a With statement that contains expressions that use it. But if you do give it a Global value, then localize it (with Block or Module) where you don't want it to have a value. x = 10; Block[{x}, Integrate[x^2, {x, 0, 1}]] 1/3 David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ The following commands yield unexpected output: x=10; Integrate[x^2, {x,0,1}] That is because Integrate does not have attributes HoldAll, so that the second command will be interpreted as Integrate[100, {10,0,1}] which is not a command that Integrate can work with (so a warning message is returned). However, I can add the attribute HoldAll to Integrate myself: SetAttributes[Integrate, HoldAll]; I'm not very sure what to expect when now trying the same experiment (the correct answer 1/3 would be nice), but the actual output surprised me: x=10; Integrate[x^2, {x,0,1}] Yields as output: 0 (without any warnings). Could anyone explain why I should have expected this result? On a side note, I found a similar in the Tech Support column of the Mathematica Journal Volume 6, Issue 2, by Carl Roy. He tried the integral without limits: x=10; SetAttributes[Integrate, HoldAll]; Integrate[x^2, x] In the journal, the output 1000/3 is mentioned, whereas in Mathematica 7.0.1 this outputs 1000. Again, does anyone understand this? === Subject: Re: HoldAll for Integrate > The following commands yield unexpected output: x=10; > Integrate[x^2, {x,0,1}] That is because Integrate does not have attributes HoldAll, so that the > second command will be interpreted as Integrate[100, {10,0,1}] which is > not a command that Integrate can work with (so a warning message is > returned). For x to be localized for Integrate, it is a necessary, but not a sufficient condition that Integrate have Hold* attribtues. However, I can add the attribute HoldAll to Integrate myself: SetAttributes[Integrate, HoldAll]; I'm not very sure what to expect when now trying the same experiment > (the correct answer 1/3 would be nice), but the actual output surprised > me: x=10; > Integrate[x^2, {x,0,1}] It is generally not a very good idea to modify built-in functions. Yields as output: 0 (without any warnings). Could anyone explain why I > should have expected this result? It is not possible to know what the output will be without knowing what Integrate does internally. On a side note, I found a similar in the Tech Support column of the > Mathematica Journal Volume 6, Issue 2, by Carl Roy. He tried the > integral without limits: x=10; > SetAttributes[Integrate, HoldAll]; > Integrate[x^2, x] In the journal, the output 1000/3 is mentioned, whereas in Mathematica > 7.0.1 this outputs 1000. effect of localizing the symbol x inside of the Plot command. But this is simply not true. What HoldAll does is that it prevents evaluation of a function's arguments before the function itself is evaluated. But *during* the evaluation of the function, the arguments can be evaluated again. Again, does anyone understand this? Instead of trying to explain what might happen in such situations, I'll just give an illustrative example. Note how the order of evaluations change when HoldAll is set for f, but the result stays the same. In[1]:= f[v_] := Head[v] In[2]:= On[] f[x] Off[] During evaluation of In[2]:= On::trace: On[] --> Null. >> During evaluation of In[2]:= f::trace: f[x] --> Head[x]. >> During evaluation of In[2]:= Head::trace: Head[x] --> Symbol. >> Out[3]= Symbol In[5]:= x = 1 Out[5]= 1 In[6]:= On[] f[x] Off[] During evaluation of In[6]:= On::trace: On[] --> Null. >> During evaluation of In[6]:= x::trace: x --> 1. >> During evaluation of In[6]:= f::trace: f[x] --> f[1]. >> During evaluation of In[6]:= f::trace: f[1] --> Head[1]. >> During evaluation of In[6]:= Head::trace: Head[1] --> Integer. >> Out[7]= Integer In[9]:= SetAttributes[f, HoldAll] In[10]:= On[] f[x] Off[] During evaluation of In[10]:= On::trace: On[] --> Null. >> During evaluation of In[10]:= f::trace: f[x] --> Head[x]. >> During evaluation of In[10]:= x::trace: x --> 1. >> During evaluation of In[10]:= Head::trace: Head[x] --> Head[1]. >> During evaluation of In[10]:= Head::trace: Head[1] --> Integer. >> Out[11]= Integer === Subject: Re: solving nonlinear simultaneous equations As far as I know FindRoot stops at the first answer it gets. I tried a few starting points. The answer below is correct: just fill in these values and you'll see they're right. There are quite probably more correct solutions. Try filling in some other starting values. How should I decide the staring values as you gaves 0.5, 0.6, 0.4, 0.8 And these results are only answers? Because in this model, answers should be t0 0.042950144337512339004069005918555574390189195213080, > t1 -> 0.020794416091072412934056566904308358806687991905694, > t2 -> 0.014356830943135308919996619330315956865348280462553, > t3 -> -0.29047823800632023417669910887671278352651919604465} > BR. > Dooma Casper On 3=A4=EB25=A4=E9, =A4U=A4=C86=AE=C942=A4=C0, Sjo= erd C. de Vries .c.devr...@gmail.com > My guess is that you have been playing with StandardForm and > TarditionalForm formatting. Parts of the expressions like t1(1 - t0) > are internally represented as t1[1 - t0], i.e. t1 is the name of a > function. You can see that if you change the format to InputForm > (using the Cell/Convert tomenu). So, what you must do is change the > square brackets in parenthesis using Finf and Replace. Additionally, the syntax of your FindRoot is wrong. You cannot have to > starting values. If you rfepaired that and you tweak the starting > values and WorkingPrecision somewhat you get: FindRoot[{eq0, eq1, eq2, eq3}, > {{t0, 0.5}, {t1, 0.6}, {t2, 0.4}, {t3, 0.8}}, WorkingPrecision -> 50= ] {t0 -> 0.042950144337512339004069005918555574390189195213080, > t1 -> 0.020794416091072412934056566904308358806687991905694, > t2 -> 0.014356830943135308919996619330315956865348280462553, > t3 -> -0.29047823800632023417669910887671278352651919604465} > I'm using mathematica5.2 to solving 4 complex nonlinear simultaneous > equations I'm only need to know the approximate answers,but FindRoot keeps > showing FindRoot::nlnum error messages. How can I solve this problem? I provides my final_2.nb file by website link. http://awin.cs.ccu.edu.tw/~dooma/final_2.nb-=C1=F4=C2=C3=B3Q= =A4=DE=A5= > =CE=A4=E5=A6r - - =C5=E3=A5=DC=B3Q=A4=DE=A5=CE=A4=E5=A6r - === Subject: Interpolation with Method->Spline I upgraded to Mathematica 7.01 today so I could try the new Method->Spline option of the Interpolation function. I've experimented with it, and it appears to give the natural spline (second derivative = 0 at the data endpoints). I would like to specify the *first *derivative at the endpoints. It is possible to do this for splines outside of Mathematica (e.g., Numerical Recipes describes it), and Mathematica permits it for ordinary polynomial interpolation, so I tried using the same syntax. Here's an example: In[53]:= exampData = {{{0.}, 0., 0.}, {{0.5}, 0.00042}, {{1.}, 0.0013}, {{1.5}, 0.00614}, {{2.}, 0.026}, {{2.2}, 0.0622}, {{2.4}, 0.153}, {{2.6}, 0.188}} Out[53]= {{{0.}, 0., 0.}, {{0.5}, 0.00042}, {{1.}, 0.0013}, {{1.5}, 0.00614}, {{2.}, 0.026}, {{2.2}, 0.0622}, {{2.4}, 0.153}, {{2.6}, 0.188}} Notice that the first data input has an extra 0 after the function value to specify a 0 first derivative at x=0. This works for polynomial interpolation. However, for spline interpolation: In[54]:= f = Interpolation[exampData, Method -> Spline] Out[54]= InterpolatingFunction[] If you plot this (e.g., Plot[f[x], {x, 0, 1}] ) you'll see that f clearly has a negative slope at x=0. In[56]:= f[0.1] Out[56]= -0.0000687322 Unfortunately for me, f represents a physical quantity for which negative values are impossible (and cause mischief in later calculations). This was why I was trying to specify the 0 derivative at x=0: in hopes of making the spline behave itself near the endpoint so I could enjoy its other nice properties (minimum curvature) elsewhere. This is a new and not-yet-well-documented feature, so maybe there's a syntax or a workaround to do what I want. Does anyone know of one? John === Subject: Re: Read data structure from binary file >I have a binary file which I would like to read into a data >structure. The data structure contains some simple data types like >Integer16 and Integer32, but also a byte array of length 255. >How can I read this byte array into mathematica along with the other >data types as a complete data structure, without having to use >BinaryReadList(file, {Integer32, Byte, Byte, Byte, Byte, >Byte, ..., Byte, Integer16}) ? I can think of two ways to approach this problem. One would be to simply do BinaryReadList[file,Byte] and post process the data. If there were a single 32-bit integer followed by a sequence of bytes followed by a single 16 bit integer, then BinaryReadList[file,Byte] should do the trick. The other approach would be to open a binary stream and do something like Flatten@{BinaryRead[stream, Integer32],BinaryReadList[stream, Byte, 255],BinaryRead[stream,Integer32]} until you have read all of the data. Remember to close the stream after you are done. === Subject: Looking for help with Reduce command for use with my Calculus course. My first post to this newsgroup :-) I'm a mathematics instructor at a two-year college. Currently, I'm trying to explain implicit differentiation and implicitly defined functions to my students. To illustrate, I'm using the famous folium of Descartes: x^3 + y^3 = 6xy I want to generate all the pairs of real (x,y) solutions for x taking integer values from -4 to 3, and to then plot these pairs as points on the curve defined by the equation. So far I've come up with: pts = Table[{i, Reduce[curve /. {x -> i}, y, Reals] // N}, {i, -4, 3}] which gives me a table with rows like: -4 y=2.2143 or like: 2 y=-3.75877 [Or] y=0.694593 [Or] y=3.06418 where the [Or] is the logical or symbol. Of course this is not what I want. I want a list of pairs like: (-4,2.2143), (2,-3.75877), (2,0.694693), (2,3.06418), etc... so I can plot them as points. Can any of you Mathematica mavens provide this neophyte with an elegant solution? Gary === Subject: finding all definitions matching a pattern Assume we have a number of definitions associated with a symbol F, for example: F[0] = 3; F[1] = 7; F[3] = 11; What I need is an automated way to generate the list of definitions, something like In[1] := getdefs[F] Out[1] = {{0,3},{1,7},{3,11}} Would you know how to write this function getdefs? I am having trouble extracting any useful information from a call to Definition[F] since it seems to wrap its output somehow. Roman. === Subject: Re: Asking PlotRange to take a Dynamic value Hi Andrew, the whole Plot is dynamic, not simple the PlotRange. Therefore, put the Dynamic around Plot, not around z: Manipulate[ Dynamic@Plot[{Log[x], x^0.2, x^0.25, x^0.3}, {x, 0.01, n}, PlotStyle -> {Red, Blue, Blue, Blue}, PlotRange -> {{1, z}, {0, 55}}], Style[Log[x] vs. !(*SuperscriptBox[x, a]) for small positive a 0.2, 0.25 & 0.3, 12, Bold], Row[{Style[x, Bold], from 1 to , PopupMenu[Dynamic[z], {10, 500, 10000, 500000}]}], {n, 0.1, Dynamic[z], Appearance -> Labeled}] Allow me some criticism. I do not see the point of the manipulate, it simple hides part of the plot. Would it not make more sense, if you would manipulate e.g. the PlotRange and always draw the whole plot? Daniel I apologise in advance for what is probably a stupid question, but I > would appreciate some help in persuading PlotRange to take a Dynamic > value - or suggesting another way to go about things entirely! For teaching purposes I wanted to draw a series of graphs of Log[x] > vs. x^a for small positive values of a at different scales (simply to > illustrate how Log[x] is eventually < x^a, for any positive a). I > thought I would use Manipulate to allow students to explore this > interactively. E.g for x=0 to 10: Manipulate[ > Plot[{Log[x], x^0.2, x^0.25, x^0.3}, {x, 0.001, n}, > PlotStyle -> {Red, Blue, Blue, Blue}, > PlotRange -> {{0, 10}, {0, 3}}], > Style[Log[x] vs. !(*SuperscriptBox[x, a]) for small > positive a 0.2, 0.25 & 0.3, 12, Bold], > Style[x = 0 to 10, 12, Bold], {n, 0.01, 10, > Appearance -> Labeled}] & for x=0 to 500,000: Manipulate[ > Plot[{Log[x], x^0.2, x^0.25, x^0.3}, {x, 0.001, n}, > PlotStyle -> {Red, Blue, Blue, Blue}, > PlotRange -> {{0, 500000}, {0, 55}}], > Style[Log[x] vs. !(*SuperscriptBox[x, a]) for small > positive a 0.2, 0.25 & 0.3, 12, Bold], > Style[x = 0 to 500,000, 12, Bold], {n, 0.01, 500000, > Appearance -> Labeled}] But rather than a series of separate graphs I thought it would be more > elegant to combine them in one plot with a Dynamic value to choose the > scale, e.g.: Manipulate[ > Plot[{Log[x], x^0.2, x^0.25, x^0.3}, {x, 0.01, n}, > PlotStyle -> {Red, Blue, Blue, Blue}, > PlotRange -> {{1, Dynamic[z]}, {0, 55}}], > Style[Log[x] vs. !(*SuperscriptBox[x, a]) for small > positive a 0.2, 0.25 & 0.3, 12, Bold], > Row[{Style[x, Bold], from 1 to , > PopupMenu[Dynamic[z], {10, 500, 10000, 500000}]}], {n, 0.1, > Dynamic[z], Appearance -> Labeled}] Unfortunately, although the graphs will plot, with continually > updating axes, what I really want is to change the plot range for each > value of x & fix it so one can see the curves evolving more easily. I > hope the 2 individual examples above make it clear what I hoped for - > essentially, to click from one to the next with the PopupMenu. The > error message reads (e.g. for x=10): Plot::prng: Value of option PlotRange -> {{1,10},{0,55}} is not All, > Full, Automatic, a positive machine number, or an appropriate list of > range specifications. What's gone wrong? PlotRange -> {{1,10},{0,55}} looks like an > appropriate list of range specifications to me! Any advice appreciated > Andrew Graham > === Subject: Re: Asking PlotRange to take a Dynamic value what's wrong with Manipulate[ Plot[{Log[x], x^0.2, x^0.25, x^0.3}, {x, 0.01, n}, PlotStyle -> {Red, Blue, Blue, Blue}, PlotRange -> {{1, z}, {0, 55}}], Style[Log[x] vs. !(*SuperscriptBox[x, a]) for small positive a 0.2, 0.25 & 0.3, 12, Bold], {{z, 10, x from 1 to }, {10, 500, 10000, 500000}, PopupMenu}, {n, 0.1, Dynamic[z], Appearance -> Labeled}] Jens I apologise in advance for what is probably a stupid question, but I > would appreciate some help in persuading PlotRange to take a Dynamic > value - or suggesting another way to go about things entirely! For teaching purposes I wanted to draw a series of graphs of Log[x] > vs. x^a for small positive values of a at different scales (simply to > illustrate how Log[x] is eventually < x^a, for any positive a). I > thought I would use Manipulate to allow students to explore this > interactively. E.g for x=0 to 10: Manipulate[ > Plot[{Log[x], x^0.2, x^0.25, x^0.3}, {x, 0.001, n}, > PlotStyle -> {Red, Blue, Blue, Blue}, > PlotRange -> {{0, 10}, {0, 3}}], > Style[Log[x] vs. !(*SuperscriptBox[x, a]) for small > positive a 0.2, 0.25 & 0.3, 12, Bold], > Style[x = 0 to 10, 12, Bold], {n, 0.01, 10, > Appearance -> Labeled}] & for x=0 to 500,000: Manipulate[ > Plot[{Log[x], x^0.2, x^0.25, x^0.3}, {x, 0.001, n}, > PlotStyle -> {Red, Blue, Blue, Blue}, > PlotRange -> {{0, 500000}, {0, 55}}], > Style[Log[x] vs. !(*SuperscriptBox[x, a]) for small > positive a 0.2, 0.25 & 0.3, 12, Bold], > Style[x = 0 to 500,000, 12, Bold], {n, 0.01, 500000, > Appearance -> Labeled}] But rather than a series of separate graphs I thought it would be more > elegant to combine them in one plot with a Dynamic value to choose the > scale, e.g.: Manipulate[ > Plot[{Log[x], x^0.2, x^0.25, x^0.3}, {x, 0.01, n}, > PlotStyle -> {Red, Blue, Blue, Blue}, > PlotRange -> {{1, Dynamic[z]}, {0, 55}}], > Style[Log[x] vs. !(*SuperscriptBox[x, a]) for small > positive a 0.2, 0.25 & 0.3, 12, Bold], > Row[{Style[x, Bold], from 1 to , > PopupMenu[Dynamic[z], {10, 500, 10000, 500000}]}], {n, 0.1, > Dynamic[z], Appearance -> Labeled}] Unfortunately, although the graphs will plot, with continually > updating axes, what I really want is to change the plot range for each > value of x & fix it so one can see the curves evolving more easily. I > hope the 2 individual examples above make it clear what I hoped for - > essentially, to click from one to the next with the PopupMenu. The > error message reads (e.g. for x=10): Plot::prng: Value of option PlotRange -> {{1,10},{0,55}} is not All, > Full, Automatic, a positive machine number, or an appropriate list of > range specifications. What's gone wrong? PlotRange -> {{1,10},{0,55}} looks like an > appropriate list of range specifications to me! Any advice appreciated > Andrew Graham > === Subject: Re: What's going on here (Table-generated lists)? Hi Erik, your guess is 100% right. Look at: Attributes[Plot] and you will see that it has HoldAll. Therefore, the Table will not be evaluated before beeing fed to Plot. To evaluate it, simply wrap Evaluate around the Table. Daniel > I'm seeing a difference in behavior with Plot in conjunction with Table, > and I'm rather confused at the reason. If I use Plot to plot a list > of functions, it works as expected, and I get a plot with each function > in its own color: Plot[{x, 2 x, 3 x, 4 x, 5 x}, {x, -1, 1}] If I use Table, then this doesn't work the same way -- the five lines > are all plotted with the same color: Plot[Table[k x, {k, 1, 5}], {x, -1, 1}] I verified that the both objects created have a Head of List, so I don't > see anything obviously different about them. Here's what confuses me more: If I generate the table separately and > then use that as a result in a later evaluation in the Plot, then I get > the colors back: In[25]:= Table[k x, {k, 1, 5}] Out[25]= {x, 2 x, 3 x, 4 x, 5 x} In[26]:= Plot[%, {x, -1, 1}] What is going on here? Is it something like Plot does a special scan of > its first argument before Evaluating it, and if it doesn't start out as > a List, it concludes that it's all one thing and plots it with the same > color, as opposed to an explicitly provided list of separate colors? > === Subject: Re: What's going on here (Table-generated lists)? > I'm seeing a difference in behavior with Plot in conjunction with Table, > and I'm rather confused at the reason. If I use Plot to plot a list > of functions, it works as expected, and I get a plot with each function > in its own color: Plot[{x, 2 x, 3 x, 4 x, 5 x}, {x, -1, 1}] If I use Table, then this doesn't work the same way -- the five lines > are all plotted with the same color: Plot[Table[k x, {k, 1, 5}], {x, -1, 1}] I verified that the both objects created have a Head of List, so I don't > see anything obviously different about them. Here's what confuses me more: If I generate the table separately and > then use that as a result in a later evaluation in the Plot, then I get > the colors back: In[25]:= Table[k x, {k, 1, 5}] Out[25]= {x, 2 x, 3 x, 4 x, 5 x} In[26]:= Plot[%, {x, -1, 1}] What is going on here? Is it something like Plot does a special scan of > its first argument before Evaluating it, and if it doesn't start out as > a List, it concludes that it's all one thing and plots it with the same > color, as opposed to an explicitly provided list of separate colors? > Yes, that is right. In newer versions of Mathematica, Plot[] is a complicated function that tries to guess whether the argument you provided needs to be evaluated symbolically before substituting in numerical values for the plot variable, or not. Of course it cannot always guess right. In this case it doesn't evaluate the Table before starting the plotting, so it thinks that it'll have only one thing to plot, and thus it uses only one colour. IMO this is quite silly. If it is able to plot all five lines, it should be able to figure out that it needs five colours ... But guessing behaviour can be manually overridden with the (I think undocumented) option Evaluated. Plot[Table[k x, {k, 1, 5}], {x, -1, 1}, Evaluated -> True] (The default is Evaluated -> Automatic) If you don't know about this option, you can use the more traditional Plot[Table[k x, {k, 1, 5}] // Evaluated, {x, -1, 1}] However, this is not completely equivalent to using the option Evaluated: with Evaluated -> True, x still gets localized inside Plot, and the plotting will work correctly even if x has a value: x = 1. Plot[Table[k x, {k, 1, 5}] // Evaluated, {x, -1, 1}] Plot[Table[k x, {k, 1, 5}], {x, -1, 1}, Evaluated -> True] === Subject: Re: What's going on here (Table-generated lists)? consider the function myTest[] defined as follows SetAttributes[myTest, HoldAll] myTest[funs : {__}, {x_Symbol, x0_?NumericQ, x1_?NumericQ}] := List of functions. myTest[fun_, {x_Symbol, x0_?NumericQ, x1_?NumericQ}] := Single function. and what may come out from {myTest[{x, Sin[x], Cos[x]}, {x, 0, Pi}], myTest[Table[Cos[k*x], {k, 3}], {x, 0, Pi}], myTest[Evaluate[Table[Cos[k*x], {k, 3}]], {x, 0, Pi}]} as expected you get {List of functions., Single function, List of functions.} and this is so, because the patterns are defined in that way. And as you have noticed, the myTest[] function behave in the same way as Plot[] does. Jens > I'm seeing a difference in behavior with Plot in conjunction with Table, > and I'm rather confused at the reason. If I use Plot to plot a list > of functions, it works as expected, and I get a plot with each function > in its own color: Plot[{x, 2 x, 3 x, 4 x, 5 x}, {x, -1, 1}] If I use Table, then this doesn't work the same way -- the five lines > are all plotted with the same color: Plot[Table[k x, {k, 1, 5}], {x, -1, 1}] I verified that the both objects created have a Head of List, so I don't > see anything obviously different about them. Here's what confuses me more: If I generate the table separately and > then use that as a result in a later evaluation in the Plot, then I get > the colors back: In[25]:= Table[k x, {k, 1, 5}] Out[25]= {x, 2 x, 3 x, 4 x, 5 x} In[26]:= Plot[%, {x, -1, 1}] What is going on here? Is it something like Plot does a special scan of > its first argument before Evaluating it, and if it doesn't start out as > a List, it concludes that it's all one thing and plots it with the same > color, as opposed to an explicitly provided list of separate colors? > === Subject: Re: What's going on here (Table-generated lists)? > I'm seeing a difference in behavior with Plot in conjunction with > Table, > and I'm rather confused at the reason. If I use Plot to plot a list > of functions, it works as expected, and I get a plot with each > function > in its own color: Plot[{x, 2 x, 3 x, 4 x, 5 x}, {x, -1, 1}] If I use Table, then this doesn't work the same way -- the five lines > are all plotted with the same color: Plot[Table[k x, {k, 1, 5}], {x, -1, 1}] I verified that the both objects created have a Head of List, so I > don't > see anything obviously different about them. Here's what confuses me more: If I generate the table separately and > then use that as a result in a later evaluation in the Plot, then I > get > the colors back: In[25]:= Table[k x, {k, 1, 5}] Out[25]= {x, 2 x, 3 x, 4 x, 5 x} In[26]:= Plot[%, {x, -1, 1}] What is going on here? Is it something like Plot does a special > scan of > its first argument before Evaluating it, and if it doesn't start > out as > a List, it concludes that it's all one thing and plots it with the > same > color, as opposed to an explicitly provided list of separate colors? > Something like that, some functions evaluate their arguments in a non- standard fashion, Plot being one of them. This is usually mentioned in the help on the function. In particular Plot has the attribute HoldAll which means its arguments are not evaluated before Plot is evaluated, you can override this with an explicit evaluate: Plot[Evaluate[Table[k x, {k, 1, 5}]], {x, -1, 1}] - Ssezi === Subject: Re: What's going on here (Table-generated lists)? > I'm seeing a difference in behavior with Plot in conjunction with Table, > and I'm rather confused at the reason. If I use Plot to plot a list > of functions, it works as expected, and I get a plot with each function > in its own color: Plot[{x, 2 x, 3 x, 4 x, 5 x}, {x, -1, 1}] If I use Table, then this doesn't work the same way -- the five lines > are all plotted with the same color: Plot[Table[k x, {k, 1, 5}], {x, -1, 1}] I verified that the both objects created have a Head of List, so I don't > see anything obviously different about them. Here's what confuses me more: If I generate the table separately and > then use that as a result in a later evaluation in the Plot, then I get > the colors back: In[25]:= Table[k x, {k, 1, 5}] Out[25]= {x, 2 x, 3 x, 4 x, 5 x} In[26]:= Plot[%, {x, -1, 1}] What is going on here? Is it something like Plot does a special scan of > its first argument before Evaluating it, and if it doesn't start out as > a List, it concludes that it's all one thing and plots it with the same > color, as opposed to an explicitly provided list of separate colors? Yes, and I think that is even documented and not so special at all: As many other functions Plot has the attribute HoldAll. Use this to get a different color for each expression: Plot[Evaluate[Table[k x, {k, 1, 5}]], {x, -1, 1}] To understand what is going on I recommend to read the following tutorial in the documentation: tutorial/NonStandardEvaluation hth, albert === Subject: Re: What's going on here (Table-generated lists)? Attributes[Plot] {HoldAll,Protected} Note the HoldAll Plot[Evaluate[Table[k x, {k, 1, 5}]], {x, -1, 1}] Bob Hanlon I'm seeing a difference in behavior with Plot in conjunction with Table, and I'm rather confused at the reason. If I use Plot to plot a list of functions, it works as expected, and I get a plot with each function in its own color: Plot[{x, 2 x, 3 x, 4 x, 5 x}, {x, -1, 1}] If I use Table, then this doesn't work the same way -- the five lines are all plotted with the same color: Plot[Table[k x, {k, 1, 5}], {x, -1, 1}] I verified that the both objects created have a Head of List, so I don't see anything obviously different about them. Here's what confuses me more: If I generate the table separately and then use that as a result in a later evaluation in the Plot, then I get the colors back: In[25]:= Table[k x, {k, 1, 5}] Out[25]= {x, 2 x, 3 x, 4 x, 5 x} In[26]:= Plot[%, {x, -1, 1}] What is going on here? Is it something like Plot does a special scan of its first argument before Evaluating it, and if it doesn't start out as a List, it concludes that it's all one thing and plots it with the same color, as opposed to an explicitly provided list of separate colors? -- Erik Max Francis && max@alcyone.com && http://www.alcyone.com/max/ San Jose, CA, USA && 37 18 N 121 57 W && AIM, Y!M erikmaxfrancis In this world, nothing is certain but death and taxes. -- Benjamin Franklin === Subject: Re: How do I hide all input in a Mathematica notebook? Mike, The simplest solution would be to permanently close the Input cells when you prepare the notebook. You do this by selecting the Input cell bracket and using Menu -> Cell -> Cell Properties -> Open, or the key sequence Alt-CPO. I don't know if there is a single command that will select all of the Input cells at once, but having selected a set of them you can open or close them all at once. This hides the Input cells as a set of thin cells. You could then evaluate your entire notebook at once to obtain the displays. One disadvantage I find with this method is that whenever I think a display is finished and I close up the Input cell, I later find I want to make a change and have to open it up again. A second disadvantage is that if you want to evaluate the cells individual you might find they are difficult to select because the cells are so thin. However, you don't have to click the bracket itself - you can click anywhere in the cell. In the Presentations package I have a number of commands for formatting 'page' displays and generating page displays by buttons that can be merged into text cells, or that can form a structured group for moving through various displays. The buttons allow either a page display in the notebook, or will launch it in a separate window. I usually put the code for the page displays in subsections that remain closed. You could do a little bit of this yourself by putting your display code in subsections. Give each display a name: display1 = code that generates the display; Then put a button in the main portion of the notebook: Button[Sales by product line, display1] Then copy the button to the open part of the notebook. An advantage of the button method is that you can change the code in display1, say, without having to change the button in the open part of the notebook. David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ Hi I am using Mathematica to prepare a report for my boss. It has lots of tables and pie charts - the sort of things bosses love. It also has a lot of Mathematica commands which scares the wossname out of him. At the moment I am hiding the input cell by cell but this is a pain. Is there a one click/one command solution? Mike www.walkingrandomly.com === Subject: Re: How do I hide all input in a Mathematica notebook? One very clean way to do this would be to create a copy of the notebook for delivery to your boss. Then in this copy execute Module[{nb}, nb = EvaluationNotebook[]; NotebookFind[EvaluationNotebook[], Input, All, CellStyle]; NotebookDelete[nb]] Within your boss's notebook. This will remove, rather than hide, the input cels in that copy of the notebook. However, if you wanted to just hid those cells you could execute Module[{nb}, nb = EvaluationNotebook[]; NotebookFind[EvaluationNotebook[], Input, All, CellStyle]; SetOptions[NotebookSelection[nb], CellOpen -> False, ShowCellBracket -> False] ] in that notebook... Hope this helps.... More advanced methods using tagging could be used (see The Joy of Tagging: Manipulating and Mining Notebooks in Mathematica at http://scientificarts.com/worklife/notebooks/ I hope that this helps, David > Hi I am using Mathematica to prepare a report for my boss. It has lots > of tables and pie charts - the sort of things bosses love. It also > has a lot of Mathematica commands which scares the wossname out of > him. At the moment I am hiding the input cell by cell but this is a pain. > Is there a one click/one command solution? Mike www.walkingrandomly.com === Subject: Re: coefficients but not from polynomial (variables does Cases[a = Sin[x*Pi] + Sin[y], _Symbol?(! NumericQ[#] &), Infinity] {x,y} Bob Hanlon Probably my question is very simple. Suppose that we have expression a= Sin[x]+Sin[y]. I would like receive variables from which this expression is dependent, so in this case {x,y}. The Variables does not work of course in this because it is not a polynomial and it gives me {Sin[x],Sin[y]}. Do anyone know how to solve my problem. I would be very grateful for quick response. Magdalena === Subject: Re: Optimization question. Hi Gregory, you want to call different functions depending depending on the arguments an further function has already seen. To accomply this you may store function values already calculated by the syntax: f1[x_]:=f1[x]= defintion of f1 If this will use too much memory you may use a global variable where the last argument of f1 is stored. Here is an examples using the first approach. f2 calls f3 or f4 depending on the arguments f1 has already seen: f1[x_] := f1[x] = x; f2[x_] := If[ Cases[DownValues[f1], HoldPattern[f1[x]], Infinity] == {}, f3[x], f4[x]]; f3[x_] := Print[f1 has not seen value: , x]; f4[x_] := Print[f1 has seen value: , x]; f1[1]; f2[1] f2[2] hope this helps, Daniel > I have a very complicated objective function calculated using a recursion. > It is straightforward to compute the gradient as the function is computed. > How to I tell Mathematica that when it needs the gradient, it must calculate > the objective first? Alternatively, is there a way to tell whether the > objective has just been evaluated and tell Mathematica to use one program > for the gradient if the objective has just been called with the same > parameter values and another if it was called in a previous iteration or sub > iteration, e.g. with different parameters. Maybe it is in the documentation > somewhere but I could not find it. Greg Duncan === Subject: 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 === Subject: Re: DeleteCases Filippo > seq = {{0, 0, 1, 1}, {0, 0, 2, 2}, {0, 0, 3, 3}, {1, 1, 0, 0}, {1, 1, > 2, 2}, {1, 1, 3, 3}, {2, 2, 0, 0}, {2, 2, 1, 1}, {2, 2, 3, 3}, {3, > 3, 0, 0}, {3, 3, 1, 1}, {3, 3, 2, 2}}; > same[{a_, a_, b_, b_}, {b_, b_, a_, a_}] = True; > same[__] = False; > Union[seq, SameTest -> same] or Tally[seq, same][[All, 1]] Bobby >> Given this example list: >> {{0, 0, 1, 1}, {0, 0, 2, 2}, {0, 0, 3, 3}, {1, 1, 0, 0}, {1, 1, 2, >> 2}, >> {1, 1, 3, 3}, {2, 2, 0, 0}, {2, 2, 1, 1}, {2, 2, 3, 3}, {3, 3, 0, 0}, >> {3, 3, 1, 1}, {3, 3, 2, 2}} >> I need the elements {a,a,b,b} and {b,b,a,a} to be the same, i.e. i >> want to delete one of the two occurrences from the list. (or all but >> one if the condition is more complicated, say {a,b,c,d} and {b,a,c,d} >> or {a,b,c,d} and {a,b,d,c}) >> How can i do that? Can i use DeleteCases? if so, what conditional >> should I use to compare different elements in the list? >> Filippo > > -- > DrMajorBob@bigfoot.com > === 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: Find out if LinearProgramming has found a solution the subject says it: I would like to find out whether LinearProgramming has found a solution or not. Currently, I do result = LinearProgramming[costs, incidenceMatrix, rhs, capacities]; If[NumberQ[First[result]],...] which works, but I guess there is a more elegant way to do it. Any hint appreciated, Karsten. === Subject: Re: Using StringReplace to replace a regex containing newlines Hi in Perl as well as Mathematica syntax, . does not match newline. Therefore you have to specify that it should match by e.g. by using(?s). Here your example: StringReplace[str,RegularExpression[BEGINIGNORE(?s).*ENDIGNORE] -> ] hope thid helps, Daniel > Check out the following question and answer: http://stackoverflow.com/questions/703153/mathematica-stringreplace It seems to me that that's a bug in Mathematica's regular expression > engine. > === Subject: Re: Footnotes, Endnotes in Mathematica I am trying to converge on a single tool for my analysis, development, > and publication work. Mathematica is great at the first 2, and Publicon > seems like an interesting tool for the third. Unfortunately my test > drive of Publicon indicates that there is no easy way to merge the two. > So for now I am sticking to Mathematica and brute focing stylesheets, > etc. I can ot for the life of me figure out how to do footnotes or > endnotes in Mathematica !! I have searched every source I can think of > nad the only useful references are to using Publicon. Dr. Robert P. Yerex, Ph.D., MBA > Chief Economist > Kronos Incorporated What mode(s) or form(s) of publication are you trying to generate? Although opinions differ, for some of us who want to submit journal > generated in Mathematica with material obtained or generated elsewhere, > or repurpose or reuse parts or elements from publications generated > earlier into new publications, the best way still seems to be to Export > material (graphics, tables, etc.) that can best (or only) be prepared in > Mathematica from Mathematica into PDF or other formats, and then use > TeX, LaTeX, Word, Pages, PowerPoint, or any of the numerous other tools > that are designed to be publication tools as your publication tools. need specialized page layout software (not that word or powerpoint could ever be described as that). Mathematica can deliver pretty much everything you will need --- with the exception of endnotes, particularly with the sort of seemless integration that exists with Endnote and MS Word/Pages, and footnotes. I think if endnote (and footnote?) capability existed in Mathematica then it could genuinely be considered as a tool designed to be publication tool. Mike === 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: Older notebooks and Mathematica 7 I am looking for a tutorial about how to update older Mathematica notebooks prior to v6. I am finding many tutorial math notebooks needed to be compatibility checked and updated. Sometimes its clear what's needed sometimes its muddy. Btw, WRI, why are many of the older files at your === Subject: Dynamic 2D ListLinePlot PlotRange 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? -- Bryce Schober === Subject: Styling the selected Tab's label in TabView 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: BarChart in v. 7 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: Re: Update to Hinton Button/palette tutorial for Mathematica 7? > P.J. Hinton's How To Create Buttons notebook reports problems when > opening in Mathematica 7. > What is best way to address the errors reported and how to fix them. I wasn't able to reproduce this. I got my copy from here... http://library.wolfram.com/conferences/devconf99/hinton/Buttons19991022.nb and it opened flawlessly in 7.0.1. There were a few pink-box errors which came from attempting to use the automated compatibility tool (I'll report those), and I didn't try running it. But I don't know of any reason the code in here shouldn't work unmodified (it uses some deprecated option names, but Mathematica should translate those to the newer option names without a problem). If you got your copy from someplace else, let me know where you got it from...or you could send it to me privately. John Fultz jfultz@wolfram.com User Interface Group Wolfram Research, Inc. === Subject: 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. 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: Integrating package documentation with the documentation center > Although the documentation center (DC) came with version 6.0, there is > (to my knowledge) still no published method for fully integrating > package documentation with this system (at least not without using the > Wolfram Workbench). Since there is clearly some interest in this information, I will post it up on my website in about a week. David Bailey http://www.dbaileyconsultancy.co.uk === Subject: Re: Integrating package documentation with the documentation center the Wolfram Workbench include everything to make a documentation > and it seems that you have just overlooked this excellent Mathematica > development tool. > I haven't overlooked the Workbench - indeed I mentioned it in my original post, but I like the way the Mathematica frontend works - I just don't want another piece of software sitting on top of that! I haven't overlooked the Workbench - indeed I mentioned it in my original post, but I like the way the Mathematica frontend works - I just don't want another piece of software sitting on top of that! People's exact project requirements vary, and it is often convenient to access the API to perform a task - rather than click through someone else's GUI. David Bailey http://www.dbaileyconsultancy.co.uk === Subject: Re: Help to define linked domains for variables Îïsure if I understood the problem. You can write the relations as æïììï÷(assuming you forgot some quotes): ÜÛÃõò[IGrave ]ùÅ[Eth]óéìï[IHat ]= [Piecewise] { û[Hyphen]±¬ < 0}, û°z == 0}, û±z > 0} ÜÛÃõò[IGrave ]ùÅ[Eth]óéìï[IHat ][CapitalYAcute]§ [Piecewise] { û[Hyphen]±¬ $B!](B a < 0}, û°r $B!](B a == 0}, û±r $B!](B a > 0} uppose there is something you want to solve here, but you have to íáëå ùïõòóåì[ODoubleDo t]a bit clearer. Ãèååòó [Hyphen][Hyphen] Óïåòä I am a very basic user of Mathematica and I have found the following problem. I have a function where I need to define for the variable $B&E(B, $B&E!l(B and z the following relations > $B&E(B = $B!](B1 if z < 0; $B&E(B = 0 if z = 0; $B&E(B = 1 if z > 0 $B&E!l(B = $B!](B1 if r $B!](B a < 0; $B&E(B = 0 if r $B!](B a = 0; $B&E(B = 1 if r $B!](B a > 0 > Shay === Subject: Re: Interpolation: Method->Spline >does anybody know what sort of splines Wolfram choose to implement. >One would assume that normal splines are the thing to do, but the second >derivative is not zero at the ends as the following shows: >d = Table[RandomReal[{-1, 1}], {5}] >f = Interpolation[d, Method -> Spline]; >Plot[f[x], {x, 1, Length[d]}, >Epilog -> Point[Transpose[{Range[Length[d]], d}]]] >Plot[f'[x], {x, 1, Length[d]}] >Plot[f''[x], {x, 1, Length[d]}] When you do FullForm[Interpolation[d,Method->Spline] you will see part of the structure of f is a BSplineFunction. This leads me to believe the spline basis is a B-spline. And since the documentation for BSplineFunction states the default is a cubic B-spline, I assume specifying Method->Spline results in a cubic B-spline interpolation. === Subject: Re: Joust in Mathematica > 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: 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: passing an array variable as a file name string to FindList 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: help in constructing a binomial consequence 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: ImageResolution I wanted to thank David Park, and the other people who emailed me, for taking the time to help me discover the root of my problem and to explain the problem that I was having and what I used as a solution. The Problem: OS: Mac OS 10.5.6 Mathematica 7.0.0 Increasing the ImageResolution option in the Rasterize function also increased the white space between the FrameLabels and the frame. The solution update to Mathematica 7.0.1 which fixed the problem. > If you don't like the default ImageMargins, then why not specify them > explicitly? GraphicsColumn[ > Table[Rasterize[ListPlot[Table[x, {x, -10, 10}], Frame -> True, > FrameLabel -> {Not quite, Hi}, > ImageMargins -> {{15, 10}, {15, 10}}], > ImageResolution-> ir], {ir, {10, 20, 50, 100, 200, 500}}]] David Park > djmp...@comcast.nethttp://home.comcast.net/~djmpark/ > I want to output some high resolution graphs, however changingImageResolu= tionseems to effect the padding around the Frame label. > Does anyone know or have a solution for this? The code below demonstrates this problem: GraphicsColumn[ > Table[Rasterize[ > ListPlot[Table[x, {x, -10, 10}], Frame -> True, > FrameLabel -> {Not quite, Hi}], > ImageResolution-> ir], {ir, {10, 20, 50, 100, 200, 500}}]] === Subject: Re: Update to Hinton Button/palette tutorial for Mathematica 7? > P.J. Hinton's How To Create Buttons notebook reports problems when > opening in Mathematica 7. > What is best way to address the errors reported and how to fix them. > If you post some code here, people will try it and probably solve the problem for you. Move the code across using the menu item Edit/CopyAs/Plain text. David Bailey http://www.dbaileyconsultancy.co.uk === Subject: Re: Update to Hinton Button/palette tutorial for Mathematica 7? Let the compatibility tool that kicks in if you load an old notebook do its job. Worked for me. > P.J. Hinton's How To Create Buttons notebook reports problems when > opening in Mathematica 7. > What is best way to address the errors reported and how to fix them. === Subject: Re: Update to Hinton Button/palette tutorial for Mathematica 7? > P.J. Hinton's How To Create Buttons notebook reports problems when > opening in Mathematica 7. > What is best way to address the errors reported and how to fix them. This? http://library.wolfram.com/conferences/devconf99/hinton/Buttons19991022.htm= l This notebook is nearly 10 years old and is appropriate for older versions of Mathematica. Mathematica 6 & 7 have a much better way to create buttons: http://reference.wolfram.com/mathematica/ref/Button.html -Rob === Subject: Re: Update to Hinton Button/palette tutorial for Mathematica 7? I would suggest that that is a very old notebook and that the way user interface objects are created and used in Mathematica >6 is very It's best to use the current Matheamtica documentation on Buttons to guide you there. Best, David > P.J. Hinton's How To Create Buttons notebook reports problems when > opening in Mathematica 7. > What is best way to address the errors reported and how to fix them. === Subject: Re: Graphics and DisplayFunction Ok, so if I understand it correctly then by using explicit > DisplayFunctions, I display the *thing*, that is the side effect of > the actual function. Obviously only things that are enclosed in Show > can be thus displayed with DisplayFunctions, and - however it's just a > guess - the various plot functions all utilize an internal Show which > encloses their internal graphics. Thus - secondarily - DisplayFunction > can be used with plotting functions as well. But then I simply don't > understand why DisplayFunction is an option for Graphics? Neither > I would forget about the DisplayFunction option - it is more or less obsolete. Just think of graphics as output - just like numbers or equations. 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: selecting a column in a grid error message. I'm a novice, and don't understand your syntax - what is the # & doing inside the Print statement for example - so haven't been able to debug it. In any case, I'm fairly sure your code doesn't help me. As I said, choosing a row with EventHandler and EventHandlerScaled is trivial, because the row position is linearly dependent on the mouse position in the grid. But that is not the case with the columns, since some of my columns can be anything from one to 100 characters wide. Paul. Dimensions[] just gives me the size of the grid in elements, what I need is the actual values of ItemSize as determined by Mathematica when one of the ItemSize options is set to Auto. -----Original Message----- === Subject: Re: selecting a column in a grid Hi Paul, you may e.g. use EventHaldler with MouseClicked and MousePosition[EventHandlerScaled]. This gives you scaled coordinates. The run from lower left to upper right and you have to fiddel a bit with them to get row and colum. Here is an example that prints row and column: gr = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}, {7, 8, 9}, {7, 8, 9}}; myGrid[gr_] := EventHandler[ Grid[gr] , MouseClicked :> (Print[{1, 2} + {0, 1} # &[Dimensions[gr]] + Round[{0.5, -1.5} # & [ Dimensions[gr] MousePosition[EventHandlerScaled]]]]) ] Daniel 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: selecting a column in a grid Hi Paul, you may e.g. use EventHaldler with MouseClicked and MousePosition[EventHandlerScaled]. This gives you scaled coordinates. The run from lower left to upper right and you have to fiddel a bit with them to get row and colum. Here is an example that prints row and column: gr = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}, {7, 8, 9}, {7, 8, 9}}; myGrid[gr_] := EventHandler[ Grid[gr] , MouseClicked :> (Print[{1, 2} + {0, 1} # &[Dimensions[gr]] + Round[{0.5, -1.5} # & [ Dimensions[gr] MousePosition[EventHandlerScaled]]]]) ] Daniel 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: eliminate x x == (y /. Solve[x*x + x + 5 + 8*x*x*x == 0 /. a_ + x :> a + y, y][[1]]) ?? Jens I have simple equation x*x+x+5+8*x*x*x=0 and I would like to eliminate > from this equation x but in this way to recaive x=- x*x-8*x*x*x-5. So > the x with the lowest power is always on tle left site. Magdalena > === Subject: Re: Deleting entire row and/or column to delete rows with elements: 0 or 0. you may use: DeleteCases[d, {a : (0. | 0) ..}] To delet columns you use the above with transposeing the matrix. Daniel I have large matrices having entire rows and/or columns of zeros and I > want to delete those zero rows and columns. My question, what is the > best (most compact) command to use in Mathematica. Please note that > the value of zero is the real zero i.e 0.0000 not just 0. > === Subject: Re: Deleting entire row and/or column I have large matrices having entire rows and/or columns of zeros and I > want to delete those zero rows and columns. My question, what is the > best (most compact) command to use in Mathematica. Please note that > the value of zero is the real zero i.e 0.0000 not just 0. > yourMatrix /. x_ /;x == 0 -> Sequence[] or if that doesn't work then yourMatrix /. x : (_Real | _Integer) /; N[x] == 0. -> Sequence[] you could change this to Chop[x] is the values ->0 could be considered zero. Mike === Subject: Re: Deleting entire row and/or column Ah, I like the Nest/Transpose solution. === Subject: Re: Can't figure out how to export Mathematica into Word > I help out my lab partners in one of my classes by exporting out the da= ta and equations we worked on from mathematica. They use microsoft word s= o 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[(=C3=AF=EF=BF=BD=C5=BD), (1)])= , !(*SubscriptBox[(F), (2)]), It seems like there is something not set up the way I want to in the ex= port or copy functions... Also, when exporting to rtf, the tables come ou= t as 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 mathematica to do the same? > Use Copy As -> MathML, then you can paste into Word 2007 (but not earlier Word versions and not any other Office applications). === Subject: Re: Can't figure out how to export Mathematica into Word > 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? Think the best way to go is with PDF files - so many other programs can read and import them. So just do a File/Save As and specify the PDF format. Another possibility is PostScript. This is no guarantee of course that it will work, but is definitely worth a try. have to choose which of the pages in the PDF file to import. I have done this on my Mac OS X system with Word 2008, but I assume that the Windows version of Word has something similar. I hope so anyway -- let us know how things work out, OK? -Bob === Subject: Re: Can't figure out how to export Mathematica into Word 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: Can't figure out how to export Mathematica into Word > 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 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[(=EF=81=B4)= , > (1)]), !(*SubscriptBox[(F), (2)]), It seems like there is something not set up the way I want to in the > export or copy functions... Also, when exporting to rtf, the tables com= e > out as 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 mathematica to do the same? Use CopyAs -> MathML and paste into Word. Equations, tables, etc., copy nicely this way, and can then be further edited within Word. (This works = for Word 2007, at any rate. Probably not for earlier versions of Word.) -- Helen Read University of Vermont === Subject: Re: Can't figure out how to export Mathematica into Word > 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? You could try this: nb = NotebookOpen[/path/to/your/file/file.nb] Export[test.rtf, nb, RTF] I tried is on a small example and while the full subscripting/ superscripting didn't seem to work, none of the box structure stuff that you have mentioned in your post was transferred and the formatting problems looked like something you could manually touch up in your final document. I viewed the output in TextEdit. I don't have MS Word so don't know what it would look like in that. In OpenOffice the (equation) output looked screwy. I'm not sure that RTF is a uniform format so that could be an issue. Mike === Subject: Re: Can't figure out how to export Mathematica into Word 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 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 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[(.95ª«), (1)]), !(*SubscriptBox[(F), (2)]), It seems like there is something not set up the way I want to in the export 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 to export this stuff out to rtf correctly by default... How do I set up mathematica to do the same? > === Subject: Re: A simple ordinary differential equation look at: f[x_?NumericQ] = 1 - 1111*x'^2 you can not take the derivative of a number. Daniel > What is wrong with this equation? Clear[sol] > f[x_?NumericQ] = 1 - 1111*x'^2; > sol = NDSolve[{x''[t] + (16/10^4)x'[t]^2*Sqr[ > f[x[t]]]/x[ > t]^2 - (1458/10^9)*f[x[t]]/x[t]^2 == > 0, x[0] == 1, x'[0] == 0}, x[t], { > t, 0, 100}, AccuracyGoal -> 8, > PrecisionGoal -> 8, WorkingPrecision - 30, MaxSteps -> Infinity]; > Plot[Evaluate[x'[t] /. sol], {t, 0, 100}] > === Subject: Re: A simple ordinary differential equation I think you are doing few mistakes: 1) you miss t in the Sqrt function 2) you define a function f as a function of x which does not include t. Better not to do that ans simply put this term in your equations; but check it first if I am right. 3)You solve equations for x[t] but you plot for x'[t]. Since it is numerically solve better to solve equations for x'[t]. I have the modified code below but not sure if it is really true. Please check it first. Clear[sol] sol = NDSolve[{x''[t] + (16/10^4) x'[t]^2* Sqrt[(1 - 1111*x'[t]^2)]/ x[t]^2 - (1458/10^9)*(1 - 1111*x'[t]^2)/x[t]^2 == 0, x[0] == 1, x'[0] == 0}, x'[t], {t, 0, 100}, AccuracyGoal -> 0, PrecisionGoal -> 0, MaxSteps -> Infinity]; Plot[Evaluate[x'[t] /. sol], {t, 0, 100}] Pasha > What is wrong with this equation? Clear[sol] > f[x_?NumericQ] = 1 - 1111*x'^2; > sol = NDSolve[{x''[t] + (16/10^4)x'[t]^2*Sqr[ > f[x[t]]]/x[ > t]^2 - (1458/10^9)*f[x[t]]/x[t]^2 == > 0, x[0] == 1, x'[0] == 0}, x[t], { > t, 0, 100}, AccuracyGoal -> 8, > PrecisionGoal -> 8, WorkingPrecision - 30, MaxSteps -> Infinity]; > Plot[Evaluate[x'[t] /. sol], {t, 0, 100}] PhD student Pasha Karami Room z.206,Dept. of Earth Sciences Utrecht University Budapestlaan 4 3584 CD Utrecht The Netherlands Tel:+31-30-2537503 === Subject: Re: A simple ordinary differential equation In the definition of f you specify a derivative of f, but Mathematica cannot know that it is supposed to be a dervative with respect to t. And, BTW, Sqr should be Sqrt. A few quick fixes: Clear[sol] f = 1 - 1111*x'[t]^2; sol = NDSolve[{x''[t] + (16/10^4) x'[t]^2* Sqrt[f]/x[t]^2 - (1458/10^9)*f/x[t]^2 == 0, x[0] == 1, x'[0] == 0}, x[t], {t, 0, 100}, AccuracyGoal -> 8, PrecisionGoal -> 8, WorkingPrecision -> 30, MaxSteps -> Infinity] Plot[D[x[t] /. sol, t] // Evaluate, {t, 0, 100}, PlotRange -> All, Frame -> True, Axes -> None > What is wrong with this equation? Clear[sol] > f[x_?NumericQ] = 1 - 1111*x'^2; > sol = NDSolve[{x''[t] + (16/10^4)x'[t]^2*Sqr[ > f[x[t]]]/x[ > t]^2 - (1458/10^9)*f[x[t]]/x[t]^2 == > 0, x[0] == 1, x'[0] == 0}, x[t], { > t, 0, 100}, AccuracyGoal -> 8, > PrecisionGoal -> 8, WorkingPre= cision - 30, MaxSteps -> Infinity]; > Plot[Evaluate[x'[t] /. sol], {t, 0, 100}] === Subject: Re: A simple ordinary differential equation what is wrong with f[x_?NumericQ] = 1 - 1111*x'^2; ? A derivative x' from a numeric value f[x_?NumericQ] what is wrong with Sqr[] is it a miss-typed Sqrt[] or is it a square Sqr[x_]:=x^2 f[x_[t_]] := 1 - 1111*x'[t]^2; sol = NDSolve[{x''[t] + (16/10^4) x'[t]^2* Sqrt[f[x[t]]]/x[t]^2 - (1458/10^9)*f[x[t]]/x[t]^2 == 0, x[0] == 1, x'[0] == 0}, {x[t], x'[t]}, {t, 0, 100}, AccuracyGoal -> 8, PrecisionGoal -> 8, WorkingPrecision -> 30, MaxSteps -> Infinity]; and Plot[Evaluate[x'[t] /. sol], {t, 0, 100}] work fine. Jens > What is wrong with this equation? Clear[sol] > f[x_?NumericQ] = 1 - 1111*x'^2; > sol = NDSolve[{x''[t] + (16/10^4)x'[t]^2*Sqr[ > f[x[t]]]/x[ > t]^2 - (1458/10^9)*f[x[t]]/x[t]^2 == > 0, x[0] == 1, x'[0] == 0}, x[t], { > t, 0, 100}, AccuracyGoal -> 8, > PrecisionGoal -> 8, WorkingPrecision - 30, MaxSteps -> Infinity]; > Plot[Evaluate[x'[t] /. sol], {t, 0, 100}] > === Subject: Re: DeleteCases >{{0, 0, 1, 1}, {0, 0, 2, 2}, {0, 0, 3, 3}, {1, 1, 0, 0}, {1, 1, 2, >2}, {1, 1, 3, 3}, {2, 2, 0, 0}, {2, 2, 1, 1}, {2, 2, 3, 3}, {3, 3, >0, 0}, {3, 3, 1, 1}, {3, 3, 2, 2}} >I need the elements {a,a,b,b} and {b,b,a,a} to be the same, i.e. i >want to delete one of the two occurrences from the list. (or all but >one if the condition is more complicated, say {a,b,c,d} and >{b,a,c,d} or {a,b,c,d} and {a,b,d,c}) How can i do that? Can i use >DeleteCases? if so, what conditional should I use to compare >different elements in the list? Given you are treating {a,a,b,b} the same as {b,b,a,a} I assume it doesn't matter which is saved. That is sorting each to put them into a standard I assume is acceptable. So, In[1]:= data = {{0, 0, 1, 1}, {0, 0, 2, 2}, {0, 0, 3, 3}, {1, 1, 0, 0}, {1, 1, 2, 2}, {1, 1, 3, 3}, {2, 2, 0, 0}, {2, 2, 1, 1}, {2, 2, 3, 3}, {3, 3, 0, 0}, {3, 3, 1, 1}, {3, 3, 2, 2}}; In[2]:= Union[Sort /@ data] Out[2]= {{0, 0, 1, 1}, {0, 0, 2, 2}, {0, 0, 3, 3}, {1, 1, 2, 2}, {1, 1, 3, 3}, {2, 2, 3, 3}} does the trick. If the list has elements with a pattern different than {a,a,b,b} that you want to preserve ordered as they are then Union[data/.{a_,a_,b_,b_}:>Sort[{a,a,b,b}] should work. And if you need to preserve the order in which each sublist appears, use DeleteDuplicates instead of Union === Subject: Re: Using a variable set elsewhere within Manipulate Hello Mathematica users, This message reports back on the answers I got on my previous message Using a variable set elsewhere within a function that has attribute HoldAll, but where HoldAll got cut off from the subject line. The problem was that I wanted to use a variable assigned to a differential equation within Manipulate to dynamically solve it as a parameter in the equation is tweaked. I want to the write the equation outside of Manipulate and use it both within and outside of Manipulate, without having to copy-paste it. This does not work: ode = x'[t] == r x[t] - x[t] ^2; Manipulate[ sol = NDSolve[ {ode, x[0] == 0.1}, x, {t, 0, 10} ]; Plot[x[t] /. sol, {t, 0, 10}, PlotRange -> {0, 1}], {r, 0.1, 1}] First I thought it did not work because of the HoldAll attribute of Manipulate, because I can get some similar bits of code working by wrapping the first argument of Manipulate in Evaluate. For instance x = y; Manipulate[x, {y, 0, 1}] does not work, but then Manipulate[Evaluate[x], {y, 0, 1}] does. An easier way of understanding that the the dynamic ode solving above does not work is by seeing that r in the assignment of ode is not the same r as in the last argument of Manipulate. Two approaches were suggested to me. David (besides giving a nice example of how to use Dynamic instead of Manipulate) made ode a function of r: ode =.; sol =. ode[r_] := x'[t] == r x[t] - x[t] ^2; Manipulate[ sol = NDSolve[ {ode[s], x[0] == 0.1}, x, {t, 0, 10} ]; Plot[x[t] /. sol, {t, 0, 10}, PlotRange -> {0, 1}], {s, 0.1, 1}] Jens used replacement: ode =.; sol =. ode = x'[t] == r x[t] - x[t] ^2; Manipulate[ sol = NDSolve[ {ode /. r -> s, x[0] == 0.1}, x, {t, 0, 10} ]; Plot[x[t] /. sol, {t, 0, 10}], {s, 0.1, 1}] Both work. However, the actual ODE's I want to solve involve many parameters, all of which I want to manipulate. Writing ode1, ode2 etc. as functions of the parameters doesn't look nice, so that is why I prefer Jens' solution with replacement. I am still looking for a nice way to get a list of rules set defined elsewhere to work within Manipulate! ;-) Daan === 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: 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. Especial ff = InterpolatingFunction[{{-1., 2.}}, {3, 3, 0, {136}, {4}, 0, 0, 0, 0}, {{-1., -0.75, -0.5, -0.25, -0.125, 0., 0.125, 0.15625, 0.1875, 0.21875, 0.234375, 0.25, 0.265625, 0.273438, 0.28125, 0.289063, 0.296875, 0.304688, 0.3125, 0.320313, 0.328125, 0.335938, 0.34375, 0.351563, 0.359375, 0.367188, 0.375, 0.382813, 0.390625, 0.398438, 0.40625, 0.414063, 0.421875, 0.429688, 0.4375, 0.445313, 0.453125, 0.460938, 0.46875, 0.476563, 0.484375, 0.492188, 0.5, 0.507813, 0.515625, 0.523438, 0.53125, 0.539063, 0.546875, 0.554688, 0.5625, 0.570313, 0.578125, 0.585938, 0.59375, 0.601563, 0.609375, 0.617188, 0.625, 0.632813, 0.640625, 0.648438, 0.65625, 0.664063, 0.671875, 0.679688, 0.6875, 0.695313, 0.703125, 0.710938, 0.71875, 0.726563, 0.734375, 0.742188, 0.75, 0.757813, 0.765625, 0.773438, 0.78125, 0.789063, 0.796875, 0.804688, 0.8125, 0.820313, 0.828125, 0.835938, 0.84375, 0.851563, 0.859375, 0.867188, 0.875, 0.882813, 0.890625, 0.898438, 0.90625, 0.914063, 0.921875, 0.929688, 0.9375, 0.945313, 0.953125, 0.960938, 0.96875, 0.976563, 0.984375, 0.992188, 1., 1.00781, 1.01563, 1.02344, 1.03125, 1.03906, 1.04688, 1.05469, 1.0625, 1.07031, 1.07813, 1.08594, 1.09375, 1.10156, 1.10938, 1.11719, 1.125, 1.13281, 1.14063, 1.14844, 1.15625, 1.17188, 1.1875, 1.20313, 1.21875, 1.23438, 1.25, 1.5, 1.75, 2.}}, {Developer`PackedArrayForm, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136}, {0., 0., 1.839556450000000*10^-316, 1.21549*10^-159, 2.31335*10^-101, 1.67253*10^-56, 4.5936*10^-25, 2.66022*10^-19, 2.23311*10^-14, 2.71726*10^-10, 1.4528*10^-8, 4.79291*10^-7, 9.75747*10^-6, 0.0000367374, 0.000122606, 0.000362738, 0.000951569, 0.00221421, 0.00457332, 0.00839564, 0.0137329, 0.0201077, 0.0265815, 0.0322166, 0.0367286, 0.0408717, 0.0462177, 0.0544092, 0.0663, 0.0813791, 0.0976722, 0.112228, 0.122235, 0.126523, 0.126732, 0.127295, 0.133834, 0.150431, 0.177017, 0.208434, 0.236308, 0.253376, 0.257998, 0.255774, 0.256824, 0.270362, 0.300085, 0.342984, 0.391402, 0.436275, 0.469696, 0.486402, 0.484727, 0.467353, 0.441479, 0.41775, 0.407822, 0.421313, 0.4633, 0.533418, 0.626979, 0.737778, 0.861279, 0.996289, 1.1438, 1.30339, 1.46955, 1.63063, 1.77232, 1.8848, 1.96966, 2.04154, 2.1219, 2.2277, 2.36187, 2.51091, 2.65028, 2.7539, 2.80324, 2.79347, 2.7351, 2.65062, 2.56727, 2.50909, 2.49206, 2.52399, 2.60708, 2.73955, 2.91432, 3.11604, 3.32016, 3.49681, 3.61939, 3.67374, 3.66173, 3.59611, 3.48923, 3.34377, 3.15256, 2.90785, 2.61315, 2.28878, 1.96732, 1.68224, 1.45678, 1.29843, 1.20019, 1.14535, 1.11267, 1.08029, 1.02917, 0.946603, 0.829484, 0.685201, 0.529164, 0.379515, 0.25137, 0.15301, 0.0852144, 0.0432423, 0.0199185, 0.00829953, 0.00311858, 0.00105388, 0.000319547, 0.0000867615, 0.0000210592, 8.81696*10^-7, 2.32524*10^-8, 3.8403*10^-10, 3.95627*10^-12, 2.53536*10^-14, 1.00878*10^-16, 1.67729*10^-83, 7.17379*10^-204, 0.}}, {Automatic}]; and ff[ValuesOnGrid] gives non numeric output. Jens I generated and saved the following interpolating function (and > wrapper). Whenever I evaluate it, I immediately get a segfault in V7 > and V6. Could someone let me know why this is, why the code that generated it > doesn't segfault, and what I should do to avoid segfault issues in the > future? fn = If[#1 > 0.1 && #1 < > 10^2, (1/(#1 Log[10])) InterpolatingFunction[{{-1., 2.}}, {3, 3, > 0, {136}, {4}, 0, 0, 0, > 0}, {{-1., -0.75, -0.5, -0.25, -0.125, 0., 0.125, 0.15625, > 0.1875, 0.21875, 0.234375, 0.25, 0.265625, 0.273438, 0.28125, > 0.289063, 0.296875, 0.304688, 0.3125, 0.320313, 0.328125, > 0.335938, 0.34375, 0.351563, 0.359375, 0.367188, 0.375, > 0.382813, 0.390625, 0.398438, 0.40625, 0.414063, 0.421875, > 0.429688, 0.4375, 0.445313, 0.453125, 0.460938, 0.46875, > 0.476563, 0.484375, 0.492188, 0.5, 0.507813, 0.515625, > 0.523438, 0.53125, 0.539063, 0.546875, 0.554688, 0.5625, > 0.570313, 0.578125, 0.585938, 0.59375, 0.601563, 0.609375, > 0.617188, 0.625, 0.632813, 0.640625, 0.648438, 0.65625, > 0.664063, 0.671875, 0.679688, 0.6875, 0.695313, 0.703125, > 0.710938, 0.71875, 0.726563, 0.734375, 0.742188, 0.75, > 0.757813, 0.765625, 0.773438, 0.78125, 0.789063, 0.796875, > 0.804688, 0.8125, 0.820313, 0.828125, 0.835938, 0.84375, > 0.851563, 0.859375, 0.867188, 0.875, 0.882813, 0.890625, > 0.898438, 0.90625, 0.914063, 0.921875, 0.929688, 0.9375, > 0.945313, 0.953125, 0.960938, 0.96875, 0.976563, 0.984375, > 0.992188, 1., 1.00781, 1.01563, 1.02344, 1.03125, 1.03906, > 1.04688, 1.05469, 1.0625, 1.07031, 1.07813, 1.08594, 1.09375, > 1.10156, 1.10938, 1.11719, 1.125, 1.13281, 1.14063, 1.14844, > 1.15625, 1.17188, 1.1875, 1.20313, 1.21875, 1.23438, 1.25, > 1.5, 1.75, 2.}}, {Developer`PackedArrayForm, {0, 1, 2, 3, 4, > 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, > 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, > 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, > 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, > 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, > 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, > 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, > 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, > 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, > 133, 134, 135, 136}, {0., 0., 1.839556450000000*10^-316, > 1.21549*10^-159, 2.31335*10^-101, 1.67253*10^-56, > 4.5936*10^-25, 2.66022*10^-19, 2.23311*10^-14, > 2.71726*10^-10, 1.4528*10^-8, 4.79291*10^-7, 9.75747*10^-6, > 0.0000367374, 0.000122606, 0.000362738, 0.000951569, > 0.00221421, 0.00457332, 0.00839564, 0.0137329, 0.0201077, > 0.0265815, 0.0322166, 0.0367286, 0.0408717, 0.0462177, > 0.0544092, 0.0663, 0.0813791, 0.0976722, 0.112228, 0.122235, > 0.126523, 0.126732, 0.127295, 0.133834, 0.150431, 0.177017, > 0.208434, 0.236308, 0.253376, 0.257998, 0.255774, 0.256824, > 0.270362, 0.300085, 0.342984, 0.391402, 0.436275, 0.469696, > 0.486402, 0.484727, 0.467353, 0.441479, 0.41775, 0.407822, > 0.421313, 0.4633, 0.533418, 0.626979, 0.737778, 0.861279, > 0.996289, 1.1438, 1.30339, 1.46955, 1.63063, 1.77232, 1.8848, > 1.96966, 2.04154, 2.1219, 2.2277, 2.36187, 2.51091, 2.65028, > 2.7539, 2.80324, 2.79347, 2.7351, 2.65062, 2.56727, 2.50909, > 2.49206, 2.52399, 2.60708, 2.73955, 2.91432, 3.11604, > 3.32016, 3.49681, 3.61939, 3.67374, 3.66173, 3.59611, > 3.48923, 3.34377, 3.15256, 2.90785, 2.61315, 2.28878, > 1.96732, 1.68224, 1.45678, 1.29843, 1.20019, 1.14535, > 1.11267, 1.08029, 1.02917, 0.946603, 0.829484, 0.685201, > 0.529164, 0.379515, 0.25137, 0.15301, 0.0852144, 0.0432423, > 0.0199185, 0.00829953, 0.00311858, 0.00105388, 0.000319547, > 0.0000867615, 0.0000210592, 8.81696*10^-7, 2.32524*10^-8, > 3.8403*10^-10, 3.95627*10^-12, 2.53536*10^-14, > 1.00878*10^-16, 1.67729*10^-83, 7.17379*10^-204, > 0.}}, {Automatic}][Log[10, #1]], 0] &; > === Subject: Re: Palette Tutorial/training help I surmise that you are a relatively new user of Mathematica? In a number of postings you have suggested changes to the design of Mathematica that I would consider rather marginal, even for you, and more or less just rearrangements of things. New users often want to redesign Mathematica before they have familiarized themselves with how it presently works. For example, a search box just searches the paclet documentation. It is already on documentation center pages. The Function Navigator is only another way to link to documentation pages. Putting a search box in the Function Navigator would only duplicate what is already there. And the documentation page would presumably already be up because that is what you used to get the Function Navigator. The various Assistant palettes might be subject to some redesign if there are enough specific comments from users. I would like to see the DelayedRule and Equal commands in some convenient place on the palettes. (Rather, say, than comma and Set.) I'm always forced to go back to the old BasicInputPalette. It is often useful to create your own paste palettes. You could rather easily learn to do this. Look up ?CreatePalette ?PasteButton If you are a new user, the main thing is to learn the basic syntax and functionality of Mathematica (which takes some time), get help from MathGroup (which is not only free but very good), and try some actual math solo (which is where the fun is). But don't spend a lot of time redesigning Mathematica because it is not only difficult but it has low payoff for any new user. David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ Hi all, I am a disabled person who has trouble with typing. So I really use/ need the palette tools a lot. Although the classroom assistant palette provides a great deal helping me, it needs to be redesigned some for my needs. I had tried tearing it apart but its way too complex to do so. All I am wanting to do is rearrange buttons and panels, and adding a few new buttons. I would be glad to create a picture mock up of the changes for anyone wanting to help me. I live on very limited income so I can't really pay for hire (M7 Home Edition is a belated 50th birthday gift from family/friends). However, if someone created an in depth tutorial how to create/edit palettes than I would gladly roll my own to meet my needs. Yes, I have studied the docs on palettes in M7, and about to work through docs in M6 as suggested to me. But often the docs do not provide enough info to help me. Or, any links to sites that have that level of tutorial. Maybe someone from the User-Interface group at WRI would like to contact me? === Subject: Re: extracting points and projecting However, the mapping given by the original poster is not the correct mapping to the Riemann sphere. I believe it should be: j1[x_, y_] := 2 x/(1 + x^2 + y^2) j2[x_, y_] := 2 y/(1 + x^2 + y^2) j3[x_, y_] := (-1 + x^2 + y^2)/(1 + x^2 + y^2) And why settle for Points when you can have lines? David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ How about: g = ContourPlot[Arg[Gamma[x + I*y]] == 0, {x, -10, 10}, {y, -10, 10}, PlotPoints -> 100] pts = First@Cases[g, x_GraphicsComplex :> First[x]]; j1[x_, y_] := 2 x/(1 + x^2 + y^2)^2 j2[x_, y_] := 2 y/(1 + x^2 + y^2)^2 j3[x_, y_] := (-1 + x^2 + y^2)/(1 + x^2 + y^2) Timing[one = pts /. {x_, y_} :> {j1[x, y], j2[x, y], j3[x, y]};] {0.127167, Null} one // Dimensions {8146, 3} Graphics3D[Point@one] or Timing[two = Outer[#2 @@ #1 &, pts, {j1, j2, j3}, 1, 1];] {0.171188, Null} one == two True Bobby > I would like to extract the points from the following ContourPlot g=ContourPlot[Arg[Gamma[x + I*y]] == 0, {x, -10, 10}, {y, -10, 10}, > PlotPoints -> 100] I can do this with pts = First@Cases[g, x_GraphicsComplex :> First[x]] Then I would like to map this list of points onto the Riemann sphere. > The projection is performed through j1[x_, y_] := 2 x/(1 + x^2 + y^2)^2 > j2[x_, y_] := 2 y/(1 + x^2 + y^2)^2 > j3[x_, y_] := (-1 + x^2 + y^2)/(1 + x^2 + y^2) I need to generate a list of three dimensional points (j1[x,y], j2[x,y], > j2[x,y]) from pts and plot them. I am unable to generate the list of > three dimensional points. Any help is very much appreciated. Cristina > -- DrMajorBob@bigfoot.com === Subject: Re: manipulate, NDSolve, Evaluate Here is my reworked version of your code. I removed your comments and inserted mine indicating the changes. i[t_] := If[t < 10 || t > 60, 0, 1] Plot[i[t], {t, 0, 100}, PlotStyle -> {Red, Thick}] RCSoln1[R_, c_: 1, v0_: 0] = DSolve[{v'[t] == 1/c (i[t] - v[t]/R), v[0] == v0}, v[t], t][[1, 1= , 2]]; (*Removed N, DSolve can do it fine. Picked the v[t] out of the solution using Part. Using Set (=) instead of SetDelayed (:=) means we don't have to use Evaluate in the Plot command. It's often quicker too. *) Plot[RCSoln1[1], {t, 0, 100}, PlotStyle -> {Red, Thick}, MaxRecursion -> 9] (* Now the solution can be used directly. Increased MaxRecursion to improve the plotting of the discontinuity *) RCSoln1a[R_, c_, v0_] = DSolve[{v'[t] == 1/c (i[t] - v[t]/R), v[0] == v0}, v[t], t][[1, 1= , 2]]; (* Same as above. Also removed use of default values here. It would result in ambiguous calling possibilities: in your definition with RCSoln1a[R_: 1,c_,v0_: 0] RCSoln1a[2,3] would have worked, but which variable now gets its default value? Is it RCSoln1a[2,3,0] or RCSoln1a[1,2,3]? The only unambiguous use of default values would be to use them at the end*) Show[ Plot[RCSoln1a[1, 1, 0], {t, 0, 100}, PlotStyle -> {Blue, Thick}, MaxRecursion -> 9], Plot[RCSoln1a[1, 5, 0], {t, 0, 100}, PlotStyle -> {Red, Thick}, MaxRecursion -> 9] ] Manipulate[ Plot[RCSoln1a[R, c, 0], {t, 0, 100}, PlotStyle -> {Blue, Thick}, MaxRecursion -> 9] , {R, 1, 5}, {c, 1, 5}] (* There were so many syntax errors in your version of this line of code that I feel that either you don't have Mathematica 6 or 7, which is required for Manipulate or you have syntax coloring switched off, which you shouldn't do. *) > Here is what I have done so far. (* First is an injected current that is applied to the cell*) > i[t_] := If[t < 10 || t > 60, 0, 1] > (* now to plot the above equation *) > Plot[i[t], {t, 0, 100}, PlotStyle -> {Red, Thick}] > (* The equation for an RC circuit. Note the IC, and that c = 1. *) > RCSoln1[R_, c_: 1, v0_: 0] := NDSolve[{v'[t] == 1/c (i[t] - v[t]= /R), > v[0] == v0}, v, {t, 0, 100}] > (* Now plotting the above equation, and assigning R = 1 *) > Plot[Evaluate[v[t] /. {RCSoln1[1]}], {t, 0, 100}, PlotStyle -> {Red, > Thick}] > (* Now let R = 1, and change the value of the capacitance in the plot t= o > see what differences this makes *) > RCSoln1a[R_: 1, c_, v0_: 0] := NDSolve[{v'[t] == 1/c (i[t] - v[t= ]/R), > v[0] == v0}, v, {t, 0, 100}] > p1 = Plot[Evaluate[v[t] /. {RCSoln1a[1]}], {t, 0, 100}, PlotStyle -= {Blue, Thick}] > p2 = Plot[Evaluate[v[t] /. {RCSoln1a[5]}], {t, 0, 100}, PlotStyle -= {Red, Thick}] > Show[p1, p2] > Now compare the difference in the way the plots look when you change the > R (resistance) vs the c (capacitance). In order for the capacitance to > change like shown. What could cause the changes in the resistance and > the capacitance? ? What I would like is: to use Manipulate with a slider to vary c and > R. I tried to use this equation. NDSolve[{v'[t] == 1/(a*c) (i[t]= - > v[t]/(b*R), v[0] == v0}, v, {t, 0, 100}]. I changed the equation b= y > putting (a*c) and (b*R). Then with the plot I thought I could add: > Manipulate[Plot[Evaluate[v[t] /. {RCSoln1a[1]}], {t, 0, 100}, ,{a, 0, > 5}, (b, 0, 5) > PlotStyle -> {Blue, Thick}]] It did not work. This is just the beginning of the text book that I am writing. Thus I > did not go into the finer details of the soma's wall thickness and how > it changes capacitance. I just wanted to show in a graphic manner what > could happen and illustrate a basic equivalent circuit for a cell > membrane. Later on in the book, I go into more details. Can you help me now? > Prof Jake > If you've already done it for a specific wall thickness it should be > very easy to do the same in a Manipulate for variable thickness > values. Please post more details if you want more specific assistence. > I am trying to combine, NDSolve with a ODE then using Plot[evaluate] t= o >> show the results, and then I would like to take it to the next step an= d >> use Manipulate. > I am working a cell membranes capacitance based on the wall thickness.= = > I would like the plot to show the the membrane voltage vs time,(I have >> done this with NDSolve and Plot), but I would like to use a slider tha= t >> reflects the difference in the cell membranes thickness which affects >> the capacitance. >> Is this possible? >> Prof. Jake === Subject: Re: Integrating package documentation with the documentation center the Wolfram Workbench include everything to make a documentation and it seems that you have just overlooked this excellent Mathematica development tool. Jens >> Although the documentation center (DC) came with version 6.0, there is >> (to my knowledge) still no published method for fully integrating >> package documentation with this system (at least not without using the >> Wolfram Workbench). >> As part of work on my new DebugTrace package, I believe I have uncovered >> the interface mechanism - using commands from the undocumented >> DocumentationSearch` (!!) context. Using these commands, it is possible >> to create documentation which pops up when F1 is pressed inside one of >> your exported symbols, and which appears in searches done within the DC. >> I am not entirely sure if this information is publicly available >> elsewhere, but if it is not, I am happy to write it up and make it >> available to everyone. Please tell me if the knowledge is already availab= > le. >> Needless to say, the information will be at your own risk, and may >> well not expose all available functionality. Since the relevant >> functions are not within a private package, I assume WRI meant this to >> be a public interface! >> David Baileyhttp://www.dbaileyconsultancy.co.uk for the discovery and the work that it took to come up with what > Wolfram neglected to. -Bob > === Subject: Re: Integrating package documentation with the documentation center Yes, this would be very useful if you would be kind enough to do it. I have made some progress using Workbench for this but more information would certainly be welcome, John Jowett > Although the documentation center (DC) came with version 6.0, there is > (to my knowledge) still no published method for fully integrating > package documentation with this system (at least not without using the > Wolfram Workbench). As part of work on my new DebugTrace package, I believe I have uncovered > the interface mechanism - using commands from the undocumented > DocumentationSearch` (!!) context. Using these commands, it is possible > to create documentation which pops up when F1 is pressed inside one of > your exported symbols, and which appears in searches done within the DC. I am not entirely sure if this information is publicly available > elsewhere, but if it is not, I am happy to write it up and make it > available to everyone. Please tell me if the knowledge is already availab= le. Needless to say, the information will be at your own risk, and may > well not expose all available functionality. Since the relevant > functions are not within a private package, I assume WRI meant this to > be a public interface! David Baileyhttp://www.dbaileyconsultancy.co.uk === Subject: Questions about Locators I have two related questions. Assuming the following minimal example where you have a LocatorPane and you count the numbers of update calls: DynamicModule[{pt = {{0, 0}}, c = 0}, Column[{LocatorPane[Dynamic[pt, (pt = #1; c++) & ], Graphics[{Yellow, Rectangle[{0, 0}, {1, 1}]}, PlotRange -> {{0, 1}, {0, 1}}, Frame -> False], LocatorAutoCreate -> True], Dynamic[c], Dynamic[pt]}]] If I move the Locator, the count and the position is updated as expected. When you add a Locator with Alt+Click then you get an update call too as one would expect since pt is dynamically changed. But that is not the case if you delete one Locator with Alt+Click on an existing one. I'm wondering why the variable pt is updated but c variable stays unchanged. Any ideas? What you can see in the above sample is, that when you grab a locator, it is centered under the mouse cursor. If I take another small sample not using a LocatorPane but a Graphics this does not happen. DynamicModule[{x = 0.5, y = 0.5}, Column[{Deploy[Graphics[Locator[Dynamic[{x, y}], LocatorRegion -> Automatic], PlotRange -> {{0, 1}, {0, 1}}]], Dynamic[{x, y}]}]] The intention of the LocatorRegion->Automatic option is to prevent the locator to go outside the given PlotRange. Without success as one can test by grabbing the Locator at one side and not at the center. Is there a way to achieve the same behaviour for a normal Locator as in a LocatorPane? Patrick === Subject: Re: Using manipulate in two cells in one note book crashes my computer. The fact that you're using the variable 'dsol' in both outputs is what's causing the problem. Each time 'dsol' changes, Mathematica wants to update the output. Here's a very simple example of what's going on... Manipulate[n x, {n, 1, 2}] Now, in a separate cell, evaluate 'x=5'. Note that it updates. Set x to something else and it updates again. Now try... Manipulate[x = n, {n, 0, 10}] and drag the slider. Note that it's updating the first Manipulate as well. What you've done is exactly the same, except that each Manipulate triggers the other, causing it to pound the kernel for updated evaluations. It shouldn't be crashing, but the repeated evaluation behavior is the designed behavior. So, you need to either localize 'dsol' (using, e.g., Module, DynamicModule, With), use two different variable names, or not use a variable at all. Now, it turns out that in your case, you could actually save quite a bit of computation here because there's no reason for the DSolve[] to be performed again and again every time you drag your sliders. The output is the same throughout your selected constant ranges. So you could both localize dsol and make your Manipulates more efficient by doing the following... With[{dsol = DSolve[{b''[t] == -k1 k2 b[t] - k1 b'[t], b[0] == b0, b'[0] == bp0}, b[t], t]}, Manipulate[ Plot[Evaluate[b[t] /. dsol], {t, 0, 10}, PlotRange -> All], {k1, 0.1, 10}, {k2, 0.1, 10}, {b0, 0.1, 10}, {bp0, 0.1, 10}]] With[{dsol = DSolve[{k1 k2 b[t] == k1 b'[t] + b''[t], b[0] == b0, b'[0] == bp0}, b[t], t]}, Manipulate[ Plot[Evaluate[b[t] /. dsol], {t, 0, 10}, PlotRange -> All], {k1, 0.1, 10}, {k2, 0.1, 10}, {b0, 0.1, 10}, {bp0, 0.1, 10}]] John Fultz jfultz@wolfram.com User Interface Group Wolfram Research, Inc. > Hello Group. I'm having an awful time with this. I have 2 essentially same codes > using manipulate. Only differences are the ODEs. When I have both of the cells open, the Mathematica goes crazy, with > the cell brackets flashing as if it's evaluating both cells at the > same time. Eventually it will crash or I have to stop it using Alt > +. Is anyone else having the same problem? Here're the cells causing problems. cell 1 Manipulate[dsol=DSolve[{b''[t]==-k1 k2 b[t]-k1 b'[t], b[0]==b0, b'[0] > ==bp0}, b[t], t]; > Plot[Evaluate[b[t]/.dsol],{t, 0, 10},PlotRange-> All], {k1, 0.1, 10}, > {k2, 0.1, 10}, {b0, 0.1, 10}, {bp0, 0.1, 10}] cell 2 Manipulate[dsol=DSolve[{k1 k2 b[t]==k1 b'[t]+b''[t], b[0]==b0, b'[0] > ==bp0}, b[t], t]; > Plot[Evaluate[b[t]/.dsol],{t, 0, 10},PlotRange-> All], {k1, 0.1, 10}, > {k2, 0.1, 10}, {b0, 0.1, 10}, {bp0, 0.1, 10}] > In two separate notebooks, these two cells cause no problems. In the > same notebook, if one of the cells are closed (by double clicking on > the cell bracket), they don't cause problems. It's only when the cells > are both open, the mathematica goes crazy and crashes. Sean === Subject: Re: What's going on here (Table-generated lists)? >I see your point about weird corner cases, but I don't see how >expilcit List detection would cause a problem with speed. It would >have to do it exactly once per call to Plot; it evaluates its >argument, if its Head is a List, then it plots each element of that >list with a different color; if not, then it plots whatever it can >with one color. Are you aware of a case where an explicit list is given to Plot and it plots in a single color? My experience with Plot indicates *everytime* I give Plot an explicit list as in Plot[{a,b,c},{x,0,1}] I get multiple colors. Note, any thing other than {a,b,c ...} isn't an explicit list. Things that evaluate to lists plot in a single color since Plot doesn't see them as lists. === Subject: Re: Using manipulate in two cells in one note book crashes my computer. > By the way, I'm using Mathematica 7.0.0. Windows vista home edition. 32 bit. I also recently updated to Java runtime 6.0 and I had some problems with Mathematica help crashing. So I uninstalled and reinstalled the Mathematica. Also have Mathematica 6.0 installed. (This problem persists in Mathematica 6 also ) I also have another CAS system and other stuff installed on here, but not sure if any of that is an issue. > Mathematica uses its own Java embedded in the installation directories, so the main Java on your machine is not relevant unless you are compiling Java code for use with J/Link. Mathematica 7 uses Java 6. Do use a different context for your two notebooks (when things work OK). The problem is that your variable dsol is shared by the two calculations - so one changes its value, which triggers the other into action..... I solved it my using a Module to localise dsol: Manipulate[ Module[{dsol}, dsol = DSolve[{k1 k2 b[t] == k1 b'[t] + b''[t], b[0] == b0, b'[0] == bp0}, b[t], t]; Plot[Evaluate[b[t] /. dsol], {t, 0, 10}, PlotRange -> All]], {k1, 0.1, 10}, {k2, 0.1, 10}, {b0, 0.1, 10}, {bp0, 0.1, 10}] David Bailey http://www.dbaileyconsultancy.co.uk === Subject: Re: Using manipulate in two cells in one note book crashes my > By the way, I'm using Mathematica 7.0.0. Windows vista home edition. 32 b= it. I also recently updated to Java runtime 6.0 and I had some problems wit= h Mathematica help crashing. So I uninstalled and reinstalled the Mathemati= ca. Also have Mathematica 6.0 installed. (This problem persists in Mathematic= a 6 also ) I also have another CAS system and other stuff installed on here, but not= sure if any of that is an issue. > What is happening is that you have global parameters that are being used by both Manipulates (eg: dsol). When it is changed in one Manipulate it also changes in the other, which itself changes the parameter(s) and this goes back and forth. So you need to make sure that **all** parameters in a Manipulate are local to that Manipulate. --David === Subject: Re: Using manipulate in two cells in one note book crashes my Hi Sean, Since both plots and manipulates use the same global variables they will interact continuously if they are visible in the same notebook. Use DynamicModule to localize the variables and shield them from each other. Like this: DynamicModule[{k1, k2, b0, bp0, dsol, b}, Manipulate[ dsol = DSolve[{k1 k2 b[t] == k1 b'[t] + b''[t], b[0] == b0, b'[0] == bp0}, b[t], t]; Plot[Evaluate[b[t] /. dsol], {t, 0, 10}, PlotRange -> All], {k1, 0.1, 10}, {k2, 0.1, 10}, {b0, 0.1, 10}, {bp0, 0.1, 10}]] > Hello Group. I'm having an awful time with this. I have 2 essentially same codes > using manipulate. Only differences are the ODEs. When I have both of the cells open, the Mathematica goes crazy, with > the cell brackets flashing as if it's evaluating both cells at the > same time. Eventually it will crash or I have to stop it using Alt > +. Is anyone else having the same problem? Here're the cells causing problems. cell 1 Manipulate[dsol=DSolve[{b''[t]==-k1 k2 b[t]-k1 b'[t], b[0]==b0,= b'[0] > ==bp0}, b[t], t]; > Plot[Evaluate[b[t]/.dsol],{t, 0, 10},PlotRange-> All], {k1, 0.1, 10}, > {k2, 0.1, 10}, {b0, 0.1, 10}, {bp0, 0.1, 10}] cell 2 Manipulate[dsol=DSolve[{k1 k2 b[t]==k1 b'[t]+b''[t], b[0]==b0, = b'[0] > ==bp0}, b[t], t]; > Plot[Evaluate[b[t]/.dsol],{t, 0, 10},PlotRange-> All], {k1, 0.1, 10}, > {k2, 0.1, 10}, {b0, 0.1, 10}, {bp0, 0.1, 10}] In two separate notebooks, these two cells cause no problems. In the > same notebook, if one of the cells are closed (by double clicking on > the cell bracket), they don't cause problems. It's only when the cells > are both open, the mathematica goes crazy and crashes. > Sean === Subject: Re: Using manipulate in two cells in one note book crashes my computer. You use th same updated global variable in the two Manipulate[] and you are wondering why the change in one Manipulate[] also cause to change the second Manipulate[] ,re-cause the change in the first, cause the change in the second .. and so on. Use clean conde with local variables and: Module[{dsol, b, k, b0, bp0, t}, dsol = DSolve[{b''[t] == -Subscript[k, 1] Subscript[k, 2] b[t] - Subscript[k, 1] b'[t], b[0] == b0, b'[0] == bp0}, b[t], t][[1]]; Manipulate[ Plot[Evaluate[ b[t] /. dsol /. {Subscript[k, 1] -> k1, Subscript[k, 2] -> k2, b0 -> [ScriptB]0, bp0 -> [ScriptB]p0}], {t, 0, 10}], {k1, 0.1, 10}, {k2, 0.1, 10}, {[ScriptB]0, 0.1, 10}, {[ScriptB]p0, 0.1, 10}] ] works fine. Jens > By the way, I'm using Mathematica 7.0.0. Windows vista home edition. 32 bit. I also recently updated to Java runtime 6.0 and I had some problems with Mathematica help crashing. So I uninstalled and reinstalled the Mathematica. Also have Mathematica 6.0 installed. (This problem persists in Mathematica 6 also ) I also have another CAS system and other stuff installed on here, but not sure if any of that is an issue. > === Subject: Re: HoldAll for Integrate Hi Szabolcs, it would not be very hard to check if we have a definite Integral. Daniel >> Hi Tammo, >> >> what Integrate really does can only somebody from Wolfram explain. But >> it completely eludes me why the integration variable in Integrate is >> not localized. Maybe some can give a reason for this. >> > > Hello Daniel, > > It does not make any sense to localize the integration variable inside Integrate because the result may contain the integration variable (in case of indefinite integrals). > > However, it might be argued that it is a bad idea to use the same syntax colouring for the integration variable that is used for localized variables (e.g. in Table), as this will make it impossible to tell from the colouring whether the variable has a value. > > > > -- Daniel Huber Metrohm Ltd. Oberdorfstr. 68 CH-9100 Herisau Tel. +41 71 353 8585, Fax +41 71 353 8907 E-Mail: Internet: === Subject: Optimization question. I have a very complicated objective function calculated using a recursion. It is straightforward to compute the gradient as the function is computed. How to I tell Mathematica that when it needs the gradient, it must calculate the objective first? Alternatively, is there a way to tell whether the objective has just been evaluated and tell Mathematica to use one program for the gradient if the objective has just been called with the same parameter values and another if it was called in a previous iteration or sub iteration, e.g. with different parameters. Maybe it is in the documentation somewhere but I could not find it. Greg Duncan === Subject: Footnotes, Endnotes in Mathematica All, I am trying to converge on a single tool for my analysis, development, and publication work. Mathematica is great at the first 2, and Publicon seems like an interesting tool for the third. Unfortunately my test drive of Publicon indicates that there is no easy way to merge the two. So for now I am sticking to Mathematica and brute focing stylesheets, etc. I can ot for the life of me figure out how to do footnotes or endnotes in Mathematica !! I have searched every source I can think of nad the only useful references are to using Publicon. Any Ideas, hints, etc, greatly appreciated!! Dr. Robert P. Yerex, Ph.D., MBA Chief Economist Kronos Incorporated tel: 503 596 5015 www.kronos.com === Subject: Re: Footnotes, Endnotes in Mathematica > I am trying to converge on a single tool for my analysis, development, > and publication work. Mathematica is great at the first 2, and Publicon > seems like an interesting tool for the third. Unfortunately my test > drive of Publicon indicates that there is no easy way to merge the two. > So for now I am sticking to Mathematica and brute focing stylesheets, > etc. I can ot for the life of me figure out how to do footnotes or > endnotes in Mathematica !! I have searched every source I can think of > nad the only useful references are to using Publicon. Dr. Robert P. Yerex, Ph.D., MBA > Chief Economist > Kronos Incorporated What mode(s) or form(s) of publication are you trying to generate? Although opinions differ, for some of us who want to submit journal generated in Mathematica with material obtained or generated elsewhere, or repurpose or reuse parts or elements from publications generated earlier into new publications, the best way still seems to be to Export material (graphics, tables, etc.) that can best (or only) be prepared in Mathematica from Mathematica into PDF or other formats, and then use TeX, LaTeX, Word, Pages, PowerPoint, or any of the numerous other tools that are designed to be publication tools as your publication tools. === Subject: Cloud computing Has anyone heard an update on WRI's Cloud Computing initiative? Mark === Subject: Using StringReplace to replace a regex containing newlines Check out the following question and answer: http://stackoverflow.com/questions/703153/mathematica-stringreplace It seems to me that that's a bug in Mathematica's regular expression engine. === Subject: How to use R within Mathematica I would like to use functions from some R libraries within Mathametica. I have seen that there exists a software called RLink but it is not readily available. Is the way to go to use the R functionaly in C/C++ and then use MathLink to call the C/C++ functions? === Subject: Deleting entire row and/or column I have large matrices having entire rows and/or columns of zeros and I want to delete those zero rows and columns. My question, what is the best (most compact) command to use in Mathematica. Please note that the value of zero is the real zero i.e 0.0000 not just 0. === Subject: Re: Deleting entire row and/or column I would suggest to introduce some cutoff epsilon, so that if the total of any row or column is less than epsilon, the row(column) is considered zero. This will speed up things considerably. Consider a test random matrix: In[1] = testMatrix = {{0.0000273478, 0.00003388, 17., 12.0001, 7.00002, 12.0001}, {0.0000192929, 0.0000107438, 0.0000910806, 0.0000370966, 0.000055372, 0.0000476642}, {0.0000649353, 0.0000388735, 17., 18., 18., 18.}, {0.0000503573, 0.0000859998, 0.0000592802, 0.000086099, 0.0000915784, 8.01093*10^-6}}; (I made the small (zero) elements relatively large to avoid messy input). If you set up epsilon = 0.001, then rows 2,4 are zeros, as well as columns 1,2. Here is then the code for the function that does what you want: In[2] = removeZeros[matr_, epsilon_] := Nest[Transpose@Select[#, Total[Abs[#]] > epsilon &] &, matr, 2]; In[3] = removeZeros[testMatrix, 0.001] Out[3] = {{17., 12.0001, 7.00002, 12.0001}, {17., 18., 18., 18.}} If you need to delete only rows, use Select[#, Total[Abs[#]] > epsilon &] &@matr in the above definition, while if you need to delete only columns, use Transpose[Select[#, Total[Abs[#]] > epsilon &] &@Transpose[matr]] By making epsilon as small as you wish, you should be able to get what you need. At the same time, this solution will have a near linear complexity in the maximal matrix dimension (for the matrices not enormously large), while if you would test element by element, you will end up with roughly quadratic complexity. Leonid I have large matrices having entire rows and/or columns of zeros and I > want to delete those zero rows and columns. My question, what is the > best (most compact) command to use in Mathematica. Please note that > the value of zero is the real zero i.e 0.0000 not just 0. === Subject: Re: Deleting entire row and/or column newmatrix = Nest[Transpose@Select[#,#.#>0&]&,oldmatrix,2] I have large matrices having entire rows and/or columns of zeros and I > want to delete those zero rows and columns. My question, what is the > best (most compact) command to use in Mathematica. Please note that > the value of zero is the real zero i.e 0.0000 not just 0. > === Subject: Re: Deleting entire row and/or column I have large matrices having entire rows and/or columns of zeros and I > want to delete those zero rows and columns. My question, what is the > best (most compact) command to use in Mathematica. Please note that > the value of zero is the real zero i.e 0.0000 not just 0. > matKill0[m_?MatrixQ] := Part[m, Pick[Range@Length[m], Equal[0, ##] & @@@ m, False], Pick[Range@Length@First[m], MapThread[Equal[0, ##] &, m], False]]; === Subject: Interpolation: Method->Spline does anybody know what sort of splines Wolfram choose to implement. One would assume that normal splines are the thing to do, but the second derivative is not zero at the ends as the following shows: d = Table[RandomReal[{-1, 1}], {5}] f = Interpolation[d, Method -> Spline]; Plot[f[x], {x, 1, Length[d]}, Epilog -> Point[Transpose[{Range[Length[d]], d}]]] Plot[f'[x], {x, 1, Length[d]}] Plot[f''[x], {x, 1, Length[d]}] Daniel === Subject: Re: pdf export problem > * Graphics that involve transparency may need to be printed as > high-resolution bitmaps. So, this last one is what I meant. And, from my experience, is true. Printing isn't quite the same thing as exporting to PDF. The PDF format supports transparency. Mathematica produces PDF files with transparency. These files can be displayed correctly on screen. Anything that is printed is rasterized at some point (whether that's explicitly done by Mathematica, the printer driver, or the printer itself is irrelevant). There are other reasons why Mathematica may rasterize a graphic saved to a PDF file (VertexColors), depending on your preferences settings. -Rob === Subject: Re: pdf export problem Hi Rob: My comments are below.... > A couple of things: > [1] For obvious reasons, transparency doesn't work well, but if you > save using the bitmap that will solve that problem. Perhaps these reasons are less obvious than you think. Transparent > graphics export to PDF fine for me. Could you explain what you mean > by this? I can only comment on this one, the posting below from someone else. Opacity Opacity[a] is a graphics directive which specifies that graphical objects which follow are to be displayed, if possible, with opacity a. Opacity[a, color] uses the specified color with opacity a. MORE INFORMATION * Opacity runs from 0 to 1, with 0 representing perfect transparency. * If an opacity a object with color c1 is placed in front of an object with color c2, the resulting color will be the blend ac1+(1-a) c2. * If red and blue with opacity 0.5 are combined, the result is purple=97not black, as it would be with physical monochromatic filters. =BB * Opacity works in both 2D and 3D graphics. * It may take significantly longer to render 3D graphics that involve transparent surfaces. * Graphics that involve transparency may need to be printed as high-resolution bitmaps. So, this last one is what I meant. And, from my experience, is true. t. === Subject: Help to define linked domains for variables am a very basic user of Mathematica and I have found the following [Eth]òïâìåí[RegisteredTra demark] have a function where I need to define for the variable $B&E(B, $B&E!l(B and z ôèfollowing relations ¤Â.a6Ũ $B!](B1 if z < 0; ¤Â.a6Ũ 0 if z = 0; ¤Â.a6Ũ 1 if z > 0 ¤Â.a6Å¡ì25 0 $B!](B1 if r $B!](B a < 0; ¤Â.a6Ũ 0 if r $B!](B a = 0; ¤Â.a6Ũ 1 if r $B!](B a > 0 Ôèáîëó éî áäöáîãfor any help Óèáù === Subject: Update to Hinton Button/palette tutorial for Mathematica 7? P.J. Hinton's How To Create Buttons notebook reports problems when opening in Mathematica 7. What is best way to address the errors reported and how to fix them. === Subject: Re: Importing data with comma as decimal separator Dom > Dom, something like Import[filename,TSV,NumberPoint->,] works fine for me most of the time. Yves > I would like to import two-column numerical data in which comma is > used as decimal separator. The first 12 lines of the file is header, > followed by two tab-separated columns of numbers. > How I can do this in Mathematica 6.0? - Show quoted text - === Subject: A simple ordinary differential equation What is wrong with this equation? Clear[sol] f[x_?NumericQ] = 1 - 1111*x'^2; sol = NDSolve[{x''[t] + (16/10^4)x'[t]^2*Sqr[ f[x[t]]]/x[ t]^2 - (1458/10^9)*f[x[t]]/x[t]^2 == 0, x[0] == 1, x'[0] == 0}, x[t], { t, 0, 100}, AccuracyGoal -> 8, PrecisionGoal -> 8, WorkingPrecision -> 30, MaxSteps -> Infinity]; Plot[Evaluate[x'[t] /. sol], {t, 0, 100}] === Subject: Re: eliminate x I'm not certain at what level of experience you are asking this question. Nor do I know how to pick out the lowest exponent of x, other than 0. But, for your particular case you could use pure functions to manipulate the equation step by step. (Look up Function in Help.) Here it is in gory detail with annotation: Print[Starting equation] x*x + x + 5 + 8*x*x*x == 0 Print[Subtract x from both sides] # - x & /@ %% Print[Multiply both sides by -1] Minus /@ %% Print[Reverse the equation] Reverse[%%] David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ I have simple equation x*x+x+5+8*x*x*x=0 and I would like to eliminate from this equation x but in this way to recaive x=- x*x-8*x*x*x-5. So the x with the lowest power is always on tle left site. Magdalena === Subject: eliminate x I have simple equati