A42 === Do you refer here to the Option Inspector? If so, what option name are you referring to?-- 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 ==== 4.2.1 embeds the required Mathematica fonts into the EPS graphic by *default*. So, you don't have to fiddle with any options.But if you want to turn font embedding off, the option name is IncludeSpecialFonts under the ToPostScriptOptions category (there's another IncludeSpecialFonts in the PrintingOptions category which does not affect EPS, but is related to printing under X)..Sincerely,John Fultzjfultz@wolfram.comUser Interface GroupWolfram Research, Inc. ==== Be careful ! Sqrt[a]*Sqrt[b] is not equal to Sqrt[a*b] if a and b are notreal positive !If you consider a and b real positive, you can tell Mathematica that it isso :You can also use PowerExpandMeilleures salutationsFlorian Jaccard-----Message d'origine-----Envoy.8e : mar., 3. d.8ecembre 2002 10:35è : mathgroup@smc.vnet.netObjet : Hi!Does somebody know an algorithm to simplify the product Sqrt[a]*Sqrt[b] ?With many thanksGernot ==== Apply Simplify or FullSimplify with Assumptions.Generally speaking, over the complex plane, Sqrt[a]*Sqrt[b] cannot besimplified further, and Mathematica knows it. In[1] := FullSimplify[Sqrt[x]Sqrt[y], x [Element] Complexes] Out[1] = Sqrt[x]*Sqrt[y]The same holds for the real plane. In[2] := FullSimplify[Sqrt[x] Sqrt[y], x [Element] Reals] Out[2] = Sqrt[x]*Sqrt[y]Sometimes, if your work over the real plane, things might look simpler. Out[3] = Sqrt[x*y] In[4] := Simplify[Sqrt[x] Sqrt[y], x < 0 && y < 0] Out[4] = -Sqrt[x*y]and so on.Best wishes,Vladimir BondarenkoMathematical and Production DirectorSymbolic Testing Group http://www.CAS-testing.org/ GEMM Project (95% ready)Mail : 76 Zalesskaya Str, Simferopol, Crimea, Ukraine ==== Dear Hartmut,It may be that introducing a test prevents internal compiling.One more simplification - and this points up the value of using Alternativesto reduce the problem to simple pattern matching without conditions ortests: Random[Integer,{1,2000}]},{6000}]; Random[Integer,{1,2000}]},{12000}];In my second posting I ended with s1[[Flatten[Position[ s1[[All,1]], Alternatives@@Union[s2[[All,1]]]]]]];//Timing {3.24 Second,Null}Using Cases gives a simpler and slightly faster version: Cases[ s1, {Alternatives@@Union[s2[[All,1]]],_}];//Timing {3.13 Second,Null}How useful Union or, as below, Intersection are will be, depends of courseon the particular inputs, but for the current ones I get Cases[ s1, {Alternatives@@s2[[All,1]],_}];//Timing {5.32 Second,Null} Cases[ s1, {Alternatives@@Intersection[s1[[All,1]],s2[[All,1]]],_}];// Timing {3.41 Second,Null}In the last one, Cases may be repeating some of the work that Intersectionhas done.Perhaps you can build spme of this in your developments.Allan---------------------Allan HayesMathematica Training and ConsultingLeicester UKwww.haystack.demon.co.ukhay@haystack.demon.co.ukVoice: +44 (0)116 271 4198----- Original Message -----believedkillstill{4}]],Iand ==== I don't know the answer, but my simple mind is telling me the integer 1 is thesame as 1.0 is that right or no?what we can also do to look at another perspective is this:Limit 1^nanyone?RAyRAy =) hehehe ==== Yes, in my opinion. Indeed, I would, arguing similarly, say that1^x should be 1 for _all_ x, including ComplexInfinity. It is, inessence, the same idea that I proposed in the recent threadindeterminate expression. (Below my signature, I've copied the mostrelevant post from that thread.)At least I can say that Mathematica's returning Indeterminate for both0^0 and 1^Infinity indicates that it is following a _consistent_philosophy. But I disagree with that philosophy. David-- -------------------- http://NewsReader.Com/ --------------------Usenet Newsgroup Service New Rate! $9.95/Month 50GB ==== Isn't this a bit like trying to divide by zero?Infinity + Infinity = Infinity; however, one can not subtract infinity frominfinity or or divide by it.Steven Shippeeshippee@jcs.mil ==== It is astonishing that debates like this keep coming up. To anyone who disagrees with the notion that 1^Infinity is indeterminate, I suggest that you write something called a new kind of calculus. But you might want to learn the old kind first.---Selwyn Hollis ==== Mathematica generally uses indeterminate for expressions which are by nature ambiguous, which means they can be represented as limits leading to different answers. This is the case with 1^Infinity. For example, consider(2^(1/n))^n and let n tend to Infinity. This can be thought of as 1^Infinity yet it remains all the time equal to 2.I assume the same is true with other expressions where Indeterminate is returned. Of course this is not mathematically the only valid approach, one adapt various conventions, for after all these are but conventions. But personally I find it rather convenient and have got programming examples which only work because Indeterminate rather than a number are returned in similar cases. I personally think this answer is on the whole more ßexible than any alternative, and I would vote for keeping it.Andrzej Kozlowski ==== I've been trying to run some modestly complicated animations consisting of several ParametricPlot3D curves. I can generate the sequence of images, but when I try to use ShowAnimation, Mathematica starts using all the CPU, and if there is sufficient number of frames, It starts swapping. What that happens I either have to reboot the system, or wait several minutes for Mathematica to let me have a few cycles so I can kill it. I've seen what I can do with Java 3D, so I know such animations can be run on this box.What is actually happening when the animations are run? Even if I get them to start, they never run smoothly. The always freze momentarily about every 7 frames or so, and sometimes they will stall for a fairly long period.I really think Mathematica is a wonderful program for handling mathematical problems. It's ability to graph mathematical functions is fantastic. I am interested in studying the time evolution of physical systems, and believe that 3D animation is the best way to understand the mathematical expressions used to describe these systems. When I get beyond the simplest systems, Mathematic seems unable to support this aspect of my modeling.I don't have time to write my own mapping between Java 3D and Mathematica, unless WRI wants to fund the effort. Is there a good way to handle this kind of situation using Mathematica?-- STHHatton's Law: There is only One inviolable Law.Reply-To: kuska@informatik.uni-leipzig.de ==== Hi,Mathematica must keep all the frames of you animation inmemory and this is probably to much.You can make simple animations with MathGL3d http://phong.informatik.uni-leipzig.de/~kuska/mathgl3dv3/as explained in the MVManual.nb. But it depend a bit on thecomplexity of your scene and the actual speeed of MathLink. Jens ==== If you have a finalized set of images, you can use automatedExport[...] commands to create a numbered sequence of images in asubdirectory.Something like pic001.jpg,pic002.jpg,...,pic100.jpg.Then you can use the free Bink tool from www.radgames.com to make ananimation. It compresses the animation, plus you can turn it into astandalone .exe file for people who don't have Mathematica.This solution is great for finalized large animations.Orestis ==== can you include or send me the notebook with these parametic plots. I would beinterested in looking at them and see how they run on my machine. ==== I guess I never learn anything the easy way. I've been told this before, but until I actually started poking around in the data from Mathematica 3D animations, I didn't understand what all this meant. I had been creating my When I looked at how they were represented, I realised how much useless data was being generated. Anyhow, just about the time I was ready to put this on the web, I had the first hard drive failure in my life (on my own system). What luck! It was the drive holind my web-site. Fortunately, I have backups of everything. Nonetheless, It took a while to get everything back up. It was already well past the end of the day. I'm too tired to add much explanation to the I made extensive use of Dr. Míóder.81[YAcute] CSM`Classes` package. It's not quite Java level OO, but It certainly is usable. http://public.globalsymmetry.com/projects/lorenz3d/ lorenz3D-scene1.nbThe notebook is just a front-end. I'm not ready to publish the code yet.-- STHHatton's Law: There is only One inviolable Law. ==== I have measured the absolute value of the electric field in severalpoints of a room.I would like to make a 3D plot of the room, showing each one of thepoints measured. Each point should be accompanied by its electricfield value or, preferably, by a color associated with the value.After that, I wanted to make a 3D interpolation of those points toobtain a colorful plot that showed how the electric field varies alongthat room (a 3D density plot).Any ideas are welcome, even if you don't know how to solve the wholeproblem!Reply-To: kuska@informatik.uni-leipzig.de ==== Hi,a) you can't draw a field {fx,fy,fz} with DensityPlot[]b) make a Delauny triangulation (in 3d it is a tetrahedisation) of you points and serach for every point the tetrahedron and interpolate the field components from the measured corner values Jens ==== Leonardo,Here I make a sample function to show how you might do it.f[x_, y_, z_] := Abs[Sin[x]Cos[y]Sin[z]];The following creates a sample set of data.data = Flatten[Table[{f[x, y, z], {x, y, z}}, {x, 0, Pi/2, Pi/20}, {y, 0, Pi/2, Pi/20}, {z, 0, Pi/2, Pi/20}], 2];Now we create a set of plotting points by transforming each data point.In our data, f goes from 0 to 1. I made the Hue go to less than 1 because 1looks almost like 0 and doesn't distinguish. For your actual function youwould have to design a more sophisticated color function. Here is a sampleplot point...Part[plotpoints, 654]{Hue[0.2241661706546524], Point[{Pi/4, Pi/5, Pi/5}]}Now, the plot is easy...plot1 = Show[Graphics3D[ {plotpoints}],You can get a better picture by spinning it aroundNeeds[Graphics`Animation`]SpinShow[plot1] SelectionMove[EvaluationNotebook[], All, GeneratedCell]FrontEndTokenExecute[OpenCloseGroup]; Pause[0.01];0.25,The whole thing looks perfectly awful!! It is very difficult to make a good3D density plot. The problem is that the points get in each other's way.Another effect makes things even worse. The ordered points create variouspatterns, depending upon the particular viewpoint. These patterns havenothing to do with the function or data that you are trying to show, butonly with the arrangement of data points. Even if the points are randomlyplaced, you will still obtain various spatial patterns. It is what EdwardTufte calls the 1+1=3 effect in graphics. The various elements combine toproduce unintended visual elements that grab the viewers attention at theexpense of the real information.So, is there a better approach? A lot depends upon the nature of yourfunction or data, and also on what aspect of the function you are trying toemphasize. You could, for example, do 2D contour plots for various slices ofthe room. You could also try cut-a-way plots of various level surfaces in3D. A multiple combination of images may best show whatever it is you aretrying to show.David Parkdjmp@earthlink.nethttp://home.earthlink.net/~djmp/problem !Reply-To: francoisNO@SPAMit-c.dk ==== Hi,Hope I won't be too imprecise, I just started with mathematicalast Friday.1)I want to define a function, say f, with among others the following propertyf[f[a,b,c],d,e] should be evaluated as f[f[a,b,1/2],b,1/2] in caseb = d and c = d = 12) from a list, say {a,b,c}, I would like to generateI guess I have understood the iterative way of doing that,but what about a more functionqal form?Francois-- Francois LauzeThe IT University of Copenhagen, Glentevej 672400 Kbh NV, Denmark ==== Francois,1) I wonder if b=d should be b = e. If so f[f[a_,b_,1],1,b_] :=f[f[a,b,1/2],b,1/2];--Allan---------------------Allan HayesMathematica Training and ConsultingLeicester UKwww.haystack.demon.co.ukhay@haystack.demon.co.ukVoice: +44 (0)116 271 4198property ==== Francois1) The naive answer is simply to include the linef[f[a_,1,1],1,e] := f[f[a,1,1/2],1,1/2]in your definition of the function f. (Note that by your definitionb=c=d=1). However, I'm not sure I've fully understood your question sothis naive answer may not go far enough.2) Again, I'm not entirely sure what you want to do. But here's oneway of transforming your sample input into your sample output. First,load the Combinatorica package, we need the KSubset function:< I don't think there is a simple expression in a conventional sense,> but you can give a simple formula in terms of a generating power> series:>> f[k_, m_] := SeriesCoefficient[Series[1/(1 - x)^k, {x, 0, m - k}], m -> k]> Andrzej Kozlowski> Yokohama, Japan> http://www.mimuw.edu.pl/~akoz/> http://platon.c.u-tokyo.ac.jp/andrzej/>> I was wondering if there was a simple expression (as a function of m>> and k )>> to compute>> the total number of solutions to the integer programming problem:>> n_1 + n_2 + n_3 + ... + n_k = m>> where m > k, each ni >= 1.>> Basically, I am trying to figure out the number of ways of >> partitioning>> a set with m unique elements into k non-empty disjoint subsets.>> For example, if k = 2, then the number of solutions to>> n_1 + n_2 = m is (m-1) = M_2(m) (say)>> if k = 3, then the number of solutions to>> n_1 + n_2 + n_3 = m is M_3(m) = sum_{i=1}^{m-2} (m-i-1) =>> sum_{i=1}^{m-2} M_2(m-i)>> I can think of a recursive solutions wherein>> M_2(m) = (m-1) and>> M_k(m) = sum_{i=1}^{m-k+1} M_(k-1)(m-i), k > 2>> Kumar>>Andrzej KozlowskiYokohama, Japanhttp://www.mimuw.edu.pl/~akoz/http:// platon.c.u-tokyo.ac.jp/andrzej/ ==== my method using WINDOWS NT 4.1; Mathematica 4.1; EXCEL 97:1. Blacken the contents of the Mathematica cell you wish to copy.2. Use right key of mouse.3. Select Copy - not: Copy As!4. Jump into an EXCEL cell.5. Paste.On my system I get the same output as it appears in Mathematica which showsmy output in StandardForm. I do not get FullForm when copying.It does, however, happen from time to time that - using my standard prcedureinexplicably appears in FullForm.Good luck!Matthias BodeSal. Oppenheim jr. & Cie. KGaAKoenigsberger Strasse 29D-60487 Frankfurt am MainGERMANYMobile: +49(0)172 6 74 95 77Internet: http://www.oppenheim.de-----Ursprí.b9ngliche Nachricht-----Gesendet: Donnerstag, 12. Dezember 2002 07:36An: mathgroup@smc.vnet.netBetreff: Pasting tables into ExcelMath friends,If I program Mathematica to calculate a Cayley Table for A_5, for example,and it displays on the screen in the notebook, I have not been able tofigure out how to paste the values into Excel without all the extraformatting, such as quote marks. Has someone worked this out?For example, the Cayley Table for A_5 copies as follows into Excel...!(* TagBox[GridBox[{ {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60}, {2, 3, 1, 7, 9, 8, 10, 12, 11, 4, 5, 6,14, 15, 13, 19, 21, 20, 22, 24, 23, 16, 17, 18, 37, 39, 38, 40, 42, 41, 46, 47, 48, 43, 44, 45, 49, 51, 50, 52, 54, 53, 58, 59, 60, 55, 56, 57, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36}, {3, 1, 2, 10, 11, 12, 4, 6, 5, 7, 9, 8,15, 13, 14, 22, 23, 24, 16, 18, 17, 19, 21, 20, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 25, 27, 26, 28, 30, 29, 34, 35, 36, 31, 32, 33, 37, 39, 38, 40, 42, 41, 46, 47, 48, 43, 44, 45}, {4, 6, 5, 1, 3, 2, 11, 10, 12, 8, 7, 9,25, 27, 26, 28, 30, 29, 34, 35, 36, 31, 32, 33, 13, 15, 14, 16, 18, 17, 22, 23, 24, 19, 20, 21, 50, 49, 51, 55, 56, 57, 52, 53, 54, 58, 60, 59, 38, 37, 39, 43, 44, 45, 40, 41, 42, 46, 48, 47}, {5, 4, 6, 8, 7, 9, 1, 2, 3, 11, 12, 10,26, 25, 27, 31, 32, 33, 28, 29, 30, 34, 36, 35, 38, 37, 39, 43, 44, 45, 40, 41, 42, 46, 48, 47, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 50, 51, 49, 55, 57, 56, 58, 60, 59, 52, 53, 54}, and so on... ==== please try:N[Sqrt[13/10], 50]Matthias BodeSal. Oppenheim jr. & Cie. KGaAKoenigsberger Strasse 29D-60487 Frankfurt am MainGERMANYMobile: +49(0)172 6 74 95 77Internet: http://www.oppenheim.de-----Ursprí.b9ngliche Nachricht-----Gesendet: Freitag, 13. Dezember 2002 10:19An: mathgroup@smc.vnet.netBetreff: Question about precision.Dear experts,I try to find the square root of 1.3, but obtain an not so correctanswer. Could someone point me how to do? My trials are thefollowings.In[28]:=Sqrt[1.3]Out[28]=1.14018In[29]:= Precision[Sqrt[1.3]]Out[29]=16In[30]:=N[Sqrt[1.3], 50]Out[30]=1.14018In[31]:=1.14018*1.14018Out[31]=1.30001The more precise answer should beIn[32]:=1.140175425*1.140175425Out[32]=1.3Wen-Feng Hsiao ==== You don't need Evaluate for the the makewithdraw function since, unlike the first example, the module gets evaluated when you instantiate a new account.makewithdraw[initbalance_] := Module[{balance = initbalance}, Function[ amount, If[ balance >= amount, balance -= amount; balance, Print[ Insufficient Funds ] ] ] ]w1=makewithdraw[100];w2=makewithdraw[100];In[701]:=w1[50]Out [701]=50In[702]:=w2[70]Out[702]=30In[703]:=w2[40]Insufficient FundsIn[704]:=w1[40]Out[704]=10Have fun, SICP is an excellent book.Alex>> This is a programming example from the wizard book chapter 3.> ( http://mitpress.mit.edu/sicp/full-text/book/book.html )>> Consider the following:>> withdraw := Evaluate[> Module[ { balance = 100 },> Function[ amount,> If[ balance >= amount,> balance -= amount; balance,> Print[ Insufficient Funds ]> ]> ]> ]> ]>> In[2]:= withdraw [ 60 ]>> Out[2]= 40>> In[2]:= withdraw[ 60 ]> Insufficient Funds>> The question now is, can I in Mathematica write a function that takes > as> argument the balance, so that I do not have to use the fixed balance => 100. Note that in first example balance is _not_ present in the global> context.>> My idea was the following:>> secondWithdraw[ initBalance_ ] := Evaluate[> Module[ { balance = initBalance },> Function[ amount,> If[ balance >= amount,> balance -= amount; balance,> Print[ Insufficient Funds ]> ]> ]> ]> ]>> In[7]:= W1:=secondWithdraw[ 100 ]>> In[8]:= W1[ 60 ]> Out[8]= If[initBalance >= 60, balance$2 -= 60; balance$2,>> Print[Insufficient Funds]]>> So this however does not work. I _assume_ that Evaluate hits to early.> The evaluation of balance >= amount to initBalance >= amount is too> early. Is this the problem? How can I circumvent it?>> I'd be glad for any insights you might have.> Oliver Ruebenkoenig, ==== >-----Original Message----->Sent: Friday, December 13, 2002 10:09 AM>To: mathgroup@smc.vnet.net>>consider the following:>>In[1]:= test[1, 1] = a;> test[1, 3] = b;>>In[2]:= ?test>Global`test>>test[1, 1] = a>test[1, 3] = b>>In[3]:= from := 1;> to := 3;> test[ 1, #1 ] & /@ Range[ from, to ]>>Out[5]= {a, test[1, 2], b}>>Of course the test[ 1, 2 ] is not evaluated; it does not >exist. If I want>to delete the existing ones I could use:>>In[9]:= deletableValue := 1;> ( HoldForm[ test[ deletableValue, #1 ] =. & ] /@ > Range[ from, to ] ) // ReleaseHold>>Unset::norep: Assignment on test for test[1, 2] not found.>>Out[10]= {Null, $Failed, Null}>>Which makes sense. >>In[14]:= ?test >Global`test>>No test in the global context. My question now: is there a mechanism>e.g. something like test[ 1, All ] that does only access the existing>test?>>I am aware of the possibility to use a conditional (If, Case, ..) and>DownValues to avoid the error message, but is there a more direct>(faster?) way?>Oliver>Oliver Ruebenkoenig, Oliver,look at:In[84]:= Clear[test]In[85]:= test[1, 1] = 11; test[1, 3] = 13; test[2, 0] = 20; test[a] := test[1, 4] + 14 test[_] := Print[what test?]In[90]:= DownValues[test]Out[90]= {HoldPattern[test[a]] :> test[1, 4] + 14, HoldPattern[test[1, 1]] :> 11, HoldPattern[test[1, 3]] :> 13, HoldPattern[test[2, 0]] :> 20, HoldPattern[test[_]] :> Print[what test?]}Selectively extract definitions (rules)In[91]:= Cases[DownValues[test], def : (Verbatim[HoldPattern][test[1, _]] :> _) :> def, {1}]Out[91]= {HoldPattern[test[1, 1]] :> 11, HoldPattern[test[1, 3]] :> 13}Try to selectively extract patterns defined...In[92]:= Cases[DownValues[test], def : HoldPattern[test[1, _]] :> HoldPattern[def], {3}]Out[92]= {HoldPattern[test[1, 4]], HoldPattern[test[1, 1]], HoldPattern[test[1, 3]]}...as you see, this is not good enough to clear selected definitions:In[93]:= Cases[DownValues[test], def : HoldPattern[test[1, _]] :> Unset[def], {3}]Unset::norep: Assignment on !(test) for !(test[((1, 4))]) not found.Out[93]= {$Failed, Null, Null}In[94]:= DownValues[test]Out[94]={HoldPattern[test[a]] :> test[1, 4] + 14, HoldPattern[test[2, 0]] :> 20, HoldPattern[test[_]] :> Print[what test?]}But match full definitions to only clear those definitions with matches appearing at lhs:In[95]:= Clear[test]In[96]:= test[1, 1] = 11;test[1, 3] = 13;test[2, 0] = 20;test[a] := test[1, 4] + 14test[_] := Print[what test?]In[101]:= DownValues[test]Out[101]= ....In[102]:= Cases[DownValues[test], (Verbatim[HoldPattern][def : test[1, _]] :> _) :> Unset[def], {1}];In[103]:= DownValues[test]Out[103]={HoldPattern[test[a]] :> test[1, 4] + 14, HoldPattern[test[2, 0]] :> 20, HoldPattern[test[_]] :> Print[what test?]}What, do you think, should or could be made faster?--Hartmut Wolf ==== I'm not an expert... But here a easy way fo obtain 50 significant numbers :In[1]:=Sqrt[1.3`50]Out[1]= 1.14017542509913797913604902556675447907600531091641In[2]:=% %//FullFormOut[2]//FullForm= 1.299999999999999999999999999999999999999999999999999999999999 9694004`50Meilleures salutationsFlorian Jaccard-----Message d'origine-----Envoy.8e : ven., 13. d.8ecembre 2002 10:19è : mathgroup@smc.vnet.netObjet : Question about precision.Dear experts,I try to find the square root of 1.3, but obtain an not so correctanswer. Could someone point me how to do? My trials are thefollowings.In[28]:=Sqrt[1.3]Out[28]=1.14018In[29]:= Precision[Sqrt[1.3]]Out[29]=16In[30]:=N[Sqrt[1.3], 50]Out[30]=1.14018In[31]:=1.14018*1.14018Out[31]=1.30001The more precise answer should beIn[32]:=1.140175425*1.140175425Out[32]=1.3Wen-Feng Hsiao ==== Martin,You can label contour plots, and in fact any plot lines that have a constantfunction on them, using the DrawLineLabels routine in the DrawGraphicspackage at my web site below. There are examples shown in the DrawGraphicsHelp. Here is your example.Needs[DrawGraphics`DrawingMaster`]Draw2D[ {g = ContourDraw[x, {x, -2.5, 2.5}, {y, -2.5, 2.5}, Contours -> Range[-3, 3, 1]], g // DrawLineLabels[#1 &, 0.6 &, DrawLLFormat -> (Round), DrawLLTextOptions -> {Background -> White}]}, Frame -> True, AspectRatio -> Automatic];I will send you a gif image of the resulting plot separately so you can seethat it works.David Parkdjmp@earthlink.nethttp://home.earthlink.net/~djmp/ c1 = ContourPlot[x, {x, -2.5, 2.5}, {y, -2.5, 2.5}, Contours -> Range[-3, 3, 1], PlotRange -> All];This generates a contour plot with vertical linesat x = {-2, -1, 0, 1, 2}, i.e., five lines.Put labels on the contours:This puts labels {-3, -2, -1, 0, 1} on the vertical linesdescribed above, i.e., the labels start with the lowest valuedefined in the option statement Contours -> Range[-3, 3, 1]Obviously, this is not what I wanted. It seems thatfor the label of the contour line with the lowest value,and so on for increasing values, regardless of the rangeof values actually shown in the plot.My desired behavior would be to label each line accordingto its value. This quick fix (?) appears to produce whatI want (edit in LabelContour.m):(* FindContours[ x_List, {z1_, z2_}] := x Original version *) FindContours[ x_List, {z1_, z2_}] := Table[If[z1 <= x[[m]] <= z2, x[[m]] , {}],{m,Length[x]}]//FlattenIt simply uses the full z-range of the contour plotto remove those contour values (as specified in Contours -> ...)that fall outside the range.Any comments on this? Is there a way to get the original codeto put proper labels on corresponding contour lines?Is there a better (more efficient) way of fixing the problem?TIA,Martin ==== Web-Feng,For machine precision numbers, the default, Mathematica normally onlydisplays 6 places of precision even though it calculates to full machineprecision - 16 places. To show more places use NumberForm.Sqrt[1.3]NumberForm[%, 16]1.140181.140175425099138You can use the Option Inspector to change the number of places normallydisplayed. (Also N is only used to convert exact numbers to approximatenumbers and affects the display ONLY if you specify more than machineprecision. So NumberForm, and not N, is the correct function to control thedisplay.)David Parkdjmp@earthlink.nethttp://home.earthlink.net/~djmp/ Precision[Sqrt[1.3]]Out[29]=16In[30]:=N[Sqrt[1.3], 50]Out[30]=1.14018In[31]:=1.14018*1.14018Out[31]=1.30001The more precise answer should beIn[32]:=1.140175425*1.140175425Out[32]=1.3Wen-Feng Hsiao ==== ... is that true?I am trying to export a cell with some greek letters in it as an epsfile from Mathematica to LyX and I end up with messed up symbols forthe greek letters.I don't want to use bitmap, is there any way for eps with mathematica?W.Reply-To: kuska@informatik.uni-leipzig.de ==== Mathematica produce correct eps files, but *you* have notproper configured you ghostscript and your dvips to findand use the Mathematica PostScript fonts. Jens> ... is that true?> I am trying to export a cell with some greek letters in it as an eps> file from Mathematica to LyX and I end up with messed up symbols for> the greek letters.> I don't want to use bitmap, is there any way for eps with mathematica?> W. ==== I've posted the same question a month ago [1], and was answered by somepeople, namely Jens Peer-Kuska, who provided a solution.However, I couldn't get it work, so I wish we could try again, and solvethis tediousness.Borut[1]http://forums.wolfram.com/mathgroup/ archive/2002/Nov/msg00514.html| ... is that true?| I am trying to export a cell with some greek letters in it as an eps| file from Mathematica to LyX and I end up with messed up symbols for| the greek letters.| I don't want to use bitmap, is there any way for eps with mathematica?|| W.|Reply-To: kuska@informatik.uni-leipzig.de ==== I have never used LyX (emacs by brith) and you should consult the LyX manual to configure it properly.I think LyX call ghostscript to render theeps file to a bitmap ian you should set theGS_LIB shell variable properly. First you should try to preview the eps-filewith ghostscript from the command line and look for the error messages, if this worksyou should look if you can configure theghostscript command inside LyX or if yoursetup of the environment variables isoverwritten by LyX. Jens> I've posted the same question a month ago [1], and was answered by some> people, namely Jens Peer-Kuska, who provided a solution.> However, I couldn't get it work, so I wish we could try again, and solve> this tediousness.> Borut> [1]> http://forums.wolfram.com/mathgroup/archive/2002/Nov/msg00514 .html> | ... is that true?> | I am trying to export a cell with some greek letters in it as an eps> | file from Mathematica to LyX and I end up with messed up symbols for> | the greek letters.> | I don't want to use bitmap, is there any way for eps with mathematica?> |> | W.> | ==== I have the following problem with Mathematica 4,now the mathkernel works without problems, and I can also plotting graphs,but when I launch the GUI it crashes every time I try to start the kernel,and i get the error messageMathematica has received the signal: SIGSEGV and has exited.If possible, please report this problem to support@wolfram.comdescribing in in as much detail as possible what you were doingwhen the problem occurred.Segmentation faultthe only solution I've found on the Wolfram web-site is to contact the support,can someone help me ??thanksToio************************************ ** Vittorio Morandi ** ** E-Mail: morandi@lamel.bo.cnr.it ** ************************************ ==== I am wondering whether it is possible to seta Legend Option to adjust the separation betweenboth the legend left border of the enclosing box and the legend SymbolShape and between the legend SymbolShape and the actual legend text.I am trying to write a legend to a MultipleListPlot, butthe above separations are too large that the legend textdoes not fit inside the sorrounding box.Sergio ==== In a previous message Re: Ellipse and circle intersection, I hinted that Solve would not always give the right answer when trying to obtain the intersections of an ellipse and a circle. Two comments were received (Tom Burton and Rasmus Debitsch) suggesting that there was nothing wrong. Still, definitely there is, as shown in the example below. The situation is as follows:In[1]:=ellipse = (x - c)^2/b^2 + (y - d)^2/a^2 == 1;circ = x^2 + y^2 == 1;sol = Solve[{ellipse, circ}, {x, y}];The solution comes out all right in terms of the four parameters a, b, c, d. The following sets of values for the parametrs are tested:In[2]:=example1Tom = {a -> 1.2, b -> 1.3, c -> 0.2, d -> 0.3};example2Tom = {a -> 1.2, b -> 1.3, c -> 1.2, d -> 1.3};example3Rasmus = {a -> 2, b -> 1, c -> 1, d -> 1};example4Tomas = {a -> 0.25, b -> 0.75, c -> 0.5, d -> 0};(the first two come from Tom Burton, the third one from Rasmus, and the fourth one is mine). Numerical solutions are then obtained for each set:In[3]:=sol1=sol/.example1Tom;In[4]:=sol2=sol/.example2Tom ;In[5]:=sol3=sol/.example3Rasmus//N;In[6]:=sol4=sol/. example4Tomas;In each of the first three cases the correct intersections (as observed graphically through ImplicitPlot) are found, in addition to some complex points. However, the fourth case fails to give a correct answer, even if the two curves intersect very nicely at four different points in the plane. This points to a weird behavior of Solve. I hope someone will come forward with some explanation.Tomas GarzaMexico City ==== > In a previous message Re: Ellipse and circle intersection, I> hinted that Solve would not always give the right answer when trying to> obtain the intersections of an ellipse and a circle. Two comments were> received (Tom Burton and Rasmus Debitsch) suggesting that there was> nothing wrong. Still, definitely there is, as shown in the example> below. The situation is as follows:> In[1]:=> ellipse = (x - c)^2/b^2 + (y - d)^2/a^2 == 1;> circ = x^2 + y^2 == 1;> sol = Solve[{ellipse, circ}, {x, y}];> The solution comes out all right in terms of the four parameters a, b,> c, d. The following sets of values for the parametrs are tested:> In[2]:=> example1Tom = {a -> 1.2, b -> 1.3, c -> 0.2, d -> 0.3};> example2Tom = {a -> 1.2, b -> 1.3, c -> 1.2, d -> 1.3};> example3Rasmus = {a -> 2, b -> 1, c -> 1, d -> 1};> example4Tomas = {a -> 0.25, b -> 0.75, c -> 0.5, d -> 0};> (the first two come from Tom Burton, the third one from Rasmus, and the> fourth one is mine). Numerical solutions are then obtained for each set:> In[3]:=> sol1=sol/.example1Tom;> In[4]:=> sol2=sol/.example2Tom;> In[5]:=> sol3=sol/.example3Rasmus//N;> In[6]:=> sol4=sol/.example4Tomas;> In each of the first three cases the correct intersections (as observed> graphically through ImplicitPlot) are found, in addition to some complex> points. However, the fourth case fails to give a correct answer, even if> the two curves intersect very nicely at four different points in the> plane. This points to a weird behavior of Solve. I hope someone will> come forward with some explanation.> Tomas Garza> Mexico CityThe reason is that the generic radical solution does not work for thoseparticular values of parameters. We can see why as follows. First wecreate polynomials and find a quartic in one variable.eqns = {ellipse,circ};polys = Map[#[[1]]-#[[2]]&, eqns];InputForm[uniploy = First[GroebnerBasis[polys, {x,y}, CoefficientDomain->RationalFunctions]]]Out[67]//InputForm= 1 + b^(-4) - 2/b^2 - (2*c^2)/b^4 - (2*c^2)/b^2 + c^4/b^4 - (2*d^2)/a^2 + (2*d^2)/(a^2*b^2) + (2*c^2*d^2)/(a^2*b^2) + d^4/a^4 + ((4*d)/a^2 - (4*d)/(a^2*b^2) - (4*c^2*d)/(a^2*b^2) - (4*d^3)/a^4)*y + (-2/a^2 - 2/b^4 + 2/b^2 + 2/(a^2*b^2) + (2*c^2)/b^4 + (2*c^2)/(a^2*b^2)+ (6*d^2)/a^4 - (2*d^2)/(a^2*b^2))*y^2 + ((-4*d)/a^4 +(4*d)/(a^2*b^2))* y^3 + (a^(-4) + b^(-4) - 2/(a^2*b^2))*y^4We have a quartic univariate in y (in terms of the problem parameters).Now we plug in your values:InputForm[unipoly /. {a->1/4, b->3/4, c->1/2, d->0}]Out[69]//InputForm= (81*(-5/3 + (1024*y^2)/27 + (16384*y^4)/81))/16384Notice that it is biquadratic (that is, quadratic in y^2). But this isexactly the case for which the Cardano formulation of the quarticradical solution does not work.To obtain a solution that does not have this limitation one must avoid aradical formulation. This can be done as below. The solution (not shown)is in terms of parametrized Root[] functions.SetOptions[Roots, Quartics->False];soln = Solve[{ellipse,circ}, {x,y}];In[73]:= InputForm[soln /. N[{a->1/4, b->3/4, c->1/2, d->0}]]Out[73]//InputForm= {{x -> 0.981455818030629, y -> -0.19168849014437103}, {x -> 0.981455818030629, y -> 0.19168849014437103}, {x -> -1.106455818030629 - 8.619810689307775*^-27*I, y -> 1.1376714700528284*^-27 - 0.473544588453747*I}, {x -> -1.106455818030629 + 8.619810689307775*^-27*I, y -> 1.1376714700528284*^-27 + 0.473544588453747*I}}If you are curious as to why the Cardano method fails when the quarticreduces to a biquadratic, I can send a derivation of that formula.Actually I should have put it inhttp://library.wolfram.com/conferences/conference98/ abstracts/various_ways_to_tackle_algebraic_equations.htmlIn the notebook accessible from that link I show how one might derivethe cubic radical solution. My updated version of the notebook alsocovers the quartic derivation so I will try to get that version put atthe web site. The essence of the nongeneric problem is that one isconfronted with a hidden division by zero.Daniel LichtblauWolfram Research ==== > In a previous message Re: Ellipse and circle intersection, I> hinted that Solve would not always give the right answer when trying to> obtain the intersections of an ellipse and a circle. Two comments were> received (Tom Burton and Rasmus Debitsch) suggesting that there was> nothing wrong. Still, definitely there is, as shown in the example> below. The situation is as follows:>> In[1]:=> ellipse = (x - c)^2/b^2 + (y - d)^2/a^2 == 1;> circ = x^2 + y^2 == 1;> sol = Solve[{ellipse, circ}, {x, y}];>> The solution comes out all right in terms of the four parameters a, b,> c, d. The following sets of values for the parametrs are tested:>> In[2]:=> example1Tom = {a -> 1.2, b -> 1.3, c -> 0.2, d -> 0.3};> example2Tom = {a -> 1.2, b -> 1.3, c -> 1.2, d -> 1.3};> example3Rasmus = {a -> 2, b -> 1, c -> 1, d -> 1};> example4Tomas = {a -> 0.25, b -> 0.75, c -> 0.5, d -> 0};>> (the first two come from Tom Burton, the third one from Rasmus, and the> fourth one is mine). Numerical solutions are then obtained for each set:>> In[3]:=> sol1=sol/.example1Tom;> In[4]:=> sol2=sol/.example2Tom;> In[5]:=> sol3=sol/.example3Rasmus//N;> In[6]:=> sol4=sol/.example4Tomas;>> In each of the first three cases the correct intersections (as observed> graphically through ImplicitPlot) are found, in addition to some complex> points. However, the fourth case fails to give a correct answer,You are correct.> This points to a weird behavior of Solve. I hope someone will> come forward with some explanation.I do too! I find this behavior to be very disturbing. (Am I overlookingsome obvious reason for such behavior?)It might be noted, for some _slight_ comfort, that at least if we firstset a = 0.25, b = 0.75, c = 0.5, d = 0, then Solve[{ellipse, circ}, {x, y}]will give us, correctly it seems,{{y -> -0.19168849014437106, x -> 0.9814558180306291}, {y -> 0. - 0.47354458845374703*I, x -> -1.106455818030629}, {y -> 0. + 0.47354458845374703*I, x -> -1.106455818030629}, {y -> 0.19168849014437106, x -> 0.9814558180306291}}As a trivial aside:Just as a curiosity, why does Mathematica see fit to reverse x and y?In other words, since we had asked for {x, y}, why does Mathematica reportthe results in the form {y -> , x -> }, rather than {x -> , y -> }?But back to Tomas' observation of incorrect behavior of Solve:I crave an explanation!-- David Cantrell ==== > The issue is: how do I create a pure recursive function? Normally when> creating a recursive function I use the name of the function to perform> the recursive call:> fact[n_] :=> If[n == 1, 1, n fact[n - 1]]> If[#>1,# #0[#-1],1]&Albert.. ==== Niall,What objection do you have to making fact a Global variable? That is thenormal Mathematica usage. Every symbol you create is put in the Globalcontext (unless you are writing a package and put it in the packagecontext.)Your recursive function could probably be better written with multipledefinitions as follows.fact[0] := 1;fact[n_] := n fact[n - 1]Often it may be useful to use dynamic programming (Section 2.4.9) so as tosave computed values.fact[0] := 1;fact[n_] := fact[n] = n fact[n - 1]David Parkdjmp@earthlink.nethttp://home.earthlink.net/~djmp/The logical step to avoid this seems to be to make the name of thefunction local as in something like the following:Function[fact, fact[5]] @@ {Function[n, If[n==0, 1, n fact[n-1]]]}or maybe:With[{fact = Function[n, If[n == 0, 1, n fact[n - 1]]]}, fact[5]]However both of these solutions steadfastly return the value 5fact[4]. I assume the problem is that the variables initialised inFunction[] and With[] must be symbols, and cannot be patterns. But arecursion requires a pattern (n_ in the first, global, solution above).What do I do to get factorial to work _without_ making the symbol factglobal?I'd be grateful for any help.Niall. ==== I had the same problem. Running ranlib did fix the out-of-date errormessage.However, I still get the message /usr/bin/ld:/usr/lib/libSystem.dylib load command 9 unknown cmd field. Then,make: *** [addtwo] Error 1.Anyone seen this?> I'm trying to get the example addtwo to compile, using ProjectBuilder.> The Developer's guide says in different places, that I should not use> libML.a, and also that I must use it. In any event, I get fatals errors> Ôout of date' if I try to include it. If I leave it out and use> mathlink.framework instead, addtwo compiles but does not run normally.> Any suggestions? I've been working on this for days, it is driving me> crazy. I'm not a professional software developer and not very familair> with ProjectBuilder, either.> MacOS X uses a static library for MathLink, just as has been done with> other UNIX variants.> There is a known issue for MacOS X wherein it is necessary to run the> command line tool ranlib on the library file libML.a before building> executables that are linked against the library. As long as you don't> move the library file to another location, you need only do this once. ==== Whoops, solved this one myself.Had to upgrade the Developer Package after upgrading to Jaguar.After that, no problem, worked fine.> I had the same problem. Running ranlib did fix the out-of-date error> message.> However, I still get the message /usr/bin/ld:> /usr/lib/libSystem.dylib load command 9 unknown cmd field. Then,> make: *** [addtwo] Error 1.> Anyone seen this?> I'm trying to get the example addtwo to compile, using ProjectBuilder.> The Developer's guide says in different places, that I should not use> libML.a, and also that I must use it. In any event, I get fatals errors> Ôout of date' if I try to include it. If I leave it out and use> mathlink.framework instead, addtwo compiles but does not run normally.> Any suggestions? I've been working on this for days, it is driving me> crazy. I'm not a professional software developer and not very familair> with ProjectBuilder, either.> MacOS X uses a static library for MathLink, just as has been done with> other UNIX variants.> There is a known issue for MacOS X wherein it is necessary to run the> command line tool ranlib on the library file libML.a before building> executables that are linked against the library. As long as you don't> move the library file to another location, you need only do this once. ==== >at school the command plot makes mathematica open>a new page witch contains the graphics but it dont seems to>be a preset of mathematica so my question is how can I>configure mathematica to make im plot my grapchics in new page>>thank>s.To set the default action for graphics, you set $DisplayFunction. The function takes a single argument, the graphics expression. For example,In[1]:=PrintShort[gr_] := Print[Short[InputForm[gr]]]In[2]:=$DisplayFunction = PrintShort;In[3]:=Plot[x^2,{x,0,10}]Graphics[{{Line[<<1>>]}}, á nge -> Automatic, <<24>>}]Note that there's no output in this example, so it's a good idea to have your function return the original expression.The second part is learning how to put a graphic into a new notebook. This can be done with DisplayString and NotebookPut.In[4]:=PutToNewNB[gr_] := (NotebookPut[ Notebook[{ Cell[GraphicsData[PostScript, DisplayString[gr]],Graphics, ImageMargins->{{0,0},{0,0}}] },WindowSize->{FitAll, FitAll}, WindowElements->{},WindowFrameElements->{CloseBox}, ShowCellBracket->False, Saveable->False] ]; gr)In[5]:=$DisplayFunction =PutToNewNB;In[6]:=Plot[x^2,{x,0,10}]Out[6]=-Graphics-------- -------------------------------------------------------Omega ConsultingThe final answer to your Mathematica needs ==== > No, you don't. There are infinitely many roots, of which Mathematica> gives you only three: -Pi/2, 0, and Pi/2.>> Actually, you get five different roots, not three.Oops! Sorry, I mistakenly had thought you were solving just f[x]==0, ratherthan f'[x]==0, which indeed gives five roots.> Nevertheless - point taken.> I ment of course that i'd like Mathematica to give me ALL the roots on> form: angle + (period * n). I'll try to be more exact the next time.Well, here's something that might interest you, although it's not reallywhat you wanted. Let's be a bit more general, now asking Mathematica toSolve[f'[x]==a, x]. This gives eight expressions:{{x -> -ArcCos[-Sqrt[5/8 - Sqrt[9 - 16*a]/8]]}, {x -> ArcCos[-Sqrt[5/8 - Sqrt[9 - 16*a]/8]]}, {x -> -ArcCos[Sqrt[5/8 - Sqrt[9 - 16*a]/8]]}, {x -> ArcCos[Sqrt[5/8 - Sqrt[9 - 16*a]/8]]}, {x -> -ArcCos[-Sqrt[5/8 + Sqrt[9 - 16*a]/8]]}, {x -> ArcCos[-Sqrt[5/8 + Sqrt[9 - 16*a]/8]]}, {x -> -ArcCos[Sqrt[5/8 + Sqrt[9 - 16*a]/8]]}, {x -> ArcCos[Sqrt[5/8 + Sqrt[9 - 16*a]/8]]}}Merely substituting 0 for a in the above gives one double and six singleroots:{{x -> (-2*Pi)/3}, {x -> (2*Pi)/3}, {x -> -Pi/3}, {x -> Pi/3}, {x -> -Pi}, {x -> Pi}, {x -> 0}, {x -> 0}}That's still not what you wanted. But to get, at least in some sense, whatyou want, you simply need to interpret all of the inverse cosines above asdenoting not just the principal value (which is what Mathematica does, ofcourse), but rather all values of the inverse cosine relation. Then eachof the eight expressions above would represent infinitely many values.Finally, substituting 0 for a, you would have all solutions represented interms of the multivalued inverse cosine relation:-arccos(-1/2), arccos(-1/2), -arccos(1/2), arccos(1/2),-arccos(-1), arccos(-1), -arccos(1), arccos(1)or equivalently, for integer N,(-2*Pi)/3+2*Pi*N, (2*Pi)/3+2*Pi*N, -Pi/3+2*Pi*N, Pi/3+2*Pi*N,-Pi+2*Pi*N, Pi+2*Pi*N, 0+2*Pi*N, 0+2*Pi*N.To get this final form -- at least the way I did it -- required humanintervention, which I'm sure you had hoped to avoid. Can anyone suggesta simple way, avoiding human intervention, to have Mathematica give anequivalent form of the result?David Cantrell-- -------------------- http://NewsReader.Com/ --------------------Usenet Newsgroup Service New Rate! $9.95/Month 50GB ==== > No, you don't. There are infinitely many roots, of which Mathematica gives> you only three: -Pi/2, 0, and Pi/2.> Actually, you get five different roots, not three. Nevertheless - point> taken.> I ment of course that i'd like Mathematica to give me ALL the roots on form:> angle + (period * n). I'll try to be more exact the next time.> Didn't you notice Mathematica's comment that, since inverse functions were> being used, some solutions might not be found? That's the explanation.> Yes, i did. I wonder why it's the ONLY method used by Mathematica. It feels> pretty bad to know that the program misses some simple roots. I don't> wonder> what kind of algorithm gave that, rather why do they use only that> algorithm.> I appologize if my question caused any trouble by it's fuzziness.> --> V.8anligen> Konrad> -------------------I did not really understand at first the nature of the question. Nowthat I do I'll take a stab at it. Under Solve>Further Examples>Gettinginfinite solution sets for some equations in the Help Browser, there iscode to do something called GeneralizeSolve. It is based on findingperiodic inverses to various known functions, and takes advantage of thefact that Solve will find solutions in terms of these inverse functions.It does not quite work directly on your problem for the simple reasonthat e.g. ArcSin[0] will evaluate to 0. So we make it work by solvingf'[x]==a and substituting a->0 afterward.Here is the code in question.arctrigs = {ArcSin, ArcCos, ArcCsc, ArcSec, ArcTan, ArcCot, ArcSinh,ArcCosh, ArcCsch, ArcSech, ArcTanh, ArcCoth};periods = {2*Pi, 2*Pi, 2*Pi, 2*Pi, Pi, Pi, 2*I*Pi, 2*I*Pi, 2*I*Pi, 2*I*Pi, I*Pi, I*Pi}; (* We use n to denote an arbitrary integer *)Generalize[f_[x_], n_] := f[x] + nperiods[[Position[arctrigs, f][[1, 1]]]] /; MemberQ[arctrigs,f]Generalize[Log[x_],n_]:=Log[x]+2[Pi][ ImaginaryI]nGeneralize[ProductLog[x_],n_]:=ProductLog[n,x] Generalize[x___, n_] := xGeneralizedSolve[eqns_, vars_] := Generalize[#, n] & //@ Solve[eqns,vars]In[12]:=GeneralizedSolve[f'[x]==a,x]/. a->0Solve::ifun: Inverse functions are being used by Solve, so somesolutions may not be found.Out[12]={{x -> -((2*Pi)/3) - 2*n*Pi}, {x -> (2*Pi)/3 + 2*n*Pi}, {x -> -(Pi/3) - 2*n*Pi}, {x -> Pi/3 + 2*n*Pi}, {x -> -Pi - 2*n*Pi}, {x -> Pi + 2*n*Pi}, {x -> -2*n*Pi}, {x -> 2*n*Pi}}A minor inconvenience is that some solutions may be listed more thanonce e.g. the last two are equivalent if we regard n as ranging over allintegers.Daniel LichtblauWolfram Research ==== > I did not really understand at first the nature of the question. Now> that I do I'll take a stab at it. Under Solve>Further Examples>Getting> infinite solution sets for some equations in the Help Browser, there is> code to do something called GeneralizeSolve.Many thanks for pointing this out. I had not see it before.It answers the question at the end of my previous post in this thread:Can anyone suggest a simple way, avoiding human intervention, to haveMathematica give an equivalent form of the result?> It is based on finding> periodic inverses to various known functions, and takes advantage of the> fact that Solve will find solutions in terms of these inverse functions.> It does not quite work directly on your problem for the simple reason> that e.g. ArcSin[0] will evaluate to 0. So we make it work by solving> f'[x]==a and substituting a->0 afterward.(Yes. I had suggested this also.)[snip of code,...]> A minor inconvenience is that some solutions may be listed more than> once e.g. the last two are equivalent if we regard n as ranging over all> integers.OTOH, instead of being viewed as an inconvenience, it might be regardedin some situations as providing valuable information about themultiplicities of the roots.David Cantrell-- -------------------- http://NewsReader.Com/ --------------------Usenet Newsgroup Service New Rate! $9.95/Month 50GB ==== >As I understand it, I can write a Complex java class with a public constructor>method of the form:>> public Complex(double Re, double Im)>>and mehtods re() and im() of the form:>> public double re();> public double im();>If I place this class file in a directory on the JavaClassPath and execute>SetComplexPath[Complex], I should then be able to pass complex numbers from>Mathematica to any java method accepting objects of type Complex.>>Has anyone had any luck with this? I haven't been able to get it to work in>Mac OS 9 or Mac OS X.Mark,This should work as you describe. I have no trouble with it on any OS, including Mac OS 9 and OS X.What happens when you try it? What error messages do you see? What does your complex number class look like? I suggest that you send this query, including the answers to these questions, to jlink@wolfram.com. To resolve your problem we may need to go into more detail than would be of general interest to the mathgroup.Todd GayleyWolfram Research ==== I'm trying to get JLink working and am having some difficulties. I need tochange the CommandLine property for InstallJava[], and I wanted to set it upso it did it automatically. In the Help it says to add a SetOptions[] tothe init.m file. I tried adding the code it suggests:<mypath]but it doesn't work. If I add this line in an external editor, I get anerror when I run Mathematica. If I open the init.m file in Mathematica, itjust doesn't stick. The init.m file has a huge giant SetOptions in it. Infact, that's all it is is one big SetOptions call. Am I supposed to add myoption to that call? If so, how. The format of the SetOptions[] in theinit.m file looks very different. Everything is enclosed in double quotes,including what looks like the property names. Here's the first few lines:SetOptions[$FrontEnd,NotebookDirectory:>FrontEnd` FileName[{$RootDirectory, C:, Documents and Settings, steven, Application Data, Mathematica, FrontEnd}, CharacterEncoding -> WindowsANSI],AutoOpenPalettes->{BasicInput.nb, AlgebraicManipulation.nb},AutoOpenNotebooks->{}, ScreenRectangle->{{0, 1024}, {0, 721}},NotebooksMenu->{If I need to add my option change in here, where should I put it. ThisSetOptions[] is so complex it's hard to see where one thing starts andanother end, especially since I'm so new to Mathematica. Also, where do Iput the <True]----------------How can I make this happen?--Steven Hodgensteven@twitch.net ==== I am due for a new computer and my driving requirement is Mathematica speed.I was wondering if anyone could recommend which processor family (Intel orAMD) and which OS (Win NT or WXP) has the best speed comparison.I read a statement that said the AMD runs circles for FP ops. over Intel,but there was no more detail, so I was wondering.Note: I have always thought about going MAC, but just have too much softwarethat I use and cannot afford to. ==== Do a search on Google.Here are a couple of links:http://www.scientificweb.de/mathstef3.htmlhttp://www2. staff.fh-vorarlberg.ac.at/~ku/karl/mma.htmlCarsten Hansen>> I am due for a new computer and my driving requirement is Mathematicaspeed.>> I was wondering if anyone could recommend which processor family (Intel or> AMD) and which OS (Win NT or WXP) has the best speed comparison.>> I read a statement that said the AMD runs circles for FP ops. over Intel,> but there was no more detail, so I was wondering.>> Note: I have always thought about going MAC, but just have too muchsoftware> that I use and cannot afford to.> ==== For Mathematica users who plot data for presentation to others, the difficulty of controlling the details of graph layout is a recurring annoyance. It has been noted before in this forum that long labels, for example, can play hob with graph formatting and alignment.process of keeping the formatting consistent, but I have always been stopped by a significant omission from Mathematica's graphics capabilities: There seems to be no way to determine the size of a graphical text element. I'm sure this has been pointed out to WR many times (twice by me), but apparently providing a way to determine the size of graphics text has a low development priority, because it hasn't happened yet.Here's an example of how the ability to determine text size could be helpful. Suppose that we want to keep the size and aspect ratio of the plot area from changing if we specify a long plot label. We might allocate a rectangle of a certain size for the label, then make sure that the label fits inside it. If it doesn't, we could programmatically reduce the font size until the formatted label is small enough to fit. But even such a simple scheme as this is unavailable to us, because we have no way to test whether the text fits inside a rectangle without plotting it and looking at it.Given the power of Mathematica, it would seem to be relatively simple for someone with knowledge of a few basics -- for example, font metrics and how PostScript formats text -- to write a function that would return the size of the bounding box for a piece of formatted text. Unfortunately, I'm not that someone; but I am wondering if one of you MathGroupies has either solved this problem or knows roughly how to do it. Or maybe you can point out something simple that I have been overlooking.Dick ZacherTo reply directly, please remove the four-letter prefix Junk from my return ==== > No, you don't. There are infinitely many roots, of which Mathematica > gives> you only three: -Pi/2, 0, and Pi/2.>> Actually, you get five different roots, not three. Nevertheless - >> point>> taken.>> I ment of course that i'd like Mathematica to give me ALL the roots >> on form:>> angle + (period * n). I'll try to be more exact the next time.> Didn't you notice Mathematica's comment that, since inverse > functions were> being used, some solutions might not be found? That's the > explanation.>> Yes, i did. I wonder why it's the ONLY method used by Mathematica. It >> feels>> pretty bad to know that the program misses some simple roots. I >> don't>> wonder>> what kind of algorithm gave that, rather why do they use only that>> algorithm.>> I appologize if my question caused any trouble by it's fuzziness.>> -->> V.81nligen>> Konrad>> ------------------->> I did not really understand at first the nature of the question. Now> that I do I'll take a stab at it. Under Solve>Further Examples>Getting> infinite solution sets for some equations in the Help Browser, there > is> code to do something called GeneralizeSolve. It is based on finding> periodic inverses to various known functions, and takes advantage of > the> fact that Solve will find solutions in terms of these inverse > functions.> It does not quite work directly on your problem for the simple reason> that e.g. ArcSin[0] will evaluate to 0. So we make it work by solving> f'[x]==a and substituting a->0 afterward.>> Here is the code in question.>> arctrigs = {ArcSin, ArcCos, ArcCsc, ArcSec, ArcTan, ArcCot, ArcSinh,> ArcCosh,> ArcCsch, ArcSech, ArcTanh, ArcCoth};>> periods = {2*Pi, 2*Pi, 2*Pi, 2*Pi, Pi, Pi, 2*I*Pi,> 2*I*Pi, 2*I*Pi, 2*I*Pi, I*Pi, I*Pi};>> (* We use n to denote an arbitrary integer *)>> Generalize[f_[x_], n_] :=> f[x] + nperiods[[Position[arctrigs, f][[1, 1]]]] /; MemberQ[arctrigs,> f]>> Generalize[Log[x_],n_]:=Log[x]+2[Pi][ImaginaryI]n>> Generalize[ProductLog[x_],n_]:=ProductLog[n,x]>> Generalize[x___, n_] := x>> GeneralizedSolve[eqns_, vars_] := Generalize[#, n] & //@ Solve[eqns,> vars]>> In[12]:=> GeneralizedSolve[f'[x]==a,x]/. a->0>> Solve::ifun: Inverse functions are being used by Solve, so some> solutions may > not be found.>> Out[12]=> {{x -> -((2*Pi)/3) - 2*n*Pi}, {x -> (2*Pi)/3 + 2*n*Pi},> {x -> -(Pi/3) - 2*n*Pi}, {x -> Pi/3 + 2*n*Pi},> {x -> -Pi - 2*n*Pi}, {x -> Pi + 2*n*Pi},> {x -> -2*n*Pi}, {x -> 2*n*Pi}}>> A minor inconvenience is that some solutions may be listed more than> once e.g. the last two are equivalent if we regard n as ranging over > all> integers.> Daniel Lichtblau> Wolfram Research>This last minor inconvenience can be dealt with as follows:g[x_, y_] := TrueQ[Simplify[Element[x, Integers], Element[y, Integers]] && Simplify[Element[y, Integers], Element[x, Integers]]]l = GeneralizedSolve[Derivative[1][f][x] == a, x] /. a -> 0Solve::ifun:Inverse functions are being used by Solve, so some solutions may not be found.{{x -> -((2*Pi)/3) - 2*n*Pi}, {x -> (2*Pi)/3 + 2*n*Pi}, {x -> -(Pi/3) - 2*n*Pi}, {x -> Pi/3 + 2*n*Pi}, {x -> -Pi - 2*n*Pi}, {x -> Pi + 2*n*Pi}, {x -> -2*n*Pi}, {x -> 2*n*Pi}}Union[l, SameTest -> (g[x /. #1, x /. #2] & )]{{x -> -2*n*Pi}, {x -> -Pi - 2*n*Pi}, {x -> -((2*Pi)/3) - 2*n*Pi}, {x -> -(Pi/3) - 2*n*Pi}, {x -> Pi/3 + 2*n*Pi}, {x -> (2*Pi)/3 + 2*n*Pi}, {x -> Pi + 2*n*Pi}}(One could of course write a version of GeneralizedSolve that does this automatically).Andrzej KozlowskiYokohama, Japanhttp://www.mimuw.edu.pl/~akoz/http:// platon.c.u-tokyo.ac.jp/andrzej/Reply-To: kuska@informatik.uni-leipzig.de ==== would you be so kind to read the manual *before* youstart to programm ? Fine.Your first definition > withdraw := Evaluate[> Module[ { balance = 100 },> Function[ amount,> If[ balance >= amount,> balance -= amount; balance,> Print[ Insufficient Funds ]> ]> ]> ]> ]return a pure function that does the If[] test when youcall it withdraw[60]. Since you force to evaluate the Module[] you create globalvariable balance$ that can't removed when theModule[] ends. If you would like to use a fixed constant youshould use With[], i.e.withdraw = With[{balance = 100}, Function[amount, If[balance >= amount, balance - amount, Print[Insufficient Funds]]]]In the next definition> secondWithdraw[ initBalance_ ] := Evaluate[> Module[ { balance = initBalance },> Function[ amount,> If[ balance >= amount,> balance -= amount; balance,> Print[ Insufficient Funds ]> ]> ]> ]> ]you Evaluate[] the right side before you have a given a valuefor initBalance but that can't work, because the patterninitBalance_ has absolute nothing to do with the variableinitBalance. You meanwithdraw::insuff = Insifficuent funds Ô1'.withdraw[amount_, balance_:100] := If[balance >= amount, balance - amount, Message[withdraw::insuff, balance] ]orwithdraw1[amount_,balance_:100]/; balance>amount :=balance-amountwithdraw1[amount_,balance_:100]:=(Message[ withdraw::insuff,balance];balance) Jens> This is a programming example from the wizard book chapter 3.> ( http://mitpress.mit.edu/sicp/full-text/book/book.html )> Consider the following:> withdraw := Evaluate[> Module[ { balance = 100 },> Function[ amount,> If[ balance >= amount,> balance -= amount; balance,> Print[ Insufficient Funds ]> ]> ]> ]> ]> In[2]:= withdraw [ 60 ]> Out[2]= 40> In[2]:= withdraw[ 60 ]> Insufficient Funds> The question now is, can I in Mathematica write a function that takes as> argument the balance, so that I do not have to use the fixed balance => 100. Note that in first example balance is _not_ present in the global> context.> My idea was the following:> secondWithdraw[ initBalance_ ] := Evaluate[> Module[ { balance = initBalance },> Function[ amount,> If[ balance >= amount,> balance -= amount; balance,> Print[ Insufficient Funds ]> ]> ]> ]> ]> In[7]:= W1:=secondWithdraw[ 100 ]> In[8]:= W1[ 60 ]> Out[8]= If[initBalance >= 60, balance$2 -= 60; balance$2,> Print[Insufficient Funds]]> So this however does not work. I _assume_ that Evaluate hits to early.> The evaluation of balance >= amount to initBalance >= amount is too> early. Is this the problem? How can I circumvent it?> I'd be glad for any insights you might have.> Oliver Ruebenkoenig, ==== Your example works fine if you remove Evaluate: In[1]:= secondWithdraw[ initBalance_ ] := Module[ { balance = initBalance }, Function[ amount, If[ balance >= amount, balance -= amount; balance, Print[ Insufficient Funds ] ] ] ]In[4]:= W1:=secondWithdraw[100]In[5]:=W1[60]Out[5]=40 ==== >----- Original Message----->Sent: Friday, December 13, 2002 10:10 AM>To: mathgroup@smc.vnet.net>>This is a programming example from the wizard book chapter 3.>( http://mitpress.mit.edu/sicp/full-text/book/book.html )>>Consider the following: >>withdraw := Evaluate[> Module[ { balance = 100 },> Function[ amount,> If[ balance >= amount,> balance -= amount; balance,> Print[ Insufficient Funds ]> ]> ]> ]> ]>>In[2]:= withdraw [ 60 ]>>Out[2]= 40>>In[2]:= withdraw[ 60 ]>Insufficient Funds>>The question now is, can I in Mathematica write a function >that takes as>argument the balance, so that I do not have to use the fixed balance =>100. Note that in first example balance is _not_ present in the global>context. >>My idea was the following:>>secondWithdraw[ initBalance_ ] := Evaluate[> Module[ { balance = initBalance },> Function[ amount,> If[ balance >= amount,> balance -= amount; balance,> Print[ Insufficient Funds ]> ]> ]> ]> ]>>In[7]:= W1:=secondWithdraw[ 100 ]>>In[8]:= W1[ 60 ] >Out[8]= If[initBalance >= 60, balance$2 -= 60; balance$2, >> Print[Insufficient Funds]]>>So this however does not work. I _assume_ that Evaluate hits to early.>The evaluation of balance >= amount to initBalance >= amount is too>early. Is this the problem? How can I circumvent it?>>I'd be glad for any insights you might have.>Oliver Ruebenkoenig, Oliver,you'r quite right, dispense with that Evaluate: In[5]:= withdraw2[initBalance_] := Module[{balance = initBalance}, Function[amount, If[balance >= amount, balance -= amount; balance, Print[Insufficient Funds]]]]In[11]:= W1 = withdraw2[100];In[12]:= balance$21Out[12]= 100In[13]:= W1[60]Out[13]= 40In[14]:= W1[60]Insufficient FundsThe example from the wizard book, in fact is no good at all, just construedto bewilder little children. Your idea to create an account, an individualobject, is much better. However other methods should be defined, and theconstructor given a different name.Here is something containing several member functions: In[177]:= Remove[createAccount]In[178]:=createAccount /: Set[thisAccount_, createAccount[initial_:1 ]] := (thisAccount = Module[{account, key = Random[Integer, {0, 10^12}]}, With[{key = key}, account[Balance] := SequenceForm[account[key], [ThinSpace][InvisibleComma][InvisibleComma], EUR]; account[key] = initial; account[Withdraw] = (If[account[key] >= #, (account[key] -=#)EUR, Print[Insufficient Funds]; $Failed]) &; account[Deposit] = (account[key] += #; If[account[key] > 10^6, Print[Beware of Taxes!]]; account[key]EUR) &; account]];)In[179]:= myAccount = createAccount[] -- this calls the constructor with default initial balance (a donation from my bank), no output is givenIn[180]:= ?myAccountGlobal`myAccountmyAccount = account$154 -- that's the object createdIn[181]:= ?account$154.... -- you see what's behind the sceneIn[182]:= myAccount[Balance]Out[182]= 1 EUR -- method Balance shows the initial donationIn[183]:= myAccount[Deposit][60]Out[183]= 61 EURIn[184]:= myAccount[Balance]Out[184]= 61 EURIn[185]:= myAccount[Withdraw][50]Out[185]= 11 EURIn[186]:= myAccount[Withdraw][50]Insufficient FundsOut[186]= $FailedIn[187]:= myAccount[Deposit][10^7]Beware of Taxes!Out[187]= 10000011 EURPerhaps it is better to move the methods to a class (and just fix theparameters):In[206]:= Remove[createAccount, Balance, Withdraw, Deposit]In[207]:=createAccount /: Set[thisAccount_, createAccount[initial_:1 ]] := (thisAccount = Module[{account, key = Random[Integer, {0, 10^12}]}, account[key] = initial; With[{key = key}, account[Balance] := Balance[account, key]]; account[Withdraw] = Withdraw[account, key]; account[Deposit] = Deposit[account, key]; account];)In[212]:=Balance[account_, key_] := SequenceForm[account[key], [ThinSpace], EUR]In[213]:=Withdraw[account_, key_][amount_] := (If[account[key] >= amount, (account[key] -= amount)EUR, Print[Insufficient Funds]; $Failed])In[214]:=Deposit[account_, key_][amount_] := (account[key] += amount; If[account[key] > 10^6, Print[Beware of Taxes!]]; account[key]EUR)The key isn't necessary, consider it as a password (from the bank not fromyou! and it doesn't matter if someone else has the same password) Of coursewe have to hide Information, however I couldn't succeed as my definition...Evaluate[account] /: Information[account, ___] := gotcha!;...prevented Information[account$154] but not Information[account$154, LongForm -> True] orInformation[account$154, LongForm -> False]...wasn't effective. The explanation for that certainly is quitecomplicated, so I have to state: with Mathematica you can reach for anymoney (and any password for that matter)!--Hartmut WolfReply-To: kuska@informatik.uni-leipzig.de ==== make an Interpolation[] from the data and use Integrate[],or use the standard add on package NumericalMath`ListIntegrate`Mathematica don't use splines, it make pice wise polynomialsand integrate the polynomial. Since you have the sourcecode of ListIntegrate you can look by your self. Jens> Dear Mathemticons( * ):> I have a very simple question. I have a function that is NOT specified> as an analytic expression. Rather, the function is a previsouly> tabulated list of the form:> F( x ):=> { ( x( 1 ),F( x( 1 ) ) ), ... , ( x( i ),F( x( i ) ) , ... ,> ( x( N ),F( x( N ) ) ) }> The list is comprised of N pairs of values, one for the independent varaible> x and the other for the dependent function F( x ).> The x values are NOT equally spaced. They are tabulated at unevenly spaced> intervals.> Also, I do NOT have the freedom to compute additional list values between the> ones initially provided. In a sense, this list can be conceived of as DATA,> although it is actually generated by a previous complex computation.> GOAL:> I wish to integrate this tabulated function from x( 1 ) to x( N )> SIMPLE SOLUTION:> Apply the trapaziodal rule.> DESIRED SOLUTION:> I wish to integrate this tabulated function with a higher degree of accuracy> or fidelity, however this is construed. The caveat, is, as previously> mentioned, that I cannot direclty compute a more densely spaced list of> function values.> PROVISIONAL DESIRED SOLUTION ?> Should I implement a Romberg Type integration scheme where I synthetically> sample progressively more tightly spaced function values via interpolation until> the integral convereges to its final value within a pre-specified precision?> What interpolation scheme should I employ? Cubic spine? Spath Monotonicity> Preserving Hermite? Cubic Spline with Tension? I only required vlaues of> the function, and not its higher derivatives. I am afraid to use Cubic Splines> in general since these often bulge and may produce an answer worse that> the linear interpolation that the Trapazoidal Rule uses.> What technique, if any, does Mathematica employ?> I wish to do this both on Mathematica as well as in an F90 code.> The technique should be fast, since I will be integrating 1000's of such> functions sequentially.> Any advice will be greatly appreciated!> Sincerely,> Theodore Sande> MIT Department of Physics> ( * ) Mathematicon: The fundamental quantum of the Mathematica User's Field ==== > Dear Mathemticons( * ):> I have a very simple question. I have a function that is NOT specified> as an analytic expression. Rather, the function is a previsouly> tabulated list of the form:> F( x ):=> { ( x( 1 ),F( x( 1 ) ) ), ... , ( x( i ),F( x( i ) ) , ... ,> ( x( N ),F( x( N ) ) ) }...The choice of integration scheme is related to the best way to interpolate,which depends on your function. But a very simple question deserves astraightforward answer :-)I would like to recommend that you interpolate explicitely and thenintegrate. It's easy. It's pretty accurate for a lot of functions. Themethod of interpolation is relatively well documented. And best of all, youcan see what you are doing. Here's an example:data = {{1, 3}, {2, 4}, {3, 1}, {4, 2}, {5, 4}, {6, 1}, {7, 2}}FF[x_] = Table[F[n][x_] = Interpolation[data, InterpolationOrder -> n][x], {n, 0, 5}]Plot[Evaluate[FF[x]], {x, 1, 7}];<< NumericalMath`NIntegrateInterpolatingFunct`Table[{n, NIntegrateInterpolatingFunction[F[n][x], {x, 1, 7}]}, {n, 0, 5}]Tom Burton ==== I am using mathematica in windows,I want that when I'm open a file by mouse clicking it will change theworking directory of mathematica to the directory of the file, so if Iwill save data with save (without define to where),it will be saved inthe directory of the open file automaticaly.thanks ==== When i go:f1[x_] := somethingtmp = int(f1[x])dxf2[x_] = tmpthen everything is nice but this:f1[x_] := somethingtmp = int(f1[x])dxf2[x_] = %just won't work. Apparetly Mathematica believesthat % mean the thing i did BEFORE the integral!How come?--V.8anligenKonrad-------------------phone #1: (+46/0) 708 - 70 73 92phone #2: (+46/0) 704 - 79 96 95url: http://konrads.webbsida.com------------------- ==== I have a text file with a first line containing words giving the namesof the data in the column below. Subsequent lines contain the data:x y z 1 2 32 4 63 6 9I want a function that will read this file and and create lists x={1,2,3}y={2,4,6}z={3,6,9}I do not understand how to take the strings x, y, and z that Iread from the first line and create lists with those names to which Ican assign the values.Peter ==== I now finished the creation of an oo system for Mathematica and put it ontomy web site:www.schmitther.deThe contents on the web site are:- a documentation of the system- the oo package- an example, that can be executedThe system is a rather complete implementation of the principles of oo.I want to mention the following features:multiple inheritanceandpolymorphism.I am convinced, that there are applications, which can be better implementedby using the object-oriented method.Hermann Schmitt ==== Reformatted>> There seems to be a bug here due to the fact that ContinuousDistributions.m >> (4.0.0) does not check that q is numeric. > Quantile[NoncentralChiSquareDistribution[2, 10], q] >> Produces a load of errors and some incorrect results when used in LogPlot. > LogPlot[Quantile[NoncentralChiSquareDistribution[2, 10], q], {q, .1, .9}] > This is of course a pain. What is the best way to correct this? Is it to >> copy the particular function from ContinuousDistribution.m and re-include it >> in a little add on or is there an updated version.> I cannot reproduce your difficulty in 4.2. LogPlot there has attribute > HoldFirst, Yes so does 4.0 Attributes[LogPlot]{HoldFirst} I do not understand why this is insufficient to hold off the evaluation until q gets a value. I suspect that it is something to do with the complexity of LogPlot's calls to scaledplot etc.> so no attempt is made to evaluate Quantile[...] before a numeric > value is substituted for q. If this is not true in version 4.0, then you> might try > LogPlot[Unevaluated[Quantile[NoncentralChiSquareDistribution[ 2, 10], q]], > {q, .1, .9}] I was unfamiliar with Unevaluated. One would expect it to do the trick but it doesn't stop the Nintegrate ::nlim error > Tom Burton > PS I am unfamiliar with this distribution and would not notice some > incorrect results. TB I am reasonably certain the the incorrect results are caused by premature evaluation since I have rebuilt the function outside ContinuousDistributions and got what I believe are correct results. Would I be right in presuming that 4.2 has this problem fixed in which case it would be nice to be able to get hold of the 4.2 version of ContinuousDistributions.mStatistics`ContinuousDistributions` Private` Clear[Quantile[NoncentralChiSquareDistribution]] Reprogram with the q_?NumericQ in place.I have actually corrected my copy of ContinuousDistributions.m by changing the lineNoncentralChiSquareDistribution/: Quantile[NoncentralChiSquareDistribution[n_, lambda_], q_, opts___?OptionQ] :=toNoncentralChiSquareDistribution/: Quantile[NoncentralChiSquareDistribution[n_, lambda_], q_?NumericQ, opts___?OptionQ] :=This seems to be effective.-- Nigel ==== > I try to find the square root of 1.3, but obtain an not so correct> answer. Could someone point me how to do? My trials are the> followings.In order to display a number to its full precision, it is often necessary to use NumberFormIn[1]:= NumberForm[Sqrt[1.3], 50] Out[1]//NumberForm= 1.140175425099138An alternative is to specify the precision of 1.3 using 1.3`30In[2]:=Sqrt[1.3`30]Out[2]= 1.140175425099137979136049025567Note that the internally held answer for Sqrt[1.3] is much more accurate than the displayed number.In[3]:=x = Sqrt[1.3]Out[3]=1.14018In[4]:=NumberForm[x*x, 50]Out[4]//NumberForm=1.3I hope this helps---NigelReply-To: kuska@informatik.uni-leipzig.de ==== you have alread, Mathematica only Print[] the short formSqrt[1.3] // FullFormYou can still useSqrt[1.3`1000000]if you need more digits. Jens> Dear experts,> I try to find the square root of 1.3, but obtain an not so correct> answer. Could someone point me how to do? My trials are the> followings.> In[28]:=> Sqrt[1.3]> Out[28]=> 1.14018> In[29]:=> Precision[Sqrt[1.3]]> Out[29]=> 16> In[30]:=> N[Sqrt[1.3], 50]> Out[30]=> 1.14018> In[31]:=> 1.14018*1.14018> Out[31]=> 1.30001> The more precise answer should be> In[32]:=> 1.140175425*1.140175425> Out[32]=> 1.3> Wen-Feng Hsiao ==== > Dear experts,>> I try to find the square root of 1.3, but obtain an not so correct> answer. Could someone point me how to do? My trials are the> followings.>> In[28]:=> Sqrt[1.3]>> Out[28]=> 1.14018>> In[29]:=> Precision[Sqrt[1.3]]>> Out[29]=> 16>> In[30]:=> N[Sqrt[1.3], 50]>> Out[30]=> 1.14018>> In[31]:=> 1.14018*1.14018>> Out[31]=> 1.30001>> The more precise answer should be> In[32]:=> 1.140175425*1.140175425>> Out[32]=> 1.3> Wen-Feng HsiaoFor Sqrt[1.3] the output isSqrt[1.3]//InputForm1.140175425099138but only the first 6 digits are displayed (controled by the optionPrintPrecision - please look up in the Option Inspector).However this is the obtained using machine arithmetic. If we need higherprecision we can use one of the following techiques:Add zeros manually Sqrt[1.300000000000000000000000000000] 1.140175425099137979136049025567Use more cunning Sqrt[1.3`30] 1.140175425099137979136049025567Change to an exact input N[Sqrt[13/10],30] 1.14017542509913797913604902557 or N[Sqrt[Rationalize[1.3]],30] 1.14017542509913797913604902557What does NOT work is the following Sqrt[SetPrecision[1.3,30]] 1.140175425099137998610649164903This is because the zeros are added on in the binary form of 1.3 duringevaluation and not, as in the first two ways, in the decimal form, duringthe pre-evaluation parsing.Check: 1.3`30 1.30000000000000000000000000000 SetPrecision[1.3,30] 1.30000000000000004440892098501Allan--------------------- Allan HayesMathematica Training and ConsultingLeicester UKwww.haystack.demon.co.ukhay@haystack.demon.co.ukVoice: +44 (0)116 271 4198 ==== > In[30]:=> N[Sqrt[1.3], 50]> Out[30]=> 1.14018TryIn[31]:=N[Sqrt[13/10], 50]Out[31]= 1.1401754250991379791360490255667544790760053109164 ==== Dear Wen-Feng Hsiao,you liked to learn the difference between the treatment of machine precisionnumbers and reals of arbitrary precision in Mathematica.The definitive Reference is here:http://documents.wolfram.com/v4/index229.html>----- Original Message----->Sent: Friday, December 13, 2002 10:19 AM>To: mathgroup@smc.vnet.net>Dear experts,>>I try to find the square root of 1.3, but obtain an not so correct>answer. Could someone point me how to do? My trials are the>followings.>>In[28]:=>Sqrt[1.3] -- you entered a machine-precision number>>Out[28]=>1.14018 -- output is a machine-precision number, but only 6 decimal positions are displayed>>In[29]:=>Precision[Sqrt[1.3]]>>Out[29]=>16 -- this is only a formal answer, as precisions of machine-precision numbers are not really calculated or adapted.>>In[30]:=>N[Sqrt[1.3], 50] -- this doesn't work, since N cannot change a machine-precision number to one of arbitrary precision. The right way to do that is Sqrt[SetPrecision[1.3, 50]] Out[]= 1.14017542509913799861064916490273263923168523118758>>Out[30] =>1.14018>>In[31]:=>1.14018*1.14018 -- you should not do such a thing: you typed in what you saw, no wonder what you got!>>Out[31]=>1.30001>>The more precise answer should be>In[32]:=>1.140175425*1.140175425>>Out[32]=>1.3>Wen-Feng Hsiao>Just look at this:1. Machine Precision--------------------In[1]:= $MachinePrecisionOut[1]= 16In[2]:= Sqrt[1.3]Out[2]= 1.14018In[3]:= % // InputFormOut[3]//InputForm= 1.140175425099138 -- That is the number (InputForm) you should have typed! (if you like typing)In[4]:= %*%Out[4]= 1.3 -- sufficiently close?In[5]:= % // InputFormOut[5]//InputForm= 1.3000000000000003 -- a small error results, ok, that's machine arithmetic2. Arbitrary Precision (of same Precision 16)---------------------------------------------In[6]:= Sqrt[1.3`16]Out[6]= 1.1401754250991380 -- more is displayed, according to precisionIn[7]:= % // InputFormOut[7]//InputForm= 1.140175425099137979136049025540202`16.301 -- even more positions are delivered her (due to internal rise of precision, to assure a result of precision 16); of course these extra positions are not significant!In[8]:= %*%Out[8]= 1.300000000000000In[9]:= % // InputFormOut[9]//InputForm= 1.299999999999999999999999999923524`16 -- much less error than above with machine-precision.--Hartmut Wolf ==== > I need some help, here. I'm using Mathematica 4.2 on OS X and I'd > like to save a notebook so that I can include it in a LaTeX file. > According to the Wolfram site, Mathematica has a convenient save as > option just for this sort of task. Unfortunately, I can't get it to > work for the life of me. The notebook saves, but it won't compile.I think this is an area where Wolfram over extended itself. I also tried to use TeX in the way suggested but gave up because the solution is incomplete. I even went to the trouble of adding my own extensions to TeXSave. I found the the complete result was much too restrictive in how one could use Mathematica or TeX.Now I write in TeX (actually ConTeXt) and copy formula and results over as necessary saving graphs as Ô.eps' and converting to Ô.pdf' etc. ConTeXt has a facility for pretty printing Perl, Java, SQL, TeX and MetaPost. I wonder whether an enterprising person will write one for Mathematica Source.> I use TeXShop, a very standard LaTeX environment for OS X that's > built (I believe) on top of teTeX. Per the Ôrequest' of my LaTeX > compiler, I've located copies of notebook2e.sty and wrisym.sty, but > this doesn't help; the fatal error is something like Ô! LaTeX Error: > This NFSS system isn't set up properly.'> Does anybody out there have a slick solution to my problem? It seems > to me that Wolfram should have made this process work out-of-the-box > with standard installations of Mathematica 4.2 and standard > installation of LaTeX utilities. Perhaps I'm missing something.I agree. A facility should not be advertised without reservation if reservations exist. In this facility there are many reservations.> I hope somebody out there can give me a hand with this. (FWIW, I > have access to latex and Mathematics 4.2 on linux and NT platforms, > too.)My comments only apply to 4.0, but I do not believe much has been done to improve the situation. I am sure Wolfram would have shouted if they had!> ==== How can i create a package? Any Directions and Tips?_________________________________________Paulo FerreiraMore ways to contact me: http://wwp.icq.com/132191789_________________________________ ________ ==== >I was wondering if anyone could recommend which processor family>(Intel or AMD) and which OS (Win NT or WXP) has the best speed>comparison.>Note: I have always thought about going MAC, but just have too much>software that I use and cannot afford to.FWIW, I've found Mathematica to run much better under Mac OS X than Win NT. I can't comment on Win XP having never used it.As far as other Windows softare, there is a program (Virtual PC) for Macs that enables a Mac to run just about any software written for a PC. ==== I am seeking a working Launch Command for the Advanced Options of bare kernel on a remote OSX machine via ssh from my OSX machine, no problem, but have had no luck getting the same remote kernel to launch from my Front end.In the 4.2 Help Browser, under Getting Started,System-Specific Information, Troubleshooting,Macintosh (MacOSX) it says:In order to connect to a remote kernel, you must be able to connect via rsh without a password into the machine running the kernel.I of course have been ignoring this advice, since in my environment passwords are required. Does anyone know for sure if ssh can be used instead of rsh?Christopher PurcellDRDC-Atlantic, 9 Grove St., PO Box 1012,Dartmouth, NS Canada B2Y 3Z7chris.purcell@drdc-rddc.gc.ca