A120 === Subject: Re: Mathematica Player Pro! >I hope that Wolfram Research will make Player Pro free. I can't see Wolfram doing this although I would like to be wrong. Mathematica packages and notebooks are text. If the player could properly display any valid Mathematica code and allow for interactivity, making the player free would be tantamount to making Mathematica free since I could use any text editor to create the package/notebook. Admittedly, this would not be nearly as convenient or pleasant as using the front end. But it seems like it would work. === Subject: function not evaluating question tia sal2 function not evaluating question tia sal2 I trying to evaluate this function to a numerical value but it doesn;t seem to work I replace the expression with t sin t and it works what am I doing wrong? In[240]:= f = Function[{t}, 0.680232 Cos 6.28319 [t]] Out[240]:= Function[{t}, 0.680232 Cos 6.28319[t]] In[241]:= Evaluate [f[2.5]] Out[241]:= 0.680232 Cos 6.28319[2.5] Why am I not getting a numerical value? tia sal2 === Subject: Re: function not evaluating question tia sal2 > I trying to evaluate this function to a numerical value but it doesn;t > seem to work I replace the expression with t sin t and it works what > am I doing wrong? In[240]:= f = Function[{t}, 0.680232 Cos 6.28319 [t]] > Out[240]:= Function[{t}, 0.680232 Cos 6.28319[t]] f = Function[{t}, 0.680232 Cos [6.28319 t]] f[2.5] yields -0.680232 I suspect you may want: f2 = Function[{t}, 0.680232 Cos [2 Pi t]] f2[2.5] also yields -0.680232 but is not numerically = to f[2.5] === Subject: Re: function not evaluating question tia sal2 you should try to read the manual and learn to set the brackets on the right positions: f = Function[{t}, 0.680232 Cos[ 6.28319 t]] Jens > function not evaluating question tia sal2 > > > I trying to evaluate this function to a numerical value but it doesn;t > seem to work I replace the expression with t sin t and it works what > am I doing wrong? > > In[240]:= f = Function[{t}, 0.680232 Cos 6.28319 [t]] > Out[240]:= Function[{t}, 0.680232 Cos 6.28319[t]] > > > In[241]:= Evaluate [f[2.5]] > Out[241]:= 0.680232 Cos 6.28319[2.5] > > Why am I not getting a numerical value? tia sal2 > === Subject: Re: function not evaluating question tia sal2 > function not evaluating question tia sal2 > > > I trying to evaluate this function to a numerical value but it doesn;t > seem to work I replace the expression with t sin t and it works what > am I doing wrong? > > In[240]:= f = Function[{t}, 0.680232 Cos 6.28319 [t]] > Out[240]:= Function[{t}, 0.680232 Cos 6.28319[t]] > > > In[241]:= Evaluate [f[2.5]] > Out[241]:= 0.680232 Cos 6.28319[2.5] > > Why am I not getting a numerical value? tia sal2 > It seems you have misplaced a square bracket. (Note that Evaluate is not required here.) In[1]:= f = Function[{t}, 0.680232 Cos[6.28319 t]]; f[2.5] Out[2]= -0.680232 -- === Subject: Sorting 3 points Simple question, but documentation is no help. I have three coordinate triplets: P1={x1,y1,z1} P2={x2,y2,z2} P3={x3,y3,z3} where all entries are numeric. I wont to sort them into P1s={xs1,ys1,zs1} P2s={xs2,ys2,zs2} P3s={xs3,ys3,zs3} so that zs3>=zs2>=zs1, with one command {P1s,P2s,P3s}=Sort[{P1,P2,P3}, Ordering Function] Is that possible and if so, which Ordering Function === Subject: Re: Sorting 3 points correctly under versions 4 and 5 (that is important for code to be downloaded for my remote course offerings) is #1[[3]] <= #2[[3] & Last[] changed syntax under 6.0. === Subject: Re: Sorting 3 points Last[] changed syntax under 6.0. > No, it did not. According to the docs it hasn't changed since version 1 (though I have not used earlier versions than 4, so I have no first hand experience with them). === Subject: Re: Sorting 3 points > Simple question, but documentation is no help. > I have three coordinate triplets: =9AP1={x1,y1,z1} =9A =9A =9AP2={x2,y2,z2} =9A =9A =9AP3={x3,y3,z3} where all entries are numeric. I wont to sort them into =9AP1s={xs1,ys1,zs1} P2s={xs2,ys2,zs2} P3s={xs3,ys3,zs3} so that zs3>=zs2>=zs1, with one command =9A =9A{P1s,P2s,P3s}=Sort[{P1,P2,P3}, Ordering Function] Is that possible and if so, which Ordering Function The simplest solution is to use SortBy {P1s,P2s,P3s}=SortBy[{P1,P2,P3},#[[3]]&] or {P1s,P2s,P3s}=SortBy[{P1,P2,P3},Last] === Subject: Re: Sorting 3 points > Simple question, but documentation is no help. > I have three coordinate triplets: > > P1={x1,y1,z1} P2={x2,y2,z2} P3={x3,y3,z3} > > where all entries are numeric. I wont to sort them into > > P1s={xs1,ys1,zs1} P2s={xs2,ys2,zs2} P3s={xs3,ys3,zs3} > > so that zs3>=zs2>=zs1, with one command > > {P1s,P2s,P3s}=Sort[{P1,P2,P3}, Ordering Function] > > Is that possible and if so, which Ordering Function Well, this is pretty simple if you read what an ordering function is ... Sort[list, Last[#1] < Last[#2] &] (Or if you have Mathematica 6, just use SortBy[list, Last]) Perhaps the missing piece was constructing anonymous functions? Read the doc page of Function for an explanation (#1, #2 are the first and second arguments of the function). === Subject: Re: Sorting 3 points Sort[{P1,P2,P3}, Last[#1] Simple question, but documentation is no help. > I have three coordinate triplets: > > P1={x1,y1,z1} P2={x2,y2,z2} P3={x3,y3,z3} > > where all entries are numeric. I wont to sort them into > > P1s={xs1,ys1,zs1} P2s={xs2,ys2,zs2} P3s={xs3,ys3,zs3} > > so that zs3>=zs2>=zs1, with one command > > {P1s,P2s,P3s}=Sort[{P1,P2,P3}, Ordering Function] > > Is that possible and if so, which Ordering Function > === Subject: Re: Sorting 3 points > Simple question, but documentation is no help. > I have three coordinate triplets: > > P1={x1,y1,z1} P2={x2,y2,z2} P3={x3,y3,z3} > > where all entries are numeric. I wont to sort them into > > P1s={xs1,ys1,zs1} P2s={xs2,ys2,zs2} P3s={xs3,ys3,zs3} > > so that zs3>=zs2>=zs1, with one command > > {P1s,P2s,P3s}=Sort[{P1,P2,P3}, Ordering Function] > > Is that possible and if so, which Ordering Function The pure function (Last@#2 > Last@#1) & seems to be a good candidate. For instance, P1 = {1, 2, 3}; P2 = {3, 1, 2}; P3 = {2, 3, 1}; Sort[{P1, P2, P3}, (Last@#2 > Last@#1) &] (* Any Version *) SortBy[{P1, P2, P3}, Last] (* Version 6.0 and above *) {{2, 3, 1}, {3, 1, 2}, {1, 2, 3}} {{2, 3, 1}, {3, 1, 2}, {1, 2, 3}} -- === Subject: Re: ? Hello AES, I believe mathematica is doing something sensible here. It has scaled your graphics so that your print statement produces objects of about the same size. I believe this is true in 5.0 as well. To get what you want with Print, you could specify that you want a large graphics object, viz: p = Plot[Sin[x], {x, 0, Pi}, ImageSize -> Large] Print[text, p] (*should also work in 5.0*) However, I believe what you might want would be better if you used Grid (6.0), or used Inset(6.0), or used FrameLabel->text in your plot (5.0) > Print[Plot[---]]; > Print[Some textn, Plot[---]]; > * This is documented --or better, warned about -- where? (since it looks like I'll have to, once again, step aside from > attempting to accomplish anything useful with 6.0 and > burn up more time digging into its arcane documentation, > trying to understand this. Apologies for the sarcasm -- > but that's the way it feels.) -- W. Craig Carter === Subject: Re: DifferenitalD vs CapitalDifferenitalD > After applying Jens correction, I was hoping to be able to use the > DifferentialD with x, etc. and then use the 'dx' , where 'd' here is > DifferentialD (just dont know how to add it here in the email), so it > would be a Symbol....but this didnt work....I realize I can use the > straight forward dx , etc. symbol but I want to highlight the > Differential....any way to 'fix' this?....when I type in DifferentialD > , from the Palette, and then add x to it and perform //Head on it , it > just returns DifferentialD > > thank you....jerry blimbaum > [DifferentialD]x cannot be used as a symbol because [DifferentialD] is treated as an operator. A symbol name must start with a letter. But why do you want to use [DifferentialD]x as a symbol anyway? I cannot imagine any reasonable application for this. If you explained your motivation for wanting to have a symbol with this name, perhaps we could say something more useful ... === Subject: Re: DifferenitalD vs CapitalDifferenitalD > After applying Jens correction, I was hoping to be able to use the = > DifferentialD with x, etc. and then use the 'dx' , where 'd' here is = > DifferentialD (just dont know how to add it here in the email), so it = > would be a Symbol....but this didnt work....I realize I can use the = > straight forward dx , etc. symbol but I want to highlight the = > Differential....any way to 'fix' this?....when I type in DifferentialD = > , from the Palette, and then add x to it and perform //Head on it , it = > just returns DifferentialD Hi Jerry, The behavior you have noticed is perfectly normal since the built-in function *DifferentialD[]*, which can also be entered as |esc|dd|esc| (i.e. the escape key followed by the character lowercase d twice followed by the escape key again), is a *compound operator with built-in meaning*. The full form of a complete expression with *DifferentialD[]* is DifferentialD[some_expression] (one argument is required). For instance, say we enter the expression |esc|dd|esc|z Its full form is And its head is Thus, one cannot manipulate double struck lowercase d independently. Now, if you are interested by the above character without built-in meaning, you can get it with the following sequence of keys: |esc|dsd|dsd| Note that dsd stands for double struck lowercase d. Similarly, you can get a double struck capital C by entering |esc|dsC|esc| Finally, enter and evaluate the following sequences of keystrokes: |esc|int|esc|z |esc|dsd|esc|z |esc|int|esc|z |esc|dd|esc|z They look the same. However, the first expression generates an error message, while the second returns the expected definite integral. -- === Subject: Mathematica SIG (Washington DC Area) The Washington D.C. area Mathematica Special Interest Group will meet Friday, 25 April, 7:30 to 9:00 a.m. at the SAIC Enterprise Center building in Tysons Corner (see directions below). Early risers meet before 7:00 in the morning for admission at the front desk, then we have a Dutch treat breakfast downstairs. By about 7:30 we have moved to one of the classrooms. Meetings consist of prepared talks, informal discussion about Mathematica programming and applications, general questions, and new business. Here are the prepared talks: Speaker #1. Mel Friedman will discuss five mini-topics: a. Tradeoffs Between Calculating With Real and Exact Numbers b. Analytical Convolution Integral, Analytical Fourier Transform and Inverse Fourier Transform c. Fourier and Inverse Fourier Transforms With Delta Functions d. Numerical Integration of a Discretely Sampled Function e. Least Squares Fit of Discretely Sampled Function Speaker #2. Harry Bishop will discuss our evolving MathSIG group site (and what else we might do with it) and the present static (DC-SIG) site. Speaker #3. Dan Martinez may present another (as he calls it) harangue about Manipulate. If that's haranguing, then we need more of it! To inquire about attending, e-mail Dan Martinez (dmartinez@sprintmail.com) or Bruce Colletti (bcolletti@compuserve.com). In your e-mail subject line, please include 'Mathematica SIG.' A SIG representative will meet you in the lobby. Please arrive no later than ten minutes to seven if you wish to join us for breakfast, and no later than twenty after seven to attend the meeting only. The desk officer will ask for a driver's license before issuing a visitor's badge. === Subject: Re: Mathematica Player Pro! >Why not go even further and try to convince Dell and Apple, > and any other OEM, to sell the computers with Mathematica Player Pro > preloaded, just as they now come preloaded with Acrobat Reader? > hi David; I mentioned the same exact idea on here on may 9 2007 around when the free player came out . http://forums.wolfram.com/mathgroup/archive/2007/May/msg00268.html If Wolfram research can make a deal with the likes of Dell/Compaq, etc... to have the MathPlayer preinstalled in new PC's sold, then the problem with the large size of the player will no longer exist. I noticed that a new PC's from DELL nowadays, that it has adobe reader already installed on the desktop. So, I agree, it is a good idea :) Nasser === Subject: Wolfram User Interface Research? My understanding is that at least some vendors of larger software apps do a substantial amount of research into how users interact with their products -- e.g., they set up experiments in test rooms where they observe, record, and/or videotape how ordinary users perform various typical tasks using their products -- how they approach them, what mistakes they frequently make -- and try to interpret from these observations what mental constructs these users seem to be working under, why they make the mistakes they make and so on. A curiosity based question along this line for Wolfram: If one examined a bunch of notebooks generated by some representative set of users, I particularly wonder what would be the relative frequency of use for all of the numerous non-alphabetic operators in Mathematica? -- that is, all the innumerable codings like . . @ -> & @ @@ @@@ * << % and on. Which of these are frequently used, which are very seldom used, by different classes of users? (And which are most frequently misused or lead to errors when used?) One might of course ask the same thing about many of the alphabetically named computational and display commands in Mathematica (There are more than 1000 of these, is that not so?) Seems like data like this could not only improve the product but provide some really useful guidance for what to focus on in the development of manuals, tutorials, and other documentation for new or less experienced users (assuming, of course, that Wolfram will ever again have any interest in providing this kind of documentation) (sorry, couldn't resist that jab). === Subject: Re: Wolfram User Interface Research? On 2008-04-21 16:53:24 +0930, AES said: > If one examined a bunch of notebooks generated by some representative > set of users, I particularly wonder what would be the relative frequenc= y > of use for all of the numerous non-alphabetic operators in Mathematica? > -- that is, all the innumerable codings like . . @ -> & = @ > @@ @@@ * << % and on. When I started learning Mathematica, I was a little confused about how to start with all of these. I really liked the conciseness they give to expressions, but it can be tempting to chain inscrutiably long commands together and create an unreadable mess --- but of course, if you did exactly the same thing with the FullForm equivalents then the result would be just as hard to read, if not more so. One of the biggest things I've noticed is that I like using @ a lot more than I thought I would. At first, I thought that consistency would be better and everything should be nested brackets: Sort[Flatten[OptionValue[myopt]]] or whatever. But Sort@Flatten@OptionValue@myopt is much easier to type and removes the need to count brackets. And I've loved being able to tack on a //N (or whatever) to the end of expressions from the first time I saw Mathematica's postfix notation. Just a couple of thoughts :) Will === Subject: Re: Wolfram User Interface Research? This comment about APL is quite wrong: nothing compelled you to write inscrutable single line programs (except maybe in the earliest days, when one was sending single lines over a telephone line to a mainframe, then waiting for your instruction's turn to get its slice of time and have the result sent back and typed at your terminal). With APL then, and with IBM's APL2 now, you MAY, if you wish, write overly condensed one-liners. And indeed some APL programmers aimed to write as concise a program, all in one line, as they could possibly do. But what some folks regard as inscrutable, others read with ease. It's like saying that if one doesn't understand Chinese, then a couple of pictograms form an inscrutable text, whereas somebody who does understand Chinese finds it wholly scrutable. What's more, many of the combinations of symbols in APL were instantly recongnizable to any APL programmer as so-called idioms. The delight of APL was, and is, that many very complicated things can, in fact, be expressed quite concisely, in a way that the suggestive graphic symbols of APL help one understand. In fact, one could maintain that, despite the power of its pattern-matching, functional programming constructs, and list-handling abilities, Mathematica programs can be MUCH more difficult to understand than corresponding APL program -- because the Mathematica programs use all those, often long, words, and because they force one to pay close attention to order of precedence and to insert nested brackets. It's really all a matter of what one has learned, and how well, and how accustomed one is to the language. As just one rather simple-minded example, suppose you want to form the running cumulative sum of a list (in APL-speak, a vector) of numbers. In APL, this is given by + vec (and generalizes from to other binary operations). In Mathematica 5 and earlier, Rest[FoldList[Plus,0,vec]] (also generalizable) and in Mathematica 6, Accumulate[vec] (a special function that's no longer generalizable). The APL notation is related to the APL notation for summing a list, +/vec (which is also generalizable); the Mathematica analog is, of course: Plus @@ vec I think one would have a hard time proving that +/vec is more difficult to read, especially at a glance, than Plus @@ vec -- or even Total[vec]. When I see +/vec, I immediately think, add up the entries in vec. I cannot speak knowledgeably of the current situation with APL2, but for many years APL programmers were incredibly productive compared with those programming in just about all other standard computer languages. It's not for no good reason that, for example, major financial analysis systems and reservations systems were written in APL (and some still are, or at least in offshoots from the APL trunk). > >> it can be tempting to chain inscrutiably long commands >> together and create an unreadable mess --- > > As was the case, oldtimers will recall, with IBM's APL (A Programming > Language), which allowed you -- in fact, more or less compelled you -- > to write incredibly powerful, but totally inscrutable single line > programs, leading to the now classic phrase Write once -- read never, > since one day later even the original coder couldn't figure out how his > or her code worked. > > >> together and create an unreadable mess --- but of course, if you did >> exactly the same thing with the FullForm equivalents then the result >> would be just as hard to read, if not more so. > > Don't agree with you on this -- but nonetheless will take your further > comment to heart and go off and finally learn how to use @ . > -- 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: Wolfram User Interface Research? > it can be tempting to chain inscrutiably long commands > together and create an unreadable mess --- As was the case, oldtimers will recall, with IBM's APL (A Programming Language), which allowed you -- in fact, more or less compelled you -- to write incredibly powerful, but totally inscrutable single line programs, leading to the now classic phrase Write once -- read never, since one day later even the original coder couldn't figure out how his or her code worked. > together and create an unreadable mess --- but of course, if you did > exactly the same thing with the FullForm equivalents then the result > would be just as hard to read, if not more so. Don't agree with you on this -- but nonetheless will take your further comment to heart and go off and finally learn how to use @ . === Subject: Re: Wolfram User Interface Research? On 2008-04-22 04:08:34 +0930, AES said: >> together and create an unreadable mess --- but of course, if you did >> exactly the same thing with the FullForm equivalents then the result >> would be just as hard to read, if not more so. Don't agree with you on this -- but nonetheless will take your further > comment to heart and go off and finally learn how to use @ . Oh, I just meant to say that you're better off splitting things up into chunks and commenting each part if it doesn't make any sense. Here's some code of which I'm not particularly proud but which, kind of, demonstrates this idea: ListCombinations[in_List, AND_, NOT_] := Module[{s, x},=E2=80=A8 s == Tuples[{# &, NOT[#] &}, Length@in];=E2=80=A8 s = Thread[MyApply[#, i= n]] & /@ s /. MyApply[x_, y_] -> x[y];=E2=80=A8 s = AND @@ # & /@ s;=E2=80=A8= Most@s (* Last element is NOT all -- we're not using that one *)=E2=80=A8 ] ListCombinations[{a, b, c}, And, Not] If I'd chained all those s= into a single statement (which is probably that second line is pretty messy), regardless of whether those @@ and & and /. were Apply[], Function[], Replace[], and so on. Will === Subject: Re: Parallel Computing Toolkit with ssh tunnels Hi Art, in order for SSH tunneling to work for your configuration, you have to use active MathLink connections that use standard input and output as MathLink transport, i.e., LaunchSlave[remotehost,ssh `1` math -mathlink, ConnectionType- >LinkLaunch] Also see http://documents.wolfram.com/applications/parallel/Configuration/Un= ix.html Sascha > I would like to create a poor man's parallel cluster using PCT to work > through ssh tunnels due circumvent firewall restrictions. I have 3 slave and 1 master linux machines with sshd running on port > 22 and no other ports open. Assume each machine is additionally behind > a physical firewall and has a local IP and the firewall port forwards > 22 to this machine. Authentication is set up without a password so > that the following works: me@master: ssh slave1 math > Mathematica 6.0 for Linux x86 (64-bit) > Copyright 1988-2008 Wolfram Research, Inc. In[1]:= I haven't been able to get LaunchSlave[] to work with this setup with > various combinations of LinkName, LinkHost and for example, 'ssh -R > port1:127.0.0.1:port1 -R port2:127.0.0.1:port2' as replacement for > $RemoteCommand. It seems for each launch, the master listens on two new random ports > for each slave and instructs the slave to connect to these ports on a > specific IP. I think I have both an issue with the firewall and the > fact that meaningless local IPs are passed to the slaves rather than > the IP of the firewall. Even when I hand set the ports and open them > on the firewalls, I have problems. I am guessing the mathlink connection protocol is the same as > launching a remote kernel on a slave from the master, which I also > haven't been able to get to work with these firewalls and port > restrictions. I have been able to get it to work with all machines in > one local network and with no firewall restrictions. I have also been > able to use gdb to debug mathlink code using the similar two port > communication. I was wondering if anyone has gotten either PCT or remote kernel > launching through ssh tunnels to work. There are prior posts on this > forum and help on a wiki page:http://tinyurl.com/5ano5tbut I haven't > been able to get them to work either. I am using 6.0.2 on 64-bit > Ubuntu 7.10 with PCT 2.1. Art. === Subject: Re: Polygon cutter what is wrong with ContourPlot[] to reinvent the weel? Except the good old numeric code, nobody would use code from 1966 that has not updated over the time. And what is wrong with the good old Which[] function of Mathematica ? Jens > A programming style question. The code fragments below come > from conversion to Mathematica (they must work on versions > >=4.0) of an ancient Fortran IV contourplot program written > in 1966 for my thesis. They are key part of the inner loop > polygon cutter. > ----------------------------------------------------------- > Version 1. Straight translation from Fortran: > > p={Null}; > If [tb>0&&tb==tt, p={P1,P2,P4,P3}]; > If [tb==1&&tt==2, p={Pc2,P1,P2,P4,P3}]; > If [tb==-1&&tt==-1,p={}]; > If [tb==-1&&tt==0, p={Pc1,Pc2,Pc3}]; > If [tb==-1&&tt==1, p={Pc1,P4,P3}]; > If [tb==-1&&tt==2, p={Pc1,Pc2,P3,P4}]; > If [tb==0&&tt==0, p={}]; > If [tb==1&&tt==0, p={Pc3,Pc2,P1,P2}]; > If [tb==2&&tt==0, p={Pc3,P1,P2}]; > poly=Graphics[Polygon[p]]; > > V1 was actually a separate subroutine, with a RETURN after > each match, but in Mathematica it goes inline. > tb (tag-bottom) and tt (tag-top) are integers in range > -1 through 2 whereas P1, ... etc, are point coordinates. > ----------------------------------------------------------- > Version 2. Table driven variant of above: > > p={{{},{Pc1,Pc2,Pc3},{Pc1,P4,P3},{Pc1,Pc2,P3,P4}}, > {{Null},{},{Null},{Null}}, > {{Null},{Pc3,Pc2,P1,P2},{P1,P2,P4,P3},{Pc2,P1,P2,P4,P3}}, > {{Null},{Pc3,P1,P2},{Null},{P1,P2,P4,P3}}} [[tb+2,tt+2]]; > poly=Graphics[Polygon[p]]; > > Impossible (tb,tt) combinations return {Null}. V2 was > actually that implemented when V1 was later converted to > Univac 1110 machine language. > ---------------------------------------------------------- > Question: which version is preferable in Mathematica, or is > there a better one? Both run roughly at the same speed > (about 25 microsec under 5.2 on an Intel MacBook Pro). > Since this loop is traversed once for each polygon, > efficiency is important. > === Subject: Re: Polygon cutter Carlos, > Well, tell me how ContourPlot can be used for an arbitrary finite > element mesh, > which may have arbitrary geometry, topology and element type > combinations, > when the data is only known at the nodes (or at Gauss points). > the function imsUnstructuredContourPlot[ co, inc, val ] co = coordinates inc = incidences val = values at the nodes which you can get here : http://www.imtek.uni-freiburg.de/simulation/mathematica/IMSweb/imsTOC/Utliti es/Graphics/UnstructuredPlotDocu.html can do it. hth, oliver > Last I heard, ContourPlot only works for a rectangular region and the function > must be provided as, well, a function. It has its uses, but not in FEM plotting. Oliver Ruebenkoenig, === Subject: Re: Polygon cutter Well, tell me how ContourPlot can be used for an arbitrary finite element mesh, which may have arbitrary geometry, topology and element type combinations, when the data is only known at the nodes (or at Gauss points). Last I heard, ContourPlot only works for a rectangular region and the function must be provided as, well, a function. It has its uses, but not in FEM plotting. === Subject: Re: Polygon cutter a) in version 6.0 ContourPlot[] will work with data in any position as to see from ListContourPlot[Table[Random[], {5}, {3}]] b) and for higer finite elements you have to write the correct interpolation routine. But it may be sufficient, to compute the function on a triangular mesh and feed it into ListContourPlot[] Jens > Well, tell me how ContourPlot can be used for an arbitrary finite element mesh, > which may have arbitrary geometry, topology and element type combinations, > when the data is only known at the nodes (or at Gauss points). > > Last I heard, ContourPlot only works for a rectangular region and the function > must be provided as, well, a function. It has its uses, but not in FEM plotting. > === Subject: Re: Polygon cutter Hello Carlos, I believe the interpretation of good style is a bit like ethics--it's easy to agree in extreme cases, but the in-between cases are subjective. I think this depends on whether you intend to modify the code in the future. I believe V1 is easier to read, and if you think that someone else may wish to modify it, then I recommend sticking with that. However,Which will probably be more efficient, and rank the order of tests with decreasing frequency. V2 looks cool--some people like that. There is probably a way to improve the coolness even more, and remove the need to return the impossible Nulls. Creating V2 probably hones your skills and is more interesting to do, which is similarly important; but probably has a direct impact on a broader interpretation of efficiency. > A programming style question. The code fragments below come > Version 1. Straight translation from Fortran: p={Null}; > If [tb>0&&tb==tt, p={P1,P2,P4,P3}]; : : > poly=Graphics[Polygon[p]]; Version 2. Table driven variant of above: p={{{},{Pc1,Pc2,Pc3},{Pc1,P4,P3},{Pc1,Pc2,P3,P4}}, > {{Null},{},{Null},{Null}}, > {{Null},{Pc3,Pc2,P1,P2},{P1,P2,P4,P3},{Pc2,P1,P2,P4,P3}}, > {{Null},{Pc3,P1,P2},{Null},{P1,P2,P4,P3}}} [[tb+2,tt+2]]; > poly=Graphics[Polygon[p]]; Question: which version is preferable in Mathematica, or is > there a better one? Both run roughly at the same speed > (about 25 microsec under 5.2 on an Intel MacBook Pro). > Since this loop is traversed once for each polygon, > efficiency is important. -- W. Craig Carter === Subject: Re: Polygon cutter > Hello Carlos, > I believe the interpretation of good style is a bit like ethics--it's > easy to agree in extreme cases, but the in-between cases are > subjective. > I think this depends on whether you intend to modify the code in the > future. I believe V1 is easier to read, and if you think that someone > else may wish to modify it, then I recommend sticking with that. > However,Which will probably be more efficient, and rank the order of= > tests with decreasing frequency. > V2 looks cool--some people like that. There is probably a way to= > improve the coolness even more, and remove the need to return the > impossible Nulls. Creating V2 probably hones your skills and is > more interesting to do, which is similarly important; but probably has= > a direct impact on a broader interpretation of efficiency. > A programming style question. The code fragments below come > Version 1. Straight translation from Fortran: > p={Null}; > If [tb>0&&tb==tt, p={P1,P2,P4,P3}]; > : > : > poly=Graphics[Polygon[p]]; > Version 2. Table driven variant of above: > p={{{},{Pc1,Pc2,Pc3},{Pc1,P4,P3},{Pc1,Pc2,P3,P4}}, > {{Null},{},{Null},{Null}}, > {{Null},{Pc3,Pc2,P1,P2},{P1,P2,P4,P3},{Pc2,P1,P2,P4,P3}}, > {{Null},{Pc3,P1,P2},{Null},{P1,P2,P4,P3}}} [[tb+2,tt+2]]; > poly=Graphics[Polygon[p]]; > Question: which version is preferable in Mathematica, or is > there a better one? Both run roughly at the same speed > (about 25 microsec under 5.2 on an Intel MacBook Pro). > Since this loop is traversed once for each polygon, > efficiency is important. > -- > W. Craig Carter > Your suggestion of looking at the Which construct was an interesting > one - > didn't know it existed. So I tried it as > p={Null}; > Which [tb>0&&tb==tt, p={P1,P2,P4,P3}, tb==1&&tt==2,= > p={Pc2,P1,P2,P4,P3}, > tb==-1&&tt==-1,p={}, = tb==-1&&tt==0= > , > p={Pc1,Pc2,Pc3}, > tb==-1&&tt==1, p={Pc1,P4,P3}, t= b==-1&&tt==2, > p={Pc1,Pc2,P3,P4}, > tb==0&&tt==0, p={}, = tb==1&&tt==0, > p={Pc3,Pc2,P1,P2}, > tb==2&&tt==0, p={Pc3,P1,P2}]; > poly=Graphics[Polygon[p]]; > The two most common cases are the first two. I expected this to be > quicker than V1 > but it wasnt. On a MacBook Pro under 5.2: > V1 25 microsec/polygon > V2 24 > Which 30 > Similar rankings for 4.1 and 4.2. Havent tested it on 6.0. How about using Switch? switchfun[{tb_, tt_}]:= > Switch[{tb, tt}, > {tb, tb} /; tb > 0, {P1, P2, P4, P3}, > {1, 2}, {Pc2, P1, P2, P4, P3}, > {-1, 0}, {Pc1, Pc2, Pc3}, > {-1, 1}, {Pc1, P4, P3}, > {-1, 2}, {Pc1, Pc2, P3, P4}, > {1, 0}, {Pc3, Pc2, P1, P2}, > {2, 0}, {Pc3, P1, P2}, > {_, _}, {} > ] Graphics@Polygon@switchfun@{tb,tt} Note, in V6 Graphics[Polygon[{}]] is OK but Graphics[Polygon[{Null}]] > produces an error. And the same is true for Graphics3D. --Mark {Null} IS intended to trigger an error, since those tag combinations, in the famous Unix phrase, cant happen === Subject: Re: Polygon cutter The two most common cases are the first two. I expected this to be > quicker than V1 > but it wasnt. On a MacBook Pro under 5.2: V1 25 microsec/polygon > V2 24 > Which 30 Similar rankings for 4.1 and 4.2. Havent tested it on 6.0. I am glad to know it, surprised, but glad to know. Strange, because you are evaluating ifs even though it has determined to be true beforehand. So, let me suggest an (possible) improvement of V1: findpoly[tb_,tt_]:= Module[{}, If [tb>0&&tb==tt, Return[Graphics[Polygon[{P1,P2,P4,P3}]]; : : If [tb==2&&tt==0, Return[Graphics[Polygon[{Pc3,P1,P2}]]]; ] This is more like your older subroutine... -- W. Craig Carter === Subject: Re: Polygon cutter > Hello Carlos, > I believe the interpretation of good style is a bit like ethics--it's > easy to agree in extreme cases, but the in-between cases are > subjective. > I think this depends on whether you intend to modify the code in the > future. I believe V1 is easier to read, and if you think that someone > else may wish to modify it, then I recommend sticking with that. > However,Which will probably be more efficient, and rank the order of > tests with decreasing frequency. > V2 looks cool--some people like that. There is probably a way to > improve the coolness even more, and remove the need to return the > impossible Nulls. Creating V2 probably hones your skills and is > more interesting to do, which is similarly important; but probably has > a direct impact on a broader interpretation of efficiency. > A programming style question. The code fragments below come > Version 1. Straight translation from Fortran: > p={Null}; > If [tb>0&&tb==tt, p={P1,P2,P4,P3}]; > : > : > poly=Graphics[Polygon[p]]; > Version 2. Table driven variant of above: > p={{{},{Pc1,Pc2,Pc3},{Pc1,P4,P3},{Pc1,Pc2,P3,P4}}, > {{Null},{},{Null},{Null}}, > {{Null},{Pc3,Pc2,P1,P2},{P1,P2,P4,P3},{Pc2,P1,P2,P4,P3}}, > {{Null},{Pc3,P1,P2},{Null},{P1,P2,P4,P3}}} [[tb+2,tt+2]]; > poly=Graphics[Polygon[p]]; > Question: which version is preferable in Mathematica, or is > there a better one? Both run roughly at the same speed > (about 25 microsec under 5.2 on an Intel MacBook Pro). > Since this loop is traversed once for each polygon, > efficiency is important. > -- > W. Craig Carter Your suggestion of looking at the Which construct was an interesting > one - > didn't know it existed. So I tried it as p={Null}; > Which [tb>0&&tb==tt, p={P1,P2,P4,P3}, tb==1&&tt==2, > p={Pc2,P1,P2,P4,P3}, > tb==-1&&tt==-1,p={}, tb==-1&&tt==0= > , > p={Pc1,Pc2,Pc3}, > tb==-1&&tt==1, p={Pc1,P4,P3}, tb==-1&&tt==2, > p={Pc1,Pc2,P3,P4}, > tb==0&&tt==0, p={}, tb==1&&tt==0, > p={Pc3,Pc2,P1,P2}, > tb==2&&tt==0, p={Pc3,P1,P2}]; > poly=Graphics[Polygon[p]]; The two most common cases are the first two. I expected this to be > quicker than V1 > but it wasnt. On a MacBook Pro under 5.2: V1 25 microsec/polygon > V2 24 > Which 30 Similar rankings for 4.1 and 4.2. Havent tested it on 6.0. How about using Switch? switchfun[{tb_, tt_}]:= Switch[{tb, tt}, {tb, tb} /; tb > 0, {P1, P2, P4, P3}, {1, 2}, {Pc2, P1, P2, P4, P3}, {-1, 0}, {Pc1, Pc2, Pc3}, {-1, 1}, {Pc1, P4, P3}, {-1, 2}, {Pc1, Pc2, P3, P4}, {1, 0}, {Pc3, Pc2, P1, P2}, {2, 0}, {Pc3, P1, P2}, {_, _}, {} ] Graphics@Polygon@switchfun@{tb,tt} Note, in V6 Graphics[Polygon[{}]] is OK but Graphics[Polygon[{Null}]] produces an error. And the same is true for Graphics3D. --Mark === Subject: Re: Polygon cutter > Hello Carlos, > I believe the interpretation of good style is a bit like ethics--it's > easy to agree in extreme cases, but the in-between cases are > subjective. I think this depends on whether you intend to modify the code in the > future. I believe V1 is easier to read, and if you think that someone > else may wish to modify it, then I recommend sticking with that. > However,Which will probably be more efficient, and rank the order of > tests with decreasing frequency. V2 looks cool--some people like that. There is probably a way to > improve the coolness even more, and remove the need to return the > impossible Nulls. Creating V2 probably hones your skills and is > more interesting to do, which is similarly important; but probably has > a direct impact on a broader interpretation of efficiency. > A programming style question. The code fragments below come > Version 1. Straight translation from Fortran: > p={Null}; > If [tb>0&&tb==tt, p={P1,P2,P4,P3}]; : > : > poly=Graphics[Polygon[p]]; > Version 2. Table driven variant of above: > p={{{},{Pc1,Pc2,Pc3},{Pc1,P4,P3},{Pc1,Pc2,P3,P4}}, > {{Null},{},{Null},{Null}}, > {{Null},{Pc3,Pc2,P1,P2},{P1,P2,P4,P3},{Pc2,P1,P2,P4,P3}}, > {{Null},{Pc3,P1,P2},{Null},{P1,P2,P4,P3}}} [[tb+2,tt+2]]; > poly=Graphics[Polygon[p]]; > Question: which version is preferable in Mathematica, or is > there a better one? Both run roughly at the same speed > (about 25 microsec under 5.2 on an Intel MacBook Pro). > Since this loop is traversed once for each polygon, > efficiency is important. -- > W. Craig Carter Your suggestion of looking at the Which construct was an interesting one - didn't know it existed. So I tried it as p={Null}; Which [tb>0&&tb==tt, p={P1,P2,P4,P3}, tb==1&&tt==2, p={Pc2,P1,P2,P4,P3}, tb==-1&&tt==-1,p={}, tb==-1&&tt==0= , p={Pc1,Pc2,Pc3}, tb==-1&&tt==1, p={Pc1,P4,P3}, tb==-1&&tt==2, p={Pc1,Pc2,P3,P4}, tb==0&&tt==0, p={}, tb==1&&tt==0, p={Pc3,Pc2,P1,P2}, tb==2&&tt==0, p={Pc3,P1,P2}]; poly=Graphics[Polygon[p]]; The two most common cases are the first two. I expected this to be quicker than V1 but it wasnt. On a MacBook Pro under 5.2: V1 25 microsec/polygon V2 24 Which 30 Similar rankings for 4.1 and 4.2. Havent tested it on 6.0. === Subject: returning inverse Hessian from FindMinimum I am using Method -> QuasiNewton with FindMinimum. I specify the Gradient but not the Hessian. Can I have FindMinimum return the inverse Hessian it has accumulated when it completes its optimization? The implementation notes indicated BFGS is used for QuasiNewton. I would like to use the inverse Hessian to get an idea of how stable the fitted parameters are around the minimum. I would also like to use it to fudge together the minima from running FindMinimum[] in batch across several machines using the parallel computing toolkit. I don't think this is possible or desirable - I'm just messing around. I looked through the docs and the source for Optimization`UnconstrainedProblems` and didn't find anything, well, other than some good programming pointers. Any suggestions or general guidance would be cool. Sam === Subject: New Presentations Version I have released an updated version of Presentations. Existing purchasers should have received notices and a download link. If you are a purchaser and have not received the notice, please contact me and supply a working email address. Others may purchase the package for $50 through my web site below. Presentations is a package that extends Mathematica to make it easier for students, teachers and researchers to work with textbooks, tutorials and research papers. The core portion implements an easier paradigm for producing custom graphics, geometric diagrams and displays. Among other features there are routines for 3D Text that rotates with the image and hides behind surfaces, 3D arrows, custom ticks and grids, and complex function and complex number graphics. Beyond graphics there is an Indefinite Sequence section that allows the writing, some manipulations, and conversion to normal Mathematica expressions of expressions with ellipses to indicated skipped terms. New features in Presentations are: 3D Text can now be done with most ordinary fonts on your computer and you can even create block characters. A new References section allows the maintenance of lists of references or notes with user specified styles. The references can be inserted into Text cells using Tooltips, OpenerViews or Buttons with pop-up windows. A Key Equations section allows the maintenance of a list of key equations for a notebook. The equations can be numbered and the numbers are dynamically updated. There is complete control of the style and format for the equations, their labels and their references. A Student's Integral section helps students to learn and use standard integration techniques. An integrate command mimics Integrate but holds the integral unevaluated. There are then commands to operate on the integrand, use a change of variable, use integration by parts, use trigonometric substitution and do linear breakouts. The integrals can then be turned over to a BasicIntegralTable such as a student might use, to custom integral tables such as a researcher might use in special cases, or to the Mathematica Integrate or NIntegrate commands. A Manipulations section contains routines for performing common manipulations of expressions that Mathematica seems to have overlooked. CompleteTheSquare does what you might expect. FactorOut will pull an arbitrary subexpression out of an expression (such as a matrix) and apply functions such as HoldForm or CreateSubexpression to the parts. MultiplyByOne will multiply the numerator and denominator of an expression will breakout specified function patterns on specified 'vectors'. PushOnto will push a set of arguments onto specified patterns. It overcomes the severe shortcomings of the Through command. HoldOp will hold an operation, but evaluate the arguments. CreateSubexpression and ReleaseSubexpressions will wrap subexpressions in a Tooltip. A Tooltip works just as well as HoldForm in shielding expressions. (Shielding subexpressions prevents routines such as Simplify from breaking them apart.) MapLevelParts and MapLevelPatterns allows an operation to be mapped onto a subset of level parts (as a single entity) in an expression. The most common usage would be to operate on a subset of terms in a sum. SymbolsToPatterns will convert a list of symbols in an expression to named patterns. This is useful in converting derived results into general rules. -- David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ === Subject: Re: NDSolve and vector functions HI, thank's a lot for the replies. I think the most practicable way is the solution due to Carl. He packs all vector valued constants into functions that only evaluate if the argument is numeric. I will play around with this to check if there are no surprises. thank's again, Daniel > Hello all, > > does anybody know a way to compute a vector valued function using > > NDSolve without explicitely specifying all vector components. Here is a > > simple example: Although NDSolve[{p'[t]==p[t],p[0]=={1,0}},p,{t,0,1}] works, > > NDSolve[{p'[t]==p[t]+{1,1},p[0]=={1,0}},p,{t,0,1}] > > does not work because p[t] in p[t]+{1,1} is treated as a scalar and > > the expression is evaluated to {1+p[t],1+p[t]} what is clearly not > > intended. Even in IdentityMatrix[2].p[t]+{1,1} > > IdentityMatrix[2].p[t] is treated like a scalar and added to the > > components of {1,1}. > > do I miss something??? > > Daniel > > > === Subject: Hamiltonian System with NDSolve So I'm trying to solve the following Hamiltonian system using Mathematica. solution = NDSolve[{x'[t] == 2p[t], x[0] == 2, p'[t] == I*(2 + 1/2)(I*x[t])^(1 + 1/2), p[0] == 1-2*I}, {x, p}, {t,0,10}, MaxSteps -> Infinity][[1]]; I'm letting E=1, so at all points t, it should be that (p[t]/.solution)^2-(I*x[t]/.solution)^(2+1/2)=1. That is the case until the function crosses a branch cut on the complex x-plane that runs from 0 to i*(Infinity). Once the function crosses the branch cut, the system no longer preserves E and the value changes to something around 1.3. How can I go about fixing this problem? I've already tried working with the precision and accuracy goals, and that didn't work. I'm not sure what else to consider. Any help would be appreciated. Alex === Subject: Re: Hamiltonian System with NDSolve you need a symplectic method and NDSolve[] has implemente one as Method ->{SymplecticPartitionedRungeKutta, ..} Jens > So I'm trying to solve the following Hamiltonian system using Mathematica. > > solution = NDSolve[{x'[t] == 2p[t], x[0] == 2, > p'[t] == I*(2 + 1/2)(I*x[t])^(1 + 1/2), p[0] == 1-2*I}, {x, p}, {t,0,10}, MaxSteps -> Infinity][[1]]; > > I'm letting E=1, so at all points t, it should be that > (p[t]/.solution)^2-(I*x[t]/.solution)^(2+1/2)=1. > > That is the case until the function crosses a branch cut on the complex x-plane that runs from 0 to i*(Infinity). Once the function crosses the branch cut, the system no longer preserves E and the value changes to something around 1.3. > > How can I go about fixing this problem? I've already tried working with the precision and accuracy goals, and that didn't work. I'm not sure what else to consider. Any help would be appreciated. > > Alex > === Subject: Column Product of a Matrix of zeros and 1's I have a matrix of zero's and ones: myGlobalMatrix; also a set called thisSet with the columns of myGlobalMatrix which have to be multiplied (e.g. column 1,3,4). I would like to know the positions of the 1's. I do this as follows: Flatten[Position[Product[myGlobalMatrix[[All,i]],{i, thisSet}],1]] But this is to general. It does not use that the matrix consists of zeros and ones. Can this be taken into account? with friendly greetings, P_ter === Subject: Re: Very Long Wait for the Kernel after Reboot > I'm running v6.0.1 of Mathematica under Mac OS X v10.4.11 with 1 GB > time I try to evaluate a Mathematica instruction after rebooting the > computer, it takes a very long time to load the kernel (I once timed > it at five minutes, and it seems to be getting longer, but I haven't > timed it again so that might just be frustration). Subsequent > sessions with Mathematica don't require nearly as long (though it > still seems unreasonably long) to get the kernel up and running---as > long as I haven't rebooted. > > Is this normal for my configuration? Does anyone have an explanation? One thing to check is your anti-virus software. Try temporarily disabling it and see if that fixed the problem. If it does, turn the anti-virus software back on and try adding the Mathematica installation directory to the anti-virus exclusions. -- Helen Read University of Vermont === Subject: Re: Very Long Wait for the Kernel after Reboot > I experience the same problem with my mac, and I have two workarounds. > 1) Start the kernel explicity under the evaluation menu. > 2) Abort the stalled first evaluation and then re-evaluate. --Lou Talman Department of Mathematical and Computer Sciences Metropolitan State College of Denver === Subject: Re: Very Long Wait for the Kernel after Reboot Hello Louis, This thread has come up before, and I didn't see a subsequent explanation. I experience the same problem with my mac, and I have two workarounds. 1) Start the kernel explicity under the evaluation menu. 2) Abort the stalled first evaluation and then re-evaluate. I suspect the problem lies in multiple threading, and the separate processes of the Frontend and the Kernel. But, I am out of my depth here. Craig > I'm running v6.0.1 of Mathematica under Mac OS X v10.4.11 with 1 GB > computer, it takes a very long time to load the kernel (I once timed > it at five minutes, and it seems to be getting longer, but I haven't > Is this normal for my configuration? Does anyone have an explanation? > === Subject: Re: problem accessing notebooks ... > what you do with SetDirectory[] is irrelevant for the package search. ... This is not true for version 5.2. I've put an empty package pack.m into my desktop-directory and another one (pp.m) in a subdirectory named sub: In[1]:= $Version Out[1]= 5.2 for Linux x86 (64 bit) (June 20, 2005) In[2]:= !!~/Desktop/pack.m BeginPackage[pack`,{sub`pp`}]; EndPackage[]; In[3]:= !!~/Desktop/sub/pp.m BeginPackage[sub`pp`]; Print[Verzeichnis gefunden!]; EndPackage[]; In[4]:= <<~/Desktop/pack.m Get::noopen : Cannot open sub`pp`. More... Needs::nocont : Context sub`pp` was not created when Needs was evaluated. More... In[5]:= SetDirectory[~/Desktop]; In[6]:= < ... >> what you do with SetDirectory[] is irrelevant for the package search. > ... > > This is not true for version 5.2. > I've put an empty package pack.m into my desktop-directory and another one > (pp.m) in a subdirectory named sub: > > In[1]:= > $Version > Out[1]= > 5.2 for Linux x86 (64 bit) (June 20, 2005) > In[2]:= > !!~/Desktop/pack.m > BeginPackage[pack`,{sub`pp`}]; > EndPackage[]; > In[3]:= > !!~/Desktop/sub/pp.m > BeginPackage[sub`pp`]; > Print[Verzeichnis gefunden!]; > EndPackage[]; > In[4]:= > <<~/Desktop/pack.m > Get::noopen : Cannot open sub`pp`. More... > Needs::nocont : Context sub`pp` was not created when Needs was evaluated. More... > In[5]:= > SetDirectory[~/Desktop]; > In[6]:= > < Verzeichnis gefunden! > === Subject: Re: problem accessing notebooks > ... >> what you do with SetDirectory[] is irrelevant for the package search. > ... > > This is not true for version 5.2. It is true for every version of mathematica that I know of. But with the default settings ., representing the current directory, is contained within $Path. So if that entry isn't deleted, SetDirectory will help, as you have observed. If you delete . from $Path, SetDirectory will not help at all. Try your tests after doing this to see yourself: $Path = DeleteCases[$Path, .] hth, albert === Subject: Re: A Problem with Simplify >> Indeed. However, there would be two problems. First, >> someone would >> have to devise suitable algorithms and implement >> them. This may not be >> totally impossible, but it would certainly take a lot >> of effort. But >> then, we would see the second problem. This ideal >> integrate would >> run for ever on almost any non-trivial problem. You >> would get nice >> mathematical answers to trivial ones, which would >> make you feel >> good, and no answers to non-trivial ones, which would >> probably make >> you a annoyed enough to complain (to the MathGroup?). >> Would that be a good way to use the time and effort >> of programmers and >> your own money? >> As for Reduce - you should try it a little more on >> harder problems >> than the one you have just presented. It uses some >> very beautiful and >> powerful algorithms like Cylindrical Algebraic >> Decomposition but they >> have exponential or in this case double exponential >> complexity (in >> the number of variables) so if you it try on >> something with more than >> 3 variables involved you will see what I mean. Given >> the choice >> between a program that does everything in the spirit >> of true >> mathematics but can only sole trivial problems that >> can be done by >> hand and one that gives only generic solutions but >> can deal with >> cases that would take you a hundred years to do by >> hand, which one >> would you choose? >> Andrzej Kozlowski I do not see the reason why in the case of Integrate keeping track > for the conditions will take more time than in the case of Reduce. > As I understand it is just the same or something like. > No, because the formulas that Integrate deals with are very often the kind Reduce cannot deal at all with (Reduce can basically only manage algebraic equations and inequalities and those reducible to algebraic ones. Integrate often deals with transcendental functions or, what's worse, composites of transcendental and algebraic ones). If you wanted Integrate to keep track of all conditions, it would have to try to solve equations to check for zeros in the denominator, common zeros in the numerator and the denominator and such like, and it would have to do it not just in the simple cases (like your example) but in all cases. But in the vast majority of cases it can't do anything of the sort. As an illustration, just take one of your examples: p = Integrate[Sin[a x]/Cos[x], x]; Reduce[Numerator[p]==0,a] Reduce[Numerator[p] == 0, a] This system cannot be solved with the methods available to Reduce. Reduce[(-(a + 1))*Hypergeometric2F1[1/2 - a/2, 1, 3/2 - a/2, -E^(2*I*x)] - (a - 1)*E^(2*I*a*x)* Hypergeometric2F1[(a + 1)/2, 1, (a + 3)/2, -E^(2*I*x)] == 0, a] And even in the purely algebraic cases Reduce can easily take for ever. Or consider this: Reduce[x^3 + Sin[x] == 0, x] During evaluation of In[34]:= Reduce::nsmet : This system cannot be solved with the methods available to Reduce even though anyone can easily see that 0 is a solution (but Reduce is not allowed to return an incomplete solution). The problems with you kind of Integrate would involve all the above and worse. Adnrzej Kozlowski === Subject: Re: ? > I've just executed a test cell containing Print[Plot[---]]; > Print[Some textn, Plot[---]]; (same simple plot in both lines; objective of 2nd line being to get the > text and the plot -- eventually several plots -- into the same output > cell) Result from first line is expected plot; result from second line is a > miniaturized plot about 1/4 the size of the first one. * This is sensible or useful? * This is what a novice user should expect as consistent > and reasonable behavior from the above commands? (Print[Plot] doesn't do the same thing with a given Plot > as does Print[----, Plot[], ----] ???) * This is documented --or better, warned about -- where? (since it looks like I'll have to, once again, step aside from > attempting to accomplish anything useful with 6.0 and > burn up more time digging into its arcane documentation, > trying to understand this. Apologies for the sarcasm -- > but that's the way it feels.) > Graphics with ImageSize->Automatic are rendered smaller when they appear > in lists or grids, and even smaller when they appear in text-like > constructs. If you like the default size, you can specify ImageSize->Medium in your plots. The reason for this behavior is that since, in v6, graphics are now first class output objects rather than mere side effects, changing the automatic size based upon context can make it easier to work with them. Imagine, for example, outputting a list or a grid of default-sized graphics and trying to get an idea for the totality of the output while each graphic is still big enough to compete for a standalone-sized portion of the screen. John Fultz jfultz@wolfram.com User Interface Group Wolfram Research, Inc. === Subject: Re: FrontEnd and JLink I tried the following using Math.EXE, which is much the same as driving the kernel from Java: $FrontEndLaunchCommand=$InstallationDirectory<>Mathematica -mathlink; UseFrontEnd[NotebookCreate[]] I guess you need to wrap all relevant commands in UseFrontEnd. An examination of the JLink source indicates that the default FE launch command uses a -nogui option - so using the default launch command the above command seems to create an invisible notebook object. The only problem with this (depending on your applicatio) is that you get an unnecessary menu bar at the top. Also, you should give it a good test to ensure there are no strange 'features', since I don't suppose many people have used this! Unless you have already written a compled Java GUI, you may like to consider using my Super Widget Package (available free from my site, which creates a Java GUI in a very easy way, and supports a lot of Java features - such as, for example the MDI interface. David Bailey http://www.dbaileyconsultancy.co.uk > I want to create Mathematica graphical objects (notebook with cells, > palettes, plots, etc) from a Java Gui using JLink calls > Apparently, this is not possible until you don't use the > Mathematica.exe frontend > (no way to initialize a frontend from a java gui) > > hereafter a Java example > Any helps ? > > laurent > > > ----------------------------------------------------------------------------- ------- > import com.wolfram.jlink.*; > > > class Exemple_FrontEnd { > public static void main (String[] args){ > > try { > KernelLink ml = MathLinkFactory.createKernelLink(-linkmode launch - > linkname MathKernel); > ml.evaluateToInputForm(Needs[ + KernelLink.PACKAGE_CONTEXT + > ],0); > ml.evaluateToInputForm(ConnectToFrontEnd[], 0); > setVisible(True); > ml.evaluate(UseFrontEnd[NotebookCreate[]]); > > } catch (MathLinkException e) { > e.printStackTrace(); > } > } > } > === Subject: problem during polygon deletion (* I have a bug in my Mathematica program destined for the Wolfram Demonstration Project. Can anyone please give me a hint what I do wrong. The following Mathematica notebook allows the use to create, store and delete polygons. When I hit the delete last vertex button or the delete last polygon button, it works, but I get strange error messages. Any help would be very much appreciated, please send any answers to k a r l s c h e r e r 3 @ y a h o o . c o . n z (without the gaps). Even someone's email address of a person who could help me would be great. Getting desparate. OK, here is the code: *) ClearAll[Global`*]; (* -------------- define the orthogonal grid :---------------- *) lx =30; ly=30;(*size of lattice *) rx=Range[lx]; ry=Range[ly]; (* Tuples[list,n] Cell[TextData[{ generate all possible , Cell[BoxData[ StyleBox[n, TI]], InlineFormula], -tuples of elements from , Cell[BoxData[ StyleBox[list, TI]], InlineFormula] }], TableText] *)lattice = Point[Tuples [{rx,ry}]]; (* -------------- define the isometric grid :---------------- *) d=1 ;(*horizontal grid spacing *) h=Sqrt[3]/2; (* height of triangles*) lx ; ly=10;(*size of lattice *) rx1= Range[0,lx]; ry1 = 2*h* Range[0,ly]; (* Cell[generate all possible pairs of elements from these lists:, TableText] *) lattice1 = Tuples [{rx1,ry1}]; (* lattice 1 *) rx2 = .5 +rx1; ry2= h+ry1; lattice2 = Tuples [{rx2,ry2}]; (* lattice2 *) isolattice = Point[Join[lattice1, lattice2]]; (* -------------- define snap to ortho and isometric grid :---------------- *) osnap[{x_,y_}]:={Floor[x +.5],Floor[y +.5]} isosnap[{p_,q_}]:= With[ {d=Floor[Floor[q+h/2,2 h]-Floor[q+h/2, h]]}, {Floor[p+ (1-d)/2]+d/2,Floor[q+h/2, h]} ] snap[p_]:= If[gridsnap, If[ortho,osnap[p],isosnap[p]], p ] (* --------------manipulate--------------------*) Manipulate[ ClickPane[ Graphics[ { (* ------- draw grid ---------------- *) LightGray, If[grid, If[ortho,lattice,isolattice] ,{} ], (* ------- draw text ---------------- *) Black, {Text[Style[Number of stored polygons:,12],{4,-1}]}, {Text[Style[Length[pols],12],{8.6,-1}]}, {Text[Style[Stored polygons shown:,12],{13.5,-1}]}, {Text[Style[Floor[1/2+ showpols*Length[pols]],12],{17.6,-1}]}, (* -------store a new polygon ---------------- *) If[store, {store=False, If[Length[pts]>0, {pols=AppendTo[pols, pts], polcols=AppendTo[polcols, col1], pts={} }, {}] },{} ], (* ------- draw new points ---------------- *) Black,PointSize[pointsize], Point[pts], (* draw points *) (* ------- draw next polygon ---------------- *) FaceForm[col1], EdgeForm[If[outline,Thin,None]], Opacity[opacity],Polygon[pts], (* ------- draw stored polygons ---------------- *) Table[ If[showpols=B3(i-.5)/Length[pols], {FaceForm[polcols[[i]]],Polygon[pols[[i]]]} ,{}], {i,Length[pols]} ] , (* -------delete current polygon ---------------- *) If[delnew, {delnew=False, pts={} },{} ], (* -------delete all stored polygons ---------------- *) If[delall, {delall=False, pols={},polcols={} },{} ], (* -------delete last vertex of new polygon ---------------- *) If[delvertex, {delvertex=False, If[Length[pts]>0, pts=Delete[pts,-1] ,{}] } ,{}] (* -------delete last shown polygon ---------------- *) If[delmax, {delmax=False, If[Length[pols]>0, With[ {i=Floor[1/2+ showpols*Length[pols]]}, {pols=Delete[pols,i],polcols=Delete[polcols,i]} ],{}] },{}] }, PlotRange=AE{{-.2,18.2},{-2.2, 18.2}} ], (* end graphics *) ( { (* here we act on the mouseclicks (we are in a ClickPane !) *) pts=AppendTo[pts,snap[#]] (* store next vertex *) } )& ], (* end clickpane *) Style[Grid Controls,Bold], {{grid,True,Style[show grid]},{True,False}}, {{ortho,False,Style[ortho grid]},{True,False}}, {{gridsnap,True,Style[snap to gridn]},{True,False}}, Style[Global Polygon Controls,Bold], {{outline,True,Style[outline]},{True,False}}, {{opacity,.7,Style[opacityn]},0,1,ImageSize=AESmall}, Style[Controls For New Polygon,Bold], {{col1,Cyan,Style[face colour]},Red,ControlType=AEColorSlider,ImageSize=AESmall}, {{pointsize,.02,Style[pointsize new polygon,Black]}, 0,.03,ControlType=AESlider,ImageSize=AESmall}, {{delvertex,False,Style[delete last vertex]},{True,False}}, {{delnew,False,Style[delete new polygon]},{True,False}}, {{store,False,Style[store new polygonn,Blue,Bold]},{True,False}}, Style[Controls For Stored Polygons,Bold], {{showpols,1,Style[show stored polygons]},0,1,ImageSize=AESmall}, {{delmax,False,Style[delete last shown]},{True,False}}, {{delall,False,Style[delete all stored]},{True,False}}, {{pols,{}},ControlType=AENone}, {{pts,{}},ControlType=AENone}, {{polcols,{}},ControlType=AENone}, ControlPlacement=AELeft, SaveDefinitions=AETrue ] Manipulate[ ClickPane[ Graphics[ { (* ------- draw grid ---------------- *) LightGray, If[grid, If[ortho,lattice,isolattice] ,{} ], (* ------- draw text ---------------- *) Black, {Text[Style[Number of stored polygons:,12],{4,-1}]}, {Text[Style[Length[pols],12],{8.6,-1}]}, {Text[Style[Stored polygons shown:,12],{13.5,-1}]}, {Text[Style[Floor[1/2+ showpols*Length[pols]],12],{17.6,-1}]}, (* -------store a new polygon ---------------- *) If[store, {store=False, If[Length[pts]>0, {pols=AppendTo[pols, pts], polcols=AppendTo[polcols, col1], pts={} }, {}] },{} ], (* ------- draw new points ---------------- *) Black,PointSize[pointsize], Point[pts], (* draw points *) (* ------- draw next polygon ---------------- *) FaceForm[col1], EdgeForm[If[outline,Thin,None]], Opacity[opacity],Polygon[pts], (* ------- draw stored polygons ---------------- *) Table[ If[showpols=B3(i-.5)/Length[pols], {FaceForm[polcols[[i]]],Polygon[pols[[i]]]} ,{}], {i,Length[pols]} ] , (* -------delete current polygon ---------------- *) If[delnew, {delnew=False, pts={} },{} ], (* -------delete all stored polygons ---------------- *) If[delall, {delall=False, pols={},polcols={} },{} ], (* -------delete last vertex of new polygon ---------------- *) If[delvertex, {delvertex=False, If[Length[pts]>0, pts=Delete[pts,-1] ,{}] } ,{}] (* -------delete last shown polygon ---------------- *) If[delmax, {delmax=False, If[Length[pols]>0, With[ {i=Floor[1/2+ showpols*Length[pols]]}, {pols=Delete[pols,i],polcols=Delete[polcols,i]} ],{}] },{}] }, PlotRange=AE{{-.2,18.2},{-2.2, 18.2}} ], (* end graphics *) ( { (* here we act on the mouseclicks (we are in a ClickPane !) *) pts=AppendTo[pts,snap[#]] (* store next vertex *) } )& ], (* end clickpane *) Style[Grid Controls,Bold], {{grid,True,Style[show grid]},{True,False}}, {{ortho,False,Style[ortho grid]},{True,False}}, {{gridsnap,True,Style[snap to gridn]},{True,False}}, Style[Global Polygon Controls,Bold], {{outline,True,Style[outline]},{True,False}}, {{opacity,.7,Style[opacityn]},0,1,ImageSize=AESmall}, Style[Controls For New Polygon,Bold], {{col1,Cyan,Style[face colour]},Red,ControlType=AEColorSlider,ImageSize=AESmall}, {{pointsize,.02,Style[pointsize new polygon,Black]}, 0,.03,ControlType=AESlider,ImageSize=AESmall}, {{delvertex,False,Style[delete last vertex]},{True,False}}, {{delnew,False,Style[delete new polygon]},{True,False}}, {{store,False,Style[store new polygonn,Blue,Bold]},{True,False}}, Style[Controls For Stored Polygons,Bold], {{showpols,1,Style[show stored polygons]},0,1,ImageSize=AESmall}, {{delmax,False,Style[delete last shown]},{True,False}}, {{delall,False,Style[delete all stored]},{True,False}}, {{pols,{}},ControlType=AENone}, {{pts,{}},ControlType=AENone}, {{polcols,{}},ControlType=AENone}, ControlPlacement=AELeft, SaveDefinitions=AETrue ] === Subject: Re: How to remove unneeded constraints > The problem I am working on is a pretty large problem, which I am solving by dividing it into a lot of subproblems. > > As such, I have a large list of constraints that apply to the entire problem, but are not relevant for each individual subproblem. > > This becomes a problem when I use Refine, as it takes a very long time when you have a lot of conditions, even though the conditions don't pertain to the problem. Example: > In[25]:= Table[Timing@Refine[p>q,Map[Subscript[x,#]>0&,Range[i]]],{i,1000,5000,1000}] > Out[25]= {{0.547,p>q},{1.797,p>q},{3.875,p>q},{8.594,p>q},{10.468,p>q}} > > And it only gets worse. > > However, for each individual call to Refine I make, I only need a small subset of the total constraints. > > So what I want to do is something like this: > expr = some expression of n different variables; > cond = DeleteCases[totalConstraints, all cases which do not contain a variable from expr]; > result = Refine[expr,cond]; > > I have no idea how to construct a pattern powerful enough to do what is required for the DeleteCases call, though. > > All of the variables are of the form Subscript[s,_,_,_] or Subscript[b,_,_] and the conditions can also contain expressions of several variables. > here is a toy problem I used to test the code below, hope it isn't to simple: expr = Total@ Table[Random[]*ToExpression[x <> ToString[i]]^i, {i, 1, 100, 5}] conditions = Table[ToExpression[x <> ToString[i - 1]] < Random[] < ToExpression[x <> ToString[i]], {i, 1, 100}] This will construct a pattern that matches all variables in expr (maybe you need some fine tuning to extract only those symbols which represent variables in your problem): varpattern = Alternatives @@ Cases[expr, _Symbol,Infinity] Now you can use that pattern to extract the relevant conditions: DeleteCases[conditions, _?(FreeQ[#, varpattern] &)] If you haven't seen this kind of pattern yet, search for PatternTest in the documentation. In cases where a pattern where such a PatternTest using a pure function is necessary, I usually prefere to use Select instead of DeleteCases/Cases, but in this case it isn't much clearer or shorter: Select[conditions, MemberQ[#, varpattern, Infinity] &] hth, albert === Subject: Re: How to remove unneeded constraints > The problem I am working on is a pretty large problem, which I am solving by dividing it into a lot of subproblems. > > As such, I have a large list of constraints that apply to the entire problem, but are not relevant for each individual subproblem. > > This becomes a problem when I use Refine, as it takes a very long time when you have a lot of conditions, even though the conditions don't pertain to the problem. Example: > In[25]:= Table[Timing@Refine[p>q,Map[Subscript[x,#]>0&,Range[i]]],{i,1000,5000,1000}] > Out[25]= {{0.547,p>q},{1.797,p>q},{3.875,p>q},{8.594,p>q},{10.468,p>q}} > > And it only gets worse. > > However, for each individual call to Refine I make, I only need a small subset of the total constraints. > > So what I want to do is something like this: > expr = some expression of n different variables; > cond = DeleteCases[totalConstraints, all cases which do not contain a variable from expr]; > result = Refine[expr,cond]; > > I have no idea how to construct a pattern powerful enough to do what is required for the DeleteCases call, though. > > All of the variables are of the form Subscript[s,_,_,_] or Subscript[b,_,_] and the conditions can also contain expressions of several variables. Hi Kristian, A possible solution that I would recommend uses *FreeQ[]* for pattern matching and *Pick[]* to build the list of constraints that do not contains the unneeded variables. In[1]:= (* We make an arbitrary list of constraints *) conds = {E^(Subscript[s, 1, 1, 2] + Subscript[b, 3, 1]) > 1, E^(Subscript[s, 1, 1, 3] + Subscript[b, 3, 1])/+Subscript[b, 2, 2] <= 100, Abs[Log[Subscript[s, 1, 1, 3]^Sin[Subscript[b, 1, 2] Pi]]] <= 2}; (* We look for any expression that does not have a variable s for which the third index is 3 *) FreeQ[#, Subscript[s, _, _, 3] ] & /@ conds (*We look for any expression that does not have the variable b with first index equal to 3 *) FreeQ[#, Subscript[b, 3, _] ] & /@ conds (* The returned list does not contain any expression that contains the variable s for which its third index is 3 *) Pick[conds, FreeQ[#, Subscript[s, _, _, 3] ] & /@ conds] (* The following examples should be self-explanatory by now *) Pick[#, FreeQ[#, Subscript[b, ___, 3, ___] ] & /@ #] &@conds Pick[#, FreeQ[#, Subscript[_, 1, 2, ___] ] & /@ #] &@conds Pick[#, FreeQ[#, Subscript[b, 1, 2] | Subscript[s, 1, _, 2]] & /@ #] &@conds Out[2]= {True, False, False} Out[3]= {False, False, True} Out[4]= b + s 3,1 1,1,2 {E > 1} Out[5]= Sin[Pi b ] 1,2 {Abs[Log[s ]] <= 2} 1,1,3 Out[6]= b + s b + s 3,1 1,1,3 3,1 1,1,2 E {E > 1, -------------- <= 100} b 2,2 Out[7]= b + s 3,1 1,1,3 E {-------------- <= 100} b 2,2 -- === Subject: Re: How to remove unneeded constraints > Hello > > The problem I am working on is a pretty large problem, which I am solving by dividing it into a lot of subproblems. > > As such, I have a large list of constraints that apply to the entire problem, but are not relevant for each individual subproblem. > > This becomes a problem when I use Refine, as it takes a very long time when you have a lot of conditions, even though the conditions don't pertain to the problem. Example: > In[25]:= Table[Timing@Refine[p>q,Map[Subscript[x,#]>0&,Range[i]]],{i,1000,5000,1000}] > Out[25]= {{0.547,p>q},{1.797,p>q},{3.875,p>q},{8.594,p>q},{10.468,p>q}} > > And it only gets worse. > > However, for each individual call to Refine I make, I only need a small subset of the total constraints. > > So what I want to do is something like this: > expr = some expression of n different variables; > cond = DeleteCases[totalConstraints, all cases which do not contain a variable from expr]; > result = Refine[expr,cond]; > > I have no idea how to construct a pattern powerful enough to do what is required for the DeleteCases call, though. > > All of the variables are of the form Subscript[s,_,_,_] or Subscript[b,_,_] and the conditions can also contain expressions of several variables. > > The following should work if the constraints are just a linear concatenation of equations/inequalities: In[1]:= expr = Subscript[a, 1] + Subscript[a, 2] Subscript[a, 3] Out[1]= Subscript[a, 1] + Subscript[a, 2] Subscript[a, 3] In[2]:= constraints = And @@ (Subscript[a, #] > 0 & /@ Range[5000]); In[3]:= Timing[ filteredConstraints = With[ {relevantVariables = Union@Cases[expr, Subscript[__], Infinity]}, Select[constraints, ! FreeQ[#, Alternatives @@ relevantVariables] &] ] ] Out[3]= {0.047, Subscript[a, 1] > 0 && Subscript[a, 2] > 0 && Subscript[a, 3] > 0} In[4]:= Refine[expr > 0, filteredConstraints] // Timing Out[4]= {0., True} In[5]:= Refine[expr > 0, constraints] // Timing Out[5]= {10.797, True} === Subject: Exclusions I'm having a little trouble with the use of Exclusions for plotting. If I use Exclusions -> Automatic in the following, Plot3D finds no exclusions. pdfN[{x_, y_} := PDF[MultinormalDistribution[{0, 0}, {{1, 0}, {0, 1}}], {x, y}]; grayColors = Function[{x, y, z}, (Lighter[Gray, #] &)[z]]; Plot3D[ pdfN[{x, y}], {x, -3, 3}, {y, -3, 3}, PlotRange -> Full, Mesh -> 30, ColorFunction -> grayColors, PlotPoints -> 50, Exclusions -> Automatic, ExclusionsStyle -> {None, Directive[Thick, Red]}, MaxRecursion -> 0, AxesLabel -> {x, y}] However, if I try to exclude a cross-section through the mean of the distribution asin the following, as well as my defined Exclusions, I get an exclusion drawn at {y == 0, x < 0}, even though I have used inequalities to exclude y == 0 from my Exclusions. Plot3D[ pdfN[{x, y}], {x, -3, 3}, {y, -3, 3}, PlotRange -> Full, Mesh -> 30, ColorFunction -> grayColors, PlotPoints -> 50, Exclusions -> {{ArcTan[x, y] == 0.5, x > 0 && y > 0}, {ArcTan[x, y] == -Pi + 0.5, x < 0 &7 y < 0}}, ExclusionsStyle -> {None, Directive[Thick, Red]}, MaxRecursion -> 0, AxesLabel -> x, y}] Can anyone see a way that I can avoid this? === Subject: Re: Exclusions > I'm having a little trouble with the use of Exclusions for plotting. > > If I use Exclusions -> Automatic in the following, Plot3D finds no > exclusions. > > pdfN[{x_, y_} := PDF[MultinormalDistribution[{0, 0}, {{1, 0}, {0, Syntax error: a square bracket is missing. ------------------------------------------ > 1}}], {x, y}]; > > grayColors = Function[{x, y, z}, (Lighter[Gray, #] &)[z]]; > > Plot3D[ pdfN[{x, y}], {x, -3, 3}, {y, -3, 3}, PlotRange -> Full, > Mesh -> 30, ColorFunction -> grayColors, PlotPoints -> 50, > Exclusions -> Automatic, > ExclusionsStyle -> {None, Directive[Thick, Red]}, MaxRecursion -> 0, > AxesLabel -> {x, y}] > > However, if I try to exclude a cross-section through the mean of the > distribution asin the following, as well as my defined Exclusions, I > get an exclusion drawn at {y == 0, x < 0}, even though I have used > inequalities to exclude y == 0 from my Exclusions. > > Plot3D[ pdfN[{x, y}], {x, -3, 3}, {y, -3, 3}, PlotRange -> Full, > Mesh -> 30, ColorFunction -> grayColors, PlotPoints -> 50, > Exclusions -> {{ArcTan[x, y] == 0.5, x > 0 && y > 0}, {ArcTan[x, y] > == -Pi + 0.5, x < 0 &7 y < 0}}, Very likely typo: should be double ampersand sign if logical AND is intended. As written, you check whether the product of a pure function by seven times y is less than zero. ---------------------------------------------------------------------- > ExclusionsStyle -> {None, Directive[Thick, Red]}, MaxRecursion -> 0, > AxesLabel -> x, y}] Syntax error: a curly bracket is missing. ----------------------------------------- > Can anyone see a way that I can avoid this? > Exclusions -> Automatic excludes subregions associated with discontinuities. Since the function you posted is continuous, why do you expect to get any exclusion with this setting? Anyway, you may be more interested in the option *RegionFunction*, which specifies the region to include in the plot drawn. You will find below a syntacticly correct version of your code. Needs[MultivariateStatistics`] pdfN[{x_, y_}] := PDF[MultinormalDistribution[{0, 0}, {{1, 0}, {0, 1}}], {x, y}]; Plot3D[pdfN[{x, y}], {x, -3, 3}, {y, -3, 3}] grayColors = Function[{x, y, z}, (Lighter[Gray, #] &)[z]]; Plot3D[pdfN[{x, y}], {x, -3, 3}, {y, -3, 3}, PlotRange -> Full, Mesh -> 30, ColorFunction -> grayColors, PlotPoints -> 50, Exclusions -> Automatic, ExclusionsStyle -> {None, Directive[Thick, Red]}, MaxRecursion -> 0, AxesLabel -> {x, y}] Plot3D[pdfN[{x, y}], {x, -3, 3}, {y, -3, 3}, PlotRange -> Full, Mesh -> 30, ColorFunction -> grayColors, PlotPoints -> 50, Exclusions -> {{ArcTan[x, y] == 0.5, x > 0 && y > 0}, {ArcTan[x, y] == -Pi + 0.5, x < 0 && y < 0}}, ExclusionsStyle -> {None, Directive[Thick, Red]}, MaxRecursion -> 0, AxesLabel -> {x, y}] -- === Subject: Re: Exclusions On Apr 22, 2:39 am, Gulliet My first post here - I have discovered the limitations of copying and pasting. In my notebook, the syntax is correct. I don't expect an automatic exclusion, but I do get an additional (unwanted) exclusion at y==0 && x<0 when I use the following command: Plot3D[ pdfN[{x, y}], {x, -3, 3}, {y, -3, 3}, PlotRange -> Full, Mesh -> 30, ColorFunction -> grayColors, PlotPoints -> 50, ClippingStyle -> None, Exclusions -> { {ArcTan[x, y] == 0.5, x > 0 && y > 0}, {ArcTan[x, y] == -Pi + 0.5, x < 0 && y < 0}}, ExclusionsStyle -> {None, Directive[Thick, Red]}, MaxRecursion -> 0, AxesLabel -> {x, y}] === Subject: Re: Sorting 3 points p = {P1,P2,P3}; Sort[p, #1[[3]] < #2[[3]] &] Sort[p, Last[#1] < Last[#2] &] Bob Hanlon > Simple question, but documentation is no help. > I have three coordinate triplets: > > P1={x1,y1,z1} P2={x2,y2,z2} P3={x3,y3,z3} > > where all entries are numeric. I wont to sort them into > > P1s={xs1,ys1,zs1} P2s={xs2,ys2,zs2} P3s={xs3,ys3,zs3} > > so that zs3>=zs2>=zs1, with one command > > {P1s,P2s,P3s}=Sort[{P1,P2,P3}, Ordering Function] > > Is that possible and if so, which Ordering Function > === Subject: Re: Hamiltonian System with NDSolve I already tried that, and the problem still remains. Any other thoughts? === Subject: Re: Tilted decimals - Mathematica 6 Perhaps David Park has replied directly to you, but in case not... Point your browser to his Mathematica Page: http://home.comcast.net/~djmpark/Mathematica.html Scroll down to the section Packages for Sale. Click the link Presentations/DrawGraphics. At the bottom of the target page, click the link Purchase Presentations/DrawGraphics Package. It will take you to kagi.com, where you can place your order. The package you want is the first one, confusingly listed as DrawGraphics Mathematica Package. But if you order that, then you can download either the Mathematica 6.0-compatible Presentations package or else the earlier DrawGraphics package. (Kagi is similar to PayPal. You pay kagi.com by credit card, etc. You do NOT need any prior kind of account on kagi.com) > > I would like to send the following mail directly to you > ( djmpark@comcast.net, since Monday 14 April) > but I get always the following Message: > > Mailbox disabled for this recipient. > > Could you kindly tell me how to reach you ? > > Gianfranco Zosi > Dip. Fisica Generale > Universita di Torino > > > > > > I am ready to transfer 50 $ to you, but the link to Wolfram is not > clear at all, i.e., I have not seen any instruction for > Purchase Presentations Package. > Can I send them directly to you, through my Visa Card ? > > > Gianfranco > > PS I do not see in your exmaple, at least explicitly, the angle alpha Pi/6. > > > Here is one solution using the CustomTicks function from the Presentations > package. We also need to use NumberForm to extend the display precision, > otherwise all the numbers will be the same. > > Needs[Presentations`Master`] > > With[ > {xticks = CustomTicks[Identity, {123.45678, 123.45679, .000002, 5}, > CTNumberFunction - (Graphics[ > Text[Style[NumberForm[#, {9, 6}], 12], {0, 0}, {-1, 0}, {0, > 1}], > AspectRatio -> 6, > ImageSize -> {10, 60}] &)], > yticks = CustomTicks[Identity, {123.45678, 123.45679, .000002, 5}, > CTNumberFunction -> (NumberForm[#, {9, 6}] &)]}, > Draw2D[ > {Draw[x, {x, 123.45678, 123.45679}]}, > AspectRatio -> 1/GoldenRatio, > Frame -> True, > FrameTicks -> {{yticks, Automatic}, {xticks, > xticks // NoTickLabels}}, > FrameLabel -> {x, y}, > BaseStyle -> {FontSize -> 12}] > ] > > However, that rather violates the principle: Maximize the information, > minimize the ink. 123.45678 is repeated 12 times! In technical publication > the tick labels themselves are usually simplified and the functional > relation between the tick values and the quantity is put in the frame > labels. Here the tick labels go from 0 to 1 on the x and y axes. > > With[ > {ticks = CustomTicks[#/105 + 123.45678 &, {0, 1, .2, 5}]}, > Draw2D[ > {Draw[x, {x, 123.45678, 123.45679}]}, > AspectRatio -> 1/GoldenRatio, > Frame -> True, > FrameTicks -> {{ticks, ticks // NoTickLabels}, {ticks, > ticks // NoTickLabels}}, > FrameLabel -> {(x-123.45678)!(*SuperscriptBox[10, 5]), > (y-123.45678)!(*SuperscriptBox[10, 5])}, > BaseStyle -> {FontSize -> 12}] > ] > > -- David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ > > > >> How can I see all the decimals on the x-axis **and** avoid overlapping ? > > >> Trivial example: Plot[x, {x, 123.45678, 123.45679}] > > >> I would like to rotate clockwise by an angle alpha (e.g.,Pi/6, or > >> Pi/2+Pi/6) > >> the values on the x-axis and translate them in order to see the starting > >> point, > >> i.e., the 1 of 123.45678 should be near to the relevant tick. > > >> Note: I cannot use the usual Options to reduce the **size** of the > >> figures or > >> increase the size of the image. > > >> Any hint ? > > >> PS The nice suggestion by Ruskeepaa (pag. 271) seems not applicable in > >> this case. > > >> Gianfranco Zosi > >> Dip. Fisica Generale > >> Universita di Torino > > > -- 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: Tilted decimals - Mathematica 6 I would like to send the following mail directly to you ( djmpark@comcast.net, since Monday 14 April) but I get always the following Message: Mailbox disabled for this recipient. Could you kindly tell me how to reach you ? Gianfranco Zosi Dip. Fisica Generale Universita di Torino I am ready to transfer 50 $ to you, but the link to Wolfram is not clear at all, i.e., I have not seen any instruction for Purchase Presentations Package. Can I send them directly to you, through my Visa Card ? Gianfranco PS I do not see in your exmaple, at least explicitly, the angle alpha Pi/6. Here is one solution using the CustomTicks function from the Presentations package. We also need to use NumberForm to extend the display precision, otherwise all the numbers will be the same. Needs[Presentations`Master`] With[ {xticks = CustomTicks[Identity, {123.45678, 123.45679, .000002, 5}, CTNumberFunction -> (Graphics[ Text[Style[NumberForm[#, {9, 6}], 12], {0, 0}, {-1, 0}, {0, 1}], AspectRatio -> 6, ImageSize -> {10, 60}] &)], yticks = CustomTicks[Identity, {123.45678, 123.45679, .000002, 5}, CTNumberFunction -> (NumberForm[#, {9, 6}] &)]}, Draw2D[ {Draw[x, {x, 123.45678, 123.45679}]}, AspectRatio -> 1/GoldenRatio, Frame -> True, FrameTicks -> {{yticks, Automatic}, {xticks, xticks // NoTickLabels}}, FrameLabel -> {x, y}, BaseStyle -> {FontSize -> 12}] ] However, that rather violates the principle: Maximize the information, minimize the ink. 123.45678 is repeated 12 times! In technical publication the tick labels themselves are usually simplified and the functional relation between the tick values and the quantity is put in the frame labels. Here the tick labels go from 0 to 1 on the x and y axes. With[ {ticks = CustomTicks[#/105 + 123.45678 &, {0, 1, .2, 5}]}, Draw2D[ {Draw[x, {x, 123.45678, 123.45679}]}, AspectRatio -> 1/GoldenRatio, Frame -> True, FrameTicks -> {{ticks, ticks // NoTickLabels}, {ticks, ticks // NoTickLabels}}, FrameLabel -> {(x-123.45678)!(*SuperscriptBox[10, 5]), (y-123.45678)!(*SuperscriptBox[10, 5])}, BaseStyle -> {FontSize -> 12}] ] -- David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ >> >> How can I see all the decimals on the x-axis **and** avoid overlapping ? >> >> Trivial example: Plot[x, {x, 123.45678, 123.45679}] >> >> I would like to rotate clockwise by an angle alpha (e.g.,Pi/6, or >> Pi/2+Pi/6) >> the values on the x-axis and translate them in order to see the starting >> point, >> i.e., the 1 of 123.45678 should be near to the relevant tick. >> >> Note: I cannot use the usual Options to reduce the **size** of the >> figures or >> increase the size of the image. >> >> Any hint ? >> >> PS The nice suggestion by Ruskeepaa (pag. 271) seems not applicable in >> this case. >> >> Gianfranco Zosi >> Dip. Fisica Generale >> Universita di Torino >> === Subject: Re: DifferenitalD vs CapitalDifferenitalD After applying Jens correction, I was hoping to be able to use the DifferentialD with x, etc. and then use the 'dx' , where 'd' here is DifferentialD (just dont know how to add it here in the email), so it would be a Symbol....but this didnt work....I realize I can use the straight forward dx , etc. symbol but I want to highlight the Differential....any way to 'fix' this?....when I type in DifferentialD , from the Palette, and then add x to it and perform //Head on it , it just returns DifferentialD thank you....jerry blimbaum ----- Original Message ----- === Subject: Re: DifferenitalD vs CapitalDifferenitalD this is a bug, add MakeBoxes[DifferentialD[x_], fmt_] := RowBox[{[DifferentialD], ToBoxes[x, fmt]}] Jens > The documentation for DifferenitalD states: DifferenitalD[x] displays as dx , where instead of d appears the > smybol entered as esc dd esc (without the spaces). Yet when I > enter DifferentialD[x] and evaluate I get back DifferenitalD[x] (not > esc dd esc x ). The documentation for CapitalDifferentialD seems identical to that for > DifferentialD. Yet when I enter CapitalDifferentialD[x] I get Dx > where D is the symbol entered as esc DD esc. Moreover, esc dd esc x evaluates to DifferenitalD[x] but esc DD esc > x evaluates to esc DD esc x. It is all so confusing I feel like giving up on Mathematica > typesetting altogether. Can anyone explain what is going on here? This is with $Version > 6.0 for Mac OS X x86 (64-bit) (March 13, 2008) > $ReleaseNumber > 2 Andrzej Kozlowski > === Subject: Vector valued differential equations I lately asked if it is possible to write differential equations of vector valued functions without having to explicitely write all components. For the following cases it can be done very easily: Assume we are looking for a vector valued function y[t]={y1[t],y2[t]..,ym[t]}. To begin with, assume further that we have a first order differential equations that can be written explicitly as: y1'= f1[t,y]; y2'=f2[t,y],..,fm[t,y] then with F[t_,y_?VectorQ]:={f1[t,y],f12[t,y],..} where VectorQ ensure that the function is not called with symbolic arguments. With initial conditions y0={y10,y20,..} we can write the DE like: eq={y'[t]==F[t,y[t]], y[0]==y0}; NDSolve[eq,y[t],{t,0,tend}] If we have a n-th order DE, we may use the same trick. We now have: y1'= f11[t,y,y'..]; y2'=f21[..];..;ym'=fm1[..]; y1''=f12[..];..;ym''=fm2[..]; .... y1((n-1) derivative))= f1(n-1)[..];..;ym((n-1)derivative)=fm(n-1)[..] instead of y we have: f={y1,y2,..,y1',y2',..,(n-1)derivative of y1,..} with F and initial conditions f0: F[t_,f_?VectorQ]:={f11,f21,..,fm1,f21,f22,..,fm2,..,f1(n-1)} f0={y1[0],..,ym[0],y1'[0],..,(n-1)drivative of fm[0]} the DE can be written: eq={f'[t]==F[t,f[t]], f[0]==f0}; NDSolve[eq,y[t],{t,0,tend}] Here is a simple example, the 2-dim Kepler problem: f0={10,0,0,0.18};(*{x,y,vx,vy}*) tend=80; F[p_?VectorQ]:=({p[[3]],p[[4]],-p[[1]]/(p[[1]]^2+p[[2]]^2)^(3/2),-p[[2]]/(p[ [1]]^2+p[[2]]^2)^(3/2)}); eq={f'[t]==F[f[t]],f[0]==f0}; sol4=f[t]/.NDSolve[eq,f[t],{t,0,tend}][[1]]; ParametricPlot[{sol4[[1]],sol4[[2]]},{t,0,tend},Mesh->True] Daniel === Subject: Re: Comments on the .m file editor > I don't see the advantages of writing package with the .m file editor. > Normally I don't even look at the .m file. I would be interested in hearing > comments from some of the sophisticated users about when writing .m files > directly might be advantagous. > > Normally a routine should be written and debugged in a regular Mathematica > ..nb notebook. A debugging method that works for almost all cases and is very > easy to use is just to insert temporary Print statements into the routine. > > When a routine is debugged, and a usage message and SyntaxInformation are > written it can just be moved to a package.nb notebook with Initialization > cells that has been saved as an Auto Generated Package. > > That is by far the easiest method. > > You can put (* comments *) anywhere in a Mathematica expression but one very > negative feature of Mathematica is that if one uses Shift-Ctrl-N or > Shift-Ctrl-I to convert and reformat a cell it strips out all the comments. > I think comments should be considered a permanent part of an expression and > never stripped out by such reformating. > I find there are lots of advantages to having computer code in a simple text file. It makes it easy to use utilities like grep and file comparators, or to create your own utilities - such as a code indenter that works to your personal whim! The ability to skip to a particular function or section is also convenient. The time I must have wasted debugging AutoGenetated Page's in which one cell was accidentally not marked as Initialisation - editing one file is so much nicer. David Bailey http://www.dbaileyconsultancy.co.uk === Subject: Re: Comments on the .m file editor > Since the .m is in plaintext (let's not go into how a .nb is > also plaintext), it is easier to run commands like unix's diff on > the code tree to see what changed. In order for this to work right, > the .m file must be indented in a way that promotes readability... That reminds me: the .m file editor doesn't have any sort of indenting features! At the very very least, padding out a newline with the same leading spaces as the previous line would make life so much easier. Also, if people don't want constructions like [alpha] cluttering up their diffs, they are more than free to use basic ascii for their code. The reason that I started using the .m file editor to write packages is because the documentation lead me there. I've heard of initialisation cells and auto-generated packages, but it all seemed (at the time) like black magic compared to opening up the package and editing it. > I don't see the advantages of writing package with the .m file editor. > Normally I don't even look at the .m file. Can you use the interactive debugger with notebooks? The only reason I want to stick with the .m file editor is that you can insert outline comments anywhere in the code. This allows much more flexible code commenting. Actually, I'm considering writing my Mathematica code in LaTeX's docstrip format, but it would lack some of the niceties of doing everything within Mathematica's frontend. You wouldn't want to look in an auto-generated .m file. It's not a pretty sight. But a handwritten one is as easy to read as a notebook, modulo the nice symbols and typesetting=85 Will === Subject: Re: Problems to find the local extrema of an InterpolatingFunction As an unexperienced mathematica user, now I am just wondering how I can get full information on the explicit form of piecewise polynomials generated by Interpolation[] from a given set of points. What kind of algorithm does Interpolation use? I know e.g. that the default interpolation order is 3, but I'd like to know if it's a natural spline or what exactly is the default output. === Subject: Converting Power terms to Times terms I am using Dolfin/FFC for solving finite element problems. I want to use Mathematica for generating the linear and bilinear terms of the weak equation. After computing the terms, I use the InputForm, and then give the results to FFC compiler. The problem is that FFC does not accept power function. Therefore, terms such as a^2 must be written as a*a. Because there are many terms in the weak form of my problem, manual conversion of power terms takes a long time (and probably is subject to errors). Is there any way to disable power function, or stop times function to be simplified in the power form? Any other solution? Reza === Subject: Re: Converting Power terms to Times terms no, but you can redefine the output of Power[], so that it look like a*a*a, i.e. Unprotect[Power] Format[Power[a_, n_Integer], FortranForm] := (HoldForm @@ {Table[a, {n}]}) /. List -> Times Protect[Power] and FortranForm[a*b^4*Sin[w^2]] gives a*(b*b*b*b)*Sin(w*w) Jens > > I am using Dolfin/FFC for solving finite element problems. I want to use Mathematica for generating the linear and bilinear terms of the weak equation. After computing the terms, I use the InputForm, and then give the results to FFC compiler. The problem is that FFC does not accept power function. Therefore, terms such as a^2 must be written as a*a. Because there are many terms in the weak form of my problem, manual conversion of power terms takes a long time (and probably is subject to errors). > > Is there any way to disable power function, or stop times function to be simplified in the power form? > > Any other solution? > > Reza > > === Subject: Re: Converting Power terms to Times terms Hello Reza, Perhaps CForm or FortranForm may get you close? I don't know what dolfin/fcc syntax looks like. I used to solve problems like this by doing fancy editing tricks on the output. But that was Math version 1. Best Wishes, Craig I am using Dolfin/FFC for solving finite element problems. I want to use Mathematica Is there any way to disable power function, or stop times function to be simplified in the power form? -- W. Craig Carter === Subject: Re: Converting Power terms to Times terms Hi Reza, we may prevent Power to gobble up terms by e.g. converting the terms into a string. If you then copy the resulting expression to the clipboard as plain text the quotes are not copied. Here is an example: (1+a)^3+(1-a)^5/.Power[x_,n_Integer]:>Nest[#<>*(<>ToString[x]<>)&, 1,n] there is an superfluous 1* that will not hurt. hope this helps, Daniel > > I am using Dolfin/FFC for solving finite element problems. I want to use Mathematica for generating the linear and bilinear terms of the weak equation. After computing the terms, I use the InputForm, and then give the results to FFC compiler. The problem is that FFC does not accept power function. Therefore, terms such as a^2 must be written as a*a. Because there are many terms in the weak form of my problem, manual conversion of power terms takes a long time (and probably is subject to errors). > > Is there any way to disable power function, or stop times function to be simplified in the power form? > > Any other solution? > > Reza > > === Subject: Re: problem accessing notebooks Dietmar === Subject: need help with Plot I have the following situation. f[z_,t_]=some function sol=Solve[f[z,t]==0,{z}] This returns {{z->sol1[t]},{z->sol2[t]},{z->sol3[t]},{z->sol4[t]}} I want to plot Plot[Select[{sol1[t],sol2[t],sol3[t],sol4[t]},#>t&] But it doesn't plot correctly. Depending on t, Select returns either 2 or 4 values. Plot correctly plots only the sections for which Select returns 2 values (it plots two curves), and doesn't plot anything for the interval for t, in which Select returns 4 values. Can anyone help to fix this? I should also mention, that if I restrict t to only the interval where Select returns 4 values, Plot correctly plots 4 curves. === Subject: Re: need help with Plot Plot can not deal with a varying number of functions. But as a work around you may define new functions that are zero where you do not want them to draw. As dirty trick, you may instead of returning zero, you may return a symbol. In version 6, this has the effect, that this part is not drawn. Here an example with zero: sol=4 t{Sin[2Pi t],1.2 Sin[ 2.2 Pi t],1.4Sin[ 2.4Pi t], Sin[2.6Pi t]}; {sol1[t_],sol2[t_],sol3[t_],sol4[t_]}=If[# > I have the following situation. > > f[z_,t_]=some function > sol=Solve[f[z,t]==0,{z}] > This returns > {{z->sol1[t]},{z->sol2[t]},{z->sol3[t]},{z->sol4[t]}} > I want to plot > Plot[Select[{sol1[t],sol2[t],sol3[t],sol4[t]},#>t&] > But it doesn't plot correctly. Depending on t, Select returns either 2 or 4 values. Plot correctly plots only the sections for which Select returns 2 values (it plots two curves), and doesn't plot anything for the interval for t, in which Select returns 4 values. > Can anyone help to fix this? > > I should also mention, that if I restrict t to only the interval where Select returns 4 values, Plot correctly plots 4 curves. > > === Subject: Re: DifferenitalD vs CapitalDifferenitalD The way this started was an Instructor friend is teaching a course in Fields. He asked me why I use Mathematica rather then another product. I explained and told him I would show him some examples. One example I chose was to determine the Directional Derivative. Well, this involves differentials. I merely wanted to 'highlight' the differential visually. I wasnt trying to use DifferentialD as an operator. Of course, I have seen DifferentialD often enough in integrals. I was 'hoping' I could also use it this other way. for example, the element of path length , ds = Sqrt[dx^2 + dy^2 ] I would have preferred that I could type all the 'd's here as DifferentialD and, of, course solve for DifferentialDs if I knew the other differentials. But that was exactly what I couldnt do....In principle there is nothing 'wrong' with simply ds, dx, etc...I just wanted a different 'visual' on the screen. > After applying Jens correction, I was hoping to be able to use the > DifferentialD with x, etc. and then use the 'dx' , where 'd' here is > DifferentialD (just dont know how to add it here in the email), so it > would be a Symbol....but this didnt work....I realize I can use the > straight forward dx , etc. symbol but I want to highlight the > Differential....any way to 'fix' this?....when I type in DifferentialD > , from the Palette, and then add x to it and perform //Head on it , it > just returns DifferentialD thank you....jerry blimbaum > [DifferentialD]x cannot be used as a symbol because [DifferentialD] is treated as an operator. A symbol name must start with a letter. But why do you want to use [DifferentialD]x as a symbol anyway? I cannot imagine any reasonable application for this. If you explained your motivation for wanting to have a symbol with this name, perhaps we could say something more useful ... === Subject: Re: Sorting 3 points > Simple question, but documentation is no help. > I have three coordinate triplets: P1={x1,y1,z1} P2={x2,y2,z2} P3={x3,y3,z3} where all entries are numeric. I wont to sort them into P1s={xs1,ys1,zs1} P2s={xs2,ys2,zs2} P3s={xs3,ys3,zs3} so that zs3>=zs2>=zs1, with one command {P1s,P2s,P3s}=Sort[{P1,P2,P3}, Ordering Function] Is that possible and if so, which Ordering Function > Sort[{P1,P2,P3},#1[[3]]<#2[[3]]&] Ssezi === Subject: Re: Sorting 3 points Three possible solutions: In[1]:= Reverse[SortBy[{{2, 3, 1}, {3, 5, 8}, {5, 1, 6}}, Last]] Out[1]= {{3, 5, 8}, {5, 1, 6}, {2, 3, 1}} In[2]:= SortBy[{{2, 3, 1}, {3, 5, 8}, {5, 1, 6}}, Last[-#1] & ] Out[2]= {{3, 5, 8}, {5, 1, 6}, {2, 3, 1}} In[3]:= Sort[{{2, 3, 1}, {3, 5, 8}, {5, 1, 6}}, #1[[3]] > #2[[3]] & ] Out[3]= {{3, 5, 8}, {5, 1, 6}, {2, 3, 1}} Adriano Pascoletti > Simple question, but documentation is no help. > I have three coordinate triplets: P1={x1,y1,z1} P2={x2,y2,z2} P3={x3,y3,z3} where all entries are numeric. I wont to sort them into P1s={xs1,ys1,zs1} P2s={xs2,ys2,zs2} P3s={xs3,ys3,zs3} so that zs3>=zs2>=zs1, with one command {P1s,P2s,P3s}=Sort[{P1,P2,P3}, Ordering Function] Is that possible and if so, which Ordering Function === Subject: Re: Sorting 3 points Carlos, This is the last of the 'basic examples' from the Help on Sort: In: Sort[{{a,2},{c,1},{d,3}},#1[[2]]<#2[[2]]&] Out: {{c,1},{a,2},{d,3}} The sorting function is #1[[2]]<#2[[2]]& It should be easy to work out from this what you have to modify in this sorting function to achieve the results you want. Maarten carlos@Colora cc: === 21/04/2008 Subject: Sorting 3 points 09:21 Simple question, but documentation is no help. I have three coordinate triplets: P1={x1,y1,z1} P2={x2,y2,z2} P3={x3,y3,z3} where all entries are numeric. I wont to sort them into P1s={xs1,ys1,zs1} P2s={xs2,ys2,zs2} P3s={xs3,ys3,zs3} so that zs3>=zs2>=zs1, with one command {P1s,P2s,P3s}=Sort[{P1,P2,P3}, Ordering Function] Is that possible and if so, which Ordering Function === Subject: Dynamic: feature? I have a cell containing this: Dynamic[f[a, b]] Then I do this: a /: f[a, b] = 12 and the dynamic cell updates to 12, as I would expect. When I do this: b /: f[a, b] = 45 The dynamic cell does *not* update for some reason. It seems as though it does not realize an update has occurred when it is associated with b. Does anyone know why this is? Chris === Subject: Re: axis alignment of 3D plots with ListContourPlot3D I'd say that in a closer-to-ideal world, you *would* be limited to the options listed in the Documentation Centre. /snark CO > Hi and Craig, mathematica newbie I didn't know the Options command to view all options, > and thought I was limited to the options you see for each command in the Jess > === Subject: Re: axis alignment of 3D plots with ListContourPlot3D Hi and Craig, mathematica newbie I didn't know the Options command to view all options, and thought I was limited to the options you see for each command in the Jess > Hello Jess, > This will work, it is not efficient, but fairly straightforward to > modify for you own purposes: data = Table[{Sin[RandomReal[{-x, x}]], Cos[RandomReal[{-x, x}]], > Cos[ x]}, {x, 0, 1, .01}]; plot = ListPlot3D[data] Show[myplot, > ViewPoint -> r {Cos[theta] Sin[phi], Sin[theta] Sin[phi], Cos[phi]}] > (*here I use spherical coordinates, but the choice is yours) (* > You can also program your own flight trajectory and speed > *) > Can anyone tell me how I can manually the view angle of a > ListContourPlot3D? Mathematica seems to automatically set the view > angle according to the data distribution. I need to do this because I > am generating a series of 3D graphics with ListContourPlot3D, which I > then animate into a AVI movie using the export command. As the > distribution changes shape significantly in each image, Mathematica > automaitcally shifts the view angle substantially, which unfortunately > makes the resulting animation appear to shake as the view angle > changes. > > Jess > > -- > W. Craig Carter > === Subject: installing Player Pro killed using Mathematica itself: BEWARE! With an existing installation of Mathematica 6.0.2 under Windows, I just installed Player Pro. The result: if I start Mathematica itself and open a new notebook there, I am prohibited from typing any and all input. This sort of thing is intolerable! An utterly time-frittering aggravation. I suspect that the scenario involved here was not tested by WRI: My mathpass for Mathematica itself is in the Licensing subdirectory of my USERBASE directory, which is the same as my BASE directory (both set by Windows environment variables MATHEMATICA_BASE and MATHEMATICA_USERBASE). This is hardly the first time I have run into trouble with multiple passwords from multiple Wolfram Research products. It is something they have just not yet gotten right. Beware! What I did as a temporary fix was to use my Windows backup program to restore my pre-existing mathpass file. Now regular Mathematica works. But of course Player Pro does not. -- Murray Eisenberg murray@math.umass.edu Mathematics & Statistics Dept. Lederle Graduate Research Tower phone 413 549-1020 (H) University of Massachusetts 413 545-2859 (W) 710 North Pleasant Street fax 413 545-1801 Amherst, MA 01003-9305 === Subject: Re: Column Product of a Matrix of zeros and 1's >I have a matrix of zero's and ones: myGlobalMatrix; also a set >called thisSet with the columns of myGlobalMatrix which have to be >multiplied (e.g. column 1,3,4). I would like to know the positions >of the 1's. I do this as follows: >Flatten[Position[Product[myGlobalMatrix[[All,i]],{i, thisSet}],1]] >But this is to general. It does not use that the matrix consists of >zeros and ones. Can this be taken into account? with friendly I am unclear as to what you are trying to accomplish. If myGloblMatrix consists of just ones and zeros, then probably the fastest way to locate all of the ones would be Most@ArrayRules@SparseArray@myGlobalMatricx It looks like the code you have above locates all rows of myGlobalMatrix where the first thisSet columns are 1 If this is what you want, then one way would be Position[Clip[Total/@(myGlobalMatrix[[All,;;thisSet]]),{thisSet,thisSet},{0= ,1}],1] Here, I assume you are using verision 6.x === Subject: waveform I'm new to the audio functions of Mathematica, and I'd like to create a waveform that is a sine wave of whose frequency increasing linearly over time. Does anybody know a way to do this? Jack === Subject: Re: Print[Plot] vs Print[text,Plot]? > I've just executed a test cell containing Print[Plot[---]]; > Print[Some textn, Plot[---]]; (same simple plot in both lines; objective of 2nd line being to get the > text and the plot -- eventually several plots -- into the same output > cell) Result from first line is expected plot; result from second line is a > miniaturized plot about 1/4 the size of the first one. * This is sensible or useful? * This is what a novice user should expect as consistent > and reasonable behavior from the above commands? (Print[Plot] doesn't do the same thing with a given Plot > as does Print[----, Plot[], ----] ???) * This is documented --or better, warned about -- where? (since it looks like I'll have to, once again, step aside from > attempting to accomplish anything useful with 6.0 and > burn up more time digging into its arcane documentation, > trying to understand this. Apologies for the sarcasm -- > but that's the way it feels.) This is controlled by the option ImageSizeMultipliers, which can be changed at different levels if you want to. E.g., SetOptions[EvaluationNotebook[], ImageSizeMultipliers -> {1, 1}] {Plot[x, {x, 0, 1}], xxx} Maxim Rytin m.r@inbox.ru === Subject: Re: Print[Plot] vs Print[text,Plot]? > I've just executed a test cell containing > > Print[Plot[---]]; > Print[Some textn, Plot[---]]; > > (same simple plot in both lines; objective of 2nd line being to get the > text and the plot -- eventually several plots -- into the same output > cell) > > Result from first line is expected plot; result from second line is a > miniaturized plot about 1/4 the size of the first one. > > * This is sensible or useful? the default for ImageSize is Automatic, so I think it is sensible that the ImageSize is determined automatically, depending on what is to be shown. Whether or not the size in the second case is too small or not is a rather useless discussion. If you want a definite size for your plot use ImageSize to set it. > * This is what a novice user should expect as consistent > and reasonable behavior from the above commands? > > (Print[Plot] doesn't do the same thing with a given Plot > as does Print[----, Plot[], ----] ???) There are plenty of cases where mathematica does things automagically, so I think it is something that even a novice user will get used to and probably even appreciates. Just think about the automatic choosing of plotranges, plotstyles, ... I, for my part, am quite happy that I only have to mess around with these if the automatisms don't work well enough... > * This is documented --or better, warned about -- where? > > (since it looks like I'll have to, once again, step aside from > attempting to accomplish anything useful with 6.0 and > burn up more time digging into its arcane documentation, > trying to understand this. Apologies for the sarcasm -- > but that's the way it feels.) Specifications for both width and height can be any of the following: * Automatic determined by location or other dimension (default) * Tiny, Small, Medium, Large pre-defined absolute sizes ... I have never felt the need to read this in the documetation. Maybe you should just take the advantage that mathematica lets you work interactivley: try things out and accept that things are like they are. If you don't like the program or some of it's features, don't use them. There are alternatives and the old versions, and what you could do with them mostly still works with version 6. hth, albert === Subject: Re: Print[Plot] vs Print[text,Plot]? > I've just executed a test cell containing Print[Plot[---]]; > Print[Some textn, Plot[---]]; (same simple plot in both lines; objective of 2nd line being to get the > text and the plot -- eventually several plots -- into the same output > cell) Result from first line is expected plot; result from second line is a > miniaturized plot about 1/4 the size of the first one. * This is sensible or useful? * This is what a novice user should expect as consistent > and reasonable behavior from the above commands? (Print[Plot] doesn't do the same thing with a given Plot > as does Print[----, Plot[], ----] ???) * This is documented --or better, warned about -- where? (since it looks like I'll have to, once again, step aside from > attempting to accomplish anything useful with 6.0 and > burn up more time digging into its arcane documentation, > trying to understand this. Apologies for the sarcasm -- > but that's the way it feels.) I am agree absolutely. And the solution is not so obvious as one can expect. To change this behavour you need to modify the option ImageSize inside Plot[] command. This option specifies the width of the image in pixels when only one numerical argument is passed: plot = Plot[Sin[x], {x, 0, 6 Pi}, ImageSize -> 300]; And you can not control the size of the image with Graphics[Plot[], ImageSize -> 300]. This does not work. http://mathforum.org/kb/message.jspa?messageID=6184854&tstart=15 === Subject: Re: Print[Plot] vs Print[text,Plot]? > I've just executed a test cell containing > > Print[Plot[---]]; > Print[Some textn, Plot[---]]; > > (same simple plot in both lines; objective of 2nd line being to get the > text and the plot -- eventually several plots -- into the same output > cell) You do not need print for this. Here are some ways to do it using PlotLabel or Labeled, and GraphicsRow, GraphicsColumn, or GraphicsRid. Plot[Sin[x], {x, 0, 2 [Pi]}, PlotLabel -> Some text] Labeled[Plot[Sin[x], {x, 0, 2 [Pi]}], Some text, Top] Labeled[Plot[Sin[x], {x, 0, 2 [Pi]}], Some text, Bottom] GraphicsRow[{Plot[Sin[x], {x, 0, 2 [Pi]}, PlotLabel -> Plot 1], Plot[Cos[x], {x, 0, 2 [Pi]}, PlotLabel -> Plot 2]}] Labeled[GraphicsGrid[{{Plot[Sin[x], {x, 0, 2 [Pi]}, PlotLabel -> Plot 1], Plot[Cos[x], {x, 0, 2 [Pi]}, PlotLabel -> Plot 2]}, {Plot[Tan[x], {x, 0, 2 [Pi]}, PlotLabel -> Plot 3], Plot[Cot[x], {x, 0, 2 [Pi]}, PlotLabel -> Plot 4]}}], My plots, Top] Incidentally, you will usually get better answers here if you post specific Mathematica code that others can copy/paste into a notebook and execute, so that they don't have to make up examples for you. -- Helen Read University of Vermont === Subject: Re: Print[Plot] vs Print[text,Plot]? > I've just executed a test cell containing > > Print[Plot[---]]; > Print[Some textn, Plot[---]]; > > (same simple plot in both lines; objective of 2nd line being to get the > text and the plot -- eventually several plots -- into the same output > cell) Getting precise control of the size and position of graphics objects -- such as Column, Row, GraphicsRow, GraphicsColumn, Inset, etc. For instance, the above example can be written Column[{Some text, Plot[Sin[x], {x, 0, 10}]}] The output should be more of your liking. (Note that we have not use any of the available options.) Print is of really use when one wants to display some information within a loop or block structure. Do[Print[Column[{Some text, Plot[Sin[x], {x, 0, 10}]}]]; Print[Some other text], {3}] -- === Subject: Re: Print[Plot] vs Print[text,Plot]? > I've just executed a test cell containing > > Print[Plot[---]]; > Print[Some textn, Plot[---]]; > > (same simple plot in both lines; objective of 2nd line being to get the > text and the plot -- eventually several plots -- into the same output > cell) > > Result from first line is expected plot; result from second line is a > miniaturized plot about 1/4 the size of the first one. > > * This is sensible or useful? Yes, I think that it is useful that Mathematica descreases the size of graphics inlined in text. The same thing happens when you start typing in a cell that already contains a single graphic. In my subjective opinion, it would be really annyoing if the size weren't decreased automatically. > > * This is what a novice user should expect as consistent > and reasonable behavior from the above commands? > > (Print[Plot] doesn't do the same thing with a given Plot > as does Print[----, Plot[], ----] ???) > > * This is documented --or better, warned about -- where? > > (since it looks like I'll have to, once again, step aside from > attempting to accomplish anything useful with 6.0 and > burn up more time digging into its arcane documentation, > trying to understand this. Apologies for the sarcasm -- > but that's the way it feels.) Why don't you just use separate Print[] commands instead, to create separate cells? Or even better: avoid Print[] entirely, if possible. (Yes, I know that Print[]ing graphics is useful sometimes, but if all you need is an output with multiple plots, use Column instead.) === Subject: Re: Defining derivatives > > Derivative[1][f1] = f2; > > What can one _do_ with this construction? > Can one then plot or evaluate f1, without further ado? Fun, amusement, education, research, profit, ego... Here is an example that satisfies 4/6. (*caveat pedants, this is intended as a pedagogical exercise, lifted from my course notes, flames ignored*) GraphFunction[x_, y_] := ((x - y) (x + y))/(1 + (x + y)^2) (*simple graph f(x,y) ) $Assumptions = {x [Element] Reals, y [Element] Reals}; (*give simplify a hint *) CurvatureOfGraph[f_, x_, y_] := (*def. of curvature of f(x,y)*) FullSimplify[ (*silly to call simplify each time the function is called? not always*) Module[{dfdx = D[f[x, y], x], dfdy = D[f[x, y], y], d2fdx2 = D[f[x, y], {x, 2}], d2fdy2 = D[f[x, y], {y, 2}], d2fdxdy = D[f[x, y], x, y]} , Return[((1 + dfdx^2) d2fdx2 - 2 dfdx dfdy d2fdxdy + (1 + dfdy^2) d2fdy2)/ Sqrt[1 + dfdx^2 + dfdy^2]]]] CurvFunc = (*mysterious function definition for out particular surface*) Function[{x, y}, Evaluate[CurvatureOfGraph[GraphFunction, x, y]]] (*enigmatic defintions for partials on our surface*) dfdx = Function[{x, y}, Evaluate[FullSimplify[D[GraphFunction[x, y], x]]]] dfdy = Function[{x, y}, Evaluate[FullSimplify[D[GraphFunction[x, y], y]]]] angle[x_] := ((Pi/2 + ArcTan[x])/Pi) (*plot of function showing height, curvature, and normals, all in one go*) plotcurvature = Plot3D[GraphFunction[x, y], {x, -3, 3}, {y, 3, -3}, MeshFunctions -> (CurvFunc[#1, #2] &), MeshStyle -> Thick, PlotLabel -> Curvatures(level sets) and Normals(color variation), ColorFunction -> (Glow[ RGBColor[angle[dfdx[#1, #2]], angle[dfdy[#1, #2]], 0.75]] &),ColorFunctionScaling -> False, Lighting -> None] (*I think that's something*) -- W. Craig Carter === Subject: Re: Defining derivatives thank's a lot for the replies. Here is a short summary of what I just learned: - expressions with the form: f[..][..] are called SubValues of f. Documentation of this is non existent, but mathematica knows about it. - the best way to define derivatives is: Derivative[1][f]= f2 however, what is still not clear to me is why the following does not work: Derivative[1][f][x_]= f2[x] thank's again, Daniel > Hello All, > > does anybody know how to define symbolic derivatives. E.g.: > > f[x_]:=f1[x]; > > f'[x_]:=f2[x]; > > this does not work because f on the lefthand side is evaluated. To > > prevent this (do not forget to remove f before redefining it): > > f[x_]:=f1[x]; > > HoldPattern[f'[x_]]:=f2[x]; > > this gives no message, but f'[x] returns f1[x] instead of f2[x]. > > The same thinhg happens when you change the sequence of definitions: > > f'[x_]:=f2[x]; > > f[x_]:=f1[x]; > > Further, where is the information about derivatives stored? > > thank's a lot, Daniel > > > === Subject: Re: Defining derivatives Hi , is this a typo?: f'[x] ^:= f2[x] this would only worj for the variable x. Daniel >> Hello All, >> does anybody know how to define symbolic derivatives. E.g.: >> f[x_]:=f1[x]; >> f'[x_]:=f2[x]; >> this does not work because f on the lefthand side is evaluated. To >> prevent this (do not forget to remove f before redefining it): >> f[x_]:=f1[x]; >> HoldPattern[f'[x_]]:=f2[x]; >> this gives no message, but f'[x] returns f1[x] instead of f2[x]. >> The same thinhg happens when you change the sequence of definitions: >> f'[x_]:=f2[x]; >> f[x_]:=f1[x]; > > Daniel, > > *UpSetDelayed[]*. For instance, > > In[1]:= Remove[f] > f[x_] := f1[x] > f'[x] ^:= f2[x] > f'[x] > > Out[4]= f2[x] > > -- > === Subject: Re: Defining derivatives > Hi , > > is this a typo?: f'[x] ^:= f2[x] > > this would only worj for the variable x. > > Daniel Hi Daniel, Wow, that's hurt! You are right, of course. I apologize for the confusion that may have resulted. The correct expression is f' ^:= f2; Nevertheless, this approach is less generic than Carl Woll's solution Derivative[1][f1] = f2; (Note that f' = f2 is also less generic than the above.) (* Using up values *) Remove[Global`*] f[x_] := f1[x] f' ^:= f2 f'[x] D[f[x], x] f'[c] D[f[c], c] Out[4]= f2[x] Out[5]= f1'[x] Out[6]= f2[c] Out[7]= f1'[c] {* Carl Woll's solution *} Remove[Global`*] f[x_] := f1[x] Derivative[1][f1] = f2; f'[x] D[f[x], x] f'[c] D[f[c], c] Out[11]= f2[x] Out[12]= f2[x] Out[13]= f2[c] Out[14]= f2[c] (* Another possibility, but less generic *) Remove[Global`*] f[x_] := f1[x] f' = f2; f'[x] D[f[x], x] f'[c] D[f[c], c] Out[18]= f2[x] Out[19]= f1'[x] Out[20]= f2[c] Out[21]= f1'[c] -- > > > Hello All, > > > does anybody know how to define symbolic derivatives. E.g.: > > > f[x_]:=f1[x]; > > > f'[x_]:=f2[x]; > > > this does not work because f on the lefthand side is evaluated. To > > > prevent this (do not forget to remove f before redefining it): > > > f[x_]:=f1[x]; > > > HoldPattern[f'[x_]]:=f2[x]; > > > this gives no message, but f'[x] returns f1[x] instead of f2[x]. > > > The same thinhg happens when you change the sequence of definitions: > > > f'[x_]:=f2[x]; > > > f[x_]:=f1[x]; > > >> >> Daniel, > > > >> *UpSetDelayed[]*. For instance, > > >> In[1]:= Remove[f] > >> f[x_] := f1[x] > >> f'[x] ^:= f2[x] > >> f'[x] > > >> Out[4]= f2[x] > > > >> -- > > > > === Subject: Re: Defining derivatives > Nevertheless, this approach is less generic than Carl Woll's solution > > Derivative[1][f1] = f2; > What can one _do_ with this construction? Presumably it's executed in situations where f2 is already defined, and f1 isn't --- ?? --- and when executed creates f1 (to within a constant of integration)? Can one then plot or evaluate f1, without further ado? === Subject: Re: Player Pro and Packages Of course my comment was a bit sarcastic. Seriously. What I meant was that it is very difficult to protect and claim ownership for clear text file formats, like the Mathematica notebook format or the PDF format. Evidently the Adobe people have understood that for their case. I feel it a bit illogical to have a high price for the notebook editing part (Mathematica) and a low part for the calculation engine (Player Pro), since the notebook editing part to me seems as the simpler part. And I feel a bit concerned: of course I would also prefer a Mathematica free for all, but at the same time I would like the Wolfram people well paid and working, improving their product further. Hopefully Wolfram finds some new business concept to make the money roll in. Maybe they could sell Mathematica as engine for more specialized products? There are some indications that they are thinking this way. Then they would benefit from having as many Mathematica developers as possible in the community of Mathematica users. Maybe it is up to us Mathematica enthusiasts to show the world why we are enthusiastic to create resources to make Mathematica free. Ingolf Dahl > -----Original Message----- === > Subject: Re: Player Pro and Packages > > > > Maybe Wolfram should ask Adobe for an advice, how to ensure that > behind the content created for Adobe Reader is a genuine > Adobe Acrobat > license. The problems involved seem to be quite equivalent. ;-) > > I do hope this comment was sarcastic or sardonic, rather than serious? > > Is not the great virtue of PDF that it's a more or less fully > _open_, fully specified, and widely distributed format or > standard, made openly available by Adobe so that anyone with > adequate coding skills can create documents or display > documents in that format _without_ having an Adobe license at > either end. > > I understand that Adobe does retain some kind of ownership > over it, and they certainly sell tools that third parties can > purchase to create or read PDFS. And, there are security > links and password protections that document creators can put > into PDF documents to limit what recipients can do with a document. > > But my understanding was that the second paragraph above was > nonetheless more or less true (except for some unfortunate > garbage related to embedded fonts). Is this not the case? > > === Subject: Re: Player Pro and Packages > The PDF specification was first published when Adobe Acrobat was > introduced in 1993. Since then, updated versions of the PDF Reference > have been made available from Adobe via the Web. A significant number of= > developers and systems integrators offer customized enhancements and > extensions to Adobe's core family of products. Adobe publishes the PDF > specification to foster the creation of an ecosystem around the PDF > format. The PDF Reference provides a description of the Portable > Document Format and is intended for application developers wishing to > develop applications that create PDF files directly, as well as read or > modify PDF document content. >http://www.adobe.com/devnet/pdf/pdf_reference.html > (Note that this is why open source as well as non-Adobe commercial > software can legally read and create, and even add goodies to, PDF > files. To name a few: OpenOffice, PDFCreator, Mac OS X, ...) Mathematica notebooks as a widespread publication or communication > format, should seriously ponder the middle sentence Adobe publishes the PDF specification to foster the creation of an= > ecosystem around the PDF format. --- an ecosystem, note, which does not directly require anyone, authors > OR readers, to purchase any Adobe products. Perhaps I am missing something here... but the notebook specification is fully published by Wolfram. Also, Mathematica Player is free... it is only the intermediate product that has a cost associated with it. Perhaps the question is whether it is permitted to write a competitor to Player... that of course is a different intellectual property question. --David === Subject: Re: Player Pro and Packages > Maybe Wolfram should ask Adobe for an advice, how to ensure that behind the > content created for Adobe Reader is a genuine Adobe Acrobat license. The > problems involved seem to be quite equivalent. ;-) I do hope this comment was sarcastic or sardonic, rather than serious? Is not the great virtue of PDF that it's a more or less fully _open_, fully specified, and widely distributed format or standard, made openly available by Adobe so that anyone with adequate coding skills can create documents or display documents in that format _without_ having an Adobe license at either end. I understand that Adobe does retain some kind of ownership over it, and they certainly sell tools that third parties can purchase to create or read PDFS. And, there are security links and password protections that document creators can put into PDF documents to limit what recipients can do with a d