mm-519 ==== Subject: Weird Graphics Behaviour-Mathematica 4.2 Hello everyone, Something really strange happened and maybe someone can shed a light. All of suddent, Mathematica CANNOT display any graphics . Specifically, when I issue a graphics command (i.e. Plot, ListPlot, Graphics primitives), it outputs a blank space and the Window title line keeps flickering the name of the working window. It is not that the graphics are not created i.e. I can take the FullForm of any graphics command and see the internal representation, it is their rendering that is not taking place. Furthermore I can copy the (invisible) graphic into other applications (i.e. MSWord)using Copy&Paste via mouse without any problems. The OpenGL viewer AddOn seems to work perfectly (i.e. the graphics are rendered in the AddOn Window but not in the active notebook window). I am running Mathematica under WindowsXP Home on a Presario follows: In[1]:= $ProductInformation Out[1]= {ProductIDName\\[Rule]Mathematica, ProductKernelName\\[Rule]Mathematica 4.2 Kernel, ProductVersion\\[Rule]4.2 for Microsoft Windows (August 23, 2002), ProductVersionNumber\\[Rule]4.2} BTW Mathematica 5.0 (an old evaluation version came really handy!) graphics under the same system seem to work fine. Short of re-installing Mathematica (my original CD is 4985 miles away) what can I do to relive the old glorious and graphical days? Christos Argyropoulos MD PhD University of Cincinnati, College of Medicine ==== Subject: Re: New Line/CR >> > It sounds as though your shift key might have stuck down. Shift return > means execute, and if you try to execute a text cell you get a beep. Actually, I had the number lock on. Alex ==== Subject: Re: Mathematica 5.0 eps generation > > >Set this to 100% and re-run the notebook before exporting or > >saving. > > This doesn't seem to address the issue when using Mathematica on Mac OS X. \ > Try doing the following with the magnification set at 100%. > I've not tried all the variations on this theme, in particular the ones you mentioned. The problem I encountered involved creating a sequence of large plots (made large using ImageSize), then selecting and saving them as a QuickTime slide show. The QT slide show would show the enlarged plots truncated in a smaller slide show window. Setting magnification back to 100% solved the problem. I think this was in OS X rather than in OS 9; but in any case my primary message is that using magnification other than 100% **may** cause sizing troubles when saving or exporting and should be thought about. ==== Subject: Re: Nested Commutators cheers pratik, this looks interesting. though i am finding it difficult to get hold of documentation and examples for this package. ==== Subject: Re: Nested Commutators reading it now. am i to understand that i should be using ** instead of . to do the noncommutative multiplication? could you please give me a demo of your functions for the above algebra and also showing the simplification of undefined nested commutators. the simplification of nested commutators using the jacobi identities is quite important. ==== Subject: Re: Nested Commutators to steve: thats almost what i want... if this is a standard function, how come it is not listed under a commutator heading in the mathematica book 5 or the Commutator page at mathworld? one small snag though... there appears to be no Jacobi routine for terms such as: comm[X, comm[Y, comm[X, Y]]] -comm[Y, comm[X, comm[Y, X]]] comm[comm[X, comm[Y, X]], Y] comm[Y, [X, [X, Y]]] so mathematica is unable to do simplifications ==== Subject: Re: Nested Commutators a basic implementation of non-commutative algebra has been part of FeynCalc for a while. You can look at the documentation here: http://www.feyncalc.org/FeynCalcBook/Commutator/ http://www.feyncalc.org/FeynCalcBook/DotSimplify/ The implementation is straightforward and not terribly efficient. Feel free to check out the source code. Your examples can be done as follows: < hi there, > > i have searched the archive for theads on nested commutators in > mathematica, but i found no answer to my problem and i was wondering if > anyone had any helpful advise for me. > > i wish to be able to define a commutator[A, B] > http://mathworld.wolfram.com/Commutator.html > between 2 operators. > > for example i would like to be able to define an algebra by presenting > the commutators, such as > [A, B] = B > [A, C] = C > [B, C] = D > (also explicitly defining the rest to be zero) and then be able to ask > mathematica to return the solution when i nest the operators like so > [A, [A, [A, B]]] > which should return B > [A, [B, C]] > should return 0. > > it would also be nice if the Jacobi identities are used in > simplification routines, so that terms such as > [X, [Y, [X, Y]]] > -[Y, [X, [Y, X]]] > [[X, [Y, X]], Y] > are identified as being the same as > [Y, [X, [X, Y]]] > right ordering the output when the commutators cannot be calculated > explicitly. > > apologies if you have seen this question recently... i stupidly asked > it at the end of my last posting where it is surely to be missed. this > question really warrants its own thread. ==== Subject: Re: plot command > plot the derivative as shown below. I get a message below the Plot > request stating > > \Syntax::sntxi: \Incomplete expression; more input is needed.\ Any \ help > would be greatly appreciated. Darrell Bosch > > > > > > > > sol = Log[v]=A9100*Log(s) > > sol2 = Solve[sol,v] > > sol3 = D[sol2,s] > > Plot[Evaluate[sol3],{s,0,100}] > > > > Hi Darrell, Using correct syntax would help greatly! I have not gotten the error message you mentioned in your post but definitely many others. Starting from the first line, we get In[1]:= sol = Log[v] = A9100 Log(s) Set::write : Tag Log in Log[v] is Protected. Out[1]= A9100*Log*s Here you are using the symbol \=\ (simple equal), which is equivalent to the command *Set*, which tries to assign a new value/definition to the built-in command *Log*. So, either you *Unprotect* the *Log* function (very bad idea in this case :-) or most likely you use the *Equal* (double =, that is \==\) to check for equality between LHS and RHS. Of course you still use the simple \=\ to assign the equation to the symbol \sol\. Moreover, as you can see above, Log(s) is translated as Log*s, that is Log TIMES s, surely not what you wanted. Here too, using the correct syntax would help. What you want is Log[s] (square brackets). You may have a look at http://documents.wolfram.com/mathematica/GettingStarted/StartingOut/YourFirs\ tMathematicaCalculations.html Therefore, what is the correct syntax for the first line (assuming that \A9100\ is the symbol A9100 and not a misspelling for A*9100 or whatever else)? In[2]:= sol = Log[v] == A9100*Log[s] Out[2]= Logs[v] == A9100*Log[s] Now the second line gives In[3]:= sol2 = Solve[sol, v] Out[3]= {{v -> s^A9100}} a replacement rule rather than the error message \Solve::eqf : A9100\\Log\\s is not a well-formed equation.\ Now, if you derive directly this replacement rule, you get In[4]:= sol3 = D[sol2, s] Out[4]= {{0 -> A9100*s^(-1 + A9100)}} which is not what you want: LHS and RHS are both derived and since \v\ does not depend explicitly on \s\ its derivative is zero. One of the possible solutions among many variations is In[6]:= sol3 = D[v /. sol2[[1]], s] Out[6]= A9100*s^(-1 + A9100) Finally, the last command yields an error message In[7]:= Plot[Evaluate[sol3], {s, 0, 100}] \\!\\(Plot::\plnr\ : \\\!\\(A9100 \\\\\\\\ s\\^\\(\\(-1\\) + A9100\\)\\) is not a machine-size real number at s = \ \\ 4.166666666666667`*^-6.\\\) telling us that A9100 is not a number, which is true. We can circumvent this \problem\ by assigning a value to A9100 before plotting the \ function: In[7]:= Plot[Evaluate[sol3 /. A9100 -> 1], {s, 0, 100}]; And the magic operates: we get a superb graph (of a straight line in this case :-) /J.M. ==== Subject: Re: Intersection @ Complement David Bailey Garry Helzer Murray Eisenberg I found in Mathematica 5.1 Help exactly what i need: 1) MultiIntersection generalizes Intersection. If an element occurs m times in one list and n times in another, MultiIntersection will list it Min[m, n] times. MultiIntersection[{b,b,a,b,a},{a,a,a,b}] {a,a,b} (* !! *) 2) This defines a version of Complement that does not sort. An element in the first list is dropped if it occurs in one of the other \ lists. The remaining elements are listed with their original multiplicities. UnsortedComplement[x_List,y__List]:=Replace[x,Dispatch[(#\\[RuleDelayed]Sequ\ ence[])&/@Union[y]],1] UnsortedComplement[{a,b,b,b,c,a,e,d,e},{e,b,f},{b,d}] {a,c,a} (* !! *) Complement[{a,b,b,b,c,a,e,d,e},{e,b,f},{b,d}] {a,c} zak ==== Subject: Re: Intersection @ Complement > Some crazy thing Mmca does with > Intersection/Complement: > > s1={1,2,5,7,4,4,1};s2={1,6,3,5,7,7,1,6}; > Intersection[s1,s2] > {1,5,7} (* not {1,1,5,7} ?!*) > Complement[s1,s2] > {2,4} (* not {2,4,4} ?!*) > Complement[s2,s1] > {3,6} (* not {3,6,6,7} ?!*) > > Interestingly, in both cases Mmca Help > says that the result is SORTED list, > while actually it's UNION not SORT that works?! > And note that in the last case 7 is absent at all ?! > Hi Zak, I am afraid that there is nothing crazy at all in Mathematica behavior! Mathematica works just has expected with *set* operators such as intersection or complement. We do not have a specific data type for *sets* built-in Mathematica. So the only way I am aware of to represent a *set* is to use a list (here I might be wrong but the Mathematica gurus in this forum will correct me if needed). So whenever you feed Mathematica with some lists ordered in a specific way and containing repeated elements and then use *set* operations such as intersection or complement on these lists, Mathematica first reorganizes internally these lists as equivalent of *sets*: it orders them in lexicographic order (here too I might be wrong about the most general cases) and keeps only one occurrence of each elements. Then the *set* operation is applied and a list that represents a *set* is returned. For example, first we create two lists In[1]:= lst1 = {1, 2, 5, 7, 4, 4, 1} lst2 = {1, 6, 3, 5, 7, 7, 1, 6} Out[1]= {1, 2, 5, 7, 4, 4, 1} Out[2]= {1, 6, 3, 5, 7, 7, 1, 6} Now we create the \associated\ *sets* In[3]:= s1 = Union[lst1] s2 = Union[lst2] Out[3]= {1, 2, 4, 5, 7} Out[4]= {1, 3, 5, 6, 7} In[5]:= Intersection[s1, s2] Out[5]= {1, 5, 7} In[6]:= Intersection[lst1, lst2] Out[6]= {1, 5, 7} And we can see that both operations yield the same result. /J.M. ==== Subject: Re: Re: Problems with my Hi David, > > > Even Fortran has a LOGICAL data type! Yes it does. And modern versions (> F90) allow users to define their own types in terms of fundamental data types, improving readability & code even more. However, the usual way that this sort of thing is coded in Fortran (usually F77), is as a series of cryptic arguments to subroutines (eg LinPack); logical variables are rarely used, but I'm happy to be contradicted. My point was that while this can be done in Mathematica, a better way might be to use options & logical variables such as PlotJoined->True, PrintOutput->False, Or even ShowWorking->False, Brief or All. Advantages are readability & ease of use since the options can be used in any order & in some cases, omitted entirely. Dave. ==== Subject: Re: position of a pattern in a list lst={{{\abcd\,\cv\},{\z\,\zzbcz\}},{{\v\},{\zbcx\},{\xc\,\bc\ \}}}; In[18]:= Position[lst,a_String/;StringMatchQ[a,___~~\b\~~\c\~~___]] Out[18]= {{1,1,1},{1,2,2},{2,2,1},{2,3,2}} ==== Subject: Re: position of a pattern in a list > *This message was transferred with a trial version of CommuniGate > (tm) Pro* > hi > i want to search for the positions > of the pattern \b\ ~~ \c\ > in the list: > lst = {{{\abcd\, \cv\}, {\z\, \zzbcz\}} > , {{\v\}, {\zbcx\}, {\xc\, \bc\}}} > q = StringCases[#, \b\ ~~ \c\] & /@ # & /@ lst > Out[]={{{{bc}, {}}, {{}, {bc}}}, {{{}}, {{bc}}, {{}, {bc}}}} > Position[q, {\bc\}] > Out[]={{1, 1, 1}, {1, 2, 2}, {2, 2, 1}, {2, 3, 2}} > this is okay. > but suppose i want to use position directly in the same way > i have used StringCases: > Position[#, \b\ ~~ \c\] & /@ # & /@ lst > Out[]={{{}, {}}, {{}, {}, {{2}}}} > or > Position[lst, \b\ ~~ \c\] > Out[]={{2, 3, 2}} > here the Position function could not detect the wanted pattern but > only the last explicit \bc\, i hope you have ideas about this > behaviour. > my second question: can mathematica color \{\ and \}\ of the deep > nested list in a suitable way so the reader can pursue which one is > related to which. if not i think this is a valuable addition in any > future versions of mathematica. > > One possible way could be: DeleteCases[Cases[lst,x_String:>If[StringPosition[x,\bc\] != {},{ Position[lst,x],StringPosition[x,\bc\]}],Infinity],Null] {{{{1,1,1}},{{2,3}}},{{{1,2,2}},{{3,4}}},{{{2,2,1}},{{2,3}}},{{{ 2,3,2}},{{1,2}}}} Andrzej Kozlowski ==== Subject: lists of variables I need to make lists of variables, for example {t1,t2,t3} but have not been able to figure out how to make Mathematica do this. Tried using Array[t,3] which gives {t[1],t[2],t[3]} but then I don't know how to set the t[i]'s in expressions similar to F[t[1]_,t[2]_,t[3]_]:=Cos[t[1]+t[2]-t[3]] Heath ==== Subject: Converting a 3F2 to elementary functions In a fluid-mechanics application I need the 3F2 hypergeometric function (parameter m is a positive integer) g32[m_,x_]:= x^2*HypergeometricPFQ[{1,2*m-1,1},{m+1/2,2},x^2]; For small m this converts (via FunctionExpand and Simplify) to elementary functions: g32[1,x]= ArcSin[x]^2 g32[2,x]= (3*(x*Sqrt[1-x^2]+(-1+2*x^2)*ArcSin[x]))/(4*x*Sqrt[1-x^2]) g32[3,x]= (-5*(x*Sqrt[1-x^2]*(-3-20*x^2+20*x^4)+3* (1+6*x^2-24*x^4+16*x^6)*ArcSin[x]))/(192*x^3*(1-x^2)^(3/2)) g32[4,x]= (7*(x*Sqrt[1-x^2]*(45+180*x^2+1324*x^4-3008*x^6+1504*x^8)+ 15*(-3-10*x^2-80*x^4+480*x^6-640*x^8+256*x^10)*ArcSin[x]))/ (23040*x^5*(1-x^2)^(5/2)) The conversion time grows quickly, however, as m increases: m=1: 0.05 sec, m=2: 0.92 sec, m=3: 22.7 sec, m=4: 35 min so for m=5 I estimate several hours. Question: would there be a faster built-in way? (I would like to go up to m ~ 12) ==== Subject: Re: Transformation rule problem > I'm stuck with a problem concerning transformation rules and was > wondering whether somebody could give me a hint on this. I wouldn't > mind a complete solution either ;-) Here's the problem: > > In a sum like for example > > a^2 b^4 + a^3 b + a^5 + a^5 b > > I'd like to replace every instance of the product (a b) by a different > expression, let's call it d. Thus my result should look like > > d^2 b^2 + a^2 d + a^5 + a^4 d > > This replacement is required to work for arbitrary a and b (especially > when they're functions). I've already tried some simple transformation > rules but they couldn't do the job. Others have shown how to do this using replacement rules. For this type of problem though, I think that PolynomialReduce is the right tool: PolynomialReduce[a^2 b^4 + a^3 b + a^5 + a^5 b, a b - d, {a, b}] // Last Paul -- Paul Abbott Phone: +61 8 6488 2734 School of Physics, M013 Fax: +61 8 6488 1014 The University of Western Australia (CRICOS Provider No 00126G) AUSTRALIA http://physics.uwa.edu.au/~paul http://InternationalMathematicaSymposium.org/IMS2005/ ==== Subject: Re: Transformation rule problem Bob, Oliver, is it OK: rus2=a_^m_*b_^n_:> (d/a/b)^(Min[n,m])*a^m*b^n Sqrt[Sin[(c+(Sin[a]+5)^42 b^35)^2]]/.rus2 Sqrt[Sin[(c + d^35*(5 + Sin[a])^7)^ 2]] Oliver: > This replacement is required to work >for arbitrary a and b >(especially when they're functions). zak ==== Subject: Re: can anyone solve this equation? > Can anyone solve the following equation (for theta_4)? Essentially, you are solving the equation FullSimplify[Solve[a - Cos[t] - Sqrt[R^2 - Sin[t]^2] == x, t]] where x = 2 n rhs/d is a constant multiple of your right-hand side, rhs, t is theta_4, and a = R + 2/(c - 1) + 1. This is, of course, trivial. I expect that Solve struggles with your expression because of the length and/or complexity of rhs. To me, using \\[UnderBracket] makes your input expression unreadable. Only an engineer would work with such expressions! Personally, I like using subscripted expressions in Mathematica. They are not without their difficulties and subtleties -- but are preferable to using \\[UnderBracket]. Paul -- Paul Abbott Phone: +61 8 6488 2734 School of Physics, M013 Fax: +61 8 6488 1014 The University of Western Australia (CRICOS Provider No 00126G) AUSTRALIA http://physics.uwa.edu.au/~paul http://InternationalMathematicaSymposium.org/IMS2005/