mm-719 === Subject: GUI-Kit Xserver Problem Hello everyone, I've Mathematica installed on a linux box and use it via a Xserver on my Windows desktop. Now I'm trying to use this GUIKit and the examples that come with it. I've set the DISPLAY variable correctly export DISPLAY=192.168.0.xxx:0.0 The Mathematica windows pop up on my windows desktop flawlessly. But when I try to run one of those GUIKit examples, I get the following error message Java::excptn: A Java exception occurred: java.lang.InternalError: Can't connect to X11 window server using ':0.0' as the value of the DISPLAY variable. at sun.awt.X11GraphicsEnvironment.initDisplay(Native Method) at sun.awt.X11GraphicsEnvironment.(X11GraphicsEnvironment.java:134) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:141) at java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment( GraphicsEnvironment.java:62) at sun.awt.motif.MToolkit.(MToolkit.java:81) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:141) at java.awt.Toolkit$2.run(Toolkit.java:748) at java.security.AccessController.doPrivileged(Native Method) at java.awt.Toolkit.getDefaultToolkit(Toolkit.java:739) at com.sun.java.swing.plaf.gtk.GTKLookAndFeel$1.run(GTKLookAndFeel.java:264) at java.security.AccessController.doPrivileged(Native Method) GTKLookAndFeel.java:231) at com.sun.java.swing.plaf.gtk.GTKLookAndFeel.initialize(GTKLookAndFeel.java: 207) at javax.swing.UIManager.setLookAndFeel(UIManager.java:393) at javax.swing.UIManager.setLookAndFeel(UIManager.java:424) at com.wolfram.guikit.GUIKitDriver.prepareInitialLookAndFeel(Unknown Source) at com.wolfram.guikit.GUIKitDriver.createEnvironment(Unknown Source) at com.wolfram.guikit.GUIKitDriver.runModalFile(Unknown Source) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java: 39) at sun.reflect.DelegatingMethodAccessorImpl.invoke( DelegatingMethodAccessorImpl.java:25). Any idea? Christian === Subject: RootSearch-missing root I have a problem with the RootSearch. I have searched the archive and the RootSearch Examples and couldn't find an answer or at least the similar problem. The RootSearch doesn't find one of the roots. There are three roots, all three are clearly resolved when two functions are plotted but RootSearch finds only two of them. I tried to play with the options and with different values of xmax and xmin, and it just doesn't see it. FindRoot finds the missing root for well defined starting values. But I need to have all three roots. In what circumstances the RootSearch cannot find one of the roots? Ania === Subject: Re: Types in Mathematica I agree with Andrzej that that the hybrid nature of the Mathematica language is a great strength. It offers programmers (not all of whom are expert with Mathematica) a fall-back way to implement operations that they can't see how to do in a functional way. Often the loss of efficiency is not relevant in their application. Furthermore, when you use a language that follow a single paradigm (e.g. Java) there are always ideas that don't fit the paradigm and end up being implemented in a clumsy, confusing way - e.g. Java event processing (IMHO). David Bailey http://www.dbaileyconsultancy.co.uk === Subject: mathematica2mono why does mathematica insist on using its own mathematica2mono font for ( and ) when i've tried a hundred different ways to have all my text in Times when i export a graphic to pdf ? are there any undocumented options for Export[a.pdf, expr] ? i've tried {IncludeSpecialFonts -> True} from eps format. that doesnt work either. ------------------------- ts = {FontFamily -> Times, FontWeight -> Plain, FontSize -> 18, FontSlant -> Italic}; (*FontSubstitutions -> {Mathematica2 -> Times}*) p = Plot[Evaluate[Table[LegendreP[n, x], {n, 5}]], {x, -1, 1}, Prolog -> {AbsoluteThickness[2]}, PlotStyle -> {Red, Yellow, Green, Blue, Violet}, Epilog -> { Text[P1(x), {-.6, -.75}, TextStyle -> ts], Text[P2(x), {.1, -.6}, TextStyle -> ts], Text[P3(x), {.45, -.55}, TextStyle -> ts], Text[P4(x), {.65, -.5}, TextStyle -> ts], Text[P5(x), {.9, -.4}, TextStyle -> ts] } ]; Export[legendre.pdf, %]; ------------------------- i'm not trying to print the greek alphabet upside down, i just want to get a character from the ascii 128 set ... Mitch === Subject: Re: Plotting polyhedra Peter, How about this? v1 = {0, 0, 0}; v2 = {1, 0, 0}; v3 = {0, 1, 0}; v4 = {0, 0, 1}; Show[Graphics3D[{Polygon[{v1, v2, v3}], Polygon[{v1, v2, v4}], Polygon[{v1, v4, v3}], Polygon[{v4, v2, v3}]}]]; But if you are going to plot many tetrahedrons... tetrahedron[{v1_, v2_, v3_, v4_}] := {Polygon[{v1, v2, v3}], Polygon[{v1, v2, v4}], Polygon[{v1, v4, v3}], Polygon[{v4, v2, v3}]}; Show[Graphics3D[ {tetrahedron[{v1, v2, v3, v4}], tetrahedron[{{1, 1, 1}, {1, 2, 3}, {2, 4, 1}, {3, 2, 1}}]}] ]; David Park djmp@earthlink.net http://home.earthlink.net/~djmp/ I wish to be able to plot polyhedra given a table of (xyz) coordinates for vertices. I'd be happy if I was restricted to tetrahedra, but would prefer to be able to deal with general polyhedra. I can always plot the polygons that make up the faces of the polyhedron but this seems a bit tedious, is there a more efficient way than (for example) Show[Graphics3D[{Polygon[{{0,0,0},{1,0,0},{0,1,0}}],Polygon[{{0,0,0},{1, 0,0},{0,0,1}}],Polygon[{{0,0,0},{0,0,1},{0,1,0}}],Polygon[{{0,0,1},{1,0, 0},{0,1,0}}]}]] Which involves putting in the coordinates of each vertex 3 times. === Subject: Re: Absolute value of a symbolic complex expression === Subject: Re: Plotting polyhedra Hi Peter, As I mentioned on the Mathematica Users Forum, the general problem isn't well-defined: that's to say, given an ordered list of vertices, it's not in general possible to deduce what polyhedron this list is meant to specify. The tetrahedron problem *is* well-defined. I don't think there's an inbuilt Mathematica function that does that (though I may be wrong), but it wouldn't be that hard to write your own. On the forum, I've posted a function I've called tetrahedronByVertices that does tetrahedra in this way. Link to the forum page for this post: http://www.mathematica-users.org/webMathematica/wiki/wiki.jsp?pageName=Speci al:Forum_ViewTopic&pid=6035#p6035 === Subject: Re: Magnetic Pendulum Well, Do you really think that Mathgroup is a mailing list for copying homework assignment ??? ??????????????????????????????? yehuda > Does somebody have the magneticpendulum problem solved as a mathematica > notebook, which he can send me? > If not can somebody explain my how i can solve that problem? I have to > simulate a magnetic pendulum in mathematica. > thx a lot === Subject: Re: Magnetic Pendulum Martin, Just start a Mathematica Notebook. Use Sections to organize your work. Perhaps you will make a Statement of Problem section where you will define your equations, parameters and initial conditions. Then make a Solution Section where you will try to solve the equations using NDSolve. Once you get your solutions you can try to plot them. Maybe you will have additional Sections treating specific cases or classes of cases. Maybe you will want to check simplified cases where the solution reduces to an ordinary small oscillation pendulum. You will probably have to use trial and error to get to a useful point. If you have real trouble at some point, say with the differential equations and how to feed them into NDSolve, post the equations and your attempt to this group. There are many people here, not me, who know a lot about differential equations and will probably give you good help. Post the code by converting the cell to InputForm and then copying and pasting into a posting. David Park djmp@earthlink.net http://home.earthlink.net/~djmp/ rom: Martin Koschi [mailto:martin.koschi@gmx.net] Does somebody have the magneticpendulum problem solved as a mathematica notebook, which he can send me? If not can somebody explain my how i can solve that problem? I have to simulate a magnetic pendulum in mathematica. thx a lot === Subject: Re: FullSimplify Hang? FullSimplify does not report progress. There is a time constraint option (also in Simplify), but it applies only to individual transformations, not the entire process. Killing the process leaves the original expression unchanged, so it is all or nothing. If the original expression is too complicated to finish in reasonable time (say a weekend) human intervention is necessary. What kind of intervention? Typically divide and conquer. Some examples: Extract numerator and denominator from fractions, fullsimplify each and recombine. Break up complicated expressions into groups (that has to be done by hand, using InputForm and cut&paste) fullsimplify each group, recombine. Hard when many fraction levels appear. For lists and matrices simplify an item at a time in a loop, and observe which items cause fullsimplify to hang. Separate those for further divide and conquer. Changing target functions can be effective for complex expressions. Changing complexity measure sometimes helps, but effect is random. Do simplify first, then fullsimplify, kill latter if it hangs. All of these gyriations could be avoided by putting a time constraint on the full process, and asking fullsimplify to return the simplest one found so far, with a warning. === Subject: Re: FullSimplify Hang? I wonder if you try to use the TimeConstraint option? It is supposed to do exactly what you need yehuda > I run FullSimplify on expression with LeafCount of 89281. It runs for 80 > hours already , and I have no idea if it ever going to complete. > Is there any way to estimate its progress % ? > I would like also to see this feature in Mathematica. > Sometimes, it is rather annoying to not have an estimated time, esp. > considering that many other software give at least a progress bar. > It is possible it just in some king of dead loop? > I don't think so; I believe the Mathematica kernel is smart enough to > detect this. > It would be nice for Mathematica to have ability to indicate current > progress or possibility to interrupt current simplification and obtain > intermediate result. > []s > -- > Brasil > MSN: wizard_of_yendor@hotmail.com > Orkut: http://www.orkut.com/Profile.aspx?uid=2202360379963855296 === Subject: Re: FullSimplify Hang? > I run FullSimplify on expression with LeafCount of 89281. It runs > for 80 > hours already , and I have no idea if it ever going to complete. > Is there any way to estimate its progress % ? >> I would like also to see this feature in Mathematica. >> Sometimes, it is rather annoying to not have an estimated time, >> esp. >> considering that many other software give at least a progress bar. > It is possible it just in some king of dead loop? >> I don't think so; I believe the Mathematica kernel is smart enough to >> detect this. > It would be nice for Mathematica to have ability to indicate current > progress or possibility to interrupt current simplification and > obtain > intermediate result. >> []s >> -- > I can't even imagine how this could possibly be done. This kind of > estimation is only possible if the process that is being estimated > is in some sense uniform. In this case the past can be a rough > guide to the present. However, FullSimplify or Simplify apply a > number of entirely unrelated transformation in turn; how could the > time taken by any of those tried up to a given time be any guide to > the time that the other ones will take? Even if just only one > transformation is left, it could be the one that is going to take > longer than all the ones that have been tried so far put together. > Actually, the issue of hanging is spurious one, since > FullSimplify could easily take longer than your computer will last > without ever hanging. > What I would like is something else that should not be impossible. > At present we can use TimeConstrained to restrict the time taken by > FullSimplify, but if the simplification fails to be accomplished in > specified time there is no way, as far as I know, to see the best > result obtained so far. One can do that with functions like Nest > etc, but not with FullSimplify. Since, I think, Simplify must at > each moment in time store the simplest answer obtained so far, it > should not be too much to ask that this answer be returned when the > time specified in TimeConstrained is reached. (If this is possible > to do now I would love to hear about it!). > Andrzej Kozlowski Actually, I have found a way to do this! Unfortunately my current approach considerably increases the length of time taken by FullSimplify so much that it is not usable in practice :-( But it is a start ;-) I will illustrate the approach on an example. Suppose we would like to FullSimplify the expression ((1 + Sin[x])*(1 - Cos[x]))/Cos[2*x] I will first show how to obtain all the forms through into which FullSimplify simplifies the given expression. (Actually I have posted this approach a number of times before). Let's start with an empty list In[1]:= ls = {}; Next, we run: In[2]:= FullSimplify[((1 + Sin[x])*(1 - Cos[x]))/Cos[2*x], ComplexityFunction -> ((If[FullSimplify[#1 - ((1 + Sin[x])*(1 - Cos[x]))/Cos[2*x]] == 0, AppendTo[ls, #1]]; LeafCount[#1]) & )] Out[2]= (-(Cos[x] - 1))*Sec[2*x]*(Sin[x] + 1) Let's check how long our list is: In[3]:= Length[ls] Out[3]= 43 However, it includes many repetitions, so we take union and sort it according to LeafCount: In[4]:= ls = Sort[Union[ls], LeafCount[#1] < LeafCount[#2] & ]; In[5]:= Length[ls] Out[5]= 13 Let's look at the three best results: In[6]:= Take[ls, 3] Out[6]= {(-(Cos[x] - 1))*Sec[2*x]*(Sin[x] + 1), (1 - Cos[x])*Sec[2*x]*(Sin[x] + 1), (-(1/2))*Sec[2*x]*(2*Cos[x] - 2*Sin[x] + Sin[2*x] - 2)} No, let's repeat the process using TimeConstrained, to just 0.1 second. In[13]:= ls = {}; In[14]:= TimeConstrained[FullSimplify[((1 + Sin[x])*(1 - Cos[x]))/Cos[2*x], ComplexityFunction -> ((If[FullSimplify[#1 - ((1 + Sin[x])*(1 - Cos[x]))/Cos[2*x]] == 0, AppendTo[ls, #1]]; LeafCount[#1]) & )], 0.1] Out[14]= $Aborted Now there are fewer results: In[15]:= Length[ls] Out[15]= 28 and also fewer distinct results: In[16]:= ls = Sort[Union[ls], LeafCount[#1] < LeafCount[#2] & ]; In[17]:= Length[ls] Out[17]= 9 However, the best three are exactly the same as before. In[18]:= Take[ls, 3] Out[18]= {(-(Cos[x] - 1))*Sec[2*x]*(Sin[x] + 1), (1 - Cos[x])*Sec[2*x]*(Sin[x] + 1), (-(1/2))*Sec[2*x]*(2*Cos[x] - 2*Sin[x] + Sin[2*x] - 2)} Now some remarks. Firstly, we could use Enter Subsession from the Kernel/Evaluation menu instead of TimeConstrained, so that we actually can interrupt and check for the best result so far. The big slowdown in performance is the use of FullSImplify in the code, that is design to return only forms that are equivalent to the one we are simplifying. Without that we shall obtain also lots of partial forms, basically anything to which the ComplexityFunction is applied. Obviously as it stands the code is not practicable since it is going to be very much slower than applying FullSimplify itself. However, it should be easy for WRI to produce something working in a similar way but much more efficient. In fact it may be better to allow all the partial forms into ls and then select from the list only those that are equivalent to the original input. They may also be other improvements that could make this actually practicable. Andrzej Kozlowski === Subject: Re: FullSimplify Hang? >> I run FullSimplify on expression with LeafCount of 89281. It runs >> for 80 >> hours already , and I have no idea if it ever going to complete. >> Is there any way to estimate its progress % ? > I would like also to see this feature in Mathematica. > Sometimes, it is rather annoying to not have an estimated time, esp. > considering that many other software give at least a progress bar. >> It is possible it just in some king of dead loop? > I don't think so; I believe the Mathematica kernel is smart enough to > detect this. >> It would be nice for Mathematica to have ability to indicate current >> progress or possibility to interrupt current simplification and >> obtain >> intermediate result. > []s > -- I can't even imagine how this could possibly be done. This kind of estimation is only possible if the process that is being estimated is in some sense uniform. In this case the past can be a rough guide to the present. However, FullSimplify or Simplify apply a number of entirely unrelated transformation in turn; how could the time taken by any of those tried up to a given time be any guide to the time that the other ones will take? Even if just only one transformation is left, it could be the one that is going to take longer than all the ones that have been tried so far put together. Actually, the issue of hanging is spurious one, since FullSimplify could easily take longer than your computer will last without ever hanging. What I would like is something else that should not be impossible. At present we can use TimeConstrained to restrict the time taken by FullSimplify, but if the simplification fails to be accomplished in specified time there is no way, as far as I know, to see the best result obtained so far. One can do that with functions like Nest etc, but not with FullSimplify. Since, I think, Simplify must at each moment in time store the simplest answer obtained so far, it should not be too much to ask that this answer be returned when the time specified in TimeConstrained is reached. (If this is possible to do now I would love to hear about it!). Andrzej Kozlowski === Subject: Timing? Has anyone else observed anything like the following sequence of Timing results? In[1]:= L = Array[Random[Integer,{-10,10}]&,{10^6,2}]; t = Table[First[Timing[Pick[L,Total@Transpose@Sign@L,-2];]/. Second->100],{100}] Out[2]= { 86., 89., 95.,106.,119.,132.,147.,160.,168.,179., 190.,198.,201.,212.,219.,223.,228.,228.,232.,233., 234.,228.,238.,236.,236.,239.,236.,241.,242.,243., 239.,234.,241.,243.,239.,241.,238.,242.,238.,239., 238.,226.,239.,243.,240.,238.,236.,242.,240.,241., 240.,238.,239.,240.,241.,239.,239.,242.,241.,240., 241.,237.,238.,242.,240.,239.,243.,238.,239.,230., 239.,240.,240.,238.,237.,242.,239.,241.,240.,241., 240.,239.,236.,236.,241.,241.,241.,237.,241.,239., 241.,239.,239.,241.,243.,240.,239.,234.,237.,243.} In[3]:= ListPlot[t,PlotRange->All,Frame->True,Axes->None]; === Subject: Re: Solved:Defining variables in $UserBaseDirectory/init.m >Nonetheless, they did provide a solution. Use >$UserBaseDirectory/Kernel/init.m and not >$UserBaseDirectory/FrontEnd/init.m for adding such variables. Aah... That explains a lot. I paid little attention to the subject line of your post and did not realize you were attempting to use something other than $UserBaseDirectory/Kernel/init.m. If I led you to think I was using something other than $UserBaseDirectory/Kernel/init.m I apologize for any confusion I may of caused. >Perhaps I could find a way to add them to the FrontEnd context, I don't understand why this would be desireable. >certainly helped resolve the problem. You are welcome and I am glad I was able to help even though that looks to have been less effective than it could have been. -- To reply via email subtract one hundred and four === Subject: Re: Re: aggregation of related elements in a list > A surprising discovery is that if we take agg3 and modify LvisitF to be a > vector of False/True instead of 0/1, agg3 won't be linear time anymore. A > list of booleans cannot be a packed array, but it is still an ordinary > Mathematica list, which is basically a fixed size array of pointers, so > theoretically it ought to have constant access time. The problem is that > list elements may have upvalues associated with them, and in principle > after an element of the list has changed the whole structure must be > reevaluated, in case an upvalue associated with another element takes > effect now. Mathematica uses various optimizations to avoid the > reevaluation whenever possible, but it seems that for lists of symbols > (including True/False) there's still some overhead. > Maxim Rytin > m.r@inbox.ru Here's a simple test: In[1]:= $Version Out[1]= 5.2 for Microsoft Windows (June 20, 2005) In[2]:= f = Module[{L = Array[True&, #]}, Do[L[[i + 1]] = !L[[i]], {i, # - 1}]]&; Timing[f[10^4];] Timing[f[2*10^4];] %[[1]]/%%[[1]] Out[3]= {1.828*Second, Null} Out[4]= {7.282*Second, Null} Out[5]= 3.9835886 Clearly the time grows quadratically. If each of the n steps takes O(n) time, a plausible explanation is that it is related to the reevaluation of the whole list on each step. Another similar problem appears only in compiled code: In[6]:= f = Compile[{{n, _Integer}}, Module[{L = Array[0&, 2*n]}, Do[L[[{2*i - 1, 2*i}]] = i, {i, n}]]]; Timing[f[5*10^4];] Timing[f[10^5];] %[[1]]/%%[[1]] Out[7]= {22.093*Second, Null} Out[8]= {86.891*Second, Null} Out[9]= 3.9329652 It is not clear what could be the reason for this (except that assigning values to parts of expressions in combination with Compile is just extremely shoddy, that is; see for example http://forums.wolfram.com/mathgroup/archive/2005/Apr/msg00799.html ). A simple fix is to rewrite the assignment as L[[{2*i - 1, 2*i}]] = {i, i}. Maxim Rytin m.r@inbox.ru === Subject: Re: FixedPoint > Anybody know how to get FixedPoint to reveal how many iterations it > had > to perform before it found the fixed point; i.e. what n was when SameQ > was satisfied and FixedPoint exited. Just add your own own iterator, e.g. like this: Block[{n = 0}, {FixedPoint[(n++; (1/2)*(#1 + 2/#1)) & , 1.], n}] {1.414213562373095, 6} Andrzej Kozlowski === Subject: FixedPoint Anybody know how to get FixedPoint to reveal how many iterations it had to perform before it found the fixed point; i.e. what n was when SameQ was satisfied and FixedPoint exited.