A33 == You are of course right, I forgot that Mathematica does not try to keep precision or accuracy of machine arithmetic computations. But I think the actual precision you set need not be higher than machine precision, it just has to be set explicitely (is that right?). For example:In[1]:=Clear[f,a,b,k]In[2]:=k = $MachinePrecision;In[3]:=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),k];In[4]:=a=77617.;b=33096.;In[5]:=a=SetAccuracy[a,k]; In[6]:=b=SetAccuracy[b,k];In[7]:=fOut[7]=!((-5.51716400890319 `-2.8311*^19))In[8]:=Accuracy[f]Accuracy::mnprec: Value -23 would be inconsistent with $MinPrecision; bounding by $MinPrecision instead.Out[8]=-20Andrzej> Andrzej Yes, like you I took the original question to be about how to get the > result> of using the naive rational versions in place of the inexact numbers.> Bobby raises the question of how we might know accuracy of the result. You answer this with> a = 77617.; b = 33096.; In[2]:=> f := 333.75*b^6 + a^2*(11*a^2*b^2 - b^6 - 121*b^4 - 2) +> 5.5*b^8 + a/(2*b) In[3]:=> f Out[3]=> -1.1805916207174113*^21 In[4]:=> Accuracy[%] Out[4]=> -5 However this computation is done in machine arithmetic, which means > that> Mathematica keeps no check on the accuracy and precision of the > computation,> and Mathematica gives the default accuracy value without any real> signifcance: $MachinePrecision - Log[10,Abs[f]]//Round -5 To get meaningful accuracy and precision values we need to force the> computation to be in bignums (bigßoat, arbitrary precision) > arithmetic.> Mathematica then keeps track of the accuracy and precision that it can> guarantee. Clear[f,a,b,k]> k=50; 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),k];> a=77617.;b=33096.;> a=SetAccuracy[a,k];> b=SetAccuracy[b,k];> f -0.82739605995 Accuracy[f] 11 Precision[f] 11 Which tells us that the error in the computed value of f is not more > than 10^-11> The above results are rounded. More accurately we get Accuracy[f, Round->False] 11.4956 Precision[f, Round->False] 11.4133 There are several related issues here:> - is the precision (accuracy) of rhe input known?> - how does Mathematica interpret what one gives it?> - how does Mathematica go about the calculation? --> ---------------------> Hayes> Mathematica Training and Consulting> Leicester UK> www.haystack.demon.co.uk> hay@haystack.demon.co.uk> Voice: +44 (0)116 271 4198> It seems clear to me that what and what you mean by succeeds> here refer to quite different things and your objection is therefore> beside the point. There are obviously two ways in which one can> interpret the original posting. The first interpretation, which > and myself adopted, was that the question concerned purely the> computational mechanism of Mathematica. Or, to put it in other words,> it was why are the results of these two computations not the same?.> In this sense success means no more than making Mathematica return> the same answer using the two different routes the original poster > used.> You on the other hand choose to assume that the posting shows that its> author does not understand not just the mechanism of significance> arithmetic used by Mathematica but also computations with inexact> numbers in general. I do not think this is necessarily the correct> assumption. I also don't see that Mathematica is doing anything wrong.> After all, one can always check the accuracy of your answer: In[1]:=> a = 77617.; b = 33096.; In[2]:=> f := 333.75*b^6 + a^2*(11*a^2*b^2 - b^6 - 121*b^4 - 2) +> 5.5*b^8 + a/(2*b) In[3]:=> f Out[3]=> -1.1805916207174113*^21 In[4]:=> Accuracy[%] Out[4]=> -5 which tells you that it can't be very reliable. What more do you > demand? Andrzej> Andrzej Kozlowski> Yokohama, Japan> http://www.mimuw.edu.pl/~akoz/> http://platon.c.u-tokyo.ac.jp/andrzej/> Actually, we don't know whether SetAccuracy succeeds, because we> don't> know how inexact those numbers really are. If they are known to more> digits than shown in the original post, they should be entered with > as> much precision as they deserve. If not, there's no trick or > algorithm> that will give the result precision, because the value of f really is> in the noise. That is, we have no idea what the value of f should> be. Mathematica's failing is in returning a value without pointing out > that> it has no precision. Bobby -----Original Message-----> Sent: Monday, September 30, 2002 11:59 AM Andrzej, Bobby, Peter It looks as if using SetAccuracy succeeds here because the inexact> numbers> that occur have finite binary representations. If we change them> slightly to> avoid this then we have to use Rationalize: 1) Using SetAccuracy Clear[a,b,f]> f=SetAccuracy[333.74*b^6+a^2*(11*a^2*b^2-b^6-121*b^4-2)+5.4*b ^8+a/> (2*b),> Infinity]; a=77617.1;> b=33096.1; a=SetAccuracy[a,Infinity];b=SetAccuracy[b,Infinity ]; f> - 15640321149084868351974949239896188679725401538739519428131155 14949> 3891236234 52500771916869370459119776018798804630436149786919912931962574 3010292 > 36> 3> 1246> 75 /> 10867106143970760551000357827554793888198143135975649579607989 8677435 > 72> 8240> 16> 0653953612982932181371232436367739737604096 2) Rewriting as fractions a=776171/10;> b=330961/10; f=33374/100*b^6+a^2*(11*a^2*b^2-b^6-121*b^4-2)+54/10*b^8+a/(2 *b) -(5954133808997234115690303589909929091649391296257/> 41370125000000) 3) Using Rationalize Clear[a,b,f]> f=Rationalize[333.74*b^6+a^2*(11*a^2*b^2-b^6-121*b^4-2)+5.4*b ^8+a/> (2*b),> 0]; a=77617.1;> b=33096.1; a=Rationalize[a,0];b=Rationalize[b,0]; f -(5954133808997234115690303589909929091649391296257/> 41370125000000)> I use Rationalize[. , 0] besause of results like Rationalize[3.1415959] 3.1416 Rationalize[3.1415959,0] 31415959/10000000> --> ---------------------> Hayes> Mathematica Training and Consulting> Leicester UK> www.haystack.demon.co.uk> hay@haystack.demon.co.uk> Voice: +44 (0)116 271 4198> Well, first of of all, your using SetAccuracy and SetPrecision does> nothing at all here, since they do not change the value of a or b. > You> should use a = SetAccuracy[a, Infinity] etc. But even then you won't> get the same answer as when you use exact numbers because of the > way> you evaluate f. Here is the order of evaluation that will give you > the> same answer, and should explain what is going on: 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), Infinity]; a = 77617.;> b = 33096.; a = SetAccuracy[a, Infinity]; b = SetAccuracy[b, Infinity]; f 54767> -(-----)> 66192 Andrzej Kozlowski> Toyama International University> JAPAN> Could someone explain what is going on here, please? In[1]:=> a = 77617.; b = 33096.; In[2]:=> SetAccuracy[a, Infinity]; SetAccuracy[b, Infinity];> SetPrecision[a, Infinity]; SetPrecision[b, Infinity]; In[4]:=> f := 333.75*b^6 + a^2*(11*a^2*b^2 - b^6 - 121*b^4 - 2) + 5.5*b^8 +> a/(2*b) In[5]:=> SetAccuracy[f, Infinity]; SetPrecision[f, Infinity]; In[6]:=> f Out[6]=> -1.1805916207174113*^21 In[7]:=> a = 77617; b = 33096; In[8]:=> g := (33375/100)*b^6 + a^2*(11*a^2*b^2 - b^6 - 121*b^4 - 2) +> (55/10)*b^8 + a/(2*b) In[9]:=> g Out[9]=> -(54767/66192) In[10]:=> N[%] Out[10]=> -0.8273960599468214> PKAndrzej KozlowskiYokohama, Japanhttp://www.mimuw.edu.pl/~akoz/http:// platon.c.u-tokyo.ac.jp/andrzej/ ==== =So? It's just as it should be, isn't it?AndrzejAndrzej KozlowskiToyama International UniversityJAPANhttp://sigma.tuins.ac.jp/~andrzej/> Go one step further: Clear[f, a, b, k]> k = $MachinePrecision;> 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), k];> a = 77617.; b = 33096.;> a = SetAccuracy[a, k];> b = SetAccuracy[b, k];> f> Accuracy[f]> Precision[f] -5.517164009`0*^19 Accuracy::mnprec:Value -23 would be inconsistent with $MinPrecision;> bounding by $MinPrecision instead. -20 0 Accuracy::mnprec:Value !(-23) would be inconsistent with> $MinPrecision; > bounding by $MinPrecision instead. See that? NO precision. Bobby -----Original Message-----> Sent: Tuesday, October 01, 2002 5:53 PM> Cc: drbob@bigfoot.com You are of course right, I forgot that Mathematica does not try to keep precision or accuracy of machine arithmetic computations. But I think> the actual precision you set need not be higher than machine precision, it just has to be set explicitely (is that right?). For example: In[1]:=> Clear[f,a,b,k] In[2]:=> k = $MachinePrecision; In[3]:=> 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),k]; In[4]:=> a=77617.;b=33096.; In[5]:=> a=SetAccuracy[a,k]; In[6]:=> b=SetAccuracy[b,k];> In[7]:=> f Out[7]=> !((-5.51716400890319`-2.8311*^19)) In[8]:=> Accuracy[f] Accuracy::mnprec: Value -23 would be inconsistent with $MinPrecision; > bounding by $MinPrecision instead. Out[8]=> -20> Andrzej Andrzej Yes, like you I took the original question to be about how to get the result> of using the naive rational versions in place of the inexact numbers.> Bobby raises the question of how we might know accuracy of the result. You answer this with> a = 77617.; b = 33096.; In[2]:=> f := 333.75*b^6 + a^2*(11*a^2*b^2 - b^6 - 121*b^4 - 2) +> 5.5*b^8 + a/(2*b) In[3]:=> f Out[3]=> -1.1805916207174113*^21 In[4]:=> Accuracy[%] Out[4]=> -5 However this computation is done in machine arithmetic, which means> that> Mathematica keeps no check on the accuracy and precision of the> computation,> and Mathematica gives the default accuracy value without any real> signifcance: $MachinePrecision - Log[10,Abs[f]]//Round -5 To get meaningful accuracy and precision values we need to force the> computation to be in bignums (bigßoat, arbitrary precision)> arithmetic.> Mathematica then keeps track of the accuracy and precision that it can> guarantee. Clear[f,a,b,k]> k=50; 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),k];> a=77617.;b=33096.;> a=SetAccuracy[a,k];> b=SetAccuracy[b,k];> f -0.82739605995 Accuracy[f] 11 Precision[f] 11 Which tells us that the error in the computed value of f is not more than 10^-11> The above results are rounded. More accurately we get Accuracy[f, Round->False] 11.4956 Precision[f, Round->False] 11.4133 There are several related issues here:> - is the precision (accuracy) of rhe input known?> - how does Mathematica interpret what one gives it?> - how does Mathematica go about the calculation? --> ---------------------> Hayes> Mathematica Training and Consulting> Leicester UK> www.haystack.demon.co.uk> hay@haystack.demon.co.uk> Voice: +44 (0)116 271 4198> It seems clear to me that what and what you mean by succeeds> here refer to quite different things and your objection is therefore> beside the point. There are obviously two ways in which one can> interpret the original posting. The first interpretation, which > and myself adopted, was that the question concerned purely the> computational mechanism of Mathematica. Or, to put it in other words,> it was why are the results of these two computations not the same?.> In this sense success means no more than making Mathematica return> the same answer using the two different routes the original poster> used.> You on the other hand choose to assume that the posting shows that> its> author does not understand not just the mechanism of significance> arithmetic used by Mathematica but also computations with inexact> numbers in general. I do not think this is necessarily the correct> assumption. I also don't see that Mathematica is doing anything> wrong.> After all, one can always check the accuracy of your answer: In[1]:=> a = 77617.; b = 33096.; In[2]:=> f := 333.75*b^6 + a^2*(11*a^2*b^2 - b^6 - 121*b^4 - 2) +> 5.5*b^8 + a/(2*b) In[3]:=> f Out[3]=> -1.1805916207174113*^21 In[4]:=> Accuracy[%] Out[4]=> -5 which tells you that it can't be very reliable. What more do you> demand? Andrzej> Andrzej Kozlowski> Yokohama, Japan> http://www.mimuw.edu.pl/~akoz/> http://platon.c.u-tokyo.ac.jp/andrzej/> Actually, we don't know whether SetAccuracy succeeds, because we> don't> know how inexact those numbers really are. If they are known to> more> digits than shown in the original post, they should be entered with as> much precision as they deserve. If not, there's no trick or> algorithm> that will give the result precision, because the value of f really> is> in the noise. That is, we have no idea what the value of f should> be. Mathematica's failing is in returning a value without pointing out> that> it has no precision. Bobby -----Original Message-----> Sent: Monday, September 30, 2002 11:59 AM Andrzej, Bobby, Peter It looks as if using SetAccuracy succeeds here because the inexact> numbers> that occur have finite binary representations. If we change them> slightly to> avoid this then we have to use Rationalize: 1) Using SetAccuracy Clear[a,b,f]> f=SetAccuracy[333.74*b^6+a^2*(11*a^2*b^2-b^6-121*b^4-2)+5.4*b ^8+a/> (2*b),> Infinity]; a=77617.1;> b=33096.1; a=SetAccuracy[a,Infinity];b=SetAccuracy[b,Infinity ]; f> - 15640321149084868351974949239896188679725401538739519428131155 14949> 3891236234> 52500771916869370459119776018798804630436149786919912931962574 3010292> 36> 3> 1246> 75 / 10867106143970760551000357827554793888198143135975649579607989 8677435> 72> 8240> 16> 0653953612982932181371232436367739737604096 2) Rewriting as fractions a=776171/10;> b=330961/10; f=33374/100*b^6+a^2*(11*a^2*b^2-b^6-121*b^4-2)+54/10*b^8+a/(2 *b) -(5954133808997234115690303589909929091649391296257/> 41370125000000) 3) Using Rationalize Clear[a,b,f]> f=Rationalize[333.74*b^6+a^2*(11*a^2*b^2-b^6-121*b^4-2)+5.4*b ^8+a/> (2*b),> 0]; a=77617.1;> b=33096.1; a=Rationalize[a,0];b=Rationalize[b,0]; f -(5954133808997234115690303589909929091649391296257/> 41370125000000)> I use Rationalize[. , 0] besause of results like Rationalize[3.1415959] 3.1416 Rationalize[3.1415959,0] 31415959/10000000> --> ---------------------> Hayes> Mathematica Training and Consulting> Leicester UK> www.haystack.demon.co.uk> hay@haystack.demon.co.uk> Voice: +44 (0)116 271 4198> Well, first of of all, your using SetAccuracy and SetPrecision does> nothing at all here, since they do not change the value of a or b. You> should use a = SetAccuracy[a, Infinity] etc. But even then you> won't> get the same answer as when you use exact numbers because of the> way> you evaluate f. Here is the order of evaluation that will give you the> same answer, and should explain what is going on: 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), Infinity]; a = 77617.;> b = 33096.; a = SetAccuracy[a, Infinity]; b = SetAccuracy[b, Infinity]; f 54767> -(-----)> 66192 Andrzej Kozlowski> Toyama International University> JAPAN> Could someone explain what is going on here, please? In[1]:=> a = 77617.; b = 33096.; In[2]:=> SetAccuracy[a, Infinity]; SetAccuracy[b, Infinity];> SetPrecision[a, Infinity]; SetPrecision[b, Infinity]; In[4]:=> f := 333.75*b^6 + a^2*(11*a^2*b^2 - b^6 - 121*b^4 - 2) + 5.5*b^8 +> a/(2*b) In[5]:=> SetAccuracy[f, Infinity]; SetPrecision[f, Infinity]; In[6]:=> f Out[6]=> -1.1805916207174113*^21 In[7]:=> a = 77617; b = 33096; In[8]:=> g := (33375/100)*b^6 + a^2*(11*a^2*b^2 - b^6 - 121*b^4 - 2) +> (55/10)*b^8 + a/(2*b) In[9]:=> g Out[9]=> -(54767/66192) In[10]:=> N[%] Out[10]=> -0.8273960599468214> PK> Andrzej Kozlowski> Yokohama, Japan> http://www.mimuw.edu.pl/~akoz/> http://platon.c.u-tokyo.ac.jp/andrzej/ ==== =I think I'd prefer that Mathematica gave me a clue -- without beingasked explicitly in JUST the right way that only you know and hadforgotten -- that there's a precision problem.Oddly enough, when you DO ask it nicely, you get error messages, but ifyou're not aware there's a problem, it lets you go on your merry way,working with noise.Bobby-----Original Message----- Clear[f, a, b, k]> k = $MachinePrecision;> 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), k];> a = 77617.; b = 33096.;> a = SetAccuracy[a, k];> b = SetAccuracy[b, k];> f> Accuracy[f]> Precision[f] -5.517164009`0*^19 Accuracy::mnprec:Value -23 would be inconsistent with $MinPrecision;> bounding by $MinPrecision instead. -20 0 Accuracy::mnprec:Value !(-23) would be inconsistent with> $MinPrecision; > bounding by $MinPrecision instead. See that? NO precision. Bobby -----Original Message-----> Sent: Tuesday, October 01, 2002 5:53 PM> Cc: drbob@bigfoot.com You are of course right, I forgot that Mathematica does not try tokeep precision or accuracy of machine arithmetic computations. But I think> the actual precision you set need not be higher than machineprecision, it just has to be set explicitely (is that right?). For example: In[1]:=> Clear[f,a,b,k] In[2]:=> k = $MachinePrecision; In[3]:=> 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),k]; In[4]:=> a=77617.;b=33096.; In[5]:=> a=SetAccuracy[a,k]; In[6]:=> b=SetAccuracy[b,k];> In[7]:=> f Out[7]=> !((-5.51716400890319`-2.8311*^19)) In[8]:=> Accuracy[f] Accuracy::mnprec: Value -23 would be inconsistent with $MinPrecision;> bounding by $MinPrecision instead. Out[8]=> -20> Andrzej Andrzej Yes, like you I took the original question to be about how to get the result> of using the naive rational versions in place of the inexact numbers.> Bobby raises the question of how we might know accuracy of theresult. You answer this with> a = 77617.; b = 33096.; In[2]:=> f := 333.75*b^6 + a^2*(11*a^2*b^2 - b^6 - 121*b^4 - 2) +> 5.5*b^8 + a/(2*b) In[3]:=> f Out[3]=> -1.1805916207174113*^21 In[4]:=> Accuracy[%] Out[4]=> -5 However this computation is done in machine arithmetic, which means> that> Mathematica keeps no check on the accuracy and precision of the> computation,> and Mathematica gives the default accuracy value without any real> signifcance: $MachinePrecision - Log[10,Abs[f]]//Round -5 To get meaningful accuracy and precision values we need to force the> computation to be in bignums (bigßoat, arbitrary precision)> arithmetic.> Mathematica then keeps track of the accuracy and precision that itcan> guarantee. Clear[f,a,b,k]> k=50; 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),k];> a=77617.;b=33096.;> a=SetAccuracy[a,k];> b=SetAccuracy[b,k];> f -0.82739605995 Accuracy[f] 11 Precision[f] 11 Which tells us that the error in the computed value of f is not more than 10^-11> The above results are rounded. More accurately we get Accuracy[f, Round->False] 11.4956 Precision[f, Round->False] 11.4133 There are several related issues here:> - is the precision (accuracy) of rhe input known?> - how does Mathematica interpret what one gives it?> - how does Mathematica go about the calculation? --> ---------------------> Hayes> Mathematica Training and Consulting> Leicester UK> www.haystack.demon.co.uk> hay@haystack.demon.co.uk> Voice: +44 (0)116 271 4198> It seems clear to me that what and what you mean by succeeds> here refer to quite different things and your objection is therefore> beside the point. There are obviously two ways in which one can> interpret the original posting. The first interpretation, which> and myself adopted, was that the question concerned purely the> computational mechanism of Mathematica. Or, to put it in otherwords,> it was why are the results of these two computations not thesame?.> In this sense success means no more than making Mathematica return> the same answer using the two different routes the original poster> used.> You on the other hand choose to assume that the posting shows that> its> author does not understand not just the mechanism of significance> arithmetic used by Mathematica but also computations with inexact> numbers in general. I do not think this is necessarily the correct> assumption. I also don't see that Mathematica is doing anything> wrong.> After all, one can always check the accuracy of your answer: In[1]:=> a = 77617.; b = 33096.; In[2]:=> f := 333.75*b^6 + a^2*(11*a^2*b^2 - b^6 - 121*b^4 - 2) +> 5.5*b^8 + a/(2*b) In[3]:=> f Out[3]=> -1.1805916207174113*^21 In[4]:=> Accuracy[%] Out[4]=> -5 which tells you that it can't be very reliable. What more do you> demand? Andrzej> Andrzej Kozlowski> Yokohama, Japan> http://www.mimuw.edu.pl/~akoz/> http://platon.c.u-tokyo.ac.jp/andrzej/> Actually, we don't know whether SetAccuracy succeeds, because we> don't> know how inexact those numbers really are. If they are known to> more> digits than shown in the original post, they should be entered with as> much precision as they deserve. If not, there's no trick or> algorithm> that will give the result precision, because the value of f really> is> in the noise. That is, we have no idea what the value of fshould> be. Mathematica's failing is in returning a value without pointing out> that> it has no precision. Bobby -----Original Message-----> Sent: Monday, September 30, 2002 11:59 AM Andrzej, Bobby, Peter It looks as if using SetAccuracy succeeds here because the inexact> numbers> that occur have finite binary representations. If we change them> slightly to> avoid this then we have to use Rationalize: 1) Using SetAccuracy Clear[a,b,f]> f=SetAccuracy[333.74*b^6+a^2*(11*a^2*b^2-b^6-121*b^4-2)+5.4*b ^8+a/> (2*b),> Infinity]; a=77617.1;> b=33096.1; a=SetAccuracy[a,Infinity];b=SetAccuracy[b,Infinity ]; f>- 15640321149084868351974949239896188679725401538739519428131155 14949> 3891236234> 52500771916869370459119776018798804630436149786919912931962574 3010292> 36> 3> 1246> 75 / 10867106143970760551000357827554793888198143135975649579607989 8677435> 72> 8240> 16> 0653953612982932181371232436367739737604096 2) Rewriting as fractions a=776171/10;> b=330961/10;f=33374/100*b^6+a^2*(11*a^2*b^2-b^6-121*b^4-2)+54 /10*b^8+a/(2*b) -(5954133808997234115690303589909929091649391296257/> 41370125000000) 3) Using Rationalize Clear[a,b,f]> f=Rationalize[333.74*b^6+a^2*(11*a^2*b^2-b^6-121*b^4-2)+5.4*b ^8+a/> (2*b),> 0]; a=77617.1;> b=33096.1; a=Rationalize[a,0];b=Rationalize[b,0]; f -(5954133808997234115690303589909929091649391296257/> 41370125000000)> I use Rationalize[. , 0] besause of results like Rationalize[3.1415959] 3.1416 Rationalize[3.1415959,0] 31415959/10000000> --> ---------------------> Hayes> Mathematica Training and Consulting> Leicester UK> www.haystack.demon.co.uk> hay@haystack.demon.co.uk> Voice: +44 (0)116 271 4198> Well, first of of all, your using SetAccuracy and SetPrecisiondoes> nothing at all here, since they do not change the value of a or b. You> should use a = SetAccuracy[a, Infinity] etc. But even then you> won't> get the same answer as when you use exact numbers because of the> way> you evaluate f. Here is the order of evaluation that will give you the> same answer, and should explain what is going on: 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), Infinity]; a = 77617.;> b = 33096.; a = SetAccuracy[a, Infinity]; b = SetAccuracy[b, Infinity]; f 54767> -(-----)> 66192 Andrzej Kozlowski> Toyama International University> JAPAN> Could someone explain what is going on here, please? In[1]:=> a = 77617.; b = 33096.; In[2]:=> SetAccuracy[a, Infinity]; SetAccuracy[b, Infinity];> SetPrecision[a, Infinity]; SetPrecision[b, Infinity]; In[4]:=> f := 333.75*b^6 + a^2*(11*a^2*b^2 - b^6 - 121*b^4 - 2) + 5.5*b^8+> a/(2*b) In[5]:=> SetAccuracy[f, Infinity]; SetPrecision[f, Infinity]; In[6]:=> f Out[6]=> -1.1805916207174113*^21 In[7]:=> a = 77617; b = 33096; In[8]:=> g := (33375/100)*b^6 + a^2*(11*a^2*b^2 - b^6 - 121*b^4 - 2) +> (55/10)*b^8 + a/(2*b) In[9]:=> g Out[9]=> -(54767/66192) In[10]:=> N[%] Out[10]=> -0.8273960599468214> PK> Andrzej Kozlowski> Yokohama, Japan> http://www.mimuw.edu.pl/~akoz/> http://platon.c.u-tokyo.ac.jp/andrzej/ ==== =I've been looking over the file and directory manipulation functions in Mathematica 4.1, and I'm not finding good examples of how to test for the existence of a file or directory before I attempt to create, access, or delete it. Are there any good examples of this somewhere?STH ==== =FileNames[] does what you want.Steve Luttrell> I've been looking over the file and directory manipulation functions inMathematica> 4.1, and I'm not finding good examples of how to test for the existence of> a file or directory before I attempt to create, access, or delete it. Are> there any good examples of this somewhere? STH>Reply-To: kuska@informatik.uni-leipzig.de ==== =FileNames[] returns an empty list if there are nofiles. SoFileNames[blub.txt]will return {} if the file does not exist. Jens I've been looking over the file and directory manipulation functions in Mathematica> 4.1, and I'm not finding good examples of how to test for the existence of> a file or directory before I attempt to create, access, or delete it. Are> there any good examples of this somewhere? STH ==== =If you don't wont error messages all you need to do is to set MinPrecision low enough:In[1]:=$MinPrecision = -3;In[2]:=k = $MachinePrecision;In[3]:=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), k];In[4]:=a = 77617.; b = 33096.;In[5]:=a = SetAccuracy[a, k];In[6]:=b = SetAccuracy[b, k];In[7]:=fOut[7]=-5.517164009`-2.8311*^19In[8]:=Accuracy[f] Out[8]=-23In[9]:=Precision[f]Out[9]=-3In any case the answer you get is meaningless.> I think I'd prefer that Mathematica gave me a clue -- without being> asked explicitly in JUST the right way that only you know and had> forgotten -- that there's a precision problem. Oddly enough, when you DO ask it nicely, you get error messages, but if> you're not aware there's a problem, it lets you go on your merry way,> working with noise. Bobby -----Original Message-----> Sent: Tuesday, October 01, 2002 8:05 PM> Cc: Ô Hayes'; mathgroup@smc.vnet.net So? It's just as it should be, isn't it? Andrzej Andrzej Kozlowski> Toyama International University> JAPAN> http://sigma.tuins.ac.jp/~andrzej/> Go one step further: Clear[f, a, b, k]> k = $MachinePrecision;> 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), k];> a = 77617.; b = 33096.;> a = SetAccuracy[a, k];> b = SetAccuracy[b, k];> f> Accuracy[f]> Precision[f] -5.517164009`0*^19 Accuracy::mnprec:Value -23 would be inconsistent with $MinPrecision;> bounding by $MinPrecision instead. -20 0 Accuracy::mnprec:Value !(-23) would be inconsistent with> $MinPrecision; > bounding by $MinPrecision instead. See that? NO precision. Bobby -----Original Message-----> Sent: Tuesday, October 01, 2002 5:53 PM> Cc: drbob@bigfoot.com You are of course right, I forgot that Mathematica does not try to> keep precision or accuracy of machine arithmetic computations. But I think> the actual precision you set need not be higher than machine> precision, it just has to be set explicitely (is that right?). For example: In[1]:=> Clear[f,a,b,k] In[2]:=> k = $MachinePrecision; In[3]:=> 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),k]; In[4]:=> a=77617.;b=33096.; In[5]:=> a=SetAccuracy[a,k]; In[6]:=> b=SetAccuracy[b,k];> In[7]:=> f Out[7]=> !((-5.51716400890319`-2.8311*^19)) In[8]:=> Accuracy[f] Accuracy::mnprec: Value -23 would be inconsistent with $MinPrecision;> bounding by $MinPrecision instead. Out[8]=> -20> Andrzej Andrzej Yes, like you I took the original question to be about how to get the result> of using the naive rational versions in place of the inexact numbers.> Bobby raises the question of how we might know accuracy of the> result. You answer this with> a = 77617.; b = 33096.; In[2]:=> f := 333.75*b^6 + a^2*(11*a^2*b^2 - b^6 - 121*b^4 - 2) +> 5.5*b^8 + a/(2*b) In[3]:=> f Out[3]=> -1.1805916207174113*^21 In[4]:=> Accuracy[%] Out[4]=> -5 However this computation is done in machine arithmetic, which means> that> Mathematica keeps no check on the accuracy and precision of the> computation,> and Mathematica gives the default accuracy value without any real> signifcance: $MachinePrecision - Log[10,Abs[f]]//Round -5 To get meaningful accuracy and precision values we need to force the> computation to be in bignums (bigßoat, arbitrary precision)> arithmetic.> Mathematica then keeps track of the accuracy and precision that it> can> guarantee. Clear[f,a,b,k]> k=50; 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),k];> a=77617.;b=33096.;> a=SetAccuracy[a,k];> b=SetAccuracy[b,k];> f -0.82739605995 Accuracy[f] 11 Precision[f] 11 Which tells us that the error in the computed value of f is not more than 10^-11> The above results are rounded. More accurately we get Accuracy[f, Round->False] 11.4956 Precision[f, Round->False] 11.4133 There are several related issues here:> - is the precision (accuracy) of rhe input known?> - how does Mathematica interpret what one gives it?> - how does Mathematica go about the calculation? --> ---------------------> Hayes> Mathematica Training and Consulting> Leicester UK> www.haystack.demon.co.uk> hay@haystack.demon.co.uk> Voice: +44 (0)116 271 4198> It seems clear to me that what and what you mean by succeeds> here refer to quite different things and your objection is therefore> beside the point. There are obviously two ways in which one can> interpret the original posting. The first interpretation, which> and myself adopted, was that the question concerned purely the> computational mechanism of Mathematica. Or, to put it in other> words,> it was why are the results of these two computations not the> same?.> In this sense success means no more than making Mathematica return> the same answer using the two different routes the original poster> used.> You on the other hand choose to assume that the posting shows that> its> author does not understand not just the mechanism of significance> arithmetic used by Mathematica but also computations with inexact> numbers in general. I do not think this is necessarily the correct> assumption. I also don't see that Mathematica is doing anything> wrong.> After all, one can always check the accuracy of your answer: In[1]:=> a = 77617.; b = 33096.; In[2]:=> f := 333.75*b^6 + a^2*(11*a^2*b^2 - b^6 - 121*b^4 - 2) +> 5.5*b^8 + a/(2*b) In[3]:=> f Out[3]=> -1.1805916207174113*^21 In[4]:=> Accuracy[%] Out[4]=> -5 which tells you that it can't be very reliable. What more do you> demand? Andrzej> Andrzej Kozlowski> Yokohama, Japan> http://www.mimuw.edu.pl/~akoz/> http://platon.c.u-tokyo.ac.jp/andrzej/> Actually, we don't know whether SetAccuracy succeeds, because we> don't> know how inexact those numbers really are. If they are known to> more> digits than shown in the original post, they should be entered with as> much precision as they deserve. If not, there's no trick or> algorithm> that will give the result precision, because the value of f really> is> in the noise. That is, we have no idea what the value of f> should> be. Mathematica's failing is in returning a value without pointing out> that> it has no precision. Bobby -----Original Message-----> Sent: Monday, September 30, 2002 11:59 AM Andrzej, Bobby, Peter It looks as if using SetAccuracy succeeds here because the inexact> numbers> that occur have finite binary representations. If we change them> slightly to> avoid this then we have to use Rationalize: 1) Using SetAccuracy Clear[a,b,f]> f=SetAccuracy[333.74*b^6+a^2*(11*a^2*b^2-b^6-121*b^4-2)+5.4*b ^8+a/> (2*b),> Infinity]; a=77617.1;> b=33096.1; a=SetAccuracy[a,Infinity];b=SetAccuracy[b,Infinity ]; f - 15640321149084868351974949239896188679725401538739519428131155 14949> 3891236234> 52500771916869370459119776018798804630436149786919912931962574 3010292> 36> 3> 1246> 75 / 10867106143970760551000357827554793888198143135975649579607989 8677435> 72> 8240> 16> 0653953612982932181371232436367739737604096 2) Rewriting as fractions a=776171/10;> b=330961/10;> f=33374/100*b^6+a^2*(11*a^2*b^2-b^6-121*b^4-2)+54/10*b^8+a/(2 *b)>> -(5954133808997234115690303589909929091649391296257/> 41370125000000) 3) Using Rationalize Clear[a,b,f]> f=Rationalize[333.74*b^6+a^2*(11*a^2*b^2-b^6-121*b^4-2)+5.4*b ^8+a/> (2*b),> 0]; a=77617.1;> b=33096.1; a=Rationalize[a,0];b=Rationalize[b,0]; f -(5954133808997234115690303589909929091649391296257/> 41370125000000)> I use Rationalize[. , 0] besause of results like Rationalize[3.1415959] 3.1416 Rationalize[3.1415959,0] 31415959/10000000> --> ---------------------> Hayes> Mathematica Training and Consulting> Leicester UK> www.haystack.demon.co.uk> hay@haystack.demon.co.uk> Voice: +44 (0)116 271 4198> Well, first of of all, your using SetAccuracy and SetPrecision> does> nothing at all here, since they do not change the value of a or b. You> should use a = SetAccuracy[a, Infinity] etc. But even then you> won't> get the same answer as when you use exact numbers because of the> way> you evaluate f. Here is the order of evaluation that will give you the> same answer, and should explain what is going on: 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), Infinity]; a = 77617.;> b = 33096.; a = SetAccuracy[a, Infinity]; b = SetAccuracy[b, Infinity]; f 54767> -(-----)> 66192 Andrzej Kozlowski> Toyama International University> JAPAN> Could someone explain what is going on here, please? In[1]:=> a = 77617.; b = 33096.; In[2]:=> SetAccuracy[a, Infinity]; SetAccuracy[b, Infinity];> SetPrecision[a, Infinity]; SetPrecision[b, Infinity]; In[4]:=> f := 333.75*b^6 + a^2*(11*a^2*b^2 - b^6 - 121*b^4 - 2) + 5.5*b^8> +> a/(2*b) In[5]:=> SetAccuracy[f, Infinity]; SetPrecision[f, Infinity]; In[6]:=> f Out[6]=> -1.1805916207174113*^21 In[7]:=> a = 77617; b = 33096; In[8]:=> g := (33375/100)*b^6 + a^2*(11*a^2*b^2 - b^6 - 121*b^4 - 2) +> (55/10)*b^8 + a/(2*b) In[9]:=> g Out[9]=> -(54767/66192) In[10]:=> N[%] Out[10]=> -0.8273960599468214> PK> Andrzej Kozlowski> Yokohama, Japan> http://www.mimuw.edu.pl/~akoz/> http://platon.c.u-tokyo.ac.jp/andrzej/>Andrzej KozlowskiYokohama, Japanhttp://www.mimuw.edu.pl/~akoz/http:// platon.c.u-tokyo.ac.jp/andrzej/ ==== =>>In any case the answer you get is meaningless.Precisely.Bobby-----Original Message----- 121*b^4 - 2) + 5.5*b^8 + a/(2*b), k];In[4]:=a = 77617.; b = 33096.;In[5]:=a = SetAccuracy[a, k];In[6]:=b = SetAccuracy[b, k];In[7]:=fOut[7]=-5.517164009`-2.8311*^19In[8]:=Accuracy[f] Out[8]=-23In[9]:=Precision[f]Out[9]=-3In any case the answer you get is meaningless.> I think I'd prefer that Mathematica gave me a clue -- without being> asked explicitly in JUST the right way that only you know and had> forgotten -- that there's a precision problem. Oddly enough, when you DO ask it nicely, you get error messages, butif> you're not aware there's a problem, it lets you go on your merry way,> working with noise. Bobby -----Original Message-----> Sent: Tuesday, October 01, 2002 8:05 PM> Cc: Ô Hayes'; mathgroup@smc.vnet.net So? It's just as it should be, isn't it? Andrzej Andrzej Kozlowski> Toyama International University> JAPAN> http://sigma.tuins.ac.jp/~andrzej/> Go one step further: Clear[f, a, b, k]> k = $MachinePrecision;> 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), k];> a = 77617.; b = 33096.;> a = SetAccuracy[a, k];> b = SetAccuracy[b, k];> f> Accuracy[f]> Precision[f] -5.517164009`0*^19 Accuracy::mnprec:Value -23 would be inconsistent with $MinPrecision;> bounding by $MinPrecision instead. -20 0 Accuracy::mnprec:Value !(-23) would be inconsistent with> $MinPrecision; > bounding by $MinPrecision instead. See that? NO precision. Bobby -----Original Message-----> Sent: Tuesday, October 01, 2002 5:53 PM> Cc: drbob@bigfoot.com You are of course right, I forgot that Mathematica does not try to> keep precision or accuracy of machine arithmetic computations. But I think> the actual precision you set need not be higher than machine> precision, it just has to be set explicitely (is that right?). For example: In[1]:=> Clear[f,a,b,k] In[2]:=> k = $MachinePrecision; In[3]:=> 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),k]; In[4]:=> a=77617.;b=33096.; In[5]:=> a=SetAccuracy[a,k]; In[6]:=> b=SetAccuracy[b,k];> In[7]:=> f Out[7]=> !((-5.51716400890319`-2.8311*^19)) In[8]:=> Accuracy[f] Accuracy::mnprec: Value -23 would be inconsistent with $MinPrecision;> bounding by $MinPrecision instead. Out[8]=> -20> Andrzej Andrzej Yes, like you I took the original question to be about how to getthe result> of using the naive rational versions in place of the inexactnumbers.> Bobby raises the question of how we might know accuracy of the> result. You answer this with> a = 77617.; b = 33096.; In[2]:=> f := 333.75*b^6 + a^2*(11*a^2*b^2 - b^6 - 121*b^4 - 2) +> 5.5*b^8 + a/(2*b) In[3]:=> f Out[3]=> -1.1805916207174113*^21 In[4]:=> Accuracy[%] Out[4]=> -5>> However this computation is done in machine arithmetic, which means> that> Mathematica keeps no check on the accuracy and precision of the> computation,> and Mathematica gives the default accuracy value without any real> signifcance: $MachinePrecision - Log[10,Abs[f]]//Round -5 To get meaningful accuracy and precision values we need to force the> computation to be in bignums (bigßoat, arbitrary precision)> arithmetic.> Mathematica then keeps track of the accuracy and precision that it> can> guarantee. Clear[f,a,b,k]> k=50; 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),k];> a=77617.;b=33096.;> a=SetAccuracy[a,k];> b=SetAccuracy[b,k];> f -0.82739605995 Accuracy[f] 11 Precision[f] 11 Which tells us that the error in the computed value of f is notmore than 10^-11> The above results are rounded. More accurately we get Accuracy[f, Round->False] 11.4956 Precision[f, Round->False] 11.4133 There are several related issues here:> - is the precision (accuracy) of rhe input known?> - how does Mathematica interpret what one gives it?> - how does Mathematica go about the calculation? --> ---------------------> Hayes> Mathematica Training and Consulting> Leicester UK> www.haystack.demon.co.uk> hay@haystack.demon.co.uk> Voice: +44 (0)116 271 4198message> It seems clear to me that what and what you mean bysucceeds> here refer to quite different things and your objection istherefore> beside the point. There are obviously two ways in which one can> interpret the original posting. The first interpretation, which> and myself adopted, was that the question concerned purely the> computational mechanism of Mathematica. Or, to put it in other> words,> it was why are the results of these two computations not the> same?.> In this sense success means no more than making Mathematicareturn> the same answer using the two different routes the original poster> used.> You on the other hand choose to assume that the posting shows that> its> author does not understand not just the mechanism of significance> arithmetic used by Mathematica but also computations with inexact> numbers in general. I do not think this is necessarily the correct> assumption. I also don't see that Mathematica is doing anything> wrong.> After all, one can always check the accuracy of your answer: In[1]:=> a = 77617.; b = 33096.; In[2]:=> f := 333.75*b^6 + a^2*(11*a^2*b^2 - b^6 - 121*b^4 - 2) +> 5.5*b^8 + a/(2*b) In[3]:=> f Out[3]=> -1.1805916207174113*^21 In[4]:=> Accuracy[%] Out[4]=> -5 which tells you that it can't be very reliable. What more do you> demand? Andrzej> Andrzej Kozlowski> Yokohama, Japan> http://www.mimuw.edu.pl/~akoz/> http://platon.c.u-tokyo.ac.jp/andrzej/> Actually, we don't know whether SetAccuracy succeeds, because we> don't> know how inexact those numbers really are. If they are known to> more> digits than shown in the original post, they should be enteredwith as> much precision as they deserve. If not, there's no trick or> algorithm> that will give the result precision, because the value of f really> is> in the noise. That is, we have no idea what the value of f> should> be. Mathematica's failing is in returning a value without pointing out> that> it has no precision. Bobby -----Original Message-----> Sent: Monday, September 30, 2002 11:59 AM Andrzej, Bobby, Peter It looks as if using SetAccuracy succeeds here because the inexact> numbers> that occur have finite binary representations. If we change them> slightly to> avoid this then we have to use Rationalize: 1) Using SetAccuracy>> Clear[a,b,f]> f=SetAccuracy[333.74*b^6+a^2*(11*a^2*b^2-b^6-121*b^4-2)+5.4*b ^8+a/> (2*b),> Infinity]; a=77617.1;> b=33096.1; a=SetAccuracy[a,Infinity];b=SetAccuracy[b,Infinity ]; f - 15640321149084868351974949239896188679725401538739519428131155 14949> 3891236234> 52500771916869370459119776018798804630436149786919912931962574 3010292> 36> 3> 1246> 75 / 10867106143970760551000357827554793888198143135975649579607989 8677435> 72> 8240> 16> 0653953612982932181371232436367739737604096 2) Rewriting as fractions a=776171/10;> b=330961/10;> f=33374/100*b^6+a^2*(11*a^2*b^2-b^6-121*b^4-2)+54/10*b^8+a/(2 *b) -(5954133808997234115690303589909929091649391296257/> 41370125000000) 3) Using Rationalize Clear[a,b,f]> f=Rationalize[333.74*b^6+a^2*(11*a^2*b^2-b^6-121*b^4-2)+5.4*b ^8+a/> (2*b),> 0]; a=77617.1;> b=33096.1; a=Rationalize[a,0];b=Rationalize[b,0]; f -(5954133808997234115690303589909929091649391296257/> 41370125000000)> I use Rationalize[. , 0] besause of results like Rationalize[3.1415959] 3.1416 Rationalize[3.1415959,0] 31415959/10000000> --> ---------------------> Hayes> Mathematica Training and Consulting> Leicester UK> www.haystack.demon.co.uk> hay@haystack.demon.co.uk> Voice: +44 (0)116 271 4198> Well, first of of all, your using SetAccuracy and SetPrecision> does> nothing at all here, since they do not change the value of a orb. You> should use a = SetAccuracy[a, Infinity] etc. But even then you> won't> get the same answer as when you use exact numbers because of the> way> you evaluate f. Here is the order of evaluation that will giveyou the> same answer, and should explain what is going on: 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), Infinity]; a = 77617.;> b = 33096.; a = SetAccuracy[a, Infinity]; b = SetAccuracy[b, Infinity]; f 54767> -(-----)> 66192 Andrzej Kozlowski> Toyama International University> JAPAN> Could someone explain what is going on here, please? In[1]:=> a = 77617.; b = 33096.; In[2]:=> SetAccuracy[a, Infinity]; SetAccuracy[b, Infinity];> SetPrecision[a, Infinity]; SetPrecision[b, Infinity]; In[4]:=> f := 333.75*b^6 + a^2*(11*a^2*b^2 - b^6 - 121*b^4 - 2) + 5.5*b^8> +> a/(2*b) In[5]:=> SetAccuracy[f, Infinity]; SetPrecision[f, Infinity]; In[6]:=> f Out[6]=> -1.1805916207174113*^21 In[7]:=> a = 77617; b = 33096; In[8]:=> g := (33375/100)*b^6 + a^2*(11*a^2*b^2 - b^6 - 121*b^4 - 2) +> (55/10)*b^8 + a/(2*b) In[9]:=> g Out[9]=> -(54767/66192) In[10]:=> N[%] Out[10]=> -0.8273960599468214> PK> Andrzej Kozlowski> Yokohama, Japan> http://www.mimuw.edu.pl/~akoz/> http://platon.c.u-tokyo.ac.jp/andrzej/>Andrzej KozlowskiYokohama, Japanhttp://www.mimuw.edu.pl/~akoz/http:// platon.c.u-tokyo.ac.jp/andrzej/ ==== =>Many thanks to all who replied.>>The original problem was as follows:>>In a presentation I wish to use Plot to generate a sequence of frames and>then animate them. The problem is that the audience sees the animation>twice. Once when the frames are being generated and then again after I have>closed the group and double clicked on the top graphic. However, the first>showing during generation is enough (but uncontrolled).>>Is it possible to tidy up the generation of the graphic so that it becomes>the animation?>There were two main solutions which I now apply to my real problem and not>the simple, generic, problem in the original post.>The real problem was how to build up a probably density function (PDF) in>real time. In the examples below I redraw the PDF every time I add 10>points.>>Initialise< <<<< JLink`;>wb=WeibullDistribution[ 2.101349094155377,22.58126779173235`];>midpts=Table[i,{i, 0.5,50,1}];>>Solution from Omega Consulting>>GraphicCell[graphics_] :=> Cell[GraphicsData[PostScript, DisplayString[graphics]],Graphics]>>Block[{$DisplayFunction= Identity, graphs},> data={};> graphs => Table[data=Flatten[Join[data,RandomArray[wb,10]]];> freq=BinCounts[data,{0,50,1}];> GraphicCell[> BarChart[Transpose[{freq,midpts}],ImageSize ->500] ], {500}];> NotebookWrite[EvaluationNotebook[],Cell[CellGroupData[graphs, Closed]]];> SelectionMove[EvaluationNotebook[], All, GeneratedCell];> FrontEndExecute[{FrontEndToken[EvaluationNotebook[],> SelectionAnimate]}]> ]>>This solution works but it generates 500 frames and sometimes exceeds the>memory.>The paradigm here is generate all frames, then animate all frames. We>really need a loop that does: generate next frame, delete last frame, show next frame>>Is it possible to do this?Yes, however, I thought you didn't want to see the selection bar moving around during the animation. That's why I chose to generate the whole animation in one shot. Also, when you write the new cell over the old cell there is a ßash between frames as the old frame is deleted. Here's an example of a frame-by-frame method.GraphicCell[graphics_] := Cell[GraphicsData[PostScript, DisplayString[graphics]],Graphics]CellPrint[Cell[,Graphics]]; Block[{$DisplayFunction=Identity}, Do[ SelectionMove[EvaluationNotebook[], All, GeneratedCell]; NotebookWrite[EvaluationNotebook[], GraphicCell[Plot[x y,{x,0,1}, PlotRange->{0,50}]]], {y,50} ] ]Also, if you add ShowCellBracket->False to GraphicCell and a Pause to the loop, then things get much better visually.---------------------------------------------------- ----------Omega ConsultingThe final answer to your Mathematica needsSpend less time searching and more time finding.http://www.wz.com/internet/Mathematica.html ==== =I am trying to use FindRoot in mathematica 4.0 to find the zeros of a complex-valued function of one complex variable. In particular, I am looking for the one root with a positive imaginary part. I have a rough approximation for where the root should be, and this is good enough to give a reasonable guess.However, there are always two other roots near the one I want - one with 0 imaginary part and another with negative imag part. (For those who are interested, the zeros are the roots of the dispersion relation for a plasma interacting with a laser). Sometimes FindRoot picks up one of these instead of the one I want.So, I'd like to tell mathematica to look for a root only in a certain rectangular 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 an interval, hoping mathematica would interpret these as the corners of a rectangle. No such luck.Any help would be greatly appreciated.I'd also like to point out that this and other issues about complex roots are not clearly addressed in the built-in help files. ==== =Just a shot: Try using the DampingFactor option to force FindRoot to take smaller steps.---Selwyn Hollis ==== = > I am trying to use FindRoot in mathematica 4.0 to find the zeros of a> complex-valued function of one complex variable. In particular, I am> looking for the one root with a positive imaginary part. I have a rough> approximation for where the root should be, and this is good enough to> give a reasonable guess. However, there are always two other roots near the one I want - one with> 0 imaginary part and another with negative imag part. (For those who> are interested, the zeros are the roots of the dispersion relation for a> plasma interacting with a laser). Sometimes FindRoot picks up one of> these instead of the one I want. So, I'd like to tell mathematica to look for a root only in a certain> rectangular 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 an> interval, hoping mathematica would interpret these as the corners of a> rectangle. No such luck. Any help would be greatly appreciated. I'd also like to point out that this and other issues about complex> roots are not clearly addressed in the built-in help files.> I believe it is difficult to restrict FindRoot. Below are severalsuggestions. (1) You might tryrigging the function, say withg[x_?NumberQ] := f[x] + If[Im[x]<=0,1000,0](2) If you have version 4.2 a related approach would be to takeadvantage of constrained optimization and doNMinimize[{Re[f[x,y]]^2 + Im[f[x,y]]^2, rectangle range constraints},{x,y}]or something along those lines.(3) If proximity of the other roots is the main problem it might bealleviated by rescaling your variable.(4) Alternatively you could write your function as a pair of real valuedfunctions of two real valued arguments. Then you can use Interval tosplit the rectangle into parts, keeping subrectangles for which {0,0}lives in f[Interval[x],Interval[y]] where Interval[x], for example, is ashorthand for an interval for the x part of the rectangle being split.Daniel LichtblauWolfram ResearchReply-To: kuska@informatik.uni-leipzig.de ==== =and solving the real and imaginary part for for z->x+I*y withFindRoot[Evaluate[({Re[#] == 0, Im[#] == 0} &[ z^3 - 1]) /. z -> x + I y], {x, -3/2, 0}, {y, 0.5, 0.9}]helps not ? Jens > I am trying to use FindRoot in mathematica 4.0 to find the zeros of a> complex-valued function of one complex variable. In particular, I am> looking for the one root with a positive imaginary part. I have a rough> approximation for where the root should be, and this is good enough to> give a reasonable guess. However, there are always two other roots near the one I want - one with> 0 imaginary part and another with negative imag part. (For those who> are interested, the zeros are the roots of the dispersion relation for a> plasma interacting with a laser). Sometimes FindRoot picks up one of> these instead of the one I want. So, I'd like to tell mathematica to look for a root only in a certain> rectangular 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 an> interval, hoping mathematica would interpret these as the corners of a> rectangle. No such luck. Any help would be greatly appreciated. I'd also like to point out that this and other issues about complex> roots are not clearly addressed in the built-in help files.> ==== =The last part of my message you are quoting was completely wrong, as was pointed out by 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. What you are doing is this:In[1]:=a = SetAccuracy[77617., Infinity];b = SetAccuracy[33096., Infinity];At this point you have converted a and be to have the following exact values:In[3]:=aOut[3]=77617In[4]:=bOut[4]=33096Next you evaluate: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), Infinity]but this is a two step process (which is what you seem not to have grasped). First Mathematica computes:In[5]:=333.75*b^6 + a^2*(11*a^2*b^2 - b^6 - 121*b^4 - 2) + 5.5*b^8 + a/(2*b)Out[5]=1.1805916207174113*^21Now, because there were machine ßoats in the formula (333.75 and 5.5 ) the whole expression was computed using machine arithmetic without keeping track of precision. The answer is therefore completely inacurate. Mathematica returns the purely formal accuracy:In[6]:=Accuracy[%]Out[6]=-5But the second part of your evaluation tells it to take this inaccurate answer and convert it to an exact number.In[7]:=SetAccuracy[%%, Infinity]Out[7]=1180591620717411303424In[8]:=Accuracy[%]Out[8] =InfinityBut of course doing this is meaningless, after converting an inexact answer to an exact number does not make it a an exact answer!Of course had you evaluated f before you assigned the values to a and b you would not have encountered the problem because no machine reals would have appeared in the computation. ALternatively you might have used:f = SetAccuracy[333.75, Infinity]*b^6 + a^2*(11*a^2*b^2 - b^6 - 121*b^4 - 2) + SetAccuracy[5.5, Infinity]*b^8 + a/(2*b)Andrzej KozlowskiYokohama, Japanhttp://www.mimuw.edu.pl/~akoz/http:// platon.c.u-tokyo.ac.jp/andrzej/> It seems clear to me that what and what you mean by succeeds> here refer to quite different things and your objection is therefore> beside the point. There are obviously two ways in which one can> interpret the original posting. The first interpretation, which > and myself adopted, was that the question concerned purely the> computational mechanism of Mathematica. Or, to put it in other words,> it was why are the results of these two computations not the same?.> In this sense success means no more than making Mathematica return> the same answer using the two different routes the original poster > used.> You on the other hand choose to assume that the posting shows that its> author does not understand not just the mechanism of significance> arithmetic used by Mathematica but also computations with inexact> numbers in general. I do not think this is necessarily the correct> assumption. I also don't see that Mathematica is doing anything wrong.> After all, one can always check the accuracy of your answer: In[1]:=> a = 77617.; b = 33096.; In[2]:=> f := 333.75*b^6 + a^2*(11*a^2*b^2 - b^6 - 121*b^4 - 2) +> 5.5*b^8 + a/(2*b) In[3]:=> f Out[3]=> -1.1805916207174113*^21 In[4]:=> Accuracy[%] Out[4]=> -5 which tells you that it can't be very reliable. What more do you > demand?> As you are dealing here only with machine-precision numbers, your 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-ç.8dprecision result, whether or not all the> digits in the result can, in fact, be determined to be correct on the> basis of your input. In practice, to rely on a numerical result, you ALWAYS have to check> its accuracy. How reliable is Accuracy anyway? In[1]:=> a = SetAccuracy[77617., Infinity];> b = SetAccuracy[33096., Infinity]; In[3]:=> 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), Infinity] Out[3]=> 1180591620717411303424 In[4]:=> Accuracy[f] Out[4]=> Infinity We got completely wrong result with Infinite accuracy. In conclusion,> one can not rely on Accuracy. Checking numerical results in> Mathematica sounds like a tough task.:-) --PK Andrzej> Andrzej Kozlowski> Yokohama, Japan> http://www.mimuw.edu.pl/~akoz/> http://platon.c.u-tokyo.ac.jp/andrzej/ [...]> ==== =leap to MathGroup so I'll respond there as well to some of the issuesraised herein. Daniel,>The precision/accuracy tracking mechanism will generally let you know,>>in some fashion, that you have no trustworthy digits. But it is up to>>the user to check that sort of thing. In this case Mathematica did NOT let us know, in any fashion, that we> had no trustworthy digits. Precision and Accuracy outputs were> completely misleading. (16 and -5 respectively.) Precision, in this case, is itself a bit misleading. As I recall machinearithmetic was in use. For that domain just regard 16 as the definitionof precision. Moreover no tracking is done. It is only when bignums areused that significance arithmetic will be at play.By the way, the distinction between precision for machine numbers vs.bignums will be more clear with our next big release. At present onedoes not know if 16 refers to a machine number or a bignum of that sameprecision.> Even Andrzej> Kozlowski, who's adept in Mathematica, thought that would be meaningful,> and never came up with a better way to check (other than using infinite> precision for numbers that probably aren't known that exactly). Peter> Kosta demonstrated that he could get a completely erroneous answer with> Infinite precision. I blame the problem primarily, and I don't think there's any way to make> the answer meaningful. That's not Mathematica's fault at all, and users> need to be aware of that old maxim: garbage in, garbage out.Right. One cannot artificially raise precision or accuracy after thefact and expect a meaningful result. Again, had significance arithmeticbeen used, I think there would have been adequate information to assessthe problem.> comes up with a 22-digit result, it doesn't take much sophistication to> realize the answer can't have 16-digit precision. Here's an even more extreme result: 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), 50];> a = 77617.; b = 33096.;> f> Precision[f] -1.180591620717411303424`71.0721*^21> 71 71.0721 digits of precision? I don't think so!! It's correct, albeit the number is garbage. You start with a number thatis, in your words, all noise. (I assume you had set a and b before f,because otherwise I get a different result for Precision[f]). Nowf ~ 10^21, and so has accuracy of around 71 digits. Garbagenotwithstanding, this behavior is entirely correct and as it should be.> We can do the following instead: x = Interval[333.75];> y = Interval[5.5];> a = Interval[77617.];> b = Interval[33096.];> x*b^6 + a^2*(11*a^2*b^2 - b^6 - 121*b^4 - 2) + y*b^8 + a/(2*b) Interval[{-4.486248158726164*^22, 4.2501298345826815*^22}] and that looks like the right answer, finally!! I like that method.Yes, it's a useful way to show that the result has no digits to trust.Actually you can achieve a similar effect using significance arithmetic,as below.x = SetPrecision[33375/100, 16];y = SetPrecision[11/2, 16];a = SetPrecision[77617, 16];b = SetPrecision[33096, 16];In[18]:= InputForm[x*b^6 + a^2*(11*a^2*b^2 - b^6 - 121*b^4 - 2) + y*b^8+ a/(2*b)]Out[18]//InputForm= -1.1339143158169`0*^14This tells you there are NO reliable digits. The advantage to this isthat is is more ßexible than interval arithmetic in Mathematica whichwill not, for example, deal well with complex-valued functions orcomplex domains. Also significance arithmetic (aka arbitrary precisionarithmetic) is much faster than interval arithmetic for large problems.> However, that doesn't change the fact that Accuracy, Precision, and> SetAccuracy appear to be completely useless.My own experience is that they are quite useful. But only if used withcare and in appropriate ways. Raising accuracy after the fact does notfall into that category.> I haven't seen an example> in which they did what anyone (but you) thought they should do. BobbyMaybe. But, curiously enough, I am a user rather than developer when itcomes to that stuff. I used the precision mechanism alot in polynomialNSolve, and it did indeed work to my liking. Which counts for somethingfrom the ordinary users' perspective, because now NSolve works betterthan it otherwise might.> -----Original Message----- > I think I'd prefer that Mathematica gave me a clue -- without being> asked explicitly in JUST the right way that only you know and had> forgotten -- that there's a precision problem.> > Oddly enough, when you DO ask it nicely, you get error messages, but> if> you're not aware there's a problem, it lets you go on your merry way,> working with noise.> > Bobby Mathematica is not a mind reader. But the evaluation sequence, while> complicated, is reasonably well documented. If you perform machine> arithmetic, or for that matter significance arithmetic, and there is> massive cancellation error, no use of SetAccuracy after the fact will> fix it. The precision/accuracy tracking mechanism will generally let you know,> in some fashion, that you have no trustworthy digits. But it is up to> the user to check that sort of thing. It is not obvious to me what sort> of error the software might notice to report. If you have a concise> example of input, and expected output, I can look further. I've not seen> anything in this thread that struck me as a failure of the software to> warn the user, but maybe I missed something. DanielDaniel LichtblauWolfram Research ==== =This just means that Mathematica can't do it. This looks difficult, nonlinear andall that.Kevin> Folks,> What does it mean when I submit a differential equation, and the same> equation appears as the output?> I have tried this equation:> DSolve[y'[x] == (-x^2 + 2 y[x]^(-3))/(2 x y[x] - 3 x^2), y[x], x]> Is it too complicated for the program?> Diana Try using NDSolve and put in some BCs, it may not be solvable> analytically, but should be solvable numerically.> ==== =Helo,I watched Steve Jobs' keynote from maxworld expo 02', where Theo Graypresent Mathematica, and makes a joke - a funny integral of some sort - thatI din't get it, because the video resolution was too poor.I found the link on this page http://theodoregray.com/Can somebody, who knows the idea, explain it quickly ... ?Borut ==== =Stan,I think it is a shame that any engineering college would frown upon usingMathematica. If used correctly, it can only speed learning and give you alot more practice. It is also a shame that students can't come to collegealready knowing the basics of Mathematica so they could concentrate on thematerial to be learned. The argument that the student is supposed to belearning methods and not use Mathematica's advanced automatic routines: onecan always skip the advanced routines and program Mathematica to do thesteps of the method to be learned.Anyway, on to your question. You could do something like this...xsol = Solve[2x - 1 == 0, x][[1, 1]]answer = x /. xsol // Nwhich returnsx -> 1/20.5answer0.5Look up ReplaceAll and Rule in Help. What I like to do is save xsol as arule and not store the x value in some variable answer, or in x itself. Iwould also tend to stay with exact solutions as long as possible. Then youcan use xsol and N something like this...x^2 + Sin[x]% /. xsol% // Nwhich givesx^2 + Sin[x]1/4 + Sin[1/2]0.729426Remember that % means the previous output (in time) and when you use it forstatements within one cell it is completely unambiguous. /. is the shortcutnotation for ReplaceAll. So % /. xsol means to take the previous output, andreplace all occurrences of x using the rule xsol (which is x -> 1/2).David Parkdjmp@earthlink.nethttp://home.earthlink.net/~djmp/How would I then use the result of Solve (0.5) and assign it to anew variable, like answer for further calculations?I think it has something to do with /. and -> rules of some sort, butI can't get this simple concept to work!-Stan ==== =OK, here is what it does for me....I am using Mathematica 4.2.1 with Macintosh OS X 10.1.5....If i use the shoft key, and I select a cell, then select another cellwhile skipping some cells, it still selects all the cells between the 2that i have selected....I then copy those and I paste them into a newnotebook. Even though it selected some cells that i did not wantselected, it does still paste the individual cells into the newnotebook.However, if I use the command key instead of the shirt key, I canselect individual cells to copy with out it selecting the cellsinbetween, meaning i can only selct the particular cells i want toselect, and they still paste as individual cells.not sure if your using the command key will enable you to paste intoseperate cells but its worth a shot. try the Command key instead of theshirt key...> I am having an extremely frustrating time with one feature of > Mathematica 4.2 which I swear was not present in earlier versions. It > find is quite dreadful and yet none seems to have complained about it > so far so that I feel that perhaps I missing something obvious. > Anyway, this is the problem. I have two notebooks with a large number > of cells each. I want to copy some cells from one notebook to the > other. I am sure in earlier versions it used to be possible to select > several contiguous cells by shift clicking and then paste them into > another notebook. You would then get several cells of the same type as > you copied. However now (at least on Mac OS X) this seems impossible. > What happens is that if you select a several cells or a cell group and > past into another notebook you get a messy expression contained in a > single cell from which it does not appear possible to easily recover > the original cells. I have tired using various Copy As but have not > found anything that works. The only thing that works is copying and > pasting individual cells, which is of course very time consuming.> Is this also what happens on other platforms? I am sure it was not the > case in earlier versions, and if so was this an intentional change? It > so it seems to me as bad an idea as I have come across in many years. > Can anyone explain?Andrzej Kozlowski> ==== =I can report I do have this problem with Mathematica 4.2 in Mac OS X 10.2.2.I can select contiguous cells using shift and not contiguous cells (using command) but copying them results in one huge cell as you reported.I think is time for a Tech Support reportCiao,aov> As a follow up on this issue:> I reinstalled Mathematica 4.1 for Mac OS X and found that I still have> this problem. On the other hand Hayes informed me that he did not> have it on Mathematica 4.2 under Windows 98. I then tried it myself,> with Mathematica 4.1 under Windows 98, and indeed I found I can copy> and paste groups of cells and the cell structure is preserved. They do> not get merged into a single cell with all the Mathematica markup> visible as they do in my case under Mac OS X 10.2. I would like to know> if other Mac OS X users have the same problem. If not, it may be caused> by something weird in my installation, although it seems unlikely as I> am not experiencing any other problems. I have not yet tried reporting> this to Technical Support yet since I am not sure if other Mac OS X> users are also experiencing the same behaviour, but if it is a bug it's> an awful one.> Andrzej> I am having an extremely frustrating time with one feature of> Mathematica 4.2 which I swear was not present in earlier versions. It> find is quite dreadful and yet none seems to have complained about it> so far so that I feel that perhaps I missing something obvious.> Anyway, this is the problem. I have two notebooks with a large number> of cells each. I want to copy some cells from one notebook to the> other. I am sure in earlier versions it used to be possible to select> several contiguous cells by shift clicking and then paste them into> another notebook. You would then get several cells of the same type as> you copied. However now (at least on Mac OS X) this seems impossible.> What happens is that if you select a several cells or a cell group and> past into another notebook you get a messy expression contained in a> single cell from which it does not appear possible to easily recover> the original cells. I have tired using various Copy As but have not> found anything that works. The only thing that works is copying and> pasting individual cells, which is of course very time consuming.> Is this also what happens on other platforms? I am sure it was not the> case in earlier versions, and if so was this an intentional change? It> so it seems to me as bad an idea as I have come across in many years.> Can anyone explain? Andrzej Kozlowski>----Unix is user friendly - it's just picky about it's friends.----Alfredo Octavio,Patilla.comhttp://alfredo.octavio.net At: N 10¢È23.811', W 066¢È58.953'---- ==== =Your first problem I don't understand. As for the second, this may give youa taste of Mathematica's powers:In[1]:=< {x -> 0, y -> 0}Out[2]={{a -> 0, b -> 0}, {a -> 0, c -> 0}, {b -> 0, c -> 0}}Tomas GarzaMexico City----- Original Message -----> b = d and c = d = 1> 2) from a list, say {a,b,c}, I would like to generate> {{b->0,c->0},{a->0,c->0},{a->0,b->0}> I guess I have understood the iterative way of doing that,> but what about a more functionqal form? Francois --> Francois Lauze> The IT University of Copenhagen, Glentevej 67> 2400 Kbh NV, Denmark> ==== =Francois,If c = d = 1, then b = 1 also. So just add the definition...f[f[a_, 1, 1], 1, e_] := f[f[a, b, 1/2], b, 1/2]For your list problem, use Combinatorica.Needs[DiscreteMath`Combinatorica`]? KSubsetsKSubsets[l, k] gives all subsets of set l containing exactly k elements, ordered lexicographically.KSubsets[{a, b, c}, 2]Thread[# -> {0, 0}] & /@ %gives{{a,b},{a,c},{b,c}}{{a -> 0, b -> 0}, {a -> 0, c -> 0}, {b -> 0, c -> 0}}The last statement works this way...{a,b} -> {0,0}Thread[%]{a, b} -> {0, 0}{a -> 0, b -> 0}We then just map that function onto each of the three sets.David Parkdjmp@earthlink.nethttp://home.earthlink.net/~djmp/I 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, DenmarkReply-To: Mark Coleman ==== =Greetings,single-image stereograms in Mathematica (TMJ, Vol 5, #1). Is anyone aware of an update to this work, or any additional Mathematica resources on stereograms?-Mark ==== =MacOS 10.2. The cell structure is copied and all is exactly the same.Ihave however on occasion lost my mouse pointer when Mathematica is openand the display goes to sleep and then wakes again. It doesn't happen withany other program. I suspect its a combination of both MacOS 10.2 andMathematica because things such as mouse pointer probelms also occur onRehardsYas> As a follow up on this issue:> I reinstalled Mathematica 4.1 for Mac OS X and found that I still have> this problem. On the other hand Hayes informed me that he did not> have it on Mathematica 4.2 under Windows 98. I then tried it myself,> with Mathematica 4.1 under Windows 98, and indeed I found I can copy> and paste groups of cells and the cell structure is preserved. They do> not get merged into a single cell with all the Mathematica markup> visible as they do in my case under Mac OS X 10.2. I would like to know> if other Mac OS X users have the same problem. If not, it may be caused> by something weird in my installation, although it seems unlikely as I> am not experiencing any other problems. I have not yet tried reporting> this to Technical Support yet since I am not sure if other Mac OS X> users are also experiencing the same behaviour, but if it is a bug it's> an awful one.> Andrzej> I am having an extremely frustrating time with one feature of> Mathematica 4.2 which I swear was not present in earlier versions. It> find is quite dreadful and yet none seems to have complained about it> so far so that I feel that perhaps I missing something obvious.> Anyway, this is the problem. I have two notebooks with a large number> of cells each. I want to copy some cells from one notebook to the> other. I am sure in earlier versions it used to be possible to select> several contiguous cells by shift clicking and then paste them into> another notebook. You would then get several cells of the same type as> you copied. However now (at least on Mac OS X) this seems impossible.> What happens is that if you select a several cells or a cell group and> past into another notebook you get a messy expression contained in a> single cell from which it does not appear possible to easily recover> the original cells. I have tired using various Copy As but have not> found anything that works. The only thing that works is copying and> pasting individual cells, which is of course very time consuming.> Is this also what happens on other platforms? I am sure it was not the> case in earlier versions, and if so was this an intentional change? It> so it seems to me as bad an idea as I have come across in many years.> Can anyone explain?> Andrzej Kozlowski> ==== =Are you really sure of this? The reason why I am asking is because not only another user has confirmed the problem but the Wolfram technical support has now acknowledged this as a well known bug. The only possibility I can see is that your version of 4.2 is actually newer than mine. Could you check this? Mine is 4.2.0.0.Also:In[1]:=Out[1]=4.2 for Mac OS X (June 4, 2002)Andrzej> MacOS 10.2. The cell structure is copied and all is exactly the same.I> have however on occasion lost my mouse pointer when Mathematica is open> and the display goes to sleep and then wakes again. It doesn't happen > with> any other program. I suspect its a combination of both MacOS 10.2 and> Mathematica because things such as mouse pointer probelms also occur on Rehards> Yas As a follow up on this issue:> I reinstalled Mathematica 4.1 for Mac OS X and found that I still have> this problem. On the other hand Hayes informed me that he did > not> have it on Mathematica 4.2 under Windows 98. I then tried it myself,> with Mathematica 4.1 under Windows 98, and indeed I found I can copy> and paste groups of cells and the cell structure is preserved. They do> not get merged into a single cell with all the Mathematica markup> visible as they do in my case under Mac OS X 10.2. I would like to > know> if other Mac OS X users have the same problem. If not, it may be > caused> by something weird in my installation, although it seems unlikely as I> am not experiencing any other problems. I have not yet tried reporting> this to Technical Support yet since I am not sure if other Mac OS X> users are also experiencing the same behaviour, but if it is a bug > it's> an awful one.> Andrzej>> I am having an extremely frustrating time with one feature of>> Mathematica 4.2 which I swear was not present in earlier versions. It>> find is quite dreadful and yet none seems to have complained about it>> so far so that I feel that perhaps I missing something obvious.>> Anyway, this is the problem. I have two notebooks with a large number>> of cells each. I want to copy some cells from one notebook to the>> other. I am sure in earlier versions it used to be possible to select>> several contiguous cells by shift clicking and then paste them into>> another notebook. You would then get several cells of the same type >> as>> you copied. However now (at least on Mac OS X) this seems impossible.>> What happens is that if you select a several cells or a cell group >> and>> past into another notebook you get a messy expression contained in a>> single cell from which it does not appear possible to easily recover>> the original cells. I have tired using various Copy As but have not>> found anything that works. The only thing that works is copying and>> pasting individual cells, which is of course very time consuming.>> Is this also what happens on other platforms? I am sure it was not >> the>> case in earlier versions, and if so was this an intentional change? >> It>> so it seems to me as bad an idea as I have come across in many years.>> Can anyone explain?>> Andrzej Kozlowski>>Andrzej KozlowskiYokohama, Japanhttp://www.mimuw.edu.pl/~akoz/http:// platon.c.u-tokyo.ac.jp/andrzej/ ==== =...What happens is that if you select a several cells or a cell group andpast into another notebook you get a messy expression contained in asingle cell from which it does not appear possible to easily recoverthe original cells...What a coincidence! Or maybe not :-(I logged a telephone support call to WRI on this very matter the day after Iupdated to OS10.2.2. Is that OS upgrade involved? Hard to tell, because thesymptom appeared the day AFTER. Did I go a whole day without copying cells?In my case, the symptom extended to copying even one entire cell, to thesame or a different notebook. It stopped me in my tracks.At WRI's suggestion, I cleared the Front End cache. No help.Then I uninstalled Mathematica 4.2 (on Mac, simply drag the application tothe trash), restarted, and then reinstalled Mathematica 4.2 and pasted myinit files back in. I was up to full speed in 5 minutes (40 minutes afterthe first symptom.) The symptom is gone and has not returned.As I told WRI, I don't understand, but I am happy that that AWFUL copy bugis gone!Tom Burton ==== =I am about to describe one of the strangest experiences with a software bug that I have ever had. It now looks that, partly thanks to the help of other members of this list, I have managed to solve this most irritating problem. But the true cause of it remains still mysterious and so does the response I got from WRI's technical support.First of all, while waiting for response from the mathgroup, I decided to sent a bug report to WRI's technical support. The answer came on the next day. Moreover, it acknowledged this as a known bug and suggested a way round it. The suggestion was to copy the notebook using Copy As Complete Notebook menu item and then paste cells from the new notebook. Unfortunately this solution proved imperfect. It is true that it solved the visible markup problem but cells were still being merged into a single cell and the only thing I could do about it was to break them up again using the Divide Cell menu item, hardly a convenient way to go about copying cells. I more or less gave up (particularly once i received the first response form a mathgroup user confirming that he also had the problem) and tried to persuade myself that using Mathematica in Classic was not all that bad when I got a message from Yas Tesiram stating that he was using 4.2 on Mac OS X 10.2 and did not have the problem at all. At this point I was still pretty certain that there was indeed a bug, and that it must have been fixed in a recent release that Yas managed to get (I have to admit to suspecting WRI at this point about deliberately keeping me in the dark about the existence of a such a more recent release-- sorry about that). The breakthrough came when I got a message from TOm Burton who told me that he had this problem once but he cured it by deleting and re-installing Mathematica. I immediately tried his approach but it did not work. But now I was not prepared to give up. I created a new user, logged out as myself and logged in again as the new user. Guess what, the problem was gone. I started frantically possible culprits in my ~/Library and also for any applications that were set to run on start up. I soon noticed a possible culprit, a little freeware program called PTHPasteboard which creates multiple-clipboards. I removed it and the problem was gone. Everything seems to be fine again.Now the biggest mystery: why did technical support so quickly acknowledged a bug, which may not be one at all? Could this be something to do with the frequency of complaints (eg.g on this list ) that they are too slow to acknowledge bugs and to often refuse to accept them as such? Actually, now I begin to feel that there may be perhaps something to be said for this attitude, and certainly it seesm preferable to its opposite: too great a readiness to accept claims of bugs which may after all not be that at all.Andrzej KozlowskiYokohama, Japanhttp://www.mimuw.edu.pl/~akoz/http:// platon.c.u-tokyo.ac.jp/andrzej/> I am having an extremely frustrating time with one feature of> Mathematica 4.2 which I swear was not present in earlier versions. It> find is quite dreadful and yet none seems to have complained about it> so far so that I feel that perhaps I missing something obvious.> Anyway, this is the problem. I have two notebooks with a large number> of cells each. I want to copy some cells from one notebook to the> other. I am sure in earlier versions it used to be possible to select> several contiguous cells by shift clicking and then paste them into> another notebook. You would then get several cells of the same type as> you copied. However now (at least on Mac OS X) this seems impossible.> What happens is that if you select a several cells or a cell group and> past into another notebook you get a messy expression contained in a> single cell from which it does not appear possible to easily recover> the original cells. I have tired using various Copy As but have not> found anything that works. The only thing that works is copying and> pasting individual cells, which is of course very time consuming.> Is this also what happens on other platforms? I am sure it was not the> case in earlier versions, and if so was this an intentional change? It> so it seems to me as bad an idea as I have come across in many years.> Can anyone explain? Andrzej Kozlowski ==== =Yes :PowerExpand[Sqrt[x^2]]But : It's dangerous ! You have to be sure that x is real positive !So you can also do the following :Simplify[Sqrt[x^2],x>0]Bonne journ.8ee !Florian Jaccardprofesseur de Math.8ematiquesEICN-HESLe Locle-----Message d'origine-----Envoy.8e : jeu., 28. novembre 2002 20:08è : mathgroup@smc.vnet.netObjet : Simplification ?Is there a way to force Mathematica to simplify the terms likeSqrt[x^2]to give x ???__________________________________________________________ _Olivier DURUSSELEcole Polytechnique F.8ed.8erale de LausanneSTI-IPR-LCSMME-EcublensCH-1015 LausanneT.8el.: +41 21 693 53 17 ==== =............> Have an entry under Graphics Primitives> Have an entry under Primitives> Have an entry under Graphics Directives> Have an entry under Directives............Dave,I almost always use the on line Help BrowserSet the category to Master Index and these are found.The first three are in the printed book's index,----------------------- HayesMathematica Training and ConsultingLeicester UKwww.haystack.demon.co.ukhay@haystack.demon.co.ukVoice: +44 (0)116 271 4198> >look at the online-help for Graphics[] !>What is listed first ??>The following graphics primitives can be used:>....>and>The following graphics directives can be used:>What else can be done ? Should the text color red ?>and ßashing ?> JensHave an entry under Graphics Primitives> Have an entry under Primitives> Have an entry under Graphics Directives> Have an entry under Directives The object of an index is to let people find stuff, who don't know theright> way to ask. Dave Golber > So today I'm doing some graphics. Oh: there are _options_ and>_directives_.> So I try to find out what are all the graphics primatives?> When you look in the index of the 1500 page book, or type Graphics>Primatives> in the on-line Help, you don't find it. You have to look underGraphics or> Graphics3D. In the book, it's in the appendix.> ==== =Have an entry under Graphics Primitives> Have an entry under Primitives> Have an entry under Graphics Directives> Have an entry under DirectivesThe object of an index is to let people find stuff, who don't know the right> way to ask.Dave Golber> Well put . . . and relevant to this group.Power tends to corrupt. Absolute power corrupts absolutely. Lord Acton (1834-1902)Dependence on advertising tends to corrupt. Total dependence on advertising corrupts totally. (today's equivalent) ==== =Alexander,My guess is that your speed problems are due to the overhead of making so many calls from Mathematica into Java. There is a more or less constant overhead of making a call into Java that is due to the internals of MathLink and J/Link. On a low-to-mid-range PC, each call to Java costs about a millisecond (plus the processing time for the actual Java code to run, which is usually negligible). For many programs, this overhead is not a concern, but your code is calling into Java at least twice for every item read from the database, and if there are 100,000 items to read then you will have a slow program.There is one simple optimization you can make that should cut the time about in half. Your Switch statement tests against the constants Types`CHAR, Types`DOUBLE, etc. These harmless-looking expressions trigger a call into Java each time they are evaluated. You can eliminate these unnecessary calls by caching the values ahead of time: {$charType, $doubleType, $dateType, ...etc. } = {Types`CHAR, Types`DOUBLE, Types`DATE, ...etc.};Then the Switch becomes: Switch[type, $charType, rs@getString[i], $doubleType, rs@getDouble[i], ... etc. ]This one change will drop the number of calls into Java from two to one for each item.If you have lots of TIMESTAMP values in your data, you can also speed up your handling of these types. Right now you make 6 calls into Java for each TIMESTAMP. You could probably drop this to 2. In your DataSourceEvaluate Then in GetColumn you would use it like this:If these optimizations are still not enough, the only thing to do is to move at least some of the loop (NestWhileList) down into Java code. Then you could call into Java once for each result set instead of once for each data item.Just to be clear, the reason we move the loop is not because Java is faster than Mathematica but because we want to minimize the number of times we cross the Mathematica-Java barrier.A simple first try would be to write Java code that gets the contents of a single row. Then you could use essentially all of your current Mathematica code unchanged. With this technique, you would only have one call into Java for each row instead of each row x col. That might be enough optimization. I like this approach because it conforms with a general principle that I try to adhere to when doing mixed-language programming: Write as much as possible in the highest-level language. With J/Link, start out writing everything in Mathematica, and only if the performance isn't acceptable do you consider writing Java. Then try to find the smallest possible piece of functionality to move down into Java.Here is the RowGetter class. It is little more than a direct translation of your GetColumn function into Java. The getRow() method is a good example of a method that sends its result back to Mathematica manually instead of simply relying on J/Link's automatic behavior of sending back the method's return value. Manual functions are discussed in section 1.2.18 of the J/Link User Guide.///////////////////// RowGetter class //////////////////////import java.sql.*;import com.wolfram.jlink.*;public class RowGetter { private int[] types; public RowGetter(int[] types) { this.types = types; } public void getRow(ResultSet rs) throws MathLinkException, SQLException { ml.beginManual(); ml.putFunction(List, types.length); for (int i = 0; i <= types.length; i++) { switch (types[i]) { case Types.VARCHAR: case Types.CHAR: ml.put(rs.getString(i)); break; case Types.DOUBLE: ml.put(rs.getDouble(i)); break; case Types.TIME: case Types.DATE: break; case Types.NUMERIC: case Types.INTEGER: ml.put(rs.getInt(i)); break; case Types.TIMESTAMP: break; default: // Do something to handle the fallthrough case: ml.putSymbol($UnhandledJDBCType); } } }}/////////////////// End RowGetter class /////////////////////Then nothing about your Mathematica code has to change except the NestWhileList: rowGetter = JavaNew[RowGetter, types]; Rest[ NestWhileList[ rowGetter@getRow[rs]&, 1, rs@next[]& ] ]Todd GayleyWolfram Research>I have a Mathematica program that uses DatabaseAccess package to>retrieve large amount of data from Sybase database. DatabaseAccess is>available for Windows only since it uses odbc. Now, I wanted to run>access. At the end of this message I'll insert the code that emulates>DataSourceEvaluate and OpenDataSource from DatabaseAccess but uses>jdbc. The implementation is simple and straightforward. The problem is>the code works MUCH slower than the equivalent odbc-based one on NT. I>retrieve A LOT of data so this is really annoying. So I have two>questions:1. Is it one of the Mathematica functions that make it slow (the>conversion of the result of the sql query into Mathematica table) or>is it some fundamental java-related problem (JLink, jdbc etc)?2. How can I make it run faster?Alexander>InstallJava[];>AddToClassPath[> jconn2.jar, jdbc2_0-stdext.jar];LoadJavaClass[java.sql.Types];> LoadJavaClass[java.util.Calendar];Clear[GetColumn];>GetColumn [i_, type_, rs_] := Switch[type,> Types`CHAR,rs@getString[i],> Types`DOUBLE,rs@getDouble[i],> Types`INTEGER,rs@getInt[i],> Types`VARCHAR,rs@getString[i],> Types`TIMESTAMP,JavaBlock[> ToString[cal@get[Calendar`MONTH] + 1]<>/< ToString[cal@get[Calendar`DATE]]<>/< ToString[cal@get[Calendar`YEAR]]]> ],> Types`NUMERIC,rs@getInt[i]]ClearAll[DataSourceEvaluate];> DataSourceEvaluate[conn_,sql_String] :=> JavaBlock[> Module[{st = conn@createStatement[],rs,md, types,res},> res = If [st@execute[sql], rs = st@getResultSet[];> md = rs@getMetaData[];> types = Array[md@getColumnType[#]&,{md@getColumnCount[]}];> Rest[> NestWhileList[> Array[GetColumn[#,types[[#]], rs] &,{Length@types}] &,> 1,> rs@next[] &]],> {}];> st@close[];> res]]Clear[OpenDataSource];>OpenDataSource[database_String, user_String,password_String] :=> Module[{driver = JavaNew[com.sybase.jdbc2.jdbc.SybDriver],> dbUrl = jdbc:sybase:Tds:<>$DBServer<>:<>$DBPort<>/<>database,> prop = JavaNew[java.util.Properties]},> prop@setProperty[user,user];> prop@setProperty[password,password];> driver@connect[dbUrl,prop]]; ==== =I'm a french student in Computer Science, and crypto, and i want to knowif somebody have the mathematica implementation of Rijndael, or somegood url where i could find ressources about it. Sincerely ==== =Andrzej:I run 4.1 under Mac OS 10.2.1. For what it's worth, I copy a set of cells from a 4.1 notebook and paste into the middle of another notebook. Everything seems to go as it should.?? ==== ===========> As a follow up on this issue:> I reinstalled Mathematica 4.1 for Mac OS X and found that I still have> this problem. On the other hand Hayes informed me that he did not> have it on Mathematica 4.2 under Windows 98. I then tried it myself,> with Mathematica 4.1 under Windows 98, and indeed I found I can copy> and paste groups of cells and the cell structure is preserved. They do> not get merged into a single cell with all the Mathematica markup> visible as they do in my case under Mac OS X 10.2. I would like to know> if other Mac OS X users have the same problem. If not, it may be caused> by something weird in my installation, although it seems unlikely as I> am not experiencing any other problems. I have not yet tried reporting> this to Technical Support yet since I am not sure if other Mac OS X> users are also experiencing the same behaviour, but if it is a bug it's> an awful one.> Andrzej> I am having an extremely frustrating time with one feature of> Mathematica 4.2 which I swear was not present in earlier versions. It> find is quite dreadful and yet none seems to have complained about it> so far so that I feel that perhaps I missing something obvious.> Anyway, this is the problem. I have two notebooks with a large number> of cells each. I want to copy some cells from one notebook to the> other. I am sure in earlier versions it used to be possible to select> several contiguous cells by shift clicking and then paste them into> another notebook. You would then get several cells of the same type as> you copied. However now (at least on Mac OS X) this seems impossible.> What happens is that if you select a several cells or a cell group and> past into another notebook you get a messy expression contained in a> single cell from which it does not appear possible to easily recover> the original cells. I have tired using various Copy As but have not> found anything that works. The only thing that works is copying and> pasting individual cells, which is of course very time consuming.> Is this also what happens on other platforms? I am sure it was not the> case in earlier versions, and if so was this an intentional change? It> so it seems to me as bad an idea as I have come across in many years.> Can anyone explain? Andrzej Kozlowski ==== ========= Hugh Walker Gnarly Oaks ==== =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.>Do you refer here to the Option Inspector? If so, what option name are>you referring to?> ...If you use version 4.2.1, you can configure font> export in the preferences dialog (or give it as an> option) ==== =I'm drawing various closed objects of arbitrary shape (thick lenses, for then would like to Fill them with a specified color. How to do the Fill?(I suppose I could do this as a very complex polygon, replacing the arcs by many short line segments and building up the whole object as a lengthy list of points; but that seems like a pain.)Power tends to corrupt. Absolute power corrupts absolutely. Lord Acton (1834-1902)Dependence on advertising tends to corrupt. Total dependence on advertising corrupts totally. (today's equivalent) ==== =I want to set my axes that one unit is five centimeter. How can I do ?Sorry for my english, I'm french :) ==== =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. ==== =I type the following:ImplicitPlot[Sqrt[x-y]==0,{x,0,10}]and all ok,but if i try to use ContourPlot in the following mannerImplicitPlot[Sqrt[x-y]==0,{x,0,10},{y,0,10}]it say:ContourGraphics::ctpnt: The contour is attempting to traverse a cell inwhich some of the points have not evaluated to numbers, and it will bedropped.I have not understud why.Some one can help me? ==== =Andrzej, I have Mathematica 4.2 installed on my upgraded PowerTower Pro(G4800Mhz) with Mac OS 10.1.5 and do not have the problem you areexperiencing.Brian > As a follow up on this issue:> I reinstalled Mathematica 4.1 for Mac OS X and found that I still have > this problem. On the other hand Hayes informed me that he did not > have it on Mathematica 4.2 under Windows 98. I then tried it myself, > with Mathematica 4.1 under Windows 98, and indeed I found I can copy > and paste groups of cells and the cell structure is preserved. They do > not get merged into a single cell with all the Mathematica markup > visible as they do in my case under Mac OS X 10.2. I would like to know > if other Mac OS X users have the same problem. If not, it may be caused > by something weird in my installation, although it seems unlikely as I > am not experiencing any other problems. I have not yet tried reporting > this to Technical Support yet since I am not sure if other Mac OS X > users are also experiencing the same behaviour, but if it is a bug it's > an awful one. I am having an extremely frustrating time with one feature of > Mathematica 4.2 which I swear was not present in earlier versions. It > find is quite dreadful and yet none seems to have complained about it > so far so that I feel that perhaps I missing something obvious. > Anyway, this is the problem. I have two notebooks with a large number > of cells each. I want to copy some cells from one notebook to the > other. I am sure in earlier versions it used to be possible to select > several contiguous cells by shift clicking and then paste them into > another notebook. You would then get several cells of the same type as > you copied. However now (at least on Mac OS X) this seems impossible. > What happens is that if you select a several cells or a cell group and > past into another notebook you get a messy expression contained in a > single cell from which it does not appear possible to easily recover > the original cells. I have tired using various Copy As but have not > found anything that works. The only thing that works is copying and > pasting individual cells, which is of course very time consuming.> Is this also what happens on other platforms? I am sure it was not the > case in earlier versions, and if so was this an intentional change? It > so it seems to me as bad an idea as I have come across in many years. > Can anyone explain?> Andrzej Kozlowski> ==== => As a follow up on this issue:> I reinstalled Mathematica 4.1 for Mac OS X and found that I still have > this problem. On the other hand Hayes informed me that he did not > have it on Mathematica 4.2 under Windows 98. I then tried it myself, > with Mathematica 4.1 under Windows 98, and indeed I found I can copy > and paste groups of cells and the cell structure is preserved. [...]Andrzej[...]miss other features what are very convinient in Windows:- Selecting arbitrary cells by pressing the Ctrl-key- Clicking on a cell bracket after pressing the Alt-key selects all cells of the same type in the whole notebookRainer ==== =No problem using 4.1 and 10.2.2. NB: Copying, switching applications,switching back to Mathematica, then pasting does produce the problem you describe.However, this problem has been around for awhile, certainly it was thereusing 4.0 on OS 9.js-- Joshua A. SolomonDepartment of Optometry and Visual ScienceCity Universityhttp://www.staff.city.ac.uk/~solomon> As a follow up on this issue:> I reinstalled Mathematica 4.1 for Mac OS X and found that I still have> this problem. On the other hand Hayes informed me that he did not> have it on Mathematica 4.2 under Windows 98. I then tried it myself,> with Mathematica 4.1 under Windows 98, and indeed I found I can copy> and paste groups of cells and the cell structure is preserved. They do> not get merged into a single cell with all the Mathematica markup> visible as they do in my case under Mac OS X 10.2. I would like to know> if other Mac OS X users have the same problem. If not, it may be caused> by something weird in my installation, although it seems unlikely as I> am not experiencing any other problems. I have not yet tried reporting> this to Technical Support yet since I am not sure if other Mac OS X> users are also experiencing the same behaviour, but if it is a bug it's> an awful one.> Andrzej> I am having an extremely frustrating time with one feature of> Mathematica 4.2 which I swear was not present in earlier versions. It> find is quite dreadful and yet none seems to have complained about it> so far so that I feel that perhaps I missing something obvious.> Anyway, this is the problem. I have two notebooks with a large number> of cells each. I want to copy some cells from one notebook to the> other. I am sure in earlier versions it used to be possible to select> several contiguous cells by shift clicking and then paste them into> another notebook. You would then get several cells of the same type as> you copied. However now (at least on Mac OS X) this seems impossible.> What happens is that if you select a several cells or a cell group and> past into another notebook you get a messy expression contained in a> single cell from which it does not appear possible to easily recover> the original cells. I have tired using various Copy As but have not> found anything that works. The only thing that works is copying and> pasting individual cells, which is of course very time consuming.> Is this also what happens on other platforms? I am sure it was not the> case in earlier versions, and if so was this an intentional change? It> so it seems to me as bad an idea as I have come across in many years.> Can anyone explain?Andrzej Kozlowski ==== =There is no hint of this trouble using4.2 for Mac OS X (August 22, 2002) on Mac OS 10.2.2.If you start Mathematica with the Shift key held down it will reset all the Options in the Preferences to their default values and this might be worth trying.------------------------------------------------------ ---------> As a follow up on this issue:> I reinstalled Mathematica 4.1 for Mac OS X and found that I still have > this problem. On the other hand Hayes informed me that he did > not have it on Mathematica 4.2 under Windows 98. I then tried it > myself, with Mathematica 4.1 under Windows 98, and indeed I found I > can copy and paste groups of cells and the cell structure is > preserved. They do not get merged into a single cell with all the > Mathematica markup visible as they do in my case under Mac OS X 10.2. > I would like to know if other Mac OS X users have the same problem. If > not, it may be caused by something weird in my installation, although > it seems unlikely as I am not experiencing any other problems. I have > not yet tried reporting this to Technical Support yet since I am not > sure if other Mac OS X users are also experiencing the same behaviour, > but if it is a bug it's an awful one.Christopher PurcellDRDC-Atlantic, 9 Grove St., PO Box 1012,Dartmouth, NS Canada B2Y 3Z7chris.purcell@drdc-rddc.gc.ca ==== =(1) The function may have no zeros.(2) The coefficients in your function have such wildly differing magnitudes that you'll never get any reliable numerical results unless you do a lot of rescaling.Hope this helps...---Selwyn Hollis> i have to find all the roots in a region of this equation for a sweep> of value in w :> function[z_,w_]:=Module[{k0,sl},k0=w/(3*10^8);sl=(Sqrt[k0^2-z ^2])/(377*k0)-(I*Sqrt[e*k0^2-z^2])/(377*k0*Tan[o*Sqrt[e*k0^2- z^2]])+I> w a (1 - b t w^2)/((1 - b t w^2)*(1 - g a w^2) - b a w^2)];where a,b,g,t,o,e are costs:o=0.00406> e=1.001> b=0.048*10^(-9)> t=0.4521*10^(-12)> g=0.396*10^(-9)> a=0.176*10^(-12)I've tried with the following function posted by Selwyn Hollis:shotgun[fn_, {z_Symbol, z1_?NumericQ, z2_?NumericQ, dz_?NumericQ},> tol_?NumericQ, fuzz_?NumericQ]:= Module[{gridpts,shot,solns}, (* Construct a list of grid points. The mesh size is dz.*)> gridpts = Table[x + I*y, {x,Re[z1],Re[z2],dz},> {y,Im[z1],Im[z2],dz}]; (* It's a bit faster if we compile Abs[fn]. *)> fc = Compile[{{z,_Complex,2}}, Abs[fn]]; (* Keep only the grid points where Abs[fn] < tol. *)> starters = Extract[gridpts, Position[fc[gridpts], _?(# shot = Chop@FindRoot[fn,{z,#}]&/@starters; (* Sort by magnitude and remove repetitions.> A repetition occurs when consecutive solutions differ by > less than fuzz. *)> solns = Sort[shot,(Abs[z/.#1] < Abs[z/.#2])&];> solns = First/@Split[solns,(Abs[(z/.#1)-(z/.#2)] < fuzz)&]; (* Sort again and remove repetitions. *)> First/@Split[Sort[solns],(Abs[(z/.#1)-(z/.#2)] < fuzz)&] ]It works fine with some function but not with the mine.> Does anybody know how to change it, to make it works fine?> Massimiliano CasalettiP.S. Sorry for my english> ==== => function[z_,w_]:=Module[{k0,sl},k0=w/(3*10^8);sl=(Sqrt[k0^2-z ^2])/(377*k0)-(I*> Sqrt[e*k0^2-z^2])/(377*k0*Tan[o*Sqrt[e*k0^2-z^2]])+I> w a (1 - b t w^2)/((1 - b t w^2)*(1 - g a w^2) - b a w^2)];Doing some kind of fiber optics or wave propagation, one might guess . . . .Power tends to corrupt. Absolute power corrupts absolutely. Lord Acton (1834-1902)Dependence on advertising tends to corrupt. Total dependence on advertising corrupts totally. (today's equivalent) ==== =The following works OK in Mathematica 4.2 for Windows:input:With[{a = 1.1, b = 1.1}, NSolve[Exp[-Pi*a/x] + Exp[-Pi*b/x] == 1, x] ]output:{{x -> 4.9856}}Steve Luttrell> I am trying to solve the following equation for given values of two> parameters a and b: NSolve[Exp[-Pi*a/x] + Exp[-Pi*b/x] == 1, x] This is straightforward for integer values of the parameters a and b> (e.g. a=1, b=1). However, Mathematica is unable to compute the> solution for non-integer values of a and b (e.g. a=1.1, b=1.1; even> a=1.0, b=1.0 doesn't work). Instead, the error message Solve::tdep:> The equations appear to involve the variables to be solved for in an> essentially non-algebraic way. is produced. Can anybody point out a way to overcome this problem and to obtain a> solution? Eva>Reply-To: kuska@informatik.uni-leipzig.de ==== =what ist withWith[{a = 1.1, b = 1.0}, FindRoot[Exp[-Pi*a/x] + Exp[-Pi*b/x] == 1, {x, 1}] ] JensI am trying to solve the following equation for given values of two> parameters a and b:NSolve[Exp[-Pi*a/x] + Exp[-Pi*b/x] == 1, x]This is straightforward for integer values of the parameters a and b> (e.g. a=1, b=1). However, Mathematica is unable to compute the> solution for non-integer values of a and b (e.g. a=1.1, b=1.1; even> a=1.0, b=1.0 doesn't work). Instead, the error message Solve::tdep:> The equations appear to involve the variables to be solved for in an> essentially non-algebraic way. is produced.Can anybody point out a way to overcome this problem and to obtain a> solution?Eva ==== =I do not have this problem with my installation of Mathematica 4.2 on Mac OS X 10.2 as long as I do not have the cursor in the target notebook already in a cell-- the cursor should be a horizontal line indicating insert cell mode. It also works for non-contiguous cells.Alex> As a follow up on this issue:> I reinstalled Mathematica 4.1 for Mac OS X and found that I still have> this problem. On the other hand Hayes informed me that he did not> have it on Mathematica 4.2 under Windows 98. I then tried it myself,> with Mathematica 4.1 under Windows 98, and indeed I found I can copy> and paste groups of cells and the cell structure is preserved. They do> not get merged into a single cell with all the Mathematica markup> visible as they do in my case under Mac OS X 10.2. I would like to know> if other Mac OS X users have the same problem. If not, it may be caused> by something weird in my installation, although it seems unlikely as I> am not experiencing any other problems. I have not yet tried reporting> this to Technical Support yet since I am not sure if other Mac OS X> users are also experiencing the same behaviour, but if it is a bug it's> an awful one.> Andrzej> I am having an extremely frustrating time with one feature of> Mathematica 4.2 which I swear was not present in earlier versions. It> find is quite dreadful and yet none seems to have complained about it> so far so that I feel that perhaps I missing something obvious.> Anyway, this is the problem. I have two notebooks with a large number> of cells each. I want to copy some cells from one notebook to the> other. I am sure in earlier versions it used to be possible to select> several contiguous cells by shift clicking and then paste them into> another notebook. You would then get several cells of the same type as> you copied. However now (at least on Mac OS X) this seems impossible.> What happens is that if you select a several cells or a cell group and> past into another notebook you get a messy expression contained in a> single cell from which it does not appear possible to easily recover> the original cells. I have tired using various Copy As but have not> found anything that works. The only thing that works is copying and> pasting individual cells, which is of course very time consuming.> Is this also what happens on other platforms? I am sure it was not the> case in earlier versions, and if so was this an intentional change? It> so it seems to me as bad an idea as I have come across in many years.> Can anyone explain? Andrzej Kozlowski ==== =[I fear this is a FAQ but I've dutifully searched the current 4.2 docs andthis formus archive and could find only recommendations for Mathematica 3.0]I'm trying to copy/export graphics from Mathematica to other apps such as MS Word orPowerPoint. Graphs print great directly from Mathematica (correctly rotates they-axis text even though it doesn't appear correctly on the screen). Butattempts to copy/paste into other applications (using PICT, PICT withembedded postscript, and all other options) or Export[file.GIF,%] etc. andthen importing that file to other apps usually produces something ugly andthe y-axis text never prints rotated from these other apps.I'm addicted to producing publication-quality graphics with Mathematica, but I needto be able to include them in those documents produced by other apps. Iknow the workaround is simply to use Mathematica as my word processor for technicaldocuments, but I can't convert all my colleagues with whom I exchangeworking drafts.Any suggestions appreciated, including RTFM if you will give me a hint whereto look. gary ==== =Vince,I've often found that using PlotRange to extend the printed range just a bitbeyond the limits I want makes missing tick marks appear on either end.Gary> When I plot a graph with the following FrameTicks specification:FrameTicks - {> Automatic,> {> {-[Pi], -[Pi], {0.01, 0}, {AbsoluteThickness[1.5]}}> },> Automatic,> {> {-[Pi], -[Pi], {0.01, 0}, {AbsoluteThickness[1.5]}}> }> }the tick to the right of the -Pi label on the left axis does not appear.> The only way I can make it appear in Mathematica is with:FrameTicks - {> Automatic,> {> {-[Pi], -[Pi], {0.01, 0}, {AbsoluteThickness[1.5]}},> {-[Pi], , {0.01, 0}, {AbsoluteThickness[1.5]}}> },> Automatic,> {> {-[Pi], -[Pi], {0.01, 0}, {AbsoluteThickness[1.5]}}> }> }> where I have repeated the frametick line but omitting the -Pi label.I'm using Mathematica 4.1.1.0 on Windows XP.> Vince Boros ==== =Vince,The tick appears for me with Mathematica 4.2 under Windows 98----------------------- HayesMathematica Training and ConsultingLeicester UKwww.haystack.demon.co.ukhay@haystack.demon.co.ukVoice: +44 (0)116 271 4198> When I plot a graph with the following FrameTicks specification: FrameTicks - {> Automatic,> {> {-[Pi], -[Pi], {0.01, 0}, {AbsoluteThickness[1.5]}}> },> Automatic,> {> {-[Pi], -[Pi], {0.01, 0}, {AbsoluteThickness[1.5]}}> }> } the tick to the right of the -Pi label on the left axis does not appear.> The only way I can make it appear in Mathematica is with: FrameTicks - {> Automatic,> {> {-[Pi], -[Pi], {0.01, 0}, {AbsoluteThickness[1.5]}},> {-[Pi], , {0.01, 0}, {AbsoluteThickness[1.5]}}> },> Automatic,> {> {-[Pi], -[Pi], {0.01, 0}, {AbsoluteThickness[1.5]}}> }> }> where I have repeated the frametick line but omitting the -Pi label. I'm using Mathematica 4.1.1.0 on Windows XP.> Vince Boros ==== =In reply to my question, it turned out that in the menu item Edit -> Preferences -> Formatting Options -> Font Options, I had Background set to GrayLevel[1]. I changed Background to None, and the problem disappeared. So what had been going wrong is that I had been writing black text on a white background on top of the graph, instead of black replied offering suggestions.Vince> When I plot a graph with the following FrameTicks specification:FrameTicks - {> Automatic,> {> {-[Pi], -[Pi], {0.01, 0}, {AbsoluteThickness[1.5]}}> },> Automatic,> {> {-[Pi], -[Pi], {0.01, 0}, {AbsoluteThickness[1.5]}}> }> }the tick to the right of the -Pi label on the left axis does not appear. > The only way I can make it appear in Mathematica is with:FrameTicks - {> Automatic,> {> {-[Pi], -[Pi], {0.01, 0}, {AbsoluteThickness[1.5]}},> {-[Pi], , {0.01, 0}, {AbsoluteThickness[1.5]}}> },> Automatic,> {> {-[Pi], -[Pi], {0.01, 0}, {AbsoluteThickness[1.5]}}> }> }> where I have repeated the frametick line but omitting the -Pi label.I'm using Mathematica 4.1.1.0 on Windows XP.> Vince Boros> ==== =Vince,It would help if you gave us an actual Plot statement that exhibited theproblem. I suspect that your PlotRange is {-Pi, Pi} and then Mathematicadrops the lower tick mark. (Don't ask me why - it's a feature.) If you wouldextend the vertical PlotRange slightly, it would probably solve the problem.In the second statement you got rid of the tick label yourself and so youdidn't notice that Mathematica had already dropped it.David Parkdjmp@earthlink.nethttp://home.earthlink.net/~djmp/ {-[Pi], -[Pi], {0.01, 0}, {AbsoluteThickness[1.5]}} } }the tick to the right of the -Pi label on the left axis does not appear. The only way I can make it appear in Mathematica is with:FrameTicks -> { Automatic, { {-[Pi], -[Pi], {0.01, 0}, {AbsoluteThickness[1.5]}}, {-[Pi], , {0.01, 0}, {AbsoluteThickness[1.5]}} }, Automatic, { {-[Pi], -[Pi], {0.01, 0}, {AbsoluteThickness[1.5]}} } }where I have repeated the frametick line but omitting the -Pi label.I'm using Mathematica 4.1.1.0 on Windows XP.Vince Boros ==== =I am a new Mathematica user with a numerical integration problem. My 2DNintegration gives the warning slwcon (numerical integration convergestoo slow). I am integrating over a thin strip through a 2DInterpolating Function. The Interpolating function is zero for mostvalues. All stips pass through some non-zero region. When the strip ismostly in the non-zero region there is no problem. Howvever, when thestrip passes through only a small part of the non-zero region, thewarning occurs and the integration is slow. The integration parametersI have so far found to work best are: WorkingPrecision -> 9,AccuracyGoal ->Infinity, Precision Goal -> 2, Method -> Gausskronron.If I increase the PrecisionGoal both the number of warnings and the timeincrease.Ann Fitchard ==== =Yes, I have the same problem with 4.2 under OS X (10.2.2). And it *is awful* indeed. What's worse (because it's much harder to detect and correct) is the arbitrary introduction of spaces and linefeeds to quoted strings which are cut and pasted. For my use of Mathematica, this has cost me untold hours. No combination of copy-as and/or paste-as has affected this problem.I sure hope to hear that this is going to be fixed soon!Michael WilliamsBlacksburg> As a follow up on this issue:> I reinstalled Mathematica 4.1 for Mac OS X and found that I still have> this problem. On the other hand Hayes informed me that he did not> have it on Mathematica 4.2 under Windows 98. I then tried it myself,> with Mathematica 4.1 under Windows 98, and indeed I found I can copy> and paste groups of cells and the cell structure is preserved. They do> not get merged into a single cell with all the Mathematica markup> visible as they do in my case under Mac OS X 10.2. I would like to know> if other Mac OS X users have the same problem. If not, it may be caused> by something weird in my installation, although it seems unlikely as I> am not experiencing any other problems. I have not yet tried reporting> this to Technical Support yet since I am not sure if other Mac OS X> users are also experiencing the same behaviour, but if it is a bug it's> an awful one.> Andrzej> I am having an extremely frustrating time with one feature of> Mathematica 4.2 which I swear was not present in earlier versions. It> find is quite dreadful and yet none seems to have complained about it> so far so that I feel that perhaps I missing something obvious.> Anyway, this is the problem. I have two notebooks with a large number> of cells each. I want to copy some cells from one notebook to the> other. I am sure in earlier versions it used to be possible to select> several contiguous cells by shift clicking and then paste them into> another notebook. You would then get several cells of the same type as> you copied. However now (at least on Mac OS X) this seems impossible.> What happens is that if you select a several cells or a cell group and> past into another notebook you get a messy expression contained in a> single cell from which it does not appear possible to easily recover> the original cells. I have tired using various Copy As but have not> found anything that works. The only thing that works is copying and> pasting individual cells, which is of course very time consuming.> Is this also what happens on other platforms? I am sure it was not the> case in earlier versions, and if so was this an intentional change? It> so it seems to me as bad an idea as I have come across in many years.> Can anyone explain? Andrzej KozlowskiIn-reply-To: <200211281908.OAA24008@smc.vnet.net> ==== =RP> In[4]:= Sum[Binomial[0,k],{k,0,Infinity}]RP> Out[4]= 0RP> I disagree. Should be 1.I confirm that you identified a bug the long-liver, I have sent your dataalong with the reference to you to support@wolfram.com . Indeed, In[1] := Sum[Binomial[0, k], {k, 0, Infinity}] Out[1] = 0 In[2] := NSum[Binomial[0, k], {k, 0, Infinity}] Out[2] = 1.This bug exists in the following versions of Mathematica 4.2 for Microsoft Windows (June 5, 2002) 4.2 for Microsoft Windows (February 28, 2002) 4.1 for Microsoft Windows (November 2, 2000) 4.0 for Microsoft Windows (April 21, 1999) Microsoft Windows 3.0 (April 25, 1997)RP> Perhaps my desired result for In[3] is expecting too much.I hardly think so. For example, another system returns 1 for the counterpartof your input.RP> In[3]:= Sum[Binomial[0,k],{k,0,n}]RP> Out[3]= 0RP> I disagree. Should be If[n == 0, 1, 0].Again, you are right because this sum is equal to 1 + 0 + 0 +... 0 = 1.Please note that In[4] := Binomial[0, k] Out[4] = Sin[k*Pi]/(k*Pi)while it should be If[k==0, 1, Sin[k*Pi]/(k*Pi)] .RP> In[5]:= Sum[Binomial[n,k],{k,0,Infinity}]RP> nRP> Out[5]= 2RP> I agree. But inconsistent with Out[4].RP> After all, x/x reduces to 1, not If[x == 0, Indeterminate, 1].RP> But Out[5] demonstrates that Mathematica knows the binomial theorem.RP> It ought to be able to come up with the correct result for In[4].Yes, it seems to be too obvious to discuss further.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 ==== => In[3]:= Sum[Binomial[0,k],{k,0,n}] Out[3]= 0 I disagree. Should be If[n == 0, 1, 0].Of course, I meant If[n >= 0, 1, 0].Rob PrattDepartment of Operations Researchhttp://www.unc.edu/~rpratt/In-reply-To: <200211281907.OAA23937@smc.vnet.net> ==== =S> here is my problem:S> Lets say you solve an equation using SolveS> Solve[2x - 1 == 0, x] // N{{x -> 0.5}}S> How would I then use the result of Solve (0.5) and assign it to aS> new variable, like answer for further calculations?Just use [[...]] (or its prefix equivalent, Part) to select a part of theoutput you want to use for your further calculations. In[1] := answer = (Solve[2x - 1 == 0, x] // N)[[1, 1, 2]]; In[2] := answer^2 Out[2] = 0.25Best wishes,Vladimir BondarenkoMathematical and Production DirectorSymbolic Testing Group http://www.CAS-testing.org/ GEMM Project (95% ready) Mail : 76 Zalesskaya Str, Simferopol, Crimea, Ukraine ==== =Yes, sometimes guys in engineering faculties have odd fixations. But I thinkyou're quite right in sticking to Mathematica. Anyway, the result of a Solvestatement is a list of rules, each of them saying something like a solutionis -> something. In your case, there is only one solution, so the list hasonly one element, and the solution is the first (and only) element of thelist. So, if you writeIn[1]:=a = N[Solve[2*x - 1 == 0, x]]Out[1]={{x->0.5}}then the first element of a isIn[9]:=a[[1]]Out[9]={x->0.5}Now you want to use this particular value of x. There are several ways to goabout it. One, and perhaps the more instructive, is to look at the FullFormof a[[1]]:In[2]:=FullForm[{x->0.5}]Out[2]//FullForm=List[Rule[x, 0.5]]which again says that you're dealing with a list. The first (and only)element of this list is a rule, and the second part of this rule is thenumerical value you're looking for: In[3]:=a[[1,1,2]]Out[3]=0.5Another way of getting at it is using a ReplaceAll statement. If you writeIn[4]:=x /. {x -> 0.5}this can be read as x, where x takes the value 0.5, which, when executed,will yield 0.5. Then you may write directlyIn[5]:=N[Solve[2*x - 1 == 0, x]][[1,1,2]]Out[5]=0.5This is valid in general. If your equation has several solutions, then thefirst index will lead you to the one you wish to use. Suppose you wanted touse this solution as input to some other problem, e.g., to be used as theargument of a function, like, say Sin[x]. Then you may writeIn[6]:=Sin[x]/.a[[1]]Out[6]=0.479426orIn[7]:=Sin[x/.a[[1 ]]]Out[7]=0.479426i.e. you may use the rule on the argument or on the function itself (in thissimple example).Tomas GarzaMexico City----- Original Message -----> Lets say you solve an equation using Solve Solve[2x - 1 == 0, x] // N {{x -> 0.5}} How would I then use the result of Solve (0.5) and assign it to a> new variable, like answer for further calculations? I think it has something to do with /. and -> rules of some sort, but> I can't get this simple concept to work!> -Stan ==== =ans = Solve[2x-1==0,x][[1]]//Nanswer = x/.ansNote that the [[1]] construct effectively turns ans into {x->0.5}, withoutit the above answer would be {0.5} not 0.5.Kevin> Even though it's frowned upon by the engineering college, i use> mathematica a lot of the stuff that would take pages of code in> another system. I have most basic functions and operations down, but I am> lacking one basic thing I need to do to be able to program more> problems successfully: here is my problem: Lets say you solve an equation using Solve Solve[2x - 1 == 0, x] // N {{x -> 0.5}} How would I then use the result of Solve (0.5) and assign it to a> new variable, like answer for further calculations? I think it has something to do with /. and -> rules of some sort, but> I can't get this simple concept to work!> -Stan>Reply-To: kuska@informatik.uni-leipzig.de ==== =sound complicated ;-)answer = First[x /. Solve[2x - 1 == 0, x] // N]First[] because you will use only the first of the solutions. JensEven though it's frowned upon by the engineering college, i use> mathematica a lot of the stuff that would take pages of code in> another system. I have most basic functions and operations down, but I am> lacking one basic thing I need to do to be able to program more> problems successfully:here is my problem:Lets say you solve an equation using SolveSolve[2x - 1 == 0, x] // N{{x -> 0.5}}How would I then use the result of Solve (0.5) and assign it to a> new variable, like answer for further calculations?I think it has something to do with /. and -> rules of some sort, but> I can't get this simple concept to work!> -Stan ==== =Stan,We have fullsolution = Solve[{x + y == 2, x^2 + y^2 == 10}, {x, y}] {{x -> -1, y -> 3}, {x -> 3, y -> -1}}The full solution contains two answers {x->-1,y->3} and {x->3,y->-1}This lets us state the full solution in a way that relates to the variablesand also lets us do things like a x + b y /. solution {-a + 3 b, 3 a - b}Which gives the results of substituting using each of the two answers.With your example fullsolution = N[Solve[2 x - 1 == 0, x]] {{x -> 0.5}}We can get answer = x /. fullsolution[[1]] 0.5 answer 0.5----------------------- HayesMathematica Training and ConsultingLeicester UKwww.haystack.demon.co.ukhay@haystack.demon.co.ukVoice: +44 (0)116 271 4198> Even though it's frowned upon by the engineering college, i use> mathematica a lot of the stuff that would take pages of code in> another system. I have most basic functions and operations down, but I am> lacking one basic thing I need to do to be able to program more> problems successfully: here is my problem: Lets say you solve an equation using Solve Solve[2x - 1 == 0, x] // N {{x -> 0.5}} How would I then use the result of Solve (0.5) and assign it to a> new variable, like answer for further calculations? I think it has something to do with /. and -> rules of some sort, but> I can't get this simple concept to work!> -Stan> ==== =You can use FindRoot after plotting the graph of your equation.For examplePlot[Exp[-Pi*0.5/x] + Exp[-Pi*3.0/x], {x, 0, 10}]FindRoot[Exp[-Pi*0.5/x] + Exp[-Pi*3.0/x] == 1, {x, 2}]> NSolve[Exp[-Pi*a/x] + Exp[-Pi*b/x] == 1, x]>However, Mathematica is unable to compute the> solution for non-integer values of a and b (e.g. a=1.1, b=1.1; even> a=1.0, b=1.0 doesn't work). Instead, the error message Solve::tdep:> The equations appear to involve the variables to be solved for in an> essentially non-algebraic way. is produced.**************milkcartIn-reply-To: <200211281908.OAA23991@smc.vnet.net> ==== =EH> I am trying to solve the following equation for given values of twoEH> parameters a and b:EH> NSolve[Exp[-Pi*a/x] + Exp[-Pi*b/x] == 1, x]EH> This is straightforward for integer values of the parameters a and bEH> (e.g. a=1, b=1). However, Mathematica is unable to compute theEH> solution for non-integer values of a and b (e.g. a=1.1, b=1.1; evenEH> a=1.0, b=1.0 doesn't work). Instead, the error message Solve::tdep:EH> The equations appear to involve the variables to be solved for in anEH> essentially non-algebraic way. is produced.EH> Can anybody point out a way to overcome this problem and to obtain aEH> solution?Your may wish to use FindRoot.a = 1.1; b = 1.1;FindRoot[Exp[-Pi*a] + Exp[-Pi*b/x] == 1, {x, 1/10^100, 10}]{x -> 107.748}a = Random[Real, 1, 1000];b = Random[Real, 1, 1000];FindRoot[Exp[-Pi*a] + Exp[-Pi*b/x] == 1, {x, 1/10^100, 10}]{x -> 0.741772}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 ==== =Indeed, NSolve gives a list of numerical approximations to the roots of apolynomial equation (cf. OnLine Help). Use instead FindRoot, and of courseyou'll have to supply numerical values for a and b, as well as initialvalues. This shouldn't be difficult if you begin by plotting your functionto see where to set initial values for the root finding process. Forexample, if you defineIn[1]:=g[x_, a_, b_] := Exp[(-Pi)*(a/x)] + Exp[(-Pi)*(b/x)] - 1and plot this function, say for a = 2.5 and b = 3.0, you'll find that theroot lies somewhere between 11 and 13:In[2]:=Plot[g[x, 2.5, 3.], {x, 1, 15}, PlotRange -> {{8, 15}, {-1, 1}}];Then use FindRoot:In[3]:=FindRoot[g[x, 2.5, 3.] == 0, {x, {11, 13}}]Out[3]={x -> 12.428204959984097}Tomas GarzaMexico City----- Original Message -----> a=1.0, b=1.0 doesn't work). Instead, the error message Solve::tdep:> The equations appear to involve the variables to be solved for in an> essentially non-algebraic way. is produced. Can anybody point out a way to overcome this problem and to obtain a> solution? Eva ==== =Eva,Instead of NDSolve you could try something like this...f[a_, b_] := Exp[-Pi*a/x] + Exp[-Pi*b/x] Plot[f[1.1,2.5]-1,{x,0,10}];FindRoot[f[1.1, 2.5] == 1, {x, 6}]{x -> 7.71189}David Parkdjmp@earthlink.nethttp://home.earthlink.net/~djmp/ Can anybody point out a way to overcome this problem and to obtain asolution?Eva ==== =Does somebody know an algorithm to simplify the product Sqrt[a]*Sqrt[b] ?With many thanksGernot ==== =If i go:x [CTRL]+_i get index-mode.Power-mode is obtained byx [CTRL]+^However, i don't know how to enter those twodirectly above eachother. Is it possible?Also - [Integral] gives me a nice sign but whatdo i type to get an integral with limits? LaTeXsytax is supposed to work but i didn't succeeded...--V.8anligenKonrad------------------- ==== =Using Mathematica 4.2 under Jaguar Mac OS X 10.2, I am unable to print anything on my LaserWriter 8500 both with AppleTalk or TCP/IP connection. MS Word prints without problem. What happens?-- Daniel AMIGUET Avenue du L.8eman 59 CH 1005 Lausanne +41 21/728 0730Reply-To: ng ==== = Store your graphic in a variable, then add to it the necessary graphicsprimitives using a Show[ ] command.graph1=...your graphic...maxx=your maximum xShow[{graph1, Graphics[{ Line[{{0,-.1},{maxx,-.1}}],Line[{{0,-.2},{maxx,-.2}}]}]}]; Luck,Nicholas For reasons too involved to go into, I need to produce a plot with 4> horizontal scales running in parallel along the bottom edge. I would> appreciate recipes/suggestions for doing this.> kj> ==== =honestly say that this seems like an unbelievably powerful combination. There are, shall we say, issues. Nonetheless, once I get used to what best goes into Java Code, and what best goes into Mathematica, I believe this will redefine my idea of what Mathematica graphics are. I'm not sure how much direct mapping I can do between Mathematica's native graphics functions and Java 3D. I don't know much about extracting data from Mathematica's graphics. If I can get a raw numeric representation of Mathematicas graphics, it should be fairly easy to feed this to Java3D. This is cool! -- STHHatton's Law: There is only One inviolable Law. ==== =Dear MathGroupI have the task of plotting dipole magnetic field lines in 3Dspherical coordinate system. Before I actually start with my work, I was trying learnwith the following simple code:ex=-y[t];ey=x[t];x0=1.0;y0=1.0;t1=6;lines = FieldLine[ {x[t], ex, x0}, {y[t], ey, y0}, {t, t1}];c=Show[Graphics[lines, AspectRatio -> Automatic, Frame -> True]];a=Show[AddArrow[lines, 0.5]];In these command lines, c plots contour plot. But a gives thefollowing message:Show::gcomb: An error was encountered in combining the graphics objects in Show[{Arrow[{0.570594, 1.29399}, <<3>, HeadLength -> 4], <<4>}].If any knows the solution to this problem please let me know. I use Gangadhara-- _____________________________________________________________ ______________Bangalore - 560034, Indiahttp://www.iiap.ernet.in/personnel/ganga/ganga.html_____ _____________________________________________________________ ________ ==== =I have two lists (in general of different length) that have thefollowing structure Random[Integer, {1, 2000}]}, {100}]; Random[Integer, {1, 2000}]}, {200}];I am then interested in obtaining all the strings in s1 that matchwith those in s2. At the present time I use the following agorithm tofind the matchesmyList = Flatten[Outer[List, s1, s2, 1], 1];Select[myList,(First[First[#]] == First[Last[#]]) &]This works fine, but when s1 and s2 are large ( e.g. 3000 or moreelements) then Outer seems inefficient. My question: does anyone havea suggestion that would be more efficient than my kludge approach.Note I have tried Intersection, which finds all the matches, i.e.myList2 = Intersection[s1,s2, SameTest -> (#1[[1]] == #2[[1]] &)];But I have not been successful in selecting a