A45 == The more I play with the example the more depressing it gets. Start> with ßoating point numbers but explicitely arbitrary-precision ones.> In[1]:=> a=77617.00000000000000000000000000000;> b=33095.00000000000000000000000000000;> In[3]:=> !(333.7500000000000000000000000000000 b^6 + a^2 ((11 a^2> b^2 - > b^6 - 121 b^4 - 2)) + 5.500000000000000000000000000000 b^8 +> a/(2> b))> Out[3]=> !((-4.78339168666055402578083604864320577443814`26.6715 *^32))> In[4]:=> Accuracy[%]> Out[4]=> -6> Due to the manual section 3.1.6:> When you do calculations with arbitrary-precision numbers, as> discussed in the previous section, Mathematica always keeps track of> the precision of your results, and gives only those digits which are> known to be correct, given the precision of your input. When you do> calculations with machine-precision numbers, however, Mathematica> always gives you a machine[CapitalEth]precision result, whether or not all the> digits in the result can, in fact, be determined to be correct on the> basis of your input. > Because I started with arbitrary-precision numbers Mathematica should display> only those digits that are correct, that is none.No, 26 digits are correct (check Precision instead of Accuracy to seethis).You appear to be showing output in InputForm. If you use OutputForm orStandardForm only 26 digits will be shown. 32Out[3]= -4.7833916866605540257808360 10InputForm is showing more because it exposes bad digits as well asgood ones.> To relax a bit, set a new input cell to StandardForm and type> 77617.000000000000000000000000000000000> Convert it to InputForm. You get> 77616.999999999999999999999999999999999999999999952771` 37.9031> Convert back to StandardForm> 77616.99999999999999999999999999999999999999999976637`37.9031 > Again to InputForm> 77616.99999999999999999999999999999999999999999963735`37.9031 > Back to StandardForm> 77616.99999999999999999999999999999999999999999951376`37.9031 > See what you can get if you have enough patience or a small program.> PKAgreed, it's not very pretty. I am uncertain as to whether thisindicates a bug in StandardForm or elsewhere in the underlying numericscode, and will defer to our numerics experts on that issue. My guess isit is a bug if only because it violates the spirit of IEEE arithmeticwherein ßoats that have integer values should be representable as such(or something to that effect). I will point out, however, that the twonumbers in question are equal to the specified precision. Also itappears to be improved in our development kernel.Daniel LichtblauWolfram Research ==== The more I play with the example the more depressing it gets. Startwith ßoating point numbers but explicitely arbitrary-precision ones.In[1]:=a=77617.00000000000000000000000000000;b= 33095.00000000000000000000000000000;In[3]:=!( 333.7500000000000000000000000000000 b^6 + a^2 ((11 a^2b^2 - b^6 - 121 b^4 - 2)) + 5.500000000000000000000000000000 b^8 +a/(2 b))Out[3]=!((- 4.78339168666055402578083604864320577443814`26.6715*^32)) In[4]:=Accuracy[%]Out[4]=-6Due to the manual section 3.1.6:When you do calculations with arbitrary-precision numbers, asdiscussed in the previous section, Mathematica always keeps track ofthe precision of your results, and gives only those digits which areknown to be correct, given the precision of your input. When you docalculations with machine-precision numbers, however, Mathematicaalways gives you a machine[CapitalEth]precision result, whether or not all thedigits in the result can, in fact, be determined to be correct on thebasis of your input. Because I started with arbitrary-precision numbers Mathematica should displayonly those digits that are correct, that is none.To relax a bit, set a new input cell to StandardForm and type 77617.000000000000000000000000000000000Convert it to InputForm. You get77616.999999999999999999999999999999999999999999952771` 37.9031Convert back to StandardForm 77616.99999999999999999999999999999999999999999976637`37.9031 Again to InputForm 77616.99999999999999999999999999999999999999999963735`37.9031 Back to StandardForm 77616.99999999999999999999999999999999999999999951376`37.9031 See what you can get if you have enough patience or a small program.PK ==== > The more I play with the example the more depressing it gets. Start> with ßoating point numbers but explicitely arbitrary-precision ones.> In[1]:=> a=77617.00000000000000000000000000000;> b=33095.00000000000000000000000000000;> In[3]:=> !(333.7500000000000000000000000000000 b^6 + a^2 ((11 a^2> b^2 - > b^6 - 121 b^4 - 2)) + 5.500000000000000000000000000000 b^8 +> a/(2> b))> Out[3]=> !((-4.78339168666055402578083604864320577443814`26.6715 *^32))> In[4]:=> Accuracy[%]> Out[4]=> -6> Due to the manual section 3.1.6:> When you do calculations with arbitrary-precision numbers, as> discussed in the previous section, Mathematica always keeps track of> the precision of your results, and gives only those digits which are> known to be correct, given the precision of your input. When you do> calculations with machine-precision numbers, however, Mathematica> always gives you a machine[CapitalEth]precision result, whether or not all the> digits in the result can, in fact, be determined to be correct on the> basis of your input. > Because I started with arbitrary-precision numbers Mathematica should display> only those digits that are correct, that is none.I retract the above comment. I did not notice that was an error in the input. b=33095.00000000000000000000000000000intstead of intended b=33096.00000000000000000000000000000I am sorry for the mistake.PK> To relax a bit, set a new input cell to StandardForm and type > 77617.000000000000000000000000000000000> Convert it to InputForm. You get> 77616.999999999999999999999999999999999999999999952771` 37.9031> Convert back to StandardForm> 77616.99999999999999999999999999999999999999999976637`37.9031 > Again to InputForm> 77616.99999999999999999999999999999999999999999963735`37.9031 > Back to StandardForm> 77616.99999999999999999999999999999999999999999951376`37.9031 > See what you can get if you have enough patience or a small program.> PK ==== > The last part of my message you are quoting was completely wrong, as > was pointed out by Allan Hayes. Mathematica does not track precision of > machine arithmetic computations. In order for Mathematica to give > reliable information about the precision of a computation you have to > explicitly set the precision of all the numerical quantities.> Your own example at the bottom simply shows you have not understood the > evaluation mechanism of Mathematica. Just opposite, thanks to you and other participants, I completelyunderstood it. SetAccuracy just takes anything and calls it accurate.This behavior is useless if not stupid. It was apparently intended byMathematica developers but that doesn't make it right.On a side note, I hate the argument It is descibed in the manual,therefore it is correct. Legal doesn't mean right. Besides there isno supreme court here to overrule some stupid law. :-)PK> [...] ==== >Dear Colleagues,>>I calculated:>>Sum[1/Prime[n], {n, 15000}] // N>>Result: 2.74716>>Now I wonder if this sum will converge or keep on growing, albeit very>slowly.>Matthias Bode>Sal. Oppenheim jr. & Cie. KGaA>Koenigsberger Strasse 29>D-60487 Frankfurt am Main>GERMANY>Mobile: +49(0)172 6 74 95 77>Internet: http://www.oppenheim.de>The serie is divergent!I suggest you to look at this beautiful introduction to primes distributionhttp://www.maths.ex.ac.uk/%7Emwatkins/zeta/ vardi.htmlBye, robRoberto BrambillaCESIVia Rubattino 5420134 Milanotel +39.02.2125.5875fax +39.02.2125.5492rlbrambilla@cesi.it ==== > 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>>Steven,Directory[]returns the current directory$Pathreturns the directories in your path where files can be found.SetDirectory[]changes to the specified directory and makes it the current directory.FileNames[]returns a list of all the file names (text documents, picture documentsetc) and subdirectory (folder) names in the current directory.Since FileNames returns a list of elements, you can use all sorts of teststo see if a file you're looking for is in a said directory or not orwhether it is a subdirectory or not.I hope that this will get you started.Yas ==== has anybody tried to modify the classes.m package in the way, it wouldbe possible to have several superclasses?Oleg. ==== What does this page say, auf Englisch? I only pretend to understand German.http://www.mertig.com/neu/HTMLLinks/index_6.htmlSTH ==== The sum diverges. See Elementary Number Theory, 5th edition by David M.Burton, pages 355-356.-----Original Message-----Sal. Oppenheim jr. & Cie. KGaAKoenigsberger Strasse 29D-60487 Frankfurt am MainGERMANYMobile: +49(0)172 6 74 95 77Internet: http://www.oppenheim.de ==== Technical support has responded to my query. They say that one of thesimplifications that Mathematica does when using Simplify is to Factor theexpression, and factoring an expression consisting of inexact numbers leadsto the type of behavior I observed. They stated that changing the behaviorof Simplify to avoid the problems I noticed would make Simplify lesscapable, and that the majority of users would prefer to have Simplify behavethe way it currently does.Of course, that doesn't answer the question about why the number of terms inthe expression would cause the coefficients to go from rational to inexactto rational again.At any rate, I have another lesson learned. When using Simplify, check theresult if you are mixing infinite precision and inexact numbers, as theresult may not be what you wanted. In the past I always assumed that theresult of using Simplify on an expression produced a result equivalent tothe original expression, but now I discover that this is not true.Carl WollPhysics DeptU of Washington----- Original Message -----> {i, > n}]], x[1]]>> Now lets try CW for the first 100 values of n:> In[30]:=> Table[CW[n], {n, 100}]>> Out[30]=> {1/2, 1/2, 1/2, 1/2, 1/2, 1/2, 1/2, 1/2, 1/2, 1/2, 1/2, 1/2,> 0.5`12.3085, 0.5`12.0074, 0.5`11.7064, 0.5`11.4054,> 0.5`11.1043, 0.5`10.8033, 0.5`10.5023, 0.5`10.2012,> 0.5`9.9002, 0.5`9.5992, 0.5`9.2982, 0.5`8.9971,> 0.5`8.6961, 0.5`8.3951, 0.5`8.094, 0.5`7.793, 0.5`7.492,> 0.5`7.1909, 0.5`6.8899, 0.5`6.5889, 0.5`6.2879,> 0.5`5.9868, 0.5`5.6858, 0.5`5.3848, 0.5`5.0837,> 0.5`4.7827, 0.5`4.4817, 0.5`4.1806, 0.5`3.8796,> 0.5`3.5786, 0.5`3.2776, 0.5`2.9765, 0.5`2.6755,> 0.5`2.3745, 0.5`2.3745, 0.5`1.7724, 0.5`1.7724,> 0.5`1.1703, 0.5`1.1703, 0.5`0.5683, 0``0.1423, 0``0.1423,> 0``0.1423, 1/2, 1/2, 1/2, 1/2, 1/2, 1/2, 1/2, 1/2, 1/2,> 1/2, 1/2, 1/2, 1/2, 1/2, 1/2, 1/2, 1/2, 1/2, 1/2, 1/2,> 1/2, 1/2, 1/2, 1/2, 1/2, 1/2, 1/2, 1/2, 1/2, 1/2, 1/2,> 1/2, 1/2, 1/2, 1/2, 1/2, 1/2, 1/2, 1/2, 1/2, 1/2, 1/2,> 1/2, 1/2, 1/2}>> In[31]:= Map[Length,Split[#]]>> Out[31]=> {12,43,45}>> This is indeed curious.The problem seems to occur for values between 13> and 55 and then go away (for good???) At first I thought it maybe in> some fascinating way related to some properties of the integer n, but> now I am not sure. It certainly worth a careful examination. I hope> whoever discovers the cause of this will let us know.>> Andrzej>> Andrzej Kozlowski> Yokohama, Japan> http://www.mimuw.edu.pl/~akoz/> http://platon.c.u-tokyo.ac.jp/andrzej/>> To Technical Support and the Mathematica User community,>> I'm writing to report what I consider to be a bug. First, I want to> show a> simplified example of the problem. Consider the following expression:>> expr=0.22 + x[0] + (3*(-0.16+ x[1]))/4 + (9*(0.546 + x[2]))/16;>> When simplified I expected to get some real number plus> x[0]+3x[1]/4+9x[2]/16, but instead I get the following:>> Simplify[expr]> 0.407125 + x[0] + 0.75 x[1] + 0.5625 x[2]> >> As you can see, for some reason Mathematica converted the fractions> 3/4 and> 9/16 to real machine numbers. I consider this to be a bug.>> Now, for an example more representative of the situation that I've been> coming across.>> expr12 = 1.001`17 + Sum[(x[i] - 1.001`17)/2^i, {i, 12}];> expr13 = 1.001`17 + Sum[(x[i] - 1.001`17)/2^i, {i, 13}];> expr55 = 1.001`17 + Sum[(x[i] - 1.001`17)/2^i, {i, 55}];>> As you can see, I have replaced the real numbers by extended precision> numbers. The simplified example above demonstrates that the problem> exists> when using machine numbers. Now, we'll see what happens when we use> arbitrary precision numbers. First, let's simplify the expression with> 12> terms.>> Simplify[expr12]> (1.0010000000000 + 2048 x[1] + 1024 x[2] + 512 x[3] + 256 x[4] + 128> x[5] +>> 64 x[6] + 32 x[7] + 16 x[8] + 8 x[9] + 4 x[10] + 2 x[11] + x[12])> / 4096>> As you can see, a sum with 12 terms upon simplification has> coefficients> which are still integers as they should be. However, increasing the> number> of terms to 13 yields>> Simplify[expr13]> 0.0001221923828125 + 0.500000000000 x[1] + 0.250000000000 x[2] +>> 0.1250000000000 x[3] + 0.0625000000000 x[4] + 0.0312500000000 x[5] +>> 0.01562500000000 x[6] + 0.00781250000000 x[7] + 0.00390625000000> x[8] +>> 0.001953125000000 x[9] + 0.000976562500000 x[10] + 0.000488281250000> x[11]> +>> > 0.000244140625000 x[12] + 0.0001220703125000 x[13]>> Now, all of the coefficients are converted to real numbers,> replicating the> bug from the simplified example. Finally, let's see what happens when> we> have 55 terms. Rather than putting the resulting expression here, I> will> just leave it at the end of the post. The result though is somewhat> surprising. Each of the coefficients of the x[i] are again real> numbers, but> now their precision is only 0! The proper result of course is the sum> of> some real number (with a precision close to 0 due to numerical> cancellation)> and an expression consisting of rational numbers multiplied by x[i].> The> loss of precision of the coefficients of the x[i] is precisely what> > occurred> to me. Of course, in this simple example, simply using Expand instead> of> Simplify produces the expected result, and is my workaround. I hope you> agree with me that this is a bug, and one that Wolfram needs to> correct.>> Carl Woll> Physics Dept> U of Washington>> Simplify[expr55]> -16 -1 -1 -1> 0. 10 + 0. x[1] + 0. x[2] + 0. 10 x[3] + 0. 10 x[4] + 0. 10> x[5] +> >> -2 -2 -2 -3 -3> 0. 10 x[6] + 0. 10 x[7] + 0. 10 x[8] + 0. 10 x[9] + 0. 10> x[10]> +>> -3 -3 -4 -4> -4> 0. 10 x[11] + 0. 10 x[12] + 0. 10 x[13] + 0. 10 x[14] + 0. 10> x[15] +>> -5 -5 -5 -6> -6> 0. 10 x[16] + 0. 10 x[17] + 0. 10 x[18] + 0. 10 x[19] + 0. 10> x[20] +>> -6 -6 -7 -7> -7> 0. 10 x[21] + 0. 10 x[22] + 0. 10 x[23] + 0. 10 x[24] + 0. 10> x[25] +>> -8 -8 -8 -9> -9> 0. 10 x[26] + 0. 10 x[27] + 0. 10 x[28] + 0. 10 x[29] + 0. 10> x[30] +>> -9 -9 -10 -10> 0. 10 x[31] + 0. 10 x[32] + 0. 10 x[33] + 0. 10 x[34] +>> -10 -11 -11 -11> 0. 10 x[35] + 0. 10 x[36] + 0. 10 x[37] + 0. 10 x[38] +>> -12 -12 -12 -12> 0. 10 x[39] + 0. 10 x[40] + 0. 10 x[41] + 0. 10 x[42] +>> -13 -13 -13 -14> 0. 10 x[43] + 0. 10 x[44] + 0. 10 x[45] + 0. 10 x[46] +>> -14 -14 -15 -15> 0. 10 x[47] + 0. 10 x[48] + 0. 10 x[49] + 0. 10 x[50] +>> -15 -15 -16 -16> -> 16> 0. 10 x[51] + 0. 10 x[52] + 0. 10 x[53] + 0. 10 x[54] +> 0. 10> x[55]> >> ==== Dear CarlYou have discovered what is perhaps a bug but maybe something even mor einteresting . However, I think you stopped your investigation a little prematurely. Here is a function that just computes the coefficient of x[1] in your Simplified expression for various values of n:CW[n_] := Coefficient[Simplify[1.001`17 + Sum[(x[i] - 1.001`17)/2^i, {i, n}]], x[1]]Now lets try CW for the first 100 values of n:In[30]:=Table[CW[n], {n, 100}]Out[30]={1/2, 1/2, 1/2, 1/2, 1/2, 1/2, 1/2, 1/2, 1/2, 1/2, 1/2, 1/2, 0.5`12.3085, 0.5`12.0074, 0.5`11.7064, 0.5`11.4054, 0.5`11.1043, 0.5`10.8033, 0.5`10.5023, 0.5`10.2012, 0.5`9.9002, 0.5`9.5992, 0.5`9.2982, 0.5`8.9971, 0.5`8.6961, 0.5`8.3951, 0.5`8.094, 0.5`7.793, 0.5`7.492, 0.5`7.1909, 0.5`6.8899, 0.5`6.5889, 0.5`6.2879, 0.5`5.9868, 0.5`5.6858, 0.5`5.3848, 0.5`5.0837, 0.5`4.7827, 0.5`4.4817, 0.5`4.1806, 0.5`3.8796, 0.5`3.5786, 0.5`3.2776, 0.5`2.9765, 0.5`2.6755, 0.5`2.3745, 0.5`2.3745, 0.5`1.7724, 0.5`1.7724, 0.5`1.1703, 0.5`1.1703, 0.5`0.5683, 0``0.1423, 0``0.1423, 0``0.1423, 1/2, 1/2, 1/2, 1/2, 1/2, 1/2, 1/2, 1/2, 1/2, 1/2, 1/2, 1/2, 1/2, 1/2, 1/2, 1/2, 1/2, 1/2, 1/2, 1/2, 1/2, 1/2, 1/2, 1/2, 1/2, 1/2, 1/2, 1/2, 1/2, 1/2, 1/2, 1/2, 1/2, 1/2, 1/2, 1/2, 1/2, 1/2, 1/2, 1/2, 1/2, 1/2, 1/2, 1/2, 1/2}In[31]:= Map[Length,Split[#]]Out[31]={12,43,45}This is indeed curious.The problem seems to occur for values between 13 and 55 and then go away (for good???) At first I thought it maybe in some fascinating way related to some properties of the integer n, but now I am not sure. It certainly worth a careful examination. I hope whoever discovers the cause of this will let us know.AndrzejAndrzej KozlowskiYokohama, Japanhttp://www.mimuw.edu.pl/~akoz/http:// platon.c.u-tokyo.ac.jp/andrzej/> To Technical Support and the Mathematica User community,>> I'm writing to report what I consider to be a bug. First, I want to > show a> simplified example of the problem. Consider the following expression:>> expr=0.22 + x[0] + (3*(-0.16+ x[1]))/4 + (9*(0.546 + x[2]))/16;>> When simplified I expected to get some real number plus> x[0]+3x[1]/4+9x[2]/16, but instead I get the following:>> Simplify[expr]> 0.407125 + x[0] + 0.75 x[1] + 0.5625 x[2]>> As you can see, for some reason Mathematica converted the fractions > 3/4 and> 9/16 to real machine numbers. I consider this to be a bug.>> Now, for an example more representative of the situation that I've been> coming across.>> expr12 = 1.001`17 + Sum[(x[i] - 1.001`17)/2^i, {i, 12}];> expr13 = 1.001`17 + Sum[(x[i] - 1.001`17)/2^i, {i, 13}];> expr55 = 1.001`17 + Sum[(x[i] - 1.001`17)/2^i, {i, 55}];>> As you can see, I have replaced the real numbers by extended precision> numbers. The simplified example above demonstrates that the problem > exists> when using machine numbers. Now, we'll see what happens when we use> arbitrary precision numbers. First, let's simplify the expression with > 12> terms.>> Simplify[expr12]> (1.0010000000000 + 2048 x[1] + 1024 x[2] + 512 x[3] + 256 x[4] + 128 > x[5] +>> 64 x[6] + 32 x[7] + 16 x[8] + 8 x[9] + 4 x[10] + 2 x[11] + x[12]) > / 4096>> As you can see, a sum with 12 terms upon simplification has > coefficients> which are still integers as they should be. However, increasing the > number> of terms to 13 yields>> Simplify[expr13]> 0.0001221923828125 + 0.500000000000 x[1] + 0.250000000000 x[2] +>> 0.1250000000000 x[3] + 0.0625000000000 x[4] + 0.0312500000000 x[5] +>> 0.01562500000000 x[6] + 0.00781250000000 x[7] + 0.00390625000000 > x[8] +>> 0.001953125000000 x[9] + 0.000976562500000 x[10] + 0.000488281250000 > x[11]> +>> 0.000244140625000 x[12] + 0.0001220703125000 x[13]>> Now, all of the coefficients are converted to real numbers, > replicating the> bug from the simplified example. Finally, let's see what happens when > we> have 55 terms. Rather than putting the resulting expression here, I > will> just leave it at the end of the post. The result though is somewhat> surprising. Each of the coefficients of the x[i] are again real > numbers, but> now their precision is only 0! The proper result of course is the sum > of> some real number (with a precision close to 0 due to numerical > cancellation)> and an expression consisting of rational numbers multiplied by x[i]. > The> loss of precision of the coefficients of the x[i] is precisely what > occurred> to me. Of course, in this simple example, simply using Expand instead > of> Simplify produces the expected result, and is my workaround. I hope you> agree with me that this is a bug, and one that Wolfram needs to > correct.>> Carl Woll> Physics Dept> U of Washington>> Simplify[expr55]> -16 -1 -1 -1> 0. 10 + 0. x[1] + 0. x[2] + 0. 10 x[3] + 0. 10 x[4] + 0. 10 > x[5] +>> -2 -2 -2 -3 -3> 0. 10 x[6] + 0. 10 x[7] + 0. 10 x[8] + 0. 10 x[9] + 0. 10 > x[10]> +>> -3 -3 -4 -4 > -4> 0. 10 x[11] + 0. 10 x[12] + 0. 10 x[13] + 0. 10 x[14] + 0. 10> x[15] +>> -5 -5 -5 -6 > -6> 0. 10 x[16] + 0. 10 x[17] + 0. 10 x[18] + 0. 10 x[19] + 0. 10> x[20] +>> -6 -6 -7 -7 > -7> 0. 10 x[21] + 0. 10 x[22] + 0. 10 x[23] + 0. 10 x[24] + 0. 10> x[25] +>> -8 -8 -8 -9 > -9> 0. 10 x[26] + 0. 10 x[27] + 0. 10 x[28] + 0. 10 x[29] + 0. 10> x[30] +>> -9 -9 -10 -10> 0. 10 x[31] + 0. 10 x[32] + 0. 10 x[33] + 0. 10 x[34] +>> -10 -11 -11 -11> 0. 10 x[35] + 0. 10 x[36] + 0. 10 x[37] + 0. 10 x[38] +>> -12 -12 -12 -12> 0. 10 x[39] + 0. 10 x[40] + 0. 10 x[41] + 0. 10 x[42] +>> -13 -13 -13 -14> 0. 10 x[43] + 0. 10 x[44] + 0. 10 x[45] + 0. 10 x[46] +>> -14 -14 -15 -15> 0. 10 x[47] + 0. 10 x[48] + 0. 10 x[49] + 0. 10 x[50] +>> -15 -15 -16 -16 > -> 16> 0. 10 x[51] + 0. 10 x[52] + 0. 10 x[53] + 0. 10 x[54] + > 0. 10> x[55]> ==== I think, for input of that many numbers (and other inputs), I might usean input file that has textual names or descriptions in the first ten ortwenty columns, followed by values starting at a fixed column afterthat. Mathematica or Java could easily read inputs from that, and ahuman could read it as well. If you're concerned that a human mightjumble the file format -- accidentally deleting lines, etc. -- a programcould key on the names or descriptions rather than trusting them to bein correct order, and point out missing values. A strategy like thatallows you to start with a previous input file (not from scratch) andchange only what needs to change.Also, Mathematica 4.2 adds XML support to the picture, and that might beuseful.Bobby-----Original Message----->> I agree with Mr. Kuska, that the system Mr Nagesh describes is not> userfriendly. But I think, the suggestions of Mr. Kuska do not makeitmore> userfriendly, rather the opposite is true.>> Mr. Nagesh asks>> Is any body here have expertise or information about the capabilityof> > Mathematica as a system simulation tool?> Mr. Kuska answers:> Since the most system simulation tools are simply solving asystem of> ordinary differntial equations it is simple to do this withNDSolve[].>> My comment:>> That is: He sees the simulation system merely as a set ofdifferential> equations.>> hmm, since the original poster write>> My refrigeration system simulation package is likely to have> approximately 60 First order Differential equations.>> it seems not completly wrong to assume that the system consists of> of ode's ..>Yout should not ignore the word merely.It is not enough to have a set 60 differential equations and a set of200-250 numbers. That is not simulation system, which can be used byuserswith the exception, perhaps, of the programmer of the system himself.How does e.g. the user know what meaning a number in the set has, oughthecount the numbers from the beginning?Your nice command shows only, if there is an input, which is not anumber.But I think the user would like to know, which of the 200 elements arenotnumbers.The only good of your command is, that it looks nice and shows yourknowledge!>> The question of Mr. Nagesh:>> My 4th Objective:- How can I program the check for correctness ofthe> input values supplied by the package user ?> The answer of Mr. Kuska is:> And @@ (NumericQ /@ {aListOfAllYourNumericParameters})>> My comment:>> This is a nice command and shows the knowledge of Mr.Kuska. But doesMr.> Nagesh understand it and is it sufficient to check, if all inputsare> numerical?>> It seems you have a deeper knowlege about the things that Mr. Nagesh> understand. You know him personally ? It is not very polite to> make speculations *what* a other person understand.>> And no it is not sufficent to check that all parameters are numbers.> Typical paramters described by intervals, where the assumptions of> a model are valid. But for this checks one needs more knowlege> about the meaning of the parameters. And one needs the knowlege about> the differntial equations, to find out the eigenvalues of the jacobian> ...> Additionally I think, it is not userfriendly to see the input merelyasa> set of 200-250 numbers.>> My suggestion is, that JLink is used, a suggestion Mr. Kusk takesinto> consideration, too.>> That will be fast as lightning !> But further I suggest, that classes are defined in Java, whichrepresentthe> parts of the system.>> That is notable nonsense! When the differntial equations should be> solved with Mathematica, the parts can't be Java classes.Mathematica's> NDSolve[] need a explicit expression to integrate the equations.That's not nonsense, the Mathematica program does not fetch the classesbutthe numbers in the classes (or better in the objects).inthe Java classes in textform. They can then be fetched from theMathematicaprogram and transformed into expressions by the Command ToExpression.The aim is, to have a clear separation of the system into components,whichare manageable and understandable.>> OK you can call a Java class member from Mathematica but this will> be incredible slow when the right hand side is evaluated 200-300> times and every evaluation make several callbacks to the Java source.> Event handler of the Java main program (without some modification in> the event loop) while it is evaluating an other command.My idea is to fetch the values once from the Java objects at thebeginning.200-250 numbers is not so much..> Constructors of the classes should build objects with defaultvalues.>> That's a great idea. If a simulation run should be documented, one> always> need the full listing of the Java source to find the actual parameter> settings.That is not my opinion. I think not every user of the simulation systemshould have to know Java and Mathematica.The user must look for the values in the objects. And the values are intheobjects, if they come from the constructor or from the graphical userinterface.I think, there should be listings of the objects including names of thevariables. In the objects the values are in an meaningful environment.>> Graphical user interfaces> should give the opportunity to change the data fields in the objectsand> check the input for correctness.>> *and* what has a GUI for 200-250 variables to do with Mathematica ?> BTW one has typical much less variables because many parameters> are fixed and it make no sense to change, for example, material> constants of materials that can't exchanged> The system should give the opportunity, to store the objects onharddisk> (serialization).>> accessed directly.> Can you be so kind, to explain *how* your posting help a person that> ask How can I build a simulation system with Mathematica ?>> You *can* say Don't use Mathematica, use Java! but this has nothing> to do with the question or with my reply.It is you, who proposes to solve the problem with C/C++ and not to useMathematica (see below!)My point of view is:Use Mathematica, for what Mathemtica is good, and Java, for what Java isgood.Mathematica is not so good as Java for data entry and Java is betterthanMathematica to represent the simulation system (by objects).>> But I still would suggest to use C/C++ and a numerical> ode-solver, make a fancy GUI/Script> interface and don't use Mathematica for such a simple task.> The ode-solver is the smallest part of such a simulation system.>> Jens> My name is Nagesh and pursuing research studies inRefrigeration. At> > present I am writing a Dynamic Refrigeration System SimulationPackage.> I> am using Mathematica as a programming language for the samesincelast> one> > year. I don't have any programming experience before this. Ihave> following> querries:-> 1. Is any body here have expertise or information about thecapability> of> Mathematica as a system simulation tool?>> Since the most system simulation tools are simply solving asystemof> ordinary differntial equations it is simple to do this withNDSolve[].>> 2. Is is possible to program a user friendly interface for mysystem> simulation package with Mathematica or I have to use some other> software?>> Write a MathLink or J/Link frontend that launch the kernel. Butyou> should keep> in mind that the user interface is typical 80-90 % of your code.> If you just whant to solve some ode's it is probably easyer to> include one of the excelent ode-solvers from netlib in your C-code> than to call Mathematica to do that. As long as you dont wish tochange> the ode's very often (than Mathematica is more ßexible) youshould> not use Mathematica.>> 3. My refrigeration system simulation package is likely to have> approximately 60 First order Differential equations. Is ispossibleto> > solve these in Mathematica ?>> Sure.> If yes then can anybody here guide me about> this further.> >> Write down the equations and call NDSolve[].>> >> I am explaining below in short about the objectives I want tofulfill> from> coding out of my main input file>> 1. Example from Main Input File ( this will contain about200-250> variables> which will be entered by the user of this package)>> This sounds like a *very* userfiendly interface ;-)> > Below is examples of two variables entered into this file, whichwill be> used in other analysis files for further evaluation.>> 2. Example from other analysis file ( there will be about 20-25other> such> component analysis files ) where the above mentioned variablesfrommain> input file will be used for further evaluations:->> Below is one example from this file explaining how the variablesfrom> main> input file will be used in other files.>> I hope that this short information will be useful for guiding meto> solve> the following problems that I am facing. I am facing follwingproblems> or> objectives:->> 1. My 1st Objective:- The user of this package must be able tochange> only> the value of the variable in the main input file but he must notbeable> to> change the name of the variable itself. For example he must beableto> change the value of the variable but he must not be able tochange> the> name of this variable itself.> > Here our problem is how to achieve or program it so that ourobjective> will> be fullfilled.>> Options with defaulf values ? or something like>> {aParam,bParam}={ODEParameter1,ODEParameter2} /.> userRules /.> {ODEParameter1->1,ODEParameter2->2}>> >> 2. My 2nd Objective:- How I can program the main input file sothatit> will> be user friendly in terms of its visuals and satisfying theconstraint> mentioned above in objective1.>> What is *userfiendly* in a file with 250 variables ???> 3. My 3rd Objective:- How can I program the optional values foreach> > variable in the main input file ? so that there will be always avalue> assigned to each variable listed in main input file whenever theuser> opens> up this file. If user want to change the values of somevariablesthen> he> can change them and run the simulation otherwise the simulationrunwill> be> > done with optional values assigned to each variable in the inputfile.>> See above.> 4. My 4th Objective:- How can I program the check forcorrectness ofthe> input values supplied by the package user ?> >> And @@ (NumericQ /@ {aListOfAllYourNumericParameters})> Jens> >> ==== hi> AFAIK, Mac OS is now BSD or something like that. That makes it almost> certain that it could support QT. As I pointed out in another post, I can> run the KDE on Windows XP. I haven't been in the trenches with the Qt> impression is, it really is Ôcode once, run everywhere'.i've checked the trolltech hp. qt fully supports the following OS:MS Windows 95/98/Me, NT4, 2000 and XP. Mac OS X. > This is one of the reasons I am such a Mozilla fan. Konqueror works quite> like. But Mozilla runs everywhere with more or less a uniform look and> feel. Yes, Mozilla is written with Gtk and not with Qt, but that just> shows that WRI has options.i'm not sure if it is allowed to create a closed-source product like the mathematica fronend based on a gpl'ed library like gtk. with qt you have the possibility to buy licenses for the commercial version of qt, allowing you to create closed-source apps. > I'm a KDE fan. I've used the KDE since it was in alpha 0.4. I remember> back when it would compile in a few minutes on a pentium II. Now it takes> several hours on a P4. i started with beta1 (if i remember correctly) - sure it is really big now, but i think kde is still far away from being bloated..... imagine the mathematica frontend being seamlessly integrated into the linux ui's look and feel.... > I've always hated motif. The file chooser simply stinks. And that's just a> start.the whole motif ui stinks....:-)gerald************************************* Gerald RothM@th Desktop Development************************************* ==== > hi,> moving the frontend over to QT would have some neat side effects:> consistent look & feel with the modern linux gui, themeability, source> antialiased> truetype fonts as QT supports Xrender and Xft (looks great - see KDE3). i> think all of those points are of value, but the most important might be> source compatibility. ONE frontend for MOST (or ALL) platforms - sounds> like a dream :-))AFAIK, Mac OS is now BSD or something like that. That makes it almost certain that it could support QT. As I pointed out in another post, I can run the KDE on Windows XP. I haven't been in the trenches with the Qt impression is, it really is Ôcode once, run everywhere'.This is one of the reasons I am such a Mozilla fan. Konqueror works quite like. But Mozilla runs everywhere with more or less a uniform look and feel. Yes, Mozilla is written with Gtk and not with Qt, but that just shows that WRI has options. I'm a KDE fan. I've used the KDE since it was in alpha 0.4. I remember back when it would compile in a few minutes on a pentium II. Now it takes several hours on a P4. But if WRI wanted to go the Gtk route, they could achieve the same ends.I've always hated motif. The file chooser simply stinks. And that's just a start.> gerald> STH ==== Can I solve this inequality with Mathematica?Log[x,a]+Log[a x,a]>0I've tried all know, but I get get any good result.CeZaR ==== > First thanks to all, and in particular Bobby Treat, for your help with> this question.> The best solution was as follows:> lst = ReadList[c:data.txt, {Number, Number}]> adjacenceMatrix[> x:{{_, _}..}] := Module[{actors, events},> {actors, events} = Union /@ Transpose[x];> Array[If[MemberQ[x, {actors[[#1]], events[[#2]]}], 1, 0] & ,> {Length[actors], Length[events]}]]> a = adjacenceMatrix[lst];> b = a . Transpose[a];> c = b (1 - IdentityMatrix[Length[b]])> C is the desired symmetric matrix with off diagonal values of >=0,> indicating the number of times two actors participate in the same event.> The diagonal is set to 0.> A few items in response to Bobby's message, below. While c is, in fact,> a huge matrix with lots of cells equal to zero, that is exactly how we> need it structured for our analysis and research question (not relevant> to the list, but I'd be happy to discuss off list). Processing time is> actually not too bad!! I'm running a PIII 900 with 512 SDRAM, and the> code ran a 177 x 3669 matrix in under 90 seconds. MatrixForm [c]> presented no problems in viewing in the front end, but then it's only> 177 x 177.> Tom> **********************************************> Thomas P. Moliterno> Graduate School of Management> University of California, Irvine> tmoliter@uci.edu> **********************************************> [...]There are several ways to go about this and which is best will varybased on relative number of events vs. number of actors. Below I showthree variations. The first is a minor recoding of the one above. Thesecond iterates over all pairs of actors. The third looks at all eventsfor common actors. I then show three examples. The first two methodshave the advantage that they do not require that events be positiveintegers. With some extra work the third method could also get aroundthis restriction.toAdjacency0[data:{{_, _}..}] := Module[ {actors, events, mat1, mat2}, {actors, events} = Union /@ Transpose[data]; mat1 = Array[If[MemberQ[data, {actors[[#1]], events[[#2]]}], 1, 0] &, {Length[actors], Length[events]}]; mat2 = mat1 . Transpose[mat1]; mat2 * (1-IdentityMatrix[Length[mat2]]) ]toAdjacency1[origdata_] := Module[ {data=Union[origdata], mat}, data = Map[Last, Split[data,#1[[1]]===#2[[1]]&], {2}]; mat = Table [If [j>k, Length[Intersection[data[[j]],data[[k]]]], 0], {j,Length[data]}, {k,Length[data]}]; mat+Transpose[mat] ]toAdjacency2[origdata_] := Module[ {data=Sort[Map[Reverse,Union[origdata]]], mat, len, event}, data = Map[Last, Split[data,#1[[1]]===#2[[1]]&], {2}]; dim = Length[Union[Flatten[data]]]; len = Length[data]; mat = Table[0, {dim}, {dim}]; Do [ event = data[[j]]; Do [ Do [ mat[[event[[m]],event[[k]]]] += 1; mat[[event[[k]],event[[m]]]] += 1, {m,k-1}], {k,Length[event]}], {j,len}]; mat ]data1 = Table[{Random[Integer,{1,1000}], Random[Integer,50]}, {10000}];data2 = Table[{Random[Integer,{1,1000}], Random[Integer,100]}, {10000}];data3 = Table[{Random[Integer,{1,1000}], Random[Integer,200]}, {10000}];Timings are on a 1.5 GHz machine running the Mathematica 4.2 kernelIn[107]:= Timing[m0 = toAdjacency0[data1];]Out[107]= {5.44 Second, Null}In[108]:= Timing[m1 = toAdjacency1[data1];]Out[108]= {10.5 Second, Null}In[109]:= Timing[m2 = toAdjacency2[data1];]Out[109]= {16.24 Second, Null}In[110]:= m0 === m1 === m2Out[110]= TrueNote that for this example the result is not terrible sparse (less than20%).In[112]:= Count[Flatten[m0], 0]Out[112]= 191374In[115]:= Timing[m0 = toAdjacency0[data2];]Out[115]= {11.51 Second, Null}In[116]:= Timing[m1 = toAdjacency1[data2];]Out[116]= {10.92 Second, Null}In[117]:= Timing[m2 = toAdjacency2[data2];]Out[117]= {9.07 Second, Null}Curiously this was the first example I tried, and all three methodsperform about the same in this case. The result, not suprisingly, ismore sparse (40%) because we have the same number of actors and pairs aspreviously, but now with more events to spread out over the pairs.In[118]:= Count[Flatten[m0], 0]Out[118]= 403232When we get sparser still, the third method begins to dominate and thefirst is relatively slower.In[119]:= Timing[m0 = toAdjacency0[data3];]Out[119]= {22.73 Second, Null}In[120]:= Timing[m1 = toAdjacency1[data3];]Out[120]= {10.88 Second, Null}In[121]:= Timing[m2 = toAdjacency2[data3];]Out[121]= {4.96 Second, Null}Now sparsity is over 60%.In[122]:= Count[Flatten[m0], 0]Out[122]= 624350The relative speed of this last method, in this instance, is derivedfrom the fact that individual event lists are on average half the sizeof the previous case. Hence the main loop is expected to improve onaverage by a factor of 2 (you get a factor of 4 for iterating over allpairs in each event, but lose a factor of 2 because there are twice asmany event lists).My guess is that a preprocessor that assesses number of actors vs.number of events would be the best way to choose between the first andthird methods (which, inexplicably, are labelled as methods 0 and 2). Itis not clear to me whether the middle approach will ever dominate. Ihave not given much thought to concocting examples where it wouldbecause offhand I suspect they would be pathological as in dense andwith large intersections.As a last remark I'll note that these might run significantly faster ifcoded with Compile. Whether that is viable depends on the form of thedata. In the above example where everything is a machine integer thatapproach would certainly work.Daniel LichtblauWolfram Research ==== First thanks to all, and in particular Bobby Treat, for your help withthis question.The best solution was as follows:lst = ReadList[c:data.txt, {Number, Number}]adjacenceMatrix[ x:{{_, _}..}] := Module[{actors, events}, {actors, events} = Union /@ Transpose[x]; Array[If[MemberQ[x, {actors[[#1]], events[[#2]]}], 1, 0] & , {Length[actors], Length[events]}]]a = adjacenceMatrix[lst];b = a . Transpose[a];c = b (1 - IdentityMatrix[Length[b]])C is the desired symmetric matrix with off diagonal values of >=0,indicating the number of times two actors participate in the same event.The diagonal is set to 0. A few items in response to Bobby's message, below. While c is, in fact,a huge matrix with lots of cells equal to zero, that is exactly how weneed it structured for our analysis and research question (not relevantto the list, but I'd be happy to discuss off list). Processing time isactually not too bad!! I'm running a PIII 900 with 512 SDRAM, and thecode ran a 177 x 3669 matrix in under 90 seconds. MatrixForm [c]presented no problems in viewing in the front end, but then it's only177 x 177.Tom********************************************** Thomas P. MoliternoGraduate School of ManagementUniversity of California, Irvinetmoliter@uci.edu************************************ **********-----Original Message-----columns will be numbered from 1 to the number of observed actors orevents, and will correspond to actors and events in sorted order.That said, you're asking for a VERY large matrix, and most of itsentries will be zero. I'll suggest another way, later.The following indicates AT MOST 13.4% of the entries could be non-zero:lst = ReadList[moliterno-test1996.txt, {Number, Number}]; {actors, events} = Union /@ Transpose[lst]; N[Length[lst]/(Length[actors]*Length[actors])] 0.13350994338800987However, a random sample shows that less than 1% will be non-zero:Timing[ Count[(MemberQ[lst, {actors[[Random[Integer, Length[actors]]]], events[[Random[Integer, Length[events]]]]}] & ) /@ Range[10000], True]/ 10000.]{7.515999999999998*Second, 0.008}Nevertheless, the following code should build the matrices you want.I'm using a 2.2GHz P4 and 1024MB RDRAM, so if you have a slower machine,be warned.adjacenceMatrix[ x:{{_, _}..}] := Module[{actors, events}, {actors, events} = Union /@ Transpose[x]; Array[If[MemberQ[x, {actors[[#1]], events[[#2]]}], 1, 0] & , {Length[actors], Length[events]}]]Timing[a = adjacenceMatrix[lst]; ]Dimensions[a]{5.671999999999997*Second, Null}{166, 1778}Timing[b = a . Transpose[a]; ]{0.5309999999999988*Second, Null}You don't want to display a or b in MatrixForm. It will crash youranything at all from the result, and use something likeb[[Range[20],Range[4]]]//MatrixForm{{47, 0, 0, 0}, {0, 3, 0, 0}, {0, 0, 7, 1}, {0, 0, 1, 59}, {0, 0, 0, 3}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 1}, {0, 0, 0, 0}, {0, 0, 0, 1}, {0, 0, 0, 0}, {0, 0, 0, 0}, {2, 0, 0, 1}, {0, 0, 0, 0}, {0, 1, 0, 0}, {0, 0, 0, 1}, {0, 0, 0, 2}, {0, 0, 0, 0}, {0, 0, 0, 0}}to get a glimpse at some of it. It's the Ôa' matrix that's terriblysparse -- the Ôb' matrix isn't unreasonable. Elements of the Ôa' matrixcan be quickly computed by the functionaFunction = If[MemberQ[lst, {actors[[#1]], events[[#2]]}], 1, 0] &;That stores a line of code rather than all those ones and zeroes. The bmatrix (call it bb this time) can be computed as:Timing[bb = (#1 . Transpose[#1] & ) [Array[aFunction, {Length[actors], Length[events]}]]; ]bb == b{6.1569999999999965*Second, Null}TrueBobby Treat-----Original Message-----posting a this was the most helpful solution message to the list, butfirst I hoped to ask you a follow up question, if I may (and I'llcapture your off-line response here in my final posting to the list).I've run the code (copied from you) below, and get the correct outputfor made-up data, but when I import in real data, I get an errormessage. Here's the input I'm running:lst = ReadList[c:test1996.txt, {Number, Number}]AdjacenceMatrix[lst : {{_, _} ..}] := Module[{actors, events, adj}, {actors, events} = Union /@ Transpose[lst]; adj = Table[0, {Length[actors]}, {Length[events]}]; Scan[(Part[adj, Sequence @@ #] = 1) &, lst /. MapIndexed[Rule[#1, First[#2]] &, events]]; adj]MatrixForm[a = AdjacenceMatrix[lst]]MatrixForm[b = a.Transpose[a]]And here's what I get for output:Set::partw : Part 300007 of <<1>> does not exist.Set::partw : Part 300007 of <<1>> does not exist.Set::partw : Part 300007 of <<1>> does not exist.General::stop : Further output of Set::partw will be suppressed duringthis calculation.Then I get the two matrices (a & b as per your code), but they are justfilled with zeros. So it gets to about the 4th line of your code, butthen doesn't fill-in from my data. Finally, I should note that30007 is one of the actors in the data that I've read in. In caseyou want to run this yourself, I've attached the raw data file. Thereare 166 actors and 1778 events: both actors and events are coded with6-digit numbers, actors begin with 3's, events with 2's.I'm sure this is a silly question, and that there is an easy answer... But I sure can't find it. So I really appreciate your help andinterest!!!!Tom*************************************** *******Thomas P. MoliternoGraduate School of ManagementUniversity of California, Irvinetmoliter@uci.edu************************************ **********-----Original Message-----If you multiply it by its transpose, you get something else that'suseful:lst = {{1, A}, {1, B}, {2, B}, {3, C}, {3, D}, {1, D}, {1, C}};AdjacenceMatrix[lst : {{_, _} ..}] := Module[{actors, events, adj}, {actors, events} = Union /@ Transpose[lst]; adj = Table[0, {Length[actors]}, {Length[events]}]; Scan[(Part[adj, Sequence @@ #] = 1) &, lst /. MapIndexed[Rule[#1, First[#2]] &, events]]; adj]MatrixForm[a = AdjacenceMatrix[lst]]MatrixForm[b = a.Transpose[a]]Matrix Ôb' records how many events two actors have in common. On thediagonal, it shows the total number of events each actor is connectedto.It's easy to put zeroes on the diagonal:MatrixForm[c = b (1 - IdentityMatrix[Length[b]])]To get the originally intended incidence matrix, this works:d = c /. {_?Positive -> 1}However, I think matrices Ôa' and Ôb' are actually more useful, and Ôa'easily leads to all the others.Bobby-----Original Message-----AdjacenceMatrix[lst : {{_, _} ..}] := Module[ {actors,events adj}, {events, actors} = Union /@ Transpose[lst]; adj = Table[0, {Length[events]}, {Length[actors]}]; Scan[(Part[adj, Sequence @@ #] = 1) &, lst /. MapIndexed[Rule[#1, First[#2]] &, actors]]; adj ]you getIn[]:=AdjacenceMatrix[lst]Out[]={{1, 1, 0, 1}, {0, 1, 0, 0}, {0, 0, 1, 1}} Jens> I need to create an adjacency matrix from my data, which is currentlyin> the form of a .txt file and is basically a two column incidence list.> For example:> 1 A> 1 B> 2 B> 3 C> . .> . .> . .> m n> Where 1 to m represent actors and A to n represent events. My goal isto> have an (m x m) matrix where cell i,j equals 1 if two actors are> incident to the same event (in the sample above, 1 and 2 are both> incident to B) and 0 otherwise (w/ zeros on the diagonal).> I'm new to Mathmatica, and so I'm on the steep part of the learning> curve ... All I've been able to figure out so far is how to get my> incidence list into the program using Import[filename.txt]. But then> what? How do I convert to the adjacency matrix? I've found the> ToAdjacencyMatrix[] command in DiscreteMath`Combinatorica`, but Ican't> seem to get it to work ...> Tom> **********************************************> Thomas P. Moliterno> Graduate School of Management> University of California, Irvine> tmoliter@uci.edu> ********************************************** ==== These are working for me. If anybody wants to try this modified keymapping http://66.92.149.152/proprietary/com/wri/proprietary/com/ wri/ch05.htmlhttp://public.globalsymmetry.com/proprietary/ com/wri/KeyEventTranslations.tr.txtSTH ==== > These are working for me. If anybody wants to try this modified> keymapping> http://66.92.149.152/proprietary/com/wri/proprietary/com/wri/ ch05.html> http://public.globalsymmetry.com/proprietary/com/wri/ KeyEventTranslations.tr.txt> STHI found a bug in my hack of the KeyEventTranslations.tr file which didn't manifest itself in 4.1, but did in 4.2. I had a trailing Ô,' which was causing Mathematica to hang on startup after the chched KeyEventTranslations.m was created (second launch with the buggy file.) I also discovered that the file I was trying to share had been chmod'ed to 400. I am not sure if that is a daemon running, or scp which did it. It's open now, and I'll keep an eye on it.I'm attaching it as well, just in case.I put it here on my box:~/.Mathematica/SystemFiles/FrontEnd/TextResourcesSTH@@ resource KeyEventTranslations(* Modifiers can be Shift, Control, Command, Option For Macintosh: Command = Command Key, Option = Option Key For X11: Command = Mod1, Option = Mod2 For Windows: Command = Alt, Option = AltNOTE: I Hacked this for my purposes. I find it more natural. Theremay be problems. It comes with all the warranty that GNU software does.*)EventTranslations[{(* Evaluation *) Item[KeyEvent[Enter], EvaluateCells], Item[KeyEvent[KeypadEnter], EvaluateCells], Item[KeyEvent[Return, Modifiers -> {Shift}], EvaluateCells], Item[KeyEvent[KP_Enter], EvaluateCells], Item[KeyEvent[KeypadEnter, Modifiers -> {Shift}], EvaluateNextCell], Item[KeyEvent[KP_Enter, Modifiers -> {Shift}], EvaluateNextCell], Item[KeyEvent[Enter, Modifiers -> {Shift}], EvaluateNextCell], Item[KeyEvent[Return, Modifiers -> {Command}], Evaluate[All]], Item[KeyEvent[Return, Modifiers -> {Option}], SimilarCellBelow], Item[KeyEvent[Escape], ShortNameDelimiter], (* Cursor control *) Item[KeyEvent[Up], MovePreviousLine], Item[KeyEvent[Down], MoveNextLine], Item[KeyEvent[Left], MovePrevious], Item[KeyEvent[Right], MoveNext], Item[KeyEvent[Up, Modifiers -> {Option}], MovePreviousLine], Item[KeyEvent[Down, Modifiers -> {Option}], MoveNextLine], Item[KeyEvent[Right, Modifiers -> {Option}], MoveNextWord], Item[KeyEvent[Left, Modifiers -> {Option}], MovePreviousWord], Item[KeyEvent[Right, Modifiers->{Control}], MoveNextWord], Item[KeyEvent[Left, Modifiers->{Control}], MovePreviousWord], Item[KeyEvent[End], MoveLineEnd], Item[KeyEvent[Home], MoveLineBeginning], (* Selection *) Item[KeyEvent[Right, Modifiers -> {Shift}], SelectNext], Item[KeyEvent[Left, Modifiers -> {Shift}], SelectPrevious], Item[KeyEvent[Right, Modifiers -> {Control, Shift}], SelectNextWord], Item[KeyEvent[Left, Modifiers -> {Control, Shift}], SelectPreviousWord], Item[KeyEvent[Down, Modifiers -> {Shift}], SelectNextLine], Item[KeyEvent[Up, Modifiers -> {Shift}], SelectPreviousLine], Item[KeyEvent[Home, Modifiers -> {Shift}], SelectLineBeginning], Item[KeyEvent[End, Modifiers -> {Shift}], SelectLineEnd], Item[KeyEvent[., Modifiers -> {Control}], ExpandSelection], (* Notebook window control *) Item[KeyEvent[PageUp], ScrollPageUp], Item[KeyEvent[PageDown], ScrollPageDown], Item[KeyEvent[Prior], ScrollPageUp], Item[KeyEvent[Next], ScrollPageDown], Item[KeyEvent[Home, Modifiers -> {Control}], ScrollNotebookStart], Item[KeyEvent[End, Modifiers -> {Control}], ScrollNotebookEnd], (* Input *) Item[KeyEvent[Return], Linebreak], Item[KeyEvent[Tab], Tab], Item[KeyEvent[i, Modifiers -> {Control}], Tab], Item[KeyEvent[Backspace], DeletePrevious], Item[KeyEvent[Delete], DeleteNext], Item[KeyEvent[ForwardDelete], DeleteNext], (* Typesetting input *) Item[KeyEvent[6, Modifiers -> {Control}], Superscript], Item[KeyEvent[Keypad6, Modifiers -> {Control}], Superscript], Item[KeyEvent[^, Modifiers -> {Control}], Superscript], Item[KeyEvent[-, Modifiers -> {Control}], Subscript], Item[KeyEvent[_, Modifiers ->{Control}], Subscript], Item[KeyEvent[/, Modifiers -> {Control}], Fraction], Item[KeyEvent[KP_Divide, Modifiers -> {Control}], Fraction], Item[KeyEvent[2, Modifiers -> {Control}], Radical], Item[KeyEvent[Keypad2, Modifiers -> {Control}], Radical], Item[KeyEvent[@, Modifiers -> {Control}], Radical], Item[KeyEvent[7, Modifiers -> {Control}], Above], Item[KeyEvent[&, Modifiers -> {Control}], Above], Item[KeyEvent[Keypad7, Modifiers -> {Control}], Above], Item[KeyEvent[=, Modifiers -> {Control}], Below], Item[KeyEvent[+, Modifiers -> {Control}], Below], Item[KeyEvent[,, Modifiers -> {Control}], NewColumn], Item[KeyEvent[Return, Modifiers -> {Control}], NewRow], Item[KeyEvent[9, Modifiers -> {Control}], CreateInlineCell], Item[KeyEvent[(, Modifiers -> {Control}], CreateInlineCell], Item[KeyEvent[Keypad9, Modifiers -> {Control}], CreateInlineCell], Item[KeyEvent[), Modifiers -> {Control}], MoveNextCell], Item[KeyEvent[0, Modifiers -> {Control}], MoveNextCell], Item[KeyEvent[Keypad0, Modifiers -> {Control}], MoveNextCell], Item[KeyEvent[Left, Modifiers -> {Control}, CellClass -> BoxFormData], NudgeLeft], Item[KeyEvent[Right, Modifiers -> {Control}, CellClass -> BoxFormData], NudgeRight], Item[KeyEvent[Down, Modifiers -> {Control}, CellClass -> BoxFormData], NudgeDown], Item[KeyEvent[Up, Modifiers -> {Control}, CellClass -> BoxFormData], NudgeUp], Item[KeyEvent[8, Modifiers -> {Control}], InsertRawExpression], Item[KeyEvent[*, Modifiers -> {Control}], InsertRawExpression], Item[KeyEvent[Keypad8, Modifiers -> {Control}], InsertRawExpression], Item[KeyEvent[5, Modifiers -> {Control}, CellClass -> BoxFormData], Otherscript], Item[KeyEvent[Keypad5, Modifiers -> {Control}, CellClass -> BoxFormData], Otherscript], Item[KeyEvent[%, Modifiers -> {Control}, CellClass -> BoxFormData], Otherscript], (* Typesetting motion commands *) Item[KeyEvent[ , Modifiers -> {Control}], MoveExpressionEnd], Item[KeyEvent[Tab, Modifiers -> {Shift}, CellClass -> BoxFormData], MovePreviousPlaceHolder], Item[KeyEvent[s, Modifiers -> {Command, Control}, CellClass -> BoxFormData], MovePreviousExpression], Item[KeyEvent[S, Modifiers -> {Control, Command, Shift}, CellClass -> BoxFormData], MoveNextExpression], Item[KeyEvent[S, Modifiers -> {Control, Shift}, CellClass -> BoxFormData], DeleteNextExpression], Item[KeyEvent[s, Modifiers -> {Control}, CellClass -> BoxFormData], DeletePreviousExpression], Item[KeyEvent[k, Modifiers -> {Control}], CompleteSelection[True]], (* Miscellaneous menu commands *) Item[KeyEvent[Delete, Modifiers -> {Control}], Cut], Item[KeyEvent[Insert, Modifiers -> {Control}], Copy], Item[KeyEvent[Insert, Modifiers -> {Shift}], Paste[After]], Item[KeyEvent[z, Modifiers -> {Control}], Undo], Item[KeyEvent[c, Modifiers -> {Control}], Copy], Item[KeyEvent[x, Modifiers -> {Control}], Cut], Item[KeyEvent[v, Modifiers -> {Control}], Paste[After]], Item[KeyEvent[F1], SelectionHelpDialog] (* Unsupported features and examples *)(* Item[KeyEvent[v, Modifiers -> {Control}], SelectionSpeakSummary], *)(* Item[KeyEvent[v, Modifiers -> {Control, Shift}], SelectionSpeak] *)}] ==== >particular, the y-axis label is typically rotated by 90deg so that it>reads up the y-axis. This works fine on macs and windoze, but under>linux the label runs up the y-axis; however, the letters are rotated>so that they are the same orientation as that for the x-axis.>Printouts of the NB are fine, but it looks really stupid when using a>video projector to teach or give a talk. I have mentioned this before,>perhaps, but it is also a real problem with Mathematica. I personally>don't care why the label looks peculiar, just that it does and that>there is no easy workaround. ==== >I'm writing to report what I consider to be a bug. First, I want to>show a simplified example of the problem. Consider the following>expression:>>expr=0.22 + x[0] + (3*(-0.16+ x[1]))/4 + (9*(0.546 + x[2]))/16;>>When simplified I expected to get some real number plus>x[0]+3x[1]/4+9x[2]/16, but instead I get the following:>>Simplify[expr] 0.407125 + x[0] + 0.75 x[1] + 0.5625 x[2]>>As you can see, for some reason Mathematica converted the fractions>3/4 and 9/16 to real machine numbers. I consider this to be a bug.You really are not seeing a loss of precision here. When simplify carries out the indicated multiplication such as 9*.546/16 a machine precision number is returned because on of the arguments only has machine precision. It would be incorrect for Mathematica to return a result with greater precision than the arguements. It would also be incorrect for Mathematica to refuse to preform the required multiplications when simplifying this expression.Or said differently, if you want an exact result from Mathematica *all* of the information you supply Mathematica must also be exact. It is not sensible for Mathematica to do otherwise. ==== There is nothing imprecise about a ßoating point number. Mathematica'snon-standard usage is to treat some numbers as intervals. This non-standardusage comes from the attitude that everything I need to know aboutnumerical computations I learned in Freshman physics lab.Anyway, I'm just pointing this out so that you realize that youare not talking about truth and beauty, but about decisions madein the Mathematica design.For example, 0.25 in IEEE ßoating point format is representing theEXACT value 1/4. The rational number 1/3 does not have an exactcorresponding binary ßoating point number. That does notprevent one from computing the closest number, which from that point onthat (other) number is EXACTLY represented. An analysis of yourarithmetic or simplification in which each ßoating point number aaaa*2^bbis changed to that exact rational number may give you more satisfactoryanswers that an interval-like computation in which all data is submergedin mush.RJF> >>It seems to me that you are arguing that if you have an expression>>consisting of one term which is very inprecise and another term which>>is very precise or exact, then the total expression is only as precise>>as the least precise portion of the expression. > Yes. >>This is total nonsense. > Not exactly.>>Consider adding the following terms:>>1.234567890123456`16 + 0.00000000000000001`1>>consisting of one term with precision 16 and another term with>>precision 1. By your argument, Mathematica should return an answer>>with only a single digit of precision. Of course, Mathematica does no>>such thing.> I had not considered adding two terms with much different magnitude and much different precision.> > Consider a different example i.e.,> 1.234567890123456`16 + 0.1`1> Mathematica does not and should not return a result with 16 digits of precision> ==== Bill,See my comments below.>> There is no logical reason to insist part of the expression to be exactwhen another part is inexact. You cannot gain more precision than the leastprecise portion of the expression. Further, there is extra processingoverhead associated with maintaining exact epressions as well as additionalstorage requirements. For a simple expression such as your example theadditional overhead is insignificant. But it increases for every exact termin the expression. It doesn't take all that many terms until the overheadassociate with exact computation becomes noticeable.>It seems to me that you are arguing that if you have an expressionconsisting of one term which is very inprecise and another term which isvery precise or exact, then the total expression is only as precise as theleast precise portion of the expression. This is total nonsense. Consideradding the following terms:1.234567890123456`16 + 0.00000000000000001`1consisting of one term with precision 16 and another term with precision 1.By your argument, Mathematica should return an answer with only a singledigit of precision. Of course, Mathematica does no such thing.> >Even more troubling (to me, at least) is the>following:> >>x[0]+3x[1]/4+9x[2]/16+.4//Simplify>>0.4 + x[0] + 0.75 x[1] + 0.5625 x[2]>>I don't want Simplify to change my nice rational numbers to machine>number approximations.>> If you want exact answers you *must* have *all* terms in the expresssionexact. Simply put either an expression is exact or not. No expression can beexact unless *all* of the terms within it are exact.When did I ever say that I wanted exact answers? In the example above, Iwanted Simplify to do nothing, that is, leave the expression as a sum of aninexact quantity with some exact quantities.In the work where this situation arose, the inexact quantities are typicallyvery small and the exact quantities are large, so that the precision of theoverall expression when extended precision numbers are substituted for thex[i] is typically the same as the precision of the numbers beingsubstituted. For example, suppose x[0] and x[2] are zero, and x[1] is 1`2510^25. Substituting these numbers into the original expression will yield aresult with a precision of 25, whereas substituting these numbers into thesimplified expression will only have a precision of 16. I've worked veryhard to keep the precision of my numbers as high as possible, and I don'twant Mathematica to arbitrarily turn those very high precision numbers intomuch lower precision numbers.Carl WollPhysics DeptU of Washington ==== Bill,Let's step through the expansion here.9*(0.546+x[2]))/16can be expanded to9*0.546/16 + 9*x[2]/16which becomes.307125 + 9*x[2]/16My question was why the 9/16 gets converted to .5625, as I see no reason todo so. Even more troubling (to me, at least) is the following:x[0]+3x[1]/4+9x[2]/16+.4//Simplify0.4 + x[0] + 0.75 x[1] + 0.5625 x[2]I don't want Simplify to change my nice rational numbers to machine numberapproximations.Carl WollPhysics DeptU of Washington>>I'm writing to report what I consider to be a bug. First, I want to>show a simplified example of the problem. Consider the following> >expression:>>expr=0.22 + x[0] + (3*(-0.16+ x[1]))/4 + (9*(0.546 + x[2]))/16;>>When simplified I expected to get some real number plus>x[0]+3x[1]/4+9x[2]/16, but instead I get the following:>>Simplify[expr] 0.407125 + x[0] + 0.75 x[1] + 0.5625 x[2]>>As you can see, for some reason Mathematica converted the fractions>3/4 and 9/16 to real machine numbers. I consider this to be a bug.>> You really are not seeing a loss of precision here. When simplify carriesout the indicated multiplication such as 9*.546/16 a machine precisionnumber is returned because on of the arguments only has machine precision.It would be incorrect for Mathematica to return a result with greaterprecision than the arguements. It would also be incorrect for Mathematica torefuse to preform the required multiplications when simplifying thisexpression.>> Or said differently, if you want an exact result from Mathematica *all* ofthe information you supply Mathematica must also be exact. It is notsensible for Mathematica to do otherwise.> ==== No, Euler proved that series divergent in 1737. It's the usual theoremused to show that while the primes are sparse, they're not as sparse asthe squares (as the sum of THEIR inverses converges).Bobby-----Original Message-----Sal. Oppenheim jr. & Cie. KGaAKoenigsberger Strasse 29D-60487 Frankfurt am MainGERMANYMobile: +49(0)172 6 74 95 77Internet: http://www.oppenheim.de ==== Timing[Sum[1./Prime[n], {n, 1000000}]]{13.860000000000001*Second, 3.0682190480544405}Bobby-----Original Message-----Sal. Oppenheim jr. & Cie. KGaAKoenigsberger Strasse 29D-60487 Frankfurt am MainGERMANYMobile: +49(0)172 6 74 95 77Internet: http://www.oppenheim.de ==== That makes about twenty posts this week detailing nothing but problemsthe FrontEnd).I had been really considering it.Bobby-----Original Message-----resulted in a set of animation control buttons appearing in the bottom frame of the window. I clicked on one of these buttons, but nothing happened. I looke back in the menu and saw M-y as a keyboard shorcut torun an animation. I tried that with no result. I clicked anotherbutton in graphics control set, and my X windows locked up. This included the keyboard's ability to give me another display by using Ctl+Alt+F1. Iwent to another system and ssh-ed in and found Mathematica had over 50% of myuser resources, and was climbing. The same was true for VM. I have a gig ofphysical RAM. Once I killed Mathematica, my X came back to life.I've had several bad experiences with Mathematica and X. I honestlybelieve there help isolate and fix these. Have others had such problems?STH ==== > That makes about twenty posts this week detailing nothing but problems> the FrontEnd).> I had been really considering it.> Bobby> A few other points on this topic, if I may. I've found solutions to a lot of the problems I was having, and documented them. For example, I have the keyboard working the way I want it. C-x, C-v, C-c, C-z, all do what I expect them to, as does Delete. I used to have X restarts after extended periods of running Mathematica. That I haven't had recently. I may simply have thrashed X when I clicked too many buttons in sequence. I just wanted to report that it happened. The same thing might happen on XP. I've had my problems there as well. Not with Mathematica, but with other programs. I haven't even attempted Mathematica on XP. I'm sure it is a bit smoother to use.I guess I was just a bit upset at the sense that WRI are still stuck in the just completing my download of KDE 3.1 Beta 2. Things have changed. Gotta go install a few rpms and restart X. Bye,STH ==== > That makes about twenty posts this week detailing nothing but problems> the FrontEnd).> I had been really considering it.> BobbyPlease keep in mind that this was on Mathematica 4.1, I'll have 4.2 tomorrow, and we'll see how that goes. This isn't really the result I had hoped for by I very much wish WRI would give us a dual boot license. That way, we can use Mathematica in either environment the current situation dictates as the best. with Windows. I just don't do that as a matter of course. I've been related issuse, either because they aren't sure if the problem is their that second reason one bit. Hey, if it locks up my X, I want to know if that happens to others, and I want to identify the source of the problem.What I really would like to gain from all my negative statements is solutions to what I perceive as problems. If not that, then perhaps the perspective which makes me understand that what I see as problems are really just my unfamiliarity with the product. I also want to get others platform. That's how open source works.All that being said, if you are in a situation where an X lockup would really do harm to your project, I would say that I cannot claim it won't happen to you. OTOH, I am able to break just about any system. I can't swear to you that Mathematica won't lock up your Windows system. I can say you will not have as easy a time shelling into it and trying to recover your system without rebooting.STHReply-To: jmt@dxdydz.net ==== Sorry, I thought I had seen a demonstration, some years ago !> This sum converges, see a math text book !> Dear Colleagues,> I calculated:> Sum[1/Prime[n], {n, 15000}] // N> Result: 2.74716> Now I wonder if this sum will converge or keep on growing, albeit very> slowly.> Matthias Bode> Sal. Oppenheim jr. & Cie. KGaA> Koenigsberger Strasse 29> D-60487 Frankfurt am Main> GERMANY> Mobile: +49(0)172 6 74 95 77> Internet: http://www.oppenheim.de> Reply-To: murray@math.umass.edu ==== It is well known that the infinite series of reciprocals of the primes DIVERGES!See, for example: http://www.utm.edu/research/primes/infinity.shtml> Dear Colleagues,> I calculated:> Sum[1/Prime[n], {n, 15000}] // N> Result: 2.74716> Now I wonder if this sum will converge or keep on growing, albeit very> slowly.> Matthias Bode> Sal. Oppenheim jr. & Cie. KGaA> Koenigsberger Strasse 29> D-60487 Frankfurt am Main> GERMANY> Mobile: +49(0)172 6 74 95 77> Internet: http://www.oppenheim.de> -- Murray Eisenberg murray@math.umass.eduMathematics & Statistics Dept.Lederle Graduate Research Tower phone 413 549-1020 (H)University of Massachusetts 413 545-2859 (W)710 North Pleasant StreetAmherst, MA 01375Reply-To: jmt@dxdydz.net ==== This sum converges, see a math text book !> Dear Colleagues,> I calculated:> Sum[1/Prime[n], {n, 15000}] // N> Result: 2.74716> Now I wonder if this sum will converge or keep on growing, albeit very> slowly.> Matthias Bode> Sal. Oppenheim jr. & Cie. KGaA> Koenigsberger Strasse 29> D-60487 Frankfurt am Main> GERMANY> Mobile: +49(0)172 6 74 95 77> Internet: http://www.oppenheim.de> ==== The fact that Sum[1/Prime[n], {n, 1,Infinity}]==Infinity is a rather famous theorem of Euler. It implies that there must be infinitely many primes (otherwise the sum would be finite), and was the beginning of a vast area of mathematics, which includes such concepts as Dirichlet series, Riemann's zeta function etc.Andrzej KozlowskiYokohama, Japanhttp://www.mimuw.edu.pl/~akoz/http:// platon.c.u-tokyo.ac.jp/andrzej/On Wednesday, October 2, 2002, at 04:31 PM, Matthias.Bode@oppenheim.de > Dear Colleagues,>> I calculated:>> Sum[1/Prime[n], {n, 15000}] // N>> Result: 2.74716>> Now I wonder if this sum will converge or keep on growing, albeit very> slowly.> Matthias Bode> Sal. Oppenheim jr. & Cie. KGaA> Koenigsberger Strasse 29> D-60487 Frankfurt am Main> GERMANY> Mobile: +49(0)172 6 74 95 77> Internet: http://www.oppenheim.de>> ==== Here's a start. If you want the thing to be greater than zero, set itequal to z (which we'll assume is greater than zero) and solve forLog[x]:Log[x, a] + Log[a*x, a] == z /. Log[a_*b_] -> Log[a] + Log[b]{f, g} = Log[x] /. Simplify[Solve[%, Log[x]]]Log[a]/Log[x] + Log[a]/(Log[a] + Log[x]) == z{-(((-2 + z + Sqrt[4 + z^2])*Log[a])/(2*z)), ((2 - z + Sqrt[4 + z^2])* Log[a])/(2*z)}Neither solution appears to be extraneous.Now the task is to find the range of these functions over positive z.Take a look at their derivatives:D[f, z] // SimplifyD[g, z] // Simplify((-1 + 2/Sqrt[4 + z^2])* Log[a])/z^2((-1 - 2/Sqrt[4 + z^2])*Log[a])/z^2A little study shows that f' and g' have their signs opposite to Log[a].Both functions are monotone. The following limits:Outer[Limit[#1, z -> #2] &, {f, g}, {0, Infinity}]Exp@%{{-(Log[a]/2), -Log[a]}, {Infinity*Log[a], 0}}{{1/Sqrt[a], 1/a}, {Indeterminate, 1}}show that f varies from -Log[a]/2 to -Log[a] and g varies from 0 toInfinity if Log[a]>0 and 0 to -Infinity if Log[a]<0. Exponentiationgives ranges for x: -1/Sqrt[a] to 1/a for f, for instance. But whatdoes all this mean?When a>1, either x>1 or 1/a < x < 1/Sqrt[a].When a<1, either 0, ModeratorReply-To: ==== Try this:To the original function, add a function that's (a) zero when theimaginary part is larger than some epsilon value you choose, (b) fairlylarge when the imaginary part is 0 or negative, and (c) as smooth aspossible. For instance, something like:f=Max[(1 - x/epsilon)^5, 0]This function has four continuous derivatives in the real components --though not in the complex variable!If it doesn't penalize the real root enough, multiply f by a constantbigger than 1 and try again.Bobby Treat-----Original Message-----are interested, the zeros are the roots of the dispersion relation for aplasma interacting with a laser). Sometimes FindRoot picks up one 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. ==== > This sum converges, see a math text book !That's nonsensehttp://mathworld.wolfram.com/PrimeSums.html Jens> > Dear Colleagues,>> I calculated:>> Sum[1/Prime[n], {n, 15000}] // N>> Result: 2.74716>> Now I wonder if this sum will converge or keep on growing, albeit very> slowly.> Matthias Bode> Sal. Oppenheim jr. & Cie. KGaA> Koenigsberger Strasse 29> D-60487 Frankfurt am Main> GERMANY> Mobile: +49(0)172 6 74 95 77> Internet: http://www.oppenheim.de> ==== You need to see: http://www.research.att.com/cgi-bin/access.cgi/as/njas/ sequences/eisA.cgi?Anum=A016088>This sum converges, see a math text book !>>That's nonsense>>http://mathworld.wolfram.com/PrimeSums.html>> Jens>Dear Colleagues,>>I calculated:>>Sum[1/Prime[n], {n, 15000}] // N>>Result: 2.74716>>Now I wonder if this sum will converge or keep on growing, albeit very>slowly.>Matthias Bode>Sal. Oppenheim jr. & Cie. KGaA>Koenigsberger Strasse 29>D-60487 Frankfurt am Main>GERMANY>Mobile: +49(0)172 6 74 95 77>Internet: http://www.oppenheim.de> ==== I have updated my package Biokmod. It can be downloaded from:http://web.usal.es/~guillerm/biokmod.htmI developped this package thinking in biokinetic application andinternal dosimetry, but it can be also applied for other kind ofproblems envolving System of ODE with many variables.I will appreciate any comentsGuillermo Sanchezhttp://web.usal.es/~guillerm ==== I use BinaryImport to read a file as follows:BinaryImport[file,{Byte..}] then I use Partition to rebuild the data of dimensions 252 x 253 x 255....This works but it takes about half an hour to read the file....it's a 16MByte file.....any way to improve this?thanks....jerry blimbaumReply-To: kuska@informatik.uni-leipzig.de ==== BinaryImport[] is complet unusable for this task.I tryed the same with similar data sets and runout of kernel memory (with 1.5 GByte RAM) & 3GB swap). The WRI support respondet, that BinaryImport[] isnot for reading *large* binary data. You can have the beta version of MathGL3d 3.1 thathas an extra C-Function for that task.Since it also include excelent volume rendering functionsand a native format for reading and writing compressedvolume data files you should use MathGL3d 3.1b.Contact me direct if you wish to beta test the newversion. Jens> I use BinaryImport to read a file as follows:> BinaryImport[file,{Byte..}]> then I use Partition to rebuild the data of dimensions 252 x 253 x 255....> This works but it takes about half an hour to read the file....it's a 16> MByte file.....any way to improve this?> thanks....jerry blimbaum ==== Does any one know of a way to produce Phase PlaneDiagrams in mathematica? I need to draw a couple of direction field andanalyse the stability of critical points for mysystems of equations . Ajadi__________________________________________________Do You Yahoo!?Everything you'll ever need on one web pagehttp://uk.my.yahoo.comReply-To: kuska@informatik.uni-leipzig.de ==== if you don't like PlotField[] you shouldtry to get a copy of the book Visual DSolvehttp://store.wolfram.com/view/book/D0706.strand the book package. Jens> Does any one know of a way to produce Phase Plane> Diagrams in mathematica?> I need to draw a couple of direction field and> analyse the stability of critical points for my> systems of equations .> Ajadi> > __________________________________________________> Do You Yahoo!?> Everything you'll ever need on one web page> http://uk.my.yahoo.com ==== Please ignore a similar question I just posted about BinaryImport...I forgotan hour to import 16 MByte file, whereas this technique took less then 5seconds...special thanks to Mariusz...jerry blimbaum NSWC panama city, ß-----Original Message-----Mariusz JankowskiUniversity of Southern Mainemjkcc@usm.maine.edu207-780-5580> The question:> What is the fastest way to read binary files in Mathematica 4.0 ?> I think the fastest is with ReadList (indeed ReadSounFile that use it,seems> to be better than BinaryImport), but when i use this command...> data = ReadList[filePath, Byte]> ....it doesn't read whole file; can somebody tell me the reason?>> Raf.>> P.S.:> I made some simple tests (@ 16 bit):>> << Experimental`> data = BinaryImport[fileRawPath, Table[Integer16, {4000}],> ByteOrdering -> -1]; => 10 seconds>> data = ReadListBinary[fileRawPath, SignedInt16, ByteOrder ->> LeastSignificantByteFirst]; = > 26 seconds>> << Miscellaneous`Audio`> data = ReadSoundfile[fileWavPath] => 1.54 seconds>> ==== I came across this, and thought I would share. This may be OBE if the font selection is better in 4.2. I'll that installed by this time tomorrow...I hope.http://cgm.cs.mcgill.ca/~luc/math.htmlI started reading through this list, and had visions of recursively downloading the entire internet looking for the font's I really need. Anybody know what fonts I should have installed on my SuSE box to satisfy Mathematica's default expectations?STH ==== In: DSolve[y*D[u[x, y],x] == x*D[u[x, y],y], u[x,y], {x, y}]Out: {{u[x, y] -> C[1][(1/2)*(x^2 + y^2)]}}Square brackets are used as grouping symbols in the result!?? :^OSomebody say it isn't so.---Selwyn Hollis ==== It isn't so. C[1] is an arbitrary (smooth) function. After all, what you have got is a partial differential equation. For example, you can take C[1] to be Sin:In[1]:=v[x_, y_] = u[x, y] /. DSolve[y*D[u[x, y], x] == x*D[u[x, y], y], u[x, y], {x, y}] /. C[1] -> SinOut[1]={Sin[(1/2)*(x^2 + y^2)]}In[2]:=y*D[v[x, y], x] == x*D[v[x, y], y]Out[2]=TrueAndrzej KozlowskiYokohama, Japanhttp://www.mimuw.edu.pl/~akoz/http:// platon.c.u-tokyo.ac.jp/andrzej/>> In: DSolve[y*D[u[x, y],x] == x*D[u[x, y],y], u[x,y], {x, y}]>> Out: {{u[x, y] -> C[1][(1/2)*(x^2 + y^2)]}}>> Square brackets are used as grouping symbols in the result!?? :^O>> Somebody say it isn't so.>> ---> Selwyn Hollis>>Reply-To: ==== My OPINION is that extra graphics RAM is useful primarily for 3D games(which are themselves completely useless). A static 3D plot doesn'tneed that much graphics RAM -- it's the rapid transformation of it, tosimulate live action, that may require it.On the other hand, if the manufacturer's limits are that low forgraphics RAM, I would get another manufacturer. Who knows what otherlimitations and compromises they'll saddle you with? I would be verysuspicious.Bobby-----Original Message-----Is 32 MB adequate not just now, but likely to be adequate as well for the near future (say, a 3- to 5-year equipment lifetime)?-- Murray Eisenberg murray@math.umass.eduMathematics & Statistics Dept.Lederle Graduate Research Tower phone 413 549-1020 (H)University of Massachusetts 413 545-2859 (W)710 North Pleasant StreetAmherst, MA 01375Reply-To: kuska@informatik.uni-leipzig.de ==== > My OPINION is that extra graphics RAM is useful primarily for 3D gamesOr complex 3d scientific visualizations ? Textures ?Try to render the skull from a 256^3 CT scan or the output of a 3dplasmasimulation and you will know *what* can be done with extra 3d RAM> (which are themselves completely useless). The major effect is, that 3d Games make 3d graphics hardware lessexpensive.Five years ago a SGI cost 20-30 000 $ and today you can have more 3dpowerfor 400 $ Jens> A static 3D plot doesn't> need that much graphics RAM -- it's the rapid transformation of it, to> simulate live action, that may require it.> On the other hand, if the manufacturer's limits are that low for> graphics RAM, I would get another manufacturer. Who knows what other> limitations and compromises they'll saddle you with? I would be very> suspicious.> Bobby> -----Original Message-----> We are about to order new PCs for a university student lab in which> Mathematica will be installed. Of course they will be using 2D and 3D> graphics -- plots of surfaces, e.g. Sooner or later students will want> to rotate such plots, too.> An unresolved issue is how much graphics RAM to get. On existing> machines we typically have 64MB. But for the PCs we are looking at,> manufacturer's limits on graphics RAM, rather than cost, seems to limit> us to 32 MB.> Is 32 MB adequate not just now, but likely to be adequate as well for> the near future (say, a 3- to 5-year equipment lifetime)?> --> Murray Eisenberg murray@math.umass.edu> Mathematics & Statistics Dept.> Lederle Graduate Research Tower phone 413 549-1020 (H)> University of Massachusetts 413 545-2859 (W)> 710 North Pleasant Street> Amherst, MA 01375 ==== Greetings MathGroup,My name is Steve Earth, and I am a new subscriber to this list and also anew user of Mathematica; so please forgive this rather simple question...I would like to enter the quartic x^4 + x^3 + x^2 + x + 1 into Mathematicaand have it be able to tell me that it factors into(x^2 + GoldenRatio x + 1) ( x^2 - 1/GoldenRatio x + 1)What instructions do I need to execute to achieve this output?-Steve EarthHarker Schoolhttp://www.harker.org/ ==== SteveThe notebook given after NOTEBOOK below contains functions for factoring andpartial fractioning.Here is an application to your problem: the first stage avoids our needingto know anything about the answer.fc=FactorR[x^4+x^3+x^2+x+1,x](1 - (1/2)*(-1 - Sqrt[5])*x + x^2)* (1 - (1/2)*(-1 + Sqrt[5])*x + x^2)Now we need to get rid of Sqrt[5] in terms of GoldenRatio.This is rather messy:Simplify/@(fc/. Sqrt[5][Rule]2 GoldenRatio-1)(1 + x - GoldenRatio*x + x^2)*(1 + GoldenRatio*x + x^2)Simplify/@(%/.-GoldenRatio[Rule] 1/GoldenRatio -1)(1 + x/GoldenRatio + x^2)*(1 + GoldenRatio*x + x^2)Another examplePartialFractionsR[(1 + x)x/(1 - 3*x + x^2), x]1 - (2*(-1 + 4*x))/((3 + Sqrt[5] - 2*x)*(-3 + 2*x)) + (2*(-1 + 4*x))/((-3 + 2*x)*(-3 + Sqrt[5] + 2*x))Simplify[%](x*(1 + x))/(1 - 3*x + x^2)NOTEBOOK: to make a notebook from the following, copy from the next line tothe line preceding XXX and paste into a new Mathematica notebook.Notebook[{Cell[CellGroupData[{Cell[Factors and PartialFractions, Subtitle],Cell[Allan Hayes, 16 August 2001, Text],Cell[, Text],Cell[BoxData[ (Quit)], Input],Cell[BoxData[{ (Off[General::spell1, General::spell]), n, ((FactorC::usage = ;)n), n, ((FactorR::usage = ;)n), n, ((PartialFractionsC::usage = ;)n), n, ((PartialFractionsR::usage = ;)), n, (On[General::spell1, General::spell])}], Input, InitializationCell->True],Cell[TextData[{ FactorC[p_, x_] := , StyleBox[(*over complex numbers*), FontFamily->Arial, FontWeight->Plain], nTimes @@ Cases[Roots[p == 0, x, n Cubics -> False], u_ == v_ -> x - v]n nFactorR[p_, x_] := , StyleBox[(*over reals, coefficients must be real*), FontFamily->Arial, FontWeight->Plain], n (Times @@ Join[Cases[#1, u_ == v_ /; Im[v] == 0 :> n x - v], Cases[#1, u_ == v_ /; Im[v] > 0 :> n x^2 - x*2*Re[v] + Abs[v]^2]] & )[n Roots[p == 0, x, Cubics -> False]]}], Input, InitializationCell->True],Cell[TextData[{ PartialFractionsC[p_, x_] := , StyleBox[(*over complex numbers*), FontFamily->Arial, FontWeight->Plain], n(#+Apart[#2/FactorC[#3,x]])&@@Flatten[{PolynomialReduce[# ,#2], #2}]&[Numerator[#],Denominator[#]]&[Together[p]]n nPartialFractionsR[p_, x_] := , StyleBox[(*over reals, coefficients must be real*), FontFamily->Arial, FontWeight->Plain], n(#+Apart[#2/FactorR[#3,x]])&@@Flatten[{PolynomialReduce[# ,#2], #2}]&[Numerator[#],Denominator[#]]&[Together[p]]}], Input, InitializationCell->True],Cell[CellGroupData[{Cell[ PROGRAMMING NOTES, Subsubsection],Cell[TextData[{ The option , StyleBox[Cubics->False, FontFamily->Courier], is used to keep the roots of cubics in , StyleBox[Root[....], FontFamily->Courier], form. This is better for computation.n, StyleBox[Re[v], FontFamily->Courier], and , StyleBox[Abs[v]^2, FontFamily->Courier], are used rather than , StyleBox[v+Conjugate[v] , FontFamily->Courier], and , StyleBox[v*Conjugate[v], FontFamily->Courier], to prevent , StyleBox[Apart, FontFamily->Courier], from factorising , StyleBox[x^2 - x*2*Re[v] + Abs[v]^2], FontFamily->Courier], back to complex form.}], Text]}, Closed]],Cell[CellGroupData[{Cell[EXAMPLES, Subsubsection],Cell[pol = Expand[(x - 1)*(x + 1)^2*(x^2 + x + 1)^2*(x^2 + 4)]; , Input],Cell[CellGroupData[{Cell[f1 = FactorC[pol, x], Input],Cell[BoxData[ ((((-1) + x)) (((-2) [ImaginaryI] + x)) ((2 [ImaginaryI] + x)) ((1 + x))^2 (((((-1)))^(1/3) + x))^2 (((-(((-1)))^(2/3)) + x))^2)], Output]}, Open ]],Cell[CellGroupData[{Cell[f2 = FactorR[pol, x], Input],Cell[BoxData[ ((((-1) + x)) ((1 + x))^2 ((4 + x^2)) ((1 + x + x^2))^2)], Output]}, Open ]],Cell[CellGroupData[{Cell[f3 = FactorR[x^3 + x + 1, x], Input],Cell[BoxData[ (((x - Root[1 + #1 + #1^3 &, 1])) ((x^2 - 2 x Root[(-1) + 2 #1 + 8 #1^3 &, 1] + Root[(-1) - #1^4 + #1^6 &, 2]^2)))], Output]}, Open ]],Cell[False in Roots.We can sometimes get radical forms, but notice the complication.>, Text],Cell[CellGroupData[{Cell[ToRadicals[f3], Input],Cell[BoxData[ (((((2/(3 (((-9) + @93)))))^(1/3) - ((1/2 (((-9) + @93))))^(1/3)/3^(2/3) + x)) ((1/3 + 1/3 ((29/2 - (3 @93)/2))^(1/3) + 1/3 ((1/2 ((29 + 3 @93))))^(1/3) - 2 ((((1/2 ((9 + @93))))^(1/3)/(2 3^(2/3)) - 1/(2^(2/3) ((3 ((9 + @93))))^(1/3)))) x + x^2)))], Output]}, Open ]],Cell[Inexact forms can be found, from f3 :, Text],Cell[CellGroupData[{Cell[N[f3], Input],Cell[BoxData[ (((((0.6823278038280193`)([InvisibleSpace]) ) + x)) ((((1.4655712318767682`)([InvisibleSpace])) - 0.6823278038280193` x + x^2)))], Output]}, Open ]],Cell[or directly, Text],Cell[CellGroupData[{Cell[f3 = FactorR[x^3 + x + 1//N, x], Input],Cell[BoxData[ (((((0.6823278038280193`)([InvisibleSpace]) ) + x)) ((((1.4655712318767682`)([InvisibleSpace])) - 0.6823278038280193` x + x^2)))], Output]}, Open ]],Cell[Partial fractions, Text],Cell[CellGroupData[{Cell[pf1 = PartialFractionsR[(2 + x)/pol, x], Input],Cell[BoxData[ (1/(60 (((-1) + x))) - 1/(10 ((1 + x))^2) - 39/(100 ((1 + x))) + ((-54) - 31 x)/(4225 ((4 + x^2))) + ((-1) + 3 x)/(13 ((1 + x + x^2))^2) + (44 + 193 x)/(507 ((1 + x + x^2))))], Output]}, Open ]],Cell[CellGroupData[{Cell[pf2 = PartialFractionsR[(1 + x)x/(1 - 3*x + x^2), x], Input],Cell[<1 - (2*(-1 + 4*x))/((3 + Sqrt[5] - 2*x)*(-3 + 2*x)) + (2*(-1 + 4*x))/((-3 + 2*x)*(-3 + Sqrt[5] + 2*x))>, Output]}, Open ]],Cell[CellGroupData[{Cell[BoxData[ (Simplify[%])], Input],Cell[(x*(1 + x))/(1 - 3*x + x^2), Output]}, Open ]],Cell[Partial fractions will often involve Root objects , Text],Cell[CellGroupData[{Cell[pf3 = PartialFractionsR[(1 + x)/(x^3 - x + 1), x], Input],Cell[BoxData[ (((1 + Root[1 - #1 + #1^3 &, 1]))/((((x - Root[1 - #1 + #1^3 &, 1])) ((Root[1 - #1 + #1^3 &, 1]^2 - 2 Root[1 - #1 + #1^3 &, 1] Root[(-1) - 2 #1 + 8 #1^3 &, 1] + Root[(-1) + #1^4 + #1^6 &, 2]^2)))) + ((x + Root[1 - #1 + #1^3 &, 1] + x Root[1 - #1 + #1^3 &, 1] - 2 Root[(-1) - 2 #1 + 8 #1^3 &, 1] - Root[(-1) + #1^4 + #1^6 &, 2]^2))/(((((-x^2) + 2 x Root[(-1) - 2 #1 + 8 #1^3 &, 1] - Root[(-1) + #1^4 + #1^6 &, 2]^2)) ((Root[1 - #1 + #1^3 &, 1]^2 - 2 Root[1 - #1 + #1^3 &, 1] Root[(-1) - 2 #1 + 8 #1^3 &, 1] + Root[(-1) + #1^4 + #1^6 &, 2]^2)))))], Output]}, Open ]],Cell[This can in fact be put in radical form:, Text],Cell[CellGroupData[{Cell[ToRadicals[pf3], Input],Cell[BoxData[ (((1 - ((2/(3 ((9 - @69)))))^(1/3) - ((1/2 ((9 - @69))))^(1/3)/3^(2/3)))/(((((-( 1/3)) + 1/3 ((25/2 - (3 @69)/2))^(1/3) + 1/3 ((1/2 ((25 + 3 @69))))^(1/3) + (((-((2/(3 ((9 - @69)))))^(1/3)) - ((1/2 ((9 - @69))))^(1/3)/3^(2/3)))^2 - 2 (((-((2/(3 ((9 - @69)))))^(1/3)) - ((1/2 ((9 - @69))))^(1/3)/3^(2/3))) ((1/24 ((864 - 96 @69))^(1/3) + ((1/2 ((9 + @69))))^(1/3)/(2 3^(2/3)))))) ((((2/(3 ((9 - @69)))))^(1/3) + ((1/2 ((9 - @69))))^(1/3)/3^(2/3) + x)))) + ((1/3 - 1/3 ((25/2 - (3 @69)/2))^(1/3) - ((2/(3 ((9 - @69)))))^(1/3) - ((1/2 ((9 - @69))))^(1/3)/3^(2/3) - 1/3 ((1/2 ((25 + 3 @69))))^(1/3) - 2 ((1/24 ((864 - 96 @69))^(1/3) + ((1/2 ((9 + @69))))^(1/3)/(2 3^(2/3)))) + x + (((-((2/(3 ((9 - @69)))))^(1/3)) - ((1/2 ((9 - @69))))^(1/3)/3^(2/3))) x))/(((((-(1/3)) + 1/3 ((25/2 - (3 @69)/2))^(1/3) + 1/3 ((1/2 ((25 + 3 @69))))^(1/3) + (((-((2/(3 ((9 - @69)))))^(1/3)) - ((1/2 ((9 - @69))))^(1/3)/3^(2/3)))^2 - 2 (((-((2/(3 ((9 - @69)))))^(1/3)) - ((1/2 ((9 - @69))))^(1/3)/3^(2/3))) ((1/24 ((864 - 96 @69))^(1/3) + ((1/2 ((9 + @69))))^(1/3)/(2 3^(2/3)))))) ((1/3 - 1/3 ((25/2 - (3 @69)/2))^(1/3) - 1/3 ((1/2 ((25 + 3 @69))))^(1/3) + 2 ((1/24 ((864 - 96 @69))^(1/3) + ((1/2 ((9 + @69))))^(1/3)/(2 3^(2/3)))) x - x^2)))))], Output]}, Closed]],Cell[We could have found the inexact form directly., Text],Cell[CellGroupData[{Cell[BoxData[ (PartialFractionsR[((1 + x))/((x^3 - x + 1)) // N, x])], Input],Cell[BoxData[ ((-(0.07614206365252976`/(((1.324717957244746` )([InvisibleSpace])) + 1.` x))) + (((0.7982664819556426`)([InvisibleSpace])) + 0.07614206365252976` x)/(((0.754877666246693`)([InvisibleSpace] )) - 1.324717957244746` x + 1.` x^2))], Output]}, Open ]]}, Closed]]}, Open ]]},ScreenRectangle->{{0, 1024}, {0, 709}},AutoGeneratedPackage->None,WindowSize->{534, 628},WindowMargins->{{199, Automatic}, {0, Automatic}},ShowCellLabel->False,StyleDefinitions -> Default.nb]XXX--Allan---------------------Allan HayesMathematica Training and ConsultingLeicester UKwww.haystack.demon.co.ukhay@haystack.demon.co.ukVoice : +44 (0)116 271 4198> Greetings MathGroup,>> My name is Steve Earth, and I am a new subscriber to this list and also a> new user of Mathematica; so please forgive this rather simple question...>> I would like to enter the quartic x^4 + x^3 + x^2 + x + 1 into Mathematica> and have it be able to tell me that it factors into>> (x^2 + GoldenRatio x + 1) ( x^2 - 1/GoldenRatio x + 1)>> What instructions do I need to execute to achieve this output?>> -Steve Earth> Harker School> http://www.harker.org/>Reply-To: kuska@informatik.uni-leipzig.de ==== In[]:=Factor[x^4 + x^3 + x^2 + x + 1, Extension -> {GoldenRatio,1/GoldenRatio}]Out[]=-((-3 - 2*x + Sqrt[5]*x + GoldenRatio*x - 3*x^2)* (3 + x + Sqrt[5]*x + GoldenRatio*x + 3*x^2))/9 Jens> Greetings MathGroup,> My name is Steve Earth, and I am a new subscriber to this list and also a> new user of Mathematica; so please forgive this rather simple question...> I would like to enter the quartic x^4 + x^3 + x^2 + x + 1 into Mathematica> and have it be able to tell me that it factors into> (x^2 + GoldenRatio x + 1) ( x^2 - 1/GoldenRatio x + 1)> What instructions do I need to execute to achieve this output?> -Steve Earth> Harker School> http://www.harker.org/ ==== > The last part of my message you are quoting was completely wrong, as> was pointed out by Allan Hayes. Mathematica does not track precision of> machine arithmetic computations. In order for Mathematica to give> reliable information about the precision of a computation you have to> explicitly set the precision of all the numerical quantities.>> Your own example at the bottom simply shows you have not understood the> evaluation mechanism of Mathematica.>> Just opposite, thanks to you and other participants, I completely> understood it. SetAccuracy just takes anything and calls it accurate.> This behavior is useless if not stupid.I am not sure I understand what you are referring to as uselessif not stupid.The main purpose of SetAccuracy is to allow people who have donetheir own error analysis to specify the numerical error in aninput or in a result. It is often possible through carefulnumerical analysis, for example, to come up with a better errorestimate than can be given by generic rules for propogation of error.Another common use of SetAccuracy is for converting machine numbersor exact numbers into variable-precision numbers in situations whenit is desired that a calculation be done using variable-precisionarithmetic.Is there some aspect of this that you think is useless if not stupid,or was that remark referring to something else?Dave WithoffWolfram Research ==== > The more I play with the example the more depressing it gets. Start> with ßoating point numbers but explicitely arbitrary-precision ones.> In[1]:=> a=77617.00000000000000000000000000000;> b=33095.00000000000000000000000000000;> In[3]:=> !(333.7500000000000000000000000000000 b^6 + a^2 ((11 a^2> b^2 - > b^6 - 121 b^4 - 2)) + 5.500000000000000000000000000000 b^8 +> a/(2> b))> Out[3]=> !((-4.78339168666055402578083604864320577443814`26.6715 *^32))> In[4]:=> Accuracy[%]> Out[4]=> -6> Due to the manual section 3.1.6:> When you do calculations with arbitrary-precision numbers, as> discussed in the previous section, Mathematica always keeps track of> the precision of your results, and gives only those digits which are> known to be correct, given the precision of your input. When you do> calculations with machine-precision numbers, however, Mathematica> always gives you a machine?precision result, whether or not all the> digits in the result can, in fact, be determined to be correct on the> basis of your input. > > Because I started with arbitrary-precision numbers Mathematica should display> only those digits that are correct, that is none.An accuracy of -6 means that the least significant correct digit is 6digits to the left of the decimal point. The result Out[3] in theexample above has 26 significant digits to the left of that (the mostsigificant digit is 26+6=32 digits to the left of the decimal point),so there are 26 correct digits to display.Was there some other result you were referring to as a result inwhich the number of correct digits is none?Dave WithoffWolfram Research ==== > I came across this, and thought I would share. This may be OBE if the font > selection is better in 4.2. I'll that installed by this time tomorrow...I > hope.> http://cgm.cs.mcgill.ca/~luc/math.html> I started reading through this list, and had visions of recursively > downloading the entire internet looking for the font's I really need. > Anybody know what fonts I should have installed on my SuSE box to satisfy > Mathematica's default expectations?The contents of the page at this URL are interesting, but probably not relevant for your purposes.The only fonts which are absolutely needed by the front end are the fontsthat supply the special glyphs for mathematical notation, groupingcharacters, Greek letters, etc. These fonts were developed by Wolfram Research and are installed as part of the Mathematica installation. There are two generations of these fonts. The first generation wasintroduced in Mathematica 3.0 in the fall of 1996 and were used throughthe release of Mathematica 4.1. There were five families known as Math1 - Math5. Each familiy had four variants: a proportionaly-spaced medium face, a monospaced medium, a proportional bold, and a monospaced bold. The second generation is used by Mathematica 4.2. There are seven families named Mathematica1 - Mathematica7.Aside from the math fonts, the front end should be able to functionproperly provided that you have a font that supports the encoding for yourchosen locale. The style sheets bundled with the front end use onlyTimes, Helvetica, and Courier. Should these fonts not be available onyour system, the front end has some substitution rules. For example, the Windows front end knows to use the fonts Times New Roman,Arial, and Courier New. The X Window System ships with bitmap versions ofTimes, Helvetica, and Courier as well as an outline of Courier. If one ofthese fonts must be drawn at a size for which there are no bitmaps, outline fonts provided with Mathematica are used. Helvetica is aliased to Swiss721, and Times is aliased to Utopia through a fonts.alias file in the Mathematica fonts directory.Under MacOS and Windows, you should be albe to use whatever fonts areavailable on your system. Under X, things are a little more complicated. The front end can display whatever fonts are made available to your Xserver, but it can generate PostScript only for those fonts where an AdobeFont Metric (AFM) file is available. If you wish to display or print thePostScript, you must also make the Type 1 font file available to therendering device.Note also that the X front end has an adjustable setting for the amount of memory to reserve for storing font data. If your system has a large number of fonts, you may need to increase this setting per this FAQ page:http://support.wolfram.com/mathematica/systems/linux/ interface/fonterrors.html-- User Interface Programmer paulh@wolfram.comWolfram Research, Inc. ==== >> I came across this, and thought I would share. This may be OBE if the>> font>> selection is better in 4.2. I'll that installed by this time>> tomorrow...I hope.> http://cgm.cs.mcgill.ca/~luc/math.html> I started reading through this list, and had visions of recursively>> downloading the entire internet looking for the font's I really need.>> Anybody know what fonts I should have installed on my SuSE box to satisfy>> Mathematica's default expectations?> The contents of the page at this URL are interesting, but probably not> relevant for your purposes.That's kind'o' what I thought.[snip - history lesson - thanks]> The second generation is used by Mathematica 4.2. There are seven> families named Mathematica1 - Mathematica7.Where is the documentation for installing these?This is dated:http://support.wolfram.com/mathematica/systems/linux/ interface/fonterrors.htmlI grabbed these off the net:http://support.wolfram.com/mathematica/systems/linux/ general/latestfonts.htmlhttp://support.wolfram.com/ mathematica/systems/linux/general/MathBDF_42.tar.gzhttp:// support.wolfram.com/mathematica/systems/linux/general/MathPCF _42.tar.gzhttp://support.wolfram.com/mathematica/systems/ linux/general/MathT1_42.tar.gz> su -******# cd /usr/X11/lib/X11/fonts/# mkdir -p local/mma# cd local/mma# tar xvfz /download/com/wri/MathBDF_42.tar.gz# tar xvfz /download/com/wri/MathPCF_42.tar.gz# tar xvfz /download/com/wri/MathT1_42.tar.gz# xemacs /etc/X11/XF86Config ....# grep FontPath /etc/X11/XF86Config FontPath /usr/X11R6/lib/X11/fonts/100dpi:unscaled FontPath /usr/X11R6/lib/X11/fonts/75dpi:unscaled FontPath /usr/X11R6/lib/X11/fonts/CID FontPath /usr/X11R6/lib/X11/fonts/Speedo FontPath /usr/X11R6/lib/X11/fonts/Type1 FontPath /usr/X11R6/lib/X11/fonts/URW FontPath /usr/X11R6/lib/X11/fonts/kwintv:unscaled FontPath /usr/X11R6/lib/X11/fonts/latin2/Type1 FontPath /usr/X11R6/lib/X11/fonts/misc:unscaled FontPath /usr/X11R6/lib/X11/fonts/misc/sgi:unscaled FontPath /usr/X11R6/lib/X11/fonts/truetype FontPath /usr/X11R6/lib/X11/fonts/uni:unscaled FontPath /usr/X11R6/lib/X11/fonts/local/mma/BDF FontPath /usr/X11R6/lib/X11/fonts/local/mma/PCF FontPath /usr/X11R6/lib/X11/fonts/local/mma/T1# SuSEconfig....# init 3 [assuming you are already at a TTY console]# init 5> Aside from the math fonts, the front end should be able to function> properly provided that you have a font that supports the encoding for your> chosen locale. The style sheets bundled with the front end use only> Times, Helvetica, and Courier. Should these fonts not be available on> your system, the front end has some substitution rules.> > For example, the Windows front end knows to use the fonts Times New Roman,> Arial, and Courier New. The X Window System ships with bitmap versions of> Times, Helvetica, and Courier as well as an outline of Courier. If one of> these fonts must be drawn at a size for which there are no bitmaps,> outline fonts provided with Mathematica are used. Helvetica is aliased to> Swiss721, and Times is aliased to Utopia through a fonts.alias file in the> Mathematica fonts directory.This is what I find anoying. Every time Mathematica does one of these substitutions, it beeps. This is what I'm calling a font fault. It's like the boy who cried wolf. I start ignoring beeps. It also bothers me that I am not seeing what the author had intended. I *believe* it is the author of the notebook or help document who determines what fonts should be used. This is a point of confusion. When I opened a help page, and didn't like the size of the fonts, I tried to adjust them without the desired result. I now believe the proper remedy is to use magnification, not a font adjustment.I have far fewer chirps (beeps) in 4.2, but I do get them when changing the magnification. > Under MacOS and Windows, you should be albe to use whatever fonts are> available on your system. Under X, things are a little more complicated.> The front end can display whatever fonts are made available to your X> server, but it can generate PostScript only for those fonts where an Adobe> Font Metric (AFM) file is available. If you wish to display or print the> PostScript, you must also make the Type 1 font file available to the> rendering device.This is for another day. I believe I have done this in years gone by, but, for now, I just want to get the optimal behavior form the crt.[snip]Here's my question in a nutshell. When I do xlsfonts, what should be listed in order to run Mathematica 4.2 and not experiece font faults generated by content provided on the CD?Please note that I *just* finished installing the fonts off the web, so I'm not sure what, if any problems still remain. I suspect the helvetica faults will still occur.STH. ==== I'm a newbie and, of course, the first thing I want to do is apparently one of the most complicated...I have an expression that looks like this:A + B/C + D*Sqrt[E]/C = 0A,B,C,D, & E are all polynomials in xI want it to look like this(D^2)*E = (A*C + B)^2At that point, I'll have polynomials in x on both sides. Finally, I want the equation to be written out with terms grouped by powers of x, but I think I can do that part :)I'll be very grateful to anyone who can give me some pointers. Or, at least point me to some tutorial in the Mathematica documentation. I've been looking over the documentation and I found Appendix A.5 in The Mathematica Book, but that doesn't help me. I _need_ some examples. I did find a couple of well-written posts in this newsgroup, but not quite close enough to what I want.Troy.=-=-=-=-=-=-=-=-=-=FYI, here's the expression I'm working with.denom = Sqrt[(B^2 - r^2)^2 + 4*(r^2)*(b^2)]cnu = (2*b^2 - B^2 + r^2)/denomsnu = -2*b*Sqrt[B^2 - b^2]/denomsif = 2*r*b/denomcif = (r^2 - B^2)/denompdr = -Cos[ds]*Sin[q]*(snu*cif + cnu*sif) - Sin[ds]*(cnu*cif - snu*sif)0 == -(B^2 - b^2)*V^2/(r^2) + (((B*V)^2)/( r^2) - 2*w*b*V*Cos[q]*Cos[ds] + (w* r)^2 - (w*r*pdr)^2)*(Cos[qr])^2 Although I said it's a polynomial in x, it's really a polynomial in b that I'm after. ==== Troy,True, interactive manipulation can be difficult.However, here is one way to do what you want.We have to do the same thing to both sides of the equation. (# - D*Sqrt[K]/C)&/@(A+B/C+D*Sqrt[K]/C[Equal]0 A + B/C == -((D*Sqrt[K])/C) Together/@% (B + A*C)/C == -((D*Sqrt[K])/C) #C&/@% B + A*C == (-D)*Sqrt[K] #^2&/@% (B + A*C)^2 == D^2*KNOTES.Here is how #C&/@ (lhs ==rhs) works:#C&/@ (lhs ==rhs) --> #C&[lhs]==#C&[rhs] --> lhs C == rhs C --> ... f/@( expr) is special for for Map[f, expr]expr& is special for Function[expr]Please look up Map and Function in the Help Browser.--Allan---------------------Allan HayesMathematica Training and ConsultingLeicester UKwww.haystack.demon.co.ukhay@haystack.demon.co.ukVoice : +44 (0)116 271 4198> I'm a newbie and, of course, the first thing I want to do is apparently> one of the most complicated...>> I have an expression that looks like this:>> A + B/C + D*Sqrt[E]/C = 0>> A,B,C,D, & E are all polynomials in x> I want it to look like this>> (D^2)*E = (A*C + B)^2>> At that point, I'll have polynomials in x on both sides. Finally, I> want the equation to be written out with terms grouped by powers of x,> but I think I can do that part :)>> I'll be very grateful to anyone who can give me some pointers. Or, at> least point me to some tutorial in the Mathematica documentation. I've> been looking over the documentation and I found Appendix A.5 in The> Mathematica Book, but that doesn't help me. I _need_ some examples. I> did find a couple of well-written posts in this newsgroup, but not quite> close enough to what I want.> Troy.>> =-=-=-=-=-=-=-=-=-=>> FYI, here's the expression I'm working with.> denom = Sqrt[(B^2 - r^2)^2 + 4*(r^2)*(b^2)]> cnu = (2*b^2 - B^2 + r^2)/denom> snu = -2*b*Sqrt[B^2 - b^2]/denom> sif = 2*r*b/denom> cif = (r^2 - B^2)/denom>> pdr = -Cos[ds]*Sin[q]*(snu*cif +> cnu*sif) - Sin[ds]*(cnu*cif - snu*sif)>> 0 == -(B^2 - b^2)*V^2/(r^2) + (((B*V)^2)/(> r^2) - 2*w*b*V*Cos[q]*Cos[ds] + (w*> r)^2 - (w*r*pdr)^2)*(Cos[qr])^2>> Although I said it's a polynomial in x, it's really a polynomial in b> that I'm after.> ==== > Troy,> True, interactive manipulation can be difficult.> However, here is one way to do what you want.> We have to do the same thing to both sides of the equation.> (# - D*Sqrt[K]/C)&/@(A+B/C+D*Sqrt[K]/C[Equal]0> A + B/C == -((D*Sqrt[K])/C)I think I have to apologize for the lack of clarity in my original post. I had tried to word it carefully, but I deceived myself. I should have said:I have an expression that can be put into this form: A + B/C + D*Sqrt[K]/C = 0 A,B,C,D, & K are all polynomials in xI need to get it into that form and, in the end, I want it to look like this(D^2)*K = (A*C + B)^2I think I gave the impression that I have polynomials A,B,C,D, & K at my fingertips. I don't. The expression I have is given at the end of this message. I'm still trying to digest the respones I've garned so far. In the meantime, I decided to post this clarification.>> I'm a newbie and, of course, the first thing I want to do is >> apparently one of the most complicated...>> I have an expression that looks like this:>> A + B/C + D*Sqrt[K]/C = 0>> A,B,C,D, & K are all polynomials in x>> I want it to look like this>> (D^2)*K = (A*C + B)^2>> At that point, I'll have polynomials in x on both sides. Finally, I>> want the equation to be written out with terms grouped by powers of x,>> but I think I can do that part :)>> I'll be very grateful to anyone who can give me some pointers. Or, >> at least point me to some tutorial in the Mathematica documentation. >> I've been looking over the documentation and I found Appendix A.5 in >> The Mathematica Book, but that doesn't help me. I _need_ some >> examples. I did find a couple of well-written posts in this newsgroup, >> but not quite close enough to what I want.>> Troy.>> =-=-=-=-=-=-=-=-=-=>> FYI, here's the expression I'm working with.>> denom = Sqrt[(B^2 - r^2)^2 + 4*(r^2)*(b^2)]>> cnu = (2*b^2 - B^2 + r^2)/denom>> snu = -2*b*Sqrt[B^2 - b^2]/denom>> sif = 2*r*b/denom>> cif = (r^2 - B^2)/denom>> pdr = -Cos[ds]*Sin[q]*(snu*cif +>> cnu*sif) - Sin[ds]*(cnu*cif - snu*sif)>> 0 == -(B^2 - b^2)*V^2/(r^2) + (((B*V)^2)/(>> r^2) - 2*w*b*V*Cos[q]*Cos[ds] + (w*>> r)^2 - (w*r*pdr)^2)*(Cos[qr])^2>> Although I said it's a polynomial in x, it's really a polynomial in >> b that I'm after.> ==== I'm only a little embarassed for not having realized what was happening. (Perhaps I should have slept on it.)Surely I'm not alone in thinking this symbolism is highly nonintuitive. But of course, for it to be otherwise would require another protected symbol...---Selwyn>>In: DSolve[y*D[u[x, y],x] == x*D[u[x, y],y], u[x,y], {x, y}]>>Out: {{u[x, y] -> C[1][(1/2)*(x^2 + y^2)]}}>>Square brackets are used as grouping symbols in the result!?? :^O>>Somebody say it isn't so.> It isn't so> The square bracket is not delineating a factor it is enclosing the argument > to an arbitrary function named C[1]. While the function is dependent on both > x and y the dependence only occurs in the combination (x^2+y^2).> Bob Hanlon> Reply-To: ==== It isn't so. The solution is an arbitrary function of (1/2)*(x^2 +y^2)]}}.Bobby-----Original Message----- ==== Does anyone know what happened to the < Does anyone know what happened to the < in Mathematica 4.x? In some version I know I used it, but it seems to> have gone away. It allowed for real time manipulation of 3D graphics.> > Ray Gittings ==== > it's still there> << RealTime3D`> > but MathGL3d may be the better solution> http://phong.informatik.uni-leipzig.de/~kuska/mathgl3dv3/> Jens>>Does anyone know what happened to the <>in Mathematica 4.x? In some version I know I used it, but it seems to>>have gone away. It allowed for real time manipulation of 3D graphics.>>Ray Gittings> ==== > The more I play with the example the more> depressing it gets. Start> with ßoating point numbers but explicitly> arbitrary-precision ones.> In[1]:=> a=77617.00000000000000000000000000000;> b=33095.00000000000000000000000000000;> In[3]:=> !(333.7500000000000000000000000000000 b^6 +> a^2 ((11 a^2> b^2 - > b^6 - 121 b^4 - 2)) +> 5.500000000000000000000000000000 b^8 +> a/(2> b))> Out[3]=> >>!((-4.78339168666055402578083604864320577443814` 26.6715*^32))> In[4]:=> Accuracy[%]> Out[4]=> -6> Due to the manual section 3.1.6:> When you do calculations with arbitrary-precision> numbers, as> discussed in the previous section, Mathematica> always keeps track of> the precision of your results, and gives only> those digits which are> known to be correct, given the precision of your> input. When you do> calculations with machine-precision numbers,> however, Mathematica> always gives you a machine[CapitalEth]precision result,> whether or not all the> digits in the result can, in fact, be determined> to be correct on the> basis of your input. > Because I started with arbitrary-precision numbers> Mathematica should display> only those digits that are correct, that is none.> > No, 26 digits are correct Here is the number:-0.8273960599468213681Here is the same number computed by Mathematica with 26correct digits:-4.78339168666055402578083604864320577443814[Times]10 ^32It looks like I have been using some wrong definitionof correct.:-)You just proved that Precision is useless as a measurehow good your numerical result is. > (check Precision instead> of Accuracy to see> this).> You appear to be showing output in InputForm. If you> use OutputForm or> StandardForm only 26 digits will be shown.> 32> Out[3]= -4.7833916866605540257808360 10> InputForm is showing more because it exposes bad> digits as well as> good ones.> > To relax a bit, set a new input cell to> StandardForm and type> 77617.000000000000000000000000000000000> Convert it to InputForm. You get> >>77616.999999999999999999999999999999999999999999952771` 37.9031> Convert back to StandardForm> >>77616.99999999999999999999999999999999999999999976637` 37.9031> Again to InputForm> >>77616.99999999999999999999999999999999999999999963735` 37.9031> Back to StandardForm> >>77616.99999999999999999999999999999999999999999951376` 37.9031> See what you can get if you have enough patience> or a small program.> PK> Agreed, it's not very pretty. I am uncertain as to> whether this> indicates a bug in StandardForm or elsewhere in the> underlying numerics> code, and will defer to our numerics experts on that> issue. My guess is> it is a bug if only because it violates the spirit> of IEEE arithmetic> wherein ßoats that have integer values should be> representable as such> (or something to that effect). I will point out,> however, that the two> numbers in question are equal to the specified> precision. Also it> appears to be improved in our development kernel.> Daniel Lichtblau> Wolfram Research__________________________________________________ Do you Yahoo!?http://faith.yahoo.com ==== > You are entitled to your opinion. For my applications> this behavior IS useless.>I agree that Mathematica is probably useless for you. This is however not because it is useless or useless for your application, but because to use its full power you have to study it, understand it, and in particular, for numerical work, understand the model of arithmetic it uses. Lie with mathematics they are really no shortcuts that will lead you to its full power. In addition, since it is a computer program, it has certain conventions, which may not be the same as the conventions of other programs (they all have conventions) but which you have to accept to be able to use it. Now, once you have done that, you may still not like the way Mathematica does things and there are genuine experts in numerics who indeed do not like and are quite vocal about it. But they never say it is useless, because by saying that you are either displaying your own ignorance or engaging in stupid and pointless abuse.On a more serious level, there seem to be two basic approaches to numeric computation relevant to this discussion. It seems to me (though I am no expert in this sort of thing) that there are three types of situations that one may encounter. Firstly, there is the vast majority of rather simple computations for which built-in machine ßoating point arithmetic , which carries no guarantee of precision at all is meant for. It clearly must be sufficient for the majority of purposes, since most general purpose and even technical software available uses not other method. The reason of course is that it is by far the fastest way to do such computations (as well as being sufficient for most situations).The second type of situation is when you actually know the precision of your input and would like the program to give you some idea about the precision of the output you might expect. This is the most likely situation in empirical science and is exactly what SetPrecision is meant for. Most reasonable people would agree that Mathematica works well in this situation.There is finally one more situation, to which the only reasonable criticism that I have read in this thread appears to be directed at. That is the situation when you actually know your input exactly, but working with exact numbers is far too slow. So what you have to do is to replace your exact numbers with inexact ones padded with 0's. In Mathematica you have to take a guess at how much padding you will need, than use SetPrecision to pad the numbers, and then check the Precision of your answer. It may turn out that you did not get as much precision as you needed, in which case you have to use more zeros. Or it may be that you used more than enough, which mans that your computation could have been done faster. I learned from Leszek Sczaniecki that there is an approach due to Oliver Aberth which lets you only specify the desired precision of your answer and the program itself will choose the correct padding for your input. It woudl ertainly be nice to have this ability, but I honestly think that it would be only of marginal advantage over making your own guess. It seems to me that the checking that the Aberth mthod must require will be time consuming and wiht a bit of practice one can probably get better results as far as speed is concerned using the Mathematica approach. But this is just pure speculation and certainly it woudl be nice if such a possibility existed.Andrzej KozlowskiToyama International UniversityJAPANhttp://sigma.tuins.ac.jp/~andrzej/ ==== >Yes , there seems to be a lot of people who have a visceral hatred for>Microsoft and Windows. They are even willing to shed blood to avoid>Windows. But why? Windows works and you don't have to become a systems>programmer.>>Furthermore, I think that Steven Wolfram uses some version of Windows.>So guess which system Mathematica will be best tuned up for?If it is true Wolfram uses Mathematica on a Windows based machine my experience is it doesn't translate to Mathematica running better on Windows. I use Mathematica on WindowsNT and on a Mac (currently Mac OS X). I have found Mathematica to be more stable on a Mac than on Windows. On more than one occassion I've seen errors I made Mathematica code to crash the entire machine under WindowsNT. I've never had this happen running things on a Mac. ==== >>Yes, there seems to be a lot of people who have a visceral hatred for>>Microsoft and Windows. They are even willing to shed blood to avoid>>Windows. But why? Windows works and you don't have to become a systems>>programmer.>>Furthermore, I think that Steven Wolfram uses some version of Windows.>>So guess which system Mathematica will be best tuned up for?> If it is true Wolfram uses Mathematica on a Windows based machine my> experience is it doesn't translate to Mathematica running better on> Windows. I use Mathematica on WindowsNT and on a Mac (currently Mac OS X).> I have found Mathematica to be more stable on a Mac than on Windows. On> more than one occassion I've seen errors I made Mathematica code to crash> the entire machine under WindowsNT. I've never had this happen running> things on a Mac.I believe you hit the nail on the head. I suspect Dr. Wolfram is running on Mac. I have the feeling WRI is a clandestine Mac holdout.STH. ==== I ran Turbo XML http://www.tibco.com/solutions/products/extensibility/turbo_ xml.jsp on ToFileName[{$TopDirectory, SystemFiles, IncludeFiles, XML}, notebookml1.dtd ]It gave me an error saying: There is more than one attribute named class. My guess is this was the intention:hattons@ljosalfr:~/.Mathematica/SystemFiles/ IncludeFiles/XML/NotebookML1> diff /opt/Wolfram/Mathematica/4.2/SystemFiles/IncludeFiles/XML/ NotebookML1/notebookml.dtd /home/hattons/.Mathematica/SystemFiles/IncludeFiles/XML/ NotebookML1/notebookml.dtd91c91Comments?STH. ==== I've posted Mathematica notebooks and packages illustrating most of theneural networks discussed in James Anderson's book An Introduction toNeural Networks to the Brainstage Research web site (www.brainstage.com).Have fun!DonDonald Doherty, Ph.D.Brainstage Research, Inc.donald.doherty@brainstage.com ==== can I have mathematica solver things like a(over)b, (in how many ways can you pick b items from a items)?I have mathematica 4.Stefan ==== StefanYou certainly can - try Binomial[a,b].Mark Westwood> can I have mathematica solver things like a(over)b, (in how many ways> can you pick b items from a items)?> I have mathematica 4.> Stefan ==== There are two basic ways, the second of which has two forms. The basic ways are:1. Using the built in function ContourPlot, e.g.:ContourPlot[x^3y + y^3 - 9, {x, -9, 9}, {y, -27, 27}, Contours -> {0}, ContourShading -> False, Axes -> True, Frame -> False, PlotPoints -> 50, AxesOrigin -> {0, 0}]alternatively you can use a Standard package:<{0,0}]or ImplicitPlot[x^3y+y^3-==9,{x,-9,9},{y,-27,27},AxesOrigin->{ 0,0}]The difference between these two is that the first one gives you a smoother picture but requires the equation to be solvable (by Mathematica) for y. The second will give a picture very similar to that produced by the first method.Andrzej KozlowskiYokohama, Japanhttp://www.mimuw.edu.pl/~akoz/http:// platon.c.u-tokyo.ac.jp/andrzej/> How can I plot functions like:>> (x-2)^2 + 2(y-3)^2 = 6>> and>> x^3y + y^3 = 9>> using Mathematica?>> ==== Since you already know the answer, the simplest way is:In[51]:=Factor[x^4 + x^3 + x^2 + x + 1, Extension -> {GoldenRatio}]Out[51]=(-(-1 - x + GoldenRatio*x - x^2))*(1 + GoldenRatio*x + x^2)Andrzej KozlowskiYokohama, Japanhttp://www.mimuw.edu.pl/~akoz/http:// platon.c.u-tokyo.ac.jp/andrzej/> Greetings MathGroup,>> My name is Steve Earth, and I am a new subscriber to this list and > also a> new user of Mathematica; so please forgive this rather simple > question...>> I would like to enter the quartic x^4 + x^3 + x^2 + x + 1 into > Mathematica> and have it be able to tell me that it factors into>> (x^2 + GoldenRatio x + 1) ( x^2 - 1/GoldenRatio x + 1)>> What instructions do I need to execute to achieve this output?>> -Steve Earth> Harker School> http://www.harker.org/>> Greetings MathGroup,>> My name is Steve Earth, and I am a new subscriber to this list and > also a> new user of Mathematica; so please forgive this rather simple > question...>> I would like to enter the quartic x^4 + x^3 + x^2 + x + 1 into > Mathematica> and have it be able to tell me that it factors into>> (x^2 + GoldenRatio x + 1) ( x^2 - 1/GoldenRatio x + 1)>> What instructions do I need to execute to achieve this output?>> -Steve Earth> Harker School> http://www.harker.org/>Andrzej KozlowskiYokohama, Japanhttp://www.mimuw.edu.pl/~akoz/http:// platon.c.u-tokyo.ac.jp/andrzej/ ==== I confess I am not 100% sure what you mean. Would you like to do this in steps, like you would do it by hand?In[1]:=a + b/c + d*(Sqrt[e]/c) == 0;In[2]:=Thread[(#1 - a - b/c & )[%], Equal]Out[2]=(d*Sqrt[e])/c == -a - b/cIn[3]:=Thread[(#1*c & )[%], Equal]Out[3]=d*Sqrt[e] == (-a - b/c)*cIn[4]:=Thread[(#1^2 & )[%], Equal]Out[4]=d^2*e == (-a - b/c)^2*c^2In[5]:=Simplify[%]Out[5]=d^2*e == (b + a*c)^2Of course you can combine all the steps into a single function, but I think it will be fairly complicated.My own favourite way to do this sort of thing is:In[1]:=Simplify[d^2*e == (d^2*e /. AlgebraicRules[ a + b/c + d*(Sqrt[e]/c) == 0, e])]Out[1]=d^2*e == (b + a*c)^2However, AlgebraicRules has not been documented since version 4. It should be possible to do this using PolynomialReduce but it seems to require the sort of skill only Daniel Lichtblau possesses;)Andrzej KozlowskiToyama International UniversityJAPANhttp://sigma.tuins.ac.jp/~andrzej/> I'm a newbie and, of course, the first thing I want to do is apparently> one of the most complicated...>> I have an expression that looks like this:>> A + B/C + D*Sqrt[E]/C = 0>> A,B,C,D, & E are all polynomials in x> I want it to look like this>> (D^2)*E = (A*C + B)^2>> At that point, I'll have polynomials in x on both sides. Finally, I> want the equation to be written out with terms grouped by powers of x,> but I think I can do that part :)>> I'll be very grateful to anyone who can give me some pointers. Or, at> least point me to some tutorial in the Mathematica documentation. I've> been looking over the documentation and I found Appendix A.5 in The> Mathematica Book, but that doesn't help me. I _need_ some examples. I> did find a couple of well-written posts in this newsgroup, but not > quite> close enough to what I want.> Troy.>> =-=-=-=-=-=-=-=-=-=>> FYI, here's the expression I'm working with.> denom = Sqrt[(B^2 - r^2)^2 + 4*(r^2)*(b^2)]> cnu = (2*b^2 - B^2 + r^2)/denom> snu = -2*b*Sqrt[B^2 - b^2]/denom> sif = 2*r*b/denom> cif = (r^2 - B^2)/denom>> pdr = -Cos[ds]*Sin[q]*(snu*cif +> cnu*sif) - Sin[ds]*(cnu*cif - snu*sif)>> 0 == -(B^2 - b^2)*V^2/(r^2) + (((B*V)^2)/(> r^2) - 2*w*b*V*Cos[q]*Cos[ds] + (w*> r)^2 - (w*r*pdr)^2)*(Cos[qr])^2>> Although I said it's a polynomial in x, it's really a polynomial in b> that I'm after.>> ==== Only on second reading I noticed the part about a,b,c,d being polynomials in x. Both methods will still work if first perform the same operation as below and finally use the replacement rule%/.{a->p[x],b->q[x],c->r[x],d->u[x],e->v[x]}, where p[x] etc are the given polynomials. Of course collecting of terms can be done with Collect[%,x].Andrzej KozlowskiYokohama, Japanhttp://www.mimuw.edu.pl/~akoz/http:// platon.c.u-tokyo.ac.jp/andrzej/> I confess I am not 100% sure what you mean. Would you like to do this > in steps, like you would do it by hand?>> In[1]:=> a + b/c + d*(Sqrt[e]/c) == 0;>> In[2]:=> Thread[(#1 - a - b/c & )[%], Equal]>> Out[2]=> (d*Sqrt[e])/c == -a - b/c>> In[3]:=> Thread[(#1*c & )[%], Equal]>> Out[3]=> d*Sqrt[e] == (-a - b/c)*c>> In[4]:=> Thread[(#1^2 & )[%], Equal]>> Out[4]=> d^2*e == (-a - b/c)^2*c^2>> In[5]:=> Simplify[%]>> Out[5]=> d^2*e == (b + a*c)^2>> Of course you can combine all the steps into a single function, but I > think it will be fairly complicated.>> My own favourite way to do this sort of thing is:>> In[1]:=> Simplify[d^2*e == (d^2*e /. AlgebraicRules[> a + b/c + d*(Sqrt[e]/c) == 0, e])]>> Out[1]=> d^2*e == (b + a*c)^2>> However, AlgebraicRules has not been documented since version 4. It > should be possible to do this using PolynomialReduce but it seems to > require the sort of skill only Daniel Lichtblau possesses;)>> Andrzej Kozlowski> Toyama International University> JAPAN> http://sigma.tuins.ac.jp/~andrzej/> I'm a newbie and, of course, the first thing I want to do is >> apparently>> one of the most complicated...>> I have an expression that looks like this:>> A + B/C + D*Sqrt[E]/C = 0>> A,B,C,D, & E are all polynomials in x>> I want it to look like this>> (D^2)*E = (A*C + B)^2>> At that point, I'll have polynomials in x on both sides. Finally, I>> want the equation to be written out with terms grouped by powers of x,>> but I think I can do that part :)>> I'll be very grateful to anyone who can give me some pointers. Or, at>> least point me to some tutorial in the Mathematica documentation. >> I've>> been looking over the documentation and I found Appendix A.5 in The>> Mathematica Book, but that doesn't help me. I _need_ some examples. I>> did find a couple of well-written posts in this newsgroup, but not >> quite>> close enough to what I want.>> Troy.>> =-=-=-=-=-=-=-=-=-=>> FYI, here's the expression I'm working with.>> denom = Sqrt[(B^2 - r^2)^2 + 4*(r^2)*(b^2)]>> cnu = (2*b^2 - B^2 + r^2)/denom>> snu = -2*b*Sqrt[B^2 - b^2]/denom>> sif = 2*r*b/denom>> cif = (r^2 - B^2)/denom>> pdr = -Cos[ds]*Sin[q]*(snu*cif +>> cnu*sif) - Sin[ds]*(cnu*cif - snu*sif)>> 0 == -(B^2 - b^2)*V^2/(r^2) + (((B*V)^2)/(>> r^2) - 2*w*b*V*Cos[q]*Cos[ds] + (w*>> r)^2 - (w*r*pdr)^2)*(Cos[qr])^2>> Although I said it's a polynomial in x, it's really a polynomial in >> b>> that I'm after.>> ==== <{-1,5}]ImplicitPlot[x ^3y + y^3 == 9, {x, -10, 10}]Meilleures salutationsFlorian Jaccard-----Message d'origine-----Envoy.8e : dim., 6. octobre 2002 11:34è : mathgroup@smc.vnet.netObjet : Plotting ellipses and other functionsHow can I plot functions like:(x-2)^2 + 2(y-3)^2 = 6andx^3y + y^3 = 9using Mathematica? ==== >How can I plot functions like:>>(x-2)^2 + 2(y-3)^2 = 6>>and>>x^3y + y^3 = 9>>using Mathematica?>Needs[Graphics`ImplicitPlot`];ImplicitPlot[ (x - 2)^2 + 2(y - 3)^2 == 6, {x, -1, 5}, {y, 1, 5}];ImplicitPlot[x^3 y + y^3 == 9, {x, -6, 6}, {y, -6, 6}];Bob Hanlon ==== >Could somebody please inform me how to Round numbers to a>certain Accuracy using Mathematica 4.2. This is not as easy as it>sounds.>Every function that I have read Rounds the Display, and not the actual>number.myRound[x_, n_] := Round[10^n*x]/10.^n;Table[myRound[Random[], 3], {10}]{0.044, 0.019, 0.738, 0.298, 0.917, 0.171, 0.021, 0.314, 0.658, 0.153}Bob HanlonReply-To: tgarza01@prodigy.net.mx ==== You might use ImplicitPlot:In[1]:=<< Graphics`ImplicitPlot`In[2]:=eqn1 = (x - 2)^2 + 2*(y - 3)^2 == 6; In[3]:=ImplicitPlot[eqn1, {x, -2, 6}]; In[4]:=eqn2 = x^3*y + y^3 == 9; In[5]:=ImplicitPlot[eqn2, {x, -8, 8}]; Tomas GarzaMexico CityOriginal Message:----------------- ==== You may use Binomial. It could also be useful to look at the AddOn packageDiscreteMath`Combinatorica`, where you will find a wealth of interestingthings related to that.In[1]:=Binomial[6,2]Out[1]=15Tomas GarzaMexico CityOriginal Message:----------------- ==== I feel as if I've finally had the breakthrough in intuitively understanding the Mathematica editor, or at least the basics. I want to explain to others what they really need to know about the editor to use it for basic purposes. Part of the reason I now understand the editor better is that I've since worked with LyX http://www.devel.lyx.org and XEmacs http://www.xemacs.org, and I've also become proficient with DocBook XML.When I first started using the editor, reading the Mathematica Help didn't seem to help. It seemed to tell me a whole lot more than I needed to know, and didn't tell me what I really needed to know. Now I'm in the position of being able to use it, but not being able to explain exactly what it is I've learned. Is there any documentation directed toward the beginner, which tells him or her what to do, what to expect, what quirks to be aware of, and etc.? I'm looking for something along the lines of click here to make this happen. If you see this, it may seem weird, but that's normal. Those brackedt on the left really mean... . STH. ==== >I would like to enter the quartic x^4 + x^3 + x^2 + x + 1 into Mathematica>and have it be able to tell me that it factors into>>(x^2 + GoldenRatio x + 1) ( x^2 - 1/GoldenRatio x + 1)>>What instructions do I need to execute to achieve this output?>soln = Factor[x^4 + x^3 + x^2 + x + 1, Extension -> GoldenRatio] // Simplify(x^2 - GoldenRatio*x + x + 1)*(x^2 + GoldenRatio*x + 1)soln = Simplify /@ (soln /. -GoldenRatio -> -1 - 1/GoldenRatio)(x^2 - x/GoldenRatio + 1)*(x^2 + GoldenRatio*x + 1)soln // FunctionExpand // FullSimplifyx^4 + x^3 + x^2 + x + 1Bob Hanlon ==== Stefan,I don't think I completely understand your question, but I think you arelooking for the Binomial function in Mathematica.Binomial[4, 2]6David Parkdjmp@earthlink.nethttp://home.earthlink.net/~djmp/ Sender: steve@smc.vnet.netApproved: Steven M. Christensen , Moderator ==== Steve,You could use the Extension feature of Factor as documented in Help.expr = x^4 + x^3 + x^2 + x + 1ans = Factor[expr, Extension -> {1/GoldenRatio}](-(1/4))*(-2 - x + Sqrt[5]*x - 2*x^2)* (2 + x + Sqrt[5]*x + 2*x^2)You could also use...Factor[expr, Extension -> {Sqrt[5]}]It took me some effort to figure out how to manipulate the answer into yourform.ans /. {x + Sqrt[5]*x -> (2*GoldenRatio)*x, -x + Sqrt[5]*x -> (2/GoldenRatio)*x}% /. (-4^(-1))*a_*b_ :> Simplify[-a/2]*Simplify[b/2](-(1/4))*(-2 + (2*x)/GoldenRatio - 2*x^2)* (2 + 2*GoldenRatio*x + 2*x^2)(1 - x/GoldenRatio + x^2)*(1 + GoldenRatio*x + x^2)David Parkdjmp@earthlink.nethttp://home.earthlink.net/~djmp/ http://www.harker.org/ ==== David,To plot equations like that, simply use ImplicitPlot.Needs[Graphics`ImplicitPlot`]ImplicitPlot[( x - 2)^2 + 2(y - 3)^2 == 6, {x, -1, 5}, {y, 1, 5}];ImplicitPlot[x^3*y + y^3 == 9, {x, -10, 10}, {y, -10, 10}];You may have to fish a little to obtain the appropriate x and y ranges.Start by making them larger and then narrow down to the region that youwant.I have put a new package at my web site for solving conic section problemsin the plane. You can solve for complete information on any conic sectionand obtain a parametric representation for plotting it. The package alsocomes with complete Help documentation and examples.Using your first example (the second is not a conic).Needs[ConicSections`ConicSections`]eqn = (x - 2)^2 + 2(y - 3)^2 == 6;The routine ParseConic will take any quadratic equation and return the scalea, eccentricity e, a parametrization, and rotation matrix P, translation Tand reßection matrix R that transforms the conic from standard position toits actual position. (In standard position the conic has its foci andverticies on the x-axis with the center at zero.){{a, e}, curve[t_], {P, T, R}} = ParseConic[eqn]{{Sqrt[6], 1/Sqrt[2]}, {2 + Sqrt[6]*Cos[t], 3 + Sqrt[3]*Sin[t]}, {{{1, 0}, {0, 1}}, {2, 3}, {{1, 0}, {0, 1}}}}We could then plot the curve using ParametricPlot, which is more efficientand controllable.ParametricPlot[Evaluate[curve[t]], {t, -Pi, Pi}, AspectRatio -> Automatic, Frame -> True, Axes -> None, PlotLabel -> eqn];Knowing a and e we can use the StandardConic routine to obtain all theinformation about the conic in standard position as a set of rules.standarddata = StandardConic[{a, e}]{conictype -> Ellipse, conicequation -> x^2/6 + y^2/3 == 1, coniccurve -> {Sqrt[6]*Cos[t], Sqrt[3]*Sin[t]}, coniccurvedomain -> {-Pi, Pi}, coniccenter -> {0, 0}, conicfocus -> {{Sqrt[3], 0}, {-Sqrt[3], 0}}, conicdirectrix -> {x == -2*Sqrt[3], x == 2*Sqrt[3]}, conicvertex -> {{Sqrt[6], 0}, {-Sqrt[6], 0}}}routine to obtain the same information for the conic in its actual position.standarddata // TransformEllipseRules[P, T, R]{conictype -> Ellipse, conicequation -> (1/6)*((-2 + x)^2 + 2*(-3 + y)^2) == 1, coniccurve -> {2 + Sqrt[6]*Cos[t], 3 + Sqrt[3]*Sin[t]}, coniccurvedomain -> {-Pi, Pi}, coniccenter -> {2, 3}, conicfocus -> {{2 + Sqrt[3], 3}, {2 - Sqrt[3], 3}}, conicdirectrix -> {2*Sqrt[3] + x == 2, x == 2*(1 + Sqrt[3])}, conicvertex -> {{2 + Sqrt[6], 3}, {2 - Sqrt[6], 3}}}David Parkdjmp@earthlink.nethttp://home.earthlink.net/~djmp/ Sender: steve@smc.vnet.netApproved: Steven M. Christensen , ModeratorReply-To: ==== Try this:A + B/C + D*(Sqrt[E]/C) == 0(#1 - %[[1,{1, 2}]] & ) /@ %(C*#1 & ) /@ %(#1^2 & ) /@ %Simplify[%]Also, be aware that E is the natural logarithm base, reserved for thatpurpose.DrBob-----Original Message-----want the equation to be written out with terms grouped by powers of x, but I think I can do that part :)I'll be very grateful to anyone who can give me some pointers. Or, at least point me to some tutorial in the Mathematica documentation. I've been looking over the documentation and I found Appendix A.5 in The Mathematica Book, but that doesn't help me. I _need_ some examples. I did find a couple of well-written posts in this newsgroup, but not quiteclose enough to what I want.Troy.=-=-=-=-=-=-=-=-=-=FYI, here's the expression I'm working with.denom = Sqrt[(B^2 - r^2)^2 + 4*(r^2)*(b^2)]cnu = (2*b^2 - B^2 + r^2)/denomsnu = -2*b*Sqrt[B^2 - b^2]/denomsif = 2*r*b/denomcif = (r^2 - B^2)/denompdr = -Cos[ds]*Sin[q]*(snu*cif + cnu*sif) - Sin[ds]*(cnu*cif - snu*sif)0 == -(B^2 - b^2)*V^2/(r^2) + (((B*V)^2)/( r^2) - 2*w*b*V*Cos[q]*Cos[ds] + (w* r)^2 - (w*r*pdr)^2)*(Cos[qr])^2 Although I said it's a polynomial in x, it's really a polynomial in b that I'm after.Reply-To: ==== It's a little ugly, but here's my solution:x^4 + x^3 + x^2 + x + 1Simplify@Factor[%, Extension -> {GoldenRatio, 1/GoldenRatio}]Collect[%[[2]]/3, x]Collect[%[[3]]/3, x]% /. Sqrt[5] -> 2GoldenRatio - 1% // SimplifyCollect[#, x] & /@ %% /. {1 - GoldenRatio -> -1/GoldenRatio}FullSimplify@Expand@%(The last line is a check.)Bobby-----Original Message-----(x^2 + GoldenRatio x + 1) ( x^2 - 1/GoldenRatio x + 1)What instructions do I need to execute to achieve this output?-Steve EarthHarker Schoolhttp://www.harker.org/ ==== >How can I plot functions like:>>(x-2)^2 + 2(y-3)^2 = 6>>and>>x^3y + y^3 = 9>>using Mathematica?Use ImplicitPlot in the package Graphics`ImplicitPlot` ==== David,<{0,0} ]-----Original Message-----Sender: steve@smc.vnet.netApproved: Steven M. Christensen , ModeratorReply-To: jcd@q-e-d.org ==== I look for a way to right align entries output by MatrixForm. There is an adhoc option, but I haven't figured out how it is supposed to work in Mathematica 4.0(if it works at all).m={{MatrixForm[{0,0,0}],-123456789},{123456789,1}}; MatrixForm[m,TableAlignments->{Right,Top}]appears identical toMatrixForm[m] (with no SetOptions override)Strangely, Mathematica doesn't complain if you input ill options like:MatrixForm[m,TableAlignments->{WhateverIsIllegal,Right, Top,MakeSomeSpiralOfIt}]In Mathematica 2.2x, the behavior is rather strange: one option alone works, butwhen two are given (e.g. {Right,Top}), only the last seems to be acted upon.I didn't bother to try hard with the older version, so don't ßame me if I'mwrong.At the other hand, when a TableAlignments->Right is given to TableForm,entries are right-aligned correctly.Can someone provide a way out (even a slow external module) or tell me howto use this option.I apologize for using a phony address in an attempt ==== I decided to export one of my notebooks to html/mathmlhttp://baldur.globalsymmetry.com/proprietary/com /wri/notebooks/essential/66.92.149.152 baldur.globalsymmetry.comWhen I try to view it with Mozilla, I get a Ô?' in place of the imaginary number symbol. When I first load the page with Mozilla, I get an error telling meTo properly display the MathML on this page you need to install the following fonts: CMSY 10, CMEX 10, Math1, Math2, Math4.For further infromation see:http://www.mozilla.org/projects/mathml/fontsI did what the instructions at the URL told me, and I still get the error. I looked through the fonts in the Mathematica font directory, and I found:Mathematica1Mono.9.bdf -wri-mathematica1mono-medium-r-normal--9-90-75-75-m-50- adobe-fontspecificMathematica3.12.bdf -wri-mathematica3-medium-r-normal--12-120-75-75-p-70- adobe-fontspecificMathematica3.24.bdf -wri-mathematica3-medium-r-normal--24-240-75-75-p-130- adobe-fontspecificMathematica3.36.bdf -wri-mathematica3-medium-r-normal--36-360-75-75-p-210- adobe-fontspecific....Mathematica7.12.bdf -wri-mathematica7-medium-r-normal--12-120-75-75-p-40- adobe-fontspecificMathematica7.24.bdf ....-wri-mathematica6-medium-r-normal--12-120-75-75-p-30- adobe-fontspecificMathematica6.24.bdf -wri-mathematica6-medium-r-normal--24-240-75-75-p-70- adobe-fontspecificMathematica6.36.bdf -wri-mathematica6-medium-r-normal--15-150-75-75-p-50- adobe-fontspecificMathematica5.12.bdf -wri-mathematica5-medium-r-normal--12-120-75-75-p-50- adobe-fontspecificMathematica5.24.bdf -wri-mathematica5-medium-r-normal--24-240-75-75-p-110- adobe-fontspecificMathematica5.36.bdf -wri-mathematica5-medium-r-normal--36-360-75-75-p-160- adobe-fontspecificMathematica5.13.bdf -wri-mathematica5-medium-r-normal--13-130-75-75-p-50- adobe-fontspecificMathematica4.18.bdf -wri-mathematica4-medium-r-normal--18-180-75-75-p-130- adobe-fontspecificMathematica5.10.bdf....I suspect this is what mozilla is looking for, but I don't know exactly how to tell it as much. Any ideas?STH.Reply-To: ==== I suppose my silliness is understandable, in light of all the confusion,both here and in the Browser on what significance arithmetic is, whatbignums and bigßoats might be, etc.If many smart people are confused, there's a possibility --- just apossibility, mind you --- that it isn't entirely their fault. Yes? No?>>like 71 above, or -5 for Accuracy in the example that fooled me), butit's not a big dealFor people who don't understand it as well as you, yes, it's a big deal.My purpose in all this is to understand the issue well enough to knowhow to proceed. I think that I do, now, but I doubt everybody on thelist does.Daniel says this will all be clearer in the next release, and that'sgood!Bobby-----Original Message----->> -1.180591620717411303424`71.0721*^21> 71>> 71.0721 digits of precision? I don't think so!!Either I am it altogether or you are just simply beating to death the point that in case of machine arithmetic (only!) Precision and Accuracy are purely formal and essentially meaningless.One can argue whether in this case there is any point of returning any value for Precision, or Accuracy (like 71 above, or -5 for Accuracy in the example that fooled me), but it's not a big deal and it most certainly does not make SetPrecision meaningless. On the contrary, SetPrecision is very useful and in fact it is SetPrecision that can tell you that the answer above is meaningless:In[8]:=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=SetPrecision[77617.,$MachinePrecision]; b = SetPrecision[ 33096.,$MachinePrecision];In[10]:={f,Precision[f]}Out[10]={ 1.19801754103509`0*^19, 0}I would say this is correct and show that SetPrecision is very useful indeed. It tells you (what of course you ought to already know in this case anyway) that machine precision will not give you a realiable answer in this case. If you know your numbers with a great deal of accuracy you can get an accurate answer:In[24]:=f = SetAccuracy[333.75*b^6 + a^2*(11*a^2*b^2 - b^6 - 121*b^4 - 2) + 5.5*b^8 + a/(2*b), 100];a=SetPrecision[77617.,100]; b = SetPrecision[33096.,100];In[26]:={f, Precision[f]}Out[26]={- 0.82739605994682136814116509547981629199903311578438481991 781484167246798617832`61.2597, 61}Again you can be pretty sure that you got an accurate answer, provided of course your original setting of precision was valid.Honestly, to say that SetPrecision and SetAccuaracy are useless is one of the silliest thing I have read on this list in years.>Andrzej KozlowskiYokohama, Japanhttp://www.mimuw.edu.pl/~akoz/http:// platon.c.u-tokyo.ac.jp/andrzej/ ==== How can I plot functions like:(x-2)^2 + 2(y-3)^2 = 6andx^3y + y^3 = 9using Mathematica?Reply-To: kuska@informatik.uni-leipzig.de ==== look whatGraphics`ImplicitPlot`does. Jens> How can I plot functions like:> (x-2)^2 + 2(y-3)^2 = 6> and> x^3y + y^3 = 9> using Mathematica? ==== David:For a start you can try the following:Using ContourPlotContourPlot[(x - 2)^2 + 2(y - 3)^2 - 6, {x, -1, 5}, {y, -1, 5}, Contours -> {0}, ContourShading -> False, ContourSmoothing -> 5]Or using ImplicitPlot<< Graphics`ImplicitPlot`ImplicitPlot[(x - 2)^2 + 2(y - 3)^2 == 6, {x, -1, 5}]ImplicitPlot[x^3y + y^3 == 9, {x, -4, 4}]Hans> How can I plot functions like:>> (x-2)^2 + 2(y-3)^2 = 6>> and>> x^3y + y^3 = 9>> using Mathematica?>> ==== Try reading help under the keyword ImplicitPlot| How can I plot functions like:|| (x-2)^2 + 2(y-3)^2 = 6|| and|| x^3y + y^3 = 9|| using Mathematica?|||| ==== DavidEnquire within the Help Browser for the ImplicitPlot package and allwill be revealed. For example, I snipped the following lines from thedocumentation:<< Graphics`ImplicitPlot`ImplicitPlot[x^2 + 2 y^2 == 3, {x, -2, 2}]Hope this is of sufficient help to get you started - post again if youhave any further questions.Mark Westwood> How can I plot functions like:> > (x-2)^2 + 2(y-3)^2 = 6> and> x^3y + y^3 = 9> using Mathematica? ==== you can. Use:< is there any way of linking Mathematica with Excel?> Lu.92s ==== I am getting the same problem (though Mathematica 4.1).Has anyone any ideas? Aron. >>I am facing the problem in starting the link to math kernel from within>Excel.>>Specifically, when I get the message link failed to open when I click>Launch button in the ÔStart Mathematica Link' dialog box. I have triedusing>Multilink too so that I am able to access the kernel from Mathematicaand>Excel simultaneously but I still get the same message.>>I am currently using Mathematica 4.0 and Excel 2002 (Excel XP). Theprograms>Mathematica and Excel otherwise appear to work fine. I am using WindowsXP>home edition on Dell 8100 laptop. I have used the Mathematica Link forMS>Excel for Excel 2000 in my installation as there were no specific filesfor>Excel 2002. Given that I was able to successfully add the menus withinexcel>I think the addin should work fine but it does not?>>All help would be sincerely appreciated.>>Sincerely,>>Tahir Sheikh. ==== Download the 2002 file from this page. I use it for Excel 2002 Service Pack2.http://support.wolfram.com/applicationpacks/excel_ link/excelxp.html>> I am getting the same problem (though Mathematica 4.1).> Has anyone any ideas?>> Aron.>>I am facing the problem in starting the link to math kernel from within>Excel.>>Specifically, when I get the message link failed to open when I click>Launch button in the ÔStart Mathematica Link' dialog box. I have tried> using> >Multilink too so that I am able to access the kernel from Mathematica> and>Excel simultaneously but I still get the same message.>>I am currently using Mathematica 4.0 and Excel 2002 (Excel XP). The> programs>Mathematica and Excel otherwise appear to work fine. I am using Windows> XP> >home edition on Dell 8100 laptop. I have used the Mathematica Link for> MS>Excel for Excel 2000 in my installation as there were no specific files> for>Excel 2002. Given that I was able to successfully add the menus within> excel>I think the addin should work fine but it does not?>>All help would be sincerely appreciated.>>Sincerely,>> >Tahir Sheikh.> ==== I did not request any accuracy for f. I set the accuracy of the numerical components of the expression f. You cannot request the accuracy of the result of your computation in Mathematica, you can only set the accuracy of the input and later check what accuracy of the output results form it. In my last message on this topic I tried to explain this in the plainest and simplest way I could think of. There is nothing more left for me to say. I feel like Sisyphus but unlike him I can at least give up!Andrzej Kozlowski>> [...]>> I would say this is correct and show that SetPrecision is very useful>> indeed. It tells you (what of course you ought to already know in this>> case anyway) that machine precision will not give you a realiable>> answer in this case. If you know your numbers with a great deal of>> accuracy you can get an accurate answer:>> In[24]:=>> f = SetAccuracy[333.75*b^6 + a^2*(11*a^2*b^2 - b^6 ->> 121*b^4 - 2) + 5.5*b^8 + a/(2*b), 100];>> a=SetPrecision[77617.,100]; b = SetPrecision[33096.,100];>> In[26]:=>> {f, Precision[f]}>> Out[26]=>> {-0.82739605994682136814116509547981629199903311578438481991 >> 781484167246798617832`61.2597, 61}>> Congratulations! You just requested accuracy of 100 for f and got 61 (> to convince yourself add Accuracy[f] to In[26]). If In[24] one> replaces SetAccuracy by SetPrecision the result is similar.>> PK> Again you can be pretty sure that you got an accurate answer, provided>> of course your original setting of precision was valid.>> Honestly, to say that SetPrecision and SetAccuaracy are useless is one>> of the silliest thing I have read on this list in years.> Andrzej Kozlowski>> Yokohama, Japan>> http://www.mimuw.edu.pl/~akoz/>> http://platon.c.u-tokyo.ac.jp/andrzej/>Andrzej KozlowskiYokohama, Japanhttp://www.mimuw.edu.pl/~akoz/http:// platon.c.u-tokyo.ac.jp/andrzej/Reply-To: ==== Here's a more intuitive method, perhaps:a + b/c + d*(Sqrt[e]/c) == 0f = %[[1, 3]]%% /. f -> gFirst@Solve[%, g]f^2 == (g^2 /. %)However, it occurs to me you might want a more general method to collecta radical on one side and then square both sides. If so, here's aclumsy first attempt:expr = a + b/c + d*(Sqrt[e]/c) == 0f = First@Cases[expr, Power[a_, Rational[b_, c_]], Infinity]power = First@Cases[f, Rational[b_, c_] -> Rational[c, b], Infinity]coefficient = First@Cases[expr, Times[a_, f] -> a, Infinity]Solve[expr /. coefficient f -> g, g][[1, 1]]g^2 == (g^2 /. %)% /. g -> coefficient fDrBob-----Original Message-----DrBob-----Original Message-----want the equation to be written out with terms grouped by powers of x, but I think I can do that part :)I'll be very grateful to anyone who can give me some pointers. Or, at least point me to some tutorial in the Mathematica documentation. I've been looking over the documentation and I found Appendix A.5 in The Mathematica Book, but that doesn't help me. I _need_ some examples. I did find a couple of well-written posts in this newsgroup, but not quiteclose enough to what I want.Troy.=-=-=-=-=-=-=-=-=-=FYI, here's the expression I'm working with.denom = Sqrt[(B^2 - r^2)^2 + 4*(r^2)*(b^2)]cnu = (2*b^2 - B^2 + r^2)/denomsnu = -2*b*Sqrt[B^2 - b^2]/denomsif = 2*r*b/denomcif = (r^2 - B^2)/denompdr = -Cos[ds]*Sin[q]*(snu*cif + cnu*sif) - Sin[ds]*(cnu*cif - snu*sif)0 == -(B^2 - b^2)*V^2/(r^2) + (((B*V)^2)/( r^2) - 2*w*b*V*Cos[q]*Cos[ds] + (w* r)^2 - (w*r*pdr)^2)*(Cos[qr])^2 Although I said it's a polynomial in x, it's really a polynomial in b that I'm after. ==== > On Friday, October 4, 2002, at 06:01 PM, DrBob>>[...]>> I would say this is correct and show that> SetPrecision is very useful> indeed. It tells you (what of course you ought> to already know in this> case anyway) that machine precision will not> give you a realiable> answer in this case. If you know your numbers> with a great deal of> accuracy you can get an accurate answer:>> > In[24]:=> f = SetAccuracy[333.75*b^6 + a^2*(11*a^2*b^2 -> b^6 -> 121*b^4 - 2) + 5.5*b^8 + a/(2*b), 100];> a=SetPrecision[77617.,100]; b => SetPrecision[33096.,100];> In[26]:=> {f, Precision[f]}>> Out[26]=> >>{- 0.82739605994682136814116509547981629199903311578438481991> > 781484167246798617832`61.2597, 61}>> Congratulations! You just requested accuracy of> 100 for f and got 61 (> to convince yourself add Accuracy[f] to In[26]).> If In[24] one> replaces SetAccuracy by SetPrecision the result is> similar.> PK> [...]> One has (initially) an accuracy of 100 for an> expression that contains> variables.> In[25]:= Clear[a,b,f]> In[26]:= f = SetAccuracy[333.75*b^6 +> a^2*(11*a^2*b^2 - b^6 -> 121*b^4 - 2) + 5.5*b^8 + a/(2*b), 100]; > In[27]:= Accuracy[f]> Out[27]= 100.> Now we assign values to some indeterminants in f.> In[28]:= a = SetPrecision[77617.,100]; b => SetPrecision[33096.,100];> In[29]:= {f, Precision[f], Accuracy[f]}> Out[29]=>{- 0.827396059946821368141165095479816291999033115784384819917814 8,> 61.2599, 61.3422}> The precision and accuracy has dropped. This is all> according to> standard numerical analysis regarding cancellation> error. You'll find it> in any textbook on the topic.> Assume that I want accuracy and precision of 100 forf. You advice me to make experiments to find out, whatshould be the initial precision and accuracy of a andb to reach the requested accuracy and precision for f.Notice, that you cannot just repeat I[26], we sawalready what happens. I have to re-type I[24], I[25],I[26], I[27], I[28], and I[29] as many times as neededto get f with accuracy and precision 100. Dan, you simply advocate to do MANUAL WORK that shouldbe done by machine.Let's suppose that in the above example I just want 60digits not 61. Precisely, I want 60 digits and nothingor zeros afterwards. Let's see if I could useSetAccuracy.In[30]:=SetAccuracy[%, 60]Out[30]=- 0.82739605994682136814116509547981629199903311578438481991781 In[31]:=% // FullFormOut[30]//FullForm=- 0.827396059946821368141165095479816291999033115784384819917814 841672467988`59.9177Oops, it did not work (as expected). Let's highlightwith mouse the expression in Out[30] and copy to a newcell. Oops, we got - 0.827396059946821368141165095479816291999033115784384819917814 841672467988`59.9177again. Let's change Out[30] to a text cell and thencopy. In[31]:=- 0.82739605994682136814116509547981629199903311578438481991781 Out[31]=- 0.82739605994682136814116509547981629199903311578438481991781 Success? Not so fast.In[32]:=% // FullFormOut[32]//FullForm=- 0.827396059946821368141165095479816291999033115784384819917809 99999999999863508`59.2041Dan, is there any simple way to get what I want? As I repeated already number of times, at this stageof the development of computer technology, softwareshould do it for me (!). We both know that this isdoable. Some of the textbooks that you just advised meto read describe it. As a developer of Mathematica,tell us why do you consider this to be a bad idea? Peter Kosta> As for what happens when you artificially raise> precision (or accuracy)> of machine numbers far beyond that guaranteed by> their internal> representation, that falls into to category of> garbage in, garbage out.> It is, howoever, valid to use SetPrecision to raise> precision in> (typically iterative) algorithms where significance> arithmetic might be> unduly pessimistic due to incorrect assumptions> about uncorollatedness> of numerical error. Examples of such usage have> appeared in this news> group.> > Daniel Lichtblau> Wolfram Research__________________________________________________ Do you Yahoo!?http://faith.yahoo.com ==== > Are there any known issues with simpy treating the JLink.jar as a Java > extension as follows?> cp JLink.jar $JAVA_HOME/jre/lib/ext?> According to my understanding of the discussion in the Java Tutorial on > extensions, that should work:It does;starting with M4.2, J/Link 2.0 gets preinstalled and comes with a 1.4murphee ==== Are there any known issues with simpy treating the JLink.jar as a Java extension as follows?cp JLink.jar $JAVA_HOME/jre/lib/ext?According to my understanding of the discussion in the Java Tutorial on extensions, that should work:http://java.sun.com/docs/books/tutorial/ext/basics/ install.htmlCommants?STH. ==== >Are there any known issues with simpy treating the JLink.jar as a Java>extension as follows?>cp JLink.jar $JAVA_HOME/jre/lib/ext?>>According to my understanding of the discussion in the Java Tutorial on>extensions, that should work:>http://java.sun.com/docs/books/tutorial/ext/basics/ install.html>>Commants?You should not do this. Code from the jre/lib/ext directory is trusted, so this poses a security risk from malicious applets. Leave JLink.jar where it lives in the JLink directory. If you want it to be available to all Java programs on your system, add its location to your CLASSPATH environment variable (this is not a security risk, as remote applets cannot load classes from CLASSPATH).Todd GayleyWolfram Research ==== The key is in using the command Factor with the option Extension:In[1]:=Factor[x^4 + x^3 + x^2 + x + 1, Extension -> {GoldenRatio}]Out[1]=-((-1 - x + GoldenRatio*x - x^2)*(1 + GoldenRatio*x + x^2))For manual verification you should keep in mind that: 1/GoldenRatio = GoldenRatio - 1Germ.87n Buitrago----- Original Message -----> (x^2 + GoldenRatio x + 1) ( x^2 - 1/GoldenRatio x + 1)>> What instructions do I need to execute to achieve this output?>> -Steve Earth> Harker School> http://www.harker.org/> ==== Actually, including 1/GoldenRatio in the extension leads to an unnecessarily complicated formula.In this case there is no real need to so, since by definitionIn[30]:=Unevaluated[1/GoldenRatio==GoldenRatio-1] //FullSimplifyOut[30]=TrueIf one really insists on having the answer in the form proposed in Steve's original posting one can simply do:(Collect[#1, x] & ) /@ Factor[x^4 + x^3 + x^2 + x + 1, Extension -> {GoldenRatio}] /. -1 + GoldenRatio -> 1/GoldenRatio(-(-1 + x/GoldenRatio - x^2))*(1 + GoldenRatio*x + x^2)>> In[]:=Factor[x^4 + x^3 + x^2 + x + 1, Extension -> {GoldenRatio,> 1/GoldenRatio}]> Out[]=-((-3 - 2*x + Sqrt[5]*x + GoldenRatio*x - 3*x^2)*> (3 + x + Sqrt[5]*x + GoldenRatio*x + 3*x^2))/9>> Jens> Greetings MathGroup,>> My name is Steve Earth, and I am a new subscriber to this list and >> also a>> new user of Mathematica; so please forgive this rather simple >> question...>> I would like to enter the quartic x^4 + x^3 + x^2 + x + 1 into >> Mathematica>> and have it be able to tell me that it factors into>> (x^2 + GoldenRatio x + 1) ( x^2 - 1/GoldenRatio x + 1)>> What instructions do I need to execute to achieve this output?>> -Steve Earth>> Harker School>> http://www.harker.org/>Andrzej KozlowskiYokohama, Japanhttp://www.mimuw.edu.pl/~akoz/http:// platon.c.u-tokyo.ac.jp/andrzej/ ==== I want to apply a function to every k-th element of a long list and add the result to the k+1 element. [Actually k = 3 and I just want to multiply myList[[k]] by a constant (independent of k) and add the result to myList[[k+1]] for every value of k that's divisible by 3.]Is there a way to do this -- or in general to get at every k-th element of a list -- that's faster and more elegant than writing a brute force Do[] loop or using Mod[] operators, and that will take advantage of native List operators, but still not be too recondite? I've been thinking about multiplying a copy of myList by a mask list {0,0,1,0,0,1,..} to generate a masked copy and approaches like that. Better ways??? ==== Take[list, am, n, sa] gives elements m through n in steps of s. > I want to apply a function to every k-th element of a long list and > add the result to the k+1 element. > [Actually k = 3 and I just want to multiply myList[[k]] by a > constant (independent of k) and add the result to myList[[k+1]] for > every value of k that's divisible by 3.]> Is there a way to do this -- or in general to get at every k-th > element of a list -- that's faster and more elegant than writing a brute > force Do[] loop or using Mod[] operators, and that will take > advantage of native List operators, but still not be too recondite? > I've been thinking about multiplying a copy of myList by a mask list > {0,0,1,0,0,1,..} to generate a masked copy and approaches like that. > Better ways??? ==== lst= Range[14]{1,2,3,4,5,6,7,8,9,10,11,12,13,14}A list of positions in lst ( for your purpose Range[1, Length[lst], 3] willdo)ps= {3,5,10};The following applies h to each ps element in lst and adds the result to thefollowing element(lst[[ps+1]]=h/@lst[[ps]]+lst[[ps+1]];lst){1,2,3,4+h[ 3],5,6+h[5],7,8,9,10,11+h[10],12,13,14}--Allan------------- --------Allan HayesMathematica Training and ConsultingLeicester UKwww.haystack.demon.co.ukhay@haystack.demon.co.ukVoice : +44 (0)116 271 4198> I want to apply a function to every k-th element of a long list and> add the result to the k+1 element.>> [Actually k = 3 and I just want to multiply myList[[k]] by a> constant (independent of k) and add the result to myList[[k+1]] for> every value of k that's divisible by 3.]>> Is there a way to do this -- or in general to get at every k-th> element of a list -- that's faster and more elegant than writing a brute> force Do[] loop or using Mod[] operators, and that will take> advantage of native List operators, but still not be too recondite?>> I've been thinking about multiplying a copy of myList by a mask list> {0,0,1,0,0,1,..} to generate a masked copy and approaches like that.> Better ways???> ==== Consider the following approach, whish uses the MapAt command, that is Mapwith Ômapping-position' control.dummyFun={#,trueFun@#}&list={a,b,c,d,e,f,g,h,i,j,k, l,m,n,o,p}spec=Partition[Range[3,Length[list],3],1]MapAt[ dummyFun,list,spec]%//FlattenHope that is what you want,Borut| I want to apply a function to every k-th element of a long list and| add the result to the k+1 element.|| [Actually k = 3 and I just want to multiply myList[[k]] by a| constant (independent of k) and add the result to myList[[k+1]] for| every value of k that's divisible by 3.]|| Is there a way to do this -- or in general to get at every k-th| element of a list -- that's faster and more elegant than writing a brute| force Do[] loop or using Mod[] operators, and that will take| advantage of native List operators, but still not be too recondite?|| I've been thinking about multiplying a copy of myList by a mask list| {0,0,1,0,0,1,..} to generate a masked copy and approaches like that.| Better ways???|Reply-To: kuska@informatik.uni-leipzig.de ==== something like:With[{k=3},Flatten[ {#[[2]] + c*#[[1]], #[[3]]} & /@ Partition[lst, k, k, {1, 1}], 1]]?? Jens> I want to apply a function to every k-th element of a long list and> add the result to the k+1 element.> [Actually k = 3 and I just want to multiply myList[[k]] by a> constant (independent of k) and add the result to myList[[k+1]] for> every value of k that's divisible by 3.]> Is there a way to do this -- or in general to get at every k-th> element of a list -- that's faster and more elegant than writing a brute> force Do[] loop or using Mod[] operators, and that will take> advantage of native List operators, but still not be too recondite?> I've been thinking about multiplying a copy of myList by a mask list> {0,0,1,0,0,1,..} to generate a masked copy and approaches like that.> Better ways???Reply-To: ==== Daniel,>>The precision/accuracy tracking mechanism will generally let you know,in some fashion, that you have no trustworthy digits. But it is up tothe user to check that sort of thing.In this case Mathematica did NOT let us know, in any fashion, that wehad no trustworthy digits. Precision and Accuracy outputs werecompletely misleading. (16 and -5 respectively.) Even AndrzejKozlowski, who's adept in Mathematica, thought that would be meaningful,and never came up with a better way to check (other than using infiniteprecision for numbers that probably aren't known that exactly). PeterKosta demonstrated that he could get a completely erroneous answer withInfinite precision.I blame the problem primarily, and I don't think there's any way to makethe answer meaningful. That's not Mathematica's fault at all, and usersneed to be aware of that old maxim: garbage in, garbage out.comes up with a 22-digit result, it doesn't take much sophistication torealize 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.;fPrecision[f]-1.180591620717411303424`71.0721*^ 217171.0721 digits of precision? I don't think so!!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.However, that doesn't change the fact that Accuracy, Precision, andSetAccuracy appear to be completely useless. I haven't seen an examplein which they did what anyone (but you) thought they should do.Bobby-----Original Message-----> you're not aware there's a problem, it lets you go on your merry way,> working with noise.> BobbyMathematica is not a mind reader. But the evaluation sequence, whilecomplicated, is reasonably well documented. If you perform machinearithmetic, or for that matter significance arithmetic, and there ismassive cancellation error, no use of SetAccuracy after the fact willfix it.The precision/accuracy tracking mechanism will generally let you know,in some fashion, that you have no trustworthy digits. But it is up tothe user to check that sort of thing. It is not obvious to me what sortof error the software might notice to report. If you have a conciseexample of input, and expected output, I can look further. I've not seenanything in this thread that struck me as a failure of the software towarn the user, but maybe I missed something.Daniel ==== GentleBeingsI have a straightforward implementation of successive approximationsbut I cannot seem to froce the code to find the correct solution when I havetrig or exponentials involved. Can the assembled wisdom point tostraghtforward fixes I know FindRoot works the object is to teachprogramming and successive approx, tho.kenfBelow is the codeClear[f, g, gi, lim, r, rr, fr, gir, a, b, c, d, conv]; Plot[{x * ((x + 3)), 10*Sin[x]}, {x, 0.01, 2.4}, PlotStyle -> {{RGBColor[1, 0, 0], Thickness[ .006]}, {RGBColor[0, 0, 1], Thickness[ .006]}} ]; rr = FindRoot[x * ((x + 3)) == 10*Sin[x], {x, 2, 0.01, 2.4}]; f[a_] := a * ((a + 3)) /; a > 0; g[b_] := 10. * Sin[b] /; b > 0; gi[c_] := ArcSin[0.1*c] /; c > 0; Print[Actual root is , rr]; lim = 10; r = 2.0; conv = 10^-4; For[i = 1, i < lim, i++, { fr = f[r]; gir = gi[fr]; d = Abs[N[gir] - r]; i If[d < conv, Break[]]; r = gir; Print[The value of x = , r, found after , i, iterations,, with a tolerence , d, n] } ] Print[The value of x = , r, found after , i, iterations,, with a tolerence , d, n]Every man, woman and responsible child has an unalienable individual,civil, Constitutional and human right to obtain, own, and carry, openly orconcealed, any weapon -- riße, shotgun, handgun, machine gun, anything --any time, any place, without asking anyone's permission. L. Neil Smith ==== > I want to apply a function to every k-th element of a long list and> add the result to the k+1 element.>> [Actually k = 3 and I just want to multiply myList[[k]] by a> constant (independent of k) and add the result to myList[[k+1]] for> every value of k that's divisible by 3.]>> Is there a way to do this -- or in general to get at every k-th> element of a list -- that's faster and more elegant than writing a > brute> force Do[] loop or using Mod[] operators, and that will take> advantage of native List operators, but still not be too recondite?>> I've been thinking about multiplying a copy of myList by a mask > list> {0,0,1,0,0,1,..} to generate a masked copy and approaches like that.> Better ways???>>Here is a generalization of what you've asked:f[l_List,c_,k_Integer,p_Integer]:=Flatten[Block[{r=#[[ k]] c},Join[Take[#,k-1],{r,#[[k+1]]+ r},Drop[#,k+1]]]&/@Partition[l,p]]/;(Mod[Length[l],p]==0&&k< p)I took the liberty of allowing you to partition the list into sublists of length p independent of k, for your case simply set k = 3 and p = 4. c is the constant you wish to use.Sseziwa ==== There is an equivalent approach that will give the answer without knowing it in advance. All we need to know is that any quartic can be factored over the reals as a product of two quadratics, so:Union[(a + b*x + x^2)*(c + d*x + x^2) /. Select[SolveAlways[x^4 + x^3 + x^2 + x + 1 == (a + b*x + x^2)*(c + d*x + x^2), x], FreeQ[#1, I] & ], SameTest -> (Expand[#1] == Expand[#2] & )]{(1 + (1/2)*(1 - Sqrt[5])*x + x^2)* (1 + (1/2)*(1 + Sqrt[5])*x + x^2)}Andrzej KozlowskiToyama International UniversityJAPANhttp://sigma.tuins.ac.jp/~andrzej/> Steve> The notebook given after NOTEBOOK below contains functions for > factoring and> partial fractioning.> Here is an application to your problem: the first stage avoids our > needing> to know anything about the answer.>> fc=FactorR[x^4+x^3+x^2+x+1,x]>> (1 - (1/2)*(-1 - Sqrt[5])*x + x^2)*> (1 - (1/2)*(-1 + Sqrt[5])*x + x^2)>> Now we need to get rid of Sqrt[5] in terms of GoldenRatio.> This is rather messy:>> Simplify/@(fc/. Sqrt[5][Rule]2 GoldenRatio-1)>> (1 + x - GoldenRatio*x + x^2)*(1 + GoldenRatio*x + x^2)>> Simplify/@(%/.-GoldenRatio[Rule] 1/GoldenRatio -1)>> (1 + x/GoldenRatio + x^2)*(1 + GoldenRatio*x + x^2)> Another example>> PartialFractionsR[(1 + x)x/(1 - 3*x + x^2), x]>> 1 - (2*(-1 + 4*x))/((3 + Sqrt[5] - 2*x)*(-3 + 2*x)) +> (2*(-1 + 4*x))/((-3 + 2*x)*(-3 + Sqrt[5] + 2*x))>> Simplify[%]>> (x*(1 + x))/(1 - 3*x + x^2)>> NOTEBOOK: to make a notebook from the following, copy from the next > line to> the line preceding XXX and paste into a new Mathematica notebook.>> Notebook[{>> Cell[CellGroupData[{> Cell[Factors and PartialFractions, Subtitle],>> Cell[Allan Hayes, 16 August 2001, Text],>> Cell[<> Here are some functions for factoring and expressing in partial > fractions over the reals and over the complex numbers.>, Text],>> Cell[BoxData[> (Quit)], Input],>> Cell[BoxData[{> (Off[General::spell1, General::spell]), n,> ((FactorC::usage = polynomial in x with complex coefficients, gives its factorization > over the complex numbers.n> The output may include Root objects which may be evaluated with > ToRadicals or N.>;)n), n,> ((FactorR::usage = polynomial in x with real coefficients, gives its factorization over > the reals.n> The output may include Root objects which may be evaluated with > ToRadicals or N.>;)n), n,> ((PartialFractionsC::usage = where ratl is a rational in x with complex coefficients, gives its > factorization over the complex numbers.n> The output may include Root objects which may be evaluated with > ToRadicals or N.>;)n), n,> ((PartialFractionsR::usage = where ratl is a rational in x with real coefficients, gives its > factorization over the real numbers.n> The output may include Root objects which may be evaluated with > ToRadicals or N.>;)), n,> (On[General::spell1, General::spell])}], Input,> InitializationCell->True],>> Cell[TextData[{> FactorC[p_, x_] := ,> StyleBox[(*over complex numbers*),> FontFamily->Arial,> FontWeight->Plain],> nTimes @@ Cases[Roots[p == 0, x, n Cubics -> False], u_ == > v_ -> x - v]n nFactorR[p_, x_] := ,> StyleBox[(*over reals, coefficients must be real*),> FontFamily->Arial,> FontWeight->Plain],> n (Times @@ Join[Cases[#1, u_ == v_ /; Im[v] == 0 :> n x > - v], Cases[#1, u_ == v_ /; Im[v] > 0 :> n x^2 - x*2*Re[v] + > Abs[v]^2]] & )[n Roots[p == 0, x, Cubics -> False]]> }], Input,> InitializationCell->True],>> Cell[TextData[{> PartialFractionsC[p_, x_] := ,> StyleBox[(*over complex numbers*),> FontFamily->Arial,> FontWeight->Plain],> n(#+Apart[#2/FactorC[#3,x]])&@@Flatten[{PolynomialReduce[# ,#2], > #2}]&[Numerator[#],Denominator[#]]&[Together[p]]n n> PartialFractionsR[p_, x_] := ,> StyleBox[(*over reals, coefficients must be real*),> FontFamily->Arial,> FontWeight->Plain],> n(#+Apart[#2/FactorR[#3,x]])&@@Flatten[{PolynomialReduce[# ,#2], > #2}]&[Numerator[#],Denominator[#]]&[Together[p]]> }], Input,> InitializationCell->True],>> Cell[CellGroupData[{>> Cell[PROGRAMMING NOTES, Subsubsection],>> Cell[TextData[{> The option ,> StyleBox[Cubics->False,> FontFamily->Courier],> is used to keep the roots of cubics in ,> StyleBox[Root[....],> FontFamily->Courier],> form. This is better for computation.n,> StyleBox[Re[v],> FontFamily->Courier],> and ,> StyleBox[Abs[v]^2,> FontFamily->Courier],> are used rather than ,> StyleBox[v+Conjugate[v] ,> FontFamily->Courier],> and ,> StyleBox[v*Conjugate[v],> FontFamily->Courier],> to prevent ,> StyleBox[Apart,> FontFamily->Courier],> from factorising ,> StyleBox[x^2 - x*2*Re[v] + Abs[v]^2],> FontFamily->Courier],> back to complex form.> }], Text]> }, Closed]],>> Cell[CellGroupData[{>> Cell[EXAMPLES, Subsubsection],>> Cell[pol = Expand[(x - 1)*(x + 1)^2*(x^2 + x + 1)^2*(x^2 + 4)]; , > Input],>> Cell[CellGroupData[{>> Cell[f1 = FactorC[pol, x], Input],>> Cell[BoxData[> ((((-1) + x)) (((-2) [ImaginaryI] +> x)) ((2 [ImaginaryI] +> x)) ((1 + x))^2 (((((-1)))^(1/3) + x))^2 > (((-(((-1)))^(2/3)) + x))^2)], Output]> }, Open ]],>> Cell[CellGroupData[{>> Cell[f2 = FactorR[pol, x], Input],>> Cell[BoxData[> ((((-1) + x)) ((1 + x))^2 ((4 +> x^2)) ((1 + x + x^2))^2)], Output]> }, Open ]],>> Cell[CellGroupData[{>> Cell[f3 = FactorR[x^3 + x + 1, x], Input],>> Cell[BoxData[> (((x - Root[1 + #1 + #1^3 &, 1])) ((x^2 -> 2 x Root[(-1) + 2 #1 + 8 #1^3 &, 1] +> Root[(-1) - #1^4 + #1^6 &, 2]^2)))], Output]> }, Open ]],>> Cell[<> Root objects appear because of the option Cubics->False in Roots.> We can sometimes get radical forms, but notice the complication.>, Text],>> Cell[CellGroupData[{>> Cell[ToRadicals[f3], Input],>> Cell[BoxData[> (((((2/(3 (((-9) + @93)))))^(1/3) - ((1/2 > (((-9) + @93))))^(1/3)/3^(2/3) + x)) ((1/3 +> 1/3 ((29/2 - (3 @93)/2))^(1/3) +> 1/3 ((1/2 ((29 + 3 @93))))^(1/3) -> 2 ((((1/2 ((9 + @93))))^(1/3)/(2 > 3^(2/3)) -> 1/(2^(2/3) ((3 ((9 + > @93))))^(1/3)))) x + x^2)))], Output]> }, Open ]],>> Cell[Inexact forms can be found, from f3 :, Text],>> Cell[CellGroupData[{>> Cell[N[f3], Input],>> Cell[BoxData[> (((((0.6823278038280193`)([InvisibleSpace]) ) +> x)) ((((1.4655712318767682`)([InvisibleSpace])) -> 0.6823278038280193` x + x^2)))], Output]> }, Open ]],>> Cell[or directly, Text],>> Cell[CellGroupData[{>> Cell[f3 = FactorR[x^3 + x + 1//N, x], Input],>> Cell[BoxData[> (((((0.6823278038280193`)([InvisibleSpace]) ) +> x)) ((((1.4655712318767682`)([InvisibleSpace])) -> 0.6823278038280193` x + x^2)))], Output]> }, Open ]],>> Cell[Partial fractions, Text],>> Cell[CellGroupData[{>> Cell[pf1 = PartialFractionsR[(2 + x)/pol, x], Input],>> Cell[BoxData[> (1/(60 (((-1) + x))) - 1/(10 ((1 + x))^2) -> 39/(100 ((1 + x))) + ((-54) - 31 x)/(4225 ((4 + > x^2))) + ((-1) + 3 x)/(13 ((1 + x + x^2))^2) + (44 + > 193 x)/(507 ((1 + x + x^2))))], Output]> }, Open ]],>> Cell[CellGroupData[{>> Cell[pf2 = PartialFractionsR[(1 + x)x/(1 - 3*x + x^2), x], > Input],>> Cell[<> 1 - (2*(-1 + 4*x))/((3 + Sqrt[5] - 2*x)*(-3 + 2*x)) +> (2*(-1 + 4*x))/((-3 + 2*x)*(-3 + Sqrt[5] + 2*x))>, Output]> }, Open ]],>> Cell[CellGroupData[{>> Cell[BoxData[> (Simplify[%])], Input],>> Cell[(x*(1 + x))/(1 - 3*x + x^2), Output]> }, Open ]],>> Cell[Partial fractions will often involve Root objects , Text],>> Cell[CellGroupData[{>> Cell[pf3 = PartialFractionsR[(1 + x)/(x^3 - x + 1), x], Input],>> Cell[BoxData[> (((1 +> Root[1 - #1 + #1^3 &,> 1]))/((((x -> Root[1 - #1 + #1^3 &,> 1])) ((Root[1 - #1 + #1^3 &, 1]^2 -> 2 Root[1 - #1 + #1^3 &,> 1] Root[(-1) - 2 #1 + 8 #1^3 &, 1] +> Root[(-1) + #1^4 + #1^6 &, 2]^2)))) + ((x +> Root[1 - #1 + #1^3 &, 1] +> x Root[1 - #1 + #1^3 &, 1] -> 2 Root[(-1) - 2 #1 + 8 #1^3 &, 1] -> Root[(-1) + #1^4 + #1^6 &, 2]^2))/(((((-x^2) +> 2 x Root[(-1) - 2 #1 + 8 #1^3 &, 1] -> Root[(-1) + #1^4 + #1^6 &, 2]^2)) ((Root[1 - > #1 + #1^3 &, 1]^2 -> 2 Root[1 - #1 + #1^3 &,> 1] Root[(-1) - 2 #1 + 8 #1^3 &, 1] +> Root[(-1) + #1^4 + #1^6 &, 2]^2)))))], > Output]> }, Open ]],>> Cell[This can in fact be put in radical form:, Text],>> Cell[CellGroupData[{>> Cell[ToRadicals[pf3], Input],>> Cell[BoxData[> (((1 - ((2/(3 ((9 - @69)))))^(1/3) - ((1/2 ((9 > - @69))))^(1/3)/3^(2/3)))/(((((-( 1/3)) +> 1/3 ((25/2 - (3 @69)/2))^(1/3) +> 1/3 ((1/2 ((25 + 3 @69))))^(1/3) + > (((-((2/(3 ((9 - @69)))))^(1/3)) - ((1/2 ((9 - > @69))))^(1/3)/3^(2/3)))^2 -> 2 (((-((2/(3 ((9 - @69)))))^(1/3)) - > ((1/2 ((9 - @69))))^(1/3)/3^(2/3))) ((1/24 ((864 > - 96 @69))^(1/3) + ((1/2 ((9 + @69))))^(1/3)/(2 > 3^(2/3)))))) ((((2/(3 ((9 - @69)))))^(1/3) + ((1> /2 ((9 - @69))))^(1/3)/3^(2/3) + x)))) + ((1/3 -> 1/3 ((25/2 - (3 @69)/2))^(1/3) - ((2/(3 > ((9 - @69)))))^(1/3) - ((1/2 ((9 - @69))))^(1/3)/3> ^(2/3) - 1/3 ((1/2 ((25 + 3 @69))))^(1/3) -> 2 ((1/24 ((864 - 96 @69))^(1/3) + ((1/2 > ((9 + @69))))^(1/3)/(2 3^(2/3)))) +> x + (((-((2/(3 ((9 - @69)))))^(1/3)) - > ((1/2 ((9 - @69))))^(1/3)/3^(2/3))) x))/(((((-(1> /3)) + 1/3 ((25/2 - (3 @69)/2))^(1/3) +> 1/3 ((1/2 ((25 + 3 @69))))^(1/3) + > (((-((2/(3 ((9 - @69)))))^(1/3)) - ((1/2 ((9 - > @69))))^(1/3)/3^(2/3)))^2 -> 2 (((-((2/(3 ((9 - @69)))))^(1/3)) - > ((1/2 ((9 - @69))))^(1/3)/3^(2/3))) ((1/24 ((864 > - 96 @69))^(1/3) + ((1/2 ((9 + @69))))^(1/3)/(2 > 3^(2/3)))))) ((1/3 -> 1/3 ((25/2 - (3 @69)/2))^(1/3) -> 1/3 ((1/2 ((25 + 3 @69))))^(1/3) +> 2 ((1/24 ((864 - 96 @69))^(1/3) + ((1/2 > ((9 + @69))))^(1/3)/(2 3^(2/3)))) x -> x^2)))))], Output]> }, Closed]],>> Cell[We could have found the inexact form directly., Text],>> Cell[CellGroupData[{>> Cell[BoxData[> (PartialFractionsR[((1 + x))/((x^3 - x + 1)) // N,> x])], Input],>> Cell[BoxData[> ((-(0.07614206365252976`/(((1.324717957244746` )(> [InvisibleSpace])) +> 1.` x))) + (((0.7982664819556426`)(> [InvisibleSpace])) + 0.07614206365252976` > x)/(((0.754877666246693`)([InvisibleSpace]) ) - > 1.324717957244746` x + 1.` x^2))], Output]> }, Open ]]> }, Closed]]> }, Open ]]> },> ScreenRectangle->{{0, 1024}, {0, 709}},> AutoGeneratedPackage->None,> WindowSize->{534, 628},> WindowMargins->{{199, Automatic}, {0, Automatic}},> ShowCellLabel->False,> StyleDefinitions -> Default.nb> ]>> XXX> --> Allan>> ---------------------> Allan Hayes> Mathematica Training and Consulting> Leicester UK> www.haystack.demon.co.uk> hay@haystack.demon.co.uk> Voice: +44 (0)116 271 4198>> Greetings MathGroup,>> My name is Steve Earth, and I am a new subscriber to this list and >> also a>> new user of Mathematica; so please forgive this rather simple >> question...>> I would like to enter the quartic x^4 + x^3 + x^2 + x + 1 into >> Mathematica> and have it be able to tell me that it factors into>> (x^2 + GoldenRatio x + 1) ( x^2 - 1/GoldenRatio x + 1)>> What instructions do I need to execute to achieve this output?>> -Steve Earth>> Harker School>> http://www.harker.org/>> ==== In my earlier posting I used Union and SameTest to replace two equivalent answers (arising form the symmetry of the equation) by a single one. However, the way I did, while givign the right answer, it makes little logical sense since in general applying Expand would make any factorizations the same leaving us always with just a single one. WIthout using Union at all we get:(a + b*x + x^2)*(c + d*x + x^2) /. Select[SolveAlways[x^4 + x^3 + x^2 + x + 1 == (a + b*x + x^2)*(c + d*x + x^2), x], FreeQ[#1, I] & ]{(1 + (1/2 - Sqrt[5]/2)*x + x^2)* (1 + (1/2)*(1 + Sqrt[5])*x + x^2), (1 + (1/2)*(1 - Sqrt[5])*x + x^2)* (1 + (1/2)*(1 + Sqrt[5])*x + x^2)}Since having two identical answers differing only in the way they are written out is a bit of a nuisance, a way to get rid of one of them which does not suffer from the illogicality of my first approach is:Union[(a + b*x + x^2)*(c + d*x + x^2) /. Select[SolveAlways[x^4 + x^3 + x^2 + x + 1 == (a + b*x + x^2)*(c + d*x + x^2), x], FreeQ[#1, I] & ], SameTest -> (Simplify[First[#1] == First[#2]] & )]{(1 + (1/2)*(1 - Sqrt[5])*x + x^2)* (1 + (1/2)*(1 + Sqrt[5])*x + x^2)}> There is an equivalent approach that will give the answer without > knowing it in advance. All we need to know is that any quartic can be > factored over the reals as a product of two quadratics, so:> Union[(a + b*x + x^2)*(c + d*x + x^2) /.> Select[SolveAlways[x^4 + x^3 + x^2 + x + 1 ==> (a + b*x + x^2)*(c + d*x + x^2), x], FreeQ[#1, I] & ],> SameTest -> (Expand[#1] == Expand[#2] & )]> {(1 + (1/2)*(1 - Sqrt[5])*x + x^2)*> (1 + (1/2)*(1 + Sqrt[5])*x + x^2)}> Andrzej Kozlowski> Toyama International University> JAPAN> http://sigma.tuins.ac.jp/~andrzej/> Steve>> The notebook given after NOTEBOOK below contains functions for >> factoring and>> partial fractioning.>> Here is an application to your problem: the first stage avoids our >> needing>> to know anything about the answer.>> fc=FactorR[x^4+x^3+x^2+x+1,x]>> (1 - (1/2)*(-1 - Sqrt[5])*x + x^2)*>> (1 - (1/2)*(-1 + Sqrt[5])*x + x^2)>> Now we need to get rid of Sqrt[5] in terms of GoldenRatio.>> This is rather messy:>> Simplify/@(fc/. Sqrt[5][Rule]2 GoldenRatio-1)>> (1 + x - GoldenRatio*x + x^2)*(1 + GoldenRatio*x + x^2)>> Simplify/@(%/.-GoldenRatio[Rule] 1/GoldenRatio -1)>> (1 + x/GoldenRatio + x^2)*(1 + GoldenRatio*x + x^2)>> Another example>> PartialFractionsR[(1 + x)x/(1 - 3*x + x^2), x]>> 1 - (2*(-1 + 4*x))/((3 + Sqrt[5] - 2*x)*(-3 + 2*x)) +>> (2*(-1 + 4*x))/((-3 + 2*x)*(-3 + Sqrt[5] + 2*x))>> Simplify[%]>> (x*(1 + x))/(1 - 3*x + x^2)>> NOTEBOOK: to make a notebook from the following, copy from the next >> line to>> the line preceding XXX and paste into a new Mathematica notebook.>> Notebook[{>> Cell[CellGroupData[{>> Cell[Factors and PartialFractions, Subtitle],>> Cell[Allan Hayes, 16 August 2001, Text],>> Cell[<>> Here are some functions for factoring and expressing in partial >> fractions over the reals and over the complex numbers.>> >, Text],>> Cell[BoxData[>> (Quit)], Input],>> Cell[BoxData[{>> (Off[General::spell1, General::spell]), n,>> ((FactorC::usage = > polynomial in x with complex coefficients, gives its factorization >> over the complex numbers.n>> The output may include Root objects which may be evaluated with >> ToRadicals or N.>;)n), n,>> ((FactorR::usage = > polynomial in x with real coefficients, gives its factorization over >> the reals.n>> The output may include Root objects which may be evaluated with >> ToRadicals or N.>;)n), n,>> ((PartialFractionsC::usage = > where ratl is a rational in x with complex coefficients, gives its >> factorization over the complex numbers.n>> The output may include Root objects which may be evaluated with >> ToRadicals or N.>;)n), n,>> ((PartialFractionsR::usage = > where ratl is a rational in x with real coefficients, gives its >> factorization over the real numbers.n>> The output may include Root objects which may be evaluated with >> ToRadicals or N.>;)), n,>> (On[General::spell1, General::spell])}], Input,>> InitializationCell->True],>> Cell[TextData[{>> FactorC[p_, x_] := ,>> StyleBox[(*over complex numbers*),>> FontFamily->Arial,>> FontWeight->Plain],>> nTimes @@ Cases[Roots[p == 0, x, n Cubics -> False], u_ == >> v_ -> x - v]n nFactorR[p_, x_] := ,>> StyleBox[(*over reals, coefficients must be real*),>> FontFamily->Arial,>> FontWeight->Plain],>> n (Times @@ Join[Cases[#1, u_ == v_ /; Im[v] == 0 :> n x > - v], Cases[#1, u_ == v_ /; Im[v] > 0 :> n x^2 - x*2*Re[v] + >> Abs[v]^2]] & )[n Roots[p == 0, x, Cubics -> False]]>> }], Input,>> InitializationCell->True],>> Cell[TextData[{>> PartialFractionsC[p_, x_] := ,>> StyleBox[(*over complex numbers*),>> FontFamily->Arial,>> FontWeight->Plain],>> n(#+Apart[#2/FactorC[#3,x]])&@@Flatten[{PolynomialReduce[# ,#2], >> #2}]&[Numerator[#],Denominator[#]]&[Together[p]]n n>> PartialFractionsR[p_, x_] := ,>> StyleBox[(*over reals, coefficients must be real*),>> FontFamily->Arial,>> FontWeight->Plain],>> n(#+Apart[#2/FactorR[#3,x]])&@@Flatten[{PolynomialReduce[# ,#2], >> #2}]&[Numerator[#],Denominator[#]]&[Together[p]]>> }], Input,>> InitializationCell->True],>> Cell[CellGroupData[{>> Cell[PROGRAMMING NOTES, Subsubsection],>> Cell[TextData[{>> The option ,>> StyleBox[Cubics->False,>> FontFamily->Courier],>> is used to keep the roots of cubics in ,>> StyleBox[Root[....],>> FontFamily->Courier],>> form. This is better for computation.n,>> StyleBox[Re[v],>> FontFamily->Courier],>> and ,>> StyleBox[Abs[v]^2,>> FontFamily->Courier],>> are used rather than ,>> StyleBox[v+Conjugate[v] ,>> FontFamily->Courier],>> and ,>> StyleBox[v*Conjugate[v],>> FontFamily->Courier],>> to prevent ,>> StyleBox[Apart,>> FontFamily->Courier],>> from factorising ,>> StyleBox[x^2 - x*2*Re[v] + Abs[v]^2],>> FontFamily->Courier],>> back to complex form.>> }], Text]>> }, Closed]],>> Cell[CellGroupData[{>> Cell[EXAMPLES, Subsubsection],>> Cell[pol = Expand[(x - 1)*(x + 1)^2*(x^2 + x + 1)^2*(x^2 + 4)]; , >> Input],>> Cell[CellGroupData[{>> Cell[f1 = FactorC[pol, x], Input],>> Cell[BoxData[>> ((((-1) + x)) (((-2) [ImaginaryI] +>> x)) ((2 [ImaginaryI] +>> x)) ((1 + x))^2 (((((-1)))^(1/3) + x))^2 >> (((-(((-1)))^(2/3)) + x))^2)], Output]>> }, Open ]],>> Cell[CellGroupData[{>> Cell[f2 = FactorR[pol, x], Input],>> Cell[BoxData[>> ((((-1) + x)) ((1 + x))^2 ((4 +>> x^2)) ((1 + x + x^2))^2)], Output]>> }, Open ]],>> Cell[CellGroupData[{>> Cell[f3 = FactorR[x^3 + x + 1, x], Input],>> Cell[BoxData[>> (((x - Root[1 + #1 + #1^3 &, 1])) ((x^2 ->> 2 x Root[(-1) + 2 #1 + 8 #1^3 &, 1] +>> Root[(-1) - #1^4 + #1^6 &, 2]^2)))], Output]>> }, Open ]],>> Cell[<>> Root objects appear because of the option Cubics->False in Roots.>> We can sometimes get radical forms, but notice the complication.>>, Text],>> Cell[CellGroupData[{>> Cell[ToRadicals[f3], Input],>> Cell[BoxData[>> (((((2/(3 (((-9) + @93)))))^(1/3) - ((1/2 >> (((-9) + @93))))^(1/3)/3^(2/3) + x)) ((1/3 +>> 1/3 ((29/2 - (3 @93)/2))^(1/3) +>> 1/3 ((1/2 ((29 + 3 @93))))^(1/3) ->> 2 ((((1/2 ((9 + @93))))^(1/3)/(2 >> 3^(2/3)) ->> 1/(2^(2/3) ((3 ((9 + >> @93))))^(1/3)))) x + x^2)))], Output]>> }, Open ]],>> Cell[Inexact forms can be found, from f3 :, Text],>> Cell[CellGroupData[{>> Cell[N[f3], Input],>> Cell[BoxData[>> (((((0.6823278038280193`)([InvisibleSpace]) ) +>> x)) ((((1.4655712318767682`)([InvisibleSpace])) ->> 0.6823278038280193` x + x^2)))], Output]>> }, Open ]],>> Cell[or directly, Text],>> Cell[CellGroupData[{>> Cell[f3 = FactorR[x^3 + x + 1//N, x], Input],>> Cell[BoxData[>> (((((0.6823278038280193`)([InvisibleSpace]) ) +>> x)) ((((1.4655712318767682`)([InvisibleSpace])) ->> 0.6823278038280193` x + x^2)))], Output]>> }, Open ]],>> Cell[Partial fractions, Text],>> Cell[CellGroupData[{>> Cell[pf1 = PartialFractionsR[(2 + x)/pol, x], Input],>> Cell[BoxData[>> (1/(60 (((-1) + x))) - 1/(10 ((1 + x))^2) ->> 39/(100 ((1 + x))) + ((-54) - 31 x)/(4225 ((4 + >> x^2))) + ((-1) + 3 x)/(13 ((1 + x + x^2))^2) + (44 + >> >> 193 x)/(507 ((1 + x + x^2))))], Output]>> }, Open ]],>> Cell[CellGroupData[{>> Cell[pf2 = PartialFractionsR[(1 + x)x/(1 - 3*x + x^2), x], >> Input],>> Cell[<>> 1 - (2*(-1 + 4*x))/((3 + Sqrt[5] - 2*x)*(-3 + 2*x)) +>> (2*(-1 + 4*x))/((-3 + 2*x)*(-3 + Sqrt[5] + 2*x))>>, Output]>> }, Open ]],>> Cell[CellGroupData[{>> Cell[BoxData[>> (Simplify[%])], Input],>> Cell[(x*(1 + x))/(1 - 3*x + x^2), Output]>> }, Open ]],>> Cell[Partial fractions will often involve Root objects , Text],>> Cell[CellGroupData[{>> Cell[pf3 = PartialFractionsR[(1 + x)/(x^3 - x + 1), x], Input],>> Cell[BoxData[>> (((1 +>> Root[1 - #1 + #1^3 &,>> 1]))/((((x ->> Root[1 - #1 + #1^3 &,>> 1])) ((Root[1 - #1 + #1^3 &, 1]^2 ->> 2 Root[1 - #1 + #1^3 &,>> 1] Root[(-1) - 2 #1 + 8 #1^3 &, 1] +>> Root[(-1) + #1^4 + #1^6 &, 2]^2)))) + ((x +>> Root[1 - #1 + #1^3 &, 1] +>> x Root[1 - #1 + #1^3 &, 1] ->> 2 Root[(-1) - 2 #1 + 8 #1^3 &, 1] ->> Root[(-1) + #1^4 + #1^6 &, 2]^2))/(((((-x^2) +>> 2 x Root[(-1) - 2 #1 + 8 #1^3 &, 1] ->> Root[(-1) + #1^4 + #1^6 &, 2]^2)) ((Root[1 - >> #1 + #1^3 &, 1]^2 ->> 2 Root[1 - #1 + #1^3 &,>> 1] Root[(-1) - 2 #1 + 8 #1^3 &, 1] +>> Root[(-1) + #1^4 + #1^6 &, 2]^2)))))], >> Output]>> }, Open ]],>> Cell[This can in fact be put in radical form:, Text],>> Cell[CellGroupData[{>> Cell[ToRadicals[pf3], Input],>> Cell[BoxData[>> (((1 - ((2/(3 ((9 - @69)))))^(1/3) - ((1/2 ((9 >> - @69))))^(1/3)/3^(2/3)))/(((((- (1/3)) +>> 1/3 ((25/2 - (3 @69)/2))^(1/3) +>> 1/3 ((1/2 ((25 + 3 @69))))^(1/3) + >> (((-((2/(3 ((9 - @69)))))^(1/3)) - ((1/2 ((9 - >> @69))))^(1/3)/3^(2/3)))^2 ->> 2 (((-((2/(3 ((9 - @69)))))^(1/3)) - >> ((1/2 ((9 - @69))))^(1/3)/3^(2/3))) ((1/24 ((864 >> - 96 @69))^(1/3) + ((1/2 ((9 + @69))))^(1/3)/(2 >> 3^(2/3)))))) ((((2/(3 ((9 - @69)))))^(1/3) + ((1>> /2 ((9 - @69))))^(1/3)/3^(2/3) + x)))) + ((1/3 ->> 1/3 ((25/2 - (3 @69)/2))^(1/3) - ((2/(3 >> ((9 - @69)))))^(1/3) - ((1/2 ((9 - @69))))^(1/3)/3>> ^(2/3) - 1/3 ((1/2 ((25 + 3 @69))))^(1/3) ->> 2 ((1/24 ((864 - 96 @69))^(1/3) + ((1/2 >> ((9 + @69))))^(1/3)/(2 3^(2/3)))) +>> x + (((-((2/(3 ((9 - @69)))))^(1/3)) - >> ((1/2 ((9 - @69))))^(1/3)/3^(2/3))) x))/(((((-(1>> /3)) + 1/3 ((25/2 - (3 @69)/2))^(1/3) +>> 1/3 ((1/2 ((25 + 3 @69))))^(1/3) + >> (((-((2/(3 ((9 - @69)))))^(1/3)) - ((1/2 ((9 - >> @69))))^(1/3)/3^(2/3)))^2 ->> 2 (((-((2/(3 ((9 - @69)))))^(1/3)) - >> ((1/2 ((9 - @69))))^(1/3)/3^(2/3))) ((1/24 ((864 >> - 96 @69))^(1/3) + ((1/2 ((9 + @69))))^(1/3)/(2 >> 3^(2/3)))))) ((1/3 ->> 1/3 ((25/2 - (3 @69)/2))^(1/3) ->> 1/3 ((1/2 ((25 + 3 @69))))^(1/3) +>> 2 ((1/24 ((864 - 96 @69))^(1/3) + ((1/2 > ((9 + @69))))^(1/3)/(2 3^(2/3)))) x ->> x^2)))))], Output]>> }, Closed]],>> Cell[We could have found the inexact form directly., Text],>> Cell[CellGroupData[{>> Cell[BoxData[>> (PartialFractionsR[((1 + x))/((x^3 - x + 1)) // N,>> x])], Input],>> Cell[BoxData[>> ((-(0.07614206365252976`/(((1.324717957244746` )(>> [InvisibleSpace])) +>> 1.` x))) + (((0.7982664819556426`)(>> [InvisibleSpace])) + 0.07614206365252976` >> x)/(((0.754877666246693`)([InvisibleSpace]) ) - >> 1.324717957244746` x + 1.` x^2))], Output]>> }, Open ]]>> }, Closed]]>> }, Open ]]>> },>> ScreenRectangle->{{0, 1024}, {0, 709}},>> AutoGeneratedPackage->None,>> WindowSize->{534, 628},>> WindowMargins->{{199, Automatic}, {0, Automatic}},>> ShowCellLabel->False,>> StyleDefinitions -> Default.nb>> ]>> XXX>> -->> Allan>> --------------------->> Allan Hayes>> Mathematica Training and Consulting>> Leicester UK>> www.haystack.demon.co.uk>> hay@haystack.demon.co.uk>> Voice: +44 (0)116 271 4198> Greetings MathGroup,>> My name is Steve Earth, and I am a new subscriber to this list and > also a> new user of Mathematica; so please forgive this rather simple > question...>> I would like to enter the quartic x^4 + x^3 + x^2 + x + 1 into > Mathematica> and have it be able to tell me that it factors into>> (x^2 + GoldenRatio x + 1) ( x^2 - 1/GoldenRatio x + 1)>> What instructions do I need to execute to achieve this output?>> -Steve Earth> Harker School> http://www.harker.org/>Andrzej KozlowskiYokohama, Japanhttp://www.mimuw.edu.pl/~akoz/http:// platon.c.u-tokyo.ac.jp/andrzej/Reply-To: ==== Let's be realistic. If you want 60 digits of precision, too bad! -- inthe real world. There's nothing we can measure that closely. Drugconcentrations in clinical trials are generally measured within 15%, forinstance. Even machine precision is more than can be realisticallyexpected in any application I can think of. Even getting a satellite toJupiter probably involves more error in the final result than machineprecision. (If not, it's because we rely on ongoing corrections andnatural factors that put the satellite where it should be, such asgravity drawing it toward each rendezvous -- not on that kind ofprecision in propulsion or guidance.)So... unless all numerics in a problem have a theoretical origin, andcould be represented in Mathematica as Infinite precision expressions...all this talk of higher-precision computation seems futile.The realistic question is this: given that I have confidence, say, in 6digits of precision for the inputs of an expression, how many digits canI trust in the end result? Giving inputs MORE precision than theydeserve isn't the best way to answer that question. Here are twomethods of answering it in Mathematica. One uses bignums and theother uses Intervals.Repetitious trial and error are NOT required either way.BIGNUMS:ClearAll[a, b, f, x, y]f = x*b^6 + a^2*(11*a^2*b^2 - b^6 - 121*b^4 - 2) + y*b^8 + a/(2*b); a = SetPrecision[77617, 6]; b = SetPrecision[33096, 6]; x = SetPrecision[33375/100, 6]; y = SetPrecision[55/10, 6]; InputForm[f]-4.1396`-12.5121*^19Several previous solutions have set the precision or accuracy of fbefore giving a and b (and possibly x and y) values. That results inmaking the exponents imprecise along with all coefficients (not just xand y), which may or may not be what we want.INTERVALS:I'll first digress to figure out what Interval is equivalent to 6-digitprecision. You might not actually do this if you like the Intervalmethod, but you have to decide SOMEHOW what Interval width to use.nums = {77617, 33096, 33375/100, 55/10}; (Interval[SetPrecision[#1, 6]] & ) /@ nums /. Interval[{a_, b_}] :>2*((b - a)/(b + a)); InputForm[%]{3.2209438653903`0.207*^-6, 3.7768914672467`0.2761*^-6, 2.9260299625467`0.1652*^-6, 2.7743252840909`0.1421*^-6}For these numbers, # + Interval[{-1,1}]*#/630000& gets us very close, soI'll use that. The second method therefore is:g = #1 + Interval[{-1, 1}]*(#1/630000) & ; a = g[77617]; b = g[33096]; x = g[333.75]; y = g[5.5]; f = x*b^6 + a^2*(11*a^2*b^2 - b^6 - 121*b^4 - 2) + y*b^8 + a/(2*b)(Min[f] + Max[f])/2Interval[{-2.136361928005054*^32, 2.1363651195928296*^32}]1.5957938878075177*^26Either method shows the answer has no trustworthy digits, but I thinkthe second result is far easier to interpret.Here's another example, using the Sin function, whose derivative is Cos,whose magnitude is bounded by one. The precision of the Sin of a numbershould be GREATER than the precision of the number itself, especiallywhen Cos is small.a = SetPrecision[Pi/2, 6]; InputForm[Sin[a]]0.9999999999990905052982256654`11.6078a = g[N[Pi/2]]; Sin[a] - 1Interval[{-3.1084024243455137*^-12, 0}]I hope this was worthwhile to someone.DrBob-----Original Message----->[...]>> I would say this is correct and show that> SetPrecision is very useful> indeed. It tells you (what of course you ought> to already know in this> case anyway) that machine precision will not> give you a realiable> answer in this case. If you know your numbers> with a great deal of> accuracy you can get an accurate answer:>> > In[24]:=> f = SetAccuracy[333.75*b^6 + a^2*(11*a^2*b^2 -> b^6 -> 121*b^4 - 2) + 5.5*b^8 + a/(2*b), 100];> a=SetPrecision[77617.,100]; b => SetPrecision[33096.,100];> In[26]:=> {f, Precision[f]}>> Out[26]=> >>{- 0.82739605994682136814116509547981629199903311578438481991> > 781484167246798617832`61.2597, 61}>> Congratulations! You just requested accuracy of> 100 for f and got 61 (> to convince yourself add Accuracy[f] to In[26]).> If In[24] one> replaces SetAccuracy by SetPrecision the result is> similar.> PK> [...]> One has (initially) an accuracy of 100 for an> expression that contains> variables.> In[25]:= Clear[a,b,f]> In[26]:= f = SetAccuracy[333.75*b^6 +> a^2*(11*a^2*b^2 - b^6 -> 121*b^4 - 2) + 5.5*b^8 + a/(2*b), 100]; > In[27]:= Accuracy[f]> Out[27]= 100.> Now we assign values to some indeterminants in f.> In[28]:= a = SetPrecision[77617.,100]; b => SetPrecision[33096.,100];> In[29]:= {f, Precision[f], Accuracy[f]}> Out[29]=>{- 0.827396059946821368141165095479816291999033115784384819917814 8,> 61.2599, 61.3422}> The precision and accuracy has dropped. This is all> according to> standard numerical analysis regarding cancellation> error. You'll find it> in any textbook on the topic.> Assume that I want accuracy and precision of 100 forf. You advice me to make experiments to find out, whatshould be the initial precision and accuracy of a andb to reach the requested accuracy and precision for f.Notice, that you cannot just repeat I[26], we sawalready what happens. I have to re-type I[24], I[25],I[26], I[27], I[28], and I[29] as many times as neededto get f with accuracy and precision 100. Dan, you simply advocate to do MANUAL WORK that shouldbe done by machine.Let's suppose that in the above example I just want 60digits not 61. Precisely, I want 60 digits and nothingor zeros afterwards. Let's see if I could useSetAccuracy.In[30]:=SetAccuracy[%, 60]Out[30]=- 0.82739605994682136814116509547981629199903311578438481991781 In[31]:=% // FullFormOut[30]//FullForm=- 0.827396059946821368141165095479816291999033115784384819917814 841672467988`59.9177Oops, it did not work (as expected). Let's highlightwith mouse the expression in Out[30] and copy to a newcell. Oops, we got - 0.827396059946821368141165095479816291999033115784384819917814 841672467988`59.9177again. Let's change Out[30] to a text cell and thencopy. In[31]:=- 0.82739605994682136814116509547981629199903311578438481991781 Out[31]=- 0.82739605994682136814116509547981629199903311578438481991781 Success? Not so fast.In[32]:=% // FullFormOut[32]//FullForm=- 0.827396059946821368141165095479816291999033115784384819917809 99999999999863508`59.2041Dan, is there any simple way to get what I want? As I repeated already number of times, at this stageof the development of computer technology, softwareshould do it for me (!). We both know that this isdoable. Some of the textbooks that you just advised meto read describe it. As a developer of Mathematica,tell us why do you consider this to be a bad idea? Peter Kosta> As for what happens when you artificially raise> precision (or accuracy)> of machine numbers far beyond that guaranteed by> their internal> representation, that falls into to category of> garbage in, garbage out.> It is, howoever, valid to use SetPrecision to raise> precision in> (typically iterative) algorithms where significance> arithmetic might be> unduly pessimistic due to incorrect assumptions> about uncorollatedness> of numerical error. Examples of such usage have> appeared in this news> group.> > Daniel Lichtblau> Wolfram Research__________________________________________________ Do you Yahoo!?http://faith.yahoo.com ==== Bobby,The example that I gave in my previous posting does not make my point, or itmakes it in rather a hidden way, but it does show something interestingabout computation with bigßoats.I'll explain what I mean by this and then give an example that does makethe point directly.First, the previous example: Sin[#1]*10^#1*Log[1+10^(-#1)]&[15.9] -0.336629 Sin[#1]*10^#1*Log[1+10^(-#1)]&[SetPrecision[15.9,20]] Precision[%] -0.190858581374189370 17.7558 Sin[#1]*10^#1*Log[1+10^(-#1)]&[SetPrecision[15.9,7]] Precision[%] -0.19086 4.70309(**) It looks as if the internal computations must be to a higher precisionthan 4 and that they start at SetPrecision[15.9,7]//FullForm 15.9000000000000003553`7With MaxError = 10^-Accuracy[sp]//FullForm 1.590000000000001`*^-6 Roughly speaking, not more than the first seven digits are asserted to becorrect.Now, the new example (taken from Stan Wagon, Programming Tips, Mathematicain Education and Research Volume 7, Number 2, 1988 p50) Clear[x] ser= Normal[Series[Cos[x],{x,0,200}]]; x= 75.0; ser//FullForm -2.7019882604300525`*^15Probably not reliable.Set precision to 20: x= SetPrecision[75.0, 20]; (a=ser)//FullForm -16928.799183047`1.4688 MaxError= 10^-Accuracy[a] 575.263Not good enough.Raise the precision to x= SetAccuracy[75.0,40]; (a=ser)//FullForm 1.0807905977573169155`7.7627MaxError = 10^-Accuracy[a] !(1.3999657487996298`*^-6)That is 1.3999657487996298 10^-6Good enoughAllan---------------------Allan HayesMathematica Training and ConsultingLeicester UKwww.haystack.demon.co.ukhay@haystack.demon.co.ukVoice : +44 (0)116 271 4198 ==== Bobby,You note some important points but there are situations in which raisingaccuracy is a practical necessity.1) It may be that a calculation (perhaps describing a real world phenonenon)necessitates our raising the precision of inuts so as to work to highprecision internally even when the output is not very sensitive to changesin input.Compare the following graphs pts = Table[({#1, Sin[#1]*10^#1*Log[1 + 10^(-#1)]} & )[x], {x, 15., 20.,0.1}]; ListPlot[pts, PlotJoined -> True] pts = Table[({#1, Sin[#1]*10^#1*Log[1 + 10^(-#1)]} & )[ SetAccuracy[x, 20]], {x, 15., 20., 0.1}]; ListPlot[pts, PlotJoined -> True]2) Another situation in which high precision numbers are needed is when acomputation with exact numbers would be slow or might use up all the memoryavailable. We then need to replace the exact numbers with high precisionbigßoats which causes the number of digits used internally to berestricted and the maximum error in the output to be reported.The N function will raise the precision of the exact numbers to try andreach the requested precision.There are also concerns with, for example, how the replacing bigßoats arerelated to the original numbers.How important this depends on the use to which the calculation is being putand how sensitive the output is to changes in inputs - in the plotting aboveit is not important.--Allan---------------------Allan HayesMathematica Training and ConsultingLeicester UKwww.haystack.demon.co.ukhay@haystack.demon.co.ukVoice : +44 (0)116 271 4198> Let's be realistic. If you want 60 digits of precision, too bad! -- in> the real world. There's nothing we can measure that closely. Drug> concentrations in clinical trials are generally measured within 15%, for> instance. Even machine precision is more than can be realistically> expected in any application I can think of. Even getting a satellite to> Jupiter probably involves more error in the final result than machine> precision. (If not, it's because we rely on ongoing corrections and> natural factors that put the satellite where it should be, such as> gravity drawing it toward each rendezvous -- not on that kind of> precision in propulsion or guidance.)>> So... unless all numerics in a problem have a theoretical origin, and> could be represented in Mathematica as Infinite precision expressions...> all this talk of higher-precision computation seems futile.>> The realistic question is this: given that I have confidence, say, in 6> digits of precision for the inputs of an expression, how many digits can> I trust in the end result? Giving inputs MORE precision than they> deserve isn't the best way to answer that question. Here are two> methods of answering it in Mathematica. One uses bignums and the> other uses Intervals.>> Repetitious trial and error are NOT required either way.>> BIGNUMS:>> ClearAll[a, b, f, x, y]> f = x*b^6 + a^2*(11*a^2*b^2 - b^6 - 121*b^4 - 2) + y*b^8 + a/(2*b);> a = SetPrecision[77617, 6];> b = SetPrecision[33096, 6];> x = SetPrecision[33375/100, 6];> y = SetPrecision[55/10, 6];> InputForm[f]>> -4.1396`-12.5121*^19>> Several previous solutions have set the precision or accuracy of f> before giving a and b (and possibly x and y) values. That results in> making the exponents imprecise along with all coefficients (not just x> and y), which may or may not be what we want.>> INTERVALS:>> I'll first digress to figure out what Interval is equivalent to 6-digit> precision. You might not actually do this if you like the Interval> method, but you have to decide SOMEHOW what Interval width to use.>> nums = {77617, 33096, 33375/100, 55/10};> (Interval[SetPrecision[#1, 6]] & ) /@ nums /. Interval[{a_, b_}] :>> 2*((b - a)/(b + a));> InputForm[%]>> {3.2209438653903`0.207*^-6,> 3.7768914672467`0.2761*^-6,> 2.9260299625467`0.1652*^-6,> 2.7743252840909`0.1421*^-6}>> For these numbers, # + Interval[{-1,1}]*#/630000& gets us very close, so> I'll use that. The second method therefore is:>> g = #1 + Interval[{-1, 1}]*(#1/630000) & ;> a = g[77617];> b = g[33096];> x = g[333.75];> y = g[5.5];> f = x*b^6 + a^2*(11*a^2*b^2 - b^6 - 121*b^4 - 2) + y*b^8 + a/(2*b)> (Min[f] + Max[f])/2>> Interval[{-2.136361928005054*^32, 2.1363651195928296*^32}]>> 1.5957938878075177*^26>> Either method shows the answer has no trustworthy digits, but I think> the second result is far easier to interpret.>> Here's another example, using the Sin function, whose derivative is Cos,> whose magnitude is bounded by one. The precision of the Sin of a number> should be GREATER than the precision of the number itself, especially> when Cos is small.>> a = SetPrecision[Pi/2, 6];> InputForm[Sin[a]]>> 0.9999999999990905052982256654`11.6078>> a = g[N[Pi/2]];> Sin[a] - 1>> Interval[{-3.1084024243455137*^-12, 0}]>> I hope this was worthwhile to someone.>> DrBob>> -----Original Message-----> On Friday, October 4, 2002, at 06:01 PM, DrBob>>[...]>> I would say this is correct and show that> SetPrecision is very useful> indeed. It tells you (what of course you ought> to already know in this> case anyway) that machine precision will not> give you a realiable> answer in this case. If you know your numbers> with a great deal of> accuracy you can get an accurate answer:>> In[24]:=> f = SetAccuracy[333.75*b^6 + a^2*(11*a^2*b^2 -> b^6 -> 121*b^4 - 2) + 5.5*b^8 + a/(2*b), 100];> a=SetPrecision[77617.,100]; b => SetPrecision[33096.,100];> > In[26]:=> {f, Precision[f]}>> > Out[26]=> {-0.82739605994682136814116509547981629199903311578438481991 > 781484167246798617832`61.2597, 61}> Congratulations! You just requested accuracy of> 100 for f and got 61 (> to convince yourself add Accuracy[f] to In[26]).> If In[24] one> replaces SetAccuracy by SetPrecision the result is> similar.>> PK> [...]>> One has (initially) an accuracy of 100 for an> expression that contains> variables.>> In[25]:= Clear[a,b,f]>> In[26]:= f = SetAccuracy[333.75*b^6 +> a^2*(11*a^2*b^2 - b^6 -> 121*b^4 - 2) + 5.5*b^8 + a/(2*b), 100];>> In[27]:= Accuracy[f]> Out[27]= 100.>> Now we assign values to some indeterminants in f.>> In[28]:= a = SetPrecision[77617.,100]; b => SetPrecision[33096.,100];>> In[29]:= {f, Precision[f], Accuracy[f]}> Out[29]=>> {- 0.827396059946821368141165095479816291999033115784384819917814 8,>> 61.2599, 61.3422}>> The precision and accuracy has dropped. This is all> according to> standard numerical analysis regarding cancellation> error. You'll find it> in any textbook on the topic.> Assume that I want accuracy and precision of 100 for> f. You advice me to make experiments to find out, what> should be the initial precision and accuracy of a and> b to reach the requested accuracy and precision for f.> Notice, that you cannot just repeat I[26], we saw> already what happens. I have to re-type I[24], I[25],> I[26], I[27], I[28], and I[29] as many times as needed> to get f with accuracy and precision 100.>> Dan, you simply advocate to do MANUAL WORK that should> be done by machine.>> Let's suppose that in the above example I just want 60> digits not 61. Precisely, I want 60 digits and nothing> or zeros afterwards. Let's see if I could use> SetAccuracy.>> In[30]:=> SetAccuracy[%, 60]>> Out[30]=> - 0.82739605994682136814116509547981629199903311578438481991781 >> In[31]:=> % // FullForm>> Out[30]//FullForm=> - 0.827396059946821368141165095479816291999033115784384819917814 841672467> 988`> 59.9177>> Oops, it did not work (as expected). Let's highlight> with mouse the expression in Out[30] and copy to a new> cell. Oops, we got> - 0.827396059946821368141165095479816291999033115784384819917814 841672467> 988`> 59.9177> again. Let's change Out[30] to a text cell and then> copy.>> In[31]:=> - 0.82739605994682136814116509547981629199903311578438481991781 >> Out[31]=> - 0.82739605994682136814116509547981629199903311578438481991781 >> Success? Not so fast.>> In[32]:=> % // FullForm>> Out[32]//FullForm=> - 0.827396059946821368141165095479816291999033115784384819917809 999999999> 998635> 08`59.2041>> Dan, is there any simple way to get what I want?>> As I repeated already number of times, at this stage> of the development of computer technology, software> should do it for me (!). We both know that this is> doable. Some of the textbooks that you just advised me> to read describe it. As a developer of Mathematica,> tell us why do you consider this to be a bad idea?>> Peter Kosta>> As for what happens when you artificially raise> precision (or accuracy)> of machine numbers far beyond that guaranteed by> their internal> representation, that falls into to category of> garbage in, garbage out.> It is, howoever, valid to use SetPrecision to raise> precision in> (typically iterative) algorithms where significance> arithmetic might be> unduly pessimistic due to incorrect assumptions> about uncorollatedness> of numerical error. Examples of such usage have> appeared in this news> group.> Daniel Lichtblau> Wolfram Research> __________________________________________________> Do you Yahoo!?> http://faith.yahoo.com>>Reply-To: ==== Here's a start, with a more complicated function:lst = Range[50]; f = #1^2 & ; k = 7; r = Range[k + 1, Length[lst], k]; lst[[r]] = lst[[r]] + f /@ lst[[r - 1]]; lst{1, 2, 3, 4, 5, 6, 7, 57, 9, 10, 11, 12, 13, 14, 211, 16, 17, 18, 19,20, 21, 463, 23, 24, 25, 26, 27, 28, 813, 30, 31, 32, 33, 34, 35, 1261,37, 38, 39, 40, 41, 42, 1807, 44, 45, 46, 47, 48, 49, 2451}or:g[lst_List, k_Integer?Positive, f_Function] := Module[ {result = lst, r = Range[k + 1, Length[lst], k]}, result[[r]] = result[[r]] + f /@ lst[[r - 1]]; result ]lst = Range[50]; lst = g[lst, 7, #1^2 & ]or:lst = Range[50]; lst + Drop[Prepend[MapIndexed[If[Mod[First@#2, k] == 0, f@#1, 0] &,lst], 0], -1]DrBob-----Original Message-----advantage of native List operators, but still not be too recondite? I've been thinking about multiplying a copy of myList by a mask list{0,0,1,0,0,1,..} to generate a masked copy and approaches like that. Better ways??? ==== I'm playing around with Mathematica just trying to see what happens if... One thing I came up with was lst1={a,b,c}; lst2={d,e,f}; Map[lst1,lst2} which resulted in the following rather unusual looking expression(?):{{a, b, c}[d], {a, b, c}[e], {a, b, c}[f]}I'm wondering if such a List represents something Ômeaningful'. Any opinions?STH. ==== > I'm playing around with Mathematica just trying to see what happens if...One thing> I came up with was lst1={a,b,c}; lst2={d,e,f}; Map[lst1,lst2} which> resulted in the following rather unusual looking expression(?):>> {{a, b, c}[d], {a, b, c}[e], {a, b, c}[f]}>> I'm wondering if such a List represents something Ômeaningful'. Any> opinions?Through /@ {{a, b, c}[d], {a, b, c}[e], {a, b, c}[f]}{{a[d], b[d], c[d]}, {a[e], b[e], c[e]}, {a[f], b[f], c[f]}}which might be useful.--Allan---------------------Allan HayesMathematica Training and ConsultingLeicester UKwww.haystack.demon.co.ukhay@haystack.demon.co.ukVoice : +44 (0)116 271 4198 ==== >I want to apply a function to every k-th element of a long list and>add the result to the k+1 element.>>[Actually k = 3 and I just want to multiply myList[[k]] by a>constant (independent of k) and add the result to myList[[k+1]] for>every value of k that's divisible by 3.]lst = Table[Random[], {20}]fact = 2Here's a matrix method. f represents an indexed element of a matrix.f[x_,x_] := If[Mod[x,3]==0, fact, 1]f[x_, y_] := If[Mod[x,3]==0&&y[Equal]x+1, 2, 0]Create a matrix from the elements.arr = Array[f,{Length[lst], Length[lst]}];Then matrix multiply.newlst1 = lst.arrHere's another way with the highly underrated MapIndexed.Create pairs of the nth and n-1th values.pairs = Transpose[{lst, Prepend[Drop[lst,-1],0]}]Create a function that takes the nth value (val), the n-1th value (prevval), and the index (num).multlst[{val_, prevval_}, {num_}] := Switch[Mod[num, 3], 0, fact*val, 1,val+ fact*prevval, 2, val ]Then, MapIndexed across the pairs.newlst2=MapIndexed[multlst, pairs]------------------------------------------------------- -------Omega ConsultingThe final answer to your Mathematica needsSpend less time searching and more time finding.http://www.wz.com/internet/Mathematica.html ==== I have two equations that I have solved for:x[n_] := 2331 + 8 ny[n_] := -3108 - 11nI want to include only solutions which are non-negative, that is x >= 0 andy >= 0.In this example we can do 2331 + 8n > = 0 and solve for n, n >= -291.375and -3108 - 11 n >= 0 and solve for n, n <= -282.545So we have -291.375 <= n <= -282.545.The integer solution set here is for n ={-290, -289, -288, -287, -286, -285, -284, -283}.So in this case we have 8 non-negative solutions.Given that I can supply x[n] and y[n], how do I go about finding the set n? ==== Here is a way of doing what you want (output cells are indented):<=0,y[n]>=0},n] -(2331/8) <= n <= -(3108/11)FullForm[soln] Inequality[Rational[-2331,8],LessEqual,n,LessEqual,Rational[- 3108,11]]Range[Apply[Sequence,{Ceiling[soln[[1]]],Floor[soln [[-1]]]}]] {-291, -290, -289, -288, -287, -286, -285, -284, -283}--Steve LuttrellWest Malvern, UK>> I have two equations that I have solved for:>> x[n_] := 2331 + 8 n> y[n_] := -3108 - 11n>> I want to include only solutions which are non-negative, that is x >= 0and> y >= 0.>> In this example we can do 2331 + 8n > = 0 and solve for n, n >= -291.375> and -3108 - 11 n >= 0 and solve for n, n <= -282.545>> So we have -291.375 <= n <= -282.545.>> The integer solution set here is for n => {-290, -289, -288, -287, -286, -285, -284, -283}.>> So in this case we have 8 non-negative solutions.>> Given that I can supply x[n] and y[n], how do I go about finding the setn?>> ==== Let's first consider your original problem and take a small list as an example:mylist = {a, b, c, d, e, f, g};As you pointed out there is a rather obvious and natural way to do it using the Do loop.In[5]:=Do[mylist[[3*i + 1]] = k*mylist[[3*i]] + mylist[[3*i + 1]], {i, 1, Length[mylist]/3}]; mylistOut[5]={a, b, c, d + c*k, e, f, g + f*k}One can also do it using something like your second approach. Notice the need to re-set mylist which got changed by the Do loop:In[6]:=mylist={a,b,c,d,e,f,g};In[7]:=RotateRight[ Table[If[Mod[i,3]==0,k, 0],{i,1,Length[mylist]}]*mylist]+mylistOut[7]={a,b,c,d+c k,e,f,g+f k}There is an ambiguity that appears if the length of the list is exactly divisible by 3. In that case k times the last element should be added to the next element. In this case the first approach (using Do) will produce an error message while the second will interpret the next element to mean the first element of the list. One can fix that but I shan't bother to do so and assume that the length of the list is not divisible by 3.Now let's take a large list and compare the performance of the two approaches:In[8]:=k = 2;In[9]:=mylist = Table[Random[Integer, {1, 9}], {10000}];In[11]:=mylist1 = mylist;In[12]:=Timing[list1 = (Do[mylist[[3*i + 1]] = k*mylist[[3*i]] + mylist[[3*i + 1]], {i, 1, Length[mylist]/3}]; mylist); ]Out[12]={0.21999999999999997*Second, Null}In[13]:=mylist = mylist1;In[14]:=Timing[list2 = RotateRight[Table[If[Mod[i, 3] == 0, k, 0], {i, 1, Length[mylist]}]*mylist] + mylist; ]Out[14]={0.020000000000000018*Second, Null}In[15]:=list1 == list2Out[15]=TrueSo you were right, at least in this implementation the second approach turns out to be much faster. Note also however, that when you change the problem to the one that you originally stated the two approaches will no longer give the same answer. The reason is that your statement is ambiguous: apply a function to every k-th element of a long list and add the result to the k+1 element can either mean that you want to take the original k-th element of the original list, multiply by a constant and add to the next one, or do the same with the already altered k-th element (by the previous step of the procedure). The Do loop approach will do the latter and the other the former.Andrzej KozlowskiYokohama, Japanhttp://www.mimuw.edu.pl/~akoz/http:// platon.c.u-tokyo.ac.jp/andrzej/> I want to apply a function to every k-th element of a long list and> add the result to the k+1 element.>> [Actually k = 3 and I just want to multiply myList[[k]] by a> constant (independent of k) and add the result to myList[[k+1]] for> every value of k that's divisible by 3.]>> Is there a way to do this -- or in general to get at every k-th> element of a list -- that's faster and more elegant than writing a > brute> force Do[] loop or using Mod[] operators, and that will take> advantage of native List operators, but still not be too recondite?>> I've been thinking about multiplying a copy of myList by a mask > list> {0,0,1,0,0,1,..} to generate a masked copy and approaches like that.> Better ways???> ==== Can Mathematica factor the polynomialp1=x^6+9/14*x^5+9/28*x^4+3/35*x^3+9/700*x^2+9/ 8750*x+3/87500;without a priori knowledge of the Extension field? ==== Carlos,Futher to my previous posting (which gave the code for the function FactorRused below), here is a complete factorisation by radicals.I also test that the product of the factors gives the original polynomial.We want to factor the polynomial p1 = x^6 + (9/14)*x^5 + (9/28)*x^4 + (3/35)*x^3 + (9/700)*x^2 +(9/8750)*x + 3/87500; in radicals.We can't expect this to be easy or even possible in terms of radicals (thegeneral quintic is not solvable interms of radicals).But, using the function FactorR given in my posting, Re:factoring quarticover radicals, sent a few days ago (08/012/02) , we get p2 = FactorR[p1, x](x^2 - 2*x*Root[3 + 45*#1 + 225*#1^2 + 700*#1^3 & , 1] + Root[-3 + 225*#1^2 - 5625*#1^4 + 87500*#1^6 & , 2]^2)* (x^2 - 2*x*Root[1827 + 65340*#1 + 974700*#1^2 + 7824000*#1^3 +36360000*#1^4 + 100800000*#1^5 + 156800000*#1^6 & , 2] + Root[9 - 1350*#1^2 + 84375*#1^4 - 3056250*#1^6 - 11250000*#1^8 - 984375000*#1^10 + 7656250000*#1^12 & , 3]^2)* (x^2 - 2*x*Root[1827 + 65340*#1 + 974700*#1^2 + 7824000*#1^3 +36360000*#1^4 + 100800000*#1^5 + 156800000*#1^6 & , 1] + Root[9 - 1350*#1^2 + 84375*#1^4 - 3056250*#1^6 - 11250000*#1^8 - 984375000*#1^10 + 7656250000*#1^12 & , 4]^2)Try to change the root objects to radical form: p3 = p2 /. r_Root :> ToRadicals[r](3/140 + (1/140)*(13/5)^(2/3)*3^(1/3) - (1/140)*(13/5)^(1/3)*3^(2/3) - 2*(-(3/28) - (1/28)*(13/5)^(2/3)*3^(1/3) + (1/28)*(13/5)^(1/3)*3^(2/3))*x+ x^2)*(x^2 - 2*x*Root[1827 + 65340*#1 + 974700*#1^2 + 7824000*#1^3 + 36360000*#1^4 + 100800000*#1^5 + 156800000*#1^6 & , 2] + Root[9 - 1350*#1 + 84375*#1^2 - 3056250*#1^3 - 11250000*#1^4 - 984375000*#1^5 + 7656250000*#1^6 & , 1])* (x^2 - 2*x*Root[1827 + 65340*#1 + 974700*#1^2 + 7824000*#1^3 +36360000*#1^4 + 100800000*#1^5 + 156800000*#1^6 & , 1] + Root[9 - 1350*#1 + 84375*#1^2 - 3056250*#1^3 - 11250000*#1^4 - 984375000*#1^5 + 7656250000*#1^6 & , 2])We succeeded with the first factor: f1 = p3[[1]]3/140 + (1/140)*(13/5)^(2/3)*3^(1/3) - (1/140)*(13/5)^(1/3)*3^(2/3) - 2*(-(3/28) - (1/28)*(13/5)^(2/3)*3^(1/3) + (1/28)*(13/5)^(1/3)*3^(2/3))*x+ x^2The product of the other two factors, in a form avoiding root objects, iseasily found by division: q = PolynomialQuotient[p1, f1, x]3/3500 + ((13/5)^(1/3)*3^(2/3))/3500 + (3/175 +(1/175)*(13/5)^(1/3)*3^(2/3))*x + (9/70 - (1/140)*(13/5)^(2/3)*3^(1/3) + (1/28)*(13/5)^(1/3)*3^(2/3))*x^2 + (3/7 - (1/14)*(13/5)^(2/3)*3^(1/3) + (1/14)*(13/5)^(1/3)*3^(2/3))*x^3 +x^4Try FactorR on this f23 = FactorR[q, x](x^2 + ((-(1/2))*Sqrt[117/1960 + (9/784)*(13/5)^(2/3)*3^(1/3) + (39*(13/5)^(1/3)*3^(2/3))/3920] + Im[(1/2)*Sqrt[117/1960 + (9/784)*(13/5)^(2/3)*3^(1/3) + (39*(13/5)^(1/3)*3^(2/3))/3920 + (-2250 + 25*13^(2/3)*15^(1/3) - 125*13^(1/3)*15^(2/3))/8750 + (3*(7500 - 250*13^(2/3)*15^(1/3) + 250*13^(1/3)*15^(2/3))^2)/ 1225000000 - (-((2*(300 + 20*13^(1/3)*15^(2/3)))/4375) + (1/17500)*((7500 - 250*13^(2/3)*15^(1/3) +250*13^(1/3)*15^(2/3))* ((2250 - 25*13^(2/3)*15^(1/3) + 125*13^(1/3)*15^(2/3))/4375 - (7500 - 250*13^(2/3)*15^(1/3) + 250*13^(1/3)*15^(2/3))^2/ 306250000)))/(4*Sqrt[-(117/1960) -(9/784)*(13/5)^(2/3)*3^(1/3) - (39*(13/5)^(1/3)*3^(2/3))/3920])]])^2 - 2*x*((-7500 + 250*13^(2/3)*15^(1/3) - 250*13^(1/3)*15^(2/3))/70000 + Re[(1/2)*Sqrt[117/1960 + (9/784)*(13/5)^(2/3)*3^(1/3) + (39*(13/5)^(1/3)*3^(2/3))/3920 + (-2250 + 25*13^(2/3)*15^(1/3) - 125*13^(1/3)*15^(2/3))/8750 + (3*(7500 - 250*13^(2/3)*15^(1/3) + 250*13^(1/3)*15^(2/3))^2)/ 1225000000 - (-((2*(300 + 20*13^(1/3)*15^(2/3)))/4375) + (1/17500)*((7500 - 250*13^(2/3)*15^(1/3) +250*13^(1/3)*15^(2/3))* ((2250 - 25*13^(2/3)*15^(1/3) + 125*13^(1/3)*15^(2/3))/4375 - (7500 - 250*13^(2/3)*15^(1/3) + 250*13^(1/3)*15^(2/3))^2/ 306250000)))/(4*Sqrt[-(117/1960) -(9/784)*(13/5)^(2/3)*3^(1/3) - (39*(13/5)^(1/3)*3^(2/3))/3920])]]) + ((-7500 + 250*13^(2/3)*15^(1/3) - 250*13^(1/3)*15^(2/3))/70000 + Re[(1/2)*Sqrt[117/1960 + (9/784)*(13/5)^(2/3)*3^(1/3) + (39*(13/5)^(1/3)*3^(2/3))/3920 + (-2250 + 25*13^(2/3)*15^(1/3) - 125*13^(1/3)*15^(2/3))/8750 + (3*(7500 - 250*13^(2/3)*15^(1/3) + 250*13^(1/3)*15^(2/3))^2)/ 1225000000 - (-((2*(300 + 20*13^(1/3)*15^(2/3)))/4375) + (1/17500)*((7500 - 250*13^(2/3)*15^(1/3) +250*13^(1/3)*15^(2/3))* ((2250 - 25*13^(2/3)*15^(1/3) + 125*13^(1/3)*15^(2/3))/4375 - (7500 - 250*13^(2/3)*15^(1/3) + 250*13^(1/3)*15^(2/3))^2/ 306250000)))/(4*Sqrt[-(117/1960) -(9/784)*(13/5)^(2/3)*3^(1/3) - (39*(13/5)^(1/3)*3^(2/3))/3920])]])^2)* (x^2 + ((1/2)*Sqrt[117/1960 + (9/784)*(13/5)^(2/3)*3^(1/3) + (39*(13/5)^(1/3)*3^(2/3))/3920] + Im[(-(1/2))*Sqrt[117/1960 + (9/784)*(13/5)^(2/3)*3^(1/3) + (39*(13/5)^(1/3)*3^(2/3))/3920 + (-2250 + 25*13^(2/3)*15^(1/3) - 125*13^(1/3)*15^(2/3))/8750 + (3*(7500 - 250*13^(2/3)*15^(1/3) + 250*13^(1/3)*15^(2/3))^2)/ 1225000000 + (-((2*(300 + 20*13^(1/3)*15^(2/3)))/4375) + (1/17500)*((7500 - 250*13^(2/3)*15^(1/3) +250*13^(1/3)*15^(2/3))* ((2250 - 25*13^(2/3)*15^(1/3) + 125*13^(1/3)*15^(2/3))/4375 - (7500 - 250*13^(2/3)*15^(1/3) + 250*13^(1/3)*15^(2/3))^2/ 306250000)))/(4*Sqrt[-(117/1960) -(9/784)*(13/5)^(2/3)*3^(1/3) - (39*(13/5)^(1/3)*3^(2/3))/3920])]])^2 - 2*x*((-7500 + 250*13^(2/3)*15^(1/3) - 250*13^(1/3)*15^(2/3))/70000 + Re[(-(1/2))*Sqrt[117/1960 + (9/784)*(13/5)^(2/3)*3^(1/3) + (39*(13/5)^(1/3)*3^(2/3))/3920 + (-2250 + 25*13^(2/3)*15^(1/3) - 125*13^(1/3)*15^(2/3))/8750 + (3*(7500 - 250*13^(2/3)*15^(1/3) + 250*13^(1/3)*15^(2/3))^2)/ 1225000000 + (-((2*(300 + 20*13^(1/3)*15^(2/3)))/4375) + (1/17500)*((7500 - 250*13^(2/3)*15^(1/3) +250*13^(1/3)*15^(2/3))* ((2250 - 25*13^(2/3)*15^(1/3) + 125*13^(1/3)*15^(2/3))/4375 - (7500 - 250*13^(2/3)*15^(1/3) + 250*13^(1/3)*15^(2/3))^2/ 306250000)))/(4*Sqrt[-(117/1960) -(9/784)*(13/5)^(2/3)*3^(1/3) - (39*(13/5)^(1/3)*3^(2/3))/3920])]]) + ((-7500 + 250*13^(2/3)*15^(1/3) - 250*13^(1/3)*15^(2/3))/70000 + Re[(-(1/2))*Sqrt[117/1960 + (9/784)*(13/5)^(2/3)*3^(1/3) + (39*(13/5)^(1/3)*3^(2/3))/3920 + (-2250 + 25*13^(2/3)*15^(1/3) - 125*13^(1/3)*15^(2/3))/8750 + (3*(7500 - 250*13^(2/3)*15^(1/3) + 250*13^(1/3)*15^(2/3))^2)/ 1225000000 + (-((2*(300 + 20*13^(1/3)*15^(2/3)))/4375) + (1/17500)*((7500 - 250*13^(2/3)*15^(1/3) +250*13^(1/3)*15^(2/3))* ((2250 - 25*13^(2/3)*15^(1/3) + 125*13^(1/3)*15^(2/3))/4375 - (7500 - 250*13^(2/3)*15^(1/3) + 250*13^(1/3)*15^(2/3))^2/ 306250000)))/(4*Sqrt[-(117/1960) -(9/784)*(13/5)^(2/3)*3^(1/3) - (39*(13/5)^(1/3)*3^(2/3))/3920])]])^2)We try to get rid of the parts Re[.] and Im[.]:, f231 = f23 /. z:(_Re | _Im) :> ToRadicals[FullSimplify[z]](((-7500 + 250*13^(2/3)*15^(1/3) - 250*13^(1/3)*15^(2/3))/70000 - (1/280)*Sqrt[3*(-390 + 13*13^(2/3)*15^(1/3) + 15*13^(1/3)*15^(2/3))])^2+ ((1/2)*Sqrt[117/1960 + (9/784)*(13/5)^(2/3)*3^(1/3) + (39*(13/5)^(1/3)*3^(2/3))/3920] + (1/280)*Sqrt[1170 + 73*13^(2/3)*15^(1/3) + 67*13^(1/3)*15^(2/3)])^2 - 2*((-7500 + 250*13^(2/3)*15^(1/3) - 250*13^(1/3)*15^(2/3))/70000 - (1/280)*Sqrt[3*(-390 + 13*13^(2/3)*15^(1/3) + 15*13^(1/3)*15^(2/3))])*x+ x^2)*(((-7500 + 250*13^(2/3)*15^(1/3) - 250*13^(1/3)*15^(2/3))/70000 + (1/280)*Sqrt[3*(-390 + 13*13^(2/3)*15^(1/3) + 15*13^(1/3)*15^(2/3))])^2+ ((-(1/2))*Sqrt[117/1960 + (9/784)*(13/5)^(2/3)*3^(1/3) + (39*(13/5)^(1/3)*3^(2/3))/3920] + (1/280)*Sqrt[1170 + 73*13^(2/3)*15^(1/3) + 67*13^(1/3)*15^(2/3)])^2 - 2*((-7500 + 250*13^(2/3)*15^(1/3) - 250*13^(1/3)*15^(2/3))/70000 + (1/280)*Sqrt[3*(-390 + 13*13^(2/3)*15^(1/3) + 15*13^(1/3)*15^(2/3))])*x+ x^2)We now have the ramaining two factors in radical form, but a littlesimplification helps: f232 = f231 /. (n_)?NumericQ :> Simplify[n]((1/78400)*(30 - 13^(2/3)*15^(1/3) + 13^(1/3)*15^(2/3) + Sqrt[-1170 + 39*13^(2/3)*15^(1/3) + 45*13^(1/3)*15^(2/3)])^2 + (1/78400)*(Sqrt[1170 + 45*13^(2/3)*15^(1/3) + 39*13^(1/3)*15^(2/3)] + Sqrt[1170 + 73*13^(2/3)*15^(1/3) + 67*13^(1/3)*15^(2/3)])^2 - (1/140)*(-30 + 13^(2/3)*15^(1/3) - 13^(1/3)*15^(2/3) - Sqrt[-1170 + 39*13^(2/3)*15^(1/3) + 45*13^(1/3)*15^(2/3)])*x + x^2)* ((1/78400)*(-30 + 13^(2/3)*15^(1/3) - 13^(1/3)*15^(2/3) + Sqrt[-1170 + 39*13^(2/3)*15^(1/3) + 45*13^(1/3)*15^(2/3)])^2 + (1/78400)*(Sqrt[1170 + 45*13^(2/3)*15^(1/3) + 39*13^(1/3)*15^(2/3)] - Sqrt[1170 + 73*13^(2/3)*15^(1/3) + 67*13^(1/3)*15^(2/3)])^2 - (1/140)*(-30 + 13^(2/3)*15^(1/3) - 13^(1/3)*15^(2/3) + Sqrt[-1170 + 39*13^(2/3)*15^(1/3) + 45*13^(1/3)*15^(2/3)])*x + x^2)TESTTest if the product of the factors is equal to p1: prd1 = Collect[Expand[f232*f1], x]172077/3841600000 - (4959*(13/5)^(2/3)*3^(1/3))/768320000 + (117*(13/5)^(1/3)*3^(2/3))/27440000 - (1/1920800000)* (3*Sqrt[1170 + 45*13^(2/3)*15^(1/3) + 39*13^(1/3)*15^(2/3)]* Sqrt[-1170 + 39*13^(2/3)*15^(1/3) + 45*13^(1/3)*15^(2/3)]* Sqrt[1170 + 73*13^(2/3)*15^(1/3) + 67*13^(1/3)*15^(2/3)]) + (1/3841600000)*((13/5)^(1/3)*3^(2/3)*Sqrt[1170 + 45*13^(2/3)*15^(1/3) + 39*13^(1/3)*15^(2/3)]*Sqrt[-1170 + 39*13^(2/3)*15^(1/3) + 45*13^(1/3)*15^(2/3)]*Sqrt[1170 + 73*13^(2/3)*15^(1/3) + 67*13^(1/3)*15^(2/3)]) + (491193/384160000 - (7731*(13/5)^(2/3)*3^(1/3))/76832000 + (117*(13/5)^(1/3)*3^(2/3))/2744000 - (1/384160000)* (9*Sqrt[1170 + 45*13^(2/3)*15^(1/3) + 39*13^(1/3)*15^(2/3)]* Sqrt[-1170 + 39*13^(2/3)*15^(1/3) + 45*13^(1/3)*15^(2/3)]* Sqrt[1170 + 73*13^(2/3)*15^(1/3) + 67*13^(1/3)*15^(2/3)]) - (1/384160000)*((13/5)^(2/3)*3^(1/3)*Sqrt[1170 + 45*13^(2/3)*15^(1/3) + 39*13^(1/3)*15^(2/3)]*Sqrt[-1170 + 39*13^(2/3)*15^(1/3) + 45*13^(1/3)*15^(2/3)]*Sqrt[1170 + 73*13^(2/3)*15^(1/3) + 67*13^(1/3)*15^(2/3)]) + (1/192080000)*((13/5)^(1/3)*3^(2/3)* Sqrt[1170 + 45*13^(2/3)*15^(1/3) + 39*13^(1/3)*15^(2/3)]* Sqrt[-1170 + 39*13^(2/3)*15^(1/3) + 45*13^(1/3)*15^(2/3)]* Sqrt[1170 + 73*13^(2/3)*15^(1/3) + 67*13^(1/3)*15^(2/3)]))*x + (1087173/76832000 - (12771*(13/5)^(2/3)*3^(1/3))/30732800 + (5967*(13/5)^(1/3)*3^(2/3))/30732800 - (1/76832000)* (9*Sqrt[1170 + 45*13^(2/3)*15^(1/3) + 39*13^(1/3)*15^(2/3)]* Sqrt[-1170 + 39*13^(2/3)*15^(1/3) + 45*13^(1/3)*15^(2/3)]* Sqrt[1170 + 73*13^(2/3)*15^(1/3) + 67*13^(1/3)*15^(2/3)]) - (1/153664000)*(3*(13/5)^(2/3)*3^(1/3)*Sqrt[1170 + 45*13^(2/3)*15^(1/3) + 39*13^(1/3)*15^(2/3)]*Sqrt[-1170 + 39*13^(2/3)*15^(1/3) + 45*13^(1/3)*15^(2/3)]*Sqrt[1170 + 73*13^(2/3)*15^(1/3) + 67*13^(1/3)*15^(2/3)]) + (1/153664000)*(3*(13/5)^(1/3)*3^(2/3)* Sqrt[1170 + 45*13^(2/3)*15^(1/3) + 39*13^(1/3)*15^(2/3)]* Sqrt[-1170 + 39*13^(2/3)*15^(1/3) + 45*13^(1/3)*15^(2/3)]* Sqrt[1170 + 73*13^(2/3)*15^(1/3) + 67*13^(1/3)*15^(2/3)]))*x^2 + (23871/274400 - (99*(13/5)^(2/3)*3^(1/3))/109760 +(663*(13/5)^(1/3)*3^(2/3))/ 548800 - (1/2744000)*(Sqrt[1170 + 45*13^(2/3)*15^(1/3) + 39*13^(1/3)*15^(2/3)]*Sqrt[-1170 + 39*13^(2/3)*15^(1/3) + 45*13^(1/3)*15^(2/3)]*Sqrt[1170 + 73*13^(2/3)*15^(1/3) + 67*13^(1/3)*15^(2/3)]))*x^3 + (9*x^4)/28 + (9*x^5)/14 + x^6 prd1 /. (n_)?NumericQ :> ToRadicals[FullSimplify[n]]172077/3841600000 - (4959*(13/5)^(2/3)*3^(1/3))/768320000 + (117*(13/5)^(1/3)*3^(2/3))/27440000 - (9*(234 + 221*(13/5)^(1/3)*3^(2/3) - 33*13^(2/3)*15^(1/3)))/384160000 + (117*(-165 + 17*13^(2/3)*15^(1/3) + 6*13^(1/3)*15^(2/3)))/3841600000 + (9*x)/8750 + (9*x^2)/700 + (3*x^3)/35 + (9*x^4)/28 + (9*x^5)/14 + x^6 Together[%](3 + 90*x + 1125*x^2 + 7500*x^3 + 28125*x^4 + 56250*x^5 + 87500*x^6)/87500 Apart[%]3/87500 + (9*x)/8750 + (9*x^2)/700 + (3*x^3)/35 + (9*x^4)/28 + (9*x^5)/14 +x^6This is p1: p13/87500 + (9*x)/8750 + (9*x^2)/700 + (3*x^3)/35 + (9*x^4)/28 + (9*x^5)/14 +x^6------------------It is ususlly better to try to reduce a difference to zero than to reduceone form to anothertst1 = Collect[Expand[f232*f1 - p1], x]tst2 = tst1 /. (n_)?NumericQ :> ToRadicals[FullSimplify[n]]8073/768320000 - (4959*(13/5)^(2/3)*3^(1/3))/768320000 + (117*(13/5)^(1/3)*3^(2/3))/27440000 - (9*(234 + 221*(13/5)^(1/3)*3^(2/3) - 33*13^(2/3)*15^(1/3)))/384160000 + (117*(-165 + 17*13^(2/3)*15^(1/3) + 6*13^(1/3)*15^(2/3)))/3841600000Together[%]0--Allan------- --------------Allan HayesMathematica Training and ConsultingLeicester UKwww.haystack.demon.co.ukhay@haystack.demon.co.ukVoice : +44 (0)116 271 4198> Can Mathematica factor the polynomial>> p1=x^6+9/14*x^5+9/28*x^4+3/35*x^3+9/700*x^2+9/8750*x+3/87500; >> without a priori knowledge of the Extension field?> ==== Carlos,p1=x^6+9/14*x^5+9/28*x^4+3/35*x^3+9/700*x^ 2+9/8750*x+3/87500;We can't expect this to be easy or even possible in terms of radicals (thegeneral quintic is not solvable interms of radicals).But, using the function FactorR given in my posting, Re:factoring quarticover radicals, sent a few days (08/012/02) ago, we getp2=FactorR[p1,x](x^2 - 2*x*Root[3 + 45*#1 + 225*#1^2 + 700*#1^3 & , 1] + Root[-3 + 225*#1^2 - 5625*#1^4 + 87500*#1^6 & , 2]^2)* (x^2 - 2*x*Root[1827 + 65340*#1 + 974700*#1^2 + 7824000*#1^3 + 36360000*#1^4 + 100800000*#1^5 + 156800000*#1^6 & , 2] + Root[9 - 1350*#1^2 + 84375*#1^4 - 3056250*#1^6 - 11250000*#1^8 - 984375000*#1^10 + 7656250000*#1^12 & , 3]^2)* (x^2 - 2*x*Root[1827 + 65340*#1 + 974700*#1^2 + 7824000*#1^3 + 36360000*#1^4 + 100800000*#1^5 + 156800000*#1^6 & , 1] + Root[9 - 1350*#1^2 + 84375*#1^4 - 3056250*#1^6 - 11250000*#1^8 - 984375000*#1^10 + 7656250000*#1^12 & , 4]^2)Try to express the factors in terms of radicalsp3=ToRadicals/@p2(3/140 + (1/140)*(13/5)^(2/3)*3^(1/3) - (1/140)*(13/5)^(1/3)*3^(2/3) - 2*(-(3/28) - (1/28)*(13/5)^(2/3)*3^(1/3) + (1/28)*(13/5)^(1/3)*3^(2/3))*x + x^2)* (x^2 - 2*x*Root[1827 + 65340*#1 + 974700*#1^2 + 7824000*#1^3 + 36360000*#1^4 + 100800000*#1^5 + 156800000*#1^6 & , 2] + Root[9 - 1350*#1 + 84375*#1^2 - 3056250*#1^3 - 11250000*#1^4 - 984375000*#1^5 + 7656250000*#1^6 & , 1])* (x^2 - 2*x*Root[1827 + 65340*#1 + 974700*#1^2 + 7824000*#1^3 + 36360000*#1^4 + 100800000*#1^5 + 156800000*#1^6 & , 1] + Root[9 - 1350*#1 + 84375*#1^2 - 3056250*#1^3 - 11250000*#1^4 - 984375000*#1^5 + 7656250000*#1^6 & , 2])We succeeded with the first factorf1=p3[[1]] 3/140 + (1/140)*(13/5)^(2/3)*3^(1/3) - (1/140)*(13/5)^(1/3)*3^(2/3) - 2*(-(3/28) - (1/28)*(13/5)^(2/3)*3^(1/3) + (1/28)*(13/5)^(1/3)*3^(2/3))*x + x^2The product of the other two factors, in a form avoiding root objects, iseasily found:q=PolynomialQuotient[p1,f1,x] 3/3500 + ((13/5)^(1/3)*3^(2/3))/3500 + (3/175 + (1/175)*(13/5)^(1/3)*3^(2/3))*x + (9/70 - (1/140)*(13/5)^(2/3)*3^(1/3) + (1/28)*(13/5)^(1/3)*3^(2/3))*x^2 + (3/7 - (1/14)*(13/5)^(2/3)*3^(1/3) + (1/14)*(13/5)^(1/3)*3^(2/3))*x^3 + x^4 5*(3 + 10*x*(6 + 5*x*(9 + 10*x*(3 + 7*x)))))Try FactorR on thisf23=FactorR[q,x] (x^2 + ((-(1/2))*Sqrt[117/1960 + (9/784)*(13/5)^(2/3)* 3^(1/3) + (39*(13/5)^(1/3)*3^(2/3))/3920] + Im[(1/2)*Sqrt[117/1960 + (9/784)*(13/5)^(2/3)* 3^(1/3) + (39*(13/5)^(1/3)*3^(2/3))/3920 + (-2250 + 25*13^(2/3)*15^(1/3) - 125*13^(1/3)* 15^(2/3))/8750 + (3*(7500 - 250*13^(2/3)*15^(1/3) + 250*13^(1/3)* 15^(2/3))^2)/1225000000 - (-((2*(300 + 20*13^(1/3)*15^(2/3)))/4375) + (1/17500)*((7500 - 250*13^(2/3)*15^(1/3) + 250*13^(1/3)*15^(2/3))*((2250 - 25*13^(2/3)* 15^(1/3) + 125*13^(1/3)*15^(2/3))/4375 - (7500 - 250*13^(2/3)*15^(1/3) + 250*13^(1/3)*15^(2/3))^2/306250000)))/ (4*Sqrt[-(117/1960) - (9/784)*(13/5)^(2/3)* 3^(1/3) - (39*(13/5)^(1/3)*3^(2/3))/ 3920])]])^2 - 2*x*((-7500 + 250*13^(2/3)*15^(1/3) - 250*13^(1/3)*15^(2/3))/70000 + Re[(1/2)*Sqrt[117/1960 + (9/784)*(13/5)^(2/3)* 3^(1/3) + (39*(13/5)^(1/3)*3^(2/3))/3920 + (-2250 + 25*13^(2/3)*15^(1/3) - 125*13^(1/3)* 15^(2/3))/8750 + (3*(7500 - 250*13^(2/3)*15^(1/3) + 250*13^(1/3)* 15^(2/3))^2)/1225000000 - (-((2*(300 + 20*13^(1/3)*15^(2/3)))/4375) + (1/17500)*((7500 - 250*13^(2/3)*15^(1/3) + 250*13^(1/3)*15^(2/3))*((2250 - 25*13^(2/3)* 15^(1/3) + 125*13^(1/3)*15^(2/3))/4375 - (7500 - 250*13^(2/3)*15^(1/3) + 250*13^(1/3)*15^(2/3))^2/306250000)))/ (4*Sqrt[-(117/1960) - (9/784)*(13/5)^(2/3)* 3^(1/3) - (39*(13/5)^(1/3)*3^(2/3))/ 3920])]]) + ((-7500 + 250*13^(2/3)*15^(1/3) - 250*13^(1/3)* 15^(2/3))/70000 + Re[(1/2)*Sqrt[117/1960 + (9/784)*(13/5)^(2/3)* 3^(1/3) + (39*(13/5)^(1/3)*3^(2/3))/3920 + (-2250 + 25*13^(2/3)*15^(1/3) - 125*13^(1/3)* 15^(2/3))/8750 + (3*(7500 - 250*13^(2/3)*15^(1/3) + 250*13^(1/3)* 15^(2/3))^2)/1225000000 - (-((2*(300 + 20*13^(1/3)*15^(2/3)))/4375) + (1/17500)*((7500 - 250*13^(2/3)*15^(1/3) + 250*13^(1/3)*15^(2/3))*((2250 - 25*13^(2/3)* 15^(1/3) + 125*13^(1/3)*15^(2/3))/4375 - (7500 - 250*13^(2/3)*15^(1/3) + 250*13^(1/3)*15^(2/3))^2/306250000)))/ (4*Sqrt[-(117/1960) - (9/784)*(13/5)^(2/3)* 3^(1/3) - (39*(13/5)^(1/3)*3^(2/3))/ 3920])]])^2)* (x^2 + ((1/2)*Sqrt[117/1960 + (9/784)*(13/5)^(2/3)* 3^(1/3) + (39*(13/5)^(1/3)*3^(2/3))/3920] + Im[(-(1/2))*Sqrt[117/1960 + (9/784)*(13/5)^(2/3)* 3^(1/3) + (39*(13/5)^(1/3)*3^(2/3))/3920 + (-2250 + 25*13^(2/3)*15^(1/3) - 125*13^(1/3)* 15^(2/3))/8750 + (3*(7500 - 250*13^(2/3)*15^(1/3) + 250*13^(1/3)* 15^(2/3))^2)/1225000000 + (-((2*(300 + 20*13^(1/3)*15^(2/3)))/4375) + (1/17500)*((7500 - 250*13^(2/3)*15^(1/3) + 250*13^(1/3)*15^(2/3))*((2250 - 25*13^(2/3)* 15^(1/3) + 125*13^(1/3)*15^(2/3))/4375 - (7500 - 250*13^(2/3)*15^(1/3) + 250*13^(1/3)*15^(2/3))^2/306250000)))/ (4*Sqrt[-(117/1960) - (9/784)*(13/5)^(2/3)* 3^(1/3) - (39*(13/5)^(1/3)*3^(2/3))/ 3920])]])^2 - 2*x*((-7500 + 250*13^(2/3)*15^(1/3) - 250*13^(1/3)*15^(2/3))/70000 + Re[(-(1/2))*Sqrt[117/1960 + (9/784)*(13/5)^(2/3)* 3^(1/3) + (39*(13/5)^(1/3)*3^(2/3))/3920 + (-2250 + 25*13^(2/3)*15^(1/3) - 125*13^(1/3)* 15^(2/3))/8750 + (3*(7500 - 250*13^(2/3)*15^(1/3) + 250*13^(1/3)* 15^(2/3))^2)/1225000000 + (-((2*(300 + 20*13^(1/3)*15^(2/3)))/4375) + (1/17500)*((7500 - 250*13^(2/3)*15^(1/3) + 250*13^(1/3)*15^(2/3))*((2250 - 25*13^(2/3)* 15^(1/3) + 125*13^(1/3)*15^(2/3))/4375 - (7500 - 250*13^(2/3)*15^(1/3) + 250*13^(1/3)*15^(2/3))^2/306250000)))/ (4*Sqrt[-(117/1960) - (9/784)*(13/5)^(2/3)* 3^(1/3) - (39*(13/5)^(1/3)*3^(2/3))/ 3920])]]) + ((-7500 + 250*13^(2/3)*15^(1/3) - 250*13^(1/3)* 15^(2/3))/70000 + Re[(-(1/2))*Sqrt[117/1960 + (9/784)*(13/5)^(2/3)* 3^(1/3) + (39*(13/5)^(1/3)*3^(2/3))/3920 + (-2250 + 25*13^(2/3)*15^(1/3) - 125*13^(1/3)* 15^(2/3))/8750 + (3*(7500 - 250*13^(2/3)*15^(1/3) + 250*13^(1/3)* 15^(2/3))^2)/1225000000 + (-((2*(300 + 20*13^(1/3)*15^(2/3)))/4375) + (1/17500)*((7500 - 250*13^(2/3)*15^(1/3) + 250*13^(1/3)*15^(2/3))*((2250 - 25*13^(2/3)* 15^(1/3) + 125*13^(1/3)*15^(2/3))/4375 - (7500 - 250*13^(2/3)*15^(1/3) + 250*13^(1/3)*15^(2/3))^2/306250000)))/ (4*Sqrt[-(117/1960) - (9/784)*(13/5)^(2/3)* 3^(1/3) - (39*(13/5)^(1/3)*3^(2/3))/ 3920])]])^2)We still use Re and Im--Allan---------------------Allan HayesMathematica Training and ConsultingLeicester UKwww.haystack.demon.co.ukhay@haystack.demon.co.ukVoice : +44 (0)116 271 4198> Can Mathematica factor the polynomial>> p1=x^6+9/14*x^5+9/28*x^4+3/35*x^3+9/700*x^2+9/8750*x+3/87500; >> without a priori knowledge of the Extension field?> ==== Dear MathGroup Experts,Is there a slick way to use Mathematica to plot the phase portrait of a pair of (straightforward) differential equations? I'd also like to see a plot of the associated vector/direction field. I found a good package called DynPac, but it's very cumbersome to use, and I was hoping there's another tool out there that my students would feel more comfortable using.Jason-- Jason Miller, Ph.D.Division of Mathematics and Computer ScienceTruman State University100 East Normal St.Kirksville, MO 63501http://vh216801.truman.edu660.785.7430 ==== >I have two equations that I have solved for:>>x[n_] := 2331 + 8 n>y[n_] := -3108 - 11n>>I want to include only solutions which are non-negative, that is x >= 0>and>y >= 0.>>In this example we can do 2331 + 8n > = 0 and solve for n, n >= -291.375>and -3108 - 11 n >= 0 and solve for n, n <= -282.545>>So we have -291.375 <= n <= -282.545.>>The integer solution set here is for n =>{-290, -289, -288, -287, -286, -285, -284, -283}.>>So in this case we have 8 non-negative solutions.>>Given that I can supply x[n] and y[n], how do I go about finding the set>n?>Needs[Algebra`InequalitySolve`];x[n_] := 2331 + 8n;y[n_] := -3108 - 11n;rng = InequalitySolve[{x[n] >= 0, y[n] >= 0}, n];soln = Range[Ceiling[rng[[1]]], rng[[-1]]]{-291, -290, -289, -288, -287, -286, -285, -284, -283}Length[soln]9Bob Hanlon ==== Factoring without specifying the extension does not really make sense. Of course Mathematica can easily factor yur polynomial into linear factors over the complex numbers (with the help of Solve), but I suspect you are really asking for is factoring over the reals. This is harder and needs more human input. But anyway, Mathematica can do this, or at least I have done it using Mathematica. In fact if you are satisfied with a numerical answer Mathematica can do alone and in seconds:In[1]:=Simplify[N[x^6 + (9/14)*x^5 + (9/28)*x^4 + (3/35)*x^3 + (9/700)*x^2 + (9/8750)*x + 3/87500]]Out[1]=1.*(0.010974992601737198 + 0.20255610310498295*x + x^2)*(0.020476912388332692 + 0.2047691238833268*x + x^2)*(0.15256133957420948 + 0.23553191586883315*x + x^2)But I have in fact been foolish enough to compute the exact answer too. I do not propose to post it here for it's absolutely horrible (expressed in terms of Root objects) and quite useless. However if you really want to see it I can send it to you privately.Andrzej KozlowskiYokohama, Japanhttp://www.mimuw.edu.pl/~akoz/http:// platon.c.u-tokyo.ac.jp/andrzej/> To: mathgroup@smc.vnet.net>> Can Mathematica factor the polynomial>> p1=x^6+9/14*x^5+9/28*x^4+3/35*x^3+9/700*x^2+9/8750*x+3/87500; >> without a priori knowledge of the Extension field?> ==== > > Can Mathematica factor the polynomial> p1=x^6+9/14*x^5+9/28*x^4+3/35*x^3+9/700*x^2+9/8750*x+3/87500; > without a priori knowledge of the Extension field?The endless sci.math.symbolic thread strikes MathGroup!Not exactly possible with no prior knowledge. Factor must work with agiven field, and the default is the rationals. You might direct it, sayby using the discriminant of the polynomial (as pointed out by PeterMontgomery and Stephen Forrest on sci.math.symbolic. One may do this inMathematica as:p1 = x^6+9/14*x^5+9/28*x^4+3/35*x^3+9/700*x^2+9/8750*x+3/87500;I cribbed code for Discriminant right from www.mathworld.com:Discriminant[p_?PolynomialQ,x_] := With[{n = Exponent[p,x]}, Cancel[((-1)^(n(n-1)/2)Resultant[p,D[p,x],x])/Coefficient[p,x ,n]^(2n-1)]] In[3]:= InputForm[Factor[p1, Extension->Sqrt[Discriminant[p1,x]]]]Out[3]//InputForm= ((-15*I + Sqrt[195] - (225*I)*x + 15*Sqrt[195]*x - (1125*I)*x^2 + 75*Sqrt[195]*x^2 - (3500*I)*x^3)*(15*I + Sqrt[195] + (225*I)*x + 15*Sqrt[195]*x + (1125*I)*x^2 + 75*Sqrt[195]*x^2 +(3500*I)*x^3))/12250000Daniel LichtblauWolfram Research ==== On second thoughts: any one who really wants to see what the exact answer is, can evaluate the following:sols = Select[{a, b} /. SolveAlways[ x^6 + (9/14)*x^5 + (9/28)*x^4 + (3/35)*x^3 + (9/700)*x^2 + (9/8750)*x + 3/87500 == (x^2 + a*x + b)*(x^4 + c*x^3 + d*x^2 + e*x + f), x], FreeQ[N[#1], _Complex] & ]Times @@ (Map[x^2 + {x, 1}.# &, sols])N[%](0.010974992601737203 + 0.20255610310498245*x + x^2)* (0.020476912388332696 + 0.20476912388332683*x + x^2)* (0.15256133957420942 + 0.23553164887424147*x + x^2)Andrzej KozlowskiYokohama, Japanhttp://www.mimuw.edu.pl/~akoz/http:// platon.c.u-tokyo.ac.jp/andrzej/> Factoring without specifying the extension does not really make sense. > Of course Mathematica can easily factor yur polynomial into linear > factors over the complex numbers (with the help of Solve), but I > suspect you are really asking for is factoring over the reals. This is > harder and needs more human input. But anyway, Mathematica can do > this, or at least I have done it using Mathematica. In fact if you are > satisfied with a numerical answer Mathematica can do alone and in > seconds:>> In[1]:=> Simplify[N[x^6 + (9/14)*x^5 + (9/28)*x^4 + (3/35)*x^3 + (9/700)*x^2 + > (9/8750)*x + 3/87500]]>> Out[1]=> 1.*(0.010974992601737198 + 0.20255610310498295*x + > x^2)*(0.020476912388332692 +> 0.2047691238833268*x + x^2)*(0.15256133957420948 + > 0.23553191586883315*x + x^2)>> But I have in fact been foolish enough to compute the exact answer > too. I do not propose to post it here for it's absolutely horrible > (expressed in terms of Root objects) and quite useless. However if you > really want to see it I can send it to you privately.>> Andrzej Kozlowski> Yokohama, Japan> http://www.mimuw.edu.pl/~akoz/> http://platon.c.u-tokyo.ac.jp/andrzej/>> To: mathgroup@smc.vnet.net>> Can Mathematica factor the polynomial>> p1=x^6+9/14*x^5+9/28*x^4+3/35*x^3+9/700*x^2+9/8750*x+3/87500; >> without a priori knowledge of the Extension field?>>Reply-To: ==== Those aren't equations; they're functions, and we don't solve functions,we solve equations. What equations do you want to solve?DrBob-----Original Message-----and -3108 - 11 n >= 0 and solve for n, n <= -282.545So we have -291.375 <= n <= -282.545.The integer solution set here is for n ={-290, -289, -288, -287, -286, -285, -284, -283}.So in this case we have 8 non-negative solutions.Given that I can supply x[n] and y[n], how do I go about finding the setn? ==== Is there a logically fundamental difference between functional and procedural programming? What I mean to ask is, can we do exactly the same thing with purely functional approaches as we can with purely procedural approaches? Is this basically the recursive verses iterative distinction?Why would one chose one approach over the other?STH. ==== > Let's be realistic. If you want 60 digits of precision, too bad! -- in> the real world. There's nothing we can measure that closely. Drug> concentrations in clinical trials are generally measured within 15%, for> instance. Even machine precision is more than can be realistically> expected in any application I can think of. Even getting a satellite to> Jupiter probably involves more error in the final result than machine> precision. (If not, it's because we rely on ongoing corrections and> natural factors that put the satellite where it should be, such as> gravity drawing it toward each rendezvous -- not on that kind of> precision in propulsion or guidance.)> So... unless all numerics in a problem have a theoretical origin, and> could be represented in Mathematica as Infinite precision expressions...> all this talk of higher-precision computation seems futile....Except in the very rare instance when one needs to do intermediate calculations with, e.g., 60 digits of precision in order to get only a few correct digits of the final answer.The length of this thread is surely proof of the need for a definitive reference on the topic. Has there been a Mathematica-centered numerical analysis book published since Skeel & Keiper?---Selwyn Hollis ==== > In[24]:=> f = SetAccuracy[333.75*b^6 + a^2*(11*a^2*b^2 - b^6 -> 121*b^4 - 2) + 5.5*b^8 + a/(2*b), 100];> a=SetPrecision[77617.,100]; b = SetPrecision[33096.,100];> >> In[26]:=> {f, Precision[f]}>> Out[26]=> {-0.82739605994682136814116509547981629199903311578438481991 > 781484167246798617832`61.2597, 61}> Congratulations! You just requested accuracy of> 100 for f and got 61 (> to convince yourself add Accuracy[f] to In[26]).There is no request in that example for an accuracy of 100 in theresult. The only request is for an accuracy of 100 in the input.> In[26]:= f = SetAccuracy[333.75*b^6 +> a^2*(11*a^2*b^2 - b^6 -> 121*b^4 - 2) + 5.5*b^8 + a/(2*b), 100]; > In[27]:= Accuracy[f]> Out[27]= 100.> Now we assign values to some indeterminants in f.> In[28]:= a = SetPrecision[77617.,100]; b = SetPrecision[33096.,100];> In[29]:= {f, Precision[f], Accuracy[f]}> Out[29]=> {- 0.827396059946821368141165095479816291999033115784384819917814 8,> 61.2599, 61.3422}> The precision and accuracy has dropped. This is all> according to> standard numerical analysis regarding cancellation> error. You'll find it in any textbook on the topic.> Assume that I want accuracy and precision of 100 for> f. You advice me to make experiments to find out, what> should be the initial precision and accuracy of a and> b to reach the requested accuracy and precision for f.> Notice, that you cannot just repeat I[26], we saw> already what happens. I have to re-type I[24], I[25],> I[26], I[27], I[28], and I[29] as many times as needed> to get f with accuracy and precision 100. > > Dan, you simply advocate to do MANUAL WORK that should> be done by machine.You do not have to do any of this manually. The machine (Mathematica)will do all of this, usually using built-in functions. The N function,for example, will automatically adjust the working precision to giveyou a precision that you request, provided that doing so doesn't involvemaking up arbitrary digits.The example above starts out with machine numbers (333.75, 5.5, etc.),uses SetPrecision and SetAccuracy to make up arbitrary digits to padthose numbers out to some specified number of digits, and then doessome simple arithmetic. If the goal is to get some specified numberof digits in the result, and it is ok to make up arbitrary digits likethis to achieve that goal, then the only manual work required to achivethat goal is to apply SetAccuracy or SetPrecision to the result, totell the computer that that is what you want.> Let's suppose that in the above example I just want 60> digits not 61. Precisely, I want 60 digits and nothing> or zeros afterwards. Let's see if I could use> SetAccuracy.> In[30]:= SetAccuracy[%, 60]> Out[30]= - 0.82739605994682136814116509547981629199903311578438481991781 > In[31]:= % // FullForm> Out[30]//FullForm=> - 0.827396059946821368141165095479816291999033115784384819917814 841672467988`> 59.9177> Oops, it did not work (as expected).If you could explain what you were expecting I am sure there are manycontributors to this group who could explain to you why it did not do that.> Let's highlight> with mouse the expression in Out[30] and copy to a new> cell. Oops, we got > - 0.827396059946821368141165095479816291999033115784384819917814 841672467988`> 59.9177 again. Let's change Out[30] to a text cell and then copy. > In[31]:= - 0.82739605994682136814116509547981629199903311578438481991781 > Out[31]= - 0.82739605994682136814116509547981629199903311578438481991781 > Success? Not so fast.If you could describe what you were trying to achieve with all of thatcopying and pasting and such I am again sure that there are manycontributors to this group who could describe how to do it. Itis very unlikely that the process will involve any copying and pastingor detours through text cells.> In[32]:=> % // FullForm> Out[32]//FullForm=> - 0.827396059946821368141165095479816291999033115784384819917809 999999999998635> 08`59.2041> Dan, is there any simple way to get what I want? Probably the answer is yes, but you will have to describe moreclearly what you want.> As I repeated already number of times, at this stage> of the development of computer technology, software> should do it for me (!).If what you want to do is get a certain number of digits inthe result, and it is ok to make up arbitrary digits as in theexamples above, then you can do that by simply applying SetPrecisionor SetAccuracy to the result. If you want the computer toautomatically adjust the working precision to give a certainprecision in the result, you can do that using N. If you wantsomething else, and you can describe what that is, then probablysomeone can describe how to get Mathematica to do that for you.Dave WithoffWolfram Research ==== Putting in Print[Some header text, TableForm[ Table[----------]]]puts the header text and the Table in the same cell, but with a largish gap (3 lines?) between the text and the Table's header lines.Hardly a serious problem, pretty trivial in fact, but a bit ugly and seems as if it really shouldn't work this way. Any way to get rid of this?siegman@stanford.eduReply-To: ==== The first problem is that ArcSin[x/10] isn't a left-inverse of 10 Sin[x]in the region of the root. That's why your code converges on anotherroot. A better inverse for your purpose is the gi below:f = #(# + 3) &;g = 10Sin@# &;gi = Pi - ArcSin[#/10] &;Using that inverse, there's still a problem, though. Yourapproximation of the root withr = gi@f@rfails because the derivative of gi@f at the root isgi'[f@rr]f'[rr]-2.02342That's greater than one in magnitude, so distance from the root ismagnified rather than diminished. Instead, tryr = fi@g@rWherefi[y_] := Evaluate[x /. Last@Solve[f@x == y, x]]This should work, sincefi'[g@rr]g'[rr]-0.4942135544 2685166Sure enough, it does work:Values = NestList[fi[g[#1]] & , 2., 12]{2., 1.8679332339369226, 1.9368280058437026, 1.9040490698559083,1.9205018812387413, 1.9124384783620436, 1.916439313493727, 1.9144659935649395,1.9154421880638148, 1.914959973607326, 1.915198347545482, 1.9150805538598723,1.9151387724997768}(f[#1] - g[#1] & ) /@ values{0.9070257317431825, -0.4688124734947827, 0.2242366717647286, -0.11228304957089463, 0.05509675095190758, -0.02732121417963107, 0.0134795615740817, -0.006667318794729482, 0.003293718665990042, -0.0016281317372435211, 0.0008045637255396088, -0.00039764607942949226, 0.0001965172491082967}Absolute error is cut in half at each iteration, as expected with aderivative for fi@g near -1/2. The negative sign causes the error toalternate in sign. We can also look at the log-absolute value of theerror as follows:(Log[Abs[f[#1] - g[#1]]] & ) /@ values{-0.09758445910053692, -0.7575524337892089, -1.4950532145264737,-2.18673236744676, -2.8986645309519163, -3.6000918023816326, -4.306580698204814,-5.010537479670821, -5.715738058891756, -6.420322094992857, -7.125210383308283,-7.829948195959684, -8.534760348785936}Rest[%] - Drop[%, -1]{-0.659967974688672, -0.7375007807372648, -0.6916791529202861,-0.7119321635051565, -0.7014272714297163, -0.7064888958231816, -0.7039567814660064,-0.7052005792209357, -0.7045840361011004, -0.7048882883154262, -0.704737812651401,-0.7048121528262516}The difference in logarithm of the absolute error approachesLog@Abs[fi'[g@rr]g'[rr] ]-0.7047875587967565If you want to use this for teaching, try to use as little code aspossible -- as I have above -- and always try to avoid Do loops inMathematica on principle.DrBob-----Original Message-----kenfBelow is the codeClear[f, g, gi, lim, r, rr, fr, gir, a, b, c, d, conv]; Plot[{x * ((x + 3)), 10*Sin[x]}, {x, 0.01, 2.4}, PlotStyle -> {{RGBColor[1, 0, 0], Thickness[ .006]}, {RGBColor[0, 0, 1], Thickness[ .006]}} ]; rr = FindRoot[x * ((x + 3)) == 10*Sin[x], {x, 2, 0.01, 2.4}]; f[a_] := a * ((a + 3)) /; a > 0; g[b_] := 10. * Sin[b] /; b > 0; gi[c_] := ArcSin[0.1*c] /; c > 0; Print[Actual root is , rr]; lim = 10; r = 2.0; conv = 10^-4; For[i = 1, i < lim, i++, { fr = f[r]; gir = gi[fr]; d = Abs[N[gir] - r]; i If[d < conv, Break[]]; r = gir; Print[The value of x = , r, found after , i, iterations,, with a tolerence , d, n] } ] Print[The value of x = , r, found after , i, iterations,, with a tolerence , d, n]Every man, woman and responsible child has an unalienable individual,civil, Constitutional and human right to obtain, own, and carry, openlyorconcealed, any weapon -- riße, shotgun, handgun, machine gun, anything--any time, any place, without asking anyone's permission. L. Neil Smith ==== f[t_] = {t + Sqrt[3] Sin[t], 2 Cos[t], t Sqrt[3] - Sin[t]}So It's basically a vector whose coordinates are determined based on thevalues you pass in.Then I took the derivative by just typing f', which outputs{1 + Sqrt[3] Cos[#1], -2 Sin[#1], Sqrt[3] - Cos[#1]}&What I'd like to do is have Mathematica calculate the norm of this as itwould any vector, so that I can play with the norm function. As it turnsout, the norm in this case is identical to Sqrt[8], so it would be nice ifMathematica could figure that out. Is it possible to do this? ==== [My previous reply seems to have gone astray - at least it has not come backto me.Here is a slightly edited repeat]You have computed f[t_] = {t + Sqrt[3] Sin[t], 2 Cos[t], t Sqrt[3] - Sin[t]};and then found f' {1 + Sqrt[3]*Cos[#1], -2*Sin[#1], Sqrt[3] - Cos[#1]} &To get the function for the norm of the derivative we can use norm = Evaluate/@(Simplify/@(Sqrt[#.#]&/@(f'))) 2*Sqrt[2] &We map the usual functions for calclulating and simplifying the norm insideFunction[.] (which is the full form of (.)& and then map the functionEvaluation to make the result evaluate -- this is needed since Function hasthe attribute HoldAll.Please note that the parentheses are essential.--Allan---------------------Allan HayesMathematica Training and ConsultingLeicester UKwww.haystack.demon.co.ukhay@haystack.demon.co.ukVoice : +44 (0)116 271 4198>> f[t_] = {t + Sqrt[3] Sin[t], 2 Cos[t], t Sqrt[3] - Sin[t]}>> So It's basically a vector whose coordinates are determined based on the> values you pass in.>> Then I took the derivative by just typing f', which outputs>> {1 + Sqrt[3] Cos[#1], -2 Sin[#1], Sqrt[3] - Cos[#1]}&> What I'd like to do is have Mathematica calculate the norm of this as it> would any vector, so that I can play with the norm function. As it turns> out, the norm in this case is identical to Sqrt[8], so it would be nice if> Mathematica could figure that out. Is it possible to do this?> ==== > f[t_] = {t + Sqrt[3] Sin[t], 2 Cos[t], t Sqrt[3] - Sin[t]}> So It's basically a vector whose coordinates are determined based on the> values you pass in.> Then I took the derivative by just typing f', which outputs> {1 + Sqrt[3] Cos[#1], -2 Sin[#1], Sqrt[3] - Cos[#1]}&> What I'd like to do is have Mathematica calculate the norm of this as it> would any vector, so that I can play with the norm function.I don't think whether the definition is prompt (=) or delayed (:=) is asimportant as supplied the argument [t] inIn := Simplify[Sqrt[f'[t] . f'[t]]]Out = 2 Sqrt[2]Or you can construct a new pure function withIn := Evaluate[Simplify[Sqrt[f'[#] . f'[#]]]]&Out = 2 Sqrt[2] &Of course, there is not much left to play with :)Tom Burton ==== >I want to apply a function to every k-th element of a long list and>add the result to the k+1 element.>>[Actually k = 3 and I just want to multiply myList[[k]] by a>constant (independent of k) and add the result to myList[[k+1]] for>every value of k that's divisible by 3.]If I understand what you are trying to do correctly, the following should work(f[#[[1]]+#[[2]])&/@Partition[Drop[list,k-1],2,k]Here f is the function you want applied to the k-th element ==== MathGroup/Mathematica Newsgroup users -in the past 24 hours or so and have not seen your post, please resend/repostit. Disk drive problems caused some of the posts in the queue to be lost.This has been fixed.Sorry for the delay.Steve ChristensenModerator ==== >Please allow me to summarize what I've learned in the recent discussion, and >retract my claim that Accuracy, Precision, and SetAccuracy are useless.>Numbers come in three varietiesThe technical term is ßavors.>- machine precision, Infinite precision,>and bignum or bigßoat. Bignums and bigßoats (synonymous?)Actually bignums can also refer to integers too large to represent asmachine integers. But I tend to use bignum when I really meanbigßoat, and I suspect this sloppy practice may be common.>aren't called that in the Help Browser, but they're the result of using>N[expr,k] or >SetAccuracy[expr,k] where k is bigger than machine precision.>If k <= machine precision, the result is a machine precision number, even>if you know the expression isn't that precise.>If, when you use N or SetAccuracy as described above, the expression>contains undefined symbols, you get an expression with all its numerics>replaced by bignums of the indicated precision. When the symbols are>defined later, if ANY of them are machine precision, the expression is>computed with machine arithmetic - with the side-effect that coefficients>that originally were Infinite-precision are now only machine precision.>That is, x^2 might have become x^2.0000000000000000000000000000000000>but later became x^2., for instance.I think this is correct in cases where all symbolic stuff gets replacedby numeric values. In general there is a sort of coercion to lowestprecision, with the caveat that machine ßoats pollute everything.>If all the symbols have been set to bignum or Infinite precision values,>the computation will be done taking precision into account, and the result>has a Precision or Accuracy that makes sense. In all other cases,>Precision returns Infinity for entirely Infinite-precision expressions>and 16 for everything else.I'm not sure I understand this last sentence. My interpretation:Computations that are exact will have infinite precision. Computationsin machine arithmetic will claim a precision of 16. If that is what youare claiming, then yes, that's what Mathematica is doing (but see mylast remarks).>When one of the experts says significance arithmetic that's what they>mean - using SetAccuracy or N to give things more than 16 digits, leaving>no machine precision numbers anywhere in the expression, and using Accuracy>or Precision, which ARE meaningful in that case, to judge the result.>(It's meaningful if all your inputs really have more than 16 digits of>precision, that is.)I'm as guilty as anyone else in this thread, perhaps more so, of beingtoo loose with the technical jargon. Also I am not certain what version4 makes of SetAccuracy/SetPrecision in terms of significance arithmetic.In the development kernel they will force everything in sight to havethe indicated precision, whether justified or not. This may wellintroduce error even with exact input, e.g. in cases where intermediatecomputations would require higher precision in order to get an endresult with the requested precision or accuracy. N[], on the other hand,will handle that and, except in pathological circumstances, will give aresult with the correct precision.As another minor point, arbitrary precision numbers are simply(tautologically?) numbers that may have arbitrarily large precision(subject to software limitations). Significance arithmetic refers to aparticular model of manipulating such numbers with a mechanism fortracking precision. There are other models, in particular fixedprecision arithmetic; that we use the former, by default, is anoccasional source of sturm und drang in this news group. I'm sure thedistinction between arbitrary precision numbers and significancearithmetic has at least minor relevance to this thread, and I imagineI've helped to confuse the issue in some places by using the termsalmost interchangeably.>You can't use significance arithmetic to determine how much precision a >result has if your inputs have 16 or 15 or 2 digits of precision.One can, if the numbers are really bignums (of low precision,naturally). What one cannot do at present is create such low precisionnumbers via N[].>In the example we've been looking at, you can give the inputs MORE accuracy>than you really believe they have, and still get back 0 digits from>Precision at the end, so there are clearly no trustworthy digits when>you use the original inputs either. If an expression is on the razor's>edge, and has lost only a few digits of precision, that wouldn't work>so well.>Oddly enough, significance arithmetic in the Browser doesn't take you>to any of that. Instead, it takes you to Interval arithmetic, a more>sophisticated method, which may give a more accurate gauge of how much>precision you really have, and WILL deal with machine precision numbers>and numbers with even less precision. It does a very good job on the>example. However, it isn't very suitable for Complex numbers, matrices,>etc. NSolve and NIntegrate probably can't handle it, either.I have filed a suggestion in-house that the documentation onsignificance arithmetic take one to the section on arbitrary precisionnumbers (3.1.5), as that would be more appropriate. Note that thatsection, while primarily concerned with the significance arithmeticmodel, also brießy mentions fixed precision bignum arithmetic.>Daniel Lichtblau promises that all this will be clearer in the next release.I'm not sure I'd go that far. What I will claim is that the distinctionbetween machine numbers and bignums will be more transparent to users.At present if one does, say, N[number,precision] then one will get amachine number if prec<=$MachinePrecision. We have made a change so thatthis will no longer be the case. I am not prepared to go into details atthis time (sorry).Perhaps more important for everyday use, and certainly more pertinentfor this thread, Precision[] will distinguish between bignums of 16digits precision and machine numbers. Again, I have to defer on details.At the very least I think the pitfall of believing a claim of 16 digitsprecision for machine numbers will be removed.Daniel LichtblauWolfram Research ==== Bobby,One point:>.... bigßoats ... [are] the result of using N[expr,k] or SetAccuracy[expr,k] where k is bigger than machine precision. If k <=> machine > precision, the result is a machine precision number.We get bigßoats with k<=machine precision with SetAccuracy and SetPrecision but not with N:Example a=SetPrecision[2.3,5] 2.3000 Precision[a] 5. Precision[a^2000] 1.69897Also, of course, when more than machine precision significant digits are given a=1.01234567891234500; Precision[a] 17.301Allan---------------------Allan HayesMathematica Training and ConsultingLeicester UKwww.haystack.demon.co.ukhay@haystack.demon.co.ukVoice : +44 (0)116 271 4198Reply-To: ==== Please allow me to summarize what I've learned in the recent discussion,and retract my claim that Accuracy, Precision, and SetAccuracy areuseless. Numbers come in three varieties - machine precision, Infinite precision,and bignum or bigßoat. Bignums and bigßoats (synonymous?) aren'tcalled that in the Help Browser, but they're the result of usingN[expr,k] or SetAccuracy[expr,k] where k is bigger than machineprecision. If k <= machine precision, the result is a machine precisionnumber, even if you know the expression isn't that precise. If, when you use N or SetAccuracy as described above, the expressioncontains undefined symbols, you get an expression with all its numericsreplaced by bignums of the indicated precision. When the symbols aredefined later, if ANY of them are machine precision, the expression iscomputed with machine arithmetic - with the side-effect thatcoefficients that originally were Infinite-precision are now onlymachine precision. That is, x^2 might have becomex^2.0000000000000000000000000000000000 but later became x^2., forinstance. If all the symbols have been set to bignum or Infinite precisionvalues, the computation will be done taking precision into account, andthe result has a Precision or Accuracy that makes sense. In all othercases, Precision returns Infinity for entirely Infinite-precisionexpressions and 16 for everything else. When one of the experts says significance arithmetic that's what theymean - using SetAccuracy or N to give things more than 16 digits,leaving no machine precision numbers anywhere in the expression, andusing Accuracy or Precision, which ARE meaningful in that case, to judgethe result. (It's meaningful if all your inputs really have more than16 digits of precision, that is.) You can't use significance arithmetic to determine how much precisiona result has if your inputs have 16 or 15 or 2 digits of precision. Inthe example we've been looking at, you can give the inputs MORE accuracythan you really believe they have, and still get back 0 digits fromPrecision at the end, so there are clearly no trustworthy digits whenyou use the original inputs either. If an expression is on the razor'sedge, and has lost only a few digits of precision, that wouldn't work sowell. Oddly enough, significance arithmetic in the Browser doesn't take youto any of that. Instead, it takes you to Interval arithmetic, a moresophisticated method, which may give a more accurate gauge of how muchprecision you really have, and WILL deal with machine precision numbersand numbers with even less precision. It does a very good job on theexample. However, it isn't very suitable for Complex numbers,matrices, etc. NSolve and NIntegrate probably can't handle it, either. Daniel Lichtblau promises that all this will be clearer in the nextrelease. DrBob ==== Deleting the browserindex.nb does not correct the online help e.g theonline mathematica book is not fully accessable etc.Why are some ofthe *.nb files corrupted in the first place?It seems to occur only onwin2k.>Try deleting ...> >Mathematica4.2DocumentationEnglishMainBook BrowserIndex.nb> ==== If you follow this link, you will see what I have found out about this:http://forums.wolfram.com/student-support/topics/5709 Brian> Deleting the browserindex.nb does not correct the online help e.g the> online mathematica book is not fully accessable etc.Why are some of> the *.nb files corrupted in the first place?It seems to occur only on> win2k.>Try deleting ...> >Mathematica4.2DocumentationEnglishMainBook BrowserIndex.nb> ==== > Is there a logically fundamental difference between functional and> procedural programming? What I mean to ask is, can we do exactly the > same> thing with purely functional approaches as we can with purely > procedural> approaches?> There is a fundamental difference, a strictly functional language does statement alone then it is obvious that there are some things that can be done in a procedural (nowadays people prefer to call them imperative) language that cannot be done in a functional language. On the other hand in imperative languages without pointers to procedures on cannot define a function which takes another function as an argument which functional languages allow. What you are probably really interested in is whether there exist a class of programs in the sense of a transformation on some input set into an output set which can be expressed in only one paradigm. Because nearly all major programming languages (SQL being the glaring exception) can implement a Turing Machine any algorithm which can be performed by a Turing Machine can be performed by any programming language, imperative or functional. So in principle functional and imperative languages are equivalently powerful although in practice it is easier to express some concepts in one paradigm or another.> Is this basically the recursive verses iterative distinction?> No.> Why would one chose one approach over the other?> In software engineering circles there is some evidence that the functional programming paradigm allows for efficient implementation of large programming projects, see http://www.math.chalmers.se/~rjmh/Papers/whyfp.html. Also it is possible to prove a strictly functional program correct because it cannot have side effects (no destructive updates of global states) which caused some excitement in academia but has not been a big selling point in industry. That said, by now you must realize that Mathematica is not a strictly functional language although you can use it as such. Actually Mathematica has a lot in common with LISP which is sometimes lumped together with the functional languages since it admits that programming style but both Mathematica and LISP are not pure (the desirability of purity being left to personal preference). One last advantage of functional programs though (which is related to the fact that they admit correctness proofs) is that it is relatively easy for a compiler/interpreter to optimize a functional program. This is why implicit iteration (Map in Mathematica) tends to outperform imperative style loops (Do, For, While etc.), which have to do a destructive update of the loop counter variable and therefore cannot reorganize a loop since statements in the loop may also destructively update the loop counter. C et al. get around this problem by being closely matched to the hardware. Ssezi ==== Hey folks,I have been working on a problem that seems to not lend itself to a solution. The following Mathematica code begins with the expression that I am trying to solve. For the curious, it's a degree 2 zonal and sectoral harmonics problem where I am trying to calculate and plot the geoid of earth as compared to an ellipse to see how well the geoid is approximated as an ellipse. In any case, we have the following relation ship,U =GM/r( 1 - (ae/r)^2 ( J2 (3/2 Sin[t]^2 - 1/2) - 3 Cos[t]^2 (C22 Cos[2 x] + S22 Sin[2 x]));Ur =1/2 we^2 (r Cos[t])^2;W[x_] =U + Ur;In trying to reorder W to become a function r wrt t, that is r[t_], I tried, among others,Solve[W[t], r]which returned({{r -> Root[ae^2 GM J2 + 6 ae^2 C22 GM Cos[ [t]] ^2 - 3 ae^2 GM J2 Sin[ [t]] ^2 + 2 GM #1 ^2 - 2 W0 #1 ^3 + we^2 Cos[ [t]] ^2 #1 ^5 &, 1]}, {r -> Root[ae^2 GM J2 + 6 ae^2 C22 GM Cos[ [t]] ^2 - 3 ae^2 GM J2 Sin[ [t]] ^2 + 2 GM #1 ^2 - 2 W0 #1 ^3 + we^2 Cos[ [t]] ^2 #1 ^5 &, 2]}, {r -> Root[ae^2 GM J2 + 6 ae^2 C22 GM Cos[ [t]] ^2 - 3 ae^2 GM J2 Sin[ [t]] ^2 + 2 GM #1 ^2 - 2 W0 #1 ^3 + we^2 Cos[ [t]] ^2 #1 ^5 &, 3]}, {r -> Root[ae^2 GM J2 + 6 ae^2 C22 GM Cos[ [t]] ^2 - 3 ae^2 GM J2 Sin[ [t]] ^2 + 2 GM #1 ^2 - 2 W0 #1 ^3 + we^2 Cos[ [t]] ^2 #1 ^5 &, 4]}, {r -> Root[ae^2 GM J2 + 6 ae^2 C22 GM Cos[ [t]] ^2 - 3 ae^2 GM J2 Sin[ [t]] ^2 + 2 GM #1 ^2 - 2 W0 #1 ^3 + we^2 Cos[ [t]] ^2 #1 ^5 &, 5]}} )which wasn't too much help, though it is a list of 5 Root functions. But in order to plot, I need a function r(t) so I can plot r wrt t...right?ParametricPlot[r[t], {t, 0, Pi}]So, I guess my questions are as follows:1. How do I get Solve[ ] to output numbers, as //N and NSolve did nothing to Solve[r[t], ...] to get any numbers instead of just r -> Root[...]?2. Is there a way to use ParametricPlot[ W[t], {t, 0.0, Pi}] instead of using r[t] and negating the whole issue of solving W[t] for r[t]?I have read that Solve only works for up to 4th order polynomials. I have been unable to find anything that works on my problem, having tried SolveAlways[ ] and other, and combination of others.Any help is welcome. I'll be glad to forward my Notebook if someone jdhouse4@mac.comPh.D. Graduate StudentAerospace EngineeringUniversity of Texas at Austin512-784-3205 ==== Try can use ImplicitPlot from the Graphics package.Janusz.> Hey folks,>> I have been working on a problem that seems to not lend itself to a> solution. The following Mathematica code begins with the expression> that I am trying to solve. For the curious, it's a degree 2 zonal and> sectoral harmonics problem where I am trying to calculate and plot the> geoid of earth as compared to an ellipse to see how well the geoid is> approximated as an ellipse. In any case, we have the following relation> ship,>> U =GM/r( 1 - (ae/r)^2 ( J2 (3/2 Sin[t]^2 - 1/2) - 3 Cos[t]^2 (C22> Cos[2 x] + S22 Sin[2 x]));> Ur =1/2 we^2 (r Cos[t])^2;> W[x_] =U + Ur;>> In trying to reorder W to become a function r wrt t, that is r[t_], I> tried, among others,>> Solve[W[t], r]>> which returned>> ({{r ->> Root[ae^2 GM J2 + 6 ae^2 C22 GM Cos[ [t]] ^2 -> 3 ae^2 GM J2 Sin[ [t]] ^2 + 2 GM #1 ^2 -> 2 W0 #1 ^3 + we^2 Cos[ [t]] ^2 #1 ^5 &,> 1]}, {r ->> Root[ae^2 GM J2 + 6 ae^2 C22 GM Cos[ [t]] ^2 -> 3 ae^2 GM J2 Sin[ [t]] ^2 + 2 GM #1 ^2 -> 2 W0 #1 ^3 + we^2 Cos[ [t]] ^2 #1 ^5 &,> 2]}, {r ->> Root[ae^2 GM J2 + 6 ae^2 C22 GM Cos[ [t]] ^2 -> 3 ae^2 GM J2 Sin[ [t]] ^2 + 2 GM #1 ^2 -> 2 W0 #1 ^3 + we^2 Cos[ [t]] ^2 #1 ^5 &,> 3]}, {r ->> Root[ae^2 GM J2 + 6 ae^2 C22 GM Cos[ [t]] ^2 -> 3 ae^2 GM J2 Sin[ [t]] ^2 + 2 GM #1 ^2 -> 2 W0 #1 ^3 + we^2 Cos[ [t]] ^2 #1 ^5 &,> 4]}, {r ->> Root[ae^2 GM J2 + 6 ae^2 C22 GM Cos[ [t]] ^2 -> 3 ae^2 GM J2 Sin[ [t]] ^2 + 2 GM #1 ^2 -> 2 W0 #1 ^3 + we^2 Cos[ [t]] ^2 #1 ^5 &, 5]}} )>> which wasn't too much help, though it is a list of 5 Root functions.> But in order to plot, I need a function r(t) so I can plot r wrt> t...right?>> ParametricPlot[r[t], {t, 0, Pi}]>> So, I guess my questions are as follows:> 1. How do I get Solve[ ] to output numbers, as //N and NSolve did> nothing to Solve[r[t], ...] to get any numbers instead of just r ->> Root[...]?>> 2. Is there a way to use ParametricPlot[ W[t], {t, 0.0, Pi}] instead of> using r[t] and negating the whole issue of solving W[t] for r[t]?>> I have read that Solve only works for up to 4th order polynomials. I> have been unable to find anything that works on my problem, having> tried SolveAlways[ ] and other, and combination of others.>> Any help is welcome. I'll be glad to forward my Notebook if someone>> jdhouse4@mac.com>> Ph.D. Graduate Student> Aerospace Engineering> University of Texas at Austin>> 512-784-3205 ==== Dear friends, I have build a table with this pattern:Flatten[{{{d, X, Y, Z}}, Table[{t, x[t], y[t], z[t]}, {t, 1, 10}], Table[{t, x[t], y[t], z[t]}, {t, 20, 100, 10}], Table[{t, x[t], y[t], z[t]}, {t, 200, 1000, 100}]}, 1] // TableFormI would like obtain the same Output in a more elegant way. In other word, how Can I avoid write Table[{t, x[t], y[t], z[t]} a few times.ThansGuillermoSanchez---------------------------- -----------------This message was sent using Endymion MailMan.Reply-To: kuska@informatik.uni-leipzig.de ==== Flatten[{{{d, X, Y, Z}}, Flatten[Table[{t, x[t], y[t], z[t]}, Evaluate[{t, Sequence @@ #}]] & /@ {{1, 10}, {20, 100, 10}, {200, 1000, 100}}, 1]}, 1] // TableForm??? Jens> Dear friends,> I have build a table with this pattern:> Flatten[{{{d, X, Y, Z}},> Table[{t, x[t], y[t], z[t]}, {t, 1, 10}],> Table[{t, x[t], y[t], z[t]}, {t, 20, 100, 10}],> Table[{t, x[t], y[t], z[t]}, {t, 200, 1000, 100}]}, 1] // TableForm> I would like obtain the same Output in a more elegant way. In other word, how> Can I avoid write Table[{t, x[t], y[t], z[t]} a few times.> Thans> Guillermo> Sanchez> ---------------------------------------------> This message was sent using Endymion MailMan. ==== > I would like obtain the same Output in a more elegant way. In other word, how > Can I avoid write Table[{t, x[t], y[t], z[t]} a few times. Table[{t=10^k; t, x[t], y[t], z[t]}, {k, 0, 3, 0.2}]or something similar. ==== Guillermo,Instead of Flatten[{{{d,X,Y,Z}},Table[{t,x[t],y[t],z[t]},{t ,1,10}], Table[{t,x[t],y[t],z[t]},{t,20,100,10}], Table[{t,x[t],y[t],z[t]},{t,200,1000,100}]},1];we can use Flatten[{{{{d,X,Y,Z}}}, Table[{t,x[t],y[t],z[t]},#]&/@{{t,1,10},{t,20,100,10},{t, 200,1000, 100}}},2];Test %===%% True--Allan---------------------Allan HayesMathematica Training and ConsultingLeicester UKwww.haystack.demon.co.ukhay@haystack.demon.co.ukVoice : +44 (0)116 271 4198> Dear friends,> I have build a table with this pattern:>> Flatten[{{{d, X, Y, Z}},> Table[{t, x[t], y[t], z[t]}, {t, 1, 10}],> Table[{t, x[t], y[t], z[t]}, {t, 20, 100, 10}],> Table[{t, x[t], y[t], z[t]}, {t, 200, 1000, 100}]}, 1] // TableForm>> I would like obtain the same Output in a more elegant way. In other word,how> Can I avoid write Table[{t, x[t], y[t], z[t]} a few times.>> Thans>> Guillermo> Sanchez>> ---------------------------------------------> This message was sent using Endymion MailMan.> ==== I have two seperate list questions that I was hoping to get help with.Question 1. I have a variable length list similar to that generated by FactorInteger,that is {number, exponent} pairs. An example follows.lista = {{2,3},{3,1},{5,1}} ... this is the number 2^3 * 3^1 * 5^1I want to generate a list of all the products of numbers from this list.I can tell that I get a total (3+1)*(1+1)*(1+1) = 4*2*2 = 16, products and Iwant a list showing all of those.These would be:2^3 can generate {2^0, 2^1, 2^2, 2^3} = {1, 2, 4 ,8}3^1 can generate {3^0, 3^1} = {3} ... we dont care about the duplicate 15^1 can generate {5^0, 5^1} = {5} ... we dont care about the duplicate 1Hence the 4*2*2 = 16 (the product of one more of the exponents) above.Next we should get 16 products (from these lists), namely (I left them asproducts below to show what I am after):{1, 2, 4, 8, 1*3, 2*3, 4*3, 8*3, 1*5, 2 * 5, 4* 5, 8* 5, 1*3*5,2*3*5, 4*3*5, 8*3*5}If the list were lista = {{2,4}, {3,2}, {5, 3},{7^5}}, we would have(4+1)(2+1)(3+1)(5+1) = 360 products, for example and the return valuesshould be a single list showing all of those.Question 2.I have two lists and want to generate two new lists from them. These twolists are {number, exponent} pairs.In the first list, I want the minimum intersection of {number, exponent}pairs.In the second list, I want the maximum union of {number, exponent} pairs.Let me show an example:Input:list1 = {{2, 3}, {3, 4}, {5, 6}, {7, 2}, {17, 5}}list2 = {{2, 5}, {3, 2}, {5, 1}, {7, 3}}Output:minint = {{2, 3}, {3, 2}, {5, 1}, {7, 2}}Note: In this example we only kept those pairs where the intersection of thenumber exists and also keep the min power of those.maxint = {{2, 5}, {3, 4}, {5, 6}, {7, 3}, {17, 5}}Note: In this example we kept the union of lists and also keep the max powerof each.Flip ==== When using Parametric Plot to make closed Lissajous curves, it's best not totake the parameter too far. for instance the codeParametricPlot[{Sin[t], Sin[2t]}, {t, 0, 10Pi}]looks much the same if you go to 20Pi or 30 Pi. But if you go too far, say,1000Pi, the curve will stray so much that it can appear, deceptively, to bean open Lissajous curve, filling the rectangle. I don't understand how it'sdoing this. I assume the reason has to do with machine precision, but cananyone tell me in a little detail what's happening here?thanks,--_______________ Steve Story Polymer Research Group 411B Cox North Carolina State University 1-919-515-8147 _______________ ==== I'm attempting to identify the essential aspects of Mathematica. I believe the place to start is with the Ôfunctional operations'. I'm seeking the Ôbasis' of Mathematica. Kind of the orthonormal subset of functionality which can be used to derive all the other. I'm also trying to be pragmatic. I'm not trying to reinvent Mathematica, I'm just trying to understand the invention that already exists.If anyone is interested in seeing what I've gathered so far, I have a notebook in both HTML, and Mathematica (4.2, if that matters) notebook format available here:http://public.globalsymmetry.com/proprietary/com/wri/ notebooks/with-gif/essential/essential.nbhttp:// public.globalsymmetry.com/proprietary/com/wri/notebooks/ with-gif/essential/index.htmlPlease let me know if you have any problems accessing these. The sysadmin is kind of new at running a DNS server. The server may go down for a while at Ideally that should take about an hour... and then there's reality...What I'm hoping for is some constructive feedback regarding my selection of functions. I am aware that I've neglected the more advanced use of these functions such as level specification. I'm trying to keep things as simple as possible. I'm not looking for the obfuscated Mathematica challenge. Not just yet. I'm seeking the examples which, if correctly understood, will make other Mathematica functionality fall into place. I believe there is also a set of Ôprocedural operators' which can properly be treated separately. I hope to get to them soon. I know I've received some very good feedback on other questions I've asked on the news group. I owe people responses to their thoughtful input. I hope to address these soon. I am very grateful to all who have responded to my questions.STH. ==== I would like to mark representative samples of t on a parametric plot,where t is the third parameter. For example, how could I mark the 8values t=0, t=Pi/4, ..., t=7Pi/4 on the plot generated by:ParametricPlot[{Sin[t], Cos[t]}, {t, 0, 2Pi}]Reply-To: kuska@informatik.uni-leipzig.de ==== ff[t_] := {Sin[t], Cos[t]}ParametricPlot[Evaluate[ff[t]], {t, 0, 2Pi}, Epilog -> {PointSize[0.025], (Point[ff[#]] & /@ Table[phi, {phi, 0, 2Pi,Pi/4}])}] Jens> I would like to mark representative samples of t on a parametric plot,> where t is the third parameter. For example, how could I mark the 8> values t=0, t=Pi/4, ..., t=7Pi/4 on the plot generated by:> ParametricPlot[{Sin[t], Cos[t]}, {t, 0, 2Pi}]> ==== How do I evaluate this product in mathematica:f[s_]=Product[a+b*Exp[s*x[i]],{i,1,n}] ?D[f[s],s] does not evaluate the terms. ==== I want to perform this calculation:In[1]:=z1 = a1 + b1 IOut[1]=a1 + [ImaginaryI] b1In[3]:=z2 = a2 + b2 IOut[3]=a2 + [ImaginaryI] b2In[19]:=Abs[(z1 - z2)/(1 - z1 Conjugate[z2])]This should output 1! But it doesn't work...Also, Abs[a1+b1 I] doesn't get the right result.Any ideeas?CeZaR ==== Of course one can use standard programming techniques to answer this and it will in fact be the most efficient method. But as you will probably get lots of answers of this kind, I will do it in another way: by exploiting a few standard built-in number theoretic functions which are very closely connected with your problems.Question 1:In[1]:=funct1[l_List]:=Outer[Times,Sequence@@(Divisors/@ Power@@@l)]//FlattenIn[2]:=funct1[{{2,3},{3,1},{5,1}}]Out [2]={1,5,3,15,2,10,6,30,4,20,12,60,8,40,24,120}Note what we did. We first converted your pairs {a,b} back into powers a^b then found all the divisors using the built in Divisors function, then found all the products using Outer.Question 2.In[3]:=minint[list1_,list2_]:=GCD[ Times@@Power@@@list1,Times@@Power@@@list2]//FactorIntegerIn [4]:=maxint[list1list1_,list2_]:=LCM[Times@@Power@@@list1, Times@@Power@@@list 2]//FactorIntegere.g.In[5]:=list1 = {{2, 3}, {3, 4}, {5, 6}, {7, 2}, {17, 5}};In[6]:=list2 = {{2, 5}, {3, 2}, {5, 1}, {7, 3}};In[7]:=minint[list1,list2]Out[7]={{2,3},{3,2},{5,1},{ 7,2}}In[8]:=maxint[list1,list2]Out[8]={{2,5},{3,4},{5,6},{ 7,3},{17,5}}Basically all we did was to use the built in functions GCD and LCM after converting your lists of powers to numbers. Then we factored them again.In this case to finally factor an integer, which guarantees the programs to be inefficient for large numbers. However if your original list of pairs were indeed the result of using FactorInteger, then you should of course use versions of the above programs that can be applied to the original un-factored integers. Indeed, in that case this is the only efficient way to proceed.Andrzej KozlowskiYokohama, Japanhttp://www.mimuw.edu.pl/~akoz/http:// platon.c.u-tokyo.ac.jp/andrzej/>> I have two seperate list questions that I was hoping to get help with.>> Question 1.>> I have a variable length list similar to that generated by > FactorInteger,> that is {number, exponent} pairs. An example follows.>> lista = {{2,3},{3,1},{5,1}} ... this is the number 2^3 * 3^1 * 5^1>> I want to generate a list of all the products of numbers from this > list.>> I can tell that I get a total (3+1)*(1+1)*(1+1) = 4*2*2 = 16, products > and I> want a list showing all of those.>> These would be:>> 2^3 can generate {2^0, 2^1, 2^2, 2^3} = {1, 2, 4 ,8}> 3^1 can generate {3^0, 3^1} = {3} ... we dont care about the > duplicate 1> 5^1 can generate {5^0, 5^1} = {5} ... we dont care about the duplicate > 1>> Hence the 4*2*2 = 16 (the product of one more of the exponents) above.>> Next we should get 16 products (from these lists), namely (I left them > as> products below to show what I am after):>> {1, 2, 4, 8, 1*3, 2*3, 4*3, 8*3, 1*5, 2 * 5, 4* 5, 8* 5, 1*3*5,> 2*3*5, 4*3*5, 8*3*5}>> If the list were lista = {{2,4}, {3,2}, {5, 3},{7^5}}, we would have> (4+1)(2+1)(3+1)(5+1) = 360 products, for example and the return values> should be a single list showing all of those.>> Question 2.>> I have two lists and want to generate two new lists from them. These > two> lists are {number, exponent} pairs.>> In the first list, I want the minimum intersection of {number, > exponent}> pairs.>> In the second list, I want the maximum union of {number, exponent} > pairs.>> Let me show an example:>> Input:>> list1 = {{2, 3}, {3, 4}, {5, 6}, {7, 2}, {17, 5}}>> list2 = {{2, 5}, {3, 2}, {5, 1}, {7, 3}}>> Output:>> minint = {{2, 3}, {3, 2}, {5, 1}, {7, 2}}>> Note: In this example we only kept those pairs where the intersection > of the> number exists and also keep the min power of those.>> maxint = {{2, 5}, {3, 4}, {5, 6}, {7, 3}, {17, 5}}>> Note: In this example we kept the union of lists and also keep the max > power> of each.> Flip> ==== To start with, what you are saying is simply not true. A simple example:In[1]:=Abs[(z1 - z2)/(1 - z1*Conjugate[z2])] /. {z1 -> 1 + I, z2 -> 1 - I}Out[1]=2/Sqrt[5]Presumably you meant Abs[(z1 - z2)/(z1 - Conjugate[z2]) in which case:In[1]:=ComplexExpand[Abs[(z1-z2)/(z1- Conjugate[z2])],TargetFunctions->{Im,Re}]Out[1]=1Andrzej KozlowskiYokohama, Japanhttp://www.mimuw.edu.pl/~akoz/http:// platon.c.u-tokyo.ac.jp/andrzej/>> I want to perform this calculation:>> In[1]:=z1 = a1 + b1 I> Out[1]=a1 + [ImaginaryI] b1> In[3]:=z2 = a2 + b2 I> Out[3]=a2 + [ImaginaryI] b2> In[19]:=Abs[(z1 - z2)/(1 - z1 Conjugate[z2])]>> This should output 1! But it doesn't work...>> Also, Abs[a1+b1 I] doesn't get the right result.> Any ideeas?>> CeZaR> ==== Charles,One method is to use Epilog as follows. For simplicity I define theparametrization of the curve, the list of t values and the list ofassociated points. It is also nice to add some color to the plot.Needs[Graphics`Colors`]curve[t_] := {Sin[t], Cos[t]}tvals = Pi/4Range[0, 7];pts = curve /@ tvals;ParametricPlot[Evaluate[curve[t]], {t, 0, 2Pi}, PlotStyle -> Blue, Epilog -> {Black, AbsolutePointSize[5], Point /@ pts, MapThread[Text[#1, 1.1 #2] &, {tvals, pts}]}, Axes -> None, AspectRatio -> Automatic, PlotRange -> All, Background -> Linen, ImageSize -> 430];If you use the DrawGraphics package at my web site, this can be doneslightly easier, without using PlotStyle or Epilog. ParametricDraw justextracts the graphics primitives, actually the Line, from ParametricPlotwithout a side plot. Then we can just combine it with the Point and Textprimitives. Draw2D is a shortcut for Show[Graphics[...],opts];Needs[DrawGraphics`DrawingMaster` ]Draw2D[ {Blue, ParametricDraw[Evaluate[curve[t]], {t, 0, 2Pi}], Black, AbsolutePointSize[5], Point /@ pts, MapThread[Text[#1, 1.1 #2] &, {tvals, pts}]}, AspectRatio -> Automatic, Background -> Linen, ImageSize -> 430];David Parkdjmp@earthlink.nethttp://home.earthlink.net/~djmp/ Sender: steve@smc.vnet.netApproved: Steven M. Christensen , Moderator ==== I think a better place to look for the essential aspects of Mathematica arein rule application, pattern matching, and mathematical knowledge. I willbe interested in hearing what other people have to say.Richard Palmer> I'm attempting to identify the essential aspects of Mathematica. I believe> the > place to start is with the Ôfunctional operations'. I'm seeking the> Ôbasis' of Mathematica. Kind of the orthonormal subset of functionality> which can be used to derive all the other. I'm also trying to be> pragmatic. I'm not trying to reinvent Mathematica, I'm just trying to> understand > the invention that already exists.> If anyone is interested in seeing what I've gathered so far, I have a> notebook in both HTML, and Mathematica (4.2, if that matters) notebook format> available here:> http://public.globalsymmetry.com/proprietary/com/wri/ notebooks/with-gif/essent> ial/essential.nb> http://public.globalsymmetry.com/proprietary/com/wri/ notebooks/with-gif/essent> ial/index.html> Please let me know if you have any problems accessing these. The sysadmin is> kind of new at running a DNS server. The server may go down for a while at> Ideally that should take about an hour... and then there's reality...> What I'm hoping for is some constructive feedback regarding my selection of> functions. I am aware that I've neglected the more advanced use of these> functions such as level specification. I'm trying to keep things as simple> as possible. I'm not looking for the obfuscated Mathematica challenge. Not> just > yet. I'm seeking the examples which, if correctly understood, will make> other Mathematica functionality fall into place. I believe there is also a> set of > Ôprocedural operators' which can properly be treated separately. I hope to> get to them soon.> I know I've received some very good feedback on other questions I've asked> on the news group. I owe people responses to their thoughtful input. I> hope to address these soon. I am very grateful to all who have responded> to my questions.> STH ==== >I have build a table with this pattern:>>Flatten[{{{d, X, Y, Z}},> Table[{t, x[t], y[t], z[t]}, {t, 1, 10}], > Table[{t, x[t], y[t], z[t]}, {t, 20, 100, 10}], > Table[{t, x[t], y[t], z[t]}, {t, 200, 1000, 100}]}, 1] // TableForm>>I would like obtain the same Output in a more elegant way. In other word,>how >Can I avoid write Table[{t, x[t], y[t], z[t]} a few times.>Fit[{1, 20, 200}, {1, n, n^2}, n]Flatten[ Prepend[ Table[{t, x[t], y[t], z[t]}, {n, 3}, {t, (161*n^2)/2 - (445*n)/2 + 143, 10^n, 10^(n - 1)}], {{d, X, Y, Z}}], 1]Bob Hanlon ==== >I would like to mark representative samples of t on a parametric plot,>where t is the third parameter. For example, how could I mark the 8>values t=0, t=Pi/4, ..., t=7Pi/4 on the plot generated by:>ParametricPlot[{Sin[t], Cos[t]}, {t, 0, 2Pi}]>ParametricPlot[{Sin[t], Cos[t]}, {t, 0, 2Pi}, AspectRatio -> Automatic, Epilog -> {AbsolutePointSize[5], RGBColor[1, 0, 0], Table[Point[{Sin[t], Cos[t]}], {t, 0, 7Pi/4, Pi/4}]}];Bob Hanlon ==== > I would like to mark representative samples of t on a parametric plot,> where t is the third parameter. For example, how could I mark the 8> values t=0, t=Pi/4, ..., t=7Pi/4 on the plot generated by:> ParametricPlot[{Sin[t], Cos[t]}, {t, 0, 2Pi}]One way is to use Epilog:ParametricPlot[{Sin[t], Cos[t]}, {t, 0, 2*Pi}, Epilog -> {PointSize[0.02], Table[With[{p = {Sin[t], Cos[t]}}, {Point[p],Text[t, p, -1.5*p]}], {t, Pi/4, 7*(Pi/4), Pi/4}]}, PlotRange -> All] ==== >I would like to mark representative samples of t on a parametric plot,>where t is the third parameter. For example, how could I mark the 8>values t=0, t=Pi/4, ..., t=7Pi/4 on the plot generated by:>ParametricPlot[{Sin[t], Cos[t]}, {t, 0, 2Pi}]There are a number of possibilities depending on exactly how you want things to appearYou could use Ticks->{Cos[# Pi/4]&/@Range[0,7],Sin[# Pi/4]&/@Range[0,7]}combined with Axes->True and seting AxesOrigin to an appropriate locationAnother option would be using Epilog->MapThread[Point[{#1,#2}]&,Cos[# Pi/4]&/@Range[0,7],Sin[# Pi/4]&/@Range[0,7]}] to plot points at the key locations. In order to get a satisfactory display you may also need to adjust either PointSize or PlotStyle.Other options include making plots of the marks and the parametric plot as separate graphics then combining them with the Show command ==== >I have two seperate list questions that I was hoping to get help with.>>Question 1.>> I have a variable length list similar to that generated by FactorInteger,>that is {number, exponent} pairs. An example follows.>>lista = {{2,3},{3,1},{5,1}} ... this is the number 2^3 * 3^1 * 5^1>>I want to generate a list of all the products of numbers from this list.>>I can tell that I get a total (3+1)*(1+1)*(1+1) = 4*2*2 = 16, products>and I>want a list showing all of those.>>These would be:>>2^3 can generate {2^0, 2^1, 2^2, 2^3} = {1, 2, 4 ,8}>3^1 can generate {3^0, 3^1} = {3} ... we dont care about the duplicate>1>5^1 can generate {5^0, 5^1} = {5} ... we dont care about the duplicate>1>>Hence the 4*2*2 = 16 (the product of one more of the exponents) above.>>Next we should get 16 products (from these lists), namely (I left them>as>products below to show what I am after):>>{1, 2, 4, 8, 1*3, 2*3, 4*3, 8*3, 1*5, 2 * 5, 4* 5, 8* 5, 1*3*5,>2*3*5, 4*3*5, 8*3*5}>>If the list were lista = {{2,4}, {3,2}, {5, 3},{7^5}}, we would have>(4+1)(2+1)(3+1)(5+1) = 360 products, for example and the return values>should be a single list showing all of those.>>Question 2.>>I have two lists and want to generate two new lists from them. These two>lists are {number, exponent} pairs.>>In the first list, I want the minimum intersection of {number, exponent}>pairs.>>In the second list, I want the maximum union of {number, exponent} pairs.>>Let me show an example:>>Input:>>list1 = {{2, 3}, {3, 4}, {5, 6}, {7, 2}, {17, 5}}>>list2 = {{2, 5}, {3, 2}, {5, 1}, {7, 3}}>>Output:>>minint = {{2, 3}, {3, 2}, {5, 1}, {7, 2}}>>Note: In this example we only kept those pairs where the intersection of>the>number exists and also keep the min power of those.>>maxint = {{2, 5}, {3, 4}, {5, 6}, {7, 3}, {17, 5}}>>Note: In this example we kept the union of lists and also keep the max>power>of each.>allProducts[x_] := Module[{sx = Sort[x, #2[[2]] < #1[[2]] &], f}, Union[Flatten[ Outer[f, Sequence @@ (PadRight[#, sx[[1, -1]] + 1, 1] & /@ (#[[1]]^ Range[0, #[[2]]] & /@ sx))]] /. f -> Times]];lista = {{2, 3}, {3, 1}, {5, 1}};allProducts[lista]{1, 2, 3, 4, 5, 6, 8, 10, 12, 15, 20, 24, 30, 40, 60, 120}minInt[x_, y_] := FactorInteger[GCD[ Times @@ (#[[1]]^#[[2]] & /@ x), Times @@ (#[[1]]^#[[2]] & /@ y)]];maxInt[x_, y_] := Union[x, y] //. {s___, {b_, e1_}, {b_, e2_}, r___} :> {s, {b, Max[e1, e2]}, r}list1 = {{2, 3}, {3, 4}, {5, 6}, {7, 2}, {17, 5}};list2 = {{2, 5}, {3, 2}, {5, 1}, {7, 3}};minInt[list1, list2]{{2, 3}, {3, 2}, {5, 1}, {7, 2}}maxInt[list1, list2]{{2, 5}, {3, 4}, {5, 6}, {7, 3}, {17, 5}}Bob Hanlon ==== >I want to perform this calculation:>>In[1]:=z1 = a1 + b1 I Out[1]=a1 + [ImaginaryI] b1 In[3]:=z2 = a2 + b2>I Out[3]=a2 + [ImaginaryI] b2 In[19]:=Abs[(z1 - z2)/(1 - z1>Conjugate[z2])]>>This should output 1! But it doesn't work...>>Also, Abs[a1+b1 I] doesn't get the right result. Any ideeas?What do you mean by doesn't work and doesn't get the right result? Do you mean Mathematica returns an unevaluated expression? If so, have you assigned values to the symbols a1, b1, a2 and b2? If you haven't assigned values, how is Mathematica to know these symbols do not take on complex values? ==== >I want to perform this calculation:>>In[1]:=z1 = a1 + b1 I Out[1]=a1 + [ImaginaryI] b1 In[3]:=z2 = a2 + b2>I Out[3]=a2 + [ImaginaryI] b2 In[19]:=Abs[(z1 - z2)/(1 - z1> >Conjugate[z2])]>>This should output 1! But it doesn't work...>>Also, Abs[a1+b1 I] doesn't get the right result. Any ideeas?> What do you mean by doesn't work and doesn't get the right result? Do you mean Mathematica returns an unevaluated expression? If so, have you assigned values to the symbols a1, b1, a2 and b2? If you haven't assigned values, how is Mathematica to know these symbols do not take on complex values?Yes, it returns an unevaluated expression.CeZaR ==== Steve,Increase the PlotPoints.ParametricPlot[{Sin[t], Sin[2t]}, {t, 0, 1000Pi}, PlotPoints -> 2000];But, generally one wouldn't want to make the t domain greater than requiredto plot the complete figure, in this case 0 to 2 Pi.David Parkdjmp@earthlink.nethttp://home.earthlink.net/~djmp/--_ ______________ Steve Story Polymer Research Group 411B Cox North Carolina State University 1-919-515-8147 _______________ ==== Guillermo,This might be considered slightly better..TableForm[{#, x[#], y[#], z[#]} & /@ Join[Range[10], Range[20, 100, 10], Range[200, 1000, 100]], TableHeadings -> {None, {d, X, Y, Z}}]David Parkdjmp@earthlink.nethttp://home.earthlink.net/~djmp/ ThansGuillermoSanchez----------------------------------- ----------This message was sent using Endymion MailMan. ==== Luca,It looks like Mathematica doesn't implement the Leibniz rule on indefiniteproducts. Here is my attempt to implement it. I hope I haven't slipped up.You may get some other better answers. I am not going to paste in all theoutput because you can duplicate it in your own notebook.First I define your f, separating the parameters from the variable s.f[a_, b_, n_][s_] := Product[a + b*Exp[s*x[i]], {i, 1, n}]You could differentiate with respect to s byf[a,b,n]'[s]but Mathematica doesn't evaluate. However, if you specify an integer for n,Mathematica will evaluate.f[a,b,3]'[s]LeibnizD::usage = LeibnizD[product, x] will differentiate an indefinite productexpression with respect to x using the Leibniz rule. The product must be of the form Product[factor, {iter, min, max}].;LeibnizD[p_Product, x_] := Module[{factor, term, piter, pmin, pmax}, {piter, pmin, pmax} = Rest[p]; factor = First[p]; term = (D[factor, x])/factor ; p Sum[term // Evaluate, {piter, pmin, pmax} // Evaluate]]Then the following gives the differentiation in terms of the originalproduct times a sum.LeibnizD[f[a, b, n][s], s]Checking one case..f[a, b, 3]'[s] == (LeibnizD[f[a, b, n][s], s] /. n -> 3) // SimplifyTrueAnd if it correct for one case it must be correct for all. Right?David Parkdjmp@earthlink.nethttp://home.earthlink.net/~djmp/ Sender: steve@smc.vnet.netApproved: Steven M. Christensen , Moderator ==== I noticed a rather curious trick that can be used to avoid having to use FactorInteger in the code I sent earlier for minint and maxint. Here is the new version:In[2]:=list1 = {{2, 3}, {3, 4}, {5, 6}, {7, 2}, {17, 5}};In[3]:=list2 = {{2, 5}, {3, 2}, {5, 1}, {7, 3}};In[4]:=minint[list1_List, list2_List] := ToExpression[PolynomialGCD[Times @@ Apply[ToString[#1]^#2 & , list1, {1}], Times @@ Apply[ToString[#1]^#2 & , list2, {1}]] /. {Times -> List, Power -> List}]In[5]:=maxint[list1_List, list2_List] := ToExpression[PolynomialLCM[Times @@ Apply[ToString[#1]^#2 & , list1, {1}], Times @@ Apply[ToString[#1]^#2 & , list2, {1}]] /. {Times -> List, Power -> List}]In[6]:=minint[list1, list2]Out[6]={{2, 3}, {3, 2}, 5, {7, 2}}In[7]:=maxint[list1, list2]Out[7]={{17, 5}, {2, 5}, {3, 4}, {5, 6}, {7, 3}}The idea is to do exactly the same thing as before but now we find the GCD and LCM of expressions like 2^3 *5^4 and 2^4*5^3 etc. Note that the base in a^b is a string and not a number so we need to use PolynomialGCD and PoynomialLCM instead of GCD and LCM. Using such algebraic functions will usually make the program slower, but on the other hand we need not use FactorInteger so when the numbers one gets are large enough the present version should be faster. In any case it seems a curious idea so I thought it worth posting (even though it is easy to write conventional programs to do the same thing that ought to be much more efficient).> Of course one can use standard programming techniques to answer this > and it will in fact be the most efficient method. But as you will > probably get lots of answers of this kind, I will do it in another > way: by exploiting a few standard built-in number theoretic functions > which are very closely connected with your problems.>> Question 1:>> In[1]:=> funct1[l_List]:=Outer[Times,Sequence@@(Divisors/@Power@@@l)]/ /Flatten>> In[2]:=> funct1[{{2,3},{3,1},{5,1}}]>> Out[2]=> {1,5,3,15,2,10,6,30,4,20,12,60,8,40,24,120}>> Note what we did. We first converted your pairs {a,b} back into > powers a^b then found all the divisors using the built in Divisors > function, then found all the products using Outer.>> Question 2.>> In[3]:=> minint[list1_,list2_]:=GCD[> Times@@Power@@@list1,Times@@Power@@@list2]//FactorInteger>> In[4]:=> maxint[list1list1_,list2_]:=LCM[Times@@Power@@@list1,Times@@ Power@@@lis > t2]> //FactorInteger>> e.g.>> In[5]:=> list1 = {{2, 3}, {3, 4}, {5, 6}, {7, 2}, {17, 5}};> In[6]:=> list2 = {{2, 5}, {3, 2}, {5, 1}, {7, 3}};> In[7]:=> minint[list1,list2]>> Out[7]=> {{2,3},{3,2},{5,1},{7,2}}>> In[8]:=> maxint[list1,list2]>> Out[8]=> {{2,5},{3,4},{5,6},{7,3},{17,5}}>> Basically all we did was to use the built in functions GCD and LCM > after converting your lists of powers to numbers. Then we factored > them again.>> In this case to finally factor an integer, which guarantees the > programs to be inefficient for large numbers. However if your original > list of pairs were indeed the result of using FactorInteger, then you > should of course use versions of the above programs that can be > applied to the original un-factored integers. Indeed, in that case > this is the only efficient way to proceed.>> Andrzej Kozlowski> Yokohama, Japan> http://www.mimuw.edu.pl/~akoz/> http://platon.c.u-tokyo.ac.jp/andrzej/> I have two seperate list questions that I was hoping to get help with.>> Question 1.>> I have a variable length list similar to that generated by >> FactorInteger,>> that is {number, exponent} pairs. An example follows.>> lista = {{2,3},{3,1},{5,1}} ... this is the number 2^3 * 3^1 * 5^1>> I want to generate a list of all the products of numbers from this >> list.>> I can tell that I get a total (3+1)*(1+1)*(1+1) = 4*2*2 = 16, >> products and I>> want a list showing all of those.>> These would be:>> 2^3 can generate {2^0, 2^1, 2^2, 2^3} = {1, 2, 4 ,8}>> 3^1 can generate {3^0, 3^1} = {3} ... we dont care about the >> duplicate 1>> 5^1 can generate {5^0, 5^1} = {5} ... we dont care about the >> duplicate 1>> Hence the 4*2*2 = 16 (the product of one more of the exponents) above.>> Next we should get 16 products (from these lists), namely (I left >> them as>> products below to show what I am after):>> {1, 2, 4, 8, 1*3, 2*3, 4*3, 8*3, 1*5, 2 * 5, 4* 5, 8* 5, 1*3*5,>> 2*3*5, 4*3*5, 8*3*5}>> If the list were lista = {{2,4}, {3,2}, {5, 3},{7^5}}, we would have>> (4+1)(2+1)(3+1)(5+1) = 360 products, for example and the return values>> should be a single list showing all of those.>> Question 2.>> I have two lists and want to generate two new lists from them. These >> two>> lists are {number, exponent} pairs.>> In the first list, I want the minimum intersection of {number, >> exponent}>> pairs.>> In the second list, I want the maximum union of {number, exponent} >> pairs.>> Let me show an example:>> Input:>> list1 = {{2, 3}, {3, 4}, {5, 6}, {7, 2}, {17, 5}}>> list2 = {{2, 5}, {3, 2}, {5, 1}, {7, 3}}>> Output:>> minint = {{2, 3}, {3, 2}, {5, 1}, {7, 2}}>> Note: In this example we only kept those pairs where the intersection >> of the>> number exists and also keep the min power of those.>> maxint = {{2, 5}, {3, 4}, {5, 6}, {7, 3}, {17, 5}}>> Note: In this example we kept the union of lists and also keep the >> max power>> of each.>> Flip> 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/ ==== If you use SetDelayed rather than Set, and then Simplify, Mathematica returns the answer you expect:f[t_] := {t + Sqrt[3] Sin[t], 2 Cos[t], t Sqrt[3] - Sin[t]} ;Simplify[Sqrt[f'[t] .f'[t]]]Out[2]= 2 Sqrt[2]>Sqrt[3] Sin[t], 2 Cos[t], t Sqrt[3] - Sin[t]} So It's basically a vector >whose coordinates are determined based on the values you pass in. Then I >took the derivative by just typing f', which outputs {1 + Sqrt[3] Cos[#1], >-2 Sin[#1], Sqrt[3] - Cos[#1]}& What I'd like to do is have Mathematica >calculate the norm of this as it would any vector, so that I can play with >the norm function. As it turns out, the norm in this case is identical to >Sqrt[8], so it would be nice if Mathematica could figure that out. Is it Christopher J. PurcellDefence R&D Canada .9a Atlantic9 Grove St., PO Box 1012Dartmouth NS Canada B2Y 3Z7 ==== >I wanted to do list manipulation methods explicitly on the lists without>using GCD and FactoInteger specifically. I am doing things with numbers>that I know the factorization for, but the methods in Mathematica (or anything>else for that matter) don't suffice.>>Is there an easy way to get rid of the GCD and FactorInteger in the second>method.>minInt[x_, y_] := Select[Union[x, y], MemberQ[First /@ Intersection[x, y, SameTest -> (#1[[1]] == #2[[1]] &)], #[[1]]] &] //. {s___, {b_, e1_}, {b_, e2_}, r___} :> {s, {b, Min[e1, e2]}, r};list1 = {{2, 3}, {3, 4}, {5, 6}, {7, 2}, {17, 5}};list2 = {{2, 5}, {3, 2}, {5, 1}, {7, 3}};minInt[list1, list2]{{2, 3}, {3, 2}, {5, 1}, {7, 2}}Bob Hanlon ==== I'm using mozilla I built a few hours ago. The classical mechanics site look very nice. I did, however receive the errors described here:http://baldur.globalsymmetry.com/proprietary/com/wri/ ch08.htmlTo properly display the MathML on this page you need the following fonts: CMSY10, CMEX10, Math1, Math2, Math4. For further infromation see: http://www.mozilla.org/projects/mathml/fontsAmong the fonts which I seem to be missin is the one used to display the imaginary coeficient in the MathML discussed below. You will find more discussion of my experiences with XML and Mathematica on the page I linked to above.I believe there is something which still needs to be done with my fonts, but I haven't had time to research it. If anyone knows the solution, I would really appreciate knowing. I can think of installed. The display is a bit better on the XP system, but for the most part, the results are similar. STH> Steven> I have done a great deal with MathML and esp with Mathematica 4.2> a) you need a modern browser NS 7.0 or Mozilla 1 or Amaya> b) IE needs a plugin www.dessci.com has mathplayer but there are other> issues> c) The rendering is done by the browser as is the XML parsing> d) an on line example is at>> http://core.ecu.edu/phys/ßurchickk/Classes/CM4226/ classicalMechanics2-1.xm>l e) you can test the browser with the w3c test site> http://www.w3.org/Math/testsuite/> -----Original Message-----> Sent: Saturday, October 12, 2002 5:05 AM> To: mathgroup@smc.vnet.net> I'm trying to get a handle on Mathematica's XML capabilities. I'm finding> a few> things to be a bit confusing. One of these is where the> http://www.wolfram.com/XML/DTD/2001/NBMLwMathML.dtd really is. Another> point of confusion is how exactly the rendering in the browser is expected> to take place. If needs be, I can spin up my own CSS. Does Mathematica> provide> CSS for MathML or NBML? I've character mentioned entity references before,> but I still haven't found an answer. What I've found here seems> inconsistent with what Mathematica chose for the character entity reference> for an> imaginary number: http://www.bitjungle.com/~isoent/>> This is what Mathematica produced for a complex number:>>

> > > cpx> => > > 1066> > + > > 42> > > > > ;> >

If I understand the http://www.bitjungle.com/~isoent/ent.xml, the imaginary> number symbol should be ࠿ which is a black letter capital ÔI'. That> doesn't seem correct to me. I'm currently stumbling around in here looking> for a possible clue as to what I should expect:> http://www.physiome.org.nz/Docs/web-tech/specs/mathML20/ chapter3.html>> Has anybody worked with this?>> STH ====