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 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 > > >> 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? 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, ...) -- === 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. === Subject: Changing TextStyle within Show I have often used TextStyle as a global option in Show, for example TextStyle->{FontFamily->Times,FontSlant->Italic,FontSize->9} to render all text in a plot. Is there a way to use it as a Graphics instruction so that font size, etc. is changed for subsequent Text objects as the plot is processed? The Graphics documentation (I am looking at 5.2 on my laptop) says yes, but gives no specific format or examples. I would expect a function like Graphics[TextStyle[ arguments ]] to be available but cant find a description. === Subject: Problem with RegionFunction any idea what is the problem with the output of this Manipulate? Manipulate[ Plot3D[Sin[x]*Cos[y],{x,1,10},{y,2,10},RegionFunction->Function[{x,y}, 45<=(y^x)]] ,{dummy,{True,False}}] Interestingly none of the following codes produces errors: Plot3D[Sin[x]*Cos[y], {x, 1, 10}, {y, 1, 10}, RegionFunction -> Function[{x, y}, 45 <= (y^x)]] Manipulate[ Plot3D[Sin[x]*Cos[y], {x, 1, 10}, {y, 1, 10}, RegionFunction -> If[region, All, Function[{x, y}, 45 <= (y^x)]]] , {region, {True, False}}] Any suggestion would be appreciated. Istvan Zachar === Subject: Defining output formats On the doc page tutorial/DefiningOutputFormats there is an example: This specifies the TeXForm for the symbol x. In[1]:= Format[x, TeXForm] := {bf x} The output format for x that you specified is now used whenever the TeX form is needed. In[2]:= TeXForm[1 + x^2] Out[2]//TeXForm= x^2+1 Quite obviously, this does not work in the way the documentation suggests. I would have expected {bf x}^2 + 1. Let's try another example: In[3]:= TeXForm[x] Out[3]//TeXForm= text{${backslash backslash $bf x$}$} So is there a way to tell Mathematica that x should always be formatted in bold in TeXForm? === Subject: Re: Product In the following link of Wolfram Blog, Mark Sofroniou makes some comments about the efficient algorithms for multiplications included in Mathematica. http://blog.wolfram.com/2007/09/25/arithmetic-is-hard-to-get-right/ Jose Mexico -----Mensaje original----- De: Jose Luis Gomez [mailto:jose.luis.gomez@itesm.mx] Enviado el: Viernes, 11 de Abril de 2008 11:24 a.m. Para: 'Steven'; 'mathgroup@smc.vnet.net' Asunto: RE: Product (* Steven *) (* I think it is an interesting question *) (* See what happens when we compare total with other ways to add many small integers *) (* First a test list:*) In[1]:= mytestlist = Table[RandomInteger[{1, 9}], {1000000}]; (* add all the numbers in the list, and also report the computer time used to calculate:*) In[2]:= Timing[Plus @@ mytestlist] Out[2]= {0.266, 5003966} (* AGAIN add all the numbers in the list, BUT THIS TIME USING TOTAL and also report the computer time used to calculate:*) In[3]:= Timing[Total[mytestlist]] Out[3]= {0.031, 5003966} (* As you can see, for small integers, Total has a special algorithm that that adds ten times faster than just add all the numbers in order*) (* Therefore your question is equivalent to ask if there is an improved algorithm to multiply numbers, and if that algorithm is implemented in a special command in Mathematica, equivalent to Total*) (* I do not know the answer, while someone else answers this, you can multiply the following way:*) In[4]:= Times @@ mytestlist (* large result deleted *) (* The following link might be interesting for you:*) (* http://homepage.cem.itesm.mx/lgomez/matecmatica/fp/fp.html *) (* http://homepage.cem.itesm.mx/lgomez/matecmatica/funcionalprog.nb *) (* Hope that helps *) (* Jose *) (* Mexico *) -----Mensaje original----- De: Steven [mailto:steven_504@telenet.be] Enviado el: Viernes, 11 de Abril de 2008 12:43 a.m. Para: mathgroup@smc.vnet.net Asunto: Product Silly beginner's question: is there a function to multiply all elements of a list, like Total does for addition? 'fraid I can't find it. TIA === Subject: Re: bar charts, frame ticks, and error bars easiest option. :) dan went through a lot of gyrations on formatting of charts, hate to say it, but I simply went back to MS Excel. > Hello all, > I've found a number of posts that deal with either using frames with > bar charts or error bars with bar charts, but I've been having > difficulty implementing those previous suggestions when it comes to a > bar chart showing multiple sets of data. Take for example the > following: > BarChart[{{10, 20, 30, 40}, {5, 15, 25, 35}}, > Frame -> {True, True, None, None}, > FrameTicks -> {{{1, A}, {2, B}, {3, C}, {4, D}}, Automatic, > None, None}] > The problem with the result is that the ticks show up under the first > bar of each set, when I would hope that the ticks would be at the > center of each set. I haven't even tried to use error bars yet. Does > anyone have any suggestions on how to make this work? And maybe, how > to implement a plot legend with these multiple set bar charts? > Dan === Subject: Re: Timing >Who know how change bellow procedure to received reasonable timing? Part: >Expand[((3 + 2 Sqrt[2])^(2^(n - 1) - 1) - (3 - 2 Sqrt[2])^(2^(n - 1) - >1))/(4 Sqrt[2])]/(2^n - 1) >is every time integer > >Timing[Do[ If[IntegerQ[Expand[((3 + 2 Sqrt[2])^(2^(n - 1) - 1) - (3 - >>2 Sqrt[2])^(2^(n - 1) - 1))/(4 Sqrt[2])]/(2^n - 1)], >> Print[n]], {n, 1, 17}]] >> >I will be greatfull for any help! (Mayby some N[] or Floor[N[]] or >Int[N[]] will be quickest Best wishes >Artur > > You should review Fibonacci numbers and difference equations. Anyway, one can prove that ((3 + 2 Sqrt[2])^(2^(n - 1) - 1) - (3 - 2 Sqrt[2])^(2^(n - 1) - 1))/(4 Sqrt[2]) is an integer. Then notice: In[166]:= 3 - 2 Sqrt[2] // N Out[166]= 0.171573 As n gets larger, this term disappears. Therefore, all you need to do is: f[n_] := Round[(3 + 2 Sqrt[2])^(2^(n-1)-1)/(4 Sqrt[2])] Of course, the number of digits doubles every time, so on my computer things become very slow at f[23] (which is an integer with ~3.2 million digits). So, you might want to experiment with recurrence relations (a la Fibonacci). This might allow you to incorporate the 2^n-1 denominator and keep things from blowing quite so quickly. For example, if g[n_] := ((3 + 2 Sqrt[2])^n - (3 - 2 Sqrt[2])^n)/(4 Sqrt[2]) then (from the quadratic satisfied by 3 +/- 2 Sqrt[2]): g[n+2] == 6 g[n+1] - g[n] g[0]==0 g[1]==1 {g[n+1], g[n]} == {{6, -1}, {1, 0}} . {g[n], g[n-1]} or MatrixPower[{{6, -1}, {1,0}}, n] == {{g[n+1], -g[n]}, {g[n], g[n-1]}} etc. Carl Woll Wolfram Research === Subject: Re: Timing It is easy to prove that expr is an integer. Let A=(3 + 2 Sqrt[2]) and B=3 -2 Sqrt[2]. Then A and B are the roots of x^2 - (A + B) x + A B == 0 // Expand = x^2 - 6 x + 1 == 0 with A+B = 6 and A*B=1. Note also that A-B=4Sqrt[2]. expr is (A^m-B^m)/(4*Sqrt[2])= (A-B)*(A^(m-1) + A^(m-2) B + A^(m-3)B^2+ ...A*B^(m-2)+B^(m-1))/(4 Sqrt[2]) = A^(m-1) + A^(m-2) B + A^(m-3)B^2+ ...A*B^(m-2)+B^(m-1) = (A^(m-1)+B^(m-1)) + (A^(m-2)*B+ A*B^(m-2))+...= (A^(m-1)+B^(m-1) + (A^(m-3)+B^(m-3) + ....) + 1 Here m is 2^(n-1)-1.The 1 is present because A*B // Simplify 1 so the product of the same powers o A and B is 1. So expr clearly an integer since any sum of power A^k+B^k can be expresses as polynomial with integer coefficients in the symmetric functions of A and B. So this does not require any use of Mathematica. The question when this is divisible by 2^n-1 is far from clear. One could try to use something like this: f[n_] := Module[ {prec = Log[10, ((2*Sqrt[2] + 3)^ (2^(n - 1) - 1) - (3 - 2*Sqrt[2])^ (2^(n - 1) - 1))/ ((4*Sqrt[2])*(2^n - 1))], p}, p = N[((2*Sqrt[2] + 3)^ (2^(n - 1) - 1) - (3 - 2*Sqrt[2])^ (2^(n - 1) - 1))/ ((4*Sqrt[2])*(2^n - 1)), prec + $MachinePrecision]; p == Round[p]] Table[f[n], {n, 2, 20}] // Timing {11.4016, {False, True, False, True, False, True, False, False, False, False, False, True, False, False, False, True, False, True, False}} This is at least vastly faster than the OP's version. Andrzej Kozlowski > The previous method should work (in a very weak interpretation of > work) if you replace the expr with; expr = Expand[((3 + 2 Sqrt[2])^(2^(n - 1) - 1) - (3 - > 2 Sqrt[2])^(2^(n - 1) - 1))/(4 Sqrt[2])] Note: FullSimplify[Together[expr], Element[n, Integers]] is considerably simpler ((3 + 2*Sqrt[2])^2^(-1 + n)*(-4 + 3*Sqrt[2]) - > (3 - 2*Sqrt[2])^2^(-1 + n)*(4 + 3*Sqrt[2]))/8 I can't immediately see that this result should be integer, but I am > getting integers for the first 10 t = Table[nexpr /. n -> i, {i, 1, 10}] // Expand > Map[IntegerQ, t] > In general, Do is slow compared to Table, but it is the size of the > expression that is the limiting factor here. > My problem is find such numbers n that expression >> ((3 + 2 Sqrt[2])^(2^(n - 1) - 1) - (3 - 2 Sqrt[2])^(2^(n - 1) - 1))/ >> (4 >> Sqrt[2]) >> is divisable by (2^n - 1) >> or another words (2^n - 1) is divisor of ((3 + 2 Sqrt[2])^(2^(n - >> 1) - 1) - >> (3 - 2 Sqrt[2])^(2^(n - 1) - 1))/(4 Sqrt[2]) >> My procedure Do[ If[IntegerQ[Expand[((3 + 2 Sqrt[2])^(2^(n - 1) - >> 1) - (3 - >> 2 Sqrt[2])^(2^(n - 1) - 1))/(4 Sqrt[2])]/(2^n - 1)], Print[n]], >> {n, 1, >> 17}] >> is extremaly slow (probably Expand function do that as aslowly but >> without >> Expand we don't have integers. I don't have idea how improove them. >> Best wishes >> Artur >> W_Craig Carter pisze: > Hello Artur, > I am not sure I understand your question: Are you asking for > Member[expr,Integers] && Element[n,Integers] > for 1 <= n <= 17 ? If so, this may be a hint, although it does not exactly check the > above: Map[Element[Rationalize[#, .00000001], Integers] & , > Table[expr /. n -> i, {i, 1, 30}]] and it is reasonably fast. This approximate method gets worse for > large n; so I don't trust the result except for n=1,3,5 Note, that > Map[Element[Rationalize[Expand[#], .00000001], Integers] & , > Table[expr /. n -> i, {i, 1, 10}]] Gives a different result and is much slower, thus emphasizing the > result for large n. I am curious to see the better solutions.... > Who know how change bellow procedure to received reasonable timing? >> Part: >> Expand[((3 + 2 Sqrt[2])^(2^(n - 1) - 1) - (3 - 2 Sqrt[2])^(2^(n - >> 1) - >> 1))/(4 Sqrt[2])]/(2^n - 1) >> is every time integer > Timing[Do[ If[IntegerQ[Expand[((3 + 2 Sqrt[2])^(2^(n - 1) - 1) - > (3 - > 2 Sqrt[2])^(2^(n - 1) - 1))/(4 Sqrt[2])]/(2^n - 1)], > Print[n]], {n, 1, 17}]] > I will be greatfull for any help! (Mayby some N[] or Floor[N[]] or >> Int[N[]] will be quickest >> Best wishes >> Artur > > > -- > W. Craig Carter > === Subject: Re: Timing The previous method should work (in a very weak interpretation of work) if you replace the expr with; expr = Expand[((3 + 2 Sqrt[2])^(2^(n - 1) - 1) - (3 - 2 Sqrt[2])^(2^(n - 1) - 1))/(4 Sqrt[2])] Note: FullSimplify[Together[expr], Element[n, Integers]] is considerably simpler ((3 + 2*Sqrt[2])^2^(-1 + n)*(-4 + 3*Sqrt[2]) - (3 - 2*Sqrt[2])^2^(-1 + n)*(4 + 3*Sqrt[2]))/8 I can't immediately see that this result should be integer, but I am getting integers for the first 10 t = Table[nexpr /. n -> i, {i, 1, 10}] // Expand Map[IntegerQ, t] In general, Do is slow compared to Table, but it is the size of the expression that is the limiting factor here. > My problem is find such numbers n that expression > ((3 + 2 Sqrt[2])^(2^(n - 1) - 1) - (3 - 2 Sqrt[2])^(2^(n - 1) - 1))/(4 > Sqrt[2]) > is divisable by (2^n - 1) or another words (2^n - 1) is divisor of ((3 + 2 Sqrt[2])^(2^(n - 1) - 1) - > (3 - 2 Sqrt[2])^(2^(n - 1) - 1))/(4 Sqrt[2]) My procedure Do[ If[IntegerQ[Expand[((3 + 2 Sqrt[2])^(2^(n - 1) - 1) - (3 - > 2 Sqrt[2])^(2^(n - 1) - 1))/(4 Sqrt[2])]/(2^n - 1)], Print[n]], {n, 1, > 17}] is extremaly slow (probably Expand function do that as aslowly but without > Expand we don't have integers. I don't have idea how improove them. > Best wishes > Artur W_Craig Carter pisze: > Hello Artur, > I am not sure I understand your question: > > Are you asking for > Member[expr,Integers] && Element[n,Integers] > for 1 <= n <= 17 ? > > If so, this may be a hint, although it does not exactly check the above: > > Map[Element[Rationalize[#, .00000001], Integers] & , > Table[expr /. n -> i, {i, 1, 30}]] > > and it is reasonably fast. This approximate method gets worse for > large n; so I don't trust the result except for n=1,3,5 > > Note, that > Map[Element[Rationalize[Expand[#], .00000001], Integers] & , > Table[expr /. n -> i, {i, 1, 10}]] > > Gives a different result and is much slower, thus emphasizing the > result for large n. > > I am curious to see the better solutions.... > > Who know how change bellow procedure to received reasonable timing? > > Part: > Expand[((3 + 2 Sqrt[2])^(2^(n - 1) - 1) - (3 - 2 Sqrt[2])^(2^(n - 1) - > 1))/(4 Sqrt[2])]/(2^n - 1) > is every time integer > > Timing[Do[ If[IntegerQ[Expand[((3 + 2 Sqrt[2])^(2^(n - 1) - 1) - (3 - > > 2 Sqrt[2])^(2^(n - 1) - 1))/(4 Sqrt[2])]/(2^n - 1)], > > Print[n]], {n, 1, 17}]] > > I will be greatfull for any help! (Mayby some N[] or Floor[N[]] or > Int[N[]] will be quickest > > Best wishes > Artur > > > > -- W. Craig Carter === Subject: Re: Timing My problem is find such numbers n that expression ((3 + 2 Sqrt[2])^(2^(n - 1) - 1) - (3 - 2 Sqrt[2])^(2^(n - 1) - 1))/(4 Sqrt[2]) is divisable by (2^n - 1) or another words (2^n - 1) is divisor of ((3 + 2 Sqrt[2])^(2^(n - 1) - 1) - (3 - 2 Sqrt[2])^(2^(n - 1) - 1))/(4 Sqrt[2]) My procedure Do[ If[IntegerQ[Expand[((3 + 2 Sqrt[2])^(2^(n - 1) - 1) - (3 - 2 Sqrt[2])^(2^(n - 1) - 1))/(4 Sqrt[2])]/(2^n - 1)], Print[n]], {n, 1, 17}] is extremaly slow (probably Expand function do that as aslowly but without Expand we don't have integers. I don't have idea how improove them. Best wishes Artur W_Craig Carter pisze: > Hello Artur, > I am not sure I understand your question: Are you asking for > Member[expr,Integers] && Element[n,Integers] > for 1 <= n <= 17 ? If so, this may be a hint, although it does not exactly check the above: Map[Element[Rationalize[#, .00000001], Integers] & , > Table[expr /. n -> i, {i, 1, 30}]] and it is reasonably fast. This approximate method gets worse for > large n; so I don't trust the result except for n=1,3,5 Note, that > Map[Element[Rationalize[Expand[#], .00000001], Integers] & , > Table[expr /. n -> i, {i, 1, 10}]] Gives a different result and is much slower, thus emphasizing the > result for large n. I am curious to see the better solutions.... >> Who know how change bellow procedure to received reasonable timing? >> Part: >> Expand[((3 + 2 Sqrt[2])^(2^(n - 1) - 1) - (3 - 2 Sqrt[2])^(2^(n - 1) - >> 1))/(4 Sqrt[2])]/(2^n - 1) >> is every time integer >> > Timing[Do[ If[IntegerQ[Expand[((3 + 2 Sqrt[2])^(2^(n - 1) - 1) - (3 - >> > 2 Sqrt[2])^(2^(n - 1) - 1))/(4 Sqrt[2])]/(2^n - 1)], >> > Print[n]], {n, 1, 17}]] >> > I will be greatfull for any help! (Mayby some N[] or Floor[N[]] or >> Int[N[]] will be quickest >> Best wishes >> Artur >> === Subject: Re: Timing Hello Artur, I am not sure I understand your question: Are you asking for Member[expr,Integers] && Element[n,Integers] for 1 <= n <= 17 ? If so, this may be a hint, although it does not exactly check the above: Map[Element[Rationalize[#, .00000001], Integers] & , Table[expr /. n -> i, {i, 1, 30}]] and it is reasonably fast. This approximate method gets worse for large n; so I don't trust the result except for n=1,3,5 Note, that Map[Element[Rationalize[Expand[#], .00000001], Integers] & , Table[expr /. n -> i, {i, 1, 10}]] Gives a different result and is much slower, thus emphasizing the result for large n. I am curious to see the better solutions.... > Who know how change bellow procedure to received reasonable timing? Part: > Expand[((3 + 2 Sqrt[2])^(2^(n - 1) - 1) - (3 - 2 Sqrt[2])^(2^(n - 1) - > 1))/(4 Sqrt[2])]/(2^n - 1) > is every time integer > > Timing[Do[ If[IntegerQ[Expand[((3 + 2 Sqrt[2])^(2^(n - 1) - 1) - (3 - > > 2 Sqrt[2])^(2^(n - 1) - 1))/(4 Sqrt[2])]/(2^n - 1)], > > Print[n]], {n, 1, 17}]] > I will be greatfull for any help! (Mayby some N[] or Floor[N[]] or > Int[N[]] will be quickest Best wishes > Artur -- W. Craig Carter === Subject: Re: Timing Who know how change bellow procedure to received reasonable timing? Part: Expand[((3 + 2 Sqrt[2])^(2^(n - 1) - 1) - (3 - 2 Sqrt[2])^(2^(n - 1) - 1))/(4 Sqrt[2])]/(2^n - 1) is every time integer > Timing[Do[ If[IntegerQ[Expand[((3 + 2 Sqrt[2])^(2^(n - 1) - 1) - (3 - > 2 Sqrt[2])^(2^(n - 1) - 1))/(4 Sqrt[2])]/(2^n - 1)], > Print[n]], {n, 1, 17}]] > I will be greatfull for any help! (Mayby some N[] or Floor[N[]] or Int[N[]] will be quickest Best wishes Artur === Subject: matrix of vectors - super slow I have an matrix of vectors where each element has to go through various transformations, that is each element has to be multiplied by a few different matrices. Is there a more efficient way of doing that from what I am currently doing? n = 128*1; m = 128*1; R = 1; BeamIn = Table[( { {Sqrt[2]/2}, {Sqrt[2]/2} } ), {i, n}, {j, m}]; PBeam = Table[0, {i, n}, {j, m}]; SBeam = Table[0, {i, n}, {j, m}]; PInt = Table[0, {i, n}, {j, m}]; SInt = Table[0, {i, n}, {j, m}]; HalfWave[[Theta]_] = ( { {Cos[-[Theta]], Sin[-[Theta]]}, {-Sin[-[Theta]], Cos[-[Theta]]} } ).( { {1, 0}, {0, Exp[-I [Pi]]} } ).( { {Cos[[Theta]], Sin[[Theta]]}, {-Sin[[Theta]], Cos[[Theta]]} } ); QuarterWave[[Theta]_] = ( { {Cos[-[Theta]], Sin[-[Theta]]}, {-Sin[-[Theta]], Cos[-[Theta]]} } ).( { {1, 0}, {0, Exp[-I [Pi]/2]} } ).( { {Cos[[Theta]], Sin[[Theta]]}, {-Sin[[Theta]], Cos[[Theta]]} } ); PPol = ( { {1, 0}, {0, 0} } ); SPol = ( { {0, 0}, {0, 1} } ); LaserRod[TT_, [Theta]_, Q_] = ( { {Cos[-[Theta]], Sin[-[Theta]]}, {-Sin[-[Theta]], Cos[-[Theta]]} } ).( { {Exp[-I *2.8 *TT^2*Q], 0}, {0, Exp[I *0.4 *TT^2* Q]} } ).( { {Cos[[Theta]], Sin[[Theta]]}, {-Sin[[Theta]], Cos[[Theta]]} } ); For[i = 1, i <= n, i++, For[j = 1, j <= m, j++, x = R ((2 i - n) - 1); y = R ((2 j - m) - 1); r = Sqrt[x^2 + y^2]; [Theta] = ArcTan[y/x]; PBeam[[i, j]] = PPol.LaserRod[r, [Theta], 1*10^-3].QuarterWave[[Pi]/ 2].LaserRod[r, [Theta], 1*10^-3].PPol.BeamIn[[i, j]]; SBeam[[i, j]] = SPol.LaserRod[r, [Theta], 1*10^-3].QuarterWave[[Pi]/ 2].LaserRod[r, [Theta], 1*10^-3].PPol.BeamIn[[i, j]]; PInt[[i, j]] = Norm[PBeam[[i, j]][[1, 1]]]^2; SInt[[i, j]] = Norm[SBeam[[i, j]][[2, 1]]]^2; ]; ]; ListDensityPlot[PInt] ListDensityPlot[SInt] === Subject: Re: Cannot NSolve a system of equations >> I have the following system that I need to solve, but I cannot get a >> sensible result. >> Unprotect[In,Out];Clear[In,Out];ClearAll[Global`*]; >> zet=0.083; >> phi=0.75;eta=1.75;alpha=0.64;y1=0.235457064;y2=0.512465374;y3=0.781779009; >> y4=1.109572176; y5=2.360726377;tau1=zet y1^phi;tau2=zet >> y2^phi;tau3=zet y3^phi;tau4=zet y4^phi;tau5=zet y5^phi; >> taubar=(tau1 y1+tau2 y2+tau3 y3+tau4 y4+tau5 y5)/ >> 5;a1=(1+phi)tau1;a2=(1+phi)tau2;a3=(1+phi)tau3;a4=(1+phi)tau4;a5=(1+phi)tau5; >> eqns1={x1==(roverw(1-tau1)+((roverw+(1-x))y1-1)( (1-taubar+(1-abar)/ >> eta)x+(taubar-tau1)roverw-(1-taubar)))/(roverw (1-tau1+(1-a1)/eta)- >> ( (1-taubar+(1-abar)/eta)x+(taubar-tau1)roverw-(1-taubar))), >> x2==(roverw(1-tau2)+((roverw+(1-x))y2-1)( (1-taubar+(1-abar)/eta)x+ >> (taubar-tau2)roverw-(1-taubar)))/(roverw (1-tau2+(1-a2)/eta)-( (1- >> taubar+(1-abar)/eta)x+(taubar-tau2)roverw-(1-taubar))), >> x3==(roverw(1-tau3)+((roverw+(1-x))y3-1)( (1-taubar+(1-abar)/eta)x+ >> (taubar-tau3)roverw-(1-taubar)))/(roverw (1-tau3+(1-a3)/eta)-( (1- >> taubar+(1-abar)/eta)x+(taubar-tau3)roverw-(1-taubar))), >> x4==(roverw(1-tau4)+((roverw+(1-x))y4-1)( (1-taubar+(1-abar)/eta)x+ >> (taubar-tau4)roverw-(1-taubar)))/(roverw (1-tau4+(1-a4)/eta)-( (1- >> taubar+(1-abar)/eta)x+(taubar-tau4)roverw-(1-taubar))), >> x5==(roverw(1-tau5)+((roverw+(1-x))y5-1)( (1-taubar+(1-abar)/eta)x+ >> (taubar-tau5)roverw-(1-taubar)))/(roverw (1-tau5+(1-a5)/eta)-( (1- >> taubar+(1-abar)/eta)x+(taubar-tau5)roverw-(1-taubar))), >> x==(x1+x2+x3+x4+x5)/5, abar == (a1 x1+a2 x2+a3 x3+a4 x4+a5 x5)/ >> (5x),roverw==(1-x)(1-alpha)/alpha }; >> sol=NSolve[eqns1,{x, x1,x2,x3,x4,x5,abar, roverw}]; >> eqns1 /. sol >> Out[741]={{False, False, False, False, False, True, True, True}, >> {False, False, >> False, False, False, True, True, True}, {False, False, False, >> False, False, True, False, True}, {False, False, True, False, False, >> True, False, True}, {False, False, True, False, False, True, False, >> True}, {False, False, True, True, False, True, True, False}} >> What am I doing wrong? Is it just because the system is too >> complicated? >> Any help would be truly appreciated. >> Murat > > Quite possibly there are issues involving numeric stability and the > presence of denominators. I was able to get a solution set, containg two > solutions, by starting with exact input and then numericizing to high > precision. > > zet = 83/1000; > phi = 3/4; > eta = 7/4; > alpha = 16/25; > > {y1,y2,y3,y4,y5} = Rationalize[ > {0.235457064,0.512465374,0.781779009,1.109572176,2.360726377}, 0]; > > With this I can do: > > In[34]:= Timing[sol = NSolve[N[eqns,500],vars];] > Out[34]= {5., Null} > > In[36]:= eqns/.sol > Out[36]= {{True, True, True, True, True, True, True, True}, > {True, True, True, True, True, True, True, True}} > > Here are the solution values, at machine precision. > > In[39]:= InputForm[N[sol]] > Out[39]//InputForm= > {{x -> 0.6251836373550925, x1 -> 0.6454246796060954, > x2 -> 0.6474758190687543, x3 -> 0.6445628507802813, > x4 -> 0.6355486246954559, x5 -> 0.5529062126248758, > abar -> 0.13411739130856176, roverw -> 0.21083420398776043}, > {x -> 1., x1 -> 1., x2 -> 1., x3 -> 1., x4 -> 1., x5 -> 1., > abar -> 0.13829898904658144, roverw -> 0.}} > An equivalent, but somewhat simpler approach is to simply increase the nominal precision of the numbers: In[25]:= eqn2 = SetPrecision[eqns1, 30]; In[26]:= sol = NSolve[eqn2, {x, x1, x2, x3, x4, x5, abar, roverw}]; In[27]:= eqn2 /. Equal -> Subtract /. sol Out[27]= {{0.*10^-25, 0.*10^-25, 0.*10^-23, 0.*10^-24, 0.*10^-25, 0.*10^-27, 0.*10^-28, 0.*10^-28}, {0.*10^-24, 0.*10^-24, 0.*10^-24, 0.*10^-23, 0.*10^-23, 0.*10^-26, 0.*10^-27, 0.*10^-27}, {0.*10^-25 + 0.*10^-25 I, 0.*10^-26 + 0.*10^-26 I, 0.*10^-26 + 0.*10^-26 I, 0.*10^-26 + 0.*10^-26 I, 0.*10^-26 + 0.*10^-26 I, 0.*10^-28 + 0.*10^-28 I, 0.*10^-28 + 0.*10^-28 I, 0.*10^-29 + 0.*10^-29 I}, {0.*10^-25 + 0.*10^-25 I, 0.*10^-26 + 0.*10^-26 I, 0.*10^-26 + 0.*10^-26 I, 0.*10^-26 + 0.*10^-26 I, 0.*10^-26 + 0.*10^-26 I, 0.*10^-28 + 0.*10^-28 I, 0.*10^-28 + 0.*10^-28 I, 0.*10^-29 + 0.*10^-29 I}, {0.*10^-29, 0.*10^-29, 0.*10^-29, 0.*10^-29, 0.*10^-29, 0.*10^-29, 0.*10^-30, 0.*10^-29}, {0.*10^-28, 0.*10^-28, 0.*10^-28, 0.*10^-28, 0.*10^-28, 0.*10^-29, 0.*10^-29, 0.*10^-29}} === Subject: Re: Cannot NSolve a system of equations I sincerely thank you all for your help. It cleared up a lot of things for me. I had tried Rationalize but didn't know about precision issues. Now I have a follow-up question. I still cannot trust my results 100% because when I slightly change one of my parameters, solution set changes drastically. My theory says that resulting variables should between 0 and 1, so I am only interested in that range. And sometimes I don't even get any such solutions. suggestions): Unprotect[In, Out]; Clear[In, Out]; ClearAll[Global`*]; phi = Rationalize[0.74615385]; eta = 7/4; alpha = 16/25; taubar = 13/100; {y1, y2, y3, y4, y5} = Rationalize[{0.235457064, 0.512465374, 0.781779009, 1.109572176, 2.360726377}, 0]; zet = N[5 taubar/(y1^(1 + phi) + y2^(1 + phi) + y3^(1 + phi) + y4^( 1 + phi) + y5^(1 + phi))]; tau1 = zet y1^phi; tau2 = zet y2^phi; tau3 = zet y3^phi; tau4 = zet y4^phi; tau5 = zet y5^phi; a1 = (1 + phi) tau1; a2 = (1 + phi) tau2; a3 = (1 + phi) tau3; a4 = (1 + phi) tau4; a5 = (1 + phi) tau5; eqns1 = {x1 == (roverw (1 - tau1) + ((roverw + (1 - x)) y1 - 1) ((1 - taubar + (1 - abar)/eta) x + (taubar - tau1) roverw - (1 - taubar)))/(roverw (1 - tau1 + (1 - a1)/eta) - ((1 - taubar + (1 - abar)/eta) x + (taubar - tau1) roverw - (1 - taubar))), x2 == (roverw (1 - tau2) + ((roverw + (1 - x)) y2 - 1) ((1 - taubar + (1 - abar)/eta) x + (taubar - tau2) roverw - (1 - taubar)))/(roverw (1 - tau2 + (1 - a2)/eta) - ((1 - taubar + (1 - abar)/eta) x + (taubar - tau2) roverw - (1 - taubar))), x3 == (roverw (1 - tau3) + ((roverw + (1 - x)) y3 - 1) ((1 - taubar + (1 - abar)/eta) x + (taubar - tau3) roverw - (1 - taubar)))/(roverw (1 - tau3 + (1 - a3)/eta) - ((1 - taubar + (1 - abar)/eta) x + (taubar - tau3) roverw - (1 - taubar))), x4 == (roverw (1 - tau4) + ((roverw + (1 - x)) y4 - 1) ((1 - taubar + (1 - abar)/eta) x + (taubar - tau4) roverw - (1 - taubar)))/(roverw (1 - tau4 + (1 - a4)/eta) - ((1 - taubar + (1 - abar)/eta) x + (taubar - tau4) roverw - (1 - taubar))), x5 == (roverw (1 - tau5) + ((roverw + (1 - x)) y5 - 1) ((1 - taubar + (1 - abar)/eta) x + (taubar - tau5) roverw - (1 - taubar)))/(roverw (1 - tau5 + (1 - a5)/eta) - ((1 - taubar + (1 - abar)/eta) x + (taubar - tau5) roverw - (1 - taubar))), x == (x1 + x2 + x3 + x4 + x5)/5, abar == (a1 x1 + a2 x2 + a3 x3 + a4 x4 + a5 x5)/(5 x), roverw == (1 - x) (1 - alpha)/alpha}; vars = {x, x1, x2, x3, x4, x5, abar, roverw}; sol = NSolve[N[eqns1, 500], vars]; InputForm[N[sol]] One of the solutions I get is between 0 and 1: {x -> 0.5004885149810059, x1 -> 0.6893393376625371, x2 -> 0.6337652704581314, x3 -> 0.5731109245369462, x4 -> 0.4917632705087048, x5 -> 0.1144637717387098, abar -> 0.1244737777525507, roverw -> 0.2809752103231842} So I am happy. But when I drop the last digit of the first parameter, i.e. phi = Rationalize[0.7461538];, the new set of solutions do not have any results compatible with my assumptions: {{x -> 0.2949617829869077, x1 -> -1.9491786143565832, x2 -> 10.96762641745164, x3 -> 96.0369893781559, x4 -> -73.18097932930044, x5 -> -30.399648937016046, abar -> -5.824073507107748, roverw -> 0.39658399706986447}, {x -> 2.0689803436369942, x1 -> -8.65276583855146, x2 -> -18.39904428993495, x3 -> -33.55295774059405, x4 -> -69.9736576669751, x5 -> 140.92332725424055, abar -> 2.4458078645586667, roverw -> -0.6013014432958093}, {x -> 0.6213605439915423, x1 -> -12.823085779076337, x2 -> 41.57610980587073, x3 -> -6.337885849417286, x4 -> -8.665252197121296, x5 -> -10.64308326029811, abar -> -0.7583206767716181, roverw -> 0.21298469400475745}, {x -> 0.6854511826071373 - 0.04362902433398709*I, x1 -> 0.59964456896311 + 0.08549874839569205*I, x2 -> 0.6411455792212575 + 0.04079939260558141*I, x3 -> 0.6760747168284579 - 0.003707834204090894*I, x4 -> 0.7125762414563436 - 0.05913956075670094*I, x5 -> 0.7978148065665167 - 0.28159586771041706*I, abar -> 0.17051392124951886 - 0.016129276403199968*I, roverw -> 0.17693370978348527 + 0.024541326187867737*I}, {x -> 0.6854511826071373 + 0.04362902433398709*I, x1 -> 0.59964456896311 - 0.08549874839569205*I, x2 -> 0.6411455792212575 - 0.04079939260558141*I, x3 -> 0.6760747168284579 + 0.003707834204090894*I, x4 -> 0.7125762414563436 + 0.05913956075670094*I, x5 -> 0.7978148065665167 + 0.28159586771041706*I, abar -> 0.17051392124951886 + 0.016129276403199968*I, roverw -> 0.17693370978348527 - 0.024541326187867737*I}, {x -> 0.9999999999989753, x1 -> 0.9999999999982316, x2 -> 0.9999999999985612, x3 -> 0.999999999998809, x4 -> 0.9999999999991211, x5 -> 1.0000000000001525, abar -> 0.16068192162412143, roverw -> 0.}} And this is just one of the instances that this happens. I solve the same set of equations for many parameter sets. Sometimes I get a solution in the [0,1] range, but it is so different than the previous one, it doesn't make sense. Or sometimes, I have to tweak parameter values (drop a digit here, add another one there) to get a meaningful solution. I need a set of results over different parameter values that I can compare and contrast, but it is hard to do that when my results suddenly disappear or jump to an improbable value. Now I know that this is probably the most Mathematica can do for me, but is there a way to make my system more stable? Maybe play with my equations a little bit? Or put another way, what makes my system so unstable? === Subject: Re: Color space conversion in Mathematica v6.0 On May 21, 1:57 pm, Robert Buchanan EPS and PDF image files. Either prior to Export[]-ing or while > Export[]-ing I would like to convert them from color to grayscale. Is > there an option to Export[] for doing this or some other function in > the Mathematical kernel for doing this? In versions earlier than 6.0 I > could specify ColorOutput->GrayLevel, but this is not a valid option > in version 6.0. There is a global FrontEnd option: which will convert bitmaps to grayscale when exporting to either EPS or PDF, but this does not affect other graphics primitives. One way to do this conversion for other primitives is a simple replacement: (* g is a Graphics expresion *) g//.{c:(_RGBColor|_CMYKColor|_Hue):>ToColor[c,GrayLevel]} It's more complicated for Graphics3D expressions, as you must deal with lighting issues. -Rob === Subject: Re: Mathematica 6: No more memory available problem with > Try this: d = RandomReal[{0, 1}, {78, 20003}]; ListDensityPlot[d, PerformanceGoal -> Speed] ListPlot3D[d, PerformanceGoal -> Speed] Mathematica deals with large data sets by downsampling, using the > MaxPlotPoints option. PerformanceGoal->Speed, will use a very simple > plotting code to give a draft representation of the data (no mesh > lines, no RegionFunction, etc.). This also works, although it may take a little bit longer, around 20 ListDensityPlot[d, PerformanceGoal -> Speed, > MaxPlotPoints -> Infinity] or even: ListPlot3D[d, PerformanceGoal -> Speed, MaxPlotPoints -> Infinity] Mathematica is a very good tool to visualize large data sets. Ulises Cervantes > Wolfram Research, Inc. With respect, I cannot agree with this. I have been trying to use Mathematica to visualize xyz output from a Zygo optical profilometer. The data is in 640x480=307300 xyz tripletts. ListPlot3D, even with the options you specify, requires 123.5 seconds to generate the plot. Afterwords, any attempt to manipulate the plot orientation freezes the front end so badily that the function is useless. Other activities also grind to a halt. Watching utilization with task manager suggests that the 640x480 plot has consumed all memory. In fact, in some cases of prior history in the kernel I just get an out-of-memory abort from the kernel. I sent in a summary of this to Wolfram support a few months ago and was told that my data set was too large. I would really like to be able to process 640x480 data sets in 3D. I am running 6.0.2.0 on XP Pro with 4GB ram. David Keith === Subject: Re: sending programatically output to clipboard Just a note that EMF and MGF are Windows-specific Export formats... The original poster did indeed specify that they were working on Windows. But any other folks that are not should not be concerned if this doesn't work for them... David > Hi everyone, > I would like to find a way to programatically send some output to the > clipboard. For the time being I would like to do that with formatted > equations, and I would like to send them as bitmap or metafile (I work > on Windows). So it should be the equivalent of Copy As. I searched on > the forum and I found a few posts on related topics, but I did not > manage to get it working. > Any help is appreciated. > Adrian For example, nb = NotebookPut[Notebook[{Cell[1234, Title]}]]; > SelectionMove[nb, All, Notebook]; > FrontEndExecute[FrontEndToken[nb, CopySpecial, EMF]] Use EMF for metafile (copies both enhanced and windows-style metafiles).= = > Use > MGF for bitmaps. > John Fultz > jfu...@wolfram.com > User Interface Group > Wolfram Research, Inc. === Subject: enter key on new Mac MBP Although this is really a Mac question, I am posting it here since the main app it applies to is Mathmatica. My old Ti 500 PB died so I upgraded to a MBP. On the right side of the space bar on the PB was the enter key, on the MBP it is another option key. Is there a easy way to reassign this right option key back to being an enter key? === Subject: Re: intersecting a hypercube and a hyperplane > Hi all, > > I have a problem you will laugh about (maybe). Here: > > You have a hypercube and a hyperplane. They intersect. In n-D the > intersection region is a (n-1)-D object. I am interested in > determining the vertices of the intersection object. Of course, I can > check all the edges and determine all intersection vertices, but that > takes n 2^(n-1) checks. Do you know of any algorithm to compute that? > > The hyperplane is Sum(Xi)=C, for some C, where Xi is the i-th > coordinate. > > Idea: For each vertex of the hypercube you add its coordinates, and > form a partition into three sets (vertices behind, at, and in-front of > the hyperplane). That information would allow you to restrict the > search to edges involved in two of those sets. The problem is the > preprocessing time (to compute the sum for every vertex) itself is > exponential on n. I need something more efficient than exponential, > or else, a pointer that indicates that no such algorithm exists. > > This comes from an optimization problem. The hypercube is the search > space and the hyperplane corresponds to a energy conservation > constraint. I am using an evolutionary computation technique, and are > interested in generating a population of points that lie in the > intersection. > > Any pointers/ideas will be greatly appreciated. > > Juan Flores > Univesity of Michoacan, Mexico Use linear programming, e.g. as LinearProgramming or NMinimize, to find all extremal points in the cube subject to lying on the plane. The hypercube can be written as 2*n inequalities, in pairs of the form low_j<=p_j<=high_j, where p_j is a linear expression and the normals to these expressions are all pairwise orthogonal. In the nice case, they are simply coordinates, that is, inequalities are low_j<=x_j<=highDifferentialEvolution then it will be using an evolutionary algorithm (or, at least, an algorithm with evolution in its name; it's the appearance that matters, I'm told). Daniel Lichtblau Wolfram Research === Subject: Re: URL button on Documentation Center pages > I just noticed the URL button at the top right corner of Mathematica > 6.0.2 Documentation Center pages. Is this new in 6.0.2? I hadn't > noticed it before. Also, what is the use of the first entry in the 4-item drop-down menu > that results from clicking the URL button? It simply shows you the URL. Sometimes you can get to a given page in the Documentation center with out the syntactically full URL appearing in the search field. >This entry is the same as > what appears in the search bar above the actual page. (By contrast, the 2nd entry, Copy url, is a minor time saver: With > two clicks, one on URL, the second on that Copy url entry, one has > the page's URL on the clipboard. This is definitely faster, at least > for me, than moving the mouse into the search bar, selecting the entire > entry there, and then using the usual key combination to copy it.) -- > Murray Eisenberg mur...@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: change a system of PDEs to ODEs via traveling wave Todd, > If I have a system of PDEs in x and t, how can I change to the > traveling wave variable xi=x-ct to get a system of ODEs? This is an example for Burger's equation u_t -u_xx + u u_x = 0 . It should be easy to extend it to a system. Define the operator burgers[u_, {x_,t_}] := D[u,x] - D[u, {x,2}] + u D[u, {x,2}] Now burgers[f[x - c t], {x,t}] /. x - c t -> y gives the equation for a travelling wave with profile f[y]. Julian === Subject: PlotLegends package Does anyone know how to make the example lines in the legend wider. I am using Dashed and Dotted and its pretty hard to tell them apart in the legend since the example is very narrow. I see how to make the LegendTextSpace narrower and LegendSpacing to move the text over, but how to you get the the lines wider. For example it is like this now ___ Line 1 ..... Line 2 But I want ______ Line 1 ........... Line 2 === Subject: Re: Wolfram Workbench user experiences > > Before Workbench existed, many times I used a very simple ASCII editor > (Notepad for Windows) to create Mathematica packages. My personal reason for > using an ASCII editor is that I like to have control on the exact code that > is actually written, and I liked to have my code in a readable way, even if > you do Not have Mathematica (if you used Mathematica 5.2 as your IDE, to > write the packages, then .m file was not so easy to read, end-of-line > characters were missing, weird characters would appear, etc. so that you > actually needed the original .nb file from which the .m file was created, in > order to be able to read -as a human- the package) > > That is my personal way of programming. Sometimes I do the same with HTML > files, just use a simple ASCII editor, so I have all the control in the > actual code. > > Now that I have Wolfram Workbench 1.0.0, I like it very much. For me, it is > like a simple ASCII editor but it does know about Mathematica syntax, so I > have syntax coloring, when I mouse-over a known Mathematica command, I get > the message about the basic syntax of that command, etc. But at the same > time, WHAT I WRITE IS WHAT I GET in the final .m file, which is something > that I like very much. Furthermore, you also get syntax coloring when you > print your program. That I love: many advantages without losing the control > of the exact code that is written in the .m file of my packages. > > Therefore, for me, who used to program in simple ASCII editor (Notepad for > Windows), the Workbench has been great. > > Of course I do a very basic use of all the possibilities of Workbench, so > far I have Not written a package where different programming languages are > used, neither have I used other advanced features of Workbench. I have > written just plain Mathematica packages, like the one here: > http://homepage.cem.itesm.mx/lgomez/quantum/index.htm > > Jose > Mexico > > > -----Mensaje original----- > De: David Bailey [mailto:dave@Remove_Thisdbailey.co.uk] > Enviado el: Viernes, 02 de Mayo de 2008 02:43 a.m. > Para: mathgroup@smc.vnet.net > Asunto: Wolfram Workbench user experiences > > I would be very interested in other people's experiences with the > Wolfram Workbench. I must admit that I prefer to use the frontend as my > 'IDE', and the workbench seemed fairly alien when I tried it. > > David Bailey > http://www.dbaileyconsultancy.co.uk > > > Try opening a .m file in Mathematica. At 6.0 you get a much better editor than the WB. It knows about (and therefore displays) lots of special symbols, and it finds and colours probable syntax errors. It operates much more like an editor than the notebook editor because it does not try to auto-indent. Best of all, it lets you create headings and sections - just as you would in a notebook - and it hides these away in the .m file as Mathematica comments. I prepare all my packages using this part of Mathematica. David Bailey http://www.dbaileyconsultancy.co.uk === Subject: Re: Range of Use of Mathematica > >> One sign of bloat, is that there are now two major interfaces - >> notebook >> and Workbench (not to mention Math.exe) and such a profusion of >> commands >> and options that even those of us that use the product regularly >> cannot >> hope to be familiar with more than a smallish subset. There are also >> two >> help systems! This has, unfortunately, impacted on the quality of >> documentation. My advice to a beginner would be to read the V5.0 or >> even >> V4.0 documentation (plus a few tips about the changes in Graphics) to >> get some idea of the way the system works. > > > I think one should not loose sight of in my opinion, a very essential > fact, which is that the Mathematica Kernel, has remained largely > unchanged, except (of course) for continual enhancement by addition of > new functions, which only make it more efficient and powerful (and > make programing considerably easier). What this means is, that people > who see themselves essentially as Kernel users, are not in any > fundamental away affected by any of the changes you are mentioning > above. I know, because I consider myself one of them. I have never > tried using Workbench (even though I have downloaded it), and I have > not even made a serious effort to learn how MakeBoxes etc, works. I > still write all research in TeX. I know that it is possible to use > FrontEndToken etc, and if I even wanted to do so I know where to find > the documentation - but I have never found any incentive to do this. > However, I have become interested in the new Dynamic functionality, > partly because I think it is a great teaching tool and partly because > of the Demonstrations project, but this is really the first new > addition to the Front End that has interested me. I am sure that I am > not alone. In fact, Wolfram has a different set of people working on > the Kernel and on the Front End, and I am sure that there are people > in the Kernel group whose knowledge of the workings of the Front End > isn't much greater than mine. > > I mention this because even though I have not, until recently, been > very interested in the Front End, I have never been in anyway > inconvenience by the developments that have taken place in that area. > True, Mathematica has grown larger, but not more than have my hard > that seem to worry AES. I am a mathematician and intend to remain one. > I use Mathematica in the way that it was originally advertised, as a > system for doing mathematics by computer. The most far reaching > change in the program that was ever made happened, in fact, in version > 2, when the Kernel was separated from the Front End. Sometime little > later WRI changed its advertising slogan to something like the > world's only fully integrated technical computing system. That, of > course, shows clearly the strategic direction that WRI chose and it > has consistently followed since. But for me it has always remained a > system for doing mathematics by computer. In spite of that, I see no > reason to complain, because I have never found the slightest conflict > between these two roles of Mathematica. I have never found , for > example, that the development of Mathematica's typesetting > capabilities has in any way adversely affected any of Mathematica's > numerical or algebraic ones, which are the ones that really matter to > me. > So I really still fail to see what this whole discussion is supposed > to be about. I particularly, I can't understand why someone who keeps > saying that Mathematica does not need publishing or presentation > capabilities etc. and should only be used for computations would at > the same time complain about the supposed lack of documentations of > functionality which, according to him, should not be there in the > first place. > > Andrzej Kozlowski > > > Obviously, WRI are very reluctant to remove functionality, so our code goes on working from version to version. That is great, but we surely also want newcomers to find Mathematica easy to use. Unless a new user decides to go on a course - with all the extra expense that involves - they have to try to get an overview of the system and decide which features are important to learn about. I suspect that this is not as easy as it may seem to those of us that have used Mathematica for years, and know how it all fits together. The new documentation system encourages a browsing style of learning that may miss out vital ideas. For example, a user could be forgiven for deciding not to invest time learning about the relationship between the FE and the kernel. As a result he may fail to understand how code in different notebooks interoperates. API's can get too big - try programming in the WIN32 API! David Bailey http://www.dbaileyconsultancy.co.uk === Subject: Re: Computing n-grams Use Partition x = {a, b, c, d, e, f, g}; Partition[x, 2, 1] {{a, b}, {b, c}, {c, d}, {d, e}, {e, f}, {f, g}} Partition[x, 3, 1] {{a, b, c}, {b, c, d}, {c, d, e}, {d, e, f}, {e, f, g}} Bob Hanlon > > Imagine one has a list such as {a,b,c,d,e,f,g}. I'm trying to find an > efficient way in Mathematica to compute the n-grams of the list. That is, for > n=2, the n-grams are all the lists of length 2 consisting of consecutive > elements, e.g., > > {a,b},{b,c},{c,d},{d,e},... > > While for n=3, > > {a,b,c},{b,c,d},{c,d,e},..., and so on. > > As I understand it, the built-in Mathematica commands such as Subsets or > Permutations compute all possible list of size n, without regard to the > order of the list elements. > > > Mark > > === Subject: Re: On which OS is Mathematica best implemented? So far as I can tell, Mathematica is identical on the two machines. Bobby > I have not used Mathematica in a long time, but am about to get back > into it. In it's first few versions (the only ones I have used) the Mac > version was by far more polished, had more features, and was much > stabler than its Windows counterpart (well, for everything I wanted to > do, which was a lot). Such was the case for quite a few other programs > at the time, including Microsoft's own cash caws, Excel and Word. Well, things changed for the Office suite- The Windows versions of Excel > and Word have been ahead of the Mac versions for years (since v.5 of > Excel). What about Mathematica? On which OS is it ahead by and large > /these/ days? How does its release/update history compare on the two > platforms? The computer I will load this onto runs Mac OS 10.5.2, WinXP > sp3, and of course Unix. Dave -- DrMajorBob@longhorns.com === Subject: Re: On which OS is Mathematica best implemented? On 2008-05-22 04:25:07 +0930, LeftCoast_Dave said: > On which OS is it ahead by and large > /these/ days? Being originally written on the Mac I find its windowing metaphor makes more sense still on Mac OS X (there's no shortcut in Windows to cycle through, um, windows -- as far as I was able to tell), but in terms of what the program can do it's identical across all platforms. This is no doubt due to large parts of the program now being written in Mathematica itself. Will === Subject: Re: On which OS is Mathematica best implemented? > On 2008-05-22 04:25:07 +0930, LeftCoast_Dave said: > >> On which OS is it ahead by and large >> /these/ days? > > Being originally written on the Mac I find its windowing metaphor makes > more sense still on Mac OS X (there's no shortcut in Windows to cycle > through, um, windows -- as far as I was able to tell), but in terms of > what the program can do it's identical across all platforms. This is no > doubt due to large parts of the program now being written in > Mathematica itself. > > Will > > I added the following to my MENUSETUP.TR file to provide a menu item for cycling through windows: Item[Ne&xt,FrontEndExecute[Module[List[Set[ll, Notebooks[]], k], CompoundExpression[ Set[ll, DeleteCases[ll, Condition[Pattern[s, Blank[]], Or[Not[Part[Options[s, WindowClickSelect], 1, 2]], Not[Part[Options[s, Visible], 1, 2]]]]]], Set[ll, Sort[ll]], Set[k, Part[Position[ll, SelectedNotebook[]], 1, 1]], SetSelectedNotebook[Part[Join[ll, ll], Plus[k, 1]]]]]],MenuEvaluator->Automatic], Needless to say, you should preserve the old version of MENUSETUP.TR before you try to edit it! Because the menu item has a mnemonic, just typing Alt-X will perform the cycling operation. David Bailey http://www.dbaileyconsultancy.co.uk === Subject: Re: On which OS is Mathematica best implemented? > (there's no shortcut in Windows to cycle > through, um, windows -- as far as I was able to tell), Try CTRL-F6. This is a standard Windows shortcut key for cycling through sub-windows. === Subject: Re: On which OS is Mathematica best implemented? I think that it is a reasonable truth to say that the Windows and mac versions are very similar (I don't use Linux/Unix). The key differences between any of the implementations really reside in the qualitative differences between the operating systems themselves. WRI does a remarkable job of executing a parallel development across OS's. I use a Mac, but I develop a variety of applications on it which I then need to deploy on other OS's. My experience in doing a lot of this is that when I create something on the Mac, it generally works elsewhere in the same way; sometimes though I need to do some small OS-specific tweaks... I hope that this helps... --David A WorkLife FrameWork E x t e n d i n g MATHEMATICA's Reach... Trial Version at: http://scientificarts.com/worklife/ > I have not used Mathematica in a long time, but am about to get back > into it. In it's first few versions (the only ones I have used) the Mac > version was by far more polished, had more features, and was much > stabler than its Windows counterpart (well, for everything I wanted to > do, which was a lot). Such was the case for quite a few other programs > at the time, including Microsoft's own cash caws, Excel and Word. Well, things changed for the Office suite- The Windows versions of Excel > and Word have been ahead of the Mac versions for years (since v.5 of > Excel). What about Mathematica? On which OS is it ahead by and large > /these/ days? How does its release/update history compare on the two > platforms? The computer I will load this onto runs Mac OS 10.5.2, WinXP > sp3, and of course Unix. Dave === Subject: Re: Adding an edge to a directed cyclic graph Aside from explicitly changing the embedding coordinates of vertices in the Graph object, offhand the only ways I know to change the location of vertices for ShowGraph by Mathematica commands are the Combinatorica functions ShakeGraph and SpringEmbedding. But some other methods are: other options are: (1) Use GraphPlot instead of ShowGraph and then manually move the vertex by clicking in its vicinity until you see a small graphics square highlighted, then drag to a new position. (2) Use Levon Lloyd's visual graph editor, which exports in Combinatorica Graph type form. Undoubtedly it would not be terribly difficult to construct a Dynamic expression that uses locators in order to create and move vertices and edges for a graph. This could just reproduce the behavior of Lloyd's visual editor, so it's not clear what would be gained except that everything could be done strictly within Mathematica. You might find helpful the guide to Combinatorica'a graph functions (and to the kernel's GraphPlot function) that I used for my Discrete Structures course. See the item Graphs.nb on the Files page at: www.math.umass.edu/Courses/Math_455_Eisenberg > Sorry to ask a question that probably has an answer in the > Combinatorica book; I've just purchased it and waiting for delivery. > > I am teaching myself discrete math by learning Combinatorica. Is there > an obvious way to add an edge to a directed graph and have > the edges renumbered associated with the cyclic order? The number of > vertices are fixed. > > This seems like a common thing to do; so before embarking on my own > code to do this, I am hoping I am missing an obvious built-in. > > For example: > > Needs[Combinatorica`] > > (*c6 is the cycle in which I'd like to insert and edge*) > > c6 = Cycle[6, Type -> Directed] > ShowGraph[c6, VertexNumber -> True, EdgeLabel -> True, > EdgeLabelColor -> Darker[Orange], BaseStyle -> Large] > > (*here I hope to add a sub-loop to replace the edge going from 4-5*) > modc6 = AddEdges[ > DeleteEdge[c6, {4, 5}], > { > {{4, 5}, EdgeColor -> Green}, > {{5, 4}, EdgeColor -> Blue}, > {{4, 5}, EdgeColor -> Red} > } > ] > > (*the edge numbering no longer corresponds to the cycle index--what I > need is a ReplaceEdge*) > > ShowGraph[modc6, VertexNumber -> True, EdgeLabel -> True, > EdgeLabelColor -> Darker[Orange], BaseStyle -> Large] > > (*does anyone know an option to increase the bowing angle of the > Graphics for the subloop?*) > -- 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: solid sections I have a base region comprised of 2 parabolic functions. I also have a semi-ellipse as the typical dx slice, and the length of the semi- ellipse(long side) is the length of the base region (i.e. top function minus bottom function). The ratio for the length of the semi-ellipse and it's height have already been established. My question is: Is there any way in Mathematica that I can plot the base region, and then have it plot on the same view, a 3D representation of the slices on top of the base region. It will basically be an integral in the dx direction with predetermined delta Xes (i.e. the thickness of each slice). If someone knows the syntax/code for this, I will be most grateful. === Subject: Interpolation and plot doing strange things with mathematica 6 tia I run these commands that I've had plenty of help getting to work...but the plot doesn't follow the points, as you can see in the plot. At the end it just goes crazy and when I test the points with input s[0] output is -3.73293 why are the numbers so out of sync... at s[0] it should be -2 not -3.73293 I try increasing the number in the line N[FourierTrigSeries[f[x], x, 25, FourierParameters -> {-1, 1/138}]] (I've changed the number 25 to over 100 and the problem seems to get worse) See code below: In[89]:= data3 = {{0, -2}, {7, 1}, {10, 6}, {12, -2}, {18, -6}, {27, 6}, {34, 4}, {42, -6}, {49, -5}, {56, 4}, {62, 3}, {67, -5}, {70, -3}, {79, 3}, {83, 7}, {88, -3}, {89, -8}, {96, 7}, {105, 9}, {113, -8}, {122, -9}, {131, 9}, {132, 1}, {134, -9}, {138, -2}}; f = Interpolation[data3, PeriodicInterpolation -> True]; << FourierSeries` s[x_] = N[ FourierTrigSeries[f[x], x, 25, FourierParameters -> {-1, 1/138}]] discr = Interpolation[data3 /. {x_, y_} -> {x, y}, InterpolationOrder -> 1]; g[x_] = Piecewise[{{discr[x], 0 < x < 138}, {0, True}}]; Show[Plot[s[x], {x, 0, 138}, PlotStyle -> Red, PlotRange -> {-15, 15}], Plot[g[x], {x, 0, 138}, Filling -> Axis], ListPlot[data3, Filling -> Axis, PlotRange -> {0, 138}]] tia sal2 === Subject: Re: Interpolation and plot doing strange things with mathematica if you make a approximation based on a Fourier series it converges in the middle and never point wise The most famous example is the Gibbs phenomenon. http://en.wikipedia.org/wiki/Gibbs_phenomenon Jens > > I run these commands that I've had plenty of help getting to > work...but the plot doesn't follow the points, as you can see in the > plot. At the end it just goes crazy and when I test the points with > > input s[0] > output is -3.73293 > why are the numbers so out of sync... at s[0] it should be -2 not > -3.73293 > > I try increasing the number in the line > N[FourierTrigSeries[f[x], x, 25, FourierParameters -> {-1, 1/138}]] > (I've changed the number 25 to over 100 and the problem seems to get > worse) > > See code below: > > In[89]:= data3 = {{0, -2}, {7, 1}, {10, 6}, {12, -2}, {18, -6}, {27, > 6}, {34, > 4}, {42, -6}, {49, -5}, {56, 4}, {62, 3}, {67, -5}, {70, -3}, {79, > 3}, {83, 7}, {88, -3}, {89, -8}, {96, 7}, {105, > 9}, {113, -8}, {122, -9}, {131, 9}, {132, > 1}, {134, -9}, {138, -2}}; > f = Interpolation[data3, PeriodicInterpolation -> True]; > > << FourierSeries` > > s[x_] = N[ > FourierTrigSeries[f[x], x, 25, FourierParameters -> {-1, 1/138}]] > > discr = Interpolation[data3 /. {x_, y_} -> {x, y}, > InterpolationOrder -> 1]; > > g[x_] = Piecewise[{{discr[x], 0 < x < 138}, {0, True}}]; > > Show[Plot[s[x], {x, 0, 138}, PlotStyle -> Red, > PlotRange -> {-15, 15}], Plot[g[x], {x, 0, 138}, Filling -> Axis], > ListPlot[data3, Filling -> Axis, PlotRange -> {0, 138}]] > > tia sal2 > === Subject: Re: EventHandler problem > I'm trying to design a custom InputField that indicates whether or not = > the user has pressed Return to submit the changes. It's a simple > design: a red or green disk is drawn to the right of the InputField to = > indicate the state. Here's the definition of the disks: red = Graphics[{Green, AbsolutePointSize[12], Point[{0, = 0}]}, > ImageSize -> {20, Automatic}] green = Graphics[{Green, AbsolutePointSize[12], Point[{0= , 0}]}, > ImageSize -> {20, Automatic}] Here's my first attempt at creating the InputField: DynamicModule[{k = 1, changed = False}, > Row[{ > EventHandler[ > InputField[Dynamic[k], Number, FieldSize -> Tiny, > ContinuousAction -> True], > {KeyDown :> (changed = True), > ReturnKeyDown :> (changed = False) > }, > PassEventsDown -> True > ], > Dynamic[If[changed, red, green]] > }] > ] Everything works except setting the value of changed back to False > when the Return key is pressed. Mathematica fires the action for > *both* KeyDown and ReturnKeyDown, and the KeyDown action is > invoked after the ReturnKeyDown action. (This happens regardless of > whether one uses {KeyDown :> (...), ReturnKeyDown :> (...) } or > {ReturnKeyDown :> (...) KeyDown :> (...)} in the argument to > EventHandler.) I've tried detecting the value of the key by using CurrentValue[EventK= ey] but this doesn't seem to do anything... Any thoughts on how to solve this problem would be greatly appreciated! > Jason -- > Dr J. McKenzie Alexander > Department of Philosophy, Logic and Scientific Method > London School of Economics and Political Science > Houghton Street, London WC2A 2AE > The CurrentValue[EventKey] behaviour is a bug. Here's a workaround: DynamicModule[{col = Green, x = Null, ret = }, EventHandler[ {InputField[Dynamic[x]], Style[[FilledCircle], FontColor -> Dynamic[col]]}, {KeyDown :> (If[! ret, col = Red]; ret = False), ReturnKeyDown :> (col = Green; ret = True)}, PassEventsDown -> True] ] Maxim Rytin m.r@inbox.ru === Subject: circuit grid Hello all I am trying to implement a routing algo, As routing is done on a grid (what i mean by grid is here)(http://www.lautsprechershop.de/hifi/ images/platte_ra140.jpg) I was trying to represent it using a Polygon, and using Points to represent the points, but wasn't able to represent points (Points) on the polygon. How can I represent a Point on a defined polygon === Subject: Re: Redundant manipulate > What does that Labeled accomplish that the following does not? Absolutely nothing. ;-) > > Column[{Slider[Dynamic[10/a, (a = 10/#) &], {1, 10}], > Slider[Dynamic[a], {1, 10}], Dynamic[a]}, > Alignment -> Center] > > I have a manipulate like this: Manipulate[ > Row[{a = , a, b = 2 a = , b = 2 a}] > , {a, -10, 10, 1}, {b, -20, 20, 1}] If I change a, then b changes, but I also want that when I change b, > I'm not sure how to do this with Manipulate, but it is achievable with = > >> Dynamic: >> Labeled[Column[{Slider[Dynamic[10/a, (a = 10/#) &], {1, 10}], >> Slider[Dynamic[a], {1, 10}]}], Dynamic[a]] > === Subject: Re: Computing n-grams Try Partition[list,n,1] where list is the list to be partitioned > Imagine one has a list such as {a,b,c,d,e,f,g}. I'm trying to find an > efficient way in Mathematica to compute the n-grams of the list. That is, > for > n=2, the n-grams are all the lists of length 2 consisting of consecutive > elements, e.g., {a,b},{b,c},{c,d},{d,e},... While for n=3, {a,b,c},{b,c,d},{c,d,e},..., and so on. As I understand it, the built-in Mathematica commands such as Subsets or > Permutations compute all possible list of size n, without regard to the > order of the list elements. > Mark > -- Richard Palmer Home 508 877-3862 Cell 508 982-7266 === Subject: Re: Computing n-grams Hello Mark, I believe this may work for your purposes: t = {a, b, c, d, e, f, g} Transpose[NestList[RotateLeft[#] &, t, 1]] Transpose[NestList[RotateLeft[#] &, t, 2]] Imagine one has a list such as {a,b,c,d,e,f,g}. I'm trying to find an > efficient way in Mathematica to compute the n-grams of the list. That is, for > n=2, the n-grams are all the lists of length 2 consisting of consecutive > elements, e.g., {a,b},{b,c},{c,d},{d,e},... While for n=3, {a,b,c},{b,c,d},{c,d,e},..., and so on. As I understand it, the built-in Mathematica commands such as Subsets or > Permutations compute all possible list of size n, without regard to the > order of the list elements. > Mark > -- W. Craig Carter === Subject: Re: Computing n-grams Partition[ myList, n, 1] Hope that helps! C.O. Imagine one has a list such as {a,b,c,d,e,f,g}. I'm trying to find an > efficient way in Mathematica to compute the n-grams of the list. That is, > for n=2, the n-grams are all the lists of length 2 consisting of > consecutive elements, e.g., {a,b},{b,c},{c,d},{d,e},... While for n=3, {a,b,c},{b,c,d},{c,d,e},..., and so on. As I understand it, the built-in Mathematica commands such as Subsets or > Permutations compute all possible list of size n, without regard to the > order of the list elements. > Mark -- Curtis Osterhoudt cfo@remove_this.lanl.and_this.gov PGP Key ID: 0x4DCA2A10 Please avoid sending me Word or PowerPoint attachments See http://www.gnu.org/philosophy/no-word-attachments.html === Subject: Re: Computing n-grams Imagine one has a list such as {a,b,c,d,e,f,g}. I'm trying to find an > efficient way in Mathematica to compute the n-grams of the list. > That is, for > n=2, the n-grams are all the lists of length 2 consisting of > consecutive > elements, e.g., {a,b},{b,c},{c,d},{d,e},... While for n=3, {a,b,c},{b,c,d},{c,d,e},..., and so on. As I understand it, the built-in Mathematica commands such as > Subsets or > Permutations compute all possible list of size n, without regard to > the > order of the list elements. I don't think you need to use Combinatorica, nGram[l_,n_]:=Table[l[[Range[i,i+n-1]]],{i,Length[l]-n+1}] will give you the desired list. === Subject: Re: Computing n-grams Imagine one has a list such as {a,b,c,d,e,f,g}. I'm trying to find an > efficient way in Mathematica to compute the n-grams of the list. That is, for > n=2, the n-grams are all the lists of length 2 consisting of consecutive > elements, e.g., {a,b},{b,c},{c,d},{d,e},... While for n=3, {a,b,c},{b,c,d},{c,d,e},..., and so on. As I understand it, the built-in Mathematica commands such as Subsets or > Permutations compute all possible list of size n, without regard to the > order of the list elements. > Mark Partition with an offset of 1 will do the trick. In[1]:= Partition[{a, b, c, d, e, f}, 3, 1] Out[1]= {{a, b, c}, {b, c, d}, {c, d, e}, {d, e, f}} In[2]:= nGram[list_,n_]:=Partition[list,n,1] In[3]:= nGram[{a, b, c, d, e, f},2] Out[3]= {{a, b}, {b, c}, {c, d}, {d, e}, {e, f}} Darren Glosemeyer Wolfram Research === Subject: Re: Plotting a series of piecewise functions Hi Claus, a simple If statement will do it. Further, you haf a syntax error, confusing x0 and xo: f[lambda_,xo_,x_]:=If[x I want to plot a series of functions. Namely I want to plot a series of > 2-parametric exponential distribution functions. By series I mean the > graphs for various xo values on one plot. > So, > the function looks like this: > > f[lambda_, xo_, x_]:=lambda*Exp[-lambda*(x-xo)] > > Now I can plot this (wrongly) with > > Plot[Evaluate[Table[f[lambda,xo,x],{lambda,0.5,0.5},{x0,4}]],{x,0,10}] > > The problem is that, really, f should be zero for x I can plot one graph (for xo=1 and lambda=1) like this: > > Plot[Piecewise[{{f[0.5,1,x],x>1},{0,x<1}}],{x,0,10}] > > Now, how could I plot a series of plots (for different xo) on one chart > similarly to the Piecwise approach (can I do it with Piecewise at all, > or do I need an If clause of sorts)? > > Claus > -- Daniel Huber Metrohm Ltd. Oberdorfstr. 68 CH-9100 Herisau Tel. +41 71 353 8585, Fax +41 71 353 8907 E-Mail: Internet: === Subject: Re: Plotting a series of piecewise functions you can plot it when you find out that xo is different from x0 because o is a letter and 0 is a digit Plot[Evaluate[Table[f[lambda,x0,x],{lambda,0.5,0.5},{x0,4}]],{x,0,10}] when you define f[lambda_, xo_, x_] := Piecewise[{{lambda*Exp[-lambda*(x - xo)], x > xo}}, 0] Jens > I want to plot a series of functions. Namely I want to plot a series of > 2-parametric exponential distribution functions. By series I mean the > graphs for various xo values on one plot. > So, > the function looks like this: > > f[lambda_, xo_, x_]:=lambda*Exp[-lambda*(x-xo)] > > Now I can plot this (wrongly) with > > Plot[Evaluate[Table[f[lambda,xo,x],{lambda,0.5,0.5},{x0,4}]],{x,0,10}] > > The problem is that, really, f should be zero for x I can plot one graph (for xo=1 and lambda=1) like this: > > Plot[Piecewise[{{f[0.5,1,x],x>1},{0,x<1}}],{x,0,10}] > > Now, how could I plot a series of plots (for different xo) on one chart > similarly to the Piecwise approach (can I do it with Piecewise at all, > or do I need an If clause of sorts)? > > Claus > === Subject: Re: Colors chosen for ListPlot, etc., in v. 6 > > I was curious about the colors used automatically for multiple lists in > graphics such as ListPlot. I cannot shed more light but only to say that the automatic colors seem to be the same as in the indexed color palette 1 - see ColorData[1] Antti === Subject: Re: Problems with ListPlot >> 2) In addition of 1 point and 1 line (2 other should be clipped as >> they lie outside of the range) I see 2 points, where the line crosses >> the lower and upper edges of the plot. > I don't really understand this second question ... > if you set Joined -> True, there are 2 points visible at:{1.5,0.5} and >> {2.5,1.5} that should not be there. >> Version:6.0 for Microsoft Windows (32-bit) (February 7, 2008) >> Daniel > > Oh, sorry, now I see what the OP meant. The Mesh option influences > this, but I couldn't find a workaround ... > It would probably be quicker not to use ListPlot at all, and just > build up the plot from graphics primitives (i.e. quicker than finding > a workaround for this bug) ... It would also make handling plot > markers easier ... > Here's a workaround: Try moving the PlotRange option out of ListPlot (it has a different meaning for plotting functions and for Graphics ... quite confusing ...): Show[ ListPlot[{0, 1, 2}, PlotMarkers -> Style[[FilledCircle], FontSize -> 12], Joined -> True, GridLines -> Automatic], PlotRange -> {{1, 3}, {0.5, 1.5}}, AxesOrigin -> Automatic] === Subject: Re: How to connect one object to the other? image (find the attached jpg image file - contact the author as attachments are not permitted in this group - moderator). i want to connect one object (disk / circle) to the other, with arrow, and when we move any object, all attached arrows has to attached with it. > Gohar, Below are two solutions with different characteristics:- First, plotObject[G_] := > Locator[{RandomReal[30], RandomReal[30]}, Graphics[G], ImageSize - 20] > Framed@Graphics[ > Table[{Arrow[{{RandomReal[30], RandomReal[30]}, {RandomReal[30], > RandomReal[30]}}], > plotObject[{RGBColor[RandomReal[1], RandomReal[1], RandomReal[1], > 0.5], > Disk[{5, 5}, 5]}]}, {i, 10}], PlotRange -> 50] gives black arrows which can be double clicked to move, resize & > redirect each of them but are not Locators. Second, plotObject[G_] := > Locator[{RandomReal[30], RandomReal[30]}, Graphics[G], ImageSize - 40] Framed@Graphics[ > Table[{plotObject[{RGBColor[RandomReal[1], RandomReal[1], > RandomReal[1], > 0.5], Arrowheads[Large], > Arrow[{{RandomReal[30], RandomReal[30]}, {RandomReal[30], > RandomReal[30]}}]}], > plotObject[{RGBColor[RandomReal[1], RandomReal[1], RandomReal[1], > 0.9], > Disk[{5, 5}, 5]}]}, {i, 10}], PlotRange -> 50] gives random coloured arrows which are locators which can be dragged > but which cannot be resized or redirected. HTH, > Syd Geraghty B.Sc, M.Sc. sydgeraghty@mac.com My System Mathematica 6.0.2.1 for Mac OS X x86 (64 - bit) (March 13, 2008) > MacOS X V 10.5.2 > i am using Mathematica 6 on Window XP > > this code makes disk drag able disk objects, i want to connect them > with > arrow, how con i achieve this, any ideas? > > plotObject[G_] := Locator[{RandomReal[30], RandomReal[30]}, > Graphics[G], ImageSize -> 20] > > p = { > RGBColor[RandomReal[1], RandomReal[1], RandomReal[1], 0.5], > Disk[{5, 5}, 5] > } > > Framed@Graphics[ > Table[plotObject[{RGBColor[RandomReal[1], RandomReal[1], > RandomReal[1], 0.5], Disk[{5, 5}, 5]}], {i, 10}], > PlotRange -> 50] > > Gohar Sultan > === Subject: Re: how to determine the center or foci of an ellipse from a slope Hi John, Thomas,??? Having a slope field is a differential equation. Specifying an initial condition, we are able to integrate it and get one of the many possible ellipses. Having an ellipse, you can determine the center. First we must create a function with input: x,y and output: slope, call it slope[{x,y}]. If your data is measured on a rectangular grid, the function Interpolation will do this. Next we specify the DE: eq={pos'[t]==slope[pos[t]], pos[0]==pos0} where pos[t] is the position (a 2 vector) and pos0={x0,y0} are suitable initial conditions. Now we can solve: NDSolve[eq,p[t],{t,0,tmax}] where tmax must be chosen according to your data. Last we must determine the center. One way to do this is to remember that an ellipse is a quadratic curve that can be described e.g. by: a x^2+2 b x y+ c y^2 + 2 d x + 2 f y + g == 0 the parameters a,b,..g can be fitted using some points {x,y} of your previous solution. With these parameters, we get the center: x0=(cd-bf)/(b^2-ac) y0=(af-bd)/(b^2-ac) (you may look this up e.g.: http://mathworld.wolfram.com/Ellipse.html) hope this helps, Daniel > Hi guys, > I have a slope field (2d-array), which is defined > by ellipses (can be arbitrarily tilted), which all have the > same foci and center but different major and minor half axes. > In fact, I obtained the tangent at each point by measurements. > > Does somebody have an idea on how to approach the problem > of finding the center or the foci of the ellipses? I think > there is no exact solution to the problem? > > Thomas > -- Daniel Huber Metrohm Ltd. Oberdorfstr. 68 CH-9100 Herisau Tel. +41 71 353 8585, Fax +41 71 353 8907 E-Mail: Internet: === Subject: Re: how to determine the center or foci of an ellipse from a slope > Hi guys, > I have a slope field (2d-array), which is defined > by ellipses (can be arbitrarily tilted), which all have the > same foci and center but different major and minor half axes. > In fact, I obtained the tangent at each point by measurements. Does somebody have an idea on how to approach the problem > of finding the center or the foci of the ellipses? I think > there is no exact solution to the problem? > For those who might post replies to this topic: This same question has also been asked here: http://tinyurl.com/5gdn2t === Subject: Re: Help with find root needed Hi Aaron, the slope at strating point 10 is too large and the algorithm overshoots. Choose a better starting point, e.g. Max[1,gamma] Further, if the root is near 1 you must allow Mathematica to search around 1. Simply change {z,10,1,10} to {z,10,0.5,10}. Here is the correction: K[h_,[Gamma]_]:=z/.FindRoot[f[z,h,[Gamma]]==0,{z,Max[1,[Gamma]],0.5,10 }]; hope this helps, Daniel > > In what follows, I'm looking for the largest root of a function, that > is also a function of two parameters. The Manipulate command shows me > that the root is consistently there (albeit near a singularity which > might be what's causing problems). However, FindRoot doesn't find it > as the plot shows. I get one error, but my guess is that it's > referring to one particular point on the plot. > > f[z_, h_, [Gamma]_] := > Tanh[h*z] + ([Gamma]^2 + 1 - z^2)/([Gamma]^2 - 1 - z^2) * > z/[Gamma]; > Manipulate[ > Plot[f[z, h, [Gamma]], {z, 0, 10}], {h, .1, 10}, {[Gamma], .1, > 10}] > K[h_, [Gamma]_] := > z /. FindRoot[f[z, h, [Gamma]] == 0, {z, 10, 1, 10}]; > Plot3D[K[h, [Gamma]], {h, .1, 10}, {[Gamma], .1, 10}] > > > Aaron > -- Daniel Huber Metrohm Ltd. Oberdorfstr. 68 CH-9100 Herisau Tel. +41 71 353 8585, Fax +41 71 353 8907 E-Mail: Internet: === Subject: Re: Help with find root needed In what follows, I'm looking for the largest root of a function, that > is also a function of two parameters. The Manipulate command shows me > that the root is consistently there (albeit near a singularity which > might be what's causing problems). However, FindRoot doesn't find it > as the plot shows. I get one error, but my guess is that it's > referring to one particular point on the plot. f[z_, h_, [Gamma]_] := > Tanh[h*z] + ([Gamma]^2 + 1 - z^2)/([Gamma]^2 - 1 - z^2) * > z/[Gamma]; > Manipulate[ > Plot[f[z, h, [Gamma]], {z, 0, 10}], {h, .1, 10}, {[Gamma], .1, > 10}] > K[h_, [Gamma]_] := > z /. FindRoot[f[z, h, [Gamma]] == 0, {z, 10, 1, 10}]; > Plot3D[K[h, [Gamma]], {h, .1, 10}, {[Gamma], .1, 10}] > Aaron > Starting closer to the root helps. If we start just to the right of the singularity, good results can be obtained. In[1]:= f[z_, h_, [Gamma]_] := Tanh[h*z] + ([Gamma]^2 + 1 - z^2)/([Gamma]^2 - 1 - z^2)* z/[Gamma]; In[2]:= K[h_, [Gamma]_] := z /. FindRoot[f[z, h, [Gamma]] == 0, {z, 1.01*([Gamma]^2 + 1)}]; In[3]:= Plot3D[K[h, [Gamma]], {h, .01, 10}, {[Gamma], .01, 10}, PlotRange -> All] The root finder is basically taking steps and refining step size to try to get to the root. With that sharp drop off heading to the left toward the singularity and starting far from the root, there is a better chance of the root finder taking too big of a step and stepping over the singularity. Darren Glosemeyer Wolfram Research === Subject: Re: Help with find root needed Hello Aaron, The singularity appears to be only a function of gamma; so its position can be precalculated. Perhaps, this will work for you: Kother[h_, [Gamma]_] := z /. Module[{singularity = Re[ Sqrt[[Gamma]^2 - 1]]}, FindRoot[ f[z, h, [Gamma]] == 0, {z, singularity + $MachineEpsilon, $MaxMachineNumber }]] (*for example*) Kother[1, 2] (*returns 2.00483*) I haven't tested it for the the full range of parameters In what follows, I'm looking for the largest root of a function, that > is also a function of two parameters. The Manipulate command shows me > that the root is consistently there (albeit near a singularity which > might be what's causing problems). However, FindRoot doesn't find it > as the plot shows. I get one error, but my guess is that it's > referring to one particular point on the plot. f[z_, h_, [Gamma]_] := > Tanh[h*z] + ([Gamma]^2 + 1 - z^2)/([Gamma]^2 - 1 - z^2) * > z/[Gamma]; > Manipulate[ > Plot[f[z, h, [Gamma]], {z, 0, 10}], {h, .1, 10}, {[Gamma], .1, > 10}] > K[h_, [Gamma]_] := > z /. FindRoot[f[z, h, [Gamma]] == 0, {z, 10, 1, 10}]; > Plot3D[K[h, [Gamma]], {h, .1, 10}, {[Gamma], .1, 10}] > Aaron -- W. Craig Carter === Subject: Mathematica SIG (Washington DC Area) The Washington D.C. area Mathematica Special Interest Group will meet Friday, 23 May, 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. For the prepared talk, Dan Martinez will present a mishmash of Manipulate applications and will discuss Inset. He will also present a demonstration titled Equilibrium of Three Coplanar Forces. 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. === === ===