A9 These are working for me. If anybody wants to try this modiŽed keymapping http://66.92.149.152/proprietary/com/wri/ proprietary/com/wri/ch05.htmlhttp://public.globalsymmetry.com /proprietary/com/wri/KeyEventTranslations.tr.txtSTH====> These are working for me. If anybody wants to try this modiŽed> keymapping> http://66.92.149.152/proprietary/com/wri/proprietary/com/wri/ ch05.html>http://public.globalsymmetry.com/proprietary/com/ wri/KeyEventTranslations.tr.txt> STHI found a bug in my hack of the KeyEventTranslations.tr Žle which didn¹tmanifest itself in 4.1, but did in 4.2. I had a trailing Œ,¹ which wascausing Mathematica to hang on startup after the chched KeyEventTranslations.m wascreated (second launch with the buggy Žle.) I also discovered that theŽle I was trying to share had been chmod¹ed to 400. I am not sure if thatis a daemon running, or scp which did it. It¹s open now, and I¹ll keep aneye on it.I¹m attaching it as well, just in case.I put it here on my box:~/.Mathematica/SystemFiles/FrontEnd/TextResourcesSTH@@ resource KeyEventTranslations(* ModiŽers can beShift,Control,Command,Option For Macintosh:Command = Command Key,Option = Option Key For X11:Command = Mod1,Option = Mod2 For Windows:Command = Alt,Option = AltNOTE: I Hacked this for my purposes. I Žnd it more natural. Theremay be problems. It comes with all the warranty that GNU software does.*)EventTranslations[{(* Evaluation *) Item[KeyEvent[Enter],EvaluateCells], Item[KeyEvent[KeypadEnter],EvaluateCells], Item[KeyEvent[Return, ModiŽers -> {Shift}],EvaluateCells], Item[KeyEvent[KP_Enter],EvaluateCells], Item[KeyEvent[KeypadEnter, ModiŽers -> {Shift}],EvaluateNextCell], Item[KeyEvent[KP_Enter, ModiŽers -> {Shift}],EvaluateNextCell], Item[KeyEvent[Enter, ModiŽers -> {Shift}],EvaluateNextCell], Item[KeyEvent[Return, ModiŽers -> {Command}], Evaluate[All]], Item[KeyEvent[Return, ModiŽers -> {Option}],SimilarCellBelow], Item[KeyEvent[Escape],ShortNameDelimiter], (* Cursor control *) Item[KeyEvent[Up],MovePreviousLine], Item[KeyEvent[Down],MoveNextLine], Item[KeyEvent[Left],MovePrevious], Item[KeyEvent[Right],MoveNext], Item[KeyEvent[Up, ModiŽers -> {Option}],MovePreviousLine], Item[KeyEvent[Down, ModiŽers -> {Option}],MoveNextLine], Item[KeyEvent[Right, ModiŽers -> {Option}],MoveNextWord], Item[KeyEvent[Left, ModiŽers -> {Option}],MovePreviousWord], Item[KeyEvent[Right, ModiŽers->{Control}],MoveNextWord], Item[KeyEvent[Left, ModiŽers->{Control}],MovePreviousWord], Item[KeyEvent[End],MoveLineEnd], Item[KeyEvent[Home],MoveLineBeginning], (* Selection *) Item[KeyEvent[Right, ModiŽers -> {Shift}],SelectNext], Item[KeyEvent[Left, ModiŽers -> {Shift}],SelectPrevious], Item[KeyEvent[Right, ModiŽers -> {Control, Shift}],SelectNextWord], Item[KeyEvent[Left, ModiŽers -> {Control, Shift}],SelectPreviousWord], Item[KeyEvent[Down, ModiŽers -> {Shift}],SelectNextLine], Item[KeyEvent[Up, ModiŽers -> {Shift}],SelectPreviousLine], Item[KeyEvent[Home, ModiŽers -> {Shift}],SelectLineBeginning], Item[KeyEvent[End, ModiŽers -> {Shift}],SelectLineEnd], Item[KeyEvent[., ModiŽers -> {Control}],ExpandSelection], (* Notebook window control *) Item[KeyEvent[PageUp],ScrollPageUp], Item[KeyEvent[PageDown],ScrollPageDown], Item[KeyEvent[Prior],ScrollPageUp], Item[KeyEvent[Next],ScrollPageDown], Item[KeyEvent[Home, ModiŽers -> {Control}],ScrollNotebookStart], Item[KeyEvent[End, ModiŽers -> {Control}],ScrollNotebookEnd], (* Input *) Item[KeyEvent[Return],Linebreak], Item[KeyEvent[Tab],Tab], Item[KeyEvent[i, ModiŽers -> {Control}],Tab], Item[KeyEvent[Backspace],DeletePrevious], Item[KeyEvent[Delete],DeleteNext], Item[KeyEvent[ForwardDelete],DeleteNext], (* Typesetting input *) Item[KeyEvent[6, ModiŽers -> {Control}],Superscript], Item[KeyEvent[Keypad6, ModiŽers -> {Control}],Superscript], Item[KeyEvent[^, ModiŽers -> {Control}],Superscript], Item[KeyEvent[-, ModiŽers -> {Control}],Subscript], Item[KeyEvent[_, ModiŽers ->{Control}], Subscript], Item[KeyEvent[/, ModiŽers -> {Control}],Fraction], Item[KeyEvent[KP_Divide, ModiŽers -> {Control}],Fraction], Item[KeyEvent[2, ModiŽers -> {Control}],Radical], Item[KeyEvent[Keypad2, ModiŽers -> {Control}],Radical], Item[KeyEvent[@, ModiŽers -> {Control}],Radical], Item[KeyEvent[7, ModiŽers -> {Control}],Above], Item[KeyEvent[&, ModiŽers -> {Control}],Above], Item[KeyEvent[Keypad7, ModiŽers -> {Control}],Above], Item[KeyEvent[=, ModiŽers -> {Control}],Below], Item[KeyEvent[+, ModiŽers -> {Control}],Below], Item[KeyEvent[,, ModiŽers -> {Control}],NewColumn], Item[KeyEvent[Return, ModiŽers -> {Control}],NewRow], Item[KeyEvent[9, ModiŽers -> {Control}],CreateInlineCell], Item[KeyEvent[(, ModiŽers -> {Control}],CreateInlineCell], Item[KeyEvent[Keypad9, ModiŽers -> {Control}],CreateInlineCell], Item[KeyEvent[), ModiŽers -> {Control}],MoveNextCell], Item[KeyEvent[0, ModiŽers -> {Control}],MoveNextCell], Item[KeyEvent[Keypad0, ModiŽers -> {Control}],MoveNextCell], Item[KeyEvent[Left, ModiŽers -> {Control}, CellClass -> BoxFormData],NudgeLeft], Item[KeyEvent[Right, ModiŽers -> {Control}, CellClass -> BoxFormData],NudgeRight], Item[KeyEvent[Down, ModiŽers -> {Control}, CellClass -> BoxFormData],NudgeDown], Item[KeyEvent[Up, ModiŽers -> {Control}, CellClass -> BoxFormData],NudgeUp], Item[KeyEvent[8, ModiŽers -> {Control}],InsertRawExpression], Item[KeyEvent[*, ModiŽers -> {Control}],InsertRawExpression], Item[KeyEvent[Keypad8, ModiŽers -> {Control}],InsertRawExpression], Item[KeyEvent[5, ModiŽers -> {Control}, CellClass -> BoxFormData],Otherscript], Item[KeyEvent[Keypad5, ModiŽers -> {Control}, CellClass -> BoxFormData],Otherscript], Item[KeyEvent[%, ModiŽers -> {Control}, CellClass -> BoxFormData],Otherscript], (* Typesetting motion commands *) Item[KeyEvent[ , ModiŽers -> {Control}],MoveExpressionEnd], Item[KeyEvent[Tab, ModiŽers -> {Shift}, CellClass -> BoxFormData],MovePreviousPlaceHolder], Item[KeyEvent[s, ModiŽers -> {Command, Control}, CellClass -> BoxFormData],MovePreviousExpression], Item[KeyEvent[S, ModiŽers -> {Control, Command, Shift}, CellClass -> BoxFormData],MoveNextExpression], Item[KeyEvent[S, ModiŽers -> {Control, Shift}, CellClass -> BoxFormData],DeleteNextExpression], Item[KeyEvent[s, ModiŽers -> {Control}, CellClass -> BoxFormData],DeletePreviousExpression], Item[KeyEvent[k, ModiŽers -> {Control}], CompleteSelection[True]], (* Miscellaneous menu commands *) Item[KeyEvent[Delete, ModiŽers -> {Control}],Cut], Item[KeyEvent[Insert, ModiŽers -> {Control}],Copy], Item[KeyEvent[Insert, ModiŽers -> {Shift}], Paste[After]], Item[KeyEvent[z, ModiŽers -> {Control}],Undo], Item[KeyEvent[c, ModiŽers -> {Control}],Copy], Item[KeyEvent[x, ModiŽers -> {Control}],Cut], Item[KeyEvent[v, ModiŽers -> {Control}], Paste[After]], Item[KeyEvent[F1],SelectionHelpDialog] (* Unsupported features and examples *)(* Item[KeyEvent[v, ModiŽers -> {Control}],SelectionSpeakSummary], *)(* Item[KeyEvent[v, ModiŽers -> {Control, Shift}],SelectionSpeak] *)}]====>particular, the y-axis label is typically rotated by 90deg so that it>reads up the y-axis. This works Žne on macs and windoze, but under>linux the label runs up the y-axis; however, the letters are rotated>so that they are the same orientation as that for the x-axis.>Printouts of the NB are Žne, but it looks really stupid when using a>video projector to teach or give a talk. I have mentioned this before,>perhaps, but it is also a real problem with Mathematica. I personally>don¹t care why the label looks peculiar, just that it does and that>there is no easy workaround.====>I¹m writing to report what I consider to be a bug. First, I want to>show a simpliŽed example of the problem. Consider the following>expression:>>expr=0.22 + x[0] + (3*(-0.16+ x[1]))/4 + (9*(0.546 + x[2]))/16;>>When simpliŽed I expected to get some real number plus>x[0]+3x[1]/4+9x[2]/16, but instead I get the following:>>Simplify[expr] 0.407125 + x[0] + 0.75 x[1] + 0.5625 x[2]>>As you can see, for some reason Mathematica converted the fractions>3/4 and 9/16 to real machine numbers. I consider this to be a bug.You really are not seeing a loss of precision here. When simplify carries out the indicated multiplication such as 9*.546/16 a machine precision number is returned because on of the arguments only has machine precision. It would be incorrect for Mathematica to return a result with greater precision than the arguements. It would also be incorrect for Mathematica to refuse to preform the required multiplications when simplifying this expression.Or said differently, if you want an exact result from Mathematica *all* of the information you supply Mathematica must also be exact. It is not sensible for Mathematica to do otherwise.====Bill,See my comments below. There is no logical reason to insist part of the expression to be exactwhen another part is inexact. You cannot gain more precision than the leastprecise portion of the expression. Further, there is extra processingoverhead associated with maintaining exact epressions as well as additionalstorage requirements. For a simple expression such as your example theadditional overhead is insigniŽcant. But it increases for every exact termin the expression. It doesn¹t take all that many terms until the overheadassociate with exact computation becomes noticeable.>It seems to me that you are arguing that if you have an expressionconsisting of one term which is very inprecise and another term which isvery precise or exact, then the total expression is only as precise as theleast precise portion of the expression. This is total nonsense. Consideradding the following terms:1.234567890123456`16 + 0.00000000000000001`1consisting of one term with precision 16 and another term with precision 1.By your argument, Mathematica should return an answer with only a singledigit of precision. Of course, Mathematica does no such thing.>Even more troubling (to me, at least) is the>following:> >x[0]+3x[1]/4+9x[2]/16+.4//Simplify> >0.4 + x[0] + 0.75 x[1] + 0.5625 x[2]> >I don¹t want Simplify to change my nice rational numbers to machine>number approximations. If you want exact answers you *must* have *all* terms in the expresssionexact. Simply put either an expression is exact or not. No expression can beexact unless *all* of the terms within it are exact.When did I ever say that I wanted exact answers? In the example above, Iwanted Simplify to do nothing, that is, leave the expression as a sum of aninexact quantity with some exact quantities.In the work where this situation arose, the inexact quantities are typicallyvery small and the exact quantities are large, so that the precision of theoverall expression when extended precision numbers are substituted for thex[i] is typically the same as the precision of the numbers beingsubstituted. For example, suppose x[0] and x[2] are zero, and x[1] is 1`2510^25. Substituting these numbers into the original expression will yield aresult with a precision of 25, whereas substituting these numbers into thesimpliŽed expression will only have a precision of 16. I¹ve worked veryhard to keep the precision of my numbers as high as possible, and I don¹twant Mathematica to arbitrarily turn those very high precision numbers intomuch lower precision numbers.Carl WollPhysics DeptU of Washington====Bill,Let¹s step through the expansion here.9*(0.546+x[2]))/16can be expanded to9*0.546/16 + 9*x[2]/16which becomes.307125 + 9*x[2]/16My question was why the 9/16 gets converted to .5625, as I see no reason todo so. Even more troubling (to me, at least) is the following:x[0]+3x[1]/4+9x[2]/16+.4//Simplify0.4 + x[0] + 0.75 x[1] + 0.5625 x[2]I don¹t want Simplify to change my nice rational numbers to machine numberapproximations.Carl WollPhysics DeptU of Washington >I¹m writing to report what I consider to be a bug. First, I want to>show a simpliŽed example of the problem. Consider the following>expression:> >expr=0.22 + x[0] + (3*(-0.16+ x[1]))/4 + (9*(0.546 + x[2]))/16;> >When simpliŽed I expected to get some real number plus>x[0]+3x[1]/4+9x[2]/16, but instead I get the following:> >Simplify[expr] 0.407125 + x[0] + 0.75 x[1] + 0.5625 x[2]> >As you can see, for some reason Mathematica converted the fractions>3/4 and 9/16 to real machine numbers. I consider this to be a bug. You really are not seeing a loss of precision here. When simplify carriesout the indicated multiplication such as 9*.546/16 a machine precisionnumber is returned because on of the arguments only has machine precision.It would be incorrect for Mathematica to return a result with greaterprecision than the arguements. It would also be incorrect for Mathematica torefuse to preform the required multiplications when simplifying thisexpression. Or said differently, if you want an exact result from Mathematica *all* ofthe information you supply Mathematica must also be exact. It is notsensible for Mathematica to do otherwise.>====No, Euler proved that series divergent in 1737. It¹s the usual theoremused to show that while the primes are sparse, they¹re not as sparse asthe squares (as the sum of THEIR inverses converges).Bobby-----Original Message-----Sal. Oppenheim jr. & Cie. KGaAKoenigsberger Strasse 29D-60487 Frankfurt am MainGERMANYMobile: +49(0)172 6 74 95 77Internet: http://www.oppenheim.de====Timing[Sum[1./Prime[n], {n, 1000000}]]{13.860000000000001*Second, 3.0682190480544405}Bobby-----Original Message-----Sal. Oppenheim jr. & Cie. KGaAKoenigsberger Strasse 29D-60487 Frankfurt am MainGERMANYMobile: +49(0)172 6 74 95 77Internet: http://www.oppenheim.de====That makes about twenty posts this week detailing nothing but problemsthe FrontEnd).I had been really considering it.Bobby-----Original Message-----resulted in a set of animation control buttons appearing in the bottomframe of the window. I clicked on one of these buttons, but nothinghappened. I looke back in the menu and saw M-y as a keyboard shorcut torun an animation. I tried that with no result. I clicked anotherbuttonin graphics control set, and my X windows locked up. This included thekeyboard¹s ability to give me another display by using Ctl+Alt+F1. Iwentto another system and ssh-ed in and found Mathematica had over 50% of myuserresources, and was climbing. The same was true for VM. I have a gig ofphysical RAM. Once I killed Mathematica, my X came back to life.I¹ve had several bad experiences with Mathematica and X. I honestlybelieve therehelpisolate and Žx these. Have others had such problems?STH====> That makes about twenty posts this week detailing nothing but problems> the FrontEnd).> I had been really considering it.> BobbyPlease keep in mind that this was on Mathematica 4.1, I¹ll have 4.2 tomorrow, andwe¹ll see how that goes. This isn¹t really the result I had hoped for byI very much wish WRI would give us a dual boot license. That way, we canuse Mathematica in either environment the current situation dictates as the best. with Windows. I just don¹t do that as a matter of course. I¹ve beenrelated issuse, either because they aren¹t sure if the problem is theirthat second reason one bit. Hey, if it locks up my X, I want to know ifthat happens to others, and I want to identify the source of the problem.What I really would like to gain from all my negative statements issolutions to what I perceive as problems. If not that, then perhaps theperspective which makes me understand that what I see as problems arereally just my unfamiliarity with the product. I also want to get othersplatform. That¹s how open source works.All that being said, if you are in a situation where an X lockup wouldreally do harm to your project, I would say that I cannot claim it won¹thappen to you. OTOH, I am able to break just about any system. I can¹tswear to you that Mathematica won¹t lock up your Windows system. I can say youwill not have as easy a time shelling into it and trying to recover yoursystem without rebooting.STHReply-To: jmt@dxdydz.net====Sorry, I thought I had seen a demonstration, some years ago !> This sum converges, see a math text book !> Dear Colleagues,> I calculated:> Sum[1/Prime[n], {n, 15000}] // N> Result: 2.74716> Now I wonder if this sum will converge or keep on growing, albeit very> slowly.> Matthias Bode> Sal. Oppenheim jr. & Cie. KGaA> Koenigsberger Strasse 29> D-60487 Frankfurt am Main> GERMANY> Mobile: +49(0)172 6 74 95 77> Internet: http://www.oppenheim.de>Reply-To: murray@math.umass.edu====It is well known that the inŽnite series of reciprocals of the primesDIVERGES!See, for example: http://www.utm.edu/research/primes/inŽnity.shtml> Dear Colleagues,> I calculated:> Sum[1/Prime[n], {n, 15000}] // N> Result: 2.74716> Now I wonder if this sum will converge or keep on growing, albeit very> slowly.> Matthias Bode> Sal. Oppenheim jr. & Cie. KGaA> Koenigsberger Strasse 29> D-60487 Frankfurt am Main> GERMANY> Mobile: +49(0)172 6 74 95 77> Internet: http://www.oppenheim.de> --Murray Eisenberg murray@math.umass.eduMathematics & Statistics Dept.Lederle Graduate Research Tower phone 413 549-1020 (H)University of Massachusetts 413 545-2859 (W)710 North Pleasant StreetAmherst, MA 01375Reply-To: jmt@dxdydz.net====This sum converges, see a math text book !> Dear Colleagues,> I calculated:> Sum[1/Prime[n], {n, 15000}] // N> Result: 2.74716> Now I wonder if this sum will converge or keep on growing, albeit very> slowly.> Matthias Bode> Sal. Oppenheim jr. & Cie. KGaA> Koenigsberger Strasse 29> D-60487 Frankfurt am Main> GERMANY> Mobile: +49(0)172 6 74 95 77> Internet: http://www.oppenheim.de> ====The fact that Sum[1/Prime[n], {n, 1,InŽnity}]==InŽnity is a ratherfamous theorem of Euler. It implies that there must be inŽnitely manyprimes (otherwise the sum would be Žnite), and was the beginning of avast area of mathematics, which includes such concepts as Dirichletseries, Riemann¹s zeta function etc.Andrzej KozlowskiYokohama, Japanhttp://www.mimuw.edu.pl/~akoz/http:// platon.c.u-tokyo.ac.jp/andrzej/On Wednesday, October 2, 2002, at 04:31 PM, Matthias.Bode@oppenheim.de > Dear Colleagues, I calculated: Sum[1/Prime[n], {n, 15000}] // N Result: 2.74716 Now I wonder if this sum will converge or keep on growing, albeit very> slowly.> Matthias Bode> Sal. Oppenheim jr. & Cie. KGaA> Koenigsberger Strasse 29> D-60487 Frankfurt am Main> GERMANY> Mobile: +49(0)172 6 74 95 77> Internet: http://www.oppenheim.de====Here¹s a start. If you want the thing to be greater than zero, set itequal to z (which we¹ll assume is greater than zero) and solve forLog[x]:Log[x, a] + Log[a*x, a] == z /. Log[a_*b_] -> Log[a] + Log[b]{f, g} = Log[x] /. Simplify[Solve[%, Log[x]]]Log[a]/Log[x] + Log[a]/(Log[a] + Log[x]) == z{-(((-2 + z + Sqrt[4 + z^2])*Log[a])/(2*z)), ((2 - z + Sqrt[4 + z^2])* Log[a])/(2*z)}Neither solution appears to be extraneous.Now the task is to Žnd the range of these functions over positive z.Take a look at their derivatives:D[f, z] // SimplifyD[g, z] // Simplify((-1 + 2/Sqrt[4 + z^2])* Log[a])/z^2((-1 - 2/Sqrt[4 + z^2])*Log[a])/z^2A little study shows that f¹ and g¹ have their signs opposite to Log[a].Both functions are monotone. The following limits:Outer[Limit[#1, z -> #2] &, {f, g}, {0, InŽnity}]Exp@%{{-(Log[a]/2), -Log[a]}, {InŽnity*Log[a], 0}}{{1/Sqrt[a], 1/a}, {Indeterminate, 1}}show that f varies from -Log[a]/2 to -Log[a] and g varies from 0 toInŽnity if Log[a]>0 and 0 to -InŽnity if Log[a]<0. Exponentiationgives ranges for x: -1/Sqrt[a] to 1/a for f, for instance. But whatdoes all this mean?When a>1, either x>1 or 1/a < x < 1/Sqrt[a].When a<1, either 0, ModeratorReply-To: ====Try this:To the original function, add a function that¹s (a) zero when theimaginary part is larger than some epsilon value you choose, (b) fairlylarge when the imaginary part is 0 or negative, and (c) as smooth aspossible. For instance, something like:f=Max[(1 - x/epsilon)^5, 0]This function has four continuous derivatives in the real components --though not in the complex variable!If it doesn¹t penalize the real root enough, multiply f by a constantbigger than 1 and try again.Bobby Treat-----Original Message-----are interested, the zeros are the roots of the dispersion relation for aplasma interacting with a laser). Sometimes FindRoot picks up one ofthese instead of the one I want.So, I¹d like to tell mathematica to look for a root only in a certainrectangular region of the complex plane. Well, if I could tell it, Œlook for roots with imag. part > something¹, I¹d be happy too.I tried specifying complex values for the start and stop points of aninterval, hoping mathematica would interpret these as the corners of arectangle. No such luck.Any help would be greatly appreciated.I¹d also like to point out that this and other issues about complexroots are not clearly addressed in the built-in help Žles.====> This sum converges, see a math text book !That¹s nonsensehttp://mathworld.wolfram.com/PrimeSums.html Jens> Dear Colleagues,> > I calculated:> > Sum[1/Prime[n], {n, 15000}] // N> > Result: 2.74716>> Now I wonder if this sum will converge or keep on growing, albeit very> slowly.> > Matthias Bode> Sal. Oppenheim jr. & Cie. KGaA> Koenigsberger Strasse 29> D-60487 Frankfurt am Main> GERMANY> Mobile: +49(0)172 6 74 95 77> Internet: http://www.oppenheim.de> >====I have updated my package Biokmod. It can be downloaded from:http://web.usal.es/~guillerm/biokmod.htmI developped this package thinking in biokinetic application andinternal dosimetry, but it can be also applied for other kind ofproblems envolving System of ODE with many variables.I will appreciate any comentsGuillermo Sanchezhttp://web.usal.es/~guillerm====I use BinaryImport to read a Žle as follows:BinaryImport[Žle,{Byte..}] then I use Partition to rebuild the data of dimensions 252 x 253 x 255....This works but it takes about half an hour to read the Žle....it¹s a 16MByte Žle.....any way to improve this?thanks....jerry blimbaumReply-To: kuska@informatik.uni-leipzig.de====BinaryImport[] is complet unusable for this task.I tryed the same with similar data sets and runout of kernel memory (with 1.5 GByte RAM) & 3GB swap).The WRI support respondet, thatBinaryImport[] isnot for reading *large* binary data.You can have the beta version of MathGL3d 3.1 thathas an extra C-Function for that task.Since it also include excelent volume rendering functionsand a native format for reading and writing compressedvolume data Žles you should use MathGL3d 3.1b.Contact me direct if you wish tobeta test the newversion. Jens> I use BinaryImport to read a Žle as follows:> BinaryImport[Žle,{Byte..}]> then I use Partition to rebuild the data of dimensions 252 x 253 x 255....> This works but it takes about half an hour to read the Žle....it¹s a 16> MByte Žle.....any way to improve this?> thanks....jerry blimbaum====Does any one know of a way to produce Phase PlaneDiagrams in mathematica? I need to draw a couple of direction Želd andanalyse the stability of critical points for mysystems of equations . Ajadi__________________________________________________Do You Yahoo!?Everything you¹ll ever need on one web pagehttp://uk.my.yahoo.comReply-To: kuska@informatik.uni-leipzig.de====if you don¹t like PlotField[] you shouldtry to get a copy of the bookVisual DSolvehttp://store.wolfram.com/view/book/D0706.strand the book package. Jens> Does any one know of a way to produce Phase Plane> Diagrams in mathematica?> I need to draw a couple of direction Želd and> analyse the stability of critical points for my> systems of equations .> Ajadi> __________________________________________________> Do You Yahoo!?> Everything you¹ll ever need on one web page> http://uk.my.yahoo.com====Please ignore a similar question I just posted about BinaryImport...I forgotan hour to import 16 MByte Žle, whereas this technique took less then 5seconds...special thanks to Mariusz...jerry blimbaum NSWC panama city, ž-----Original Message-----Mariusz JankowskiUniversity of Southern Mainemjkcc@usm.maine.edu207-780-5580> The question:> What is the fastest way to read binary Žles in Mathematica 4.0 ?> I think the fastest is with ReadList (indeed ReadSounFile that use it,seems> to be better than BinaryImport), but when i use this command...> data = ReadList[ŽlePath, Byte]> ....it doesn¹t read whole Žle; can somebody tell me the reason? Raf. P.S.:> I made some simple tests (@ 16 bit): << Experimental`> data = BinaryImport[ŽleRawPath, Table[Integer16, {4000}],> ByteOrdering -> -1]; => 10 seconds data = ReadListBinary[ŽleRawPath, SignedInt16, ByteOrder - LeastSigniŽcantByteFirst]; = > 26 seconds << Miscellaneous`Audio`> data = ReadSoundŽle[ŽleWavPath] => 1.54 seconds====I came across this, and thought I would share. This may be OBE if the fontselection is better in 4.2. I¹ll that installed by this time tomorrow...Ihope.http://cgm.cs.mcgill.ca/~luc/math.htmlI started reading through this list, and had visions of recursivelydownloading the entire internet looking for the font¹s I really need. Anybody know what fonts I should have installed on my SuSE box to satisfyMathematica¹s default expectations?STH====In: DSolve[y*D[u[x, y],x] == x*D[u[x, y],y], u[x,y], {x, y}]Out: {{u[x, y] -> C[1][(1/2)*(x^2 + y^2)]}}Square brackets are used as grouping symbols in the result!?? :^OSomebody say it isn¹t so.---Selwyn Hollis====It isn¹t so. C[1] is an arbitrary (smooth) function. After all, whatyou have got is a partial differential equation. For example, you cantake C[1] to be Sin:In[1]:=v[x_, y_] = u[x, y] /. DSolve[y*D[u[x, y], x] == x*D[u[x, y], y], u[x, y], {x, y}] /. C[1] -> SinOut[1]={Sin[(1/2)*(x^2 + y^2)]}In[2]:=y*D[v[x, y], x] == x*D[v[x, y], y]Out[2]=TrueAndrzej KozlowskiYokohama, Japanhttp://www.mimuw.edu.pl/~akoz/http:// platon.c.u-tokyo.ac.jp/andrzej/ In: DSolve[y*D[u[x, y],x] == x*D[u[x, y],y], u[x,y], {x, y}] Out: {{u[x, y] -> C[1][(1/2)*(x^2 + y^2)]}} Square brackets are used as grouping symbols in the result!?? :^O Somebody say it isn¹t so. ---> Selwyn HollisReply-To: ====My OPINION is that extra graphics RAM is useful primarily for 3D games(which are themselves completely useless). A static 3D plot doesn¹tneed that much graphics RAM -- it¹s the rapid transformation of it, tosimulate live action, that may require it.On the other hand, if the manufacturer¹s limits are that low forgraphics RAM, I would get another manufacturer. Who knows what otherlimitations and compromises they¹ll saddle you with? I would be verysuspicious.Bobby-----Original Message-----Is 32 MB adequate not just now, but likely to be adequate as well forthe near future (say, a 3- to 5-year equipment lifetime)?--Murray Eisenberg murray@math.umass.eduMathematics & Statistics Dept.Lederle Graduate Research Tower phone 413 549-1020 (H)University of Massachusetts 413 545-2859 (W)710 North Pleasant StreetAmherst, MA 01375Reply-To: kuska@informatik.uni-leipzig.de====> My OPINION is that extra graphics RAM is useful primarily for 3D gamesOr complex 3d scientiŽc visualizations ? Textures ?Try to render the skull from a 256^3 CT scan or the output of a 3dplasmasimulation and you will know *what* can be done with extra 3d RAM> (which are themselves completely useless).The major effect is, that 3d Games make 3d graphics hardware lessexpensive.Five years ago a SGI cost 20-30 000 $ and today you can have more 3dpowerfor 400 $ Jens> A static 3D plot doesn¹t> need that much graphics RAM -- it¹s the rapid transformation of it, to> simulate live action, that may require it.> On the other hand, if the manufacturer¹s limits are that low for> graphics RAM, I would get another manufacturer. Who knows what other> limitations and compromises they¹ll saddle you with? I would be very> suspicious.> Bobby> -----Original Message-----> We are about to order new PCs for a university student lab in which> Mathematica will be installed. Of course they will be using 2D and 3D> graphics -- plots of surfaces, e.g. Sooner or later students will want> to rotate such plots, too.> An unresolved issue is how much graphics RAM to get. On existing> machines we typically have 64MB. But for the PCs we are looking at,> manufacturer¹s limits on graphics RAM, rather than cost, seems to limit> us to 32 MB.> Is 32 MB adequate not just now, but likely to be adequate as well for> the near future (say, a 3- to 5-year equipment lifetime)?> --> 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> Amherst, MA 01375====Greetings MathGroup,My name is Steve Earth, and I am a new subscriber to this list and also anew user of Mathematica; so please forgive this rather simple question...I would like to enter the quartic x^4 + x^3 + x^2 + x + 1 into Mathematicaand have it be able to tell me that it factors into(x^2 + GoldenRatio x + 1) ( x^2 - 1/GoldenRatio x + 1)What instructions do I need to execute to achieve this output?-Steve EarthHarker Schoolhttp://www.harker.org/Reply-To: kuska@informatik.uni-leipzig.de====In[]:=Factor[x^4 + x^3 + x^2 + x + 1, Extension -> {GoldenRatio,1/GoldenRatio}]Out[]=-((-3 - 2*x + Sqrt[5]*x + GoldenRatio*x - 3*x^2)* (3 + x + Sqrt[5]*x + GoldenRatio*x + 3*x^2))/9 Jens> Greetings MathGroup,> My name is Steve Earth, and I am a new subscriber to this list and also a> new user of Mathematica; so please forgive this rather simple question...> I would like to enter the quartic x^4 + x^3 + x^2 + x + 1 into Mathematica> and have it be able to tell me that it factors into> (x^2 + GoldenRatio x + 1) ( x^2 - 1/GoldenRatio x + 1)> What instructions do I need to execute to achieve this output?> -Steve Earth> Harker School> http://www.harker.org/====> The last part of my message you are quoting was completely wrong, as> was pointed out by Allan Hayes. Mathematica does not track precision of> machine arithmetic computations. In order for Mathematica to give> reliable information about the precision of a computation you have to> explicitly set the precision of all the numerical quantities.> > Your own example at the bottom simply shows you have not understood the> evaluation mechanism of Mathematica. Just opposite, thanks to you and other participants, I completely> understood it. SetAccuracy just takes anything and calls it accurate.> This behavior is useless if not stupid.I am not sure I understand what you are referring to asuselessif not stupid.The main purpose of SetAccuracy is to allow people who have donetheir own error analysis to specify the numerical error in aninput or in a result. It is often possible through carefulnumerical analysis, for example, to come up with a better errorestimate than can be given by generic rules for propogation of error.Another common use of SetAccuracy is for converting machine numbersor exact numbers into variable-precision numbers in situations whenit is desired that a calculation be done using variable-precisionarithmetic.Is there some aspect of this that you think isuseless if not stupid,or was that remark referring to something else?Dave WithoffWolfram Research====> The more I play with the example the more depressing it gets. Start> with žoating point numbers but explicitely arbitrary-precision ones.> In[1]:=> a=77617.00000000000000000000000000000;> b=33095.00000000000000000000000000000;> In[3]:=> !(333.7500000000000000000000000000000 b^6 + a^2 ((11 a^2> b^2 - > b^6 - 121 b^4 - 2)) + 5.500000000000000000000000000000 b^8 +> a/(2> b))> Out[3]=> !((-4.78339168666055402578083604864320577443814`26.6715*^32)) > In[4]:=> Accuracy[%]> Out[4]=> -6> Due to the manual section 3.1.6:>When you do calculations with arbitrary-precision numbers, as> discussed in the previous section, Mathematica always keeps track of> the precision of your results, and gives only those digits which are> known to be correct, given the precision of your input. When you do> calculations with machine-precision numbers, however, Mathematica> always gives you a machine?precision result, whether or not all the> digits in the result can, in fact, be determined to be correct on the> basis of your input. > Because I started with arbitrary-precision numbers Mathematica should display> only those digits that are correct, that is none.An accuracy of -6 means that the least signiŽcant correct digit is 6digits to the left of the decimal point. The result Out[3] in theexample above has 26 signiŽcant digits to the left of that (the mostsigiŽcant digit is 26+6=32 digits to the left of the decimal point),so there are 26 correct digits to display.Was there some other result you were referring to as a result inwhich the number of correct digits isnone?Dave WithoffWolfram Research====> I came across this, and thought I would share. This may be OBE if the font > selection is better in 4.2. I¹ll that installed by this time tomorrow...I > hope.> http://cgm.cs.mcgill.ca/~luc/math.html> I started reading through this list, and had visions of recursively > downloading the entire internet looking for the font¹s I really need. > Anybody know what fonts I should have installed on my SuSE box to satisfy > Mathematica¹s default expectations?The contents of the page at this URL are interesting, but probably notrelevant for your purposes.The only fonts which are absolutely needed by the front end are the fontsthat supply the special glyphs for mathematical notation, groupingcharacters, Greek letters, etc. These fonts were developed by WolframResearch and are installed as part of the Mathematica installation. There are two generations of these fonts. The Žrst generation wasintroduced in Mathematica 3.0 in the fall of 1996 and were used throughthe release of Mathematica 4.1. There were Žve families known as Math1 -Math5. Each familiy had four variants: a proportionaly-spaced mediumface, a monospaced medium, a proportional bold, and a monospaced bold. The second generation is used by Mathematica 4.2. There are sevenfamilies named Mathematica1 - Mathematica7.Aside from the math fonts, the front end should be able to functionproperly provided that you have a font that supports the encoding for yourchosen locale. The style sheets bundled with the front end use onlyTimes, Helvetica, and Courier. Should these fonts not be available onyour system, the front end has some substitution rules. For example, the Windows front end knows to use the fonts Times New Roman,Arial, and Courier New. The X Window System ships with bitmap versions ofTimes, Helvetica, and Courier as well as an outline of Courier. If one ofthese fonts must be drawn at a size for which there are no bitmaps,outline fonts provided with Mathematica are used. Helvetica is aliased toSwiss721, and Times is aliased to Utopia through a fonts.alias Žle in theMathematica fonts directory.Under MacOS and Windows, you should be albe to use whatever fonts areavailable on your system. Under X, things are a little more complicated. The front end can display whatever fonts are made available to your Xserver, but it can generate PostScript only for those fonts where an AdobeFont Metric (AFM) Žle is available. If you wish to display or print thePostScript, you must also make the Type 1 font Žle available to therendering device.Note also that the X front end has an adjustable setting for the amount ofmemory to reserve for storing font data. If your system has a largenumber of fonts, you may need to increase this setting per this FAQ page:http://support.wolfram.com/mathematica/systems/linux/ interface/fonterrors.html--User Interface Programmer paulh@wolfram.comWolfram Research, Inc.====> I came across this, and thought I would share. This may be OBE if the> font> selection is better in 4.2. I¹ll that installed by this time> tomorrow...I hope.> http://cgm.cs.mcgill.ca/~luc/math.html> I started reading through this list, and had visions of recursively> downloading the entire internet looking for the font¹s I really need.> Anybody know what fonts I should have installed on my SuSE box to satisfy> Mathematica¹s default expectations?> The contents of the page at this URL are interesting, but probably not> relevant for your purposes.That¹s kind¹o¹ what I thought.[snip - history lesson - thanks]> The second generation is used by Mathematica 4.2. There are seven> families named Mathematica1 - Mathematica7.Where is the documentation for installing these?This is dated:http://support.wolfram.com/mathematica/systems/linux/ interface/fonterrors.htmlI grabbed these off the net:http://support.wolfram.com/mathematica/systems/linux/ general/latestfonts.htmlhttp://support.wolfram.com/ mathematica/systems/linux/general/MathBDF_42.tar.gzhttp:// support.wolfram.com/mathematica/systems/linux/general/MathPCF _42.tar.gzhttp://support.wolfram.com/mathematica/systems/ linux/general/MathT1_42.tar.gz> su -******# cd /usr/X11/lib/X11/fonts/# mkdir -p local/mma# cd local/mma# tar xvfz /download/com/wri/MathBDF_42.tar.gz# tar xvfz /download/com/wri/MathPCF_42.tar.gz# tar xvfz /download/com/wri/MathT1_42.tar.gz# xemacs /etc/X11/XF86ConŽg ....# grep FontPath /etc/X11/XF86ConŽg FontPath /usr/X11R6/lib/X11/fonts/100dpi:unscaled FontPath /usr/X11R6/lib/X11/fonts/75dpi:unscaled FontPath /usr/X11R6/lib/X11/fonts/CID FontPath /usr/X11R6/lib/X11/fonts/Speedo FontPath /usr/X11R6/lib/X11/fonts/Type1 FontPath /usr/X11R6/lib/X11/fonts/URW FontPath /usr/X11R6/lib/X11/fonts/kwintv:unscaled FontPath /usr/X11R6/lib/X11/fonts/latin2/Type1 FontPath /usr/X11R6/lib/X11/fonts/misc:unscaled FontPath /usr/X11R6/lib/X11/fonts/misc/sgi:unscaled FontPath /usr/X11R6/lib/X11/fonts/truetype FontPath /usr/X11R6/lib/X11/fonts/uni:unscaled FontPath /usr/X11R6/lib/X11/fonts/local/mma/BDF FontPath /usr/X11R6/lib/X11/fonts/local/mma/PCF FontPath /usr/X11R6/lib/X11/fonts/local/mma/T1# SuSEconŽg....# init 3 [assuming you are already at a TTY console]# init 5> Aside from the math fonts, the front end should be able to function> properly provided that you have a font that supports the encoding for your> chosen locale. The style sheets bundled with the front end use only> Times, Helvetica, and Courier. Should these fonts not be available on> your system, the front end has some substitution rules.> For example, the Windows front end knows to use the fonts Times New Roman,> Arial, and Courier New. The X Window System ships with bitmap versions of> Times, Helvetica, and Courier as well as an outline of Courier. If one of> these fonts must be drawn at a size for which there are no bitmaps,> outline fonts provided with Mathematica are used. Helvetica is aliased to> Swiss721, and Times is aliased to Utopia through a fonts.alias Žle in the> Mathematica fonts directory.This is what I Žnd anoying. Every time Mathematica does one of these substitutions,it beeps. This is what I¹m calling a font fault. It¹s like the boy whocried wolf. I start ignoring beeps. It also bothers me that I am notseeing what the author had intended.I *believe* it is the author of the notebook or help document who determineswhat fonts should be used. This is a point of confusion. When I opened ahelp page, and didn¹t like the size of the fonts, I tried to adjust themwithout the desired result. I now believe the proper remedy is to usemagniŽcation, not a font adjustment.I have far fewer chirps (beeps) in 4.2, but I do get them when changing themagniŽcation. > Under MacOS and Windows, you should be albe to use whatever fonts are> available on your system. Under X, things are a little more complicated.> The front end can display whatever fonts are made available to your X> server, but it can generate PostScript only for those fonts where an Adobe> Font Metric (AFM) Žle is available. If you wish to display or print the> PostScript, you must also make the Type 1 font Žle available to the> rendering device.This is for another day. I believe I have done this in years gone by, but,for now, I just want to get the optimal behavior form the crt.[snip]Here¹s my question in a nutshell. When I do xlsfonts, what should be listedin order to run Mathematica 4.2 and not experiece font faults generated by contentprovided on the CD?Please note that I *just* Žnished installing the fonts off the web, so I¹mnot sure what, if any problems still remain. I suspect the helveticafaults will still occur.STH.====Bobby,One point:>.... bigžoats ... [are] the result of using N[expr,k] orSetAccuracy[expr,k] where k is bigger than machine precision. If k <=> machine > precision, the result is a machine precision number.We get bigžoats with k<=machine precision with SetAccuracy andSetPrecision but not with N:Example a=SetPrecision[2.3,5] 2.3000 Precision[a] 5. Precision[a^2000] 1.69897Also, of course, when more than machine precision signiŽcant digits aregiven a=1.01234567891234500; Precision[a] 17.301Allan---------------------Allan HayesMathematica Training and ConsultingLeicester UKwww.haystack.demon.co.ukhay@haystack.demon.co.ukVoice: +44 (0)116 271 4198Reply-To: ====Please allow me to summarize what I¹ve learned in the recent discussion,and retract my claim that Accuracy, Precision, and SetAccuracy areuseless.Numbers come in three varieties - machine precision, InŽnite precision,andbignum orbigžoat. Bignums and bigžoats (synonymous?) aren¹tcalled that in the Help Browser, but they¹re the result of usingN[expr,k] or SetAccuracy[expr,k] where k is bigger than machineprecision. If k <= machine precision, the result is a machine precisionnumber, even if you know the expression isn¹t that precise.If, when you use N or SetAccuracy as described above, the expressioncontains undeŽned symbols, you get an expression with all its numericsreplaced by bignums of the indicated precision. When the symbols aredeŽned later, if ANY of them are machine precision, the expression iscomputed with machine arithmetic - with the side-effect thatcoefŽcients that originally were InŽnite-precision are now onlymachine precision. That is, x^2 might have becomex^2.0000000000000000000000000000000000 but later became x^2., forinstance.If all the symbols have been set tobignum or InŽnite precisionvalues, the computation will be done taking precision into account, andthe result has a Precision or Accuracy that makes sense. In all othercases, Precision returns InŽnity for entirely InŽnite-precisionexpressions and 16 for everything else.When one of the experts sayssigniŽcance arithmetic that¹s what theymean - using SetAccuracy or N to give things more than 16 digits,leaving no machine precision numbers anywhere in the expression, andusing Accuracy or Precision, which ARE meaningful in that case, to judgethe result. (It¹s meaningful if all your inputs really have more than16 digits of precision, that is.)You can¹t usesigniŽcance arithmetic to determine how much precisiona result has if your inputs have 16 or 15 or 2 digits of precision. Inthe example we¹ve been looking at, you can give the inputs MORE accuracythan you really believe they have, and still get back 0 digits fromPrecision at the end, so there are clearly no trustworthy digits whenyou use the original inputs either. If an expression is on the razor¹sedge, and has lost only a few digits of precision, that wouldn¹t work sowell.Oddly enough,signiŽcance arithmetic in the Browser doesn¹t take youto any of that. Instead, it takes you to Interval arithmetic, a moresophisticated method, which may give a more accurate gauge of how muchprecision you really have, and WILL deal with machine precision numbersand numbers with even less precision. It does a very good job on theexample. However, it isn¹t very suitable for Complex numbers,matrices, etc. NSolve and NIntegrate probably can¹t handle it, either.Daniel Lichtblau promises that all this will be clearer in the nextrelease.DrBob====I¹m a newbie and, of course, the Žrst thing I want to do is apparentlyone of the most complicated...I have an expression that looks like this:A + B/C + D*Sqrt[E]/C = 0A,B,C,D, & E are all polynomials in xI want it to look like this(D^2)*E = (A*C + B)^2At that point, I¹ll have polynomials in x on both sides. Finally, Iwant the equation to be written out with terms grouped by powers of x,but I think I can do that part :)I¹ll be very grateful to anyone who can give me some pointers. Or, atleast point me to some tutorial in the Mathematica documentation. I¹vebeen looking over the documentation and I found Appendix A.5 in TheMathematica Book, but that doesn¹t help me. I _need_ some examples. Idid Žnd a couple of well-written posts in this newsgroup, but not quiteclose enough to what I want.Troy.=-=-=-=-=-=-=-=-=-=FYI, here¹s the expression I¹m working with.denom = Sqrt[(B^2 - r^2)^2 + 4*(r^2)*(b^2)]cnu = (2*b^2 - B^2 + r^2)/denomsnu = -2*b*Sqrt[B^2 - b^2]/denomsif = 2*r*b/denomcif = (r^2 - B^2)/denompdr = -Cos[ds]*Sin[q]*(snu*cif + cnu*sif) - Sin[ds]*(cnu*cif - snu*sif)0 == -(B^2 - b^2)*V^2/(r^2) + (((B*V)^2)/( r^2) - 2*w*b*V*Cos[q]*Cos[ds] + (w* r)^2 - (w*r*pdr)^2)*(Cos[qr])^2Although I said it¹s a polynomial in x, it¹s really a polynomial inbthat I¹m after.====Troy,True, interactive manipulation can be difŽcult.However, here is one way to do what you want.We have to do the same thing to both sides of the equation. (# - D*Sqrt[K]/C)&/@(A+B/C+D*Sqrt[K]/C[Equal]0 A + B/C == -((D*Sqrt[K])/C) Together/@% (B + A*C)/C == -((D*Sqrt[K])/C) #C&/@% B + A*C == (-D)*Sqrt[K] #^2&/@% (B + A*C)^2 == D^2*KNOTES.Here is how #C&/@ (lhs ==rhs) works:#C&/@ (lhs ==rhs) --> #C&[lhs]==#C&[rhs] --> lhs C == rhs C --> ... f/@( expr) is special for for Map[f, expr]expr& is special for Function[expr]Please look up Map and Function in the Help Browser.--Allan---------------------Allan HayesMathematica Training and ConsultingLeicester UKwww.haystack.demon.co.ukhay@haystack.demon.co.ukVoice: +44 (0)116 271 4198> I¹m a newbie and, of course, the Žrst thing I want to do is apparently> one of the most complicated... I have an expression that looks like this: A + B/C + D*Sqrt[E]/C = 0 A,B,C,D, & E are all polynomials in x> I want it to look like this (D^2)*E = (A*C + B)^2 At that point, I¹ll have polynomials in x on both sides. Finally, I> want the equation to be written out with terms grouped by powers of x,> but I think I can do that part :) I¹ll be very grateful to anyone who can give me some pointers. Or, at> least point me to some tutorial in the Mathematica documentation. I¹ve> been looking over the documentation and I found Appendix A.5 in The> Mathematica Book, but that doesn¹t help me. I _need_ some examples. I> did Žnd a couple of well-written posts in this newsgroup, but not quite> close enough to what I want.> Troy. =-=-=-=-=-=-=-=-=-= FYI, here¹s the expression I¹m working with.> denom = Sqrt[(B^2 - r^2)^2 + 4*(r^2)*(b^2)]> cnu = (2*b^2 - B^2 + r^2)/denom> snu = -2*b*Sqrt[B^2 - b^2]/denom> sif = 2*r*b/denom> cif = (r^2 - B^2)/denom pdr = -Cos[ds]*Sin[q]*(snu*cif +> cnu*sif) - Sin[ds]*(cnu*cif - snu*sif) 0 == -(B^2 - b^2)*V^2/(r^2) + (((B*V)^2)/(> r^2) - 2*w*b*V*Cos[q]*Cos[ds] + (w*> r)^2 - (w*r*pdr)^2)*(Cos[qr])^2 Although I said it¹s a polynomial in x, it¹s really a polynomial inb> that I¹m after.>====I¹m only a little embarassed for not having realized what was happening. (Perhaps I should have slept on it.)Surely I¹m not alone in thinking this symbolism is highly nonintuitive.But of course, for it to be otherwise would require another protectedsymbol...---Selwyn>>In: DSolve[y*D[u[x, y],x] == x*D[u[x, y],y], u[x,y], {x, y}]>Out: {{u[x, y] -> C[1][(1/2)*(x^2 + y^2)]}}>Square brackets are used as grouping symbols in the result!?? :^O>Somebody say it isn¹t so. >It isn¹t so> The square bracket is not delineating a factor it is enclosing the argument > to an arbitrary function named C[1]. While the function is dependent on both > x and y the dependence only occurs in the combination (x^2+y^2).> Bob Hanlon>Reply-To: ====It isn¹t so. The solution is an arbitrary function of (1/2)*(x^2 +y^2)]}}.Bobby-----Original Message-----====Does anyone know what happened to the < Does anyone know what happened to the < in Mathematica 4.x? In some version I know I used it, but it seems to> have gone away. It allowed for real time manipulation of 3D graphics.> Ray Gittings====> The more I play with the example the more> depressing it gets. Start> with žoating point numbers but explicitly> arbitrary-precision ones.> In[1]:=> a=77617.00000000000000000000000000000;> b=33095.00000000000000000000000000000;> In[3]:=> !(333.7500000000000000000000000000000 b^6 +> a^2 ((11 a^2> b^2 - > b^6 - 121 b^4 - 2)) +> 5.500000000000000000000000000000 b^8 +> a/(2> b))> Out[3]=> !((-4.78339168666055402578083604864320577443814`26.6715*^32)) > In[4]:=> Accuracy[%]> Out[4]=> -6> Due to the manual section 3.1.6:>When you do calculations with arbitrary-precision> numbers, as> discussed in the previous section, Mathematica> always keeps track of> the precision of your results, and gives only> those digits which are> known to be correct, given the precision of your> input. When you do> calculations with machine-precision numbers,> however, Mathematica> always gives you a machine[CapitalEth]precision result,> whether or not all the> digits in the result can, in fact, be determined> to be correct on the> basis of your input. > Because I started with arbitrary-precision numbers> Mathematica should display> only those digits that are correct, that is none.> No, 26 digits are correctHere is the number:-0.8273960599468213681Here is the same number computed by Mathematica with 26correct digits:-4.78339168666055402578083604864320577443814[Times]10^ 32It looks like I have been using some wrong deŽnitionofcorrect.:-)You just proved that Precision is useless as a measurehow good your numerical result is. > (check Precision instead> of Accuracy to see> this).> You appear to be showing output in InputForm. If you> use OutputForm or> StandardForm only 26 digits will be shown.> 32> Out[3]= -4.7833916866605540257808360 10> InputForm is showing more because it exposesbad> digits as well as> good ones.> To relax a bit, set a new input cell to> StandardForm and type> 77617.000000000000000000000000000000000> Convert it to InputForm. You get> 77616.999999999999999999999999999999999999999999952771` 37.9031> Convert back to StandardForm> 77616.99999999999999999999999999999999999999999976637`37.9031 > Again to InputForm> 77616.99999999999999999999999999999999999999999963735`37.9031 > Back to StandardForm> 77616.99999999999999999999999999999999999999999951376`37.9031 > See what you can get if you have enough patience> or a small program.> PK> Agreed, it¹s not very pretty. I am uncertain as to> whether this> indicates a bug in StandardForm or elsewhere in the> underlying numerics> code, and will defer to our numerics experts on that> issue. My guess is> it is a bug if only because it violates the spirit> of IEEE arithmetic> wherein žoats that have integer values should be> representable as such> (or something to that effect). I will point out,> however, that the two> numbers in question are equal to the speciŽed> precision. Also it> appears to be improved in our development kernel.> Daniel Lichtblau> Wolfram Research__________________________________________________Do you Yahoo!?http://faith.yahoo.com====>Yes, there seems to be a lot of people who have a visceral hatred for>Microsoft and Windows. They are even willing toshed blood to avoid>Windows. But why? Windows works and you don¹t have to become a systems>programmer.>>Furthermore, I think that Steven Wolfram uses some version of Windows.>So guess which system Mathematica will be best tuned up for?If it is true Wolfram uses Mathematica on a Windows based machine my experience is it doesn¹t translate to Mathematica running better on Windows. I use Mathematica on WindowsNT and on a Mac (currently Mac OS X). I have found Mathematica to be more stable on a Mac than on Windows. On more than one occassion I¹ve seen errors I made Mathematica code to crash the entire machine under WindowsNT. I¹ve never had this happen running things on a Mac.====>>Yes, there seems to be a lot of people who have a visceral hatred for>>Microsoft and Windows. They are even willing toshed blood to avoid>>Windows. But why? Windows works and you don¹t have to become a systems>>programmer.>Furthermore, I think that Steven Wolfram uses some version of Windows.>>So guess which system Mathematica will be best tuned up for?> If it is true Wolfram uses Mathematica on a Windows based machine my> experience is it doesn¹t translate to Mathematica running better on> Windows. I use Mathematica on WindowsNT and on a Mac (currently Mac OS X).> I have found Mathematica to be more stable on a Mac than on Windows. On> more than one occassion I¹ve seen errors I made Mathematica code to crash> the entire machine under WindowsNT. I¹ve never had this happen running> things on a Mac.I believe you hit the nail on the head. I suspect Dr. Wolfram is running onMac. I have the feeling WRI is a clandestine Mac holdout.STH.====I ran Turbo XMLhttp://www.tibco.com/solutions/products/extensibility/ turbo_xml.jsp onToFileName[{$TopDirectory,SystemFiles,IncludeFiles,XML}, notebookml1.dtd ]It gave me an error saying:There is more than one attribute namedclass. My guess is this was the intention:hattons@ljosalfr:~/.Mathematica/SystemFiles/ IncludeFiles/XML/NotebookML1>diff /opt/Wolfram/Mathematica/4.2/SystemFiles/IncludeFiles/XML/ NotebookML1/notebookml.dtd /home/hattons/.Mathematica/SystemFiles/IncludeFiles/XML/ NotebookML1/notebookml.dtd91c91Comments?STH.====I¹ve posted Mathematica notebooks and packages illustrating most of theneural networks discussed in James Anderson¹s bookAn Introduction toNeural Networks to the Brainstage Research web site (www.brainstage.com).Have fun!DonDonald Doherty, Ph.D.Brainstage Research, Inc.donald.doherty@brainstage.com====can I have mathematica solver things like a(over)b, (in how many wayscan you pickb items froma items)?I have mathematica 4.Stefan====StefanYou certainly can - try Binomial[a,b].Mark Westwood> can I have mathematica solver things like a(over)b, (in how many ways> can you pickb items froma items)?> I have mathematica 4.> Stefan====Since you already know the answer, the simplest way is:In[51]:=Factor[x^4 + x^3 + x^2 + x + 1, Extension -> {GoldenRatio}]Out[51]=(-(-1 - x + GoldenRatio*x - x^2))*(1 + GoldenRatio*x + x^2)Andrzej KozlowskiYokohama, Japanhttp://www.mimuw.edu.pl/~akoz/http:// platon.c.u-tokyo.ac.jp/andrzej/> Greetings MathGroup, My name is Steve Earth, and I am a new subscriber to this list and > also a> new user of Mathematica; so please forgive this rather simple > question... I would like to enter the quartic x^4 + x^3 + x^2 + x + 1 into > Mathematica> and have it be able to tell me that it factors into (x^2 + GoldenRatio x + 1) ( x^2 - 1/GoldenRatio x + 1) What instructions do I need to execute to achieve this output? -Steve Earth> Harker School> http://www.harker.org/ Greetings MathGroup, My name is Steve Earth, and I am a new subscriber to this list and > also a> new user of Mathematica; so please forgive this rather simple > question... I would like to enter the quartic x^4 + x^3 + x^2 + x + 1 into > Mathematica> and have it be able to tell me that it factors into (x^2 + GoldenRatio x + 1) ( x^2 - 1/GoldenRatio x + 1) What instructions do I need to execute to achieve this output? -Steve Earth> Harker School> http://www.harker.org/>Andrzej KozlowskiYokohama, Japanhttp://www.mimuw.edu.pl/~akoz/http:// platon.c.u-tokyo.ac.jp/andrzej/====I confess I am not 100% sure what you mean. Would you like to do thisin steps, like you would do it by hand?In[1]:=a + b/c + d*(Sqrt[e]/c) == 0;In[2]:=Thread[(#1 - a - b/c & )[%], Equal]Out[2]=(d*Sqrt[e])/c == -a - b/cIn[3]:=Thread[(#1*c & )[%], Equal]Out[3]=d*Sqrt[e] == (-a - b/c)*cIn[4]:=Thread[(#1^2 & )[%], Equal]Out[4]=d^2*e == (-a - b/c)^2*c^2In[5]:=Simplify[%]Out[5]=d^2*e == (b + a*c)^2Of course you can combine all the steps into a single function, but Ithink it will be fairly complicated.My own favourite way to do this sort of thing is:In[1]:=Simplify[d^2*e == (d^2*e /. AlgebraicRules[ a + b/c + d*(Sqrt[e]/c) == 0, e])]Out[1]=d^2*e == (b + a*c)^2However, AlgebraicRules has not been documented since version 4. Itshould be possible to do this using PolynomialReduce but it seems torequire the sort of skill only Daniel Lichtblau possesses;)Andrzej KozlowskiToyama International UniversityJAPANhttp://sigma.tuins.ac.jp/~andrzej/> I¹m a newbie and, of course, the Žrst thing I want to do is apparently> one of the most complicated... I have an expression that looks like this: A + B/C + D*Sqrt[E]/C = 0 A,B,C,D, & E are all polynomials in x> I want it to look like this (D^2)*E = (A*C + B)^2 At that point, I¹ll have polynomials in x on both sides. Finally, I> want the equation to be written out with terms grouped by powers of x,> but I think I can do that part :) I¹ll be very grateful to anyone who can give me some pointers. Or, at> least point me to some tutorial in the Mathematica documentation. I¹ve> been looking over the documentation and I found Appendix A.5 in The> Mathematica Book, but that doesn¹t help me. I _need_ some examples. I> did Žnd a couple of well-written posts in this newsgroup, but not > quite> close enough to what I want.> Troy. =-=-=-=-=-=-=-=-=-= FYI, here¹s the expression I¹m working with.> denom = Sqrt[(B^2 - r^2)^2 + 4*(r^2)*(b^2)]> cnu = (2*b^2 - B^2 + r^2)/denom> snu = -2*b*Sqrt[B^2 - b^2]/denom> sif = 2*r*b/denom> cif = (r^2 - B^2)/denom pdr = -Cos[ds]*Sin[q]*(snu*cif +> cnu*sif) - Sin[ds]*(cnu*cif - snu*sif) 0 == -(B^2 - b^2)*V^2/(r^2) + (((B*V)^2)/(> r^2) - 2*w*b*V*Cos[q]*Cos[ds] + (w*> r)^2 - (w*r*pdr)^2)*(Cos[qr])^2 Although I said it¹s a polynomial in x, it¹s really a polynomial inb> that I¹m after.====Only on second reading I noticed the part about a,b,c,d beingpolynomials in x. Both methods will still work if Žrst perform thesame operation as below and Žnally use the replacement rule%/.{a->p[x],b->q[x],c->r[x],d->u[x],e->v[x]}, where p[x] etc are thegiven polynomials. Of course collecting of terms can be done withCollect[%,x].Andrzej KozlowskiYokohama, Japanhttp://www.mimuw.edu.pl/~akoz/http:// platon.c.u-tokyo.ac.jp/andrzej/> I confess I am not 100% sure what you mean. Would you like to do this > in steps, like you would do it by hand? In[1]:=> a + b/c + d*(Sqrt[e]/c) == 0; In[2]:=> Thread[(#1 - a - b/c & )[%], Equal] Out[2]=> (d*Sqrt[e])/c == -a - b/c In[3]:=> Thread[(#1*c & )[%], Equal] Out[3]=> d*Sqrt[e] == (-a - b/c)*c In[4]:=> Thread[(#1^2 & )[%], Equal] Out[4]=> d^2*e == (-a - b/c)^2*c^2 In[5]:=> Simplify[%] Out[5]=> d^2*e == (b + a*c)^2 Of course you can combine all the steps into a single function, but I > think it will be fairly complicated. My own favourite way to do this sort of thing is: In[1]:=> Simplify[d^2*e == (d^2*e /. AlgebraicRules[> a + b/c + d*(Sqrt[e]/c) == 0, e])] Out[1]=> d^2*e == (b + a*c)^2 However, AlgebraicRules has not been documented since version 4. It > should be possible to do this using PolynomialReduce but it seems to > require the sort of skill only Daniel Lichtblau possesses;) Andrzej Kozlowski> Toyama International University> JAPAN> http://sigma.tuins.ac.jp/~andrzej/ I¹m a newbie and, of course, the Žrst thing I want to do is > apparently> one of the most complicated... I have an expression that looks like this:>> A + B/C + D*Sqrt[E]/C = 0 A,B,C,D, & E are all polynomials in x> I want it to look like this (D^2)*E = (A*C + B)^2 At that point, I¹ll have polynomials in x on both sides. Finally, I> want the equation to be written out with terms grouped by powers of x,> but I think I can do that part :) I¹ll be very grateful to anyone who can give me some pointers. Or, at> least point me to some tutorial in the Mathematica documentation. > I¹ve> been looking over the documentation and I found Appendix A.5 in The> Mathematica Book, but that doesn¹t help me. I _need_ some examples. I> did Žnd a couple of well-written posts in this newsgroup, but not > quite> close enough to what I want.> Troy. =-=-=-=-=-=-=-=-=-= FYI, here¹s the expression I¹m working with.> denom = Sqrt[(B^2 - r^2)^2 + 4*(r^2)*(b^2)]> cnu = (2*b^2 - B^2 + r^2)/denom> snu = -2*b*Sqrt[B^2 - b^2]/denom> sif = 2*r*b/denom> cif = (r^2 - B^2)/denom pdr = -Cos[ds]*Sin[q]*(snu*cif +> cnu*sif) - Sin[ds]*(cnu*cif - snu*sif)>> 0 == -(B^2 - b^2)*V^2/(r^2) + (((B*V)^2)/(> r^2) - 2*w*b*V*Cos[q]*Cos[ds] + (w*> r)^2 - (w*r*pdr)^2)*(Cos[qr])^2 Although I said it¹s a polynomial in x, it¹s really a polynomial in >b> that I¹m after.====<{-1,5}]ImplicitPlot[x^3y + y^3 == 9, {x, -10, 10}]Meilleures salutationsFlorian Jaccard-----Message d¹origine-----Envoy.8e : dim., 6. octobre 2002 11:34Ė : mathgroup@smc.vnet.netObjet : Plotting ellipses and other functionsHow can I plot functions like:(x-2)^2 + 2(y-3)^2 = 6andx^3y + y^3 = 9using Mathematica?====>How can I plot functions like:(x-2)^2 + 2(y-3)^2 = 6>>and>>x^3y + y^3 = 9>>using Mathematica?>Needs[Graphics`ImplicitPlot`];ImplicitPlot[(x - 2)^2 + 2(y - 3)^2 == 6, {x, -1, 5}, {y, 1, 5}];ImplicitPlot[x^3 y + y^3 == 9, {x, -6, 6}, {y, -6, 6}];Bob Hanlon====>Could somebody please inform me how to Round numbers to a>certain Accuracy using Mathematica 4.2. This is not as easy as it>sounds.>Every function that I have read Rounds the Display, and not the actual>number.myRound[x_, n_] := Round[10^n*x]/10.^n;Table[myRound[Random[], 3], {10}]{0.044, 0.019, 0.738, 0.298, 0.917, 0.171, 0.021, 0.314, 0.658, 0.153}Bob HanlonReply-To: tgarza01@prodigy.net.mx====You might use ImplicitPlot:In[1]:=< Yes, there seems to be a lot of people who have a visceral hatred for> Microsoft and Windows. They are even willing toshed blood to avoid> Windows. But why? Windows works and you don¹t have to become a systems> programmer.> Furthermore, I think that Steven Wolfram uses some version of Windows. So> guess which system Mathematica will be best tuned up for?> I have no problems with Mathematica and Windows on my single computer.> There may be reasons for using a non-Microsoft operating system. But if> you are going to do it, make certain that they are good reasons.that of Windows XP by orders of magnitude. I recall when I Žrst startedbeen using Windows NT since October of 1992. (Yes, I know it hadn¹t beenpaper on the architecture of NT. In 1997 I was well on my way to being anMCSE. no stinkin¹ GUI¹ to Œhave a look at the KDE project¹. I took the latterroute. The KDE has gone from a simple graphical desktop with a few morefeatures than the CDE, (and a lot more glitches) to being the best desktopavailable. It¹s growth seems to be exponential. Windows seems, at best,to be linear.All of these are usability issues. There is another reason I don¹t likeusing Microsoft products. I¹ve also been using Mozilla since 1995. (Yes,it has always been called Mozilla.) I was one of the original beta testersfor the Netscape line of internet servers. When I saw what NetscapeCommunications were aiming for, Windows quickly lost its luster. Netscapeproducts were designed from the ground up with portability in mind. Theywere striving for uniform functionality across all platforms.I also saw what Microsoft did to undermine Netscape¹s R & D resources. Microsoft would condescend to having not competition in their market. Where I come from, people don¹t put up with that. Where do I come from? Iwas born in Illinois.I¹m obviously not of the opinion that closed source is unacceptable. Iwouldn¹t be using Mathematica if I were. I suspect one day Mathematica will face areal open source challeng. Her name is Charolette. She is the mother ofMozilla. That will probably be years from now. WRI need to be prepared toadjust to that eventuality when it comes.> David Park> djmp@earthlink.net> http://home.earthlink.net/~djmp/STH.====I feel as if I¹ve Žnally had the breakthrough in intuitively understanding the Mathematica editor, or at least the basics. I want to explain toothers what they really need to know about the editor to use it for basicpurposes. Part of the reason I now understand the editor better is thatI¹ve since worked with LyX http://www.devel.lyx.org and XEmacshttp://www.xemacs.org, and I¹ve also become proŽcient with DocBook XML.When I Žrst started using the editor, reading the Mathematica Help didn¹tseem to help. It seemed to tell me a whole lot more than I needed to know,and didn¹t tell me what I really needed to know. Now I¹m in the positionof being able to use it, but not being able to explain exactly what it isI¹ve learned. Is there any documentation directed toward the beginner,which tells him or her what to do, what to expect, what quirks to be awareof, and etc.? I¹m looking for something along the lines ofclick here tomake this happen. If you see this, it may seem weird, but that¹s normal.Those brackedt on the left really mean... .STH.====>I would like to enter the quartic x^4 + x^3 + x^2 + x + 1 into Mathematica>and have it be able to tell me that it factors into(x^2 + GoldenRatio x + 1) ( x^2 - 1/GoldenRatio x + 1)>>What instructions do I need to execute to achieve this output?>soln = Factor[x^4 + x^3 + x^2 + x + 1, Extension -> GoldenRatio] // Simplify(x^2 - GoldenRatio*x + x + 1)*(x^2 + GoldenRatio*x + 1)soln = Simplify /@ (soln /. -GoldenRatio -> -1 - 1/GoldenRatio)(x^2 - x/GoldenRatio + 1)*(x^2 + GoldenRatio*x + 1)soln // FunctionExpand // FullSimplifyx^4 + x^3 + x^2 + x + 1Bob Hanlon====Stefan,I don¹t think I completely understand your question, but I think you arelooking for the Binomial function in Mathematica.Binomial[4, 2]6David Parkdjmp@earthlink.nethttp://home.earthlink.net/~djmp/Sender: steve@smc.vnet.netApproved: Steven M. Christensen , Moderator====Steve,You could use the Extension feature of Factor as documented in Help.expr = x^4 + x^3 + x^2 + x + 1ans = Factor[expr, Extension -> {1/GoldenRatio}](-(1/4))*(-2 - x + Sqrt[5]*x - 2*x^2)* (2 + x + Sqrt[5]*x + 2*x^2)You could also use...Factor[expr, Extension -> {Sqrt[5]}]It took me some effort to Žgure out how to manipulate the answer into yourform.ans /. {x + Sqrt[5]*x -> (2*GoldenRatio)*x, -x + Sqrt[5]*x -> (2/GoldenRatio)*x}% /. (-4^(-1))*a_*b_ :> Simplify[-a/2]*Simplify[b/2](-(1/4))*(-2 + (2*x)/GoldenRatio - 2*x^2)* (2 + 2*GoldenRatio*x + 2*x^2)(1 - x/GoldenRatio + x^2)*(1 + GoldenRatio*x + x^2)David Parkdjmp@earthlink.nethttp://home.earthlink.net/~djmp/http:// www.harker.org/====David,To plot equations like that, simply use ImplicitPlot.Needs[Graphics`ImplicitPlot`]ImplicitPlot[(x - 2)^2 + 2(y - 3)^2 == 6, {x, -1, 5}, {y, 1, 5}];ImplicitPlot[x^3*y + y^3 == 9, {x, -10, 10}, {y, -10, 10}];You may have to Žsh a little to obtain the appropriate x and y ranges.Start by making them larger and then narrow down to the region that youwant.I have put a new package at my web site for solving conic section problemsin the plane. You can solve for complete information on any conic sectionand obtain a parametric representation for plotting it. The package alsocomes with complete Help documentation and examples.Using your Žrst example (the second is not a conic).Needs[ConicSections`ConicSections`]eqn = (x - 2)^2 + 2(y - 3)^2 == 6;The routine ParseConic will take any quadratic equation and return the scalea, eccentricity e, a parametrization, and rotation matrix P, translation Tand režection matrix R that transforms the conic from standard position toits actual position. (In standard position the conic has its foci andverticies on the x-axis with the center at zero.){{a, e}, curve[t_], {P, T, R}} = ParseConic[eqn]{{Sqrt[6], 1/Sqrt[2]}, {2 + Sqrt[6]*Cos[t], 3 + Sqrt[3]*Sin[t]}, {{{1, 0}, {0, 1}}, {2, 3}, {{1, 0}, {0, 1}}}}We could then plot the curve using ParametricPlot, which is more efŽcientand controllable.ParametricPlot[Evaluate[curve[t]], {t, -Pi, Pi}, AspectRatio -> Automatic, Frame -> True, Axes -> None, PlotLabel -> eqn];Knowing a and e we can use the StandardConic routine to obtain all theinformation about the conic in standard position as a set of rules.standarddata = StandardConic[{a, e}]{conictype ->Ellipse, conicequation -> x^2/6 + y^2/3 == 1, coniccurve -> {Sqrt[6]*Cos[t], Sqrt[3]*Sin[t]}, coniccurvedomain -> {-Pi, Pi}, coniccenter -> {0, 0}, conicfocus -> {{Sqrt[3], 0}, {-Sqrt[3], 0}}, conicdirectrix -> {x == -2*Sqrt[3], x == 2*Sqrt[3]}, conicvertex -> {{Sqrt[6], 0}, {-Sqrt[6], 0}}}routine to obtain the same information for the conic in its actual position.standarddata // TransformEllipseRules[P, T, R]{conictype ->Ellipse, conicequation -> (1/6)*((-2 + x)^2 + 2*(-3 + y)^2) == 1, coniccurve -> {2 + Sqrt[6]*Cos[t], 3 + Sqrt[3]*Sin[t]}, coniccurvedomain -> {-Pi, Pi}, coniccenter -> {2, 3}, conicfocus -> {{2 + Sqrt[3], 3}, {2 - Sqrt[3], 3}}, conicdirectrix -> {2*Sqrt[3] + x == 2, x == 2*(1 + Sqrt[3])}, conicvertex -> {{2 + Sqrt[6], 3}, {2 - Sqrt[6], 3}}}David Parkdjmp@earthlink.nethttp://home.earthlink.net/~djmp/Sender: steve@smc.vnet.netApproved: Steven M. Christensen , ModeratorReply-To: ====Try this:A + B/C + D*(Sqrt[E]/C) == 0(#1 - %[[1,{1, 2}]] & ) /@ %(C*#1 & ) /@ %(#1^2 & ) /@ %Simplify[%]Also, be aware that E is the natural logarithm base, reserved for thatpurpose.DrBob-----Original Message-----want the equation to be written out with terms grouped by powers of x,but I think I can do that part :)I¹ll be very grateful to anyone who can give me some pointers. Or, atleast point me to some tutorial in the Mathematica documentation. I¹vebeen looking over the documentation and I found Appendix A.5 in TheMathematica Book, but that doesn¹t help me. I _need_ some examples. Idid Žnd a couple of well-written posts in this newsgroup, but not quiteclose enough to what I want.Troy.=-=-=-=-=-=-=-=-=-=FYI, here¹s the expression I¹m working with.denom = Sqrt[(B^2 - r^2)^2 + 4*(r^2)*(b^2)]cnu = (2*b^2 - B^2 + r^2)/denomsnu = -2*b*Sqrt[B^2 - b^2]/denomsif = 2*r*b/denomcif = (r^2 - B^2)/denompdr = -Cos[ds]*Sin[q]*(snu*cif + cnu*sif) - Sin[ds]*(cnu*cif - snu*sif)0 == -(B^2 - b^2)*V^2/(r^2) + (((B*V)^2)/( r^2) - 2*w*b*V*Cos[q]*Cos[ds] + (w* r)^2 - (w*r*pdr)^2)*(Cos[qr])^2Although I said it¹s a polynomial in x, it¹s really a polynomial inbthat I¹m after.Reply-To: ====It¹s a little ugly, but here¹s my solution:x^4 + x^3 + x^2 + x + 1Simplify@Factor[%, Extension -> {GoldenRatio, 1/GoldenRatio}]Collect[%[[2]]/3, x]Collect[%[[3]]/3, x]% /. Sqrt[5] -> 2GoldenRatio - 1% // SimplifyCollect[#, x] & /@ %% /. {1 - GoldenRatio -> -1/GoldenRatio}FullSimplify@Expand@%(The last line is a check.)Bobby-----Original Message-----(x^2 + GoldenRatio x + 1) ( x^2 - 1/GoldenRatio x + 1)What instructions do I need to execute to achieve this output?-Steve EarthHarker Schoolhttp://www.harker.org/====>How can I plot functions like:(x-2)^2 + 2(y-3)^2 = 6>>and>>x^3y + y^3 = 9>>using Mathematica?Use ImplicitPlot in the package Graphics`ImplicitPlot`====David,<{0,0} ]-----Original Message-----Sender: steve@smc.vnet.netApproved: Steven M. Christensen , ModeratorReply-To: jcd@q-e-d.org====I look for a way to right align entries output by MatrixForm. There is an adhoc option, but I haven¹t Žgured out how it is supposed to work in Mathematica 4.0(if it works at all).m={{MatrixForm[{0,0,0}],-123456789},{123456789,1}}; MatrixForm[m,TableAlignments->{Right,Top}]appears identical toMatrixForm[m] (with no SetOptions override)Strangely, Mathematica doesn¹t complain if you input ill options like:MatrixForm[m,TableAlignments->{WhateverIsIllegal,Right, Top,MakeSomeSpiralOfIt}]In Mathematica 2.2x, the behavior is rather strange: one option alone works, butwhen two are given (e.g. {Right,Top}), only the last seems to be acted upon.I didn¹t bother to try hard with the older version, so don¹t žame me if I¹mwrong.At the other hand, when a TableAlignments->Right is given to TableForm,entries are right-aligned correctly.Can someone provide a way out (even a slow external module) or tell me howto use this option.I apologize for using a phony address in an attempt====I decided to export one of my notebooks to html/mathmlhttp://baldur.globalsymmetry.com/proprietary/com/ wri/notebooks/essential/66.92.149.152 baldur.globalsymmetry.comWhen I try to view it with Mozilla, I get a Œ?¹ in place of the imaginarynumber symbol. When I Žrst load the page with Mozilla, I get an errortelling meTo properly display the MathML on this page you need to install thefollowing fonts: CMSY 10, CMEX 10, Math1, Math2, Math4.For further infromation see:http://www.mozilla.org/projects/mathml/fontsI did what the instructions at the URL told me, and I still get the error. I looked through the fonts in the Mathematica font directory, and I found:Mathematica1Mono.9.bdf -wri-mathematica1mono-medium-r-normal--9-90-75-75-m-50- adobe-fontspeciŽcMathematica3.12.bdf -wri-mathematica3-medium-r-normal--12-120-75-75-p-70- adobe-fontspeciŽcMathematica3.24.bdf -wri-mathematica3-medium-r-normal--24-240-75-75-p-130- adobe-fontspeciŽcMathematica3.36.bdf -wri-mathematica3-medium-r-normal--36-360-75-75-p-210- adobe-fontspeciŽc....Mathematica7.12.bdf -wri-mathematica7-medium-r-normal--12-120-75-75-p-40- adobe-fontspeciŽcMathematica7.24.bdf ....-wri-mathematica6-medium-r-normal--12-120-75-75-p-30- adobe-fontspeciŽcMathematica6.24.bdf -wri-mathematica6-medium-r-normal--24-240-75-75-p-70- adobe-fontspeciŽcMathematica6.36.bdf -wri-mathematica6-medium-r-normal--15-150-75-75-p-50- adobe-fontspeciŽcMathematica5.12.bdf -wri-mathematica5-medium-r-normal--12-120-75-75-p-50- adobe-fontspeciŽcMathematica5.24.bdf -wri-mathematica5-medium-r-normal--24-240-75-75-p-110- adobe-fontspeciŽcMathematica5.36.bdf -wri-mathematica5-medium-r-normal--36-360-75-75-p-160- adobe-fontspeciŽcMathematica5.13.bdf -wri-mathematica5-medium-r-normal--13-130-75-75-p-50- adobe-fontspeciŽcMathematica4.18.bdf -wri-mathematica4-medium-r-normal--18-180-75-75-p-130- adobe-fontspeciŽcMathematica5.10.bdf....I suspect this is what mozilla is looking for, but I don¹t know exactly howto tell it as much. Any ideas?STH.====Are there any known issues with simpy treating the JLink.jar as a Javaextension as follows?cp JLink.jar $JAVA_HOME/jre/lib/ext?According to my understanding of the discussion in the Java Tutorial onextensions, that should work:http://java.sun.com/docs/books/tutorial/ext/basics/ install.htmlCommants?STH.====>[...]> I would say this is correct and show that SetPrecision is very useful > indeed. It tells you (what of course you ought to already know in this > case anyway) that machine precision will not give you a realiable > answer in this case. If you know your numbers with a great deal of > accuracy you can get an accurate answer:> In[24]:=> f = SetAccuracy[333.75*b^6 + a^2*(11*a^2*b^2 - b^6 -> 121*b^4 - 2) + 5.5*b^8 + a/(2*b), 100];> a=SetPrecision[77617.,100]; b = SetPrecision[33096.,100];> In[26]:=> {f, Precision[f]}> Out[26]=> {-0.82739605994682136814116509547981629199903311578438481991> 781484167246798617832`61.2597, 61}>Congratulations! You just requested accuracy of 100 for f and got 61 (to convince yourself add Accuracy[f] to In[26]). If In[24] onereplaces SetAccuracy by SetPrecision the result is similar.PK> Again you can be pretty sure that you got an accurate answer, provided > of course your original setting of precision was valid.> Honestly, to say that SetPrecision and SetAccuaracy are useless is one > of the silliest thing I have read on this list in years.> Andrzej Kozlowski> Yokohama, Japan> http://www.mimuw.edu.pl/~akoz/> http://platon.c.u-tokyo.ac.jp/andrzej/====> You are entitled to your opinion. For my applications> this behavior IS useless.>I agree that Mathematica is probably useless for you. This is howevernot because it is useless or useless foryour application, butbecause to use its full power you have to study it, understand it, andin particular, for numerical work, understand the model of arithmeticit uses. Lie with mathematics they are really no shortcuts that willlead you to its full power. In addition, since it is a computerprogram, it has certain conventions, which may not be the same as theconventions of other programs (they all have conventions) but which youhave to accept to be able to use it. Now, once you have done that, youmay still not like the way Mathematica does things and there are genuine experts in numerics who indeed do not like and are quite vocalabout it. But they never sayit is useless, because by saying thatyou are either displaying your own ignorance or engaging in stupid andpointless abuse.On a more serious level, there seem to be two basic approaches tonumeric computation relevant to this discussion. It seems to me (though I am no expert in this sort of thing) that there are threetypes of situations that one may encounter. Firstly, there is the vastmajority of rather simple computations for which built-in machinežoating point arithmetic , which carries no guarantee of precision atall is meant for. It clearly must be sufŽcient for the majority ofpurposes, since most general purpose and even technical softwareavailable uses not other method. The reason of course is that it is byfar the fastest way to do such computations (as well as beingsufŽcient for most situations).The second type of situation is when you actually know the precision ofyour input and would like the program to give you some idea about theprecision of the output you might expect. This is the most likelysituation in empirical science and is exactly what SetPrecision ismeant for. Most reasonable people would agree that Mathematica workswell in this situation.There is Žnally one more situation, to which the only reasonablecriticism that I have read in this thread appears to be directed at.That is the situation when you actually know your input exactly, butworking with exact numbers is far too slow. So what you have to do isto replace your exact numbers with inexact ones padded with 0¹s. InMathematica you have to take a guess at how much padding you will need,than use SetPrecision to pad the numbers, and then check the Precisionof your answer. It may turn out that you did not get as much precisionas you needed, in which case you have to use more zeros. Or it may bethat you used more than enough, which mans that your computation couldhave been done faster. I learned from Leszek Sczaniecki that there isan approach due to Oliver Aberth which lets you only specify thedesired precision of your answer and the program itself will choose thecorrect padding for your input. It woudl ertainly be nice to have thisability, but I honestly think that it would be only of marginaladvantage over making your own guess. It seems to me that the checkingthat the Aberth mthod must require will be time consuming and wiht abit of practice one can probably get better results as far as speed isconcerned using the Mathematica approach. But this is just purespeculation and certainly it woudl be nice if such a possibilityexisted.Andrzej KozlowskiToyama International UniversityJAPANhttp://sigma.tuins.ac.jp/~andrzej/Reply-To: kuska@informatik.uni-leipzig.de====look whatGraphics`ImplicitPlot`does. Jens> How can I plot functions like:> (x-2)^2 + 2(y-3)^2 = 6> and> x^3y + y^3 = 9> using Mathematica?====David:For a start you can try the following:Using ContourPlotContourPlot[(x - 2)^2 + 2(y - 3)^2 - 6, {x, -1, 5}, {y, -1, 5}, Contours -> {0}, ContourShading -> False, ContourSmoothing -> 5]Or using ImplicitPlot<< Graphics`ImplicitPlot`ImplicitPlot[(x - 2)^2 + 2(y - 3)^2 == 6, {x, -1, 5}]ImplicitPlot[x^3y + y^3 == 9, {x, -4, 4}]Hans> How can I plot functions like: (x-2)^2 + 2(y-3)^2 = 6 and x^3y + y^3 = 9 using Mathematica?====Try reading help under the keyword ImplicitPlot| How can I plot functions like:|| (x-2)^2 + 2(y-3)^2 = 6|| and|| x^3y + y^3 = 9|| using Mathematica?||||====DavidEnquire within the Help Browser for the ImplicitPlot package and allwill be revealed. For example, I snipped the following lines from thedocumentation:<< Graphics`ImplicitPlot`ImplicitPlot[x^2 + 2 y^2 == 3, {x, -2, 2}]Hope this is of sufŽcient help to get you started - post again if youhave any further questions.Mark Westwood> How can I plot functions like:> (x-2)^2 + 2(y-3)^2 = 6> and> x^3y + y^3 = 9> using Mathematica?====There are two basic ways, the second of which has two forms. The basicways are:1. Using the built in function ContourPlot, e.g.:ContourPlot[x^3y + y^3 - 9, {x, -9, 9}, {y, -27, 27}, Contours -> {0}, ContourShading -> False, Axes -> True, Frame -> False, PlotPoints -> 50, AxesOrigin -> {0, 0}]alternatively you can use a Standard package:<{0,0}]or ImplicitPlot[x^3y+y^3-==9,{x,-9,9},{y,-27,27},AxesOrigin->{ 0,0}]The difference between these two is that the Žrst one gives you asmoother picture but requires the equation to be solvable (byMathematica) for y. The second will give a picture very similar to thatproduced by the Žrst method.Andrzej KozlowskiYokohama, Japanhttp://www.mimuw.edu.pl/~akoz/http:// platon.c.u-tokyo.ac.jp/andrzej/> How can I plot functions like: (x-2)^2 + 2(y-3)^2 = 6 and x^3y + y^3 = 9 using Mathematica?====Jack,Often, what I do when developing a slightly complicated module is to Žrsttest it after I add each statement L1, L2, etc. But then often I want tomake changes after I have all the statements in. Then to debug I just addtemporary Print statements. For example...myFunction[f_] := Module[ {L1,L2,L3},L1 = ... ;L2 = ... ;Print[{L1, L2}];l3 = ... ;]Sometimes I use multiple Print statements. The only problem with thisapproach is that sometimes the difŽculty might be in a subexpression of alonger expression.This forces me to temporarily break out the longer expression into multiplestatements, or perhaps duplicate the subexpression in the Print statement.But I Žnd that the easiest method to track down errors.David Parkdjmp@earthlink.nethttp://home.earthlink.net/~djmp/l3 = ... ; Žnal step ]To see what went wrong, I use (* *) selectively as follows:Stage 1myFunction[f_] := Module[ {L1,L2,L3},L1 = ... (*;L2 = ... ;L3 = ... ; Žnal step *) ]Thus I see if L1 worked as expected. The next step is to put (* after L2and see if this works. I continue this til the bitter end and I usuallyŽnd my errors.My question; The process of moving (* *) step by step through theprogram is quite tedious when the code has lots more lines. What I wouldlike is ameta-program which (like FoldList) does this job for me. Theoutput of thismeta-program is the list of outputs of each line in themodule, probably best printed as a column.This sounds like Trace but my problem with Trace is it is terriblydifŽcult to read. For the not-so-subtle programming I do, the only thingI need is what expression is returned line by line.Any advice? All remarks are appreciated!JackReply-To: kuska@informatik.uni-leipzig.de====doeshelp you ? Jens> I often run into this difŽculty: when designing a program, say as a> module, and testing it for various inputs, I get wrong answers. What to> do? I use a method that works for me but may not be the best available.> I want to show my method and then ask a question about how it can be> imporved. (Oh yes, I abandoned Trace a long time ago!)> myFunction[f_] := Module[ {L1,L2,L3},> L1 = ... ;> L2 = ... ;> l3 = ... ;> Žnal step> ]> To see what went wrong, I use (* *) selectively as follows:> Stage 1> myFunction[f_] := Module[ {L1,L2,L3},> L1 = ... (*;> L2 = ... ;> L3 = ... ;> Žnal step *)> ]> Thus I see if L1 worked as expected. The next step is to put (* after L2> and see if this works. I continue this til the bitter end and I usually> Žnd my errors.> My question; The process of moving (* *) step by step through the> program is quite tedious when the code has lots more lines. What I would> like is ameta-program which (like FoldList) does this job for me. The> output of thismeta-program is the list of outputs of each line in the> module, probably best printed as a column.> This sounds like Trace but my problem with Trace is it is terribly> difŽcult to read. For the not-so-subtle programming I do, the only thing> I need is what expression is returned line by line.> Any advice? All remarks are appreciated!> Jack====I¹ve enhanced the code for PartialEvaluation (see my post, which Iincorrectly attaced to someone else¹s reply). It is somewhat morežexible now and does more error checking. It Žnds the rule inDownValues that matches f[args] (allowing for more than one rule inDownValues); it allows the user to specify the position of themainCompoundExpression; and it allows the user to specify an expressionthat gets appended to the truncated CompoundExpression (and henceevaluated and returned). The package is just a bit too large to posthere. It can be downloaded from my web site athttp://www.markŽsher.net/~meŽsher/mma/ mathematica.htmlNevertheless, I can give an outline of the code here (absent the errorchecking stuff).PartialEvaluation[f[args], n, expr]:(* get the DownValues andturn them off *)dv = DownValues[f];DownValues[f] = {};(* Žnd the rule that matches *)matches = Position[MatchQ[f[args], #]& /@ dv[[All, 1]], True];match = dv[[ matches[[1, 1]] ]];(* Žnd themain CompoundExpression *)ppos = Position[match, HoldPattern[CompoundExpression[__]]];pos = First[Sort[ppos]];(* extract, truncate, append to, and reinsert it *)held = Extract[match, pos, Hold];held = ReplacePart[held, Sequence, {1, 0}];held = Take[held, n];held = Join[held, Hold[expr]];held = ReplacePart[Hold[Evaluate[held]], CompoundExpression, {1, 0}];match = ReplacePart[match, held, pos, 1];(* apply the modiŽed rule and restore DownValues *)result = f[args] /. match;DownValues[f] = dv;result--Mark> I often run into this difŽculty: when designing a program, say as a> module, and testing it for various inputs, I get wrong answers. What to> do? I use a method that works for me but may not be the best available.> I want to show my method and then ask a question about how it can be> imporved. (Oh yes, I abandoned Trace a long time ago!)> myFunction[f_] := Module[ {L1,L2,L3},> L1 = ... ;> L2 = ... ;> l3 = ... ;> Žnal step> ]> To see what went wrong, I use (* *) selectively as follows:> Stage 1> myFunction[f_] := Module[ {L1,L2,L3},> L1 = ... (*;> L2 = ... ;> L3 = ... ;> Žnal step *)> ]> Thus I see if L1 worked as expected. The next step is to put (* after L2> and see if this works. I continue this til the bitter end and I usually> Žnd my errors.> My question; The process of moving (* *) step by step through the> program is quite tedious when the code has lots more lines. What I would> like is ameta-program which (like FoldList) does this job for me. The> output of thismeta-program is the list of outputs of each line in the> module, probably best printed as a column.> This sounds like Trace but my problem with Trace is it is terribly> difŽcult to read. For the not-so-subtle programming I do, the only thing> I need is what expression is returned line by line.> Any advice? All remarks are appreciated!> Jack====The following code is my attempt to provide the functionality yourequested. It does some rudimentary error checking, but I haven¹ttried very hard to fool it. The code manipulates the DownValues,locating thehighest CompoundExpression (see the lines in whichpos is deŽned), keeping only those expressions speciŽed.DownValues are restored after the expression is evaluated. The trickypart is keeping the CompoundExpression from evaluating while it isbeing manipulated. (See the lines in whichheld andnew aredeŽned.) I¹m not sure I¹m doing this part the most elegant way, butit seems to work.(* code starts here *)PartialEvaluation::usage =PartialEvaluation[f[args], n] returnsf[args] where only the Žrst n expressions are evaluated in themainCompoundExpression in DownValues[f]. For example:ntClear[f]ntf[x_] := Module[{a,b}, a=3; b=4; a b x]ntPartialEvaluation[f, 2]nreturns 4.PartialEvaluation::dvprob =DownValues[``] is either empty or hasmorethan one element.PartialEvaluation::toobig =There are only `1` expressions inthe CompoundExpression in `2`.PartialEvaluation::noce =There are no CompoundExpressions inDownValues[``].SetAttributes[PartialEvaluation, HoldFirst]PartialEvaluation[f_[args__], n_Integer] := Module[{dv, pos, held, new, eval}, Catch[ dv = DownValues[f]; If[Length[dv] != 1, Message[PartialEvaluation::dvprob, f]; Throw[HoldForm[f[args]]]]; pos = Sort[Position[dv, CompoundExpression]]; If[pos == {}, Message[PartialEvaluation::noce, f]; Throw[HoldForm[f[args]]]]; pos = Drop[First @ pos, -1]; held = Extract[dv, pos, Hold] /. CompoundExpression -> Sequence; If[Abs[n] > Length[held], Message[PartialEvaluation::toobig, Length[held], HoldForm[f[args]]]; Throw[HoldForm[f[args]]]]; new = ReplacePart[dv, Take[held, n] /. Hold[x__] :> Hold[CompoundExpression[x]], pos, 1]; DownValues[f] = new; eval = f[args]; DownValues[f] = dv; eval ]](* code ends here *)--Mark.P.S. The version of this message I posted directly from my newsreaderdidn¹t show up, so I¹m reposting (a slightly improved version) fromGoogle.> Jack,> Often, what I do when developing a slightly complicated module is to Žrst> test it after I add each statement L1, L2, etc. But then often I want to> make changes after I have all the statements in. Then to debug I just add> temporary Print statements. For example...> myFunction[f_] := Module[ {L1,L2,L3},> L1 = ... ;> L2 = ... ;> Print[{L1, L2}];> l3 = ... ;> ]> Sometimes I use multiple Print statements. The only problem with this> approach is that sometimes the difŽculty might be in a subexpression of a> longer expression.> This forces me to temporarily break out the longer expression into multiple> statements, or perhaps duplicate the subexpression in the Print statement.> But I Žnd that the easiest method to track down errors.> David Park> djmp@earthlink.net> http://home.earthlink.net/~djmp/> I often run into this difŽculty: when designing a program, say as a> module, and testing it for various inputs, I get wrong answers. What to> do? I use a method that works for me but may not be the best available.> I want to show my method and then ask a question about how it can be> imporved. (Oh yes, I abandoned Trace a long time ago!)> myFunction[f_] := Module[ {L1,L2,L3},> L1 = ... ;> L2 = ... ;> l3 = ... ;> Žnal step> ]> To see what went wrong, I use (* *) selectively as follows:> Stage 1> myFunction[f_] := Module[ {L1,L2,L3},> L1 = ... (*;> L2 = ... ;> L3 = ... ;> Žnal step *)> ]> Thus I see if L1 worked as expected. The next step is to put (* after L2> and see if this works. I continue this til the bitter end and I usually> Žnd my errors.> My question; The process of moving (* *) step by step through the> program is quite tedious when the code has lots more lines. What I would> like is ameta-program which (like FoldList) does this job for me. The> output of thismeta-program is the list of outputs of each line in the> module, probably best printed as a column.> This sounds like Trace but my problem with Trace is it is terribly> difŽcult to read. For the not-so-subtle programming I do, the only thing> I need is what expression is returned line by line.> Any advice? All remarks are appreciated!> Jack====Mathematica often produces complex resluts. But the problem is not complex:TrySolve[FR == Pi r1^2 - Pi r2^2, r1]It is simple to eliminate it in this case. Just square it.Does someone give me a hint, how to write ra rule for simplify, lik TedErsek did inhttp://www.verbeia.com/mathematica/tips/Links/Tricks_lnk_41 .htmlI thin, one has to to replace the patterni Sqrt[-a_]bySqrt[(i Sqrt[-a_])^2]and then one has to simplify it?Peter Klamser====There has been an interesting discussion about using InterpolatingFunctionfor an empirical CDF.If one is willing to sacriŽce some theoretical soundness, an empirical CDFmay be computed in a simpliŽed form:simpleEmpiricalCDF[distr_/;VectorQ[distr,NumberQ]] :=With[{nonu=Sort[distr], u=Union[distr]},Transpose[{u,FoldList[Plus,0,(Count[nonu,#]&/ @u)/Length[nonu]]//Rest}]]This code does not return a function, and the result needs someinterpretation. Nevertheless, it may be of some use.data = {0.59, 0.72, 0.47, 0.43, 0.31, 0.56, 0.22, 0.9, 0.96, 0.78, 0.66,0.18, 0.73, 0.43, 0.58, 0.11}(the tie [0.43] will be accounted for in a way that is consistent with sometextbooks)simpleEmpiricalCDF[data]//N returns{{0.11,0.0625},{0.18,0.125},{0.22,0.1875},{0.31,0.25}, {0.43,0.375},{0.47,0.4375},{0.56,0.5},{0.58,0.5625},{ 0.59,0.625},{0.66,0.6875},{0.72,0.75},{0.73,0..8125},{ 0.78,0.875},{0.9,0.9375},{0.96,1.}}A plot may be given with:simpleEmpiricalCDFPlot[distr_/;VectorQ[distr,NumberQ]] :=Module[{res,x,p},res=simpleEmpiricalCDF[distr];x=({#,#}& /@ Transpose[res][[1]])//Flatten;p=({#,#}& /@ Transpose[res][[2]])//Flatten;p= Join[{0},Drop[p,-2],{1}];ListPlot[Transpose[{x,p}],c]]Again, this plot does not režect theoretical considerations at the lowerand upper end.With regardHermann Meier I am fairly new to Mathematica and once before asked a questionandreceived somevery helpful responses. This time the problem seems very odd and I maybemaking a veryelementary error. Here is the context: I deŽne a function of the form: f[...,listA_, newEntry_,...]:= Which[...]Here Which has the form of a set of logically exclusive and exhausivetests, each test with its ownaction that modiŽes the concrete list subsituted for listA_. For instance, if there were only two tests the rhs above wouldbeone that puts the newEntryat the start of listA and the other that puts it at the end: Which[ test1, listA = Insert[listA, newEntry, 1], test2, listA = Insert[listA, newEntry, -1] ]Then I try to use the function, substituting values for the arguments:f[..., listA, newEntry, ...]. Theoutput should be the appropriately modiŽed list. But my actual outputreproduces the input form,i.e., it is simply f[...listA,newEntry,...]. Yet, the program does do something, as the use ofevaluate inplaceshows: Suppose that test1 is satisŽed by the particular values of thearguments. Then whenI applyevaluate in place to the lhs of the action that is supposed tooccur when test1 is true,in fact the value of Insert[listA,newEntry,1] is correct, but the rhsgivesonly the initial value ožistA and not the modiŽed value that is on the rhs. Concretely, suppose that in the function argument listA is {121}andnewEntry is 200.Then after evaluation of the function (input to the kernel), that linereads, according toevaluate in place: true, {121} = {200, 121}So it seems that only part of the correct action was taken: 200 was putatthe start of listA. Butthe assignment of this value -- the extended list -- to be the new valueožistA did not take place. I then tried using a new name for the modiŽed list, substituting thisprogram line for test1: test1, newListA = Insert[listA,newEntry,1]What I get here, applyingevaluate in place after evaluating thefunctionwith concrete values as aboveis: true, newListA = {200, 121} Trace doesn¹t help because all I get back is the function namewithits concrete arguments. Any thoughts? Tom====The problem is that I do not think there is any bounded 3d bodydescribed by your conditions. Anyway, this is how you can useMathematica (in general) to solve this sort of problem.You need two packages:In[1]:=< 3x && y < 4 - x^2 && z < x^2 + 4, {x}, {y}, {z}]However, you will just get some error messages and a picture that lookstwo dimensional. If you wanted the volume, evaluate:In[3]:=Integrate[Boole[y>3x&&y<4-x^2&&z3x&&y<4-x^2&&z 3x&&y<4-x^2&&z equation :> z=x^2 +4 (as bottom surface)> and on the xy plane which bounded by a parabola y=4-x^2 and y=3x line. How would I use Mathematica to plot out this 3D object or Žnd out its > volumn with only the equation given? Shz Shz> Andrzej Kozlowski 3/September/2002 04:33pm Mathematica could do this sort of thing if there were a three> dimensional object described by your equations (as boundaries) but> there isn¹t one. More precisely, the pair of equations {z=x^2 +4,> y=4-x^2} describes a parabola in three space which you can plot with: g1=ParametricPlot3D[{x, 4 - x^2, x^2 + 4}, {x, -5, 5}] The equation y=3x describes the plane: g2 = ParametricPlot3D[{x, 3x, z}, {x, -5, 5}, {z, -25, 25}]> You can see the two together in> < Show[{g1,g2}] There are clearly two points of intersection. They can be found with:> Solve[{z == x^2 + 4, y == 4 - x^2, y == 3*x}, {x, y, z}]> {{z -> 5, y -> 3, x -> 1}, {z -> 20, y -> -12, x -> -4}} So where is the 3D object whose volume you want to Žnd? Andrzej Kozlowski> Toyama International University> JAPAN Can I use Mathematica to Žnd out the volumn of this 3 dimensional> object from> the equations : z=x^2 +4, y=4-x^2, y=3x> Shz Shz ==== How can I run mathematica program in background? Is there any waysimilar to fortran or c where one can runs his program in thebackground? Please suggest. RajReply-To: kuska@informatik.uni-leipzig.de====math < someresults.m &???BTW this is a problem of your operating systemand not of Mathematica. Jens> How can I run mathematica program in background? Is there any way> similar to fortran or c where one can runs his program in the> background?> Please suggest.> Raj====All works Žne but now I wanted to generate an animated gif with help ofNow the same Žle which worked earlier produces errors:In[4]:=Export[schwing.gif, schwing,GIF]LinkConnect::linkc: !([LeftSkeleton] 1 [RightSkeleton]) is dead;attempt to connect failed.Out[4]=schwing.gifAlso a dialogue box appears withsuch Žle or directorysuch Žle or directoryThe Žles are at the place and are executable etc. But if one tries toexecute them always thisNo such Žle or directory error message appears.Does anyone know what to do?--Hendrik van Hees Fakult.8at f.9fr Physikhttp://theory.gsi.de/~vanhees/ D-33615 Bielefeld ====First deŽne the functionsz[x_] := x^2 + 4;y1[x_] := 4 - x^2;y2[x_] := 3x;Figure out where the y limits coincide:Solve[y1[x] == y2[x], x]{{x -> -4}, {x -> 1}}Which is bigger in between?y1[0] - y2[0]4y1 is. ConŽrm that with a plot. (y2 is linear):Plot[{y1[x], y2[x]}, {x, -5, 5}]Next Žgure out where z is zero:Solve[z[x] == 0, x]{{x -> -2*I}, {x -> 2*I}}It¹s never zero for real x, but is it positive, or negative?z[0]4Look at the plot, just for fun:Plot[{z[x]}, {x, -4, 1}]z is positive for all x (but only the interval [-4,1] MATTERS). Thevolume you want, therefore, isIntegrate[z[x]*(y1[x] - y2[x]), {x, -4, 1}]625/4or:g[x_] = Integrate[z[x]*(y1[x] - y2[x]), x]g[1] - g[-4]16*x - 6*x^2 - (3*x^4)/4 - x^5/5625/4Bobby Treat-----Original Message-----Sender: steve@smc.vnet.netApproved: Steven M. Christensen , Moderator====>-----Original Message----->Sent: Wednesday, September 04, 2002 8:56 AM>previous output?>>What is a efŽcient way to use output expression to deŽne new >function. PeterPeter,I¹d say none,... Œcause look atIn[1]:= y = x^2Out[1]= x^2In[2]:= f1[x_] = Out[1]Out[2]= x^2In[3]:= f2[x_] := Out[1]In[4]:= x = 5Out[4]= 5In[5]:= f3[x_] = Out[1]Out[5]= 25In[6]:= Block[{x}, f4[x_] = Out[1]]Out[6]= 25In[7]:= Block[{x}, f5[x_] := Out[1]]In[9]:= f6[x_] = yOut[9]= 25In[10]:= Block[{x}, f7[x_] = y]Out[10]= 25In[11]:= f8[x_] := yIn[12]:=Through[{f1, f2, f3, f4, f5, f6, f7, f8}[#]] & /@ {0, 1}Out[12]= {{0, 25, 25, 0, 25, 25, 0, 25}, {1, 25, 25, 1, 25, 25, 1, 25}}In[13]:= Block[{x}, f9[x_] = Out[1]]Out[13]= %1In[14]:=Through[{f1, f2, f3, f4, f5, f6, f7, f8, f9}[#]] & /@ {0, 1}Out[14]= {{0, %1, 25, 0, %1, 25, 0, 25, %1}, {1, %1, 25, 1, %1, 25, 1, 25, %1}}f1, f4 and f7 come out right, but f1 is based on the condition that thepattern variables of the expression have not been redeŽned, and f4 is onlycorrect if the history is remembered well. So what rests is f7, but thatwasn¹t you question.--Hartmut Wolf====If we are in the business of giving good links to Doppler demonstrations,here is another one (freeware):http://www.phy.ntnu.edu.tw/java/Doppler/ Doppler.htmlFor anyone interested in good Java implementations of physics phenomena,NTNU Virtual Physics Laboratory athttp://www.phy.ntnu.edu.tw/java/index.html is a treasure chest.This is not Mathematica stuff (as far as I know), but might be of interestto several Mathgroup readers.Ingolf DahlChalmers UniversitySwedenf9aid@fy.chalmers.se-----Original Message-----Sender: steve@smc.vnet.netApproved: Steven M. Christensen , Moderator====My main application for this is in drawing a piece of a plane at a pointnormal to a vector. For me, efŽciency is not an important criterion. But Iwant orthogonal vectors so the plane will be composed of squares and notdiamonds. I want unit vectors so that I can easily specify the size of thepiece I am drawing.I posted a summary last evening and it doesn¹t seem to have appeared today.In any case, I have realized that none of the routines really require theLinearAlgebra`Orthogonalization package, and run faster without it. I havemodiŽed the original routines to use a pure function instead of Normalizeor GramSchmidt.Here is a summary of the responses so far. The timings were done with thefollowing exact vector. They are faster with a machine precision vector.vtest = {1, 2, 1};__________________________________________________________ Hugh Goyder...The original routine wasOrthogonalUnitVectors[v : {_, _, _}] := GramSchmidt[NullSpace[{v}]]but I changed it toOrthogonalUnitVectors[v : {_, _, _}] := #/Sqrt[#.#] & /@ NullSpace[{v}]OrthogonalUnitVectors[vtest]{{-(1/Sqrt[2]), 0, 1/Sqrt[2]}, {-(1/Sqrt[3]), 1/Sqrt[3], -(1/Sqrt[3])}}Do[OrthogonalUnitVectors[vtest], {10000}] // Timing{2.53 Second, Null}This appears to be the shortest and fastest routine. I would give it theprize for elegance. It is certainly easy to remember.____________________________________________________ ____Ingolf Dahl...OrthogonalUnitVectors[v:{_, _, _}] := (#1/Sqrt[#1 . #1] & ) /@ NullSpace[{v, {0, 0, 0}, {0, 0, 0}}]OrthogonalUnitVectors[vtest]{{-(1/Sqrt[2]), 0, 1/Sqrt[2]}, {-(2/Sqrt[5]), 1/Sqrt[5], 0}}Do[OrthogonalUnitVectors[vtest], {10000}] // Timing{2.59 Second, Null}This is really the same as Hugh Goyder¹s routine. It isn¹t necessary to addthe zero rows to the matrix. NullSpace automatically does it.________________________________________________________ Selwyn Hollis...OrthogonalUnitVectors[v : {_, _, _}] := Module[{u, w}, u = Which[(w = {0, v[[3]], -v[[2]]}).w != 0, w, (w = {v[[3]], 0, -v[[1]]}).w != 0, w, (w = {v[[2]], -v[[1]], 0}).w != 0, w, True, Return[$Failed]]; #/Sqrt[#.#] & /@ {u, Cross[u, v]} ]OrthogonalUnitVectors[vtest]{{0, 1/Sqrt[5], -(2/Sqrt[5])}, {Sqrt[5/6], -Sqrt[2/15], -(1/Sqrt[30])}}Do[OrthogonalUnitVectors[vtest], {10000}] // Timing{11.92 Second, Null}I wish I understood the reason for using rows of the v Cross matrix as testvectors. It does have the advantage that a dot product is used to give ascalar test for zero. Why not...OrthogonalUnitVectors[v : {_, _, _}] := Module[{u, w}, u = Which[(w = {1, 0, 0})[Cross]v != {0, 0, 0}, w, (w = {0, 1, 0})[Cross]v != {0, 0, 0}, w, True, Return[$Failed]]; #/Sqrt[#.#] & /@ {u, Cross[u, v]} ]OrthogonalUnitVectors[vtest]{{1, 0, 0}, {0, -(1/Sqrt[5]), 2/Sqrt[5]}}Do[OrthogonalUnitVectors[vtest], {10000}] // Timing{10.33 Second, Null}________________________________________________________ ____John Browne...OrthogonalUnitVectors[v : {_, _, _}] := Module[{r, v1, v2}, r = {Random[], Random[], Random[]}; v1 = Cross[v, r]; v2 = Cross[v1, v]; {v1/Sqrt[Dot[v1, v1]], v2/Sqrt[Dot[v2, v2]]}]OrthogonalUnitVectors[vtest]{{0.26601, -0.534209, 0.802408}, {-0.873254, 0.218984, 0.435286}}Do[OrthogonalUnitVectors[vtest], {10000}] // Timing{9.17 Second, Null}This has the problem that the r vector might be parallel to v. But in 100000test cases it never happened.____________________________________________________ ________Daniel Lichblau...(Daniel left out the normalization, which I added.)OrthogonalUnitVectors[v:{_, _, _}] := With[{vecs = NullSpace[{v}]}, (#1/Sqrt[#1 . #1] & ) /@ {vecs[[1]], vecs[[2]] - vecs[[2]] . vecs[[1]]*vecs[[1]]}]OrthogonalUnitVectors[vtest]{{-(1/Sqrt[2 ]), 0, 1/Sqrt[2]}, {0, 1/Sqrt[5], -(2/Sqrt[5])}}Do[OrthogonalUnitVectors[vtest], {10000}] // Timing{3.35 Second, Null}________________________________________________________ ______Garry HelzerOrthogonalVectors[v : {a1_, a2_, a3_}] := With[{w = First[Sort[{{a2, -a1, 0}, {a3, 0, -a1}, {0, a3, -a2}}, OrderedQ[{Plus @@ Abs[#2], Plus @@ Abs[#1]}] &]]}, {w, Cross[v, w]} ]OrthogonalUnitVectors[vtest]{{-(1/Sqrt[2]), 0, 1/Sqrt[2]}, {-(2/Sqrt[5]), 1/Sqrt[5], 0}}Do[OrthogonalUnitVectors[vtest], {10000}] // Timing{2.64 Second, Null}________________________________________________________ __________Tom BurtonA nice feature of the following simple scheme is that you know that the twopoints of discontinuity are where r and -r cross the unit sphere.triad[u_, r_:{1, 0, 0}] := Module[{v = Cross[u, r]}, #/Sqrt[# . #] & /@{u, v, Cross[u, v]}]triad[vtest]{{1/Sqrt[6], Sqrt[2/3], 1/Sqrt[6]}, {0, 1/Sqrt[5], -(2/Sqrt[5])}, {-Sqrt[5/6], Sqrt[2/15], 1/Sqrt[30]}}Do[triad[vtest], {10000}] // Timing{17.02 Second, Null}David Parkdjmp@earthlink.nethttp://home.earthlink.net/~djmp/djmp@ earthlink.nethttp://home.earthlink.net/~djmp/====CeZaR,Sort of confused about what you really wanted. If you have forgotten toassign x = ? then you can do the following,Clear[x, eq, m, l]eq = m x^2 + 2(m + 1)x + m + 2l = {};x = 1;For[i = -30, i < 30, i++, AppendTo[l, eq /. m -> i]]ListPlot[l]But if you really intend to make a list of quadratics and then plot theresults for each of the quadratics then you can try the followingClear[x, eq, m, l]eq = m x^2 + 2(m + 1)x + m + 2;l = {};For[i = -30, i < 30, i++, AppendTo[l, eq /. m -> i]];test = Table[l[[i]], {i, 1, Length[l], 1}, {x, -50, 50}];MultipleListPlot[test[[5]], test[[10]], test[[15]], test[[20]],test[[25]], test[[30]], test[[35]], test[[40]], test[[45]], test[[50]], test[[55]], test[[60]], PlotJoined -> True, SymbolShape -> None, ImageSize -> 500 ]Essentially your For loop generates a list of quadratics if x is left out.Yas I want to do these operations: eq = m x^2 + 2(m + 1)x + m + 2> l = {}> For[i = -30, i < 30, i++, AppendTo[l, eq /. m -> i]]> Plot[l, {x, -50, 50}] but i get this error:> l is not a machine-size real number at x = -49.99999583333334 Can someone exaplain to me what i am doing wrong here??> CeZaR====Plot[l // Evaluate, {x, -30, 30}, Frame -> True];CeZaR====> I want to get some F and R such that:> F[n,p] + R[n,p] = Sum[Binomial[n,k] p^(n-k) (1-p)^k, {k, 0, Floor[n/2] - 1}],> when F[n,p] is an approximation to the sum and the R is the remaining error.> Constantine.> >>I¹m looking for a way of Žnding the approximation for partitial binomial>>sum.>>I¹ll be pleasant for any hint..> [...]> OfŽce: Taub 411You can get a closed form in terms of special functions if you splitinto two cases depending on whether n is even or odd.In[39]:= n = 2*m;In[40]:= InputForm[Sum[Binomial[n,k]*p^(n-k)*(1-p)^k, {k,0,m-1}]]Out[40]//InputForm=p^(2*m)*((p^(-1))^(2*m) - ((-4 + 4/p)^m*Gamma[1/2 + m]* Hypergeometric2F1[1, -m, 1 + m, (-1 + p)/p])/(Sqrt[Pi]*Gamma[1 +m]))In[41]:= n = 2*m+1;In[42]:= InputForm[Sum[Binomial[n,k]*p^(n-k)*(1-p)^k, {k,0,m-1}]]Out[42]//InputForm=p^(1 + 2*m)*((p^(-1))^(1 + 2*m) - (2^(1 + 2*m)*(-1 + p^(-1))^m*Gamma[3/2+ m]* Hypergeometric2F1[1, -1 - m, 1 + m, (-1 + p)/p])/(Sqrt[Pi]*Gamma[2 +m]))Daniel LichtblauWolfram Research====I want to get some F and R such that:F[n,p] + R[n,p] = Sum[Binomial[n,k] p^(n-k) (1-p)^k, {k, 0, Floor[n/2] - 1}],when F[n,p] is an approximation to the sum and the R is the remaining error.Constantine.>>I¹m looking for a way of Žnding the approximation for partitial binomial >>sum.>>I¹ll be pleasant for any hint..>Use the standard add-on package Statistics`NonlinearFit` to do a >NonlinearFit to whatever model you want to use for the approximation.>Bob Hanlon>Chantilly, VA USAConstantine ElsterComputer Science Dept.Technion I.I.T.OfŽce: Taub 411====Constantine,If you break your problem up into two cases, even n and odd n, thenMathematica can sum up your problem and get results, albeit withhypergeometric functions. Consider the following (make sure you look at thiswith a Žxed font):In[21]:=evenans = Sum[Binomial[2*n, k]*p^(2*n - k)*(1 - p)^k, {k, 0, n - 1}];In[22]:=PowerExpand[FunctionExpand[FullSimplify[evenans, n [Element] Integers]]]Out[22]= 2 n n n 1 p - 1 2 (1 - p) p Gamma[n + -] Hypergeometric2F1[1, -n, n + 1, -----] 2 p1 - ------------------------------------------------------------- ------- Sqrt[Pi] Gamma[n + 1]In[23]:=oddans = Sum[Binomial[2*n + 1, k]*p^(2*n + 1 - k)*(1 - p)^k, {k, 0, n - 1}];In[24]:=PowerExpand[FunctionExpand[FullSimplify[oddans, n [Element] Integers]]]Out[24]= 2 n + 1 n n + 1 3p - 1 2 (1 - p) p Gamma[n + -] Hypergeometric2F1[1, -n - 1, n +1, -----] 2p1 - ------------------------------------------------------------- ------------------- Sqrt[Pi] Gamma[n + 2]Is this what you were looking for?Carl WollPhysics DeptU of Washington> I want to get some F and R such that: F[n,p] + R[n,p] = Sum[Binomial[n,k] p^(n-k) (1-p)^k, {k, 0, Floor[n/2] -1}],> when F[n,p] is an approximation to the sum and the R is the remainingerror. Constantine.> >>I¹m looking for a way of Žnding the approximation for partitialbinomial>>sum.>>I¹ll be pleasant for any hint..> >Use the standard add-on package Statistics`NonlinearFit` to do a>NonlinearFit to whatever model you want to use for the approximation.> >Bob Hanlon>Chantilly, VA USA Constantine Elster> Computer Science Dept.> Technion I.I.T.> OfŽce: Taub 411====>I want to do these operations:>>eq = m x^2 + 2(m + 1)x + m + 2>l = {}>For[i = -30, i < 30, i++, AppendTo[l, eq /. m -> i]]>Plot[l, {x, -50, 50}]>>but i get this error:>l is not a machine-size real number at x = -49.99999583333334>>Can someone exaplain to me what i am doing wrong here??>eq = m x^2 + 2(m + 1)x + m + 2;l = {};For[i = -30, i < 30, i++, AppendTo[l, eq /. m -> i]];It would be more straightforward and efŽcient to deŽne the list using Tablel == Table[eq, {m, -30, 29}]TrueTo Plot, use EvaluatePlot[Evaluate[l], {x, -50, 50}];Bob Hanlon====>What is a efŽcient way to use output expression to deŽne new function.Use the menu command Input/Copy Output from Aboveor use % (Out)Bob Hanlon====>-----Original Message----->Sent: Wednesday, September 04, 2002 8:57 AM>The problem is that I do not think there is any bounded 3d body >described by your conditions. Anyway, this is how you can use >Mathematica (in general) to solve this sort of problem.>You need two packages:>>In[1]:=><>In[2]:=><< Calculus`Integration`>To see your object use:>InequalityPlot3D[y > 3x && y < 4 - x^2 && z < x^2 + 4, {x}, {y}, {z}]>>However, you will just get some error messages and a picture >that looks >two dimensional. If you wanted the volume, evaluate:>>In[3]:=>Integrate[Boole[y>3x&&y<4-x^2&&z>Out[3]=>-InŽnity>>If you impose some limits on z you will get a Žnite positive answer, >but one that clearly is unbounded:>>In[20]:=>NIntegrate[Boole[y>3x&&y<4-x^2&&z>Out[20]=>2239.58>>In[21]:=>NIntegrate [Boole[y>3x&&y<4-x^2&&z>Out[ 21]=>20989.6>>Andrzej Sorry, I must have something missing in my previous description. I need to Žnd out the volumn of a 3D object which form by the > equation :> z=x^2 +4 (as bottom surface)> and on the xy plane which bounded by a parabola y=4-x^2 and >y=3x line. How would I use Mathematica to plot out this 3D object or >Žnd out its > volumn with only the equation given? Shz Shz> Andrzej Kozlowski 3/September/2002 04:33pm Mathematica could do this sort of thing if there were a three> dimensional object described by your equations (as boundaries) but> there isn¹t one. More precisely, the pair of equations {z=x^2 +4,> y=4-x^2} describes a parabola in three space which you can >plot with: g1=ParametricPlot3D[{x, 4 - x^2, x^2 + 4}, {x, -5, 5}] The equation y=3x describes the plane: g2 = ParametricPlot3D[{x, 3x, z}, {x, -5, 5}, {z, -25, 25}]> You can see the two together in> < Show[{g1,g2}] There are clearly two points of intersection. They can be found with:> Solve[{z == x^2 + 4, y == 4 - x^2, y == 3*x}, {x, y, z}]> {{z -> 5, y -> 3, x -> 1}, {z -> 20, y -> -12, x -> -4}} So where is the 3D object whose volume you want to Žnd? Andrzej Kozlowski> Toyama International University> JAPAN Can I use Mathematica to Žnd out the volumn of this 3 dimensional> object from> the equations :>> z=x^2 +4, y=4-x^2, y=3x> Shz Shz >Shz Shz,as Andrzej having said everything about the calculation of the volume, andas still your speciŽcation is incomplete, I¹m going to show how you canplot at least all you have (communicated).As you said something obout thebottom -- which direction isup? --assuming positive z-direction the I come to the inequalities: y >= 3 x, y <= 4 -x^2, z >= 4 + x^2and arbitrarily, to make the example complete I¹ll show only parts with z < 20but do not complete the shape.To begin building the graphics we draw the boundary surfaces:[1] the bottom{xmin, xmax} = x /. NSolve[4 - x^2 == 3x, {x}]{-4., 1.}Plot[{4 - x^2, 3x}, {x, xmin, xmax}]{ymin, ymax} = {3 xmin, 4}g3 = Graphics3D[Plot3D[x^2 + 4, {x, xmin, xmax}, {y, ymin, ymax}]][2] the wallsg = ParametricPlot3D[{{x, 4 - x^2, z}, {x, 3x, z}}, {x, xmin, xmax}, {z, 0, 20}]One idea now would be to exploit the Mathematica rendering algorithm, to cutoff the undesired parts of the boundary surfaces:gg = Show[g3, g, PolygonIntersections -> False][Epsilon] = 1. 10^-4g4 = gg /. Line[_] -> {} /. p : Polygon[pts_] :> If[Or @@ (#2 > 4 - #1^2 + [Epsilon] || #2 < 3 #1 - [Epsilon] || #3 < #1^2 + 4 - [Epsilon] &) @@@ pts, {}, p]Show[g4 /. Line[_] -> {}, BoxRatios -> {1, 1, .5}, ViewPoint -> {1.3, -2.4, 5}]But alas! The edges are rather gnawed off. Increasing epsilon doesn¹t help,unwanted parts will show up and still some polygons are nibbled away.So we have to do it ourselves:We deŽnetag[inequality_][p_] := Block[{x, y, z}, {x, y, z} = p; If[inequality, {p, inside}, {p, outside}]]...tags points whether inside ore outside.sol[equality_, {p1_, _}, {p2_, _}] := Block[{p, d, x, y, z}, {x, y, z} = p = p1 (1 - d) + p2 d; First[Cases[Solve[equality, d], s_ /; NonNegative[d /. s] :> (p /. s)]] ]...computes the cut on the line between to points of opposite sides.sep[equality_][pp1_, pp2_] := If[pp1[[2]] === pp2[[2]], {pp1}, ppx = sol[equality, pp1, pp2]; {pp1, {ppx, pp1[[2]]}, {ppx, pp2[[2]]}}]...effectively cuts a segment crossing the border into two pieces.cutGraphics3D[g_, inequality_] := Module[{equality = Equal @@ inequality}, g /. Polygon[pts_] :> Block[{tagpts = tag[inequality] /@ pts}, With[{t = sep[equality] @@@ Transpose[{tagpts, RotateLeft[tagpts]}]}, With[{newpts = Cases[t, {p_, label_} /; label == inside :> p,2]}, If[Length[newpts] > 2, Polygon[newpts], {}]] ]]]...Polygons crossing a border are cut, only those inside are kept.We Žrst cut the bottom...g3new = Fold[cutGraphics3D, g3, {y >= 3x, y <= 4 - x^2}]...next the sides...gnew = cutGraphics3D[g, z >= 4 + x^2]...and display:Show[gnew, g3new, BoxRatios -> {1, 1, .5}, ViewPoint -> {1.3, -2.4, 5}]Show[gnew, g3new, BoxRatios -> {1, 1, .5}, ViewPoint -> {1.3, -2.4, 15}]Show[gnew, g3new, BoxRatios -> {1, 1, .5}, ViewPoint -> {1.3, -2.4, -2}]Show[gnew, g3new, BoxRatios -> {1, 1, .5}, ViewPoint -> {1.3, 2.5, 2}]Here I have brought a method, I had already posted twice, to a more handyform.To make that reminiscence complete, we could also deŽne a coloring functioncolorGraphics3D[g_, inequality_, colorinside_, coloroutside_] := Module[{equality = Equal @@ inequality}, g /. Polygon[pts_] :> Block[{tagpts = tag[inequality] /@ pts}, With[{t = sep[equality] @@@ Transpose[{tagpts, RotateLeft[tagpts]}]}, {With[{newpts = Cases[t, {p_, label_} /; label == outside :> p, 2]}, If[Length[newpts] > 2,{FaceForm[SurfaceColor[coloroutside]], Polygon[newpts]}, {}]], With[{newpts = Cases[t, {p_, label_} /; label == inside :> p, 2]}, If[Length[newpts] > 2, {FaceForm[SurfaceColor[colorinside]], Polygon[newpts]}, {}]]} ]]]and with...g3D = Graphics3D[Plot3D[E^(-(x^2/2) - y^2/2)/(2*Pi) , {x, -2, 2}, {y, -2,2}]]Show[colorGraphics3D[g3D, With[{e = Take[{x, y, z}, 2] - {0.8, -0.5}}, e.e] <= 1, Hue[0, 0.3, 1], Hue[0.6, 0.3, 1]]]--Hartmut Wolf====This result seems to me to be wrong (it¹s right?):In[1]:=Integrate[Sqrt[a^2*Cos[t]^2 + b^2*Sin[t]^2], {t, 0, 2*Pi}, Assumptions->{Im[a]==0, Im[b]==0}]Out[1]=0....but written in another way, it¹s right:In[2]:=Integrate[Sqrt[a^2 + (b^2 - a^2)*Sin[t]^2], {t, 0, 2*Pi}, Assumptions -> {Im[a] == 0, Im[b] == 0}]Out[2]=If[a^2/(-a^2 + b^2) >= 0 || b^2/(-a^2 + b^2) <= 0 || Im[a^2/(-a^2 + b^2)] != 0, (4*a^2*Sqrt[-1 + b^2/a^2]*EllipticE[ 1 - b^2/a^2])/Sqrt[-a^2 + b^2], Integrate[Sqrt[a^2 + (-a^2 + b^2)*Sin[t]^2], {t, 0, 2*Pi}]]Someone can explane me this difference?Raf.====involved Bessel equations(electro-magnetic Želd in coaxial) but when I initialize and calculate that2 eqs for the 2nd or 3rd time, Œcause I changed some parameters, I see astrangeRemoved[n] instead of the value ofn (=0).I use the line Remove[Global`*];at the beginning to clear any variable and I think it could be the problem.So, have I always to quit and restart the program in order to recalculatethat equations?Filippo Sola====Can someone provide me more information on how ListIntegrate worksthan what is contained in the version 4 manual ? Is there a websiteperhaps or tutorial ?I would like to know how the beginning and end of a list of {x,y}pairs that is being integrated is dealt with by ListIntegrate.I know a series of polynomials is somehow used but how ? Do theseoverlap ? Are they piecewise continuous ?Are these polynomials available for inspection ? How do they change asa function ofk ?optimumk value for a given list ? For any given list, will accuracymonotonically increase with increasing values ofk ? Is thereanything in the Option Inspector that could cause unexpected behaivorwith ListIntegrate ?Are there any good rules of thumb or procedures that will help ensurea reasonable answer is produced ?Is there a way of estimating the error or accuracy of integrationperformed by ListIntegrate ?====Be sure to note the following and what comes after it near the end ofthe Help Browser info on ListIntegrate:``This package has been included for compatibility with previousversions of Mathematica. The functionality of this package has beensuperseded by improvements made to InterpolatingFunction.In other words, ListIntegrate is a dinosaur that you don¹t need at all!To integrate a list of data with Mathematica, one can proceed in eitherof two ways: (1) Construct an interpolating function and use NIntegrate (or, better, NIntegrateInterpolatingFunction) on that (which is whatListIntegrate apparently does); or (2) apply a simple routine thatimplements the trapezoidal rule, Simpson¹s rule, or maybe some higherorder method.Assuming you¹ve chosen to take path #1, you need to realize the following:(a) NIntegrate[Interpolation[data, InterpolationOrder->1][x], {x,a,b}]is equivalent to the trapezoidal rule;(b) NIntegrate[Interpolation[data, InterpolationOrder->2][x], {x,a,b}]is *not* equivalent to Simpson¹s rule (because of the peculiar way thatInterpolation works);(c) Interpolation[data, InterpolationOrder->k] generally does not returna smooth function unless you set InterpolationOrder->n-1, where n is thenumber of data points, which is the case where a single polynomial ofdegree n-1 Žts the data points.(d) If you want to integrate a smooth interpolant, you can do this: <k][x], {x, 0, 5}, PlotRange -> All], {k, 1, 6}](The last of those plots will give a warning message.)Having said all that, you really should consider path #2 instead. Hereare a couple of links to a MathGroup discussion of last July (somehowthe thread got split up):http://library.wolfram.com/mathgroup/archive/2002/Jul/ msg00490.htmlhttp://library.wolfram.com/mathgroup/archive/ 2002/Jul/msg00519.htmlI hope all this helps some.----Selwyn Hollis > Can someone provide me more information on how ListIntegrate works > than what is contained in the version 4 manual ? Is there a website > perhaps or tutorial ? > I would like to know how the beginning and end of a list of {x,y} > pairs that is being integrated is dealt with by ListIntegrate. > I know a series of polynomials is somehow used but how ? Do these > overlap ? Are they piecewise continuous ? > Are these polynomials available for inspection ? How do they change as > a function ofk ? > optimumk value for a given list ? For any given list, will accuracy > monotonically increase with increasing values ofk ? Is there > anything in the Option Inspector that could cause unexpected behaivor > with ListIntegrate ? > Are there any good rules of thumb or procedures that will help ensure > a reasonable answer is produced ? > Is there a way of estimating the error or accuracy of integration > performed by ListIntegrate ? >====I timed Daniel¹s three solutions and Gary¹s one (plus a couple of my owna little later):perps1[v_] := If[v[[1]] == v[[2]] == 0, {{1, 0, 0}, {0, 1, 0}}, {{v[[2]], -v[[ 1]], 0}, Cross[v, {v[[2]], -v[[1]], 0}]}]perps2[v_] := With[{vecs = NullSpace[{v}]}, {vecs[[ 1]], vecs[[2]] - (vecs[[2]].vecs[[1]])*vecs[[1]]}]perps2C = Compile[{{v, _Real, 1}}, Module[{vecs = NullSpace[{v}]}, { vecs[[1]], vecs[[2]] - (vecs[[2]].vecs[[1]])*vecs[[1]]}]]helzer[v : {a1_, a2_, a3_}] := With[{w = First[Sort[{{a2, -a1, 0}, {a3, 0, -a1}, {0, a3, -a2}}, OrderedQ[{Plus @@ Abs[#2], Plus @@Abs[#1]}] &]]}, {w, Cross[v, w]}]vecs = Table[Random[], {10000}, {3}];Timing[perps1 /@ vecs; ]Timing[perps2 /@ vecs; ]Timing[perps2c /@ vecs; ]Timing[helzer /@ vecs; ]{1.7350000000000012*Second, Null}{0.5619999999999994*Second, Null}{0.219 Second, Null}{2.7349999999999994*Second, Null}I made a small change to Daniel¹s perps1, and got a solution as fast asperps2c, WITHOUT compiling. Compiling tripled the speed again, sotreatC is the fastest solution I¹ve seen so far.treat[{a_, b_, c_}] := If[a == b == 0, {{1, 0, 0}, {0, 1, 0}}, {{b, -a, 0}, {a*c, b*c, -a^2 -b^2}}]treatC = Compile[{{v, _Real, 1}}, If[v[[1]] == v[[2]] == 0, {{1, 0, 0}, {0, 1, 0}}, {{v[[2]], -v[[1]], 0}, {v[[1]]*v[[3]], v[[2]]*v[[3]], -v[[1]]^2 - v[[2]]^2}}]]vecs = Table[Random[], {10000}, {3}];Timing[perps2c /@ vecs; ]Timing[helzer /@ vecs; ]Timing[treat /@ vecs; ]Timing[treatC /@ vecs;]{0.2190000000000083*Second, Null}{2.7339999999999947*Second, Null}{0.25*Second, Null}{0.07800000000000296*Second, Null}None of these solutions reliably return normalized vectors.Bobby Treat-----Original Message-----> pose the problem to MathGroup. Who has the most elegant Mathematica> routine...> OrthogonalUnitVectors::usage =OrthogonalUnitVectors[v:{_,_,_}] willreturn> two unit vectors orthogonal to each other and to v.> You can assume that v is nonzero.> David Park> djmp@earthlink.net> http://home.earthlink.net/~djmp/Some possibilities:perps1[v_] := If [v[[1]]==v[[2]]==0, {{1,0,0},{0,1,0}}, {{v[[2]],-v[[1]],0}, Cross[v,{v[[2]],-v[[1]],0}]} ]perps2[v_] := With[{vecs=NullSpace[{v}]}, {vecs[[1]], vecs[[2]] - (vecs[[2]].vecs[[1]])*vecs[[1]]} ]This appears to be 2-3 times faster than perps1 for vectors of machinereals. I get another factor of 2 using Compile, which is appropriate fore.g. graphics use.perps2C = Compile[{{v,_Real,1}}, Module[{vecs=NullSpace[{v}]}, {vecs[[1]], vecs[[2]] - (vecs[[2]].vecs[[1]])*vecs[[1]]} ]]In[61]:= vecs = Table[Random[], {10000}, {3}];In[62]:= Timing[p2 = Map[perps1C,vecs];]Out[62]= {0.49 Second, Null}This is on a 1.5 GHz processor.Daniel LichtblauWolfram Research====>I was wondering if there is a method for resizing Raster graphics>(resizing the actual matrix of pixels, not just the display size). I>am processing a large number of JPEG images, and we sometimes need to>reduce the image size to allow data processing algorithms to function>without running out of memory. In the past we simply used a program>such as Photoshop to resize them before importing them into>Mathematica. Due to the number of images we are processing now this>is very inconvenient and it would be very useful if there was a method>for accomplishing it in Mathematica, but I can¹t Žnd one. I also>thought about doing something simple like sampling every few pixels or>averaging, but I thought there might be a method with more efŽcacy>than this. I also tried exporting the graphics with the Export command>as new JPEGs and manipulating the ImageResolution and ImageSize>options but this seemed to have no effect. Any help would be much>appreciated.>Aaron UrbasIn 4.2, the following should work (as long as you deŽne newsize).in = Import[Žle.jpg];Export[newŽle.jpg, in, ImageSize->newsize]In 4.1 and earlier, this will not work because an optimization interfereswith the ImageSize and rasters are written out with the raster size, notthe ImageSize. There is a ConversionOption to force the behavior you want.in = Import[Žle.jpg];Export[newŽle.jpg, Show[in, ImageSize->newsize], ConversionOptions->{RasterExport->Graphics}]-Dale==== Borrowing liberally from Daniel, I like the following:ClearAll[sumBin, sumBinOdd, sumBinEven, index]sumBinOdd = Sum[Binomial[2index + 1, k]*p^(2index + 1 - k)*(1 - p)^k, { k, 0, index - 1}];sumBinEven = Sum[Binomial[2index, k]* p^(2index - k)*(1 - p)^k, {k, 0, index - 1}];sumBin[n_, Odd] = sumBinOdd /. {index -> (n - 1)/2};sumBin[n_, Even] = sumBinEven /. {index -> n/2};sumBin[n_?EvenQ] = sumBin[n, Even];sumBin[n_?OddQ] = sumBin[n, Odd];It allows you to see the solution symbolically for both odd and even n,and also to calculate it when n is a known integer. We also have theopportunity, for instance, to assume that 3x is even and calculatesumBin[3x, Even]p^(3*x)*((1/p)^(3*x) - ((-4 + 4/p)^((3*x)/2)* Gamma[1/2 + (3*x)/2]*Hypergeometric2F1[1, -((3*x)/2), 1 + (3*x)/2, (-1 + p)/p])/(Sqrt[Pi]*Gamma[1 +(3*x)/2]))or assume 3x is odd and calculatesumBin[3*x, Odd]p^(3*x)*((1/p)^(3*x) - (2^(3*x)*(-1 + 1/p)^((1/2)*(-1 + 3*x))* Gamma[3/2 + (1/2)*(-1 + 3*x)]*Hypergeometric2F1[1, -1 + (1/2)*(1 - 3*x), 1 + (1/2)*(-1 + 3*x), (-1 +p)/p])/(Sqrt[Pi]* Gamma[2 + (1/2)*(-1 + 3*x)]))Bobby Treat-----Original Message-----> when F[n,p] is an approximation to the sum and the R is the remainingerror.> Constantine.>In a message dated 8/28/02 4:44:13 AM, celster@cs.technion.ac.il> >>I¹m looking for a way of Žnding the approximation for partitialbinomial>>sum.>>I¹ll be pleasant for any hint..> [...]> OfŽce: Taub 411You can get a closed form in terms of special functions if you splitinto two cases depending on whether n is even or odd.In[39]:= n = 2*m;In[40]:= InputForm[Sum[Binomial[n,k]*p^(n-k)*(1-p)^k, {k,0,m-1}]]Out[40]//InputForm=p^(2*m)*((p^(-1))^(2*m) - ((-4 + 4/p)^m*Gamma[1/2 + m]* Hypergeometric2F1[1, -m, 1 + m, (-1 + p)/p])/(Sqrt[Pi]*Gamma[1 +m]))In[41]:= n = 2*m+1;In[42]:= InputForm[Sum[Binomial[n,k]*p^(n-k)*(1-p)^k, {k,0,m-1}]]Out[42]//InputForm=p^(1 + 2*m)*((p^(-1))^(1 + 2*m) - (2^(1 + 2*m)*(-1 + p^(-1))^m*Gamma[3/2+ m]* Hypergeometric2F1[1, -1 - m, 1 + m, (-1 + p)/p])/(Sqrt[Pi]*Gamma[2 +m]))Daniel LichtblauWolfram Research====I¹ve found that Mathematica 4.2 takes too long to Žnish to generate Žrsttime help browser. Is this normal? How many time should it take?Calimero====Please excuse me if this has been discussed before; I haven¹t beenmonitoring the group very much.A long time ago I posted to this group as well as to Wolfram about theerrors in many or all functions involving Fourier transforms when valuesof FourierParameters other than the default values are used. The groupresponded that indeed there was a problem so I¹m wondering if it wasever Žxed. My version (then and now) is 4.0.1 for Macintosh.Jerry====Could you help me?I¹m to solve heat conductivity equation (Laplasequation) - partial differential equation. Are thereany ready-to-use packages that will help me do the job?Standard functionDSolve cannot! And so do functionsfrom packageCalculus`DSolveIntegrals`.More info: the space where the equation is to besolved is cylindre (not inŽnite). Andrew.==== When I multiply an expression with 0 it is giving 0.expression whichis creating problem in the further calculation.eg.In[1]:=func1[r_]:=Exp[-r/2]In[2]:coeff[[1,1]]= 0.0;;;In[34]:=func1[r]coeff[[1,1]]Out[34]:=0.Exp[-r/2]I want anything to be multiply by zero must be zero. How can I do that?Your suggestion will be highly appreciated. Raj====> When I multiply an expression with 0 it is giving 0.expression which> is creating problem in the further calculation.No. Your trouble comes when you multiply an expression by thežoating-point number 0.0, rather than by the precise symbolic 0 (having nodecimal point). Merely make the coefŽcient 0 (rather than 0.0) andeverything should work as you wish.David> eg. In[1]:=func1[r_]:=Exp[-r/2]> In[2]:coeff[[1,1]]=0.0;> ;> ;> In[34]:=func1[r]coeff[[1,1]] Out[34]:=0.Exp[-r/2] I want anything to be multiply by zero must be zero. How can I do that?-- -------------------- http://NewsReader.Com/ -------------------- Usenet Newsgroup ServiceReply-To: kuska@informatik.uni-leipzig.de====Unprotect[Times]Times[0., __] := 0Protect[Times] Jens> When I multiply an expression with 0 it is giving 0.expression which> is creating problem in the further calculation.> eg.> In[1]:=func1[r_]:=Exp[-r/2]> In[2]:coeff[[1,1]]=0.0;> ;> ;> In[34]:=func1[r]coeff[[1,1]]> Out[34]:=0.Exp[-r/2]> I want anything to be multiply by zero must be zero.> How can I do that?> Your suggestion will be highly appreciated.> Raj====Now I¹m trying to calculate this formula:Delta[eq_, x_]:=CoefŽcient[eq, x]^2 - 4 CoefŽcient[eq, x^2] CoefŽcient[eq, x^0]eq has this form a x^2 + b x + cBut there is a problem with the x^0 coefŽcient!How can I overcome that?CeZaRReply-To: kuska@informatik.uni-leipzig.de====andDelta[eq_, x_]:=CoefŽcient[eq, x]^2 - 4 CoefŽcient[eq, x,2]CoefŽcient[eq, x,0]does what you want. Because the Help-Browser say:CoefŽcient[expr, form, 0] picks out terms that are not proportional toform. Jens> Now I¹m trying to calculate this formula:> Delta[eq_, x_]:=CoefŽcient[eq, x]^2 - 4 CoefŽcient[eq, x^2] CoefŽcient[eq, x^0]> eq has this form a x^2 + b x + c> But there is a problem with the x^0 coefŽcient!> How can I overcome that?> CeZaR====I need to Žll the space between two contour lines, C1 and C2, withred color, and leave the other place white. What trick I have to use?Any suggestion and advice will be appreciated.Jun LinReply-To: kuska@informatik.uni-leipzig.de====gr = ContourPlot[x^2 + y^2, {x, -1, 1}, {y, -1, 1}, Contours -> {0.2, 0.4}, ColorFunction -> (If[# >= 0.2 && # <= 0.4, RGBColor[1, 0, 0], RGBColor[1, 1, 1]] &), ColorFunctionScaling -> False ] Jens> I need to Žll the space between two contour lines, C1 and C2, with> red color, and leave the other place white. What trick I have to use?> Any suggestion and advice will be appreciated.> Jun Lin====I am trying to Žnd an example that will demonstrate the difference between$PrePrint and $Post. I found an old thread in this news group where auser wanted to display all matrices using MatrixForm. Some users suggestedthe following: In[1]:= $Post=(#/.mtrx_?MatrixQ:>MatrixForm[mtrx]&);Then Dave Withoff said it¹s better to assign this to $PrePrint since theobjective here is to adjust the display rather than the result of thecalculation. With the assignment to $Post you could, for example, getunexpected results from calculations using %, since matrices will be wrappedin MatrixForm.--------However, if we use $Post above, the next input will compute the inversethe matrix. I did verify that Inverse can¹t take a matrix wrapped inMatrixForm. Can somebody give an example where doing this with $PrePrintinstead of $Post gives a different result. In[2]:= m={{2,3},{0,1}}; Inverse[%] Out[3]= (* Inverse of (m) in MatrixForm, not shown. *)------ Ted Ersek Get Mathematica tips, tricks from http://www.verbeia.com/mathematica/tips/Tricks.htmlReply-To: kuska@informatik.uni-leipzig.de====yo can just tryIn[]:=$Post = (# /. mtrx_?MatrixQ :> AnyHead[mtrx] &);In[]:=m = {{2, 3}, {0, 1}}In[]:=q=%;In[]:=Head[q]andIn[]:=$PrePost = (# /. mtrx_?MatrixQ :> AnyHead[mtrx] &);In[]:=m = {{2, 3}, {0, 1}}In[]:=q=%;In[]:=Head[q]But you are right -- the behaviour of MatrixForm[] in your exampleis strange. Jens> I am trying to Žnd an example that will demonstrate the difference between> $PrePrint and $Post. I found an old thread in this news group where a> user wanted to display all matrices using MatrixForm. Some users suggested> the following:> In[1]:= $Post=(#/.mtrx_?MatrixQ:>MatrixForm[mtrx]&);> Then Dave Withoff said it¹s better to assign this to $PrePrint since the> objective here is to adjust the display rather than the result of the> calculation. With the assignment to $Post you could, for example, get> unexpected results from calculations using %, since matrices will be wrapped> in MatrixForm.> --------> However, if we use $Post above, the next input will compute the inverse> the matrix. I did verify that Inverse can¹t take a matrix wrapped in> MatrixForm. Can somebody give an example where doing this with $PrePrint> instead of $Post gives a different result.> In[2]:= m={{2,3},{0,1}};> Inverse[%]> Out[3]= (* Inverse of (m) in MatrixForm, not shown. *)> ------> Ted Ersek> Get Mathematica tips, tricks from> http://www.verbeia.com/mathematica/tips/Tricks.html==== myArray is a list of triplets which look like {n,k,p}, where n and kare integers and p is real number. repetitions in n and k are allowedbut no two triplets ar the same.I deŽne a function, myfunc[n_,pthreshold_] as follows.myfunc[n_,pthreshold_] := Module[{t},t=Max[Cases[myArray, {n, k_, p_} /; (p >= pthreshold) -> p, 2]];If[t>=0,t,-1]]It prints the largest k for which p is greater than pthreshold for agiven n and-1 if there is no such k. The function does its job Žne.My problem is as follows. I would like to plot a collection of plots,myfunc[n,p], for 1<=n<=21 with respect to p. unfortunately thefollowing does not work as desired.Plot[Table[myfunc[n,p],{n,1,21}],{p,0.0,1.0}]because the Table gets evaluated to numeric value (-1) before Plot isinvoked.====I made a mistake in the deŽnition of the question. The function is correctly deŽned as myfunc[n_,pthreshold_] := Module[{t}, t=Max[Cases[myArray, {n, k_, p_} /; (p >= pthreshold) -> k, 2]]; If[t>=0,t,-1]]Please note that inserting Evaluate before Table does not workcorrectly either, because evaluating myfunc[n,p] when p is not anumber, gives -1.> Plot[Table[myfunc[n,p],{n,1,21}],{p,0.0,1.0}] > because the Table gets evaluated to numeric value (-1) before Plot is> invoked.Reply-To: kuska@informatik.uni-leipzig.de====could you supply a complete example next time ?Try myfunc[] with a more restrictive pattern andit works:myArray = Flatten[Table[{n, 1, Random[]}, {15}, {n, 1, 21}], 1];myfunc[n_, pthreshold_?NumericQ] := Module[{t}, t = Max[Cases[myArray, {n, k_, p_} /; (p >= pthreshold) -> p, 2]]; If[t >= 0, t, -1]]Plot[Evaluate[Table[myfunc[n, p], {n, 1, 21}]], {p, 0.0, 1.0}] Jens> myArray is a list of triplets which look like {n,k,p}, where n and k> are integers and p is real number. repetitions in n and k are allowed> but no two triplets ar the same.> I deŽne a function, myfunc[n_,pthreshold_] as follows.> myfunc[n_,pthreshold_] := Module[{t},> t=Max[Cases[myArray, {n, k_, p_} /; (p >= pthreshold) -> p, 2]];> If[t>=0,t,-1]]> It prints the largest k for which p is greater than pthreshold for a> given n and> -1 if there is no such k. The function does its job Žne.> My problem is as follows. I would like to plot a collection of plots,> myfunc[n,p], for 1<=n<=21 with respect to p. unfortunately the> following does not work as desired.> Plot[Table[myfunc[n,p],{n,1,21}],{p,0.0,1.0}]> because the Table gets evaluated to numeric value (-1) before Plot is> invoked.====For my PDE class we have been calculating Fourier transforms. The instructorarrived today with a printout of two plots of a certain Fourier transform,done with a different CAS. The Žrst plot was to 30 terms, the second was to120 terms. Curious, I translated the functions into Mathematica (4.0 on Windows2000on a PIII 700) to see how much time this required to process. I wasStaggered at how much time it took. Here¹s the code:L = 2;f[x_] := UnitStep[x - 1];b[n_] := (2/L)*Integrate[f[x]*Sin[n*Pi*x/L], {x, 0, L}];FS[N_, x_] := Sum[b[n]*Sin[n*Pi*x/L], {n, 1, N}];Timing[Plot[FS[30, x], {x, 0, 2}]]Out[23]={419.713 Second, [SkeletonIndicator]Graphics[SkeletonIndicator]}In this case the number of terms is 30.The time required per number of terms seems to Žt the following polynomial:y = 0.3926x^2 + 2.2379xThis is a large amount of time. I understand that the code is not optimized,and was more or less copied from the code in the other CAS, but is this areasonable amount of time, or is something going wrong? I don¹t use Mathematicabecause of the speed, but should it be this slow?Just curious,Steve Story====> I don¹t use Mathematica> because of the speed, but should it be this slow?Mathematica has become more competitive in the speed department in recentyears. See for example the attached comparison (not sent to newsgroup) byStephan Steinhaus (steinhaus-net.de). So when Mathematica takes a very longtime, you should investigate. In this case inserting Evaluate[] in twoplacesIn[91]:=b[n_] := Evaluate[(2/L)*Integrate[f[x]*Sin[n*Pi*x/L], {x, 0, L}]];....In[104]:=Timing[Plot[Evaluate[FS[120, x]], {x, 0, 2}]]Out[104]={0.18 Second,[SkeletonIndicator]Graphics[SkeletonIndicator]}speeds the process enormously (18 milliseconds to plot 120 terms on myfeeble old 500MHz PowerBook).Why was it so slow before? When I switch from an ordinary numerical languageto Mathematica, I enter into an implicit bargain withMathematica: the software will go the extra mile to get me a good answer,including (1) using exra precision (sometimes without being asked) and (2)carrying around unevaluated mathematical expressions (usually without beingasked) that could possibly be evaluated more appropriately at a later time.Most tools cannot do either of these things, so I don¹t have to worry aboutit, except for the bad answers that result now and then. But I need to takecare that Mathematica does not burden itself unnecessarily. That¹s my sideof the bargain.Number (2) is the issue here. Your deŽnition of b[n] is written so thatMathematica analytically evaluates b separately for each n. But you know inthis case that the integration can be done safely once for all n. So do it!The huge difference, though, comes from pre-evaluating the argument to Plot.Read the on-line help! You should pre-evaluate where possible. In somecases, the most common of which involve branching within the deŽnition offunction to plot, you cannot pre-evaluate so, in keeping with the bargain,Mathematica goes the extra mile and holds back just in case. You need tosteer it into the shortcut when it¹s OK.Hope this helps,Tom Burton--Reply-To: kuska@informatik.uni-leipzig.de====with your code you compute the expansion coefŽcents everytime when FS[] is evaluated. Store the values for b[n] withL = 2;f[x_] := UnitStep[x - 1];b[n_] := b[n] = (2/L)*Integrate[f[x]*Sin[n*Pi*x/L], {x, 0, L}];FS[N_, x_] := Sum[b[n]*Sin[n*Pi*x/L], {n, 1, N}];Timing[Plot[FS[30, x], {x, 0, 2}]]and you need only a 1-3 seconds (depending on your machine) Jens> For my PDE class we have been calculating Fourier transforms. The instructor> arrived today with a printout of two plots of a certain Fourier transform,> done with a different CAS. The Žrst plot was to 30 terms, the second was to> 120 terms.> Curious, I translated the functions into Mathematica (4.0 on Windows2000> on a PIII 700) to see how much time this required to process. I was> Staggered at how much time it took. Here¹s the code:> L = 2;> f[x_] := UnitStep[x - 1];> b[n_] := (2/L)*Integrate[f[x]*Sin[n*Pi*x/L], {x, 0, L}];> FS[N_, x_] := Sum[b[n]*Sin[n*Pi*x/L], {n, 1, N}];> Timing[Plot[FS[30, x], {x, 0, 2}]]> Out[23]=> {419.713 Second, [SkeletonIndicator]Graphics[SkeletonIndicator]}> In this case the number of terms is 30.> The time required per number of terms seems to Žt the following polynomial:> y = 0.3926x^2 + 2.2379x> This is a large amount of time. I understand that the code is not optimized,> and was more or less copied from the code in the other CAS, but is this a> reasonable amount of time, or is something going wrong? I don¹t use Mathematica> because of the speed, but should it be this slow?> Just curious,> Steve Story====I would like to use mathematica type papers for my math courses, butI¹m having trouble formatting documents. Despite searching, I¹ve beenunable to Žnd a complete guide to word processing with mathematica.Does anyone know where such a document could be found?====Look at in the Help browser or in the Mathematica BookStyle SheetAlso, you have the documentation included for package Author Tools(only in Mathematica 4.2).Guillermo Sanchez > I would like to use mathematica type papers for my math courses, but> I¹m having trouble formatting documents. Despite searching, I¹ve been> unable to Žnd a complete guide to word processing with mathematica.> Does anyone know where such a document could be found?====Kenny,Sympathy but no solution.I too have been trying to use Mathematica (v4.2 most recently) to typemaths papers and the like but I¹m not ready to ditch LaTeX yet. Thereare just too many cases where I cannot Žgure out how to achieve what Iwant in Mathematica, things like:- left brackets spanning multiple lines for deŽning hybrid functions;- vertical alignment of equals signs in multi-line equations orderivations;- setting typefaces in tables of material.I Žgure most of this is do-able, but I don¹t have the time, orpatience, to spend too much time on it. So, I¹ll be the Žrst customerwhen you write the guide to math publishing in Mathematica - I just hopeyou won¹t have to use LaTeX to write it.Mark Westwood> I would like to use mathematica type papers for my math courses, but> I¹m having trouble formatting documents. Despite searching, I¹ve been> unable to Žnd a complete guide to word processing with mathematica.> Does anyone know where such a document could be found?====OrthogonalUnitVectors that I sent a few minutes ago doesn¹t do what Ithought it would.After making either deŽnition below I get the following:In[2]:= s1=OrthogonalUnitVectors[{1,0,1/2,1,0},{0,1,-1,1/2,2}]Out[2]= {{0, -2/Sqrt[5], 0, 0, 1/Sqrt[5]}, {-2/3, -1/3, 0, 2/3, 0}, {-1/3, 2/3,2/3, 0, 0}}The dot products below aren¹t zero, so the vectors aren¹t orthogonal. Whatwent wrong?In[3]:= Part[s1,1].Part[s1,2]Out[3]= 2/(3*Sqrt[5])In[4]:= Part[s1,1].Part[s1,3]Out[3]= -4/(3*Sqrt[5])--------------> Hugh Goyder and David Park gave a most elegant function to Žnd two> vectors that are orthogonal to one vector in 3D. The key to coming up> with the elegant solution is an understanding of Mathematica¹s NullSpace> function. We can easily make the version from Hugh and David much more> general with the version below.> -------------> OrthogonalUnitVectors[vect__?VectorQ]:= > #/Sqrt[#.#]&/@NullSpace[{vect}]> -------------> The version above will give a set of unit orthogonal vectors if given any> number of vectors in any dimension. > So besides giving it a 3D vector we can give it the following:> OrthogonalUnitVectors[{2,1,0,-1,1}]> or> OrthogonalUnitVectors[{0,1,0,1/2,1},{1,0,-1,1/2}]> ------------> But the short version above isn¹t very robust.> (1) Clear[x,y,z];NullSpace[{{x,y,z}}]> returns two vectors orthogonal to {x,y,z}, but the two vectors> NullSpace returns aren¹t orthogonal to each other. > So (OrthogonalUnitVectors) should only work with numeric vectors.> (2) We should ensure all the vectors have the same dimension and length>1.> I give a less concise version below that corrects these problems.> ------------> OrthogonalUnitVectors[vect__?(VectorQ[#,NumericQ]&)]/;> (SameQ@@Length/@{vect})&&(Length[First[{vect}]]>1):= > #/Sqrt[#.#]&/@NullSpace[{vect}]> --------------> Ted Ersek> Get Mathematica tips, tricks from> http://www.verbeia.com/mathematica/tips/Tricks.html> ====Daniel Lichtblau has pointed out that NullSpace does not generally giveorthogonal vectors. Therefore the routines that depended upon that were inerror. He says that it does give orthogonal vectors when the input vectorcontains approximate numbers. For graphical purposes this will be goodenough for me. Therefore I modify Ted¹s routine toOrthogonalUnitVectors[vect__?(VectorQ[#, NumericQ] &)] /; (SameQ @@ Length /@ {vect}) && (Length[First[{vect}]] > 1) := #/Sqrt[#.#] & /@ NullSpace[{vect}// N]and the short version for 3D vectorsOrthogonalUnitVectors[v : {_, _, _}] := #/Sqrt[#.#] & /@ NullSpace[{v//N}]For exact vectors I might use for 3DOrthogonalUnitVectors[v : {_, _, _}] := #/Sqrt[#.#] & /@ {temp = First[NullSpace[{v}]], v[Cross]temp}I¹m still looking for something that is easy to remember.David Parkdjmp@earthlink.nethttp://home.earthlink.net/~djmp/The version above will give a set of unit orthogonal vectors if given anynumber of vectors in any dimension.So besides giving it a 3D vector we can give it the following: OrthogonalUnitVectors[{2,1,0,-1,1}] or OrthogonalUnitVectors[{0,1,0,1/2,1},{1,0,-1,1/2}]------------ But the short version above isn¹t very robust.(1) Clear[x,y,z];NullSpace[{{x,y,z}}] returns two vectors orthogonal to {x,y,z}, but the two vectorsNullSpace returns aren¹t orthogonal to each other. So (OrthogonalUnitVectors) should only work with numeric vectors.(2) We should ensure all the vectors have the same dimension and length >1.I give a less concise version below that corrects these problems.------------OrthogonalUnitVectors[vect__?(VectorQ[#, NumericQ]&)]/; (SameQ@@Length/@{vect})&&(Length[First[{vect}]]>1):= #/Sqrt[#.#]&/@NullSpace[{vect}]-------------- Ted Ersek Get Mathematica tips, tricks from http://www.verbeia.com/mathematica/tips/Tricks.html==== I am unsure if my messages are making it through to the usegroup so Iwill try again. I have several differential equations I would like toplot in Mathematica. I would like to plot the Slope Fields of themthough. Can anyone lead me in the right direction? I can solve theequations trivially but I want to display the slope Želds. An examplefollows :y¹ + 2y = 3-John====John,You can do it from scratch with PlotVectorField from theGraphics`PlotField` package, but you make make your life easier (and getprettier plots) by using my DEGraphics package, which can be found atMathSource (it¹s part of theDiffEqs suite of packages) or here:http://www.math.armstrong.edu/faculty/hollis/mmade/ DiffEqs---Selwyn Hollis> I am unsure if my messages are making it through to the usegroup so I > will try again. I have several differential equations I would like to > plot in Mathematica. I would like to plot the Slope Fields of them > though. Can anyone lead me in the right direction? I can solve the > equations trivially but I want to display the slope Želds. An example > follows :> y¹ + 2y = 3> -John>Reply-To: kuska@informatik.uni-leipzig.de====Needs[Graphics`PlotField`] PlotVectorField[{x, 3 - 2 y}, {x, 0, 4}, {y, -1, 4}, Axes -> True]??? Jens> I am unsure if my messages are making it through to the usegroup so I> will try again. I have several differential equations I would like to> plot in Mathematica. I would like to plot the Slope Fields of them> though. Can anyone lead me in the right direction? I can solve the> equations trivially but I want to display the slope Želds. An example> follows :> y¹ + 2y = 3> -John====You can proceed like this :delta[poly2_, var_] := CoefŽcient[poly2, var, 1]^2 - 4*CoefŽcient[poly2,var, 0]*CoefŽcient[poly2, var, 2]Meilleures salutationsFlorian Jaccard-----Message d¹origine-----Envoy.8e : ven., 6. septembre 2002 09:17Ė : mathgroup@smc.vnet.netObjet : CoefŽcient problemNow I¹m trying to calculate this formula:Delta[eq_, x_]:=CoefŽcient[eq, x]^2 - 4 CoefŽcient[eq, x^2]CoefŽcient[eq, x^0]eq has this form a x^2 + b x + cBut there is a problem with the x^0 coefŽcient!How can I overcome that?CeZaR====This works:eq = a x^2 + b x + cdiscriminant[eq_, x_] := CoefŽcient[eq, x]^2 - 4 CoefŽcient[eq, x, 2] CoefŽcient[eq, x, 0]discriminant[eq, x]x^0 is reduced to 1 and the CoefŽcient of 1 doesn¹t make sense toMathematica, because it depends on what the variable is (a, b, c, orx?). So, the other form of the CoefŽcient call is needed. I used itfor the second power too, but that wasn¹t necessary. I think that formis best, though, since it allows no ambiguity.I renamed the function because that¹s what the quantity is often called,for a quadratic.Bobby Treat-----Original Message-----CeZaR====>-----Original Message----->Sent: Friday, September 06, 2002 9:17 AM>myArray is a list of triplets which look like {n,k,p}, where n and k>are integers and p is real number. repetitions in n and k are allowed>but no two triplets ar the same.>>I deŽne a function, myfunc[n_,pthreshold_] as follows.>>myfunc[n_,pthreshold_] := Module[{t},>t=Max[Cases[myArray, {n, k_, p_} /; (p >= pthreshold) -> p, 2]];>If[t>=0,t,-1]]>>It prints the largest k for which p is greater than pthreshold for a>given n and>-1 if there is no such k. The function does its job Žne. >>My problem is as follows. I would like to plot a collection of plots,>myfunc[n,p], for 1<=n<=21 with respect to p. unfortunately the>following does not work as desired.>>Plot[Table[myfunc[n,p],{n,1,21}],{p,0.0,1.0}] >>because the Table gets evaluated to numeric value (-1) before Plot is>invoked.>The problem with your calculation indented is (1) to evaluate Table (withinPlot), which gives {myfunc[1, p], ..., myfunc[21, p]}but (2) *then* to prevent further evaluation of myfunc[.., p] to -1. Thereare several tricks to do so, e.g. ...Hold[Plot[toPlot, {p, 0, 1}]] /. toPlot -> Table[headPlaceholder[n, p], {n, 3}] /. headPlaceholder -> myfunc // ReleaseHold...but in your case just simply prevent evaluation of myfunc[.., p] with pbeing a Symbol by deŽning:myfunc2[n_, pthreshold_?NumericQ] := ...now...Plot[Evaluate[Table[myfunc2[n, p], {n, 21}]], {p, 0, 1}]...works as expected.BTW, what do you want to read off the plot, that you didn¹t know fromTable[myfunc[n, 0], {n, 21}] ?--Hartmut Wolf====>-----Original Message----->Sent: Friday, September 06, 2002 9:17 AM When I multiply an expression with 0 it is giving 0.expression which>is creating problem in the further calculation.>>eg.>>In[1]:=func1[r_]:=Exp[-r/2]>In[2]:coeff[[ 1,1]]=0.0;>;>;>In[34]:=func1[r]coeff[[1,1]]>>Out[34]:=0.Exp[- r/2]>>I want anything to be multiply by zero must be zero. How can I do that? >Your suggestion will be highly appreciated.> Raj>Raj,this simply is, because 0. Exp[-r/2] is not always zero!func1[-InŽnity]coeff[[1, 1]]InŽnity::indet:Indeterminate expression 0. InŽnity encountered.Out[90]= Indeterminate--Hartmut Wolf====I have a mathematica notebook showing using the alternating directionimplicit method for solving heat conduction in 2D via Žnite differencemethods. Moving from 2D to 3D is pretty simple although I can¹t Žnd mynotebook on this anymore :( . The 3D method is sometimes called Brian¹smethod. http://mid-ohio.mse.berkeley.edu/scott/projects/ index.htmlScott> Could you help me?> I¹m to solve heat conductivity equation (Laplas > equation) - partial differential equation. Are there > any ready-to-use packages that will help me do the job?> Standard functionDSolve cannot! And so do functions > from packageCalculus`DSolveIntegrals`.> More info: the space where the equation is to be > solved is cylindre (not inŽnite).> Andrew.> ==== I am working with Mathematica 4.0, and I would like pass my data todo one graphic in Origin 5.0. How can I do this in more simple manner?====> I need to Žll the space between two contour lines, C1 and C2, with> red color, and leave the other place white. What trick I have to use?> Any suggestion and advice will be appreciated.Over the years I have alighted upon the following scheme. Suppose I want tocolor only between contour levels 1 and 2:In[84]:=Needs[Graphics`Colors`]In[88]:=ContourPlot[x, {x, -1, 3}, {y, 0, 1}, Contours -> {0, 1, 2, 3, 4}, ColorFunction -> (If[1 < # < 2, Red, White] & ), ColorFunctionScaling -> False];1. Specify the speciŽc contour levels instead of specifying only the count.2. Disable ColorFunctionScaling so the argument to ColorFunction correspondsto the contour levels.Hope this helps,Tom Burton====David Park replied with----------------Daniel Lichtblau has pointed out that NullSpace does not generally giveorthogonal vectors. Therefore the routines that depended upon that were inerror. He says that it does give orthogonal vectors when the input vectorcontains approximate numbers. For graphical purposes this will be goodenough for me. Therefore I modify Ted¹s routine toOrthogonalUnitVectors[vect__?(VectorQ[#, NumericQ] &)] /; (SameQ @@ Length /@ {vect}) && (Length[First[{vect}]] > 1) := #/Sqrt[#.#] & /@ NullSpace[{vect}// N]----------------Lets see what NullSpace does with approximate complex vectors.In[1]:= v1 = {1.0 I, 0.0, 0.5 I, 0.0, 1.0}; v2 = {0.0, 2.0, 1.0 I, 2.0, 0.5}; {v3,v4,v5} = NullSpace[{v1,v2}]Out[3]= {{-0.730153 + 0.*I, 0. - 0.138254*I, 0.250585 + 0.*I, 0. - 0.138254*I, 0.+ 0.60486*I}, {0. + 0.*I, -0.515861 + 0.*I, 0. + 0.457321*I, 0.687357 + 0.*I, 0.22866+ 0.*I}, {0. + 0.*I, 0.510406 + 0.*I, 0. + 0.740442*I, -0.23274 + 0.*I, 0.370221+ 0.*I}}--------In the next line we see NullSpace returned vectors that are orthogonal tothe vectors we gave NullSpace.In[4]:= {v1.v3, v1.v4, v1.v5, v2.v3, v2.v4, v2.v5}//ChopOut[4]= {0, 0, 0, 0, 0, 0}----------However, the vectors returned aren¹t orthogonal to each other.In[5]:= {v3.v4, v3.v5, v4.v5}//ChopOut[5]= {0.229195*I, 0.371087*I, -0.677239}---------I suppose an OrthogonalUnitVectors function that uses NullSpace should (1) Only accept real valued vectors. (2) Ensure NullSpace is given approximate vectors.------ Ted Ersek====>OrthogonalUnitVectors[vect__?(VectorQ[#, NumericQ] &)] /;> (SameQ @@ Length /@ {vect}) && (Length[First[{vect}]] > 1) :=> #/Sqrt[#.#] & /@ NullSpace[{vect}// N]---------------->>Lets see what NullSpace does with approximate complex vectors.>>In[1]:=> v1 = {1.0 I, 0.0, 0.5 I, 0.0, 1.0};> v2 = {0.0, 2.0, 1.0 I, 2.0, 0.5};> {v3,v4,v5} = NullSpace[{v1,v2}]>>Out[3]=> {{-0.730153 + 0.*I, 0. - 0.138254*I, 0.250585 + 0.*I, 0. - 0.138254*I,>0.>+ 0.60486*I}, > {0. + 0.*I, -0.515861 + 0.*I, 0. + 0.457321*I, 0.687357 + 0.*I, 0.22866>+ 0.*I}, > {0. + 0.*I, 0.510406 + 0.*I, 0. + 0.740442*I, -0.23274 + 0.*I, 0.370221>+ 0.*I}}-------->In the next line we see NullSpace returned vectors that are orthogonal to>the vectors we gave NullSpace.>>In[4]:=> {v1.v3, v1.v4, v1.v5, v2.v3, v2.v4, v2.v5}//Chop>>Out[4]=> {0, 0, 0, 0, 0, 0}---------->However, the vectors returned aren¹t orthogonal to each other.>>In[5]:=> {v3.v4, v3.v5, v4.v5}//Chop>>Out[5]=> {0.229195*I, 0.371087*I, -0.677239}--------->I suppose an OrthogonalUnitVectors function that uses NullSpace should > (1) Only accept real valued vectors. > (2) Ensure NullSpace is given approximate vectors.------> Ted ErsekI think you will Žnd that the output vectors are orthogonal if you use thecomplex conjugate. for example v4.Conjugate[v5] is zero.Dennis Wangsness====>I need to Žll the space between two contour lines, C1 and C2, with>red color, and leave the other place white. What trick I have to use?>Any suggestion and advice will be appreciated.Needs[Graphics`FilledPlot`];Needs[Graphics`Colors `];FilledPlot[{4 - x^2, 3x}, {x, -4, 1}, Fills -> Red];Bob Hanlon====>For my PDE class we have been calculating Fourier transforms. The instructor>arrived today with a printout of two plots of a certain Fourier transform,>done with a different CAS. The Žrst plot was to 30 terms, the second was>to>120 terms.> Curious, I translated the functions into Mathematica (4.0 on Windows2000>on a PIII 700) to see how much time this required to process. I was>Staggered at how much time it took. Here¹s the code:>>L = 2;>f[x_] := UnitStep[x - 1];>b[n_] := (2/L)*Integrate[f[x]*Sin[n*Pi*x/L], {x, 0, L}];>>FS[N_, x_] := Sum[b[n]*Sin[n*Pi*x/L], {n, 1, N}];>>Timing[Plot[FS[30, x], {x, 0, 2}]]>>Out[23]=>{419.713 Second, [SkeletonIndicator]Graphics[SkeletonIndicator]}>>In this case the number of terms is 30.>>The time required per number of terms seems to Žt the following polynomial:>>y = 0.3926x^2 + 2.2379x>>This is a large amount of time. I understand that the code is not optimized,>and was more or less copied from the code in the other CAS, but is this>a>reasonable amount of time, or is something going wrong? I don¹t useMathematica>because of the speed, but should it be this slow?>>Just curious,Your deŽnition of b recalculates the integral for every call. To evaluatethe integral onceinclude Evaluate.Clear[f, b, FS];L = 2;f[x_] := UnitStep[x - 1];b[n_] := Evaluate[ (2/L)*Integrate[f[x]*Sin[n*Pi*x/L], {x, 0, L}]];In the case of FS it is best to wait for an integer value of N prior toperforming the Sum.FS[N_Integer, x_] := Sum[b[n]*Sin[n*Pi*x/L], {n, 1, N}];Now Evaluate the argument of the Plot to cause the Sum to be done once.Timing[Plot[Evaluate[FS[120, x]], {x, 0, 2}]][[1]]0.366667 SecondWhile my computer may be faster than yours, this result for N=120 is 1000times faster than your result for N=30.Bob Hanlon====> Now I¹m trying to calculate this formula:> Delta[eq_, x_]:=CoefŽcient[eq, x]^2 - 4 CoefŽcient[eq, x^2] CoefŽcient[eq, x^0]> eq has this form a x^2 + b x + c> But there is a problem with the x^0 coefŽcient!> How can I overcome that?> CeZaRCoefŽcient cannot Žgure out who is and is not a variable when avariable of 1 is speciŽed. To work around this you might instead dodelta1[poly_, x_] := CoefŽcient[poly,x]^2 - 4*CoefŽcient[poly,x,2]*CoefŽcient[poly,x,0]I prefer instead to use CoefŽcientList:delta2[poly_, x_] := (#[[2]]^2 - 4*#[[1]]*#[[3]])&[CoefŽcientList[poly,x]]In[25]:= poly = a*x^2+b*x+c;In[26]:= delta1[poly,x] === delta2[poly,x]Out[26]= TrueDaniel LichtblauWolfram Research====>>Delta[eq_, x_]:=CoefŽcient[eq, x]^2 - 4 CoefŽcient[eq, x^2] CoefŽcient[eq,>x^0]>>eq has this form a x^2 + b x + c>>But there is a problem with the x^0 coefŽcient!>How can I overcome that?see on-line help for CoefŽcientdelta[eq_, x_] := CoefŽcient[eq, x, 1]^2 - 4 *CoefŽcient[eq, x, 2] *CoefŽcient[eq, x, 0];eq = a*x^2 + b*x + c;delta[eq, x]b^2 - 4*a*cBob Hanlon====Would someone with a very fast machine and lots of memory be willing to trythis Solve for me?It is the inverse of the 20 node quadratic hexahedral mapping used inŽnite element analysis.None of my computers can handle this - they run out of memory (using (*Hex20 Node deŽnition in global coordinates *)Clear[x1, y1, z1,x2, y2, z2,x3, y3, z3,x4, y4, z4,x5, y5, z5,x6, y6, z6,x7, y7, z7,x8, y8, z8,x9, y9, z9,x10, y10, z10,x11, y11, z11,x12, y12, z12,x13, y13, z13,x14, y14, z14,x15, y15, z15,x16, y16, z16,x17, y17, z17,x18, y18, z18,x19, y19, z19,x20, y20, z20];(* local coordinates *)Clear[u, v, w];(* Global co-ordinates *)Clear[x, y, z];(* corner nodes *)N1= (1-u)*(1-v)*(1-w)*(-2-u-v-w)/8;N3= (1+u)*(1-v)*(1-w)*(-2+u-v-w)/8;N5= (1+u)*(1+v)*(1-w)*(-2+u+v-w)/8;N7= (1-u)*(1+v)*(1-w)*(-2-u+v-w)/8;N13=(1-u)*(1-v)*(1+w)*(-2-u-v+ w)/8;N15=(1+u)*(1-v)*(1+w)*(-2+u-v+w)/8;N17=(1+u)*(1+v)*(1+w) *(-2+u+v+w)/8;N19=(1-u)*(1+v)*(1+w)*(-2-u+v+w)/8;(* to u nodes *)N2= (1-u^2)*(1-v)*(1-w)/4;N6= (1-u^2)*(1+v)*(1-w)/4;N14=(1-u^2)*(1-v)*(1+w)/4;N18=(1-u^2)*( 1+v)*(1+w)/4;(* to v nodes *)N4= (1+u)*(1-v^2)*(1-w)/4;N8= (1-u)*(1-v^2)*(1-w)/4;N16=(1+u)*(1-v^2)*(1+w)/4;N20=(1-u)*(1- v^2)*(1+w)/4;(* to w nodes *)N9= (1-u)*(1-v)*(1-w^2)/4;N10=(1+u)*(1-v)*(1-w^2)/4;N11=(1+u)*(1+ v)*(1-w^2)/4;N12=(1-u)*(1-v)*(1-w^2)/4;(* solve the inverse transform *)Solve[{x1*N1+x2*N2+x3*N3+x4*N4+x5*N5+x6*N6+x7*N7+x8*N8+x9* N9+x10*N10+x11*N11+x12*N12+x13*N13+x14*N14+x15*N15+x16*N16+ x17*N17+x18*N18+x19*N19+x20*N20-x==0,y1*N1+y2*N2+y3*N3+y4*N4+ y5*N5+y6*N6+y7*N7+y8*N8+y9*N9+y10*N10+y11*N11+y12*N12+y13*N13 +y14*N14+y15*N15+y16*N16+y17*N17+y18*N18+y19*N19+y20*N20-y==0 ,z1*N1+z2*N2+z3*N3+z4*N4+z5*N5+z6*N6+z7*N7+z8*N8+z9*N9+z10* N10+z11*N11+z12*N12+z13*N13+z14*N14+z15*N15+z16*N16+z17*N17+ z18*N18+z19*N19+z20*N20-z==0},{u,v,w}]Christopher J. PurcellDefence R&D Canada ö Atlantic9 Grove St., PO Box 1012Dartmouth NS Canada B2Y 3Z7====Needs[Graphics`Colors`];ContourPlot[Sin[x y], {x, -5, 5}, {y, -5, 5}, ColorFunction -> (If[0.5 < # < 0.7, Red, White] &)];Bob Hanlon>ContourPlot?>Jun Lin > In a message dated 9/6/02 3:53:58 AM,>I need to Žll the space between two contour lines,> C1 and C2, with>red color, and leave the other place white. What> trick I have to use?>Any suggestion and advice will be appreciated.> Needs[Graphics`FilledPlot`];> Needs[Graphics`Colors`];> FilledPlot[{4 - x^2, 3x}, {x, -4, 1}, Fills -> Red];====Jun Lin,Here is an example.Needs[Graphics`Colors`]Let¹s make a contour plot of this function.f[x_, y_] := Sin[x]Sin[2y]Let¹s specify the exact contours to use. I got rid of the 0. contour becauseit is difŽcult to obtain in this plot.contourvalues = Complement[Range[-1, 1, 0.2], {0.}]{-1, -0.8, -0.6, -0.4, -0.2, 0.2, 0.4, 0.6, 0.8, 1.}Now we deŽne a ColorFunction for the plot. I actually colored two differentbands to show how you can make a general color function to give each band adesired color.cfun[z_] := Which[ -0.6 < z < -0.42, RoyalBlue, 0.4 < z < 0.6, Red, True, White]ContourPlot[f[x, y], {x, 0, Pi}, {y, 0, Pi}, PlotPoints -> 30, ColorFunctionScaling -> False, ColorFunction -> cfun, Contours -> contourvalues];Using the option ColorFunctionScaling -> False says that the z value will bethe actual value of f[x,y]. Otherwise, in general, it will be scaled between0 and 1. It is easier to write a color function when z is the actual valueof the function.David Parkdjmp@earthlink.nethttp://home.earthlink.net/~djmp/Sender: steve@smc.vnet.netApproved: Steven M. Christensen , ModeratorReply-To: ====I checked again the six solutions I had previously timed, and they DOgive orthogonal results. (None of them depend on NullSpace for that.)By the way, I reused mycombinations function (from a recent problemon adding fractions to get 1) to check for orthogonality: ClearAll[orthogonalQ] orthogonalQ[v : {__?VectorQ}] := And @@ (Chop@(Dot @@ #) == 0 & /@ combinations[v, {2}]) << DiscreteMath`Combinatorica`; ClearAll[combinations]; r = Range[1, 9]; combinations::usage =combinations[list,n:{__Integer}] lists the combinations of list taken n at a time; combinations[r_List, n_Integer, {}] := If[n > Length@r, {}, DiscreteMath`Combinatorica`KSubsets[r, n]]; combinations[r_List, n_Integer, e_?VectorQ] := Join[e, #] & /@DiscreteMath`Combinatorica`KSubsets[Complement[r, e], n]; combinations[r_List, n_Integer, e : {__?VectorQ}] := Flatten[ combinations[r, n, #] & /@ e, 1]; combinations[r_List, n : {__Integer}] := Which[Plus @@ n ==Length@r,Join[#, Complement[r, #]] & /@ combinations[r, Drop[n, -1]], Plus @@ n > Length@r, {}, True, Fold[ combinations[r, #2, #1] &, {}, n]]Bobby-----Original Message----- (SameQ @@ Length /@ {vect}) && (Length[First[{vect}]] > 1) := #/Sqrt[#.#] & /@ NullSpace[{vect}// N]and the short version for 3D vectorsOrthogonalUnitVectors[v : {_, _, _}] := #/Sqrt[#.#] & /@NullSpace[{v//N}]For exact vectors I might use for 3DOrthogonalUnitVectors[v : {_, _, _}] := #/Sqrt[#.#] & /@ {temp = First[NullSpace[{v}]], v[Cross]temp}I¹m still looking for something that is easy to remember.David Parkdjmp@earthlink.nethttp://home.earthlink.net/~djmp/ OrthogonalUnitVectors[vect__?VectorQ]:= #/Sqrt[#.#]&/@NullSpace[{vect}]-------------The version above will give a set of unit orthogonal vectors if givenanynumber of vectors in any dimension.So besides giving it a 3D vector we can give it the following: OrthogonalUnitVectors[{2,1,0,-1,1}] or OrthogonalUnitVectors[{0,1,0,1/2,1},{1,0,-1,1/2}]------------ But the short version above isn¹t very robust.(1) Clear[x,y,z];NullSpace[{{x,y,z}}] returns two vectors orthogonal to {x,y,z}, but the two vectorsNullSpace returns aren¹t orthogonal to each other. So (OrthogonalUnitVectors) should only work with numeric vectors.(2) We should ensure all the vectors have the same dimension and length>1.I give a less concise version below that corrects these problems.------------OrthogonalUnitVectors[vect__?(VectorQ[#, NumericQ]&)]/; (SameQ@@Length/@{vect})&&(Length[First[{vect}]]>1):= #/Sqrt[#.#]&/@NullSpace[{vect}]-------------- Ted Ersek Get Mathematica tips, tricks from http://www.verbeia.com/mathematica/tips/Tricks.html====I have substituted the letters SS, CC, X, Y and Z1 and Z2 for somecomplicated expressions just to illustrate the form of the function. Thisfunction works and all the conditions are necessary but I am sure a moreelegant programming solution perhaps using While could be found. Anyf[{Sa_, Ca_, Aa_, Sb_, Cb_, Ab_, a_, b_}] := {If[Aa == Ab, a Sa + b Sb, If[Ca == 0 || Cb == 0, a Sa + b Sb, SS]], If[Aa == Ab, a Ca + b Cb, If[Ca == 0 || Cb == 0, a Ca + b Cb, CC]], If[Ca == 0 && Cb == 0,Nil, If[Z1 == Z2, If[Ca < 0, Aa, If[Cb < 0, Ab, If[Ca > 0, If[Aa > 90, Aa - 90, Aa + 90], If[Cb > 0, If[Ab > 90, Ab - 90, Ab + 90]]]]], If[Aa == Ab, Aa, If[Ca == 0 && Cb == 0,Nil, If[Ca == 0, Ab, If[Cb == 0, Aa, If[Y == 0,Nil, If[X > 180, X - 180, If[X < 0, X + 180, X]]]]]]]]]}====Check out the Help for CoefŽcient.CoefŽcient[expr, form, 0] picks out terms that are not proportional toform.Delta[eq_, x_] := CoefŽcient[eq, x]^2 - 4 CoefŽcient[eq, x^2] CoefŽcient[eq, x, 0]Delta[a x^2 + b x + c, x]b^2 - 4*a*cDavid Parkdjmp@earthlink.nethttp://home.earthlink.net/~djmp/==== Dear all,1.) How to Žnd the General Solution for below¹s partial differential equation? (y + u) du/dx + y (du/dy) = x - y** I used to represent the partial differential symbol.Can it be solved by function NDSolve in mathematica 4.1? How?2.) I manage to get the roots of complex equation z^5 = i fromSolve[z^5 == i, z]. It gave me straight the 5 roots in the output.Is there any way to view the steps in mathematica?Shz Shz========================================================== ========================of the individual or entity to which they are addressed. Any disclosure, copying,distribution and diversion contrary to the applicable export control laws andregulations including US Export Administration Regulations is strictly prohibited.and do not disclose it to others. Please notify thepostmaster@hitachi.com.myof the delivery error by replying to this message and then delete it from your========================================================= =============================I have been trying to code Sethian¹s Fast Marching Method in 2D but Mathematicahas been very slow (taking something like 1-2 hours for something thatshould take much less than a second in C++). I am sure part of the problemmy time.I looked at the list archives and there was mention of an proŽlingpackage for Mathematica but a)I can¹t Žnd it & b)It may not work with Mathematica 4.*.My questions:1. Any general suggestions on how to Žgure out which functions are takingmost of the time? I guess I could manually have each function I aminterested in monitoring keep a variable that counts the amount of CPUtime that has been spent on it by doing something like:function[args_]:=Module[{},functionTimer+=Timing[ .... My actual function..... ][[1]]]but it would very cumbersome to do this to all of the functions in myprogram and I am not sure I will get accurate results anyway.2. Compiling functions is not always that easy. I did read the on-linedocs and the archives and it does take some work to make a functioncompile usefully. Is there an FAQ or a tutorial somewhere?3. Am I the only one who Žnds the lack of a proŽler really reallyannoying ? Mathematica is powerful and it is usually easy to ask it to do what uwant. The challenge a lot of times is doing so without taking too long.HusainPS: One more quick one: Why does the front end act funny when I have the====Caution: the deŽnitionb[n_] := Evaluate[(2/L)*Integrate[f[x]*Sin[n*Pi*x/L], {x, 0, L}]];doesn¹t immediately compute the integral unless f is already deŽned atthis point, and in that case you may as well writeb[n_] = (2/L)*Integrate[f[x]*Sin[n*Pi*x/L], {x, 0, L}];instead. If b will be computed more than once for the same n, its evenbetter to do it THIS way (if f and L do not change):f[x_] = Cos[x] (* for example *)Simplify[Integrate[f[x]*Sin[n*Pi*(x/L)], {x, 0, L}]](L*((-n)*Pi + n*Pi*Cos[L]*Cos[n*Pi] + L*Sin[L]*Sin[n*Pi]))/ ((L - n*Pi)*(L + n*Pi))b[n_] := b[n] = (L*((-n)*Pi + n*Pi*Cos[L]*Cos[n*Pi] + L*Sin[L]*Sin[n*Pi]))/ ((L - n*Pi)*(L + n*Pi))Bobby-----Original Message-----Stephan Steinhaus (steinhaus-net.de). So when Mathematica takes a verylongtime, you should investigate. In this case inserting Evaluate[] in twoplacesIn[91]:=b[n_] := Evaluate[(2/L)*Integrate[f[x]*Sin[n*Pi*x/L], {x, 0,L}]];....In[104]:=Timing[Plot[Evaluate[FS[120, x]], {x, 0, 2}]]Out[104]={0.18 Second,[SkeletonIndicator]Graphics[SkeletonIndicator]}speeds the process enormously (18 milliseconds to plot 120 terms on myfeeble old 500MHz PowerBook).Why was it so slow before? When I switch from an ordinary numericallanguageto Mathematica, I enter into an implicit bargain withMathematica: the software will go the extra mile to get me a goodanswer,including (1) using exra precision (sometimes without being asked) and(2)carrying around unevaluated mathematical expressions (usually withoutbeingasked) that could possibly be evaluated more appropriately at a latertime.Most tools cannot do either of these things, so I don¹t have to worryaboutit, except for the bad answers that result now and then. But I need totakecare that Mathematica does not burden itself unnecessarily. That¹s mysideof the bargain.Number (2) is the issue here. Your deŽnition of b[n] is written so thatMathematica analytically evaluates b separately for each n. But you knowinthis case that the integration can be done safely once for all n. So doit!The huge difference, though, comes from pre-evaluating the argument toPlot.Read the on-line help! You should pre-evaluate where possible. In somecases, the most common of which involve branching within the deŽnitionoffunction to plot, you cannot pre-evaluate so, in keeping with thebargain,Mathematica goes the extra mile and holds back just in case. You need tosteer it into the shortcut when it¹s OK.Hope this helps,Tom Burton-- ====With the second method below (mine), the times add up to 40% less than with the Žrst method (Jens-Peer¹s), for what SEEMS to be exactly the same work. Go Žgure!Can anybody explain that?(* Jens-Peer *)ClearAll[f, b, FS]L = 2;f[x_] := UnitStep[x - 1];b[n_] := b[n] = (2/L)*Integrate[f[x]*Sin[n*Pi*x/L], {x, 0, L}];FS[N_, x_] := Sum[b[n]*Sin[n*Pi*x/L], {n, 1, N}];Timing[Plot[FS[30, x], {x, 0, 2}]]{0.547 Second, .89Ŗ°Graphics.89Ŗ°}(* Treat #1 *)Timing[(2/L)*Integrate[f[x]*Sin[n*Pi*(x/L)], {x, 0, L}]]{0.016000000000000014*Second, (2*(Cos[(n*Pi)/2] - Cos[n*Pi]))/(n*Pi)}ClearAll[f, b, FS]L = 2;f[x_] := UnitStep[x - 1];b[n_] := b[n] = (2*(Cos[(n*Pi)/2] - Cos[n*Pi]))/(n*Pi);FS[N_, x_] := Sum[b[n]*Sin[n*Pi*(x/L)], {n, 1, N}];Timing[Plot[FS[30, x], {x, 0, 2}]]{0.297 Second, .89Ŗ°Graphics.89Ŗ°}Even stranger, it SLOWS the Plot if we precompute b before Timing starts:(* Treat #2 *)ClearAll[f, b, FS]L = 2;f[x_] := UnitStep[x - 1];b[n_] := b[n] = (2*(Cos[(n*Pi)/2] - (-1)^n))/(n*Pi);b /@ Range[30];FS[N_, x_] := Sum[b[n]*Sin[n*Pi*(x/L)], {n, 1, N}];Timing[Plot[FS[30, x], {x, 0, 2}]]{0.328 Second, .89Ŗ°Graphics.89Ŗ°}But here¹s a winner:(* Treat #3 *)ClearAll[f, b, FS]L = 2;f[x_] := UnitStep[x - 1];b[n_] := b[n] = N[(2*(Cos[(n*Pi)/2] - (-1)^n))/ (n*Pi)];FS[N_, x_] := Sum[b[n]*Sin[n*Pi*(x/L)], {n, 1, N}];Timing[Plot[FS[30, x], {x, 0, 2}]]{0.204 Second, .89Ŗ°Graphics.89Ŗ°}Apparently, computing b within the Plot causes machine-precision arithmetic to be used, and that saves time. Precomputing b and then converting exact expressions to approximate ones within the Plot seems to take longer. For that to make sense, I think it must be that n is approximate (not Integer) when it is passed to b within Plot.Bobby Treat-----Original Message-----and you need only a 1-3 seconds (depending on your machine) Jens For my PDE class we have been calculating Fourier transforms. The instructor> arrived today with a printout of two plots of a certain Fourier transform,> done with a different CAS. The Žrst plot was to 30 terms, the second was to> 120 terms.> Curious, I translated the functions into Mathematica (4.0 on Windows2000> on a PIII 700) to see how much time this required to process. I was> Staggered at how much time it took. Here¹s the code: L = 2;> f[x_] := UnitStep[x - 1];> b[n_] := (2/L)*Integrate[f[x]*Sin[n*Pi*x/L], {x, 0, L}]; FS[N_, x_] := Sum[b[n]*Sin[n*Pi*x/L], {n, 1, N}]; Timing[Plot[FS[30, x], {x, 0, 2}]] Out[23]=> {419.713 Second, [SkeletonIndicator]Graphics[SkeletonIndicator]} In this case the number of terms is 30. The time required per number of terms seems to Žt the following polynomial: y = 0.3926x^2 + 2.2379x This is a large amount of time. I understand that the code is not optimized,> and was more or less copied from the code in the other CAS, but is this a> reasonable amount of time, or is something going wrong? I don¹t use Mathematica> because of the speed, but should it be this slow? Just curious, Steve Story ====Even better -- MUCH better -- add Bob Hanlon¹s Evaluate to the other tricks:ClearAll[f, b, FS]L = 2;f[x_] := UnitStep[x - 1];b[n_] := b[n] = N[(2*(Cos[(n*Pi)/2] - (-1)^n))/(n*Pi)];FS[N_, x_] := Sum[b[n]*Sin[n*Pi*(x/L)], {n, 1, N}];Timing[Plot[Evaluate[FS[30, x]], {x, 0, 2}]]{0.015 Second, .89Ŗ°Graphics.89Ŗ°}ClearAll[f, b, FS]L = 2;f[x_] := UnitStep[x - 1];b[n_] := b[n] = N[(2*(Cos[(n*Pi)/2] - (-1)^n))/(n*Pi)];FS[N_, x_] := Sum[b[n]*Sin[n*Pi*(x/L)], {n, 1, N}];Timing[Plot[Evaluate[FS[120, x]], {x, 0, 2}]]{0.063 Second, .89Ŗ°Graphics.89Ŗ°}Bobby Treat-----Original Message-----Timing[Plot[FS[30, x], {x, 0, 2}]]{0.547 Second, .89Ŗ°Graphics.89Ŗ°}(* Treat #1 *)Timing[(2/L)*Integrate[f[x]*Sin[n*Pi*(x/L)], {x, 0, L}]]{0.016000000000000014*Second, (2*(Cos[(n*Pi)/2] - Cos[n*Pi]))/(n*Pi)}ClearAll[f, b, FS]L = 2;f[x_] := UnitStep[x - 1];b[n_] := b[n] = (2*(Cos[(n*Pi)/2] - Cos[n*Pi]))/(n*Pi);FS[N_, x_] := Sum[b[n]*Sin[n*Pi*(x/L)], {n, 1, N}];Timing[Plot[FS[30, x], {x, 0, 2}]]{0.297 Second, .89Ŗ°Graphics.89Ŗ°}Even stranger, it SLOWS the Plot if we precompute b before Timing starts:(* Treat #2 *)ClearAll[f, b, FS]L = 2;f[x_] := UnitStep[x - 1];b[n_] := b[n] = (2*(Cos[(n*Pi)/2] - (-1)^n))/(n*Pi);b /@ Range[30];FS[N_, x_] := Sum[b[n]*Sin[n*Pi*(x/L)], {n, 1, N}];Timing[Plot[FS[30, x], {x, 0, 2}]]{0.328 Second, .89Ŗ°Graphics.89Ŗ°}But here¹s a winner:(* Treat #3 *)ClearAll[f, b, FS]L = 2;f[x_] := UnitStep[x - 1];b[n_] := b[n] = N[(2*(Cos[(n*Pi)/2] - (-1)^n))/ (n*Pi)];FS[N_, x_] := Sum[b[n]*Sin[n*Pi*(x/L)], {n, 1, N}];Timing[Plot[FS[30, x], {x, 0, 2}]]{0.204 Second, .89Ŗ°Graphics.89Ŗ°}Apparently, computing b within the Plot causes machine-precision arithmetic to be used, and that saves time. Precomputing b and then converting exact expressions to approximate ones within the Plot seems to take longer. For that to make sense, I think it must be that n is approximate (not Integer) when it is passed to b within Plot.Bobby Treat-----Original Message-----and you need only a 1-3 seconds (depending on your machine) Jens For my PDE class we have been calculating Fourier transforms. The instructor> arrived today with a printout of two plots of a certain Fourier transform,> done with a different CAS. The Žrst plot was to 30 terms, the second was to> 120 terms.> Curious, I translated the functions into Mathematica (4.0 on Windows2000> on a PIII 700) to see how much time this required to process. I was> Staggered at how much time it took. Here¹s the code: L = 2;> f[x_] := UnitStep[x - 1];> b[n_] := (2/L)*Integrate[f[x]*Sin[n*Pi*x/L], {x, 0, L}]; FS[N_, x_] := Sum[b[n]*Sin[n*Pi*x/L], {n, 1, N}]; Timing[Plot[FS[30, x], {x, 0, 2}]] Out[23]=> {419.713 Second, [SkeletonIndicator]Graphics[SkeletonIndicator]} In this case the number of terms is 30. The time required per number of terms seems to Žt the following polynomial: y = 0.3926x^2 + 2.2379x This is a large amount of time. I understand that the code is not optimized,> and was more or less copied from the code in the other CAS, but is this a> reasonable amount of time, or is something going wrong? I don¹t use Mathematica> because of the speed, but should it be this slow? Just curious, Steve Story ====How can I plot with Mathematica two function in the same graphic?I explain better:compare a and b).====Other than Plot[{x,x^2},...] you can use Show[] as well.plt1=Plot[x,{x,0,1}];plt2=Plot[x^2,{x,0,1}];Show[plt1, plt2]Lawrence> How can I plot with Mathematica two function in the same graphic?> I explain better:> compare a and b).> Mario,> Here is a fancy version of your plot. I used Text statements within an> Epilog option to label the two curves. The regular plot statement allows you> to plot a series of functions inclosed in a list.> Needs[Graphics`Colors`]> Plot[{x, x^2}, {x, 0, 1},> PlotStyle -> {Black, Blue},> Frame -> True,> FrameLabel -> {x, y},> PlotLabel ->Comparison of Two Functions,> Epilog -> {Text[x, {0.5, 0.55}], Blue, Text[x^2, {0.7, 0.4}]},> Background -> Linen,> ImageSize -> 500];> David Park> djmp@earthlink.net> http://home.earthlink.net/~djmp/> How can I plot with Mathematica two function in the same graphic?> I explain better:> compare a and b).> ====(1) Is there a way in Mathematica 4.2 to put two separate gifs into asingle, cell side by side (with some intervening space), withouthaving to combine them in some graphics program Žrst?In particular, I¹d like to do that within a text cell.Even in a new Input cell, if I Žrst create a GridBox (via Inut>CreateTable/Matrix/Palette) and then try to insert the Žrst gif (viaEdit>Insert Object>Create from File ....), Mathematica promptlycrashes. (Mathematica 4.2 under Windows 2000.)I just don¹t see how to get anything other than a single gif into acell.(2) Is there a way to cause a gif imported into a Mathematica 4.2notebook to become a hyperlink -- so that when the user clicks on thegif the hyperlink¹s target is summoned?(My aim in all this is to use Mathematica to create web pages withhigh mathematical content -- saving the notebook as HTML+MathML --without having to do any extensive editing of the resulting .xml andrelated Žles. That way as the source Mathematica notebook changes, Iwould need only to re-export without further tinkering with the .xmlŽle, etc.) -- Murray Eisenberg Internet: murray@math.umass.edu Mathematics & Statistics Dept. Voice: 413-545-2859 (W) University of Massachusetts 413-549-1020 (H)====Your method 1), below, does not produce correct results if one thenuses menu>Save As Special>HTML+MathML.I view the resulting .xml Žle in a MathML-enabled browser (e.g.,Mozilla with appropriate TrueType fonts installed -- the four BaKoMacm fonts, theold MathematicaMath1, etc., fonts, and the two MTfonts. Then the everything in the originally multi-line inline cellappears on one line separate by a ?, as do the alignment markers. Inthe page source, these unrendered symbols have codes #8289 and #63328,respectively.Is there an issue of the encoding used in the browser here? I did tryUnicode-7, Unicode-8, and several of theWestern encodings availableunder Mozilla¹s Default Character Encoding.Or is it something else? Note that I do also have thenewMathematica TrueType fonts (Mathematica1, etc.).P.S. I don¹t think Mathematica documents this, but if one wants a Žleexported from Mathematica as HTML+MathML to be rendered correctly by abrowser, it seems to require an extension of .xml rather than .html. >>When writing a series of equations in mathematica (in a text cell) >>is there any way to align the equations at the = similar to >>what can be done in the equation editor made by math type (used >>in word etc.)? > Mike, > Two ways > 1) Start an inline cell in your text cell (menu>Edit>ExpressionInput>Start > Inline Cell) > Type in your equations with the alignment marker (Esc am Esc) inafter each > equal sign. > Close the inline cell (menu>Edit>Expression Input>End Inline Cell). > Select the text cell (or the inline cell, though this is a delicate > operation, do it by repeatedly double clicking in it}. > Use menu> Format>Text Alignment>On Alignment Marker. > -- you will Žnd that all single letters are now italic - you can select > individual letters and change this - alternatively you can select theinline > cell and use the option inspector (menu>Format>Option Inspector) to set > SingleLetterItalics->False) > -- you can put existing text in an inline cell by selcting it and using > menu>Edit>Expression Input>Start Inline Cell, but you may have to adjust > the line breaks after this.... -- Murray Eisenberg Internet: murray@math.umass.edu Mathematics & Statistics Dept. Voice: 413-545-2859 (W) University of Massachusetts 413-549-1020 (H)====Group,Can anyone help me with the following? I guess this is something trivialfor most of you, but I have being struggling with it for weeks.The problem is to construct a taxonomic hierarchy whose structure is herebydescribed by example:<< DiscreteMath`Combinatorica`n[1]:= m = 10;(*with the following I get the 1th level (1--element) partition*)in[2]:= ks1 = Partition[Range[m], 1](*Now the following gives all the 2th-level (?) different partitions thatcan be set up by joining two elements in the 1-element partition andleaving the rest as they are?*)(*First, these are all possible Œjoinings¹ to generate the two elements Œpieces¹ from 1th level (1--element) partition*)in[3]:= ks2 = KSubsets[Range[m], 2](*And this generates all the 2th-level (?) different partitions that can beset up by joining two elements in the 1-element partition and leaving therest as they are.*)in[4]:= p2 = MapThread[Complement[Append[#1, #2], (Sequence @@ {#} & /@Partition[#2, 1])] &, {Array[ks1&, Length[ks2]], ks2}];Length[p2]in[5]:= p2[[1]]out[5]:= {{3}, {4}, {5}, {6}, {7}, {8}, {9}, {10}, {1, 2}}in[6]:= p2[[Length[p2]]]out[6]:= {{1}, {2}, {3}, {4}, {5}, {6}, {7}, {8}, {9, 10}}(*compute in[4] t and see the full output*)(*Now I need to solve the problem of given the ith-level (?) differentpartitions to set up all the i+1th different partitions by joining twoelements in the ith level partition and leaving the rest as they are? *)(*for example given the following 2th-level partition*){3}, {4}, {5}, {6}, {7}, {8}, {9}, {10}, {1, 2}(*we should get*){{{4}, {5}, {6}, {7}, {8}, {9}, {10}, {1, 2, 3}},{{3}, {5}, {6}, {7}, {8}, {9}, {10}, {1, 2, 4}},{{3}, {4}, {6}, {7}, {8}, {9}, {10}, {1, 2, 5}},{{3}, {4}, {5}, {7}, {8}, {9}, {10}, {1, 2, 6}},{{3}, {4}, {5}, {6}, {8}, {9}, {10}, {1, 2, 7}},{{3}, {4}, {5}, {6}, {7}, {9}, {10}, {1, 2, 8}},{{3}, {4}, {5}, {6}, {7}, {8}, {10}, {1, 2, 9}},{{3}, {4}, {5}, {6}, {7}, {8}, {9}, {1, 2, 10}}}(*The process would end up to *){1,{2,3,4,5,6,7,8,9,10}}{2,{1,3,4,5,6,7,8,9,10}}{3,{ 1,2,4,5,6,7,8,9,10}}{4,{1,2,3,5,6,7,8,9,10}}{5,{ 1,2,3,4,6,7,8,9,10}}{6,{1,2,3,4,5,7,8,9,10}}{7,{ 1,2,3,4,5,6,8,9,10}}{8,{1,2,3,4,5,6,7,9,10}}{9,{ 1,2,3,4,5,6,7,8,10}}{10,{1,2,3,4,5,6,7,8,9}}(* and*){1,2,3,4,5,6,7,8,9,10}Emilio Martin-Serrano====> I too have been trying to use Mathematica (v4.2 most recently) to type> maths papers and the like but I¹m not ready to ditch LaTeX yet. There> are just too many cases where I cannot Žgure out how to achieve what I> want in Mathematica, things like:> - left brackets spanning multiple lines for deŽning hybrid functions;You can accomplish this by doing the following:1) Put your function braches in the rows of a grid box structure.2) Add the following options to your cell: ShowAutoStyles -> False SpanMaxSize -> InŽnityThe following cell snippet demonstrates how this inžuences the result. To view it, paste the Cell[] expression into a notebook and then click onYes when you are prompted on whether the front end should interpret theresult.Cell[BoxData[ FormBox[ RowBox[{ RowBox[{f, (,x, )}], =, RowBox[{{, GridBox[{ {x, RowBox[{x, , <, 0}]}, { SuperscriptBox[x, 2], RowBox[{0, [LessEqual],x, <, 1}]}, { RowBox[{sin, (,x, )}], RowBox[{1, [LessEqual],x, <, 2}]}, { RowBox[{[CapitalGamma], (,x, )}], RowBox[{x, [GreaterEqual], 2}]} }]}]}], TraditionalForm]],DisplayFormula, ShowAutoStyles->False, SpanMaxSize->InŽnity]> - vertical alignment of equals signs in multi-line equations or> derivations;Put your equations in a GridBox and set the ColumnAlignments option to astring containing the equal sign.Cell[BoxData[ FormBox[GridBox[{ { RowBox[{ RowBox[{ RowBox[{3,x}], , +, , RowBox[{4, ,y}]}], , =, , 9}]}, { RowBox[{ RowBox[{ RowBox[{2,x}], , -, , RowBox[{7, ,y}]}], =, RowBox[{32, , -, , RowBox[{sin, (,x, )}]}]}]} }], TraditionalForm]],DisplayFormula, GridBoxOptions->{ColumnAlignments->{=}}]> - setting typefaces in tables of material.I think the Author Tools material that comes with Mathematica 4.2 might beable to help you do this.--User Interface Programmer paulh@wolfram.comWolfram Research, Inc.====You have three nonlinear (fourth-order) equations and 23 unknowns. Afaster computer won¹t help any.Bobby-----Original Message-----(*Hex20 Node deŽnition in global coordinates *)Clear[x1, y1, z1,x2, y2, z2,x3, y3, z3,x4, y4, z4,x5, y5, z5,x6, y6, z6,x7, y7, z7,x8, y8, z8,x9, y9, z9,x10, y10, z10,x11, y11, z11,x12, y12, z12,x13, y13, z13,x14, y14, z14,x15, y15, z15,x16, y16, z16,x17, y17, z17,x18, y18, z18,x19, y19, z19,x20, y20, z20];(* local coordinates *)Clear[u, v, w];(* Global co-ordinates *)Clear[x, y, z];(* corner nodes *)N1= (1-u)*(1-v)*(1-w)*(-2-u-v-w)/8;N3= (1+u)*(1-v)*(1-w)*(-2+u-v-w)/8;N5= (1+u)*(1+v)*(1-w)*(-2+u+v-w)/8;N7= (1-u)*(1+v)*(1-w)*(-2-u+v-w)/8;N13=(1-u)*(1-v)*(1+w)*(-2-u-v+ w)/8;N15=(1+u)*(1-v)*(1+w)*(-2+u-v+w)/8;N17=(1+u)*(1+v)*(1+w) *(-2+u+v+w)/8;N19=(1-u)*(1+v)*(1+w)*(-2-u+v+w)/8;(* to u nodes *)N2= (1-u^2)*(1-v)*(1-w)/4;N6= (1-u^2)*(1+v)*(1-w)/4;N14=(1-u^2)*(1-v)*(1+w)/4;N18=(1-u^2)*( 1+v)*(1+w)/4;(* to v nodes *)N4= (1+u)*(1-v^2)*(1-w)/4;N8= (1-u)*(1-v^2)*(1-w)/4;N16=(1+u)*(1-v^2)*(1+w)/4;N20=(1-u)*(1- v^2)*(1+w)/4;(* to w nodes *)N9= (1-u)*(1-v)*(1-w^2)/4;N10=(1+u)*(1-v)*(1-w^2)/4;N11=(1+u)*(1+ v)*(1-w^2)/4;N12=(1-u)*(1-v)*(1-w^2)/4;(* solve the inverse transform *)Solve[{x1*N1+x2*N2+x3*N3+x4*N4+x5*N5+x6*N6+x7*N7+x8*N8+x9* N9+x10*N10+x11*N11+x12*N12+x13*N13+x14*N14+x15*N15+x16*N16+ x17*N17+x18*N18+x19*N19+x20*N20-x==0,y1*N1+y2*N2+y3*N3+y4*N4+ y5*N5+y6*N6+y7*N7+y8*N8+y9*N9+y10*N10+y11*N11+y12*N12+y13*N13 +y14*N14+y15*N15+y16*N16+y17*N17+y18*N18+y19*N19+y20*N20-y==0 ,z1*N1+z2*N2+z3*N3+z4*N4+z5*N5+z6*N6+z7*N7+z8*N8+z9*N9+z10* N10+z11*N11+z12*N12+z13*N13+z14*N14+z15*N15+z16*N16+z17*N17+ z18*N18+z19*N19+z20*N20-z==0},{u,v,w}]Christopher J. PurcellDefence R&D Canada - Atlantic9 Grove St., PO Box 1012Dartmouth NS Canada B2Y 3Z7====If I haven¹t missed a step, the following should work nicely -- bestdone before deŽning any of the symbols that appear:Attributes[dummyIf] = HoldAll;Attributes[dummyWhich] = HoldAll;expr = {If[Aa == Ab, a Sa + b Sb, If[Ca == 0 || Cb == 0, a Sa + b Sb,SS]],If[Aa == Ab, a Ca + b Cb, If[Ca == 0 || Cb == 0, a Ca + b Cb, CC]], If[Ca == 0 && Cb == 0,Nil, If[Z1 == Z2, If[Ca < 0, Aa, If[Cb < 0, Ab, If[Ca > 0, If[Aa > 90, Aa - 90, Aa + 90], If[Cb > 0, If[Ab > 90, Ab - 90, Ab + 90]]]]], If[Aa == Ab, Aa, If[Ca == 0 && Cb == 0,Nil, If[ Ca == 0, Ab, If[Cb == 0, Aa, If[Y == 0,Nil, If[X > 180, X - 180, If[X < 0, X + 180, X]]]]]]]]]} /. {If -> dummyIf};rule1 = dummyIf[a_, b_, dummyIf[c_, d_, e_]] -> dummyWhich[a, b, c, d, True, e];rule2 = dummyIf[a_, dummyIf[ b_, c_, d_], e_] -> dummyWhich[a && b, c, a, d, True,e];rule3 = dummyIf[a_, dummyIf[b_, c_, d_]] -> dummyWhich[a && b, c, a, d];rule4 = dummyWhich[a__, b_, dummyIf[c_, d_, e_], f___] -> dummyWhich[a, b && c, d, b, e, f];rule5 = dummyWhich[a__, b_, dummyWhich[c_, d_, e___], f___] -> dummyWhich[a, b && c, d, b, dummyWhich[e], f];rule6 = dummyWhich[] :> Null;rule7 = HoldPattern[True && a_] :> a;expr //. {rule1, rule2, rule3, rule4, rule5, rule6, rule7} /. {dummyWhich -> WhichThe result of that last line is:{Which[Aa == Ab, a Sa + b Sb, Ca == 0 || Cb == 0, a Sa + b Sb, True, SS], Which[Aa == Ab, a Ca + b Cb, Ca == 0 || Cb == 0, a Ca + b Cb, True, CC], Which[Ca == 0 && Cb == 0,Nil, Z1 == Z2 && Ca < 0, Aa, Z1 == Z2 && Cb < 0, Ab, (Z1 == Z2 && Ca > 0) && Aa > 90, Aa - 90, Z1 == Z2 && Ca > 0, Aa + 90, Z1 == Z2 && (Cb > 0 && Ab > 90), Ab - 90, Z1 == Z2 && Cb > 0, Ab + 90, Z1 == Z2, Null, Aa == Ab, Aa, Ca == 0 && Cb == 0,Nil, Ca == 0, Ab, Cb == 0, Aa, Y == 0,Nil, X > 180, X - 180, X < 0, X + 180, True, X]}I¹ve used Null where that would be the result of your original logic --maybe you want it to beNil. Or maybe you want to use Null instead ofNil. Your choice. Wherever you see Null, there¹s possibly a case youhaven¹t covered.Bobby Treat-----Original Message----- If[Aa == Ab, a Ca + b Cb, If[Ca == 0 || Cb == 0, a Ca + b Cb, CC]], If[Ca == 0 && Cb == 0,Nil, If[Z1 == Z2, If[Ca < 0, Aa, If[Cb < 0,Ab, If[Ca > 0, If[Aa > 90, Aa - 90, Aa + 90], If[Cb > 0, If[Ab > 90, Ab - 90, Ab + 90]]]]], If[Aa == Ab, Aa, If[Ca == 0 && Cb == 0,Nil, If[Ca == 0, Ab, If[Cb == 0, Aa, If[Y == 0,Nil, If[X > 180, X - 180, If[X < 0, X + 180, X]]]]]]]]]}====Dear Group,I have a program to take the local polynomial non parametric regressionof two variables. It uses Compile, unfortunately, and regularly, butinconsistently, causes Mathematica to crash (in Win2K, with I forgetwhat error, and in Win98/Mathematica4.0 with an invalid memory access fromMathDLL.dll). I am running Mathematica 4.1, and have this problem consistentlyon 4 different machines.Here is the code, if it doesn¹t crash the Žrst time, it will the secondor third:(*w = Compile[{{xj, _Real, 0}, {XX, _Real, 1}, {YY, _Real, 1}, {h, _Real,0}, {nn, _Integer, 0}, {ord, _Integer, 0}},First[Inverse[Sum[Outer[Times, Table[If[Positive[q], (XX[[i]] - xj)^q,1], {q, 0, ord}],Table[If[Positive[q], (XX[[i]] - xj)^q, 1.], {q, 0,ord}]*E^(-0.5*((XX[[i]] - xj)/h)^2)], {i, nn}]] .Sum[(Table[If[Positive[q], (XX[[i]] - xj)^q, 1.], {q, 0, ord}]*YY[[i]])*E^(-0.5*((XX[[i]] - xj)/h)^2), {i, nn}]]];*)(*!(tt = MemoryInUse[]; ListPlot[Table[{((i + 1))^2, (Timing[ nn = ((i + 1))^2; [Epsilon] = Table[Random[]*3, {i,nn}]; testX = Table[i* .3 - Random[]*2, {i, nn}]; testY = Table[Sin[i/3] - 2, {i, nn}] + [Epsilon]; Map[w[#, testX, testY, .1 + Random[], nn, 0] &, testX];])[([1])]/Second}, {i, 15}], PlotJoined ->True, PlotLabel -> ]; MemoryInUse[] - tt)*)I have followed Ted Ersek¹s tips and tricks(http://www.verbeia.com/mathematica/tips/tip_index.html ) about Compile,and have tried changing all variable names (works sometimes), removingany hidden spaces, restructuring the formulas, changing all 0¹s to 0. Œsand all 1¹s to 1. Œs, etcetera etcetera, but I still can¹t comprehendwhat the problem might be. Doingw[[-2]] shows a list of op-codenumbers, and one function name, Inverse[#1]&, so it seems to me thatthere are no problems with the use of Compile here. Would anyone haveany thoughts???Bernard Gressburnthebiscuit@netscape.net====Expanding on my earlier simpliŽcation of the Moran Research code, Istudied the problem a little more and found another useful Rule and aRule that should help but doesn¹t. Maybe somebody can explain what I¹mdoing wrong on that one.My earlier result (after applying rule1, ... rule7) had the following asthird element of a List in the deŽnition of f:Which[ Ca == 0 && Cb == 0,Nil, Z1 == Z2 && Ca < 0, Aa, Z1 == Z2 && Cb < 0, Ab, (Z1 == Z2 && Ca > 0) && Aa > 90, Aa - 90, Z1 == Z2 && Ca > 0, Aa + 90, Z1 == Z2 && (Cb > 0 && Ab > 90), Ab - 90, Z1 == Z2 && Cb > 0, Ab + 90, Z1 == Z2, Null, Aa == Ab, Aa, Ca == 0 && Cb == 0,Nil, Ca == 0, Ab, Cb == 0, Aa, Y == 0,Nil, X > 180, X - 180, X < 0, X + 180, True, X]Several things occurred to me in terms of simplifying this. The Žrstwas that the last six arguments of Which could be replaced with two, asfollows:Which[ Ca == 0 && Cb == 0,Nil, Z1 == Z2 && Ca < 0, Aa, Z1 == Z2 && Cb < 0, Ab, (Z1 == Z2 && Ca > 0) && Aa > 90, Aa - 90, Z1 == Z2 && Ca > 0, Aa + 90, Z1 == Z2 && (Cb > 0 && Ab > 90), Ab - 90, Z1 == Z2 && Cb > 0, Ab + 90, Z1 == Z2, Null, Aa == Ab, Aa, Ca == 0 && Cb == 0,Nil, Ca == 0, Ab, Cb == 0, Aa, Y == 0,Nil, True,Mod[X,180]]This probably has no advantage other than clarity, but that¹s worththe others:rule8 = dummyIf[a_ > b_, a_ - b_, dummyIf[a_ < 0, a_ + b_, a_]] :>Mod[a, b];but it had no effect on the expression. Apparently there was no match,and I can¹t see why.The second thing I noticed was that the conditionCa == 0 && Cb == 0occurs twice in the Which statement. The following rule Žxes that kindof situation:rule9 = dummyWhich[a___, b_, c_, d__, b_, e_, f__] /; EvenQ[Length[List[a]]] &&EvenQ[Length[List[d]]] && EvenQ[Length[List[f]]] :> dummyWhich[a, b, c, d, f];expr //. {rule1, rule2, rule3, rule4, rule5, rule6, rule7, rule9}The third thing I noticed was the treatment of Aa and Ab. TheexpressionsIf[Aa > 90, Aa - 90, Aa + 90]If[Ab > 90, Ab - 90, Ab + 90]in the original expression may be equivalent (depending on what¹s knownabout Aa and Ab a priori) to:Mod[Aa+90,180]Mod[Ab+90,180]If that is a valid assumption in the situation (no way for me to know),the expression is nowWhich[ Ca == 0 && Cb == 0,Nil, Z1 == Z2 && Ca < 0, Aa, Z1 == Z2 && Cb < 0, Ab, Z1 == Z2 && Ca > 0, Mod[Aa + 90, 180], Z1 == Z2 && Cb > 0, Mod[Ab + 90, 180], Z1 == Z2, Null, Aa == Ab, Aa, Ca == 0, Ab, Cb == 0, Aa, Y == 0,Nil, True, Mod[X, 180]]The next thing I notice is that the sixth condition, Z1==Z2, whichresults in Null if found True, isn¹t needed. If Z1==Z2 then one of theŽrst Žve conditions is also true, so execution wouldn¹t get that far.Hence we can delete that condition-response pair.Finally, I¹m stopping with this:Which[ Ca == 0 == Cb,Nil, Z1 == Z2 && Ca < 0, Aa, Z1 == Z2 && Cb < 0, Ab, Z1 == Z2 && Ca > 0, Mod[Aa + 90, 180], Z1 == Z2 && Cb > 0, Mod[Ab + 90, 180], Aa == Ab, Aa, Ca == 0, Ab, Cb == 0, Aa, Y == 0,Nil, True, Mod[X, 180]]I have no idea what you¹re actually doing with this code, but it looksweird even AFTER I¹ve simpliŽed it.Bobby Treat-----Original Message----- 0, Aa, If[Cb < 0, Ab, If[Ca > 0, If[Aa > 90, Aa - 90, Aa + 90], If[Cb > 0, If[Ab > 90, Ab - 90, Ab + 90]]]]], If[Aa == Ab, Aa, If[Ca == 0 && Cb == 0,Nil, If[ Ca == 0, Ab, If[Cb == 0, Aa, If[Y == 0,Nil, If[X > 180, X - 180, If[X < 0, X + 180, X]]]]]]]]]} /. {If -> dummyIf};rule1 = dummyIf[a_, b_, dummyIf[c_, d_, e_]] -> dummyWhich[a, b, c, d, True, e];rule2 = dummyIf[a_, dummyIf[ b_, c_, d_], e_] -> dummyWhich[a && b, c, a, d, True,e];rule3 = dummyIf[a_, dummyIf[b_, c_, d_]] -> dummyWhich[a && b, c, a, d];rule4 = dummyWhich[a__, b_, dummyIf[c_, d_, e_], f___] -> dummyWhich[a, b && c, d, b, e, f];rule5 = dummyWhich[a__, b_, dummyWhich[c_, d_, e___], f___] -> dummyWhich[a, b && c, d, b, dummyWhich[e], f];rule6 = dummyWhich[] :> Null;rule7 = HoldPattern[True && a_] :> a;expr //. {rule1, rule2, rule3, rule4, rule5, rule6, rule7} /. {dummyWhich -> WhichThe result of that last line is:{Which[Aa == Ab, a Sa + b Sb, Ca == 0 || Cb == 0, a Sa + b Sb, True, SS], Which[Aa == Ab, a Ca + b Cb, Ca == 0 || Cb == 0, a Ca + b Cb, True, CC], Which[Ca == 0 && Cb == 0,Nil, Z1 == Z2 && Ca < 0, Aa, Z1 == Z2 && Cb < 0, Ab, (Z1 == Z2 && Ca > 0) && Aa > 90, Aa - 90, Z1 == Z2 && Ca > 0, Aa + 90, Z1 == Z2 && (Cb > 0 && Ab > 90), Ab - 90, Z1 == Z2 && Cb > 0, Ab + 90, Z1 == Z2, Null, Aa == Ab, Aa, Ca == 0 && Cb == 0,Nil, Ca == 0, Ab, Cb == 0, Aa, Y == 0,Nil, X > 180, X - 180, X < 0, X + 180, True, X]}I¹ve used Null where that would be the result of your original logic --maybe you want it to beNil. Or maybe you want to use Null instead ofNil. Your choice. Wherever you see Null, there¹s possibly a case youhaven¹t covered.Bobby Treat-----Original Message----- If[Aa == Ab, a Ca + b Cb, If[Ca == 0 || Cb == 0, a Ca + b Cb, CC]], If[Ca == 0 && Cb == 0,Nil, If[Z1 == Z2, If[Ca < 0, Aa, If[Cb < 0,Ab, If[Ca > 0, If[Aa > 90, Aa - 90, Aa + 90], If[Cb > 0, If[Ab > 90, Ab - 90, Ab + 90]]]]], If[Aa == Ab, Aa, If[Ca == 0 && Cb == 0,Nil, If[Ca == 0, Ab, If[Cb == 0, Aa, If[Y == 0,Nil, If[X > 180, X - 180, If[X < 0, X + 180, X]]]]]]]]]}====Sorry... ONE MORE simpliŽcation:Which[ Ca == 0 == Cb,Nil, Z1 == Z2, Which[Ca < 0, Aa, Cb < 0, Ab, Ca > 0, Mod[Aa + 90, 180], Cb > 0, Mod[Ab + 90, 180]], Aa == Ab, Aa, Ca == 0, Ab, Cb == 0, Aa, Y == 0,Nil, True, Mod[X, 180]]I didn¹t like repeating the Z1==Z2 test.Upon noticing this, I thought at Žrst that my rule5 caused thissituation to occur, but actually I have to delete both rule 4 AND rule5to eliminate it, and the resulting expression wouldn¹t be as easy tounderstand.Bobby Treat-----Original Message----- Z1 == Z2 && Ca < 0, Aa, Z1 == Z2 && Cb < 0, Ab, (Z1 == Z2 && Ca > 0) && Aa > 90, Aa - 90, Z1 == Z2 && Ca > 0, Aa + 90, Z1 == Z2 && (Cb > 0 && Ab > 90), Ab - 90, Z1 == Z2 && Cb > 0, Ab + 90, Z1 == Z2, Null, Aa == Ab, Aa, Ca == 0 && Cb == 0,Nil, Ca == 0, Ab, Cb == 0, Aa, Y == 0,Nil, X > 180, X - 180, X < 0, X + 180, True, X]Several things occurred to me in terms of simplifying this. The Žrstwas that the last six arguments of Which could be replaced with two, asfollows:Which[ Ca == 0 && Cb == 0,Nil, Z1 == Z2 && Ca < 0, Aa, Z1 == Z2 && Cb < 0, Ab, (Z1 == Z2 && Ca > 0) && Aa > 90, Aa - 90, Z1 == Z2 && Ca > 0, Aa + 90, Z1 == Z2 && (Cb > 0 && Ab > 90), Ab - 90, Z1 == Z2 && Cb > 0, Ab + 90, Z1 == Z2, Null, Aa == Ab, Aa, Ca == 0 && Cb == 0,Nil, Ca == 0, Ab, Cb == 0, Aa, Y == 0,Nil, True,Mod[X,180]]This probably has no advantage other than clarity, but that¹s worththe others:rule8 = dummyIf[a_ > b_, a_ - b_, dummyIf[a_ < 0, a_ + b_, a_]] :>Mod[a, b];but it had no effect on the expression. Apparently there was no match,and I can¹t see why.The second thing I noticed was that the conditionCa == 0 && Cb == 0occurs twice in the Which statement. The following rule Žxes that kindof situation:rule9 = dummyWhich[a___, b_, c_, d__, b_, e_, f__] /; EvenQ[Length[List[a]]] &&EvenQ[Length[List[d]]] && EvenQ[Length[List[f]]] :> dummyWhich[a, b, c, d, f];expr //. {rule1, rule2, rule3, rule4, rule5, rule6, rule7, rule9}The third thing I noticed was the treatment of Aa and Ab. TheexpressionsIf[Aa > 90, Aa - 90, Aa + 90]If[Ab > 90, Ab - 90, Ab + 90]in the original expression may be equivalent (depending on what¹s knownabout Aa and Ab a priori) to:Mod[Aa+90,180]Mod[Ab+90,180]If that is a valid assumption in the situation (no way for me to know),the expression is nowWhich[ Ca == 0 && Cb == 0,Nil, Z1 == Z2 && Ca < 0, Aa, Z1 == Z2 && Cb < 0, Ab, Z1 == Z2 && Ca > 0, Mod[Aa + 90, 180], Z1 == Z2 && Cb > 0, Mod[Ab + 90, 180], Z1 == Z2, Null, Aa == Ab, Aa, Ca == 0, Ab, Cb == 0, Aa, Y == 0,Nil, True, Mod[X, 180]]The next thing I notice is that the sixth condition, Z1==Z2, whichresults in Null if found True, isn¹t needed. If Z1==Z2 then one of theŽrst Žve conditions is also true, so execution wouldn¹t get that far.Hence we can delete that condition-response pair.Finally, I¹m stopping with this:Which[ Ca == 0 == Cb,Nil, Z1 == Z2 && Ca < 0, Aa, Z1 == Z2 && Cb < 0, Ab, Z1 == Z2 && Ca > 0, Mod[Aa + 90, 180], Z1 == Z2 && Cb > 0, Mod[Ab + 90, 180], Aa == Ab, Aa, Ca == 0, Ab, Cb == 0, Aa, Y == 0,Nil, True, Mod[X, 180]]I have no idea what you¹re actually doing with this code, but it looksweird even AFTER I¹ve simpliŽed it.Bobby Treat-----Original Message----- 0, Aa, If[Cb < 0, Ab, If[Ca > 0, If[Aa > 90, Aa - 90, Aa + 90], If[Cb > 0, If[Ab > 90, Ab - 90, Ab + 90]]]]], If[Aa == Ab, Aa, If[Ca == 0 && Cb == 0,Nil, If[ Ca == 0, Ab, If[Cb == 0, Aa, If[Y == 0,Nil, If[X > 180, X - 180, If[X < 0, X + 180, X]]]]]]]]]} /. {If -> dummyIf};rule1 = dummyIf[a_, b_, dummyIf[c_, d_, e_]] -> dummyWhich[a, b, c, d, True, e];rule2 = dummyIf[a_, dummyIf[ b_, c_, d_], e_] -> dummyWhich[a && b, c, a, d, True,e];rule3 = dummyIf[a_, dummyIf[b_, c_, d_]] -> dummyWhich[a && b, c, a, d];rule4 = dummyWhich[a__, b_, dummyIf[c_, d_, e_], f___] -> dummyWhich[a, b && c, d, b, e, f];rule5 = dummyWhich[a__, b_, dummyWhich[c_, d_, e___], f___] -> dummyWhich[a, b && c, d, b, dummyWhich[e], f];rule6 = dummyWhich[] :> Null;rule7 = HoldPattern[True && a_] :> a;expr //. {rule1, rule2, rule3, rule4, rule5, rule6, rule7} /. {dummyWhich -> WhichThe result of that last line is:{Which[Aa == Ab, a Sa + b Sb, Ca == 0 || Cb == 0, a Sa + b Sb, True, SS], Which[Aa == Ab, a Ca + b Cb, Ca == 0 || Cb == 0, a Ca + b Cb, True, CC], Which[Ca == 0 && Cb == 0,Nil, Z1 == Z2 && Ca < 0, Aa, Z1 == Z2 && Cb < 0, Ab, (Z1 == Z2 && Ca > 0) && Aa > 90, Aa - 90, Z1 == Z2 && Ca > 0, Aa + 90, Z1 == Z2 && (Cb > 0 && Ab > 90), Ab - 90, Z1 == Z2 && Cb > 0, Ab + 90, Z1 == Z2, Null, Aa == Ab, Aa, Ca == 0 && Cb == 0,Nil, Ca == 0, Ab, Cb == 0, Aa, Y == 0,Nil, X > 180, X - 180, X < 0, X + 180, True, X]}I¹ve used Null where that would be the result of your original logic --maybe you want it to beNil. Or maybe you want to use Null instead ofNil. Your choice. Wherever you see Null, there¹s possibly a case youhaven¹t covered.Bobby Treat-----Original Message----- If[Aa == Ab, a Ca + b Cb, If[Ca == 0 || Cb == 0, a Ca + b Cb, CC]], If[Ca == 0 && Cb == 0,Nil, If[Z1 == Z2, If[Ca < 0, Aa, If[Cb < 0,Ab, If[Ca > 0, If[Aa > 90, Aa - 90, Aa + 90], If[Cb > 0, If[Ab > 90, Ab - 90, Ab + 90]]]]], If[Aa == Ab, Aa, If[Ca == 0 && Cb == 0,Nil, If[Ca == 0, Ab, If[Cb == 0, Aa, If[Y == 0,Nil, If[X > 180, X - 180, If[X < 0, X + 180, X]]]]]]]]]}====If x1 through x20 aren¹t unknowns, you should have told me their values.If you can¹t, they are UNKNOWN.True, you¹re not solving for them... but they affect the dimensionalityof the problem just as if you WERE solving for them. You have a20-dimensional space full of contingencies -- solution forms that dependon the values of x1 through x20. The Solve function won¹t deal withcontingencies even if it could, and if it tried, there would be toomany.Bobby-----Original Message----->Bobby-----Original Message----->Sent: Saturday, September 07, 2002 1:54 AM>resend>Would someone with a very fast machine and lots of memory be willing to>try>this Solve for me?>It is the inverse of the 20 node quadratic hexahedral mapping used in>Žnite element analysis.>None of my computers can handle this - they run out of memory (using(*Hex20 Node deŽnition in global coordinates *)>Clear[>x1, y1, z1,>x2, y2, z2,>x3, y3, z3,>x4, y4, z4,>x5, y5, z5,>x6, y6, z6,>x7, y7, z7,>x8, y8, z8,>x9, y9, z9,>x10, y10, z10,>x11, y11, z11,>x12, y12, z12,>x13, y13, z13,>x14, y14, z14,>x15, y15, z15,>x16, y16, z16,>x17, y17, z17,>x18, y18, z18,>x19, y19, z19,>x20, y20, z20];(* local coordinates *)>Clear[u, v, w];(* Global co-ordinates *)>Clear[x, y, z];(* corner nodes *)>N1= (1-u)*(1-v)*(1-w)*(-2-u-v-w)/8;>N3= (1+u)*(1-v)*(1-w)*(-2+u-v-w)/8;>N5= (1+u)*(1+v)*(1-w)*(-2+u+v-w)/8;>N7= (1-u)*(1+v)*(1-w)*(-2-u+v-w)/8;>N13=(1-u)*(1-v)*(1+w)*(-2-u-v +w)/8;>N15=(1+u)*(1-v)*(1+w)*(-2+u-v+w)/8;>N17=(1+u)*(1+v)*(1 +w)*(-2+u+v+w)/8;>N19=(1-u)*(1+v)*(1+w)*(-2-u+v+w)/8;>(* to u nodes *)>N2= (1-u^2)*(1-v)*(1-w)/4;>N6= (1-u^2)*(1+v)*(1-w)/4;>N14=(1-u^2)*(1-v)*(1+w)/4;>N18=(1-u^2) *(1+v)*(1+w)/4;>(* to v nodes *)>N4= (1+u)*(1-v^2)*(1-w)/4;>N8= (1-u)*(1-v^2)*(1-w)/4;>N16=(1+u)*(1-v^2)*(1+w)/4;>N20=(1-u)*( 1-v^2)*(1+w)/4;>(* to w nodes *)>N9= (1-u)*(1-v)*(1-w^2)/4;>N10=(1+u)*(1-v)*(1-w^2)/4;>N11=(1+u)*( 1+v)*(1-w^2)/4;>N12=(1-u)*(1-v)*(1-w^2)/4;(* solve the inverse transform *)>Solve[{>x1*N1+x2*N2+x3*N3+x4*N4+x5*N5+x6*N6+x7*N7+x8*N8+x9 *N9+x10*N10+>x11*N11+x12*N12+x13*N13+x14*N14+x15*N15+x16*N16+ x17*N17+x18*N18+x19*N19+>x20*N20-x==0,>y1*N1+y2*N2+y3*N3+y4* N4+y5*N5+y6*N6+y7*N7+y8*N8+y9*N9+y10*N10+>y11*N11+y12*N12+y13 *N13+y14*N14+y15*N15+y16*N16+y17*N17+y18*N18+y19*N19+>y20*N20 -y==0,>z1*N1+z2*N2+z3*N3+z4*N4+z5*N5+z6*N6+z7*N7+z8*N8+z9*N9+ z10*N10+>z11*N11+z12*N12+z13*N13+z14*N14+z15*N15+z16*N16+z17* N17+z18*N18+z19*N19+>z20*N20-z==0},>{u,v,w}]>Christopher J. Purcell>Defence R&D Canada - Atlantic>9 Grove St., PO Box 1012>Dartmouth NS Canada B2Y 3Z7Christopher J. PurcellDefence R&D Canada - Atlantic9 Grove St., PO Box 1012Dartmouth NS Canada B2Y 3Z7====If we do think of x1...x20 as constants, it¹s still fourth-order, withthree simultaneous equations. Evaluate this:Solve[a x^4 + b x^3 + c x^2 + d x + e == 0, x]and look at the four solutions found -- for a single variable and oneequation!For your problem, I¹m thinking there¹d be at least 4^3 solutions, eachof them even more complicated than these, and an unknown number ofcontingencies to deal with, depending on values of the xi. Check eachradical for a negative argument, and the special cases multiply quickly.For some values of the xi, there¹d be no solutions; for other values,many solutions.If you do manage to solve this, I¹d love to see the method!Bobby-----Original Message-----many.Bobby-----Original Message----->Bobby-----Original Message----->Sent: Saturday, September 07, 2002 1:54 AM>resend>Would someone with a very fast machine and lots of memory be willing to>try>this Solve for me?>It is the inverse of the 20 node quadratic hexahedral mapping used in>Žnite element analysis.>None of my computers can handle this - they run out of memory (using(*Hex20 Node deŽnition in global coordinates *)>Clear[>x1, y1, z1,>x2, y2, z2,>x3, y3, z3,>x4, y4, z4,>x5, y5, z5,>x6, y6, z6,>x7, y7, z7,>x8, y8, z8,>x9, y9, z9,>x10, y10, z10,>x11, y11, z11,>x12, y12, z12,>x13, y13, z13,>x14, y14, z14,>x15, y15, z15,>x16, y16, z16,>x17, y17, z17,>x18, y18, z18,>x19, y19, z19,>x20, y20, z20];(* local coordinates *)>Clear[u, v, w];(* Global co-ordinates *)>Clear[x, y, z];(* corner nodes *)>N1= (1-u)*(1-v)*(1-w)*(-2-u-v-w)/8;>N3= (1+u)*(1-v)*(1-w)*(-2+u-v-w)/8;>N5= (1+u)*(1+v)*(1-w)*(-2+u+v-w)/8;>N7= (1-u)*(1+v)*(1-w)*(-2-u+v-w)/8;>N13=(1-u)*(1-v)*(1+w)*(-2-u-v +w)/8;>N15=(1+u)*(1-v)*(1+w)*(-2+u-v+w)/8;>N17=(1+u)*(1+v)*(1 +w)*(-2+u+v+w)/8;>N19=(1-u)*(1+v)*(1+w)*(-2-u+v+w)/8;>(* to u nodes *)>N2= (1-u^2)*(1-v)*(1-w)/4;>N6= (1-u^2)*(1+v)*(1-w)/4;>N14=(1-u^2)*(1-v)*(1+w)/4;>N18=(1-u^2) *(1+v)*(1+w)/4;>(* to v nodes *)>N4= (1+u)*(1-v^2)*(1-w)/4;>N8= (1-u)*(1-v^2)*(1-w)/4;>N16=(1+u)*(1-v^2)*(1+w)/4;>N20=(1-u)*( 1-v^2)*(1+w)/4;>(* to w nodes *)>N9= (1-u)*(1-v)*(1-w^2)/4;>N10=(1+u)*(1-v)*(1-w^2)/4;>N11=(1+u)*( 1+v)*(1-w^2)/4;>N12=(1-u)*(1-v)*(1-w^2)/4;(* solve the inverse transform *)>Solve[{>x1*N1+x2*N2+x3*N3+x4*N4+x5*N5+x6*N6+x7*N7+x8*N8+x9 *N9+x10*N10+>x11*N11+x12*N12+x13*N13+x14*N14+x15*N15+x16*N16+ x17*N17+x18*N18+x19*N19+>x20*N20-x==0,>y1*N1+y2*N2+y3*N3+y4* N4+y5*N5+y6*N6+y7*N7+y8*N8+y9*N9+y10*N10+>y11*N11+y12*N12+y13 *N13+y14*N14+y15*N15+y16*N16+y17*N17+y18*N18+y19*N19+>y20*N20 -y==0,>z1*N1+z2*N2+z3*N3+z4*N4+z5*N5+z6*N6+z7*N7+z8*N8+z9*N9+ z10*N10+>z11*N11+z12*N12+z13*N13+z14*N14+z15*N15+z16*N16+z17* N17+z18*N18+z19*N19+>z20*N20-z==0},>{u,v,w}]>Christopher J. Purcell>Defence R&D Canada - Atlantic>9 Grove St., PO Box 1012>Dartmouth NS Canada B2Y 3Z7Christopher J. PurcellDefence R&D Canada - Atlantic9 Grove St., PO Box 1012Dartmouth NS Canada B2Y 3Z7====The documentation you¹re talking about doesn¹t even deserve to be calleddocumentation. A few hints; that¹s it.Bobby Treat-----Original Message-----> unable to Žnd a complete guide to word processing with mathematica.> Does anyone know where such a document could be found?====This is a question that¹s been asked and answered a number of times. Oneanswer, by me, can be found by going to www.wolfram.com and selectingŽrst Resource Library and then MathGroup on the Resource Library page;then search fordirection Želd. You¹ll Žnd, among many others, the URL: http://library.wolfram.com/mathgroup/archive/2002/Jul/ msg00163.html(This is not to chastise you for not Žrst looking there, but to suggesta way for you to Žnd answers more efŽciently than waiting for theou need to load the package, then manufacture a vector Želd whose plotis theslope Želd (what you callvector žow diagram). To do thelatter, let me separately deŽne the function giving the right-hand sideof the ODE; you don¹t really have to do that, but could instead directlyuse as the Žrst argument to PlotVectorField the right-hand side of mydeŽnition of f. << Graphics`PlotField` f[t_, y_] := {1, 1/y} Želd = PlotVectorField[f[t, y], {t, 0, 3}, {y, 0.05, 3}];I gave a name to the graphics result just in order to re-display theŽeld below along with the graph of one solution. First, Žnd a generalsolution: soln = First @ DSolve[{y¹[t] == 1/y[t], y[0] == 1}, y[t], t]{y[t] -> Sqrt[2]*Sqrt[1/2 + t]} grf = Plot[y[t] /. soln, {t, 0, 3}];Now combine the plot with the Želd: Show[grf, Želd];Note that PlotVectorField does not always give quite the result youmight want, since the vector lengths are scaled with respect to themagnitude of the actual vectors. You might want just adirectionŽeld in which all arrows have the same length. You can produce such agraphic by using the ScaleFunction and ScaleFactor options toPlotVectorField. For example: Želd = PlotVectorField[f[t, y], {t, 0, 3}, {y, 0.05, 3}, ScaleFunction -> (1 &), ScaleFactor -> 0.175];... I have several differential equations I would like toplot in Mathematica. I would like to plot the Slope Fields of themthough. Can anyone lead me in the right direction? I can solve theequations trivially but I want to display the slope Želds. An examplefollows :y¹ + 2y = 3...--Murray Eisenberg murray@math.umass.eduMathematics & Statistics Dept.Lederle Graduate Research Tower phone 413 549-1020 (H)University of Massachusetts 413 545-2859 (W)710 North Pleasant StreetAmherst, MA 01375====I am trying to implement a very simple sorted tree to quickly store somereal numbers I need. I have written an add, delete, minimum, and pop(delete the lowest value) function and they seem to work ok but are veryslow. Let¹s just look @ my implementation of the add part:nums=Null;(*my initial blank Tree)In[326]:=Clear[add]In[327]:=add[Null,x_Real]:=node[x, Null,Null]add[Null,node[x_Real,lower_,higher_]]=node[x,lower, higher]In[328]:=add[node[x_Real,lower_,higher_],y_Real]:= If[x>y,node[x,add[lower,y],higher],node[x,lower,add[higher,y] ]]In[288]:=add[node[x_Real,lowerx_,higherx_],node[y_Real, lowery_,highery_]]:=If[x>y, node[x,add[lowerx,node[y,lowery,highery]],higherx], node[x,lowerx,add[higherx,node[y,lowery,highery]]] ]Now this is my attempt to test how fast my add works:SeedRandom[5];Do[nums=add[nums,Random[]],{5000}];// TimingOut[333]={13.279 Second,Null}running on an 1.4GHz Athlon with 1GB of ram).Questions:1. Is this as fast as I can get my code to run?2. Am I doing something obviously stupid?3. would Compiling things help?Husain====The vectors that NullSpace gives do not need to be orthogonal toeach other. What about the following variant, that adds one vectorat a time? It may not be fast enough for serious number crunching.OrthogonalComplement[v__ /; MatrixQ[{v}]] := With[{n = Length[NullSpace[{v}]]}, Take[Nest[Join[{First[NullSpace[#]]}, #] &, {v}, n], n]];OrthonormalComplement[v__ /; MatrixQ[{v}]] := Map[#/Sqrt[#.#] &, OrthogonalComplement[v]];When the input of OrthogonalComplement is integer, I expect the outputto be integer too:OrthogonalComplement[{1, 2, 3}]{{1, -5, 3}, {-3, 0, 1}} Gianluca Gorni> OrthogonalUnitVectors that I sent a few minutes ago doesn¹t do what I> thought it would.> After making either deŽnition below I get the following:> In[2]:=> s1=OrthogonalUnitVectors[{1,0,1/2,1,0},{0,1,-1,1/2,2}]> Out[2]=> {{0, -2/Sqrt[5], 0, 0, 1/Sqrt[5]}, {-2/3, -1/3, 0, 2/3, 0}, {-1/3, 2/3,> 2/3, 0, 0}}> The dot products below aren¹t zero, so the vectors aren¹t orthogonal. What> went wrong?> In[3]:= > Part[s1,1].Part[s1,2]> Out[3]=> 2/(3*Sqrt[5])> In[4]:= > Part[s1,1].Part[s1,3]> Out[3]=> -4/(3*Sqrt[5])> --------------> Hugh Goyder and David Park gave a most elegant function to Žnd two> vectors that are orthogonal to one vector in 3D. The key to coming up> with the elegant solution is an understanding of Mathematica¹s NullSpace> function. We can easily make the version from Hugh and David much more> general with the version below.> -------------> OrthogonalUnitVectors[vect__?VectorQ]:=> #/Sqrt[#.#]&/@NullSpace[{vect}]> -------------> The version above will give a set of unit orthogonal vectors if given any> number of vectors in any dimension.> So besides giving it a 3D vector we can give it the following:> OrthogonalUnitVectors[{2,1,0,-1,1}]> or> OrthogonalUnitVectors[{0,1,0,1/2,1},{1,0,-1,1/2}]> ------------> But the short version above isn¹t very robust.> (1) Clear[x,y,z];NullSpace[{{x,y,z}}]> returns two vectors orthogonal to {x,y,z}, but the two vectors> NullSpace returns aren¹t orthogonal to each other.> So (OrthogonalUnitVectors) should only work with numeric vectors.> (2) We should ensure all the vectors have the same dimension and length> 1.> I give a less concise version below that corrects these problems.> ------------> OrthogonalUnitVectors[vect__?(VectorQ[#,NumericQ]&)]/;> (SameQ@@Length/@{vect})&&(Length[First[{vect}]]>1):=> #/Sqrt[#.#]&/@NullSpace[{vect}]> --------------> Ted Ersek> Get Mathematica tips, tricks from> http://www.verbeia.com/mathematica/tips/Tricks.html> ====I am using MultipleListPlot to plot a range of 2D graphs and have found thatthe last graph, which has a much greater (by a factor of 4) x range than theothers does not plot completely but is truncated in the x direction. Byremoving the Frame, I can see the points where these lie outside the Framebut these are not joined etc. How do I get over this?-Malcolm Woodruff====I noticed the same thing when I attempted to plot data with disjointx-ranges.One way is not to use the MultipleListPlot[] function.You can plot both the lines and the markers by applying Line and Pointgraphics to your datasets. And use Show[] to display everything on oneplot. You can use the PlotSymbol[] function instead of Point. ThePlotSymbol function is available in the MultipleListPlot package to getthe diamond, star, square, etc.Another way is to modify the MultipleListPlot[] function. I modiŽedthe function to do multiple plots on a polar grid.WARNING - I advise you not to change any of the standpackages. Instead,Žrst make a copy then modify it.One of the modiŽcations I made was to change¹pts = First[Transpose[data]]¹ in the handleset function to Œpts=data¹. This seems to work for my application.Hope this helps.Lawrence> I am using MultipleListPlot to plot a range of 2D graphs and have found that> the last graph, which has a much greater (by a factor of 4) x range than the> others does not plot completely but is truncated in the x direction. By> removing the Frame, I can see the points where these lie outside the Frame> but these are not joined etc. How do I get over this?> -> Malcolm Woodruff> ====Group,Sorry for the previous posting. The following solves (to some extent myproblem)< (1) Is there a way in Mathematica 4.2 to put two separate gifs into a> single, cell side by side (with some intervening space), without> having to combine them in some graphics program Žrst? In particular, I¹d like to do that within a text cell. Even in a new Input cell, if I Žrst create a GridBox (via Inut>Create> Table/Matrix/Palette) and then try to insert the Žrst gif (via> Edit>Insert Object>Create from File ....), Mathematica promptly> crashes. (Mathematica 4.2 under Windows 2000.)You could do something like this:grlist = Map[Import[#,GIF]&, {<Žrst Žle>, }]celist = Map[Cell[GraphicsData[PostScript, DisplayString[#]]]&, grlist]CellPrint[Cell[BoxData[GridBox[{celist}]],Text]]This embeds the PostScript versions of these graphics each as inline cellsin a GridBox[] structure.> (2) Is there a way to cause a gif imported into a Mathematica 4.2> notebook to become a hyperlink -- so that when the user clicks on the> gif the hyperlink¹s target is summoned?Again, we embed the PostScript graphic within an inline cell. Here is afunction that does what you describe:createGIFHyperlink[gifImage_String, url_String] := NotebookWrite[EvaluationNotebook[], Cell[BoxData[ ButtonBox[ Cell[GraphicsData[PostScript, DisplayString[Import[gifImage,GIF]]]], ButtonStyle ->Hyperlink, ButtonData :> {URL[url], None}]], Text]]--User Interface Programmer paulh@wolfram.comWolfram Research, Inc.====> 1.) How to Žnd the General Solution for below¹s partial differential> equation?> (y + u) du/dx + y (du/dy) = x - y> ** I used to represent the partial differential symbol.> Can it be solved by function NDSolve in mathematica 4.1? How?It¹s been a while, but I suspect that the presence of the nonlinearconvective term u du/dx alone makes a general solution unlikely. It¹s easyto get a numerical solution for a particular set of boundary conditions, butyou are not guaranteed a solution. For instance, the following choice of aand b are skirting failure, as the diagnostic contour plot shows.Tom BurtonNeeds[Graphics`Colors`]!((soln = With[{a = (-1), b = 1.27, e = 0.001}, solutions = NDSolve[{((y + u[x, y])) [PartialD]_x u[x, y] + y [PartialD]_y u[x, y] == x - y, u[x, b] == 0, u[a, y] == 0}, u, {x, a, 10}, {y, b, 10}]; [IndentingNewLine]Plot3D[ Evaluate[u[x, y] /. [InvisibleSpace]First[solutions]], {x, a, 10}, {y, b, 10}, PlotPoints [Rule] 50]; [IndentingNewLine]ContourPlot[ Evaluate[y + u[x, y] /. [InvisibleSpace]First[solutions]], {x, a, 10}, {y, b, 10}, PlotPoints [Rule] 50, ColorFunction [Rule] ((If[#1 > e, Green, Red] &))][IndentingNewLine]];))====I¹d be happier if I could just control pagination, or if automaticpagination were done sensibly.Yes, I can make a page break where I want one, but I can¹t eliminatepage-breaks that leave tons of white-space at the end of some pages. Insome of my notebooks, Mathematica puts the Žrst cell on a page byitself, using less than an inch --- and NOT because the next cell takesa whole page. If I force the Žrst two cells to stay together, theproblem just moves to the next page.It¹s enough to make Mathematica useless as a word processor all byitself.Bobby Treat-----Original Message-----derivations;- setting typefaces in tables of material.I Žgure most of this is do-able, but I don¹t have the time, orpatience, to spend too much time on it. So, I¹ll be the Žrst customerwhen you write the guide to math publishing in Mathematica - I just hopeyou won¹t have to use LaTeX to write it.Mark Westwood> I would like to use mathematica type papers for my math courses, but> I¹m having trouble formatting documents. Despite searching, I¹ve been> unable to Žnd a complete guide to word processing with mathematica.> Does anyone know where such a document could be found?====Bobby,Have a look at theGlue palette found here:---Selwyn Hollis> I¹d be happier if I could just control pagination, or if automatic> pagination were done sensibly.> Yes, I can make a page break where I want one, but I can¹t eliminate> page-breaks that leave tons of white-space at the end of some pages. In> some of my notebooks, Mathematica puts the Žrst cell on a page by> itself, using less than an inch --- and NOT because the next cell takes> a whole page. If I force the Žrst two cells to stay together, the> problem just moves to the next page.> It¹s enough to make Mathematica useless as a word processor all by> itself.> Bobby Treat> -----Original Message-----> Kenny,> Sympathy but no solution.> I too have been trying to use Mathematica (v4.2 most recently) to type> maths papers and the like but I¹m not ready to ditch LaTeX yet. There> are just too many cases where I cannot Žgure out how to achieve what I> want in Mathematica, things like:> - left brackets spanning multiple lines for deŽning hybrid functions;> - vertical alignment of equals signs in multi-line equations or> derivations;> - setting typefaces in tables of material.> I Žgure most of this is do-able, but I don¹t have the time, or> patience, to spend too much time on it. So, I¹ll be the Žrst customer> when you write the guide to math publishing in Mathematica - I just hope> you won¹t have to use LaTeX to write it.> Mark Westwood>>I would like to use mathematica type papers for my math courses, but>>I¹m having trouble formatting documents. Despite searching, I¹ve been>>unable to Žnd a complete guide to word processing with mathematica.>>Does anyone know where such a document could be found?> ====> Wouldn¹t it be nice if NullSpace¹s behavior were DOCUMENTED? Otherwise,> it¹s futile to give it approximate numbers expecting any particular> behavior. Even if it always works, it may not work in the next version> of Mathematica.> BobbyThe expected, and documented, behavior is that the output should be abasis for the null space, that is, solutions of the homogeneous matrixequation A.x==0. If this were to stop working then that would be aserious bug. Is this the behavior you mean?The implementation notes of the manual mention that approximateNullSpace is based on a singular values decomposition. This in factgives resulting vectors that are orthonormal by the usualconjugate-symmetric inner product on C (though these are now notnormal to the original vector in this same inner product, unless theyare real-valued). But this basis-orthogonality is not part of themission of NullSpace and moreover should not become part of it. Hencethat particular (and implementation dependent) aspect of NullSpaceshould not become documented.Daniel LichtblauWolfram Research====Wouldn¹t it be nice if NullSpace¹s behavior were DOCUMENTED? Otherwise,it¹s futile to give it approximate numbers expecting any particularbehavior. Even if it always works, it may not work in the next versionof Mathematica.Bobby-----Original Message-----enough for me. Therefore I modify Ted¹s routine toOrthogonalUnitVectors[vect__?(VectorQ[#, NumericQ] &)] /; (SameQ @@ Length /@ {vect}) && (Length[First[{vect}]] > 1) := #/Sqrt[#.#] & /@ NullSpace[{vect}// N]----------------Lets see what NullSpace does with approximate complex vectors.In[1]:= v1 = {1.0 I, 0.0, 0.5 I, 0.0, 1.0}; v2 = {0.0, 2.0, 1.0 I, 2.0, 0.5}; {v3,v4,v5} = NullSpace[{v1,v2}]Out[3]= {{-0.730153 + 0.*I, 0. - 0.138254*I, 0.250585 + 0.*I, 0. -0.138254*I, 0.+ 0.60486*I}, {0. + 0.*I, -0.515861 + 0.*I, 0. + 0.457321*I, 0.687357 + 0.*I,0.22866+ 0.*I}, {0. + 0.*I, 0.510406 + 0.*I, 0. + 0.740442*I, -0.23274 + 0.*I,0.370221+ 0.*I}}--------In the next line we see NullSpace returned vectors that are orthogonaltothe vectors we gave NullSpace.In[4]:= {v1.v3, v1.v4, v1.v5, v2.v3, v2.v4, v2.v5}//ChopOut[4]= {0, 0, 0, 0, 0, 0}----------However, the vectors returned aren¹t orthogonal to each other.In[5]:= {v3.v4, v3.v5, v4.v5}//ChopOut[5]= {0.229195*I, 0.371087*I, -0.677239}---------I suppose an OrthogonalUnitVectors function that uses NullSpace should (1) Only accept real valued vectors. (2) Ensure NullSpace is given approximate vectors.------ Ted Ersek====Plot[{x,x^2},{x,0,10}]Tomas GarzaMexico City----- Original Message -----====Mario,Here is a fancy version of your plot. I used Text statements within anEpilog option to label the two curves. The regular plot statement allows youto plot a series of functions inclosed in a list.Needs[Graphics`Colors`]Plot[{x, x^2}, {x, 0, 1}, PlotStyle -> {Black, Blue}, Frame -> True, FrameLabel -> {x, y}, PlotLabel ->Comparison of Two Functions, Epilog -> {Text[x, {0.5, 0.55}], Blue, Text[x^2, {0.7, 0.4}]}, Background -> Linen, ImageSize -> 500];David Parkdjmp@earthlink.nethttp://home.earthlink.net/~djmp/Sender: steve@smc.vnet.netApproved: Steven M. Christensen , Moderator====>How can I plot with Mathematica two function in the same graphic? I>explain better: I¹d like to draw a) y=x and b) y=x^2 in the same axesPlot[{x, x^2},{x,-2,2}]====This might be a convenient way of deŽning color functions:ClearAll[cfun]cfun[colors_List, brkPts_List] /; Length@colors == Length@brkPts := Function[z, Which @@ Sequence@Flatten@Transpose[{Less[z, #] & /@ brkPts,colors}]]colors = {White, RoyalBlue, White, Red, White};brkPts = {-0.6, -0.42, 0.4, 0.6, InŽnity};ContourPlot[f[x, y], { x, 0, Pi}, {y, 0, Pi}, PlotPoints -> 30, ColorFunctionScaling ->False,ColorFunction -> cfun[colors, brkPts], Contours -> contourvalues];colors = {Yellow, Peru, Salmon, Apricot, HotPink, Linen};brkPts = {-0.6, -0.42, 0.2, 0.4, 0.6, InŽnity};Timing[ContourPlot[f[x, y], {x, 0, Pi}, {y, 0, Pi}, PlotPoints -> 30, ColorFunctionScaling -> False, ColorFunction -> cfun[colors,brkPts], Contours -> contourvalues];]Bobby Treat-----Original Message-----it is difŽcult to obtain in this plot.contourvalues = Complement[Range[-1, 1, 0.2], {0.}]{-1, -0.8, -0.6, -0.4, -0.2, 0.2, 0.4, 0.6, 0.8, 1.}Now we deŽne a ColorFunction for the plot. I actually colored twodifferentbands to show how you can make a general color function to give eachband adesired color.cfun[z_] := Which[ -0.6 < z < -0.42, RoyalBlue, 0.4 < z < 0.6, Red, True, White]ContourPlot[f[x, y], {x, 0, Pi}, {y, 0, Pi}, PlotPoints -> 30, ColorFunctionScaling -> False, ColorFunction -> cfun, Contours -> contourvalues];Using the option ColorFunctionScaling -> False says that the z valuewill bethe actual value of f[x,y]. Otherwise, in general, it will be scaledbetween0 and 1. It is easier to write a color function when z is the actualvalueof the function.David Parkdjmp@earthlink.nethttp://home.earthlink.net/~djmp/Sender: steve@smc.vnet.netApproved: Steven M. Christensen , Moderator====For what it¹s worth, here¹s a version of Simpson¹s rule that works withboth equally spaced and unequally spaced points.simp = Compile[{x1,y1,x2,y2,x3,y3},With[{h13=x1-x3, h12=x1-x2, h23=x2-x3},(-y1*h23*(2x1-3x2+x3) - y2*h13^2 + y3*h12*(x1-3x2+2x3))*h13/(6h12*h23)]]; ListSimpson[vals_?VectorQ, dx_Real]:= With[{n=Length[vals]},If[OddQ[n], (dx/3)*(First[vals] + Last[vals] + 4*Plus@@vals[[Range[2,n-1,2]]] + 2*Plus@@vals[[Range[3,n-2,2]]]), $Failed]];ListSimpson[datapts_?MatrixQ] := If[OddQ[Length[datapts]], Plus@@(simp@@Flatten[#]&/@ Partition[datapts,3,2]), $Failed] (* equally spaced points*)data = Table[100*Sin[x], {x, 0, 100, 0.001}];ListSimpson[data, .001] // Timing {0.21 Second, 13.7681}(* randomly spaced points *)Table[{data = Sort[Table[With[{x =Random[Real,{0,100}]},{x,100*Sin[x]}],{100001}]];ListSimpson [data] // Timing,With[{xvals = Transpose[data][[1]]},gaps = Drop[RotateLeft[xvals] - xvals, -1];{Min[gaps], Max[gaps]}]},{4}] {{{1.62 Second, 13.8348}, {1.32223*10^-8, 0.0114454}}, {{1.59 Second, 13.8261}, {2.42163*10^-8, 0.0127803}}, {{1.62 Second, 13.8455}, {1.08923*10^-9, 0.0119059}}, {{1.54 Second, 13.7987}, {9.66814*10^-9, 0.0106988}}}---Selwyn Hollis> Mathew, Some possibilities < Integrate[> Interpolation[data, InterpolationOrder[Rule]1][x],> {x,0,100}]//Timing {4.56 Second,13.768} Trapezium rule with equal steps: #[[1]]+#[[-1]]+ 2 Tr[Take[#,{2,-2}]]&[data[[All,2]]] 0.01/2//Timing {0.22 Second,13.768} Trapezium rule with possibly unequal steps (Drop[#1,1] - Drop[#1,-1]).(Drop[#2,-1] + Drop[#2,1])&[> data[[All,1]], data[[All,2]]]/2//Timing {0.83 Second,13.768} --> Allan ---------------------> Allan Hayes> Mathematica Training and Consulting> Leicester UK> www.haystack.demon.co.uk> hay@haystack.demon.co.uk> Voice: +44 (0)116 271 4198> I¹ve tracked down the slow operation of my Mathematica simulation > code to> lie in the ListIntegrate command:> > G[n_] := ListIntegrate[xsec Phi[n], 1]> > where both xsec and Phi[n] are 400 values long.> > Is there a way to speed up ListIntegrate via Compile or a similar > technique?> > Matt> ---> Matthew Rosen> Harvard-Smithsonian Center for Astrophysics> Mail Stop 59> 60 Garden Street> Cambridge, MA 02138> > e: mrosen@cfa.harvard.edu> o: (617) 496-7614>====P.J.,I¹d be very interested in how you created thesefancy cells. Do youopen a cell, push Ctrl-Shift-e, type in all that text, then pushCtrl-Shift-e again?Bobby Treat-----Original Message-----1) Put your function braches in the rows of a grid box structure.2) Add the following options to your cell: ShowAutoStyles -> False SpanMaxSize -> InŽnityThe following cell snippet demonstrates how this inžuences the result.To view it, paste the Cell[] expression into a notebook and then clickonYes when you are prompted on whether the front end should interpret theresult.Cell[BoxData[ FormBox[ RowBox[{ RowBox[{f, (,x, )}], =, RowBox[{{, GridBox[{ {x, RowBox[{x, , <, 0}]}, { SuperscriptBox[x, 2], RowBox[{0, [LessEqual],x, <, 1}]}, { RowBox[{sin, (,x, )}], RowBox[{1, [LessEqual],x, <, 2}]}, { RowBox[{[CapitalGamma], (,x, )}], RowBox[{x, [GreaterEqual], 2}]} }]}]}], TraditionalForm]],DisplayFormula, ShowAutoStyles->False, SpanMaxSize->InŽnity]> - vertical alignment of equals signs in multi-line equations or> derivations;Put your equations in a GridBox and set the ColumnAlignments option to astring containing the equal sign.Cell[BoxData[ FormBox[GridBox[{ { RowBox[{ RowBox[{ RowBox[{3,x}], , +, , RowBox[{4, ,y}]}], , =, , 9}]}, { RowBox[{ RowBox[{ RowBox[{2,x}], , -, , RowBox[{7, ,y}]}], =, RowBox[{32, , -, , RowBox[{sin, (,x, )}]}]}]} }], TraditionalForm]],DisplayFormula, GridBoxOptions->{ColumnAlignments->{=}}]> - setting typefaces in tables of material.I think the Author Tools material that comes with Mathematica 4.2 mightbeable to help you do this.--User Interface Programmer paulh@wolfram.comWolfram Research, Inc.====> I¹d be very interested in how you created thesefancy cells. Do you> open a cell, push Ctrl-Shift-e, type in all that text, then push> Ctrl-Shift-e again?Surely you have grossly overestimated my expertise with Mathematicatypesetting language syntax. :-)Here is the walkthrough for creating each sample cell.Example 1:1) Set down a cell insertion point in your notebook.3) Click on the cell¹s bracket.4) Click on the front end menu command sequence:Format -> Cell Style -> DisplayFormula5) Click on the front end menu command sequence:Cell -> Display As -> TraditionalForm6) Click on the front end menu command:Format -> Option Inspector...7) Make sure that the Option Inspector scope indicator is set toselection.8) Enter the name of the option ShowAutoStyles into the search Želd andpress the Lookup button.9) Change the value of the option ShowAutoStyles from True to False. Thisprevents the front end from showing the left brace with the umatchedsyntax coloring.10) Look up the option SpanMaxSize as was done in step (8).11) Change the value of this option to InŽnity.12) Close the Option Inspector dialog.13) Click within the cell you just created to create an editor caret.14) Type in the text f(x) = {4 x 2.17) Enter in the function branch deŽnitions in the left column, and thedomains of deŽnition in the right column. You can use the Tab key tonavigate between grid elements.Example 2:1) Repeat Steps (1) - (11) in Example 1.2) With the cell bracket still selected, look up the option namedColumnAlignments. Change it from {Center} to {=}.3) Close the Option Inspector dialog.4) Click within the cell you just created to create an editor caret.6) Enter in the equations, with one equation per grid element.I used the front end menu command Edit -> Copy As -> Cell Expression toget the underlying expressions.Hope that demystiŽes the procedure for you.--User Interface Programmer paulh@wolfram.comWolfram Research, Inc.====You¹re not doing anything dumb as far as I can see, but you¹re using farmore memory than necessary. Here are statistics for your algorithm onmy machine:SeedRandom[5];nums = NullDo[nums = add[nums, Random[]], {5000}]; // Timingnums // LeafCountnums // ByteCountCount[nums, Null, InŽnity]Count[nums, node[_, Null, _], InŽnity]Count[nums, node[_, _, Null], InŽnity]Count[nums, node[_, Null, Null], InŽnity]Count[nums, node[___], InŽnity]Count[nums, node[_, _node | _?NumericQ, _node | _?NumericQ], InŽnity]Depth[nums]{4.406000000000001*Second, Null}150012400005001 (* Null values in the tree *)2458 (* nodes without left offspring *)2543 (* nodes without right offspring *)1669 (* leaf nodes *)4999 (* total nodes *)1667 (* nodes with both left and right offspring *)28 (* minus one, makes 27 levels in the tree *)It¹s clearly not ideal to store 5001 Nulls for 5000 actual values!Here¹s a method that doesn¹t change the algorithm much, but changes thestorage method a great deal:First of all, I¹m lazy, so I¹ll redeŽne <,>,<=,>=, etc. to make thecode simpler:Unprotect[Less, Greater, LessEqual, GreaterEqual];Less[a : _node ..] := Less @@ (First /@ {a})LessEqual[a : _node ..] := LessEqual @@ (First /@ {a})Greater[a : _node ..] := Greater @@ (First /@ {a})GreaterEqual[a : _node ..] := GreaterEqual @@ (First /@ {a})Protect[Less, Greater, LessEqual, GreaterEqual];Again because I¹m lazy, I¹ll deŽnenode so that I don¹t have toconsciously avoid leaf nodes and unnecessary nesting:ClearAll[node]node[a___, node[b_], c___] = node[a, b, c];node[node[a__]] = node[a];Here¹s myadd function:Clear[add]add[Null, x_] = node[x];add[x_, (y_)?NumericQ] := add[node[x], node[y]]add[(x_)?NumericQ, y_] := add[node[x], node[y]]add[node[x_], node[y_]] := If[x > y, node[x, y], node[y, x]] (* <--THERE! *)add[node[x_, lower_], y_node] := Which[y >= node[x], node[x, lower, y], y <= node[lower], node[lower, y, x], True, node[y, lower, x]]add[node[x_, lower_, higher_], y_node] /; node[y] <= node[x] := node[x, add[lower, y], higher]add[node[x_, lower_, higher_], y_node] := node[x, lower, add[higher,y]]Where I have a pointer is the code that prevents adding right-offspringto a leaf node. That avoids nodes like your node[a,Null,c]. When youwould have node[a,b,Null], I have node[a,b]. When you would havenode[a,Null,Null], I use a itself.Timing and space requirements are much better now:SeedRandom[5];nums = NullTiming[Do[nums = add[nums, Random[]], {5000}]; ]{2.109*Second, Null}LeafCount[nums]ByteCount[nums]Count[nums, Null, InŽnity]Count[nums, node[_], InŽnity]Count[nums, node[_, _], InŽnity]Count[nums, node[_, _, _], InŽnity]Count[nums, node[___], InŽnity]Depth[nums]7852 (* 48% fewerleaf expressions, mostly due to Nulls and right-offspring eliminated *)165624 (* 31% less storage *)0 (* no Nulls, versus 5001 *)0 (* no leaf nodes, versus 1669 *) (* no nodes without left-offspring, versus 2458 *)705 (* nodes without right offspring, versus 2543 *)2146 (* nodes with both left and right offspring, versus 1667 *)2851 (* total nodes *)21 (* 21 tree levels versus 27 *)The logical structure is identical to yours except that there are nonodes with only right-offspring. This incidentally tends to reduce treedepth.The storage format is far different: there are no trivial (childless)nodes, and nodes with left-offspring but no right-offspring are storedwithout a Null on the right.I could make this quite a bit faster, I think, if I spent time on thecode to eliminate changes to Less, Greater, etc. and the frequentnesting followed by unnesting that goes on in the algorithm. It mighttake twice as much code, however, so I like it as is.You¹re probably better off storing these things in a heap, of course.Or -- better yet -- use the built-in Sort and Ordering functions.Bobby Treat-----Original Message-----In[327]:=add[Null,x_Real]:=node[x,Null,Null]add[ Null,node[x_Real,lower_,higher_]]=node[x,lower,higher]In[328] :=add[node[x_Real,lower_,higher_],y_Real]:= If[x>y,node[x,add[lower,y],higher],node[x,lower,add[higher,y] ]]In[288]:=add[node[x_Real,lowerx_,higherx_],node[y_Real, lowery_,highery_]]:=If[x>y, node[x,add[lowerx,node[y,lowery,highery]],higherx], node[x,lowerx,add[higherx,node[y,lowery,highery]]] ]Now this is my attempt to test how fast my add works:SeedRandom[5];Do[nums=add[nums,Random[]],{5000}];// TimingOut[333]={13.279 Second,Null}RH7.3running on an 1.4GHz Athlon with 1GB of ram).Questions:1. Is this as fast as I can get my code to run?2. Am I doing something obviously stupid?3. would Compiling things help?Husain====> I am using MultipleListPlot to plot a range of 2D graphs and > have found that> the last graph, which has a much greater (by a factor of 4) x > range than the> others does not plot completely but is truncated in the x > direction. By> removing the Frame, I can see the points where these lie > outside the Frame> but these are not joined etc. How do I get over this?The easiest way is to expand your PlotRange to include the errant points.Dave.====Probably a rather simple question: what is the easiest way to open anotebook, execute it, then quit, from the command line? I would like to beable to do this from a MakeŽle. Sidney====I made the algorithm more than twice as fast with very little change,while eliminating modiŽcations to <,>,<=, and >=. Most of theimprovement, in fact, was due to eliminating those changes AFTER thecode was changed so they wouldn¹t be used anyway. That¹s because thecomparisons appear everywhere, so adding rules to those functions reallyslows down pattern matching.Clear[add, node]node[a___, node[b_], c___] = node[a, b, c];node[node[a__]] = node[a];add[Null, x_] = node[x];add[x_, (y_)?NumericQ] := add[node[x], node[y]]add[(x_)?NumericQ, y_] := add[node[x], node[y]]add[node[x_], node[y_]] := If[x >= y, node[x, y], node[y, x]]add[node[x_, lower_], y_node] := Which[First[y] >= x, node[x, lower, y], First[y] <= lower, node[lower, y, x], True, node[y, lower, x]]add[node[x_, lower_, higher_], y_node] /; First[y] <= x := node[x, add[lower, y], higher]add[node[x_, lower_, higher_], y_node] := node[x, lower, add[higher, y]]SeedRandom[5];nums = NullTiming[Do[nums = add[nums, Random[]], {5000}]; ]{0.968*Second, Null}None of the other stats changed.Bobby Treat-----Original Message-----Count[nums, Null, InŽnity]Count[nums, node[_, Null, _], InŽnity]Count[nums, node[_, _, Null], InŽnity]Count[nums, node[_, Null, Null], InŽnity]Count[nums, node[___], InŽnity]Count[nums, node[_, _node | _?NumericQ, _node | _?NumericQ], InŽnity]Depth[nums]{4.406000000000001*Second, Null}150012400005001 (* Null values in the tree *)2458 (* nodes without left offspring *)2543 (* nodes without right offspring *)1669 (* leaf nodes *)4999 (* total nodes *)1667 (* nodes with both left and right offspring *)28 (* minus one, makes 27 levels in the tree *)It¹s clearly not ideal to store 5001 Nulls for 5000 actual values!Here¹s a method that doesn¹t change the algorithm much, but changes thestorage method a great deal:First of all, I¹m lazy, so I¹ll redeŽne <,>,<=,>=, etc. to make thecode simpler:Unprotect[Less, Greater, LessEqual, GreaterEqual];Less[a : _node ..] := Less @@ (First /@ {a})LessEqual[a : _node ..] := LessEqual @@ (First /@ {a})Greater[a : _node ..] := Greater @@ (First /@ {a})GreaterEqual[a : _node ..] := GreaterEqual @@ (First /@ {a})Protect[Less, Greater, LessEqual, GreaterEqual];Again because I¹m lazy, I¹ll deŽnenode so that I don¹t have toconsciously avoid leaf nodes and unnecessary nesting:ClearAll[node]node[a___, node[b_], c___] = node[a, b, c];node[node[a__]] = node[a];Here¹s myadd function:Clear[add]add[Null, x_] = node[x];add[x_, (y_)?NumericQ] := add[node[x], node[y]]add[(x_)?NumericQ, y_] := add[node[x], node[y]]add[node[x_], node[y_]] := If[x > y, node[x, y], node[y, x]] (* <--THERE! *)add[node[x_, lower_], y_node] := Which[y >= node[x], node[x, lower, y], y <= node[lower], node[lower, y, x], True, node[y, lower, x]]add[node[x_, lower_, higher_], y_node] /; node[y] <= node[x] := node[x, add[lower, y], higher]add[node[x_, lower_, higher_], y_node] := node[x, lower, add[higher,y]]Where I have a pointer is the code that prevents adding right-offspringto a leaf node. That avoids nodes like your node[a,Null,c]. When youwould have node[a,b,Null], I have node[a,b]. When you would havenode[a,Null,Null], I use a itself.Timing and space requirements are much better now:SeedRandom[5];nums = NullTiming[Do[nums = add[nums, Random[]], {5000}]; ]{2.109*Second, Null}LeafCount[nums]ByteCount[nums]Count[nums, Null, InŽnity]Count[nums, node[_], InŽnity]Count[nums, node[_, _], InŽnity]Count[nums, node[_, _, _], InŽnity]Count[nums, node[___], InŽnity]Depth[nums]7852 (* 48% fewerleaf expressions, mostly due to Nulls and right-offspring eliminated *)165624 (* 31% less storage *)0 (* no Nulls, versus 5001 *)0 (* no leaf nodes, versus 1669 *) (* no nodes without left-offspring, versus 2458 *)705 (* nodes without right offspring, versus 2543 *)2146 (* nodes with both left and right offspring, versus 1667 *)2851 (* total nodes *)21 (* 21 tree levels versus 27 *)The logical structure is identical to yours except that there are nonodes with only right-offspring. This incidentally tends to reduce treedepth.The storage format is far different: there are no trivial (childless)nodes, and nodes with left-offspring but no right-offspring are storedwithout a Null on the right.I could make this quite a bit faster, I think, if I spent time on thecode to eliminate changes to Less, Greater, etc. and the frequentnesting followed by unnesting that goes on in the algorithm. It mighttake twice as much code, however, so I like it as is.You¹re probably better off storing these things in a heap, of course.Or -- better yet -- use the built-in Sort and Ordering functions.Bobby Treat-----Original Message-----In[327]:=add[Null,x_Real]:=node[x,Null,Null]add[ Null,node[x_Real,lower_,higher_]]=node[x,lower,higher]In[328] :=add[node[x_Real,lower_,higher_],y_Real]:= If[x>y,node[x,add[lower,y],higher],node[x,lower,add[higher,y] ]]In[288]:=add[node[x_Real,lowerx_,higherx_],node[y_Real, lowery_,highery_]]:=If[x>y, node[x,add[lowerx,node[y,lowery,highery]],higherx], node[x,lowerx,add[higherx,node[y,lowery,highery]]] ]Now this is my attempt to test how fast my add works:SeedRandom[5];Do[nums=add[nums,Random[]],{5000}];// TimingOut[333]={13.279 Second,Null}RH7.3running on an 1.4GHz Athlon with 1GB of ram).Questions:1. Is this as fast as I can get my code to run?2. Am I doing something obviously stupid?3. would Compiling things help?Husain====> Daniel,> I don¹t mean to be overly critical of WRI¹s documentation -- it¹s very> good, as such things go. Nor do I like to overlook chances to make it> better. Do you?I¹ll try to address your speciŽc remarks below and then return to this.> Your own comments below point out that we should expect vectors> resulting from NullSpace to beorthonormal by the usual> conjugate-symmetric inner product on C. But that¹s not spelled out> (documented) for dummies like myself who don¹t know that¹s a natural> result of singular values decomposition.My comments indicate that they will be orthonormal, for approximatenumericmatrix input, so long as the implementation is based on SVD. But that¹snot by any means part of what NullSpace is required to do, and it isquiteclearly implementation dependent.> Themission of NullSpace (or any function) is to adhere to> documentation, so reasonable persons may differ on whether orthogonality> is a feature we should depend on.Well... the nameNullSpace gives a pretty good idea of what it needstodo. When you stop to consider all the matrixtypes (approximatenumbers,exact numbers, symbolic, numeric but with non-number elements e.g. PiandSqrt[2]) you quickly realize that different types will most likely behandled by different methods, and these may have differentcharacteristicsof output e.g. normalized vectors, vectors with last nonzero componentequal to one, or other quirks. But these are artifacts oŽmplementation,not part of the requirements of a null space.> The mission of documentation is to tell us what to expect. When it> doesn¹t, the result is that we spend all this time discussing issues> online, trying to Žgure things out. A simpledon¹t depend on> orthogonal results would be nice, if that¹s the intent.Perhaps. If there is strong reason to expect that people might dependon such results in the Žrst place. I don¹t think there is.> In any case, I just spent ten minutes LOOKING for implementation notes> for NullSpace, and have not found any. Searching forimplementation> notes doesn¹t help and there¹s no link from NullSpace. What use is> documentation I can¹t Žnd?> In general, I don¹t like Mathematica¹s quirky Help Browser, in which I> cannot search for anything that¹s not indexed. Every other help engine> on my computer (and there are hundreds) allows me to search for words,> and that¹s exactly what I need in order to Žnd all mentions of> NullSpace.I found it in the back of the book, appendix A.9,Some Notes onInternalImplementation. See A.9.4,Approximate numerical linear algebra.In the Help Browser, click onThe Mathematica Book and then typeimplementation in the window. The second URL it gives isA.9. I¹llgrant you one might reasonably desire a good search engine. I just wantto indicate that what is there now is not entirely useless in thisinstance provided you at least know about the existance of these notesin the book.> Bobby Treat> [...]To respond to your question at the beginning, yes, I also like to seeimprovements in documentation. I certainly agree that a good searchengine would be useful in this case. Though note that I also may notbe using the Help Browser to its fullest capabilities (I claim nogreat familiarity with the Mathematica user interface). As for thespeciŽc issue of what to document about NullSpace, sufŽce it to saythat I do not favor making claims beyond what it is required to do.Daniel LichtblauWolfram Research====Daniel,I don¹t mean to be overly critical of WRI¹s documentation -- it¹s verygood, as such things go. Nor do I like to overlook chances to make itbetter. Do you?Your own comments below point out that we should expect vectorsresulting from NullSpace to beorthonormal by the usualconjugate-symmetric inner product on C. But that¹s not spelled out(documented) for dummies like myself who don¹t know that¹s a naturalresult of singular values decomposition.Themission of NullSpace (or any function) is to adhere todocumentation, so reasonable persons may differ on whether orthogonalityis a feature we should depend on.The mission of documentation is to tell us what to expect. When itdoesn¹t, the result is that we spend all this time discussing issuesonline, trying to Žgure things out. A simpledon¹t depend onorthogonal results would be nice, if that¹s the intent.In any case, I just spent ten minutes LOOKING for implementation notesfor NullSpace, and have not found any. Searching forimplementationnotes doesn¹t help and there¹s no link from NullSpace. What use isdocumentation I can¹t Žnd?In general, I don¹t like Mathematica¹s quirky Help Browser, in which Icannot search for anything that¹s not indexed. Every other help engineon my computer (and there are hundreds) allows me to search for words,and that¹s exactly what I need in order to Žnd all mentions ofNullSpace.Bobby Treat-----Original Message-----> of Mathematica.> BobbyThe expected, and documented, behavior is that the output should be abasis for the null space, that is, solutions of the homogeneous matrixequation A.x==0. If this were to stop working then that would be aserious bug. Is this the behavior you mean?The implementation notes of the manual mention that approximateNullSpace is based on a singular values decomposition. This in factgives resulting vectors that are orthonormal by the usualconjugate-symmetric inner product on C (though these are now notnormal to the original vector in this same inner product, unless theyare real-valued). But this basis-orthogonality is not part of themission of NullSpace and moreover should not become part of it. Hencethat particular (and implementation dependent) aspect of NullSpaceshould not become documented.Daniel LichtblauWolfram Research====I¹ve this problem with NIntegrate:**********************************************In[1 ]=f[y_,z_]: = (y^4/( (1+(8.44*10^-4)^2 * (1+z)^2 y^2) (Exp[z]+1) )In[2]=F[z_]: = NIntegrate[f[y,z], {z, 0, InŽnity}********************************************** Mathematica 4.0 says:******************************************************** *********************NIntegrate: : inum : Integrand 1.07577/( 1+7.12336*10^-7 (1. + z)^2 ) is notnumerical at {y}={1.}.**************************************************** **************************What is it??--Rob_jack====Daniel,We mostly agree. I simply look at things from a slightly different(user, non-WRI) perspective. My original point was -- in line with yourown comments -- that people shouldn¹t depend on NullSpace to returnorthogonal vectors even when it seems to do so, because it¹s notdocumented behavior. (Although YOU knew about it and could point todocumentation of it! Sort of.)Unlike you, perhaps, I consider the lack of search capabilities in Helpan EGREGIOUS failing -- a mistake no other Help engine makes (so far asI know). Fix that, and 90% of my complaints about documentation wouldgo away; I could have found the implementation notes on NullSpace, forinstance, without already KNOWING where they are. That is preciselywhat annoys me most of the time; the information is there, but I can¹tŽnd it. (If searching forimplementation works, why doesn¹timplementation notes yield anything at all?)Now that I¹ve found this page, I¹ll add it to all the other informationlocations I¹m trying to remember. (There¹s not much there anyway,though.)Bobby-----Original Message-----I¹ll try to address your speciŽc remarks below and then return to this.> Your own comments below point out that we should expect vectors> resulting from NullSpace to beorthonormal by the usual> conjugate-symmetric inner product on C. But that¹s not spelled out> (documented) for dummies like myself who don¹t know that¹s a natural> result of singular values decomposition.My comments indicate that they will be orthonormal, for approximatenumericmatrix input, so long as the implementation is based on SVD. But that¹snot by any means part of what NullSpace is required to do, and it isquiteclearly implementation dependent.> Themission of NullSpace (or any function) is to adhere to> documentation, so reasonable persons may differ on whetherorthogonality> is a feature we should depend on.Well... the nameNullSpace gives a pretty good idea of what it needstodo. When you stop to consider all the matrixtypes (approximatenumbers,exact numbers, symbolic, numeric but with non-number elements e.g. PiandSqrt[2]) you quickly realize that different types will most likely behandled by different methods, and these may have differentcharacteristicsof output e.g. normalized vectors, vectors with last nonzero componentequal to one, or other quirks. But these are artifacts oŽmplementation,not part of the requirements of a null space.> The mission of documentation is to tell us what to expect. When it> doesn¹t, the result is that we spend all this time discussing issues> online, trying to Žgure things out. A simpledon¹t depend on> orthogonal results would be nice, if that¹s the intent.Perhaps. If there is strong reason to expect that people might dependon such results in the Žrst place. I don¹t think there is.> In any case, I just spent ten minutes LOOKING for implementation notes> for NullSpace, and have not found any. Searching forimplementation> notes doesn¹t help and there¹s no link from NullSpace. What use is> documentation I can¹t Žnd?> In general, I don¹t like Mathematica¹s quirky Help Browser, in which I> cannot search for anything that¹s not indexed. Every other helpengine> on my computer (and there are hundreds) allows me to search for words,> and that¹s exactly what I need in order to Žnd all mentions of> NullSpace.I found it in the back of the book, appendix A.9,Some Notes onInternalImplementation. See A.9.4,Approximate numerical linear algebra.In the Help Browser, click onThe Mathematica Book and then typeimplementation in the window. The second URL it gives isA.9. I¹llgrant you one might reasonably desire a good search engine. I just wantto indicate that what is there now is not entirely useless in thisinstance provided you at least know about the existance of these notesin the book.> Bobby Treat> [...]To respond to your question at the beginning, yes, I also like to seeimprovements in documentation. I certainly agree that a good searchengine would be useful in this case. Though note that I also may notbe using the Help Browser to its fullest capabilities (I claim nogreat familiarity with the Mathematica user interface). As for thespeciŽc issue of what to document about NullSpace, sufŽce it to saythat I do not favor making claims beyond what it is required to do.Daniel LichtblauWolfram Research====Bobby Treat-----Original Message-----> Yes, I can make a page break where I want one, but I can¹t eliminate> page-breaks that leave tons of white-space at the end of some pages.In> some of my notebooks, Mathematica puts the Žrst cell on a page by> itself, using less than an inch --- and NOT because the next celltakes> a whole page. If I force the Žrst two cells to stay together, the> problem just moves to the next page.> It¹s enough to make Mathematica useless as a word processor all by> itself.> Bobby Treat> -----Original Message-----> Kenny,> Sympathy but no solution.> I too have been trying to use Mathematica (v4.2 most recently) to type> maths papers and the like but I¹m not ready to ditch LaTeX yet. There> are just too many cases where I cannot Žgure out how to achieve whatI> want in Mathematica, things like:> - left brackets spanning multiple lines for deŽning hybrid functions;> - vertical alignment of equals signs in multi-line equations or> derivations;> - setting typefaces in tables of material.> I Žgure most of this is do-able, but I don¹t have the time, or> patience, to spend too much time on it. So, I¹ll be the Žrstcustomer> when you write the guide to math publishing in Mathematica - I justhope> you won¹t have to use LaTeX to write it.> Mark Westwood>>I would like to use mathematica type papers for my math courses, but>>I¹m having trouble formatting documents. Despite searching, I¹ve been>>unable to Žnd a complete guide to word processing with mathematica.>>Does anyone know where such a document could be found?> ====Group,Sorry for the previous posting. The following solves (to some extent myproblem)<10.02times2=First[Timing[fLPartition[3,20];]]/. Second->10.18times3=First[Timing[fLPartition[3,30];]]/. Second->10.701times4=First[Timing[fLPartition[3,40];]]/. Second->11.913times5=First[Timing[fLPartition[3,50];]]/. Second->14.236times6=First[Timing[fLPartition[3,60];]]/. Second->18.222times7=First[Timing[fLPartition[3,70];]]/. Second->114.39times8=First[Timing[fLPartition[3,80];]]/. Second->123.563So far so good. But fortimes9=First[Timing[fLPartition[3,90];]]/. Second->1The computation does not always end. Some times it ends some times it doesnot (I aborted the process four times after 1 hour of computing andrunning out of, 2Gbites of, virtual memory)Emilio Martin-Serrano___________________________________Emilio Martin-SerranoSchlumbergerOil & Gas Business Consulting Principal1325 South Dairy Ashford RoadHouston, TX 77077====I¹m going to try using Mathematica to typeset some mathematicsbecause I know that my students would beneŽt from being able to dothe same., and they¹ll need someone who can answer their questions,etc. etc.I¹m pretty comfortable with some things (e.g., Mathematica¹srecognition of latex commands for most characters), and now I¹m readyto push the envelope a bit.Q1: How can I typeset a table or array of information (e.g., list ofvariables with deŽnitions) so that information in one column iscentered and information in another column is aligned žush left? Iknow exactly how I would do this in LaTeX, but I Žnd no informationon how to do this in Mathematica.Q2. How can I embed a Quicktime movie into a Mathematica notebook (e.g., so someone with MathReader can play the animation)?That¹s all for now.--Jason Miller, Ph.D.Division of Mathematics and Computer ScienceTruman State University100 East Normal St.Kirksville, MO 63501http://vh216801.truman.edu660.785.7430====It seems there is an error in the BinCounts function of Mathematica¹sstandard <Left, FontSize->18],Cell[,Text, TextAlignment->Left],Cell[CellGroupData[{Cell[,Text, TextAlignment->Left],Cell[BoxData[ (<< Statistics`DataManipulation`)],Input]}, Open ]],Cell[CellGroupData[{Cell[Assign data to the vector (1D list) dat.,Text, TextAlignment->Left],Cell[BoxData[ ((dat = {63, 184, 23, 14, 17, 32, 26, 666, 27, 11, 28, 53, 37, 29,4, 60, 7, 23, 94, 18, 43, 15, 74, 42, 81, 8, 7, 19, 0, 27, 87,35, 3, 24, 94, 42, 4, 7, 18, 7, 38, 1, 0, 61, 3, 40, 22, 8, 3, 2, 0,2, 5, 5, 7, 0, 9, 2, 11, 13, 105, 51, 36, 149, 147, 12, 1, 1, 7, 8,10, 1, 7, 25, 38, 142, 15, 8, 9, 16, 0, 1, 4, 3, 31, 30, 10};))],Input]}, Open ]],Cell[CellGroupData[{Cell[Count the number of dat data rows.,Text, TextAlignment->Left],Cell[CellGroupData[{Cell[BoxData[ (datRows = Length[dat])],Input],Cell[BoxData[ (87)],Output]}, Open ]]}, Open ]],Cell[CellGroupData[{Cell[Find the minimum value in the dat data rows.,Text, TextAlignment->Left],Cell[CellGroupData[{Cell[BoxData[ (datMin = Min[dat])],Input],Cell[BoxData[ (0)],Output]}, Open ]]}, Open ]],Cell[CellGroupData[{Cell[Find the maximum value in the dat data rows.,Text, TextAlignment->Left],Cell[CellGroupData[{Cell[BoxData[ (datMax = Max[dat])],Input],Cell[BoxData[ (666)],Output]}, Open ]]}, Open ]],Cell[CellGroupData[{Cell[Calculate the number of histogram bins to use.,Text, TextAlignment->Left],Cell[CellGroupData[{Cell[BoxData[ (datBins = Ceiling[Log[2, datRows]])],Input],Cell[BoxData[ (7)],Output]}, Open ]]}, Open ]],Cell[CellGroupData[{Cell[Set the width of a histogram bin.,Text, TextAlignment->Left],Cell[CellGroupData[{Cell[BoxData[ (datBinWidth = N[((datMax - datMin))/datBins])],Input],Cell[BoxData[ (95.14285714285714`)],Output]}, Open ]]}, Open ]],Cell[CellGroupData[{ TextAlignment->Left],Cell[CellGroupData[{Cell[BoxData[Cell[ BoxData[ ({76, 5, 0, 0, 0, 0, 0, 1})],Output]}, Open ]]}, Open ]],Cell[CellGroupData[{Cell[,Text, TextAlignment->Left],Cell[CellGroupData[{Cell[BoxData[Cell[ BoxData[ (8)],Output]}, Open ]]}, Open ]]},ScreenRectangle->{{0, 1024}, {0, 748}},CellGrouping->Manual,WindowSize->{520, 626},WindowMargins->{{-1, Automatic}, {Automatic, -1}},MacintoshSystemPageSetup-><0080001804P000000_82@?okonh34 `9B;@<5:0?l00;m009H0UP0000068dB`0B`02d5X5k/02H80@4101P00BL? 00400@ 00000000000000P0010000020D000000000000000000000000000004T40000 2004>]====On my machine, replacing Null with made Husain¹s code 8 times fasteron the same test: 0.592 seconds versus 4.688.I suppose making the same change in my code makes no difference becausethere are no Nulls in the tree (except one, very briežy), or perhapsbecause I have fewer patterns that involve Nulls.By rearranging the order of my rules, and deleting a couple that werenever used, I made my algorithm about 15% faster, getting the time downto 0.906. Mihajlo¹s amazing discovery beats that, of course -- it¹s 50%faster.I suppose what we¹ve found is that (1) my algorith makes the code fourto Žve times faster by reducing expression complexity, tree depth, andmemory use, but it¹s a slower algorithm otherwise (too many rules?); and(2) Mathematica pattern matching and code execution has a real problemwith Null used as if it means something.Bobby-----Original Message-----add[node[x_Real, lower_, higher_], y_Real] := node[x, lower, add[higher,y]];nums =NULL;SeedRandom[5];Do[nums = add[nums, Random[]], {5000}] // TimingOut{5.11 Second, Null}Clear[add];add[Null, x_Real] := node[x, Null, Null];add[node[x_Real, lower_, higher_], y_Real] /; x > y := node[x, add[lower, y], higher];add[node[x_Real, lower_, higher_], y_Real] := node[x, lower, add[higher,y]];nums = Null;SeedRandom[5];Do[nums = add[nums, Random[]], {5000}] // TimingOut{41.03 Second, Null}Also:Simplify[1==Null]1==Nulldoesn¹t evaluate to false!!Btw. changing Null toNULL in your code doesn¹t infulence the speed... Mihajlo Vanevic mvane@EUnet.yu 2002-09-09*************************************************** ************ At 2002-09-09, 00:29:00 ************************************************************* *>You¹re not doing anything dumb as far as I can see, but you¹re usingfar>more memory than necessary. Here are statistics for your algorithm on>my machine:>>SeedRandom[5];>nums = Null>Do[nums = add[nums, Random[]], {5000}]; // Timing>nums // LeafCount>nums // ByteCount>Count[nums, Null, InŽnity]>Count[nums, node[_, Null, _], InŽnity]>Count[nums, node[_, _, Null], InŽnity]>Count[nums, node[_, Null, Null], InŽnity]>Count[nums, node[___], InŽnity]>Count[nums, node[_, _node | _?NumericQ, _node | _?NumericQ], InŽnity]>Depth[nums]{4.406000000000001*Second, Null}>15001>240000>5001 (* Null values in the tree *)>2458 (* nodes without left offspring *)>2543 (* nodes without right offspring *)>1669 (* leaf nodes *)>4999 (* total nodes *)>1667 (* nodes with both left and right offspring *)>28 (* minus one, makes 27 levels in the tree *)>>It¹s clearly not ideal to store 5001 Nulls for 5000 actual values!>>Here¹s a method that doesn¹t change the algorithm much, but changes the>storage method a great deal:>>First of all, I¹m lazy, so I¹ll redeŽne <,>,<=,>=, etc. to make the>code simpler:>>Unprotect[Less, Greater, LessEqual, GreaterEqual];>Less[a : _node ..] := Less @@ (First /@ {a})>LessEqual[a : _node ..] := LessEqual @@ (First /@ {a})>Greater[a : _node ..] := Greater @@ (First /@ {a})>GreaterEqual[a : _node ..] := GreaterEqual @@ (First /@ {a})>Protect[Less, Greater, LessEqual, GreaterEqual];>>Again because I¹m lazy, I¹ll deŽnenode so that I don¹t have to>consciously avoid leaf nodes and unnecessary nesting:>>ClearAll[node]>node[a___, node[b_], c___] = node[a, b, c];>node[node[a__]] = node[a];>>Here¹s myadd function:>>Clear[add]>add[Null, x_] = node[x];>add[x_, (y_)?NumericQ] := add[node[x], node[y]]>add[(x_)?NumericQ, y_] := add[node[x], node[y]]>add[node[x_], node[y_]] := If[x > y, node[x, y], node[y, x]] (* <-->THERE! *)>add[node[x_, lower_], y_node] :=> Which[y >= node[x], node[x, lower, y],> y <= node[lower], node[lower, y, x], True, node[y, lower, x]]>add[node[x_, lower_, higher_], y_node] /;> node[y] <= node[x] := node[x, add[lower, y], higher]>add[node[x_, lower_, higher_], y_node] := node[x, lower, add[higher,>y]]>>Where I have a pointer is the code that prevents adding right-offspring>to a leaf node. That avoids nodes like your node[a,Null,c]. When you>would have node[a,b,Null], I have node[a,b]. When you would have>node[a,Null,Null], I use a itself.>>Timing and space requirements are much better now:>>SeedRandom[5];>nums = Null>Timing[Do[nums = add[nums, Random[]], {5000}]; ]{2.109*Second, Null}>>LeafCount[nums]>ByteCount[nums]>Count[nums, Null, InŽnity]>Count[nums, node[_], InŽnity]>Count[nums, node[_, _], InŽnity]>Count[nums, node[_, _, _], InŽnity]>Count[nums, node[___], InŽnity]>Depth[nums]7852 (* 48 fewerleaf expressions,> mostly due to Nulls and right-offspring eliminated *)>165624 (* 31 less storage *)>0 (* no Nulls, versus 5001 *)>0 (* no leaf nodes, versus 1669 *)> (* no nodes without left-offspring, versus 2458 *)>705 (* nodes without right offspring, versus 2543 *)>2146 (* nodes with both left and right offspring, versus 1667 *)>2851 (* total nodes *)>21 (* 21 tree levels versus 27 *)>>The logical structure is identical to yours except that there are no>nodes with only right-offspring. This incidentally tends to reducetree>depth.>>The storage format is far different: there are no trivial (childless)>nodes, and nodes with left-offspring but no right-offspring are stored>without a Null on the right.>>I could make this quite a bit faster, I think, if I spent time on the>code to eliminate changes to Less, Greater, etc. and the frequent>nesting followed by unnesting that goes on in the algorithm. It might>take twice as much code, however, so I like it as is.>>You¹re probably better off storing these things in a heap, of course.>>Or -- better yet -- use the built-in Sort and Ordering functions.>>Bobby Treat-----Original Message-----So Slow?>>I am trying to implement a very simple sorted tree to quickly storesome>real numbers I need. I have written an add, delete, minimum, and pop>(delete the lowest value) function and they seem to work ok but arevery>slow. Let¹s just look @ my implementation of the add part:>nums=Null;(*my initial blank Tree)>In[326]:=>Clear[add]>>In[327]:=>add[Null,x_Real]:=node[ x,Null,Null]>>add[Null,node[x_Real,lower_,higher_]]=node[x, lower,higher]>>In[328]:=>add[node[x_Real,lower_,higher_],y_ Real]:=> If[x>y,node[x,add[lower,y],higher],node[x,lower,add[higher,y] ]]>>In[288]:=>add[node[x_Real,lowerx_,higherx_],node[y_Real, lowery_,highery_]]:=If[x>y>,> node[x,add[lowerx,node[y,lowery,highery]],higherx],> node[x,lowerx,add[higherx,node[y,lowery,highery]]]> ]>>Now this is my attempt to test how fast my add works:>>SeedRandom[5];>Do[nums=add[nums,Random[]],{5000}];// Timing>>Out[333]=>{13.279 Second,Null}>>RH7.3>running on an 1.4GHz Athlon with 1GB of ram).>>Questions:>1. Is this as fast as I can get my code to run?>2. Am I doing something obviously stupid?>3. would Compiling things help?>Husain************************************************* *************====The following is a button that will export a selected graphic as a JPEG,ButtonBox[JPEG, ButtonFunction :> Module[{sel}, SelectionMove[InputNotebook[], All, Cell]; sel = NotebookRead[InputNotebook[]]; If[Head[sel] === Cell, If[!ValueQ[dpi], dpi = Automatic]; ImageSize -> Automatic, ImageResolution -> dpi, ConversionOptions -> {Quality -> 75}]]], ButtonEvaluator -> Automatic, Active -> True]//DisplayForm It works Žne as long as the graphic is no wider than about 330 pixels.If the graphic is wider than 330 pixels, then the size of exportedgraphic is correct, but everything on the right beyond the Žrst 330pixels is blank. There seems to be no problem with the height though.Any ideas on how to Žx or get around this problem?---Selwyn Hollis====I am having some trouble with numerical integration.!(((Timing[ ansOUT = {}; [IndentingNewLine]For[EbNo = 0, EbNo <= 2, EbNo += 10/10, [IndentingNewLine]linEbNo = 10^(EbNo/10); [IndentingNewLine]M = 64; [IndentingNewLine]K = Log[2, M]; [IndentingNewLine]p = (M/2)/(M - 1) Sum[ Binomial[M - 1, n] (((-1)))^(n + 1)/(1 + n) Exp[(- linEbNo) K n/(1 + n)], {n, 1, M - 1}]; [IndentingNewLine]Pm = (1/@(2 [Pi])) NIntegrate[ 1 - ((((1/@(2 [Pi])) NIntegrate[ Exp[(-x^2)/2], {x, (-[InŽnity]), y}, WorkingPrecision -> 32 ]))^(M - 1)) Exp[((-1)/2) ((y - @(2 K linEbNo)))^2], {y,(-[InŽnity]), [InŽnity]}, WorkingPrecision -> 32]; [IndentingNewLine]Pb = ((M/2)/(M - 1)) Pm; [IndentingNewLine]AppendTo[ ansOUT, {N[a, 4], N[p, 8], N[Pb, 8]}];[IndentingNewLine]];])([IndentingNewLine])))TableForm[ ansOUT]The code can also be downloaded fromhttp://www.itee.uq.edu.au/~dsalman/_downloads/ Proakis.nbCol. 2(symblic formula) and 3 (result of numerical integration) of thevariable ansOUT should be identical.However the numerical integration is giving a 0 answer.Can anyone please suggest how a solution to this problem.Salman====