A115 === Subject: Re: The FinancialData Function I share your concerns, but hold more hope that Wolfram realise that charging ~$2500 for a license and $500 for Premier Service results in some obligations to their customers. That said, I was disappointed that their Tech Support didn't follow up on the concerns I expressed about 6mths ago - is their statement that FinancialData is 'experimental' a caveat intended to warn us all that it's not to be used for serious work? I hope not. We are all now pretty used to the fact that Mathematica is well written, and that QA/QC is exceptionally good (despite those who think they or others can do better). Given this, I am sure they have fully understood just how powerful the curated data facilities can be for the user. Renegging in the FD function would not be acceptable to me and I suspect many others. Now, you mention the data paclets could be at risk and that Yahoo could suddenly start charging WRI (if they are not already). The solution would be simple, however, since I know there are many financal data providers out there who could fill the gap - at a cost. I would like to hear from WRI about this since its a key issue. I've never heard of this function, but have one immediate strong reaction/question: Is there -- or will there soon be -- a fully open, officially standardized, fully and openly specified, widely and near universally accepted, stable, long-term, NON-proprietary set of **formats** for the data and information that is to be transmitted back and forth between data providers and data users in this system? [Something akin to the more or less open, universal and stable graphics standards that have emerged over time.] Lacking that, I wouldn't personally go near this kind of financial data distribution system and related tools like FinancialData for building anything that was of any real and continuing importance to me. Think of mapping data, GPS and topographic data, or satellite imagery and related software tools as an analogous system. I play with some of this data, plan journeys using MapQuest, hiking trips using Google Earth (an incredible tool), etc -- but if someone suddenly decided to change all the standards for this data, I could still use all my old stored data and tools -- or just do without. (There would of course be many important commercial enterprises that would be much more seriously impacted.) But then suppose people get important, continuing personal or business activities deeply involved in an information system that uses tools like FinancialData; the data providers and Wolfram somehow get cross-wise commercially; and the data providers threaten to change their formats just enough to screw Wolfram (and all FinancialData users). Or, suppose the data providers decide to throw digital rights management complexities all over their data, as is the case now with music, films, video -- and the deep pockets financial data providers manage to bribe Congress to require that all computer tools like FinancialData contain provisions to enforce these DRM complexities. This may all come across as paranoid fears, and maybe it is -- but look what has actually happened in other areas of widely distributed electronic information distribution . . . Robert Prince-Wright Houston TX, 77006 USA === Subject: Re: The FinancialData Function On Apr 1, 10:19 am, robert prince-wright > I share your concerns, but hold more hope that Wolfram realise that charging ~$2500 for a license and $500 for Premier Service results in some obligations to their customers. That said, I was disappointed that their Tech Support didn't follow up on the concerns I expressed about 6mths ago - is their statement that FinancialData is 'experimental' a caveat intended to warn us all that it's not to be used for serious work? I hope not. We are all now pretty used to the fact that Mathematica is well written, and that QA/QC is exceptionally good (despite those who think they or others can do better). Given this, I am sure they have fully understood just how powerful the curated data facilities can be for the user. Renegging in the FD function would not be acceptable to me and I suspect many others. Now, you mention the data paclets could be at risk and that Yahoo could suddenly start charging WRI (if they are not already). The solution would be simple, however, since I know there are many financal data providers out there who could fill the gap - at a cost. I would like to hear from WRI about this since its a key issue. > I've never heard of this function, but have one immediate strong > reaction/question: Is there -- or will there soon be -- a fully open, officially > standardized, fully and openly specified, widely and near universally > accepted, stable, long-term, NON-proprietary set of **formats** > for the data and information that is to be transmitted back > and forth between data providers and data users in this > system? [Something akin to the more or less open, universal and stable graphics > standards that have emerged over time.] Lacking that, I wouldn't personally go near this kind of financial data > distribution system and related tools like FinancialData for building > anything that was of any real and continuing importance to me. Think of mapping data, GPS and topographic data, or satellite imagery > and related software tools as an analogous system. I play with some of > this data, plan journeys using MapQuest, hiking trips using Google Earth > (an incredible tool), etc -- but if someone suddenly decided to change > all the standards for this data, I could still use all my old stored > data and tools -- or just do without. (There would of course be many > important commercial enterprises that would be much more seriously > impacted.) > Financial data come in many shapes and colors. Some data are public domain, but not real time (for ex. 20 min.- delayed stock prices), other data is not free, but real time (eg. real time stock prices). Some data is real time and still free (eg. forex prices). I am sure WRI complies with all the legal requirements when distributing financial data. Things may change in the future, like everything else. > But then suppose people get important, continuing personal or business > activities deeply involved in an information system that uses tools like > FinancialData; the data providers and Wolfram somehow get cross-wise > commercially; and the data providers threaten to change their formats > just enough to screw Wolfram (and all FinancialData users). Or, suppose the data providers decide to throw digital rights management > complexities all over their data, as is the case now with music, films, > video -- and the deep pockets financial data providers manage to bribe > Congress to require that all computer tools like FinancialData contain > provisions to enforce these DRM complexities. This may all come across as paranoid fears, and maybe it is -- but look > what has actually happened in other areas of widely distributed > electronic information distribution . . . Robert Prince-Wright > Houston > TX, 77006 > USA === Subject: Re: Legend with ListDensityPlot > Equivalent functionality to colorbar in Mathematica? I'm an author of a package to do this for DensityPlot, ContourPlot, and Plot3D: I'd be interested in any helped to extend it to work with List- plots as well. I haven't got around to it, 'coz I haven't need it yet. You could always use an interpolating function with the list data as input to a ContourPlot, I suppose. Will === Subject: Re: Number of monominals I was installed today upgrade to ver. 6.02 and all working correct now. My Mathematica first process run during 2 weeks and I was working on 2 process. ARTUR Alexey Popkov pisze: > >> According to the documentation, the function Length[expr] gives the >> number of elements in expr. >> Also The length of a symbol is 0. >> You have to write it as a list, if you want the expression to be counted. >> Length[{f[1]}] >> The other inputs are working, because Length counts the elements of the >> function Plus: >> In[1]:=Length[Plus[f[1],f[2],f[3]]] >> Out[1]:=3 >> OK! >> In[2]:=Length[Plus[f[1],f[2]]] >> Out[2]:=2 >> In[3]:=Length[f[1]] >> Out[3]:=0 >> I hope, that I could answer your question. >> Patrick >> I can not reproduce such behavour in Mathematica 5.2 and 6.02. How do > you do that? > In[1]:= Length[f[1]] > Out[1]= 1 > __________ NOD32 Informacje 2701 (20071204) __________ Wiadomosc zostala sprawdzona przez System Antywirusowy NOD32 > http://www.nod32.com lub http://www.nod32.pl === Subject: Something very simple..... 1. I have a list of sphere centers and radii like this: sphlst={{{ 5.11, 0.76, -0.32}, 100.39}, {{ 7.18, -1.86, -8.19}, 98.02}, {{26.71, -9.30, -6.85}, 111.27}, {{ 0, 0, 0}, 100.00}, {{ 8.65, 4.28, -3.81}, 103.87}}. If I do Map[Sphere,sphlst] I get too many braces, like this: {Sphere[{{ 5.11, 0.76, -0.32}, 100.39}], Sphere[{{ 7.18, -1.86, -8.19}, 98.02}], Sphere[{{26.71, -9.30, -6.85}, 111.27}], Sphere[{{ 0, 0, 0}, 100.00}], Sphere[{{ 8.65, 4.28, -3.81}, 103.87}]} and Sphere needs for example Sphere[{1.11, 2.22, 3.33},4.5]. What simple thing am I missing to remove the extra braces? (I know I can use Table but isn't there a one-step method?) Flatten doesn't seem to be useful here, or I'm using it wrong. 2. I have two lists, lsta={a,b,c,d,e,f} and lstb={1,3,4}. I want the elements of lsta that do NOT correspond to elements of lstb, in this case everything from lsta except elements 1,3, and 4: result={b,e,f}. (lstb won't have entries larger than Length[lsta]). Steve Gray === Subject: Re: Something very simple..... > 1. I have a list of sphere centers and radii like this: sphlst={{{ 5.11, 0.76, -0.32}, 100.39}, > {{ 7.18, -1.86, -8.19}, 98.02}, > {{26.71, -9.30, -6.85}, 111.27}, > {{ 0, 0, 0}, 100.00}, > {{ 8.65, 4.28, -3.81}, 103.87}}. If I do Map[Sphere,sphlst] I get too many braces, like this: {Sphere[{{ 5.11, 0.76, -0.32}, 100.39}], > Sphere[{{ 7.18, -1.86, -8.19}, 98.02}], > Sphere[{{26.71, -9.30, -6.85}, 111.27}], > Sphere[{{ 0, 0, 0}, 100.00}], > Sphere[{{ 8.65, 4.28, -3.81}, 103.87}]} Here is a more complicated pattern match approach, (Apply seems to be the easiest) sphlst /. {x : (List[{z__}, n_]) -> Sphere[{z}, n]} and Sphere needs for example Sphere[{1.11, 2.22, 3.33},4.5]. > What simple thing am I missing to remove the extra braces? > (I know I can use Table but isn't there a one-step method?) > Flatten doesn't seem to be useful here, or I'm using it wrong. 2. I have two lists, lsta={a,b,c,d,e,f} and lstb={1,3,4}. > I want the elements of lsta that do NOT correspond to elements > of lstb, in this case everything from lsta except elements > 1,3, and 4: result={b,e,f}. > (lstb won't have entries larger than Length[lsta]). > Using the range and complement could be one way In[113]:= Extract[lsta, #] & /@ (Complement[Range[Length[lsta]], lstb]) Out[113]= {b, e, f} Hope this is helpful Pratik Desai Wolfram Research Steve Gray > -- === Subject: Re: Something very simple..... > 1. I have a list of sphere centers and radii like this: sphlst={{{ 5.11, 0.76, -0.32}, 100.39}, > {{ 7.18, -1.86, -8.19}, 98.02}, > {{26.71, -9.30, -6.85}, 111.27}, > {{ 0, 0, 0}, 100.00}, > {{ 8.65, 4.28, -3.81}, 103.87}}. If I do Map[Sphere,sphlst] I get too many braces, like this: {Sphere[{{ 5.11, 0.76, -0.32}, 100.39}], > Sphere[{{ 7.18, -1.86, -8.19}, 98.02}], > Sphere[{{26.71, -9.30, -6.85}, 111.27}], > Sphere[{{ 0, 0, 0}, 100.00}], > Sphere[{{ 8.65, 4.28, -3.81}, 103.87}]} and Sphere needs for example Sphere[{1.11, 2.22, 3.33},4.5]. > What simple thing am I missing to remove the extra braces? > (I know I can use Table but isn't there a one-step method?) > Flatten doesn't seem to be useful here, or I'm using it wrong. 2. I have two lists, lsta={a,b,c,d,e,f} and lstb={1,3,4}. > I want the elements of lsta that do NOT correspond to elements > of lstb, in this case everything from lsta except elements > 1,3, and 4: result={b,e,f}. > (lstb won't have entries larger than Length[lsta]). > Steve Gray Here is a newbie approach for 1: > In[26]:= > (Sphere[Sequence[First[#1], > Last[#1]]] & ) /@ sphlst > Out[26]= > {Sphere[{5.11, 0.76, -0.32}, > 100.39], Sphere[ > {7.18, -1.86, -8.19}, > 98.02], Sphere[{26.71, > -9.3, -6.85}, 111.27], > Sphere[{0, 0, 0}, 100.], > Sphere[{8.65, 4.28, -3.81}, > 103.87]} Here is a more newbie approach for 2: > In[19]:= > Flatten[Extract[lsta, > Complement[ > (Position[lsta, > #1] & ) /@ lsta, > ({{#1}} & ) /@ lstb]]] > Out[19]= > {b, e, f} I hope it helps. J=E1nos ------ ..because Annushka has already bought sunflower oil, and not only bought it, but spilled it too. Bulgakov: Master and Margarita === Subject: Re: Something very simple..... 1. A pretty ugly solution (explicitly taking the arguments to Sphere and doing a pattern match), but you get the expected blastomere plot: In[6]:= g = Sphere /@ sphlst /. {Sphere[{{a__}, b_}] -> Sphere[{a}, b]} Out[6]= {Sphere[{5.11, 0.76, -0.32}, 100.39], Sphere[{7.18, -1.86, -8.19}, 98.02], Sphere[{26.71, -9.3, -6.85}, 111.27], Sphere[{0, 0, 0}, 100.], Sphere[{8.65, 4.28, -3.81}, 103.87]} In[7]:= Graphics3D[g] Out[7]= Graphics3D[{Sphere[{5.11, 0.76, -0.32}, 100.39], Sphere[{7.18, -1.86, -8.19}, 98.02], Sphere[{26.71, -9.3, -6.85}, 111.27], Sphere[{0, 0, 0}, 100.], Sphere[{8.65, 4.28, -3.81}, 103.87]}, ImageSize -> {360., 380.88094545077234}, ViewPoint -> {2.6859783732354505, -2.033988326753927, -0.31370633583051105}, ViewVertical -> {0.4842555587883932, -0.47728721617137, 0.7967257012534106}] your 1D example lists (for example it checks to make sure that removalList is shorter or of equal length to list). But it works for your case (others' code will almost certainly be much more efficient): deleteElements[list_ /; Length[Dimensions[list]] == 1, removalList_] := Delete[list, Partition[removalList,1]]/; (Length[removalList]<=Length[list] && Length[Dimensions[removalList]] == 1 && First@Union@(Positive@removalList) && First@Union@(IntegerQ /@ removalList)) In[14]:= deleteElements[{a, b, c, d, e, f}, {1, 3, 4}] Out[14]= {b, e, f} Good luck! > 1. I have a list of sphere centers and radii like this: sphlst={{{ 5.11, 0.76, -0.32}, 100.39}, > {{ 7.18, -1.86, -8.19}, 98.02}, > {{26.71, -9.30, -6.85}, 111.27}, > {{ 0, 0, 0}, 100.00}, > {{ 8.65, 4.28, -3.81}, 103.87}}. If I do Map[Sphere,sphlst] I get too many braces, like this: {Sphere[{{ 5.11, 0.76, -0.32}, 100.39}], > Sphere[{{ 7.18, -1.86, -8.19}, 98.02}], > Sphere[{{26.71, -9.30, -6.85}, 111.27}], > Sphere[{{ 0, 0, 0}, 100.00}], > Sphere[{{ 8.65, 4.28, -3.81}, 103.87}]} and Sphere needs for example Sphere[{1.11, 2.22, 3.33},4.5]. > What simple thing am I missing to remove the extra braces? > (I know I can use Table but isn't there a one-step method?) > Flatten doesn't seem to be useful here, or I'm using it wrong. 2. I have two lists, lsta={a,b,c,d,e,f} and lstb={1,3,4}. > I want the elements of lsta that do NOT correspond to elements > of lstb, in this case everything from lsta except elements > 1,3, and 4: result={b,e,f}. > (lstb won't have entries larger than Length[lsta]). > Steve Gray === Subject: Re: Something very simple..... There are some good answers that have been posted. Here is a more compact option: Delete[lsta, List/@lstb] Januk > 2. I have two lists, lsta={a,b,c,d,e,f} and lstb={1,3,4}. > I want the elements of lsta that do NOT correspond to elements > of lstb, in this case everything from lsta except elements > 1,3, and 4: result={b,e,f}. > (lstb won't have entries larger than Length[lsta]). > Steve Gray === Subject: Re: Something very simple..... I want the elements of lsta that do NOT correspond to elements > of lstb, in this case everything from lsta except elements > 1,3, and 4: result={b,e,f}. > (lstb won't have entries larger than Length[lsta]). The following will do it: Pick[lsta, If[MemberQ[lstb, #], False, True] & /@ Range@Length@lsta] Here is how it works: lsta = {a, b, c, d, e, f} ; lstb = {1, 3, 4}; (* We build a list of same length as lsta since Pick expects two list of same length. *) Range@Length@lsta {1, 2, 3, 4, 5, 6} (* We mark what elements must be taken. *) If[MemberQ[lstb, #], False, True] & /@ Range@Length@lsta {False, True, False, False, True, True} (* The final expression is *) Pick[lsta, If[MemberQ[lstb, #], False, True] & /@ Range@Length@lsta] {b, e, f} -- === Subject: Re: Something very simple..... Sphere @@@ sphlst ?? Jens > 1. I have a list of sphere centers and radii like this: > > sphlst={{{ 5.11, 0.76, -0.32}, 100.39}, > {{ 7.18, -1.86, -8.19}, 98.02}, > {{26.71, -9.30, -6.85}, 111.27}, > {{ 0, 0, 0}, 100.00}, > {{ 8.65, 4.28, -3.81}, 103.87}}. > > If I do Map[Sphere,sphlst] I get too many braces, like this: > > {Sphere[{{ 5.11, 0.76, -0.32}, 100.39}], > Sphere[{{ 7.18, -1.86, -8.19}, 98.02}], > Sphere[{{26.71, -9.30, -6.85}, 111.27}], > Sphere[{{ 0, 0, 0}, 100.00}], > Sphere[{{ 8.65, 4.28, -3.81}, 103.87}]} > > and Sphere needs for example Sphere[{1.11, 2.22, 3.33},4.5]. > What simple thing am I missing to remove the extra braces? > (I know I can use Table but isn't there a one-step method?) > Flatten doesn't seem to be useful here, or I'm using it wrong. > > 2. I have two lists, lsta={a,b,c,d,e,f} and lstb={1,3,4}. > I want the elements of lsta that do NOT correspond to elements > of lstb, in this case everything from lsta except elements > 1,3, and 4: result={b,e,f}. > (lstb won't have entries larger than Length[lsta]). > > > Steve Gray > === Subject: Re: Something very simple..... > 1. I have a list of sphere centers and radii like this: > > sphlst={{{ 5.11, 0.76, -0.32}, 100.39}, > {{ 7.18, -1.86, -8.19}, 98.02}, > {{26.71, -9.30, -6.85}, 111.27}, > {{ 0, 0, 0}, 100.00}, > {{ 8.65, 4.28, -3.81}, 103.87}}. > > If I do Map[Sphere,sphlst] I get too many braces, like this: > > {Sphere[{{ 5.11, 0.76, -0.32}, 100.39}], > Sphere[{{ 7.18, -1.86, -8.19}, 98.02}], > Sphere[{{26.71, -9.30, -6.85}, 111.27}], > Sphere[{{ 0, 0, 0}, 100.00}], > Sphere[{{ 8.65, 4.28, -3.81}, 103.87}]} > > and Sphere needs for example Sphere[{1.11, 2.22, 3.33},4.5]. > What simple thing am I missing to remove the extra braces? > (I know I can use Table but isn't there a one-step method?) > Flatten doesn't seem to be useful here, or I'm using it wrong. The following will do it: Map[Sphere[Sequence @@ #] &, sphlst] For instance, In[1]:= sphlst = {{{5.11, 0.76, -0.32}, 100.39}, {{7.18, -1.86, -8.19}, 98.02}, {{26.71, -9.30, -6.85}, 111.27}, {{0, 0, 0}, 100.00}, {{8.65, 4.28, -3.81}, 103.87}}; Map[Sphere[Sequence @@ #] &, sphlst] Graphics3D@% Out[2]= {Sphere[{5.11, 0.76, -0.32}, 100.39], Sphere[{7.18, -1.86, -8.19}, 98.02], Sphere[{26.71, -9.3, -6.85}, 111.27], Sphere[{0, 0, 0}, 100.], Sphere[{8.65, 4.28, -3.81}, 103.87]} [... graphic deleted ...] -- === Subject: Re: Something very simple..... Just use Apply with level specification {1}: Apply[Sphere, sphlst, {1}] {Sphere[{5.11, 0.76, -0.32}, 100.39], Sphere[{7.18, -1.86, -8.19}, 98.02], Sphere[{26.71, -9.3, -6.85}, 111.27], Sphere[{0, 0, 0}, 100.], Sphere[{8.65, 4.28, -3.81}, 103.87]} Andrzej Kozlowski > 1. I have a list of sphere centers and radii like this: sphlst={{{ 5.11, 0.76, -0.32}, 100.39}, > {{ 7.18, -1.86, -8.19}, 98.02}, > {{26.71, -9.30, -6.85}, 111.27}, > {{ 0, 0, 0}, 100.00}, > {{ 8.65, 4.28, -3.81}, 103.87}}. If I do Map[Sphere,sphlst] I get too many braces, like this: {Sphere[{{ 5.11, 0.76, -0.32}, 100.39}], > Sphere[{{ 7.18, -1.86, -8.19}, 98.02}], > Sphere[{{26.71, -9.30, -6.85}, 111.27}], > Sphere[{{ 0, 0, 0}, 100.00}], > Sphere[{{ 8.65, 4.28, -3.81}, 103.87}]} and Sphere needs for example Sphere[{1.11, 2.22, 3.33},4.5]. > What simple thing am I missing to remove the extra braces? > (I know I can use Table but isn't there a one-step method?) > Flatten doesn't seem to be useful here, or I'm using it wrong. 2. I have two lists, lsta={a,b,c,d,e,f} and lstb={1,3,4}. > I want the elements of lsta that do NOT correspond to elements > of lstb, in this case everything from lsta except elements > 1,3, and 4: result={b,e,f}. > (lstb won't have entries larger than Length[lsta]). > Steve Gray > === Subject: Re: Something very simple..... Hi Steve, > 1. I have a list of sphere centers and radii like this: sphlst={{{ 5.11, 0.76, -0.32}, 100.39}, > {{ 7.18, -1.86, -8.19}, 98.02}, > {{26.71, -9.30, -6.85}, 111.27}, > {{ 0, 0, 0}, 100.00}, > {{ 8.65, 4.28, -3.81}, 103.87}}. If I do Map[Sphere,sphlst] I get too many braces, like this: {Sphere[{{ 5.11, 0.76, -0.32}, 100.39}], > Sphere[{{ 7.18, -1.86, -8.19}, 98.02}], > Sphere[{{26.71, -9.30, -6.85}, 111.27}], > Sphere[{{ 0, 0, 0}, 100.00}], > Sphere[{{ 8.65, 4.28, -3.81}, 103.87}]} and Sphere needs for example Sphere[{1.11, 2.22, 3.33},4.5]. > What simple thing am I missing to remove the extra braces? > (I know I can use Table but isn't there a one-step method?) > Flatten doesn't seem to be useful here, or I'm using it wrong. > Sphere @@@ sphlst > 2. I have two lists, lsta={a,b,c,d,e,f} and lstb={1,3,4}. > I want the elements of lsta that do NOT correspond to elements > of lstb, in this case everything from lsta except elements > 1,3, and 4: result={b,e,f}. > (lstb won't have entries larger than Length[lsta]). lsta[[ Complement[Range[Length[lsta]], lstb] ]] hope this helps, Oliver Steve Gray Oliver Ruebenkoenig, === Subject: Re: Something very simple..... Hi Steve, > 1. I have a list of sphere centers and radii like this: > > sphlst={{{ 5.11, 0.76, -0.32}, 100.39}, > {{ 7.18, -1.86, -8.19}, 98.02}, > {{26.71, -9.30, -6.85}, 111.27}, > {{ 0, 0, 0}, 100.00}, > {{ 8.65, 4.28, -3.81}, 103.87}}. > > If I do Map[Sphere,sphlst] I get too many braces, like this: > > {Sphere[{{ 5.11, 0.76, -0.32}, 100.39}], Sphere[{{ 7.18, > -1.86, -8.19}, 98.02}], Sphere[{{26.71, -9.30, -6.85}, 111.27}], > Sphere[{{ 0, 0, 0}, 100.00}], > Sphere[{{ 8.65, 4.28, -3.81}, 103.87}]} > > and Sphere needs for example Sphere[{1.11, 2.22, 3.33},4.5]. > What simple thing am I missing to remove the extra braces? > (I know I can use Table but isn't there a one-step method?) > Flatten doesn't seem to be useful here, or I'm using it wrong. Apply[Sphere, sphlst, 1] does the trick. > 2. I have two lists, lsta={a,b,c,d,e,f} and lstb={1,3,4}. > I want the elements of lsta that do NOT correspond to > elements of lstb, in this case everything from lsta except > elements 1,3, and 4: result={b,e,f}. > (lstb won't have entries larger than Length[lsta]). For this, I'd use lstc = lsta[[#]] & /@ lstb lstd = Complement[lsta, lstc] but there are undoubtedly other ways. Dave. No virus found in this outgoing message. Checked by AVG. 05:38 === Subject: Re: Something very simple..... Hi Steve, 1) you must use Map together with Apply: Map[Sphere@@#&,sphlst] 2) here we the complement of the indices and then use Part: lsta[[ Complement[Range[Length[lsta]],lstb]] ] hope this helps, Daniel > 1. I have a list of sphere centers and radii like this: > > sphlst={{{ 5.11, 0.76, -0.32}, 100.39}, > {{ 7.18, -1.86, -8.19}, 98.02}, > {{26.71, -9.30, -6.85}, 111.27}, > {{ 0, 0, 0}, 100.00}, > {{ 8.65, 4.28, -3.81}, 103.87}}. > > If I do Map[Sphere,sphlst] I get too many braces, like this: > > {Sphere[{{ 5.11, 0.76, -0.32}, 100.39}], > Sphere[{{ 7.18, -1.86, -8.19}, 98.02}], > Sphere[{{26.71, -9.30, -6.85}, 111.27}], > Sphere[{{ 0, 0, 0}, 100.00}], > Sphere[{{ 8.65, 4.28, -3.81}, 103.87}]} > > and Sphere needs for example Sphere[{1.11, 2.22, 3.33},4.5]. > What simple thing am I missing to remove the extra braces? > (I know I can use Table but isn't there a one-step method?) > Flatten doesn't seem to be useful here, or I'm using it wrong. > > 2. I have two lists, lsta={a,b,c,d,e,f} and lstb={1,3,4}. > I want the elements of lsta that do NOT correspond to elements > of lstb, in this case everything from lsta except elements > 1,3, and 4: result={b,e,f}. > (lstb won't have entries larger than Length[lsta]). > > > Steve Gray > === Subject: Re: conversion of sin to cos you may simply replace all Sin[x] -> Cos[x-Pi/2] hope this helps, Daniel > Hello all, > > Here is my problem. I have a very long product of cosines with > arguments of the form k*Pi, k being integers. > I want to convert this expression to a sum of cosines. TrigReduce > works fine, except that it converts cos to sin. > So, I want all the sin (after the TrigReduce) to be converted to cos > and the arguments be of the form p*Pi, p being rational of course. > It has something to do with Hold or HoldAll, but I don't know the > details. Or perhaps the TrigReduce can be overridden > somehow. > Can someone help? > === Subject: Combinatorica`ShowGraph HeadCenter option In whatever version of Mathematica was current 5 years ago, the following code displayed a directed graph with the arrows located half-way along each edge: < True]; ShowGraph[g, HeadCenter -> 0.5] In Mathematica 6.0.2 (with Combinatorica` instead of DiscreteMath`Combinatorica`, of course), the option HeadCenter seems to be unrecognized, and the arrows remain at their target ends -- in other words, they appear where they are hardest to see! Has this change been documented? There is nothing whatsoever about this in Compatibility/tutorial/DiscreteMath/Combinatorica. Except that this compatibility guide states, All of the functionality in DiscreteMath`Combinatorica` is available in the newly created Combinatorica Package. Plainly that is not the case in so far as HeadCenter is concerned. How can one still locate the arrows on the displayed directed graph -- using ShowGraph (which has been generally much simpler to use, especially for students, in contrast with the newer GraphPlot. -- 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 fax 413 545-1801 Amherst, MA 01003-9305 === Subject: Re: Combinatorica`ShowGraph HeadCenter option Hi Murray, here is a work around: g=ShowGraph[Cycle[3,Type->Directed]]; g=g/. x:Arrow[__]->{Arrowheads[{{Automatic,0.5}}],x} hope this helps, Daniel > In whatever version of Mathematica was current 5 years ago, the > following code displayed a directed graph with the arrows located > half-way along each edge: > > < g = SetGraphOptions[Cykcle[3], EdgeDirection -> True]; > ShowGraph[g, HeadCenter -> 0.5] > > In Mathematica 6.0.2 (with Combinatorica` instead of > DiscreteMath`Combinatorica`, of course), the option HeadCenter seems to > be unrecognized, and the arrows remain at their target ends -- in other > words, they appear where they are hardest to see! > > Has this change been documented? There is nothing whatsoever about this > in Compatibility/tutorial/DiscreteMath/Combinatorica. Except that this > compatibility guide states, All of the functionality in > DiscreteMath`Combinatorica` is available in the newly created > Combinatorica Package. Plainly that is not the case in so far as > HeadCenter is concerned. > > How can one still locate the arrows on the displayed directed graph -- > using ShowGraph (which has been generally much simpler to use, > especially for students, in contrast with the newer GraphPlot. > === Subject: Symbolic Quantum Operators for Dirac Notation in Mathematica About Quantum for Mathematica ( http://homepage.cem.itesm.mx/lgomez/quantum/index.htm ) Now you can define Symbolic Quantum Operators for Dirac Notation in Mathematica, please see this link: http://homepage.cem.itesm.mx/lgomez/quantum/defope/defope.html Before this improvement operators could be defined only through the explicit Dirac representation of their =93matrix elements=94 ket-on-bra. Now operators can be defined trough their operation on a ket. For example, rising (creation) and lowering (annihilation) operators of the harmonic oscillator are easily defined and used at the end of the document in this link http://homepage.cem.itesm.mx/lgomez/quantum/defope/defope.html Now the Quantum Random Walk is solved in the documentation by three different methods, which have different advantages and disadvantages. The last of these three methods uses the new feature of definition of symbolic quantum operators: FIRST: Q. Random Walker: Dirac Notation Approach: beautiful but slow: http://homepage.cem.itesm.mx/lgomez/quantum/qrwnaive/qrwnaive.html SECOND: Q. Random Waker: Mathematica Syntax Approach: Fastest but too specialized: http://homepage.cem.itesm.mx/lgomez/quantum/qrwefficient/qrwefficient.html THIRD: Q. Random Walker: Defining-operators approach: beautiful enough and fast enough, a good compromise: http://homepage.cem.itesm.mx/lgomez/quantum/qrwbest/qrwbest.html A colleague, Rub=E9n Dario, is already implementing new exciting Quantum Mechanics calculations (molecular collisions) using these new features. To have the new features, you must download the new Quantum.zip http://homepage.cem.itesm.mx/lgomez/quantum/Quantum.zip and install this new version according to the instructions in http://homepage.cem.itesm.mx/lgomez/quantum/installation/installation.html Enjoy it! Jose Luis Gomez-Munoz http://homepage.cem.itesm.mx/lgomez/ === Subject: Graphics3D, missing part I am trying to use Mathematica 5.1 to make a fractal tree. I get no problem for Show[G1,G2,G3], but when I do Show[G, G1, G2, G3], the problem part of the graph is missing. Have I done something wrong? Any help is much appreciated. wshun coneF = Function[{x, y, z, r, h, t}, {{x + 0.6h*Cos[t], y + 0.6h*Sin[t], z + 0.6h, 0.4r, 0.4h, t}, {x + 0.6h*Cos[t], y + 0.6h*Sin[t], z + 0.6h, 0.4r, 0.6h, Mod[t + 2Pi/3, 2Pi]}, {x + 0.6h*Cos[t], y + 0.6h*Sin[t], z + 0.6h, 0.4r, 0.6h, Mod[t + 4Pi/3, 2Pi]}}] coneG = Function[A, Flatten[Table[coneF[ Extract[A, {k, 1}], Extract[A, {k, 2}], Extract[A, {k, 3}], Extract[A, {k, 4}], Extract[A, {k, 5}], Extract[A, {k, 6}]], {k, Length[A]}], 1]] DrawCone = Function[A, Table[ParametricPlot3D[{Extract[A, {k, 1}], Extract[A, {k, 2}], Extract[A, {k, 3}]} + Extract[A, {k, 4}]*(1 - h/ Extract[A, {k, 5}])*{Cos[t], Sin[t], 0} + h*{Cos[Extract[A, {k, 6}]], Sin[Extract[A, {k, 6}]], 1}, {h, 0, Extract[A, {k, 5}]}, {t, 0, 2Pi}], {k, Length[A]}]] A = {{0, 0, 0, 1, 6, 0}}; A1 = coneG[A]; A2 = coneG[A1]; A3 = coneG[A2]; G = DrawCone[A]; G1 = DrawCone[A1]; G2 = DrawCone[A2]; G3 = DrawCone[A3] Show[G, G1, G2, G3] === Subject: Re: Graphics3D, missing part > I am trying to use Mathematica 5.1 to make a fractal tree. I get no > problem for Show[G1,G2,G3], but when I do Show[G, G1, G2, G3], the > problem part of the graph is missing. Have I done something wrong? Note sure what you get with 5.1, but on my system (6.0.2 Mac OS X Intel) both commands display only a partial graph. Setting the option PlotRange to All allows Mathematica to draw both plots completely. Show[G1, G2, G3, PlotRange -> All] Show[G, G1, G2, G3, PlotRange -> All] You can see the differences at http://homepages.nyu.edu/~jmg336/mathematica/graphics3dmissingpart.jpg HTH, -- $Version 6.0 for Mac OS X x86 (64-bit) (February 7, 2008) coneF = Function[{x, y, z, r, h, t}, {{x + 0.6 h*Cos[t], y + 0.6 h*Sin[t], z + 0.6 h, 0.4 r, 0.4 h, t}, {x + 0.6 h*Cos[t], y + 0.6 h*Sin[t], z + 0.6 h, 0.4 r, 0.6 h, Mod[t + 2 Pi/3, 2 Pi]}, {x + 0.6 h*Cos[t], y + 0.6 h*Sin[t], z + 0.6 h, 0.4 r, 0.6 h, Mod[t + 4 Pi/3, 2 Pi]}}] coneG = Function[A, Flatten[Table[ coneF[Extract[A, {k, 1}], Extract[A, {k, 2}], Extract[A, {k, 3}], Extract[A, {k, 4}], Extract[A, {k, 5}], Extract[A, {k, 6}]], {k, Length[A]}], 1]] DrawCone = Function[A, Table[ParametricPlot3D[{Extract[A, {k, 1}], Extract[A, {k, 2}], Extract[A, {k, 3}]} + Extract[A, {k, 4}]*(1 - h/Extract[A, {k, 5}])*{Cos[t], Sin[t], 0} + h*{Cos[Extract[A, {k, 6}]], Sin[Extract[A, {k, 6}]], 1}, {h, 0, Extract[A, {k, 5}]}, {t, 0, 2 Pi}], {k, Length[A]}]] A = {{0, 0, 0, 1, 6, 0}}; A1 = coneG[A]; A2 = coneG[A1]; A3 = coneG[A2]; G = DrawCone[A]; G1 = DrawCone[A1]; G2 = DrawCone[A2]; G3 = DrawCone[A3] Show[G, G1, G2, G3] Show[G, G1, G2, G3, PlotRange -> All] Show[G1, G2, G3] Show[G1, G2, G3, PlotRange -> All] === Subject: Re: Graphics3D, missing part Show[G, G1, G2, G3, PlotRange -> All] ?? Jens > I am trying to use Mathematica 5.1 to make a fractal tree. I get no > problem for Show[G1,G2,G3], but when I do Show[G, G1, G2, G3], the > problem part of the graph is missing. Have I done something wrong? > > Any help is much appreciated. > > wshun > > coneF = Function[{x, y, z, r, h, t}, {{x + 0.6h*Cos[t], y + > 0.6h*Sin[t], z + 0.6h, 0.4r, 0.4h, t}, {x + 0.6h*Cos[t], y + > 0.6h*Sin[t], z + 0.6h, 0.4r, 0.6h, Mod[t + 2Pi/3, 2Pi]}, {x + > 0.6h*Cos[t], y + 0.6h*Sin[t], z + 0.6h, 0.4r, 0.6h, Mod[t + 4Pi/3, > 2Pi]}}] > > coneG = Function[A, Flatten[Table[coneF[ Extract[A, {k, 1}], > Extract[A, {k, 2}], Extract[A, {k, 3}], Extract[A, {k, 4}], > Extract[A, {k, 5}], Extract[A, {k, 6}]], {k, Length[A]}], 1]] > > DrawCone = Function[A, Table[ParametricPlot3D[{Extract[A, {k, 1}], > Extract[A, {k, 2}], Extract[A, {k, 3}]} + Extract[A, {k, 4}]*(1 - h/ > Extract[A, {k, 5}])*{Cos[t], Sin[t], 0} + h*{Cos[Extract[A, {k, 6}]], > Sin[Extract[A, {k, 6}]], 1}, {h, 0, Extract[A, {k, 5}]}, {t, 0, 2Pi}], > {k, Length[A]}]] > > A = {{0, 0, 0, 1, 6, 0}}; A1 = coneG[A]; A2 = coneG[A1]; A3 = > coneG[A2]; > > G = DrawCone[A]; G1 = DrawCone[A1]; G2 = DrawCone[A2]; G3 = > DrawCone[A3] > > Show[G, G1, G2, G3] > === Subject: Re: Graphics3D, missing part wshun On Apr 1, 6:39 pm, Jens-Peer Kuska Show[G, G1, G2, G3, PlotRange -> All] ?? Jens > === Subject: Re: Problems with differentiating Piecewise functions >> If I set up a piecewise function and differentiate it: >> In[112]:= pw1 = Piecewise[{{x^2, x <= 0}, {x, x > 0}}] >> Out[112]= [Piecewise] { >> {x^2, x <= 0}, >> {x, x > 0} >> } >> In[113]:= pw1 /. x -> 0 >> Out[113]= 0 >> In[114]:= pw1d = D[pw1, x] >> Out[114]= [Piecewise] { >> {2 x, x < 0}, >> {1, x > 0}, >> {Indeterminate, !(* >> TagBox[True, >> PiecewiseDefault, >> AutoDelete->False, >> DeletionWarning->True])} >> } >> In[115]:= pw1d /. x -> 0 >> Out[115]= Indeterminate >> Then at the joins between the pieces I get Indeterminate values, >> because the limit x <= 0 has become x < 0 after differentiation. >> Does >> anyone know a solution to this problem? >> Howard. > What do you mean by a solution to this problem? You have a > function that is not differentiable at 0 and you would like it's > derivative to have a value there? You can't expect a solution to a > problem when you do not tell us what is the problem (except the > fact > that not all functions are differentiable - but that's life). > Note that is your pieceise function is actually differentiable than > the derivative is defined everywhere: > pw2 = Piecewise[{{x^2, x <= 0}, {x^3, x > 0}}]; > pw2d = D[pw2, x] > Piecewise[{{2*x, x < 0}, {0, x == 0}}, 3*x^2] > This is also as it should be. What else would you expect? > Andrzej Kozlowski >> example that I posted (I simplified my problem by cutting and pasting >> an example from the help file to keep the post short). I am actually >> fitting cubic splines and the functions are continuous up to the >> second derivative (at least to the accuracy of machine precision). A >> better example is: >> In[54]:= pw[x_] := >> Piecewise[{{0.+ 0.007508378277320685 x + 7.561460342471517*10^-7 x^3, >> x < 50}, {-4.8729206849430454*10^-6 (-125.76959597633721 + >> x) (1148.1044516606876- 47.50636365246156 x + x^2), 50 <= x}}] >> In[55]:= pw[x] >> Out[55]= [Piecewise] { >> {0.+ 0.00750838 x + 7.56146*10^-7 x^3, x < 50}, >> {-4.87292*10^-6 (-125.77 + x) (1148.1- 47.5064 x + x^2), 50 <= x} >> } >> In[56]:= pw[50] >> Out[56]= 0.469937 >> In[57]:= pw[50 + 10^-30] >> Out[57]= 0.469937 >> In[58]:= pw[50 - 10^-30] >> Out[58]= 0.469937 >> In[60]:= pw'[x] >> Out[60]= [Piecewise] { >> {0.00750838+ 2.26844*10^-6 x^2, x < 50}, >> {-4.87292*10^-6 (-125.77 + x) (-47.5064 + 2 x) - >> 4.87292*10^-6 (1148.1- 47.5064 x + x^2), x > 50}, >> {Indeterminate, !(* >> TagBox[True, >> PiecewiseDefault, >> AutoDelete->False, >> DeletionWarning->True])} >> } >> In[61]:= pw'[50] >> Out[61]= Indeterminate >> In[62]:= pw'[50 + 10^-30] >> Out[62]= 0.0131795 >> In[63]:= pw'[50 - 10^-30] >> Out[63]= 0.0131795 >> Also if you Plot pw or pw' you get an annoying gap in the plot at the >> join (but strangely not pw''). My guess is that Mathematica is too >> pedantic about machine precision and is treating each piece as an >> algebraic equation. However this does not explain why Plot behaves >> funnily and doesn't help if you are trying to do numerical analysis. > You are violating one of the most fundamental principles of computer > algebra: do not mix approximate numbers with symbolic computation. > More correctly, such mixing requires a great deal of care and > symbolic algebraic techniques that can deal with approximate numbers > (and even more so with machine precision input) are still in their > infancy. (In fact Mathematica is one of the few systems that make it > to some extent possible). In your case the symbolic technique you > are using is differentiation of a piecewise function, and this > cannot be reliably combined with numerical precision input. > The answer to your problem is simple. Switch from using a mixture of > symbolic methods and approximate input to a purely numeric setting. > The best way to do this, I think, is by using FunctionInterpolation. > So what you need to do is this: > pw[x_] := > Piecewise[{{0. + 0.007508378277320685 x + 7.561460342471517*10^-7 x^3, > x < 50}, {-4.8729206849430454*10^-6 (-125.76959597633721 + > x) (1148.1044516606876 - 47.50636365246156 x + x^2), 50 <= x}}] > f = FunctionInterpolation[pw[x], {x, 0, 80}]; > Plot[f[x], {x, 40, 60}] > shows a continuous curve > Plot[f'[x], {x, 40, 60}] > shows an almost smooth curve, with a slight kink at the break > point. One could probably play with the options to > FunctionInterpolation to smoothen it. > Andrzej Kozlowski Actually, you can get a smooth looking derivative by using a higher > interpolation order: f = FunctionInterpolation[pw[x], {x, 0, 80}, InterpolationOrder -> 10]; Plot[f'[x], {x, 40, 60}] looks very smooth and so does: Plot[f''[x], {x, 40, 60}] Andrzej Kozlowski FunctionInterpolation but I actually wanted to plot my splines not an approximation to them. I guess I am asking too much since Piecewise takes algebraic expressions, unlike FunctionInterpolation, and therefore must evaluate symbolically. === Subject: how change color of directed edges for GraphPlot I have a directed graph to display using GraphPlot: a=RotateVertices[EmptyGraph[4],-([Pi]/4)]; a=SetGraphOptions[a,EdgeDirection->True]; a=AddEdges[a,{{1,2},{2,3},{2,4},{3,1},{4,1},{4,3}}]; I want to display it using GraphPlot... GraphPlot[a, Method -> None, DirectedEdges -> True, VertexRenderingFunction -> ({Black, Disk[#1, 0.02]} &)] ... but I want the edges and the arrows to be Black and not the default brown. How can one do this WITHOUT having to completely rewrite what the default EdgeRenderingFunction->Automatic option does; that is, I still want the arrows with their heads in the default position (it looks something like 2/3 the way along each arrow). -- 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 fax 413 545-1801 Amherst, MA 01003-9305 === Subject: Re: changing style of vertices for ShowGraph But I want to reproduce with GraphPlot some of the old behavior of DiscreteMath`Combinatorica`ShowGraph (since some other of its behavior seems to have disappeared in Mathematica 6). Namely, to show the vertex labels not AT the vertices but rather near the vertices, so that I can still use solid disks for the vertices. If I do something like this... GraphPlot[Cycle[3],Method->Automatic, VertexLabeling->True, VertexRenderingFunction->({Black,Disk[#1,0.02],Black,Text[#2,#1]}&)] ... then I get the disks but no labels, because evidently one of the arguments of Text[#2,#1] -- which one?? (this doesn't seem to be documented?) -- is giving the location to be AT the vertices. With some experimentation, I discover that it's argument #1 that gives the coordinates of the vertex, so I can use something like: GraphPlot[Cycle[3],Method->Automatic, VertexLabeling->True, VertexRenderingFunction-> ({Black,Disk[#1,0.02],Black,Text[#2,#1+{0.05,0.05}]}&)] But this is SO much work for something that was SO simple with ShowGraph! > Setting the option VertexLabeling->True has no effect when a custom > definition is provided for VertexRenderingFunction, as VertexLabeling > only affects how the default rendering function draws the vertices. > If you want vertex labels provided you need to include that in the > definition of the custom rendering function. > > Look up the documentation for VertexRenderingFunction and > EdgeRenderingFunction to see what additional arguments are provided. > The first argument for VertexRenderingFunction is the position of the > vertex. The second argument is the label. So the following works: > > GraphPlot[Cycle[3], Method -> Automatic, VertexLabeling -> True, > EdgeLabeling -> True, EdgeRenderingFunction -> ({Black, Line[#1]} &), > VertexRenderingFunction -> ({EdgeForm[{Thickness[0.005], Red}], > Yellow, > Disk[#1, 0.04], Black, Text[#2, #1]} &)] > > You can drop the option settings for VertexLabeling and EdgeLabeling > and get the same effect. > > As for whether GraphPlot plays well with the Combinatorica graph > structure, it does handle vertex labels correctly but not edge labels, > as the following example illustrates. I was personally surprised to > find that the edge labels were not passed to EdgeRenderingFunction. I > think this might be a bug. > > GraphPlot[ > Graph[{{{1, 2}, EdgeLabel -> e1}, {{2, 3}, EdgeLabel -> e2}, > {{3, 1}, > EdgeLabel -> e3}}, > {{{-0.5, 0.866}, VertexLabel -> a}, > {{-0.5, -0.866}, VertexLabel -> b}, > {{1., 0}, VertexLabel -> c}}], > EdgeRenderingFunction -> ({Black, Line[#1], > Text[#3, Mean[#1]] > } &), > VertexRenderingFunction -> ({EdgeForm[{Thickness[0.005], Red}], > Yellow, > Disk[#1, 0.04], Black, Text[#2, #1]} &)] > > > Jason > > >> Yes, GraphPlot seems to permit making nice vertices (or edges), but >> then >> the labeling -- either with a Graph object from Combinatorica or just >> the kind of graph described by the GraphPlot reference page -- does >> not >> seem to admit vertex labels or edge labels, at least so far as I can >> see. For example, neither of the following displays either vertex >> labels or edge labels: >> GraphPlot[Cycle[3], Method -> Automatic, VertexLabeling -> True, >> EdgeLabeling -> True, EdgeRenderingFunction -> ({Black, Line[#1]} &), >> VertexRenderingFunction -> ({EdgeForm[{Thickness[0.005], Red}], >> Yellow, Disk[#1, 0.04]} &)] >> GraphPlot[{{v1 -> v2, a}, {v2 -> v3, b}, {v3 -> v1, c}}, >> Method -> Automatic, VertexLabeling -> True, EdgeLabeling -> True, >> EdgeRenderingFunction -> ({Black, Line[#1]} &), >> VertexRenderingFunction -> ({EdgeForm[{Thickness[0.005], Red}], >> Yellow, Disk[#1, 0.04]} &)] >> On the other hand, if I remove he VertexRenderingFunction option, I do >> see vertex labels on the default (yellow boxes) vertex shapes: >> GraphPlot[{v1 -> v2, a}, {v2 -> v3, b}, {v3 -> v1, c}}, >> Method -> Automatic, VertexLabeling -> True, >> EdgeLabeling -> True, EdgeRenderingFunction -> ({Black, Line[#1]} >> &)] >> GraphPlot[Cycle[3], Method -> Automatic, VertexLabeling -> True, >> EdgeLabeling -> True, EdgeRenderingFunction -> ({Black, Line[#1]} &)] >> Of course this now defeats the purpose of using GraphPlot so as to get >> exactly the kind of vertex shapes that VertexRenderingFunction, above, >> provides. >> Similarly with EdgeRenderingFunction. >> The kernel function GraphPlot doesn't seem to mesh very well with >> Combinatorica's graph functions. This all still seems only half- >> baked. > Take a look at GraphPlot, the graph rendering function that is built > into the Mathematica kernel. I switched from using ShowGraph to > GraphPlot after realising that it was (a) faster and (b) easier to > customise. Here's what you want: GraphPlot[ > Cycle[3], > Method -> None, > EdgeRenderingFunction -> ({Black, Line[#1]} &), > VertexRenderingFunction -> ({EdgeForm[{Thickness[0.005], Red}], > Yellow, > Disk[#1, 0.04]} &) > ] You need to specify Method->None, otherwise GraphPlot will override > the > specified positions of the vertices in the graph and use its own > default > vertex positioning algorithm. VertexRenderingFunction is what you need to define in order to > customise > the appearance of the vertices. I provided a definition of EdgeRenderingFunction just so that the > edges > are rendered in the same way as ShowGraph. > Jason -- > J. McKenzie Alexander > Department of Philosophy, Logic and Scientific Method > London School of Economics and Political Science > Houghton Street, London WC2A 2AE > With Mathematica 6, I can change the default style (medium black >> disk) >> for rendering the vertices of a Combinatorica Graph like this: >> Needs[Combinatorica`] >> g = Cycle[3]; >> ShowGraph[g, VertexStyle -> Disk[Large], VertexColor -> Red] >> But how can I, for example, change the vertex style so it is, say, a >> large yellow disk with a thick red boundary? Or even just change >> it to >> be a circle? I tried obvious things like the following, but they >> cause errors: >> ShowGraph[g, VertexStyle -> Graphics[Circle[], ImageSize -> 20]] >> -- >> 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 fax 413 545-1801 >> Amherst, MA 01003-9305 > > Please access the attached hyperlink for an important electronic > communications disclaimer: > http://www.lse.ac.uk/collections/secretariat/legal/disclaimer.htm > -- >> 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 fax 413 545-1801 >> Amherst, MA 01003-9305 > > -- > Dr J. McKenzie Alexander > Department of Philosophy, Logic and Scientific Method > London School of Economics and Political Science > Houghton Street, London WC2A 2AE > > > > > Please access the attached hyperlink for an important electronic communications disclaimer: http://www.lse.ac.uk/collections/secretariat/legal/disclaimer.htm > -- 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 fax 413 545-1801 Amherst, MA 01003-9305 === Subject: Re: Something very simple..... Steve, Try, Sphere@@#&/@sphlst and, Complement[lsta,lsta[[lstb]]] maarten Steve Gray unner.com> cc: === Subject: Something very simple..... 01/04/2008 10:19 1. I have a list of sphere centers and radii like this: sphlst={{{ 5.11, 0.76, -0.32}, 100.39}, {{ 7.18, -1.86, -8.19}, 98.02}, {{26.71, -9.30, -6.85}, 111.27}, {{ 0, 0, 0}, 100.00}, {{ 8.65, 4.28, -3.81}, 103.87}}. If I do Map[Sphere,sphlst] I get too many braces, like this: {Sphere[{{ 5.11, 0.76, -0.32}, 100.39}], Sphere[{{ 7.18, -1.86, -8.19}, 98.02}], Sphere[{{26.71, -9.30, -6.85}, 111.27}], Sphere[{{ 0, 0, 0}, 100.00}], Sphere[{{ 8.65, 4.28, -3.81}, 103.87}]} and Sphere needs for example Sphere[{1.11, 2.22, 3.33},4.5]. What simple thing am I missing to remove the extra braces? (I know I can use Table but isn't there a one-step method?) Flatten doesn't seem to be useful here, or I'm using it wrong. 2. I have two lists, lsta={a,b,c,d,e,f} and lstb={1,3,4}. I want the elements of lsta that do NOT correspond to elements of lstb, in this case everything from lsta except elements 1,3, and 4: result={b,e,f}. (lstb won't have entries larger than Length[lsta]). Steve Gray === Subject: Defining a Play[] function for Drawbar Organ Emulation Although I have no problem PLOTing such a function as this, I cannot get it to work with the Play[] function. Can anyone help? This is based on the 11-drawbar organ stops used on some hammond organs (such as the X-66 model) which I am trying to emulate for additive synthesis output in a future Demonstration Project (I am using Mathematica 6). ElevenDrawbars[f_, d_String] := Module[{d1, d2, d3, d4, d5, d6, d7, d8, d9, d10, h10, d11, h11, z}, d = StringTake[d, {1}] <> StringTake[d, {2}] <> StringTake[d, {4}] <> StringTake[d, {5}] <> StringTake[d, {6}] <> StringTake[d, {7}] <> StringTake[d, {9}] <> StringTake[d, {10}] <> StringTake[d, {11}] <> StringTake[d, {13}] <> StringTake[d, {14}]; d1 = ToExpression[StringTake[d, {1}]]; d2 = ToExpression[StringTake[d, {2}]]; d3 = ToExpression[StringTake[d, {3}]]; d4 = ToExpression[StringTake[d, {4}]]; d5 = ToExpression[StringTake[d, {5}]]; d6 = ToExpression[StringTake[d, {6}]]; d7 = ToExpression[StringTake[d, {7}]]; d8 = ToExpression[StringTake[d, {8}]]; d9 = ToExpression[StringTake[d, {9}]]; d10 = ToExpression[StringTake[d, {10}]]; h10 = d11/2; d11 = ToExpression[StringTake[d, {11}]]; h11 = d11/2; z = N[2 Pi]; Play[d1 Sin[1/2 f x z] + d2 Sin[3/2 f x z] + d3 Sin[f x z] + d4 Sin[2 f x z] + d5 Sin[3 f x z] + d6 Sin[4 f x z] + d7 Sin[5 f x z] + d8 Sin[6 f x z] + d9 Sin[8 f x z] + d10 Sin[7 f x z] + h10 Sin[9 f x z] + d11 Sin[10 f x z] + h11 Sin[12 f x z], {x, 0, z}, SampleDepth -> 16, SampleRate -> 44100]] I get the following error statements: In[30]:= ElevenDrawbars[440, 00 8845 041 00] During evaluation of In[30]:= Set::setraw: Cannot assign to raw object 00 8845 041 00. >> During evaluation of In[30]:= Sound::ssnm: A good PlayRange could not be found since most of the samples are not evaluating to machine-size real numbers. >> Out[30]= Sound[SampledSoundFunction[!(* TagBox[ RowBox[{CompiledFunction, [, RowBox[{ RowBox[{{, Play`Time7, }}], ,, RowBox[{Block, [, RowBox[{ RowBox[{{, RowBox[{x, =, RowBox[{0.`, , +, RowBox[{0.000022675736961451248`, , Play`Time7}]}]}], }}], ,, RowBox[{ RowBox[{(, RowBox[{ RowBox[{(, RowBox[{ RowBox[{d1$2049, , RowBox[{Sin, [, FractionBox[ RowBox[{440, , x, , z$2049}], 2], ]}]}], +, RowBox[{d2$2049, , RowBox[{Sin, [, FractionBox[ RowBox[{3, , 440, , x, , z$2049}], 2], ]}]}], +, RowBox[{d3$2049, , RowBox[{Sin, [, RowBox[{440, , x, , z$2049}], ]}]}], +, RowBox[{d4$2049, , RowBox[{Sin, [, RowBox[{2, , 440, , x, , z$2049}], ]}]}], +, RowBox[{d5$2049, , RowBox[{Sin, [, RowBox[{3, , 440, , x, , z$2049}], ]}]}], +, RowBox[{d6$2049, , RowBox[{Sin, [, RowBox[{4, , 440, , x, , z$2049}], ]}]}], +, RowBox[{d7$2049, , RowBox[{Sin, [, RowBox[{5, , 440, , x, , z$2049}], ]}]}], +, RowBox[{d8$2049, , RowBox[{Sin, [, RowBox[{6, , 440, , x, , z$2049}], ]}]}], +, RowBox[{d9$2049, , RowBox[{Sin, [, RowBox[{8, , 440, , x, , z$2049}], ]}]}], +, RowBox[{d10$2049, , RowBox[{Sin, [, RowBox[{7, , 440, , x, , z$2049}], ]}]}], +, RowBox[{h10$2049, , RowBox[{Sin, [, RowBox[{9, , 440, , x, , z$2049}], ]}]}], +, RowBox[{d11$2049, , RowBox[{Sin, [, RowBox[{10, , 440, , x, , z$2049}], ]}]}], +, RowBox[{h11$2049, , RowBox[{Sin, [, RowBox[{12, , 440, , x, , z$2049}], ]}]}]}], )}], +, 0.`}], )}], , 1.`}]}], ]}], ,, <-CompiledCode->}], ]}], False, Editable->False]), 277088, {44100, 16}]] Can ANYONE help correct my ElevenDrawbars function to avoid this problem? Benjamin Tubb brtubb@pdmusic.org === Subject: Mixed Numerical Derivatives How can I come up with the Hessian of a function, at a particular point, which can only be evaluated numerically? If I had a symbolic function, I could do something like In[123]:= D[x^3 + z*y^-1 + z^(1/2), {{x, y, z}, 2}] /. {x -> 3, y -> 5, z -> 12} Out[123]= {{18, 0, 0}, {0, 24/ 125, -1/25}, {0, -1/25, -1/(96 Sqrt[3])}} The function I'm interested in, though, can only be calculated numerically. Using ND, I can find the diagonal elements of the Hessian: In[92]:= rules = Last[ FindMaximum[{Total[logPr[vdt, ddt, var, #] & /@ testData], ddt > 0, var > 0}, {{vdt, .9}, {ddt, 120}, {var, 90}}]] Out[92]= {vdt -> 0.95945, ddt -> 151.097, var -> 103.255} In[111]:= Needs[NumericalCalculus`] In[124]:= ND[ Total[logPr[vdtp, ddt, var, #] & /@ testData] /. rules, {vdtp, 2}, Evaluate[vdt /. rules]] Out[124]= -64.4011 But what about the off diagonal elements? === Subject: Obscure limitation of shorthand f' notation for Derivative The shorthand f' notation for Derivative: f'''' >> Derivative[4][f] Equivalently, ToExpression[f <> Table[', {4}]] >> Derivative[4][f] Now, Derivative can represent derivatives of high order: Derivative[32768][f] >> Derivative[32768][f] But, ToExpression[f <> Table[', {32767}]] >> Derivative[32767][f] ToExpression[f <> Table[', {32768}]] >> Derivative[-32768][f] Evidently a short int is overflowing somewhere. === Subject: PysankyEasterEggsP.nbp $Aborted Michael Trott's PysankyEasterEggsP.nbp downloaded from www.mathematicaguidebooks.org shows $Aborted when loaded into Mathematica. No hint was given as to why. Using SetOptions[Dynamic,SynchronousUpdating->False] as suggested in tutorial/IntroductionToDynamic if you have something slow in a Dynamic did not help. The Dynamic Timeout note of 21-Nov-2007 in this newsgroup the explained how to set DynamicEvaluationTimeout whereas the online documentation did not. AbsoluteOptions[$FrontEnd,DynamicEvaluationTimeout] reports {DynamicEvaluationTimeout->6.} Using SetOptions[$FrontEnd,DynamicEvaluationTimeout->60] (a 60 second timeout) allowed the demo to load properly. Note that the FrontEnd's init.m file stores this value so the value will remain even after restarting Mathematica. It would have been very helpful if a message had been issued stating that a timeout had occurred and what to do about it. DynamicEvaluationTimeout can also be set by choosing the Edit menu's Preferences... dialog and clicking the [Open Option Inspector] button under the |Advanced| tab. Expand [+] Cell Options and click on Evaluation Options. DynamicEvaluationTimeout appears near the bottom. Click on the value and enter 60 to make the same change shown above. Click on the X on the left to remove the setting and restore the default. Note that this is all done with Show option values at the top of the dialog set to [Global Preferences]. It is also possible to select just that cell or PysankyEasterEggsP.nbp so that the DynamicEvaluationTimeout setting only applies there. To do that: 1) Disable Dynamic Updating Enabled in the Evaluation menu. 2) Load PysankyEasterEggsP.nbp, select the cell. 3) Choose the Format menu's Options Inspector... 4) Set DynamicEvaluationTimeout to 60 as stated above. 5) Enable Dynamic Updating Enabled in the Evaluation menu. It does not seem not possible to re-evaluate the cell once it has displayed $Aborted. Q.E.D. === Subject: Write documentation for 6.0 under Solaris There seems to be very little documentation about how to write documentation for 6.0. I found this http://homepage.cem.itesm.mx/lgomez/createMathematica6AddOn/createMathematic a6AddOn.html but it did not seem to work for me. I found something quite recently added to the Wolfram site recently which was an example added in the last month or so I think. It had a link to an alpha version of Workbench 1.2, but the link did not work. But that was only for Windows/Mac. Are there any plans to make it possible to write documentation if one uses Solaris - or for that matter, HP-UX or similar? I thought Mathematica was supposed to be multi-platform, but some of the add-on packages and workbench do not support all platforms. I would think the ability to write documentation needs to be in the front end and mutli-platform and should not need other packages such as workbench which only run on a subset of platforms. === Subject: Re: Problem with FourierParameters Am 1. Apr 2008 um 00:55 schrieb Devendra Kapadia: >> > I get a wrong result using FourierParameters: > > FourierTransform[f, x, w] > InverseFourierTransform[%, w, x] > > gives > > 1/2 Sqrt[[Pi]/2] (Sign[1 - w] + Sign[1 + w]) > Sin[x]/x > > which is what I expected. But with the setting of FourierParameters: > > FourierTransform[f, x, w, FourierParameters -> {1, -1}] > InverseFourierTransform[%, w, x, FourierParameters -> {1, -1}] > > gives > > 1/2 [Pi] Sign[1 - w] + 1/2 [Pi] Sign[1 + w] <--- This is OK > 0 <--- Bug? > > Other functions e.g. f=1/(1+x^2) transform correctly in both cases. > > Gruss Peter > >> Hello Peter, >> >> The answer given by InverseFourierTransform for your example with >> FourierParameters -> {1, -1} is indeed incorrect. >> >> We use symbolic integration for computing the inverse transform >> in both the cases given above. The incorrect answer appears to >> be caused by the fact that the output from FourierTransform in >> the second case is not in factored form. Hence, a partial >> workaround for the problem is to use Factor in the call >> to InverseFourierTransform, as shown below: >> >> >> In[2]:= FourierTransform[Sin[x]/x, x, w, FourierParameters -> {1, -1}] >> Pi Sign[1 - w] Pi Sign[1 + w] >> Out[2]= -------------- + -------------- >> 2 2 >> >> In[3]:= InverseFourierTransform[Factor[%], w, x, >> FourierParameters -> {1, -1}] >> Sin[x] >> Out[3]= ------ >> x >> >> >> caused by it. >> >> >> Devendra Kapadia, >> Wolfram Research, Inc. > I experimented a bit with different FourierParameters and it seems that the > wrong answer always comes up, if the first parameter (a) ist not 0. Can you > confirm this? Sincerly, Peter Breitfeld > -- > ==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-== > Peter Breitfeld | http://www.pBreitfeld.de > Kreuzgasse 4, 88348 Bad Saulgau | PGP/GPG Key gibt's hier Yes, the problem is also seen with other numerical values of 'a' in FourierParameters -> {a,b}, but the example seems to work fine if we allow 'a' to remain symbolic as shown below: In[2]:= FourierTransform[Sin[x]/x, x, w, FourierParameters -> {a, -1}] -1 + a Pi Sqrt[(2 Pi) ] (Sign[1 - w] + Sign[1 + w]) Out[2]= ------------------------------------------------- 2 In[3]:= Simplify[InverseFourierTransform[%, w, x, FourierParameters -> {a, -1}], Im[a] == 0] Sin[x] Out[3]= ------ x -Devendra === Subject: Re: Problem with FourierParameters Am 1. Apr 2008 um 00:55 schrieb Devendra Kapadia: > I get a wrong result using FourierParameters: >> FourierTransform[f, x, w] >> InverseFourierTransform[%, w, x] >> gives >> 1/2 Sqrt[[Pi]/2] (Sign[1 - w] + Sign[1 + w]) >> Sin[x]/x >> which is what I expected. But with the setting of FourierParameters: >> FourierTransform[f, x, w, FourierParameters -> {1, -1}] >> InverseFourierTransform[%, w, x, FourierParameters -> {1, -1}] >> gives >> 1/2 [Pi] Sign[1 - w] + 1/2 [Pi] Sign[1 + w] <--- This is OK >> 0 <--- Bug? >> Other functions e.g. f=1/(1+x^2) transform correctly in both cases. >> Gruss Peter > Hello Peter, The answer given by InverseFourierTransform for your example with > FourierParameters -> {1, -1} is indeed incorrect. We use symbolic integration for computing the inverse transform > in both the cases given above. The incorrect answer appears to > be caused by the fact that the output from FourierTransform in > the second case is not in factored form. Hence, a partial > workaround for the problem is to use Factor in the call > to InverseFourierTransform, as shown below: > In[2]:= FourierTransform[Sin[x]/x, x, w, FourierParameters -> {1, -1}] Pi Sign[1 - w] Pi Sign[1 + w] > Out[2]= -------------- + -------------- > 2 2 In[3]:= InverseFourierTransform[Factor[%], w, x, > FourierParameters -> {1, -1}] Sin[x] > Out[3]= ------ > x > inconvenience > caused by it. > Devendra Kapadia, > Wolfram Research, Inc. I experimented a bit with different FourierParameters and it seems that the wrong answer always comes up, if the first parameter (a) ist not 0. Can you confirm this? Sincerly, Peter Breitfeld -- ==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-== Peter Breitfeld | http://www.pBreitfeld.de Kreuzgasse 4, 88348 Bad Saulgau | PGP/GPG Key gibt's hier === Subject: Re: Problem with FourierParameters Am 1. Apr 2008 um 00:55 schrieb Devendra Kapadia: > I get a wrong result using FourierParameters: FourierTransform[f, x, w] > InverseFourierTransform[%, w, x] gives 1/2 Sqrt[[Pi]/2] (Sign[1 - w] + Sign[1 + w]) > Sin[x]/x which is what I expected. But with the setting of FourierParameters: FourierTransform[f, x, w, FourierParameters -> {1, -1}] > InverseFourierTransform[%, w, x, FourierParameters -> {1, -1}] gives 1/2 [Pi] Sign[1 - w] + 1/2 [Pi] Sign[1 + w] <--- This is OK > 0 <--- Bug? Other functions e.g. f=1/(1+x^2) transform correctly in both cases. Gruss Peter > Hello Peter, >> The answer given by InverseFourierTransform for your example with >> FourierParameters -> {1, -1} is indeed incorrect. >> We use symbolic integration for computing the inverse transform >> in both the cases given above. The incorrect answer appears to >> be caused by the fact that the output from FourierTransform in >> the second case is not in factored form. Hence, a partial >> workaround for the problem is to use Factor in the call >> to InverseFourierTransform, as shown below: >> In[2]:= FourierTransform[Sin[x]/x, x, w, FourierParameters -> {1, -1}] >> Pi Sign[1 - w] Pi Sign[1 + w] >> Out[2]= -------------- + -------------- >> 2 2 >> In[3]:= InverseFourierTransform[Factor[%], w, x, >> FourierParameters -> {1, -1}] >> Sin[x] >> Out[3]= ------ >> x >> inconvenience >> caused by it. >> Devendra Kapadia, >> Wolfram Research, Inc. The real problem comes about that Mathematica does not InverseFourierTransform Sign[1-w] correctly!!! It seams that internally a rule is defined to InverseFourierTransform Sign[1+w]+Sign[1-w] such that one need to factor out the rest before. If instead Mathematica where able to InverseFourierTransform Sign[1-w] no such rules would be necessary at all!!! I'm confused by the idea to implement special rules before the more elementary ones work -- this lead to bugs which appear almost at random. Here two distinct bugs: (I) In[1]=InverseFourierTransform[Sign[w],w,x,FourierParameters->{1,-1}] Out[1]=I/(Pi*x) + DiracDelta[x] - 2*Pi*DiracDelta[x] should be I/(Pi*x) [actually the principal value of it] why the 2*Pi in the last term [otherwise the two DiracDelta would the next bug I show with the standard FourierParameters, it is also present with FourierParameters->{1, -1} but then it is Qobscured by bug(I) (II) In[2]=InverseFourierTransform[Sign[1 - w], w, x] Out[2]=((2*I)*Cos[x] - 2*Sin[x])/(Sqrt[2*Pi]*x) should be ((2*I)*Cos[x] + 2*Sin[x])/(Sqrt[2*Pi]*x) These bugs (I)&(II) where already present in 5.2. They are quite severe as Fourier transforms of this type appear quite often in many applications. Fabian === Subject: Re: Problem with FourierParameters > I get a wrong result using FourierParameters: FourierTransform[f, x, w] > InverseFourierTransform[%, w, x] gives 1/2 Sqrt[[Pi]/2] (Sign[1 - w] + Sign[1 + w]) > Sin[x]/x which is what I expected. But with the setting of FourierParameters: FourierTransform[f, x, w, FourierParameters -> {1, -1}] > InverseFourierTransform[%, w, x, FourierParameters -> {1, -1}] gives 1/2 [Pi] Sign[1 - w] + 1/2 [Pi] Sign[1 + w] <--- This is OK > 0 <--- Bug? Other functions e.g. f=1/(1+x^2) transform correctly in both cases. Gruss Peter > Hello Peter, The answer given by InverseFourierTransform for your example with FourierParameters -> {1, -1} is indeed incorrect. We use symbolic integration for computing the inverse transform in both the cases given above. The incorrect answer appears to be caused by the fact that the output from FourierTransform in the second case is not in factored form. Hence, a partial workaround for the problem is to use Factor in the call to InverseFourierTransform, as shown below: In[2]:= FourierTransform[Sin[x]/x, x, w, FourierParameters -> {1, -1}] Pi Sign[1 - w] Pi Sign[1 + w] Out[2]= -------------- + -------------- 2 2 In[3]:= InverseFourierTransform[Factor[%], w, x, FourierParameters -> {1, -1}] Sin[x] Out[3]= ------ x caused by it. Devendra Kapadia, Wolfram Research, Inc. === Subject: Re: Mathematica notebooks the best method I agree with everything below but to tell the truth I can't see what is supposed to be the point of this entire thread. If one wants to write a research paper using Mathematica and submit it to a print or on-line journal one needs only to convert it to pdf and it should then be acceptable in many cases it would be (assuming of course that the contents are good enough). If one wants in addition to provide people who are able to use Mathematica with live calculations one can put a Mathematica notebook for download on a web page. I can't see why anyone should wish for more or argue against this. The rest seems to me a complete waste of time and effort and some of what I have read I actually found quite funny (comical) though I assume it was meant to be serious. A completely different issue is whether academic institutions should provide their students with the opportunity to discover the (in my opinion) very remarkable possibilities offered by the latest version of Mathematica. That's all that my own response was concerned with. This is a real issue while a discussion of publishing standards is a waste of time. I should like to repeat that I have yet to meet a student who would complain about the lack of a printed manual and I think using that as an argument against Mathematica is a perfect example of the sort of academic attitude I referred to in my first response. Andrzej Kozlowski > djvu vs. pdf: no big deal. Tex vs. Mathematica: BIG deal! With djvu and pdf, it's merely a matter of the final format in which > the > document appears and is disseminated. With (La)TeX and Mathematica, there's a crucial difference in the > entire > authoring process. Among other things: (1) (La)TeX concentrates upon the logical structure of the document, > whereas Mathematica from the start involves the actual appearance of > the > document. (2) Typing math markup is typically quicker in (La)TeX than in > Mathematica, as it avoids Control-key sequences (unless one is using > an > editor where such sequences are used as shortcuts) or at least uses > shorter keystroke-only sequences. (3) Mathematica allows live calculations in the document itself, > whereas TeX does not (except of the most primitive kind). > Exception: a > specialized TeX+CAS system. (4) Mathematica creates graphics of all sorts directly in the > document, whereas with the exception of a limited number of native or > package add-on graphics types, graphics must be imported into a TeX > document from an external source (such as Mathematica)! There are two other another differences: (5) One can have an entire TeX document preparation system -- > editor, > TeX engine plus packages, viewer, and converter (dvi to ps or pdf, > e.g.) > -- for free. Needless to say, Mathematica is not free. (6) The source code for TeX and many or most of the supporting > utilities is open source; this is certainly not the case for > Mathematica. >> ...I would like to point out that publishing standards are not >> set in stone. For several years I have witnessed PDF visibly loosing >> ground to djvu in the mathematical preprint area. I like with many >> other things I learned about it first form students, who quickly >> understood its technical superiority over PDF (most of all, much >> smaller file size). Now I see that a number of on-line mathematics >> journals are offering djvu as an alternative to pdf. -- > 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 fax 413 545-1801 > Amherst, MA 01003-9305 > === Subject: Re: Mathematica notebooks the best method for technical Mathematica notebooks are the best method there is for technical communications This statement is certainly true as it stands. Journals or some universities may not adopt it as a standard for some valid reasons, but notebooks are certainly superior to any type of non-live technical document . I think David Park was thinking more at private technical communications. As long as both parties use mathematica, exchanging notebooks is by far the best way to communicate. As far as journal publication is concerned, probably the best strategy would be: publish using the accpted standards (latex, pdf,ect) but mention in the paper that a notebook with the relevant calculations is available online somewhere. === Subject: Re: Mathematica notebooks the best method for technical On 1 Apr, 09:20, Mariano Su=E1rez-Alvarez > Indeed. I would not be able to describe such an effort > with any other term apart from misguided. Very misguided. > Essentially > proprietary formats cannot possibly be considered as a > the simple fact that Mathematica, say, is absurdly expensive > for most of the world, to rather more complicated issues > (for example, one can never tell when the whimsical ires > of whatever be the superpower of the day, any day, may decide > to forbid selling, say, Mathematica to country X in order > to `fight Y' for whatever value X has at the time---terrorists, > peadophiles, and so on.), to so many other issues... It simply cannot withstand any analysis. -- m The only way I could see this happening is if Wolfram Research released the front end under the GPL or similar. Then it might, but even then it is far from clear it would and I personally doubt it would. === Subject: Re: Mathematica notebooks the best method for technical > Mathematica notebooks are the best method there is for > technical communications Would this were true. It's not. Making Mathematica notebooks become the primary method for both > preparing *and communicating* technical communications (broadly > interpreted to include teaching, writing, presentations, and > publications) in both the academic and professional worlds might be a > laudable goal, and a number of people (David Park very much included) > have put sincere and laudable efforts into trying to make it be the case. Sorry, it's _not_ going to happen. Wolfram is partly to blame for this -- very much including the currently > ongoing version 6 documentation disaster. But there are also very major and fundamental reasons why this goal very > possibly should not happen, or should not be attempted, or simply could > never happen in any case. To focus on just one aspect of this topic (out of many), I would point > out that major professional societies have (since Isaaac Newton's time!) > carried the burden of developing two of the major worldwide channels of > technical and scientific communications, namely scientific and technical > journals (and archives), and scientific and technical meetings And, these societies are struggling to adapt, and in many ways > successfully adapting, today to the Internet, electronic technologies, > open access, and other emerging complexities of information > transmission and communication. It's an expensive and > resource-consuming struggle The primary communication methods or formats for user input of > technical material to essentially all such journals and meetings today > -- user input being of course the primary source for all such material > -- are TeX (or LaTeX), PDF, and (unfortunately, but it's the reality) MS > Word. I've been heavily involved with a couple of these societies, and a close > observer at least, if not a major contributor, to the major and > stressful evolution of professional society publication and meeting > activities and methods in recent years. I've also been a heavy personal > user of Mathematica since I heard Steven Wolfram introduce version 1 to > an overflowing auditorium at my university several decades ago. I can only say that I would be a vehement opponent of any proposal > within these societies to divert resources to an effort to add > Mathematica notebooks to the format list above. [And, given the current situation, I'd be a vehement opponent of any > efforts within my university to spend university resources on making > Mathematica a *preferred* and heavily university-supported computational > and communications technology within my university.] Indeed. I would not be able to describe such an effort with any other term apart from misguided. Essentially proprietary formats cannot possibly be considered as a the simple fact that Mathematica, say, is absurdly expensive for most of the world, to rather more complicated issues (for example, one can never tell when the whimsical ires of whatever be the superpower of the day, any day, may decide to forbid selling, say, Mathematica to country X in order to `fight Y' for whatever value X has at the time---terrorists, peadophiles, and so on.), to so many other issues... It simply cannot withstand any analysis. -- m === Subject: Re: Something very simple..... For the first question, use any one of these: Sphere @@@ sphlst Sphere @@ # & /@ sphlst Apply[Sphere, sphlst, 1] For the second question: lsta = {a, b, c, d, e, f}; lstb = {1, 3, 4}; lsta[[Complement[Range[Length[lsta]], lstb]]] {b,e,f} Assuming that lstb is sorted as shown Fold[Delete[#1, #2] &, lsta, Reverse[lstb]] {b,e,f} Fold[Drop[#1, {#2}] &, lsta, Reverse[lstb]] {b,e,f} Bob Hanlon > 1. I have a list of sphere centers and radii like this: > > sphlst={{{ 5.11, 0.76, -0.32}, 100.39}, > {{ 7.18, -1.86, -8.19}, 98.02}, > {{26.71, -9.30, -6.85}, 111.27}, > {{ 0, 0, 0}, 100.00}, > {{ 8.65, 4.28, -3.81}, 103.87}}. > > If I do Map[Sphere,sphlst] I get too many braces, like this: > > {Sphere[{{ 5.11, 0.76, -0.32}, 100.39}], > Sphere[{{ 7.18, -1.86, -8.19}, 98.02}], > Sphere[{{26.71, -9.30, -6.85}, 111.27}], > Sphere[{{ 0, 0, 0}, 100.00}], > Sphere[{{ 8.65, 4.28, -3.81}, 103.87}]} > > and Sphere needs for example Sphere[{1.11, 2.22, 3.33},4.5]. > What simple thing am I missing to remove the extra braces? > (I know I can use Table but isn't there a one-step method?) > Flatten doesn't seem to be useful here, or I'm using it wrong. > > 2. I have two lists, lsta={a,b,c,d,e,f} and lstb={1,3,4}. > I want the elements of lsta that do NOT correspond to elements > of lstb, in this case everything from lsta except elements > 1,3, and 4: result={b,e,f}. > (lstb won't have entries larger than Length[lsta]). > > > Steve Gray > === Subject: Re: Factorial equations > Who know how is possible with use Mathematica solving equations > involving factorials e.g > Solve[n! + n == 726, n] My difficult problem to solving is > x=n > y=n! find function f(x,y) such > f[1,1!]==1, f[2,2!]==2, f[3,3!]==5, f[4,4!]=59,f[5,5!]=246, > f[6,6!]=1103, f[7,7!]=5247 > values are generated by procedure > ClearAll[f]; a = {}; Do[k = 0; Do[k = k + f[n] x^n, {n, 0, s}]; > m = Resultant[k, D[k, x], x]; AppendTo[a, Length[m]], {s, 1, 8}]; a Who can help in find formula or do above procedure much quickest I > will > be greatfull ! > Best wishes > ARTUR In this particular case you can find all the solutions using FindInstance: FindInstance[n! + n == 726 && Element[n, Integers] && n > 0, {n}] {{n -> 6}} and FindInstance[n! + n == 726 && Element[n, Integers] && n > 0 && n != 6, {n}] {} which means that 6 is a solution and there is no other positive integer solution. Now about your probem. First, your procedure does not make sense. Your function f is a function of two variables but it your procedure you have an f[n]. Secondly, the problem as stated is trivial for Mathematica and one does not need any procedures. This will do: f[x_, y_] = Together[InterpolatingPolynomial[{{{1, 1!}, 1}, {{2, 2!}, 2}, {{3, 3!}, 5}, {{4, 4!}, 59}, {{5, 5!}, 246}, {{6, 6!}, 1103}, {{7, 7!}, 5247}}, {x, y}]] (1/141478298898)*(1235040757839*x^3 - 6971716404999*x^2 + 135058984529*y*x + 12699232479546*x - 27342188*y^2 - 692985197547*y - 6263124978282) Now you can check that Apply[f[##1] & , Table[{n, n!}, {n, 1, 6}], {1}] {1, 2, 5, 59, 246, 1103} Andrzej Kozlowski === Subject: Re: Factorial equations Just as Solve will tell you, there IS no algebraic solution to problems like that. We can do pretty well with numerical methods, though: Clear[f] f[s_] := FindRoot[n + Gamma[n + 1] == s, {n, 3}] f[726] {n -> 6.} f[600] {n -> 5.89694} Bobby > Who know how is possible with use Mathematica solving equations > involving factorials e.g > Solve[n! + n == 726, n] My difficult problem to solving is > x=n > y=n! find function f(x,y) such > f[1,1!]==1, f[2,2!]==2, f[3,3!]==5, f[4,4!]=59,f[5,5!]== 246, > f[6,6!]=1103, f[7,7!]=5247 > values are generated by procedure > ClearAll[f]; a = {}; Do[k = 0; Do[k = k + f[n] x^n, {n, 0, s}]; > m = Resultant[k, D[k, x], x]; AppendTo[a, Length[m]], {s, 1, 8}]; a Who can help in find formula or do above procedure much quickest I will > be greatfull ! > Best wishes > ARTUR > -- DrMajorBob@longhorns.com === Subject: Re: Factorial equations > Who know how is possible with use Mathematica solving equations > involving factorials e.g > Solve[n! + n == 726, n] > > My difficult problem to solving is > x=n > y=n! > > find function f(x,y) such > f[1,1!]==1, f[2,2!]==2, f[3,3!]==5, f[4,4!]=59,f[5,5!]=246, > f[6,6!]=1103, f[7,7!]=5247 > values are generated by procedure > ClearAll[f]; a = {}; Do[k = 0; Do[k = k + f[n] x^n, {n, 0, s}]; > m = Resultant[k, D[k, x], x]; AppendTo[a, Length[m]], {s, 1, 8}]; a > > Who can help in find formula or do above procedure much quickest I will > be greatfull ! > Best wishes > ARTUR > This is all quite confusing. It is not hard to write a solver for equations of the form, say, n+n!==constant. To get an idea of how you might go about it, see (for example) But this will not help with what I believe is your goal, to find a closed form for terms in your sequence A007878 from the OEIS. I've no idea as to whether there is a concise closed form for this sequence. I also do not see why you have a function of two variables, since you only use one. That is, it is not clear why you work with f(n,n!) rather then just f(n). There may be a good reason, but if so you did not show it. Also you left out a term in your sequence: the fourth one is actually 16. As for computing it faster, the time is pretty much all spent in the discriminants. Some trial and error lead me to use the Bezout matrix formulation, as that seems fastest. Note that I also explicitly expand, since there is no guarantee these will be computed in expanded form. Timing[aa = Table[ k = Array[f,s+1,0].x^Range[0,s]; m = Discriminant[k, x, Method->SylvesterMatrix]; Length[Expand[m]], {s,1,8}]] Out[20]= {24.11, {0, 2, 5, 16, 59, 246, 1103, 5247}} The zero for the first term is because the discriminant of f[0] + x*f[1] is 1, and 1, being an atom in Mathematica, has length of zero. This may be related to ome recent questions you posted to the news group. Finally I will say that there might be better/faster ways to compute these discriminants (say, faster determinant code than what Mathematica now has). Daniel Lichtblau Wolfram Research === Subject: Re: Factorial equations >> Who know how is possible with use Mathematica solving equations >> involving factorials e.g >> Solve[n! + n == 726, n] >> My difficult problem to solving is >> x=n >> y=n! >> find function f(x,y) such >> f[1,1!]==1, f[2,2!]==2, f[3,3!]==5, f[4,4!]=59,f[5,5!]=246, >> f[6,6!]=1103, f[7,7!]=5247 >> values are generated by procedure >> ClearAll[f]; a = {}; Do[k = 0; Do[k = k + f[n] x^n, {n, 0, s}]; >> m = Resultant[k, D[k, x], x]; AppendTo[a, Length[m]], {s, 1, 8}]; a >> Who can help in find formula or do above procedure much quickest I >> will >> be greatfull ! >> Best wishes >> ARTUR In this particular case you can find all the solutions using > FindInstance: FindInstance[n! + n == 726 && Element[n, Integers] && n > 0, {n}] > {{n -> 6}} and > FindInstance[n! + n == 726 && Element[n, Integers] && n > 0 && n != > 6, {n}] > {} which means that 6 is a solution and there is no other positive > integer solution. Actually, this can be done more simply by using Reduce: Reduce[n! + n == 726 && Element[n, Integers] && n > 0, {n}] n==6 As for the second half, it now seems to me that by function you probably mean a polynomial with integer coefficients (?), in which case the polynomial below is not a satisfactory answer. However, since I still have no idea what your actual problem is (or why you believe that such a polynomial with integer coefficients exists) I will leave this problem to others. Andrzej Kozlowski > Now about your probem. First, your procedure does not make sense. > Your function f is a function of two variables but it your procedure > you have an f[n]. Secondly, the problem as stated is trivial for > Mathematica and one does not need any procedures. This will do: f[x_, y_] = > Together[InterpolatingPolynomial[{{{1, 1!}, 1}, {{2, 2!}, 2}, {{3, > 3!}, 5}, > {{4, 4!}, 59}, {{5, 5!}, 246}, {{6, 6!}, 1103}, {{7, 7!}, > 5247}}, {x, y}]] > (1/141478298898)*(1235040757839*x^3 - 6971716404999*x^2 + > 135058984529*y*x + 12699232479546*x - 27342188*y^2 - > 692985197547*y - > 6263124978282) Now you can check that Apply[f[##1] & , Table[{n, n!}, {n, 1, 6}], {1}] > {1, 2, 5, 59, 246, 1103} > Andrzej Kozlowski === Subject: Re: Factorial equations As for the first question (solving equations with factorials), Ted Ersek's RootSearch function works wonders: In[11]:= RootSearch[n! + n == 726, {n, 2, 10}] Out[11]= {{n -> 6.}} The package is available here: http://library.wolfram.com/infocenter/MathSource/4482/ Hope that helps a bit! > Who know how is possible with use Mathematica solving equations > involving factorials e.g > Solve[n! + n == 726, n] My difficult problem to solving is > x=n > y=n! find function f(x,y) such > f[1,1!]==1, f[2,2!]==2, f[3,3!]==5, f[4,4!]=59,f[5,5!]=246, > f[6,6!]=1103, f[7,7!]=5247 > values are generated by procedure > ClearAll[f]; a = {}; Do[k = 0; Do[k = k + f[n] x^n, {n, 0, s}]; > m = Resultant[k, D[k, x], x]; AppendTo[a, Length[m]], {s, 1, 8}]; a Who can help in find formula or do above procedure much quickest I will > be greatfull ! > Best wishes > ARTUR -- Curtis Osterhoudt cfo@remove_this.lanl.and_this.gov PGP Key ID: 0x4DCA2A10 Please avoid sending me Word or PowerPoint attachments See http://www.gnu.org/philosophy/no-word-attachments.html === Subject: Factorial equations Who know how is possible with use Mathematica solving equations involving factorials e.g Solve[n! + n == 726, n] My difficult problem to solving is x=n y=n! find function f(x,y) such f[1,1!]==1, f[2,2!]==2, f[3,3!]==5, f[4,4!]=59,f[5,5!]=246, f[6,6!]=1103, f[7,7!]=5247 values are generated by procedure ClearAll[f]; a = {}; Do[k = 0; Do[k = k + f[n] x^n, {n, 0, s}]; m = Resultant[k, D[k, x], x]; AppendTo[a, Length[m]], {s, 1, 8}]; a Who can help in find formula or do above procedure much quickest I will be greatfull ! Best wishes ARTUR === Subject: Re: Factorial equations > My difficult problem to solving is > x=n > y=n! > > find function f(x,y) such > f[1,1!]==1, f[2,2!]==2, f[3,3!]==5, f[4,4!]=59,f[5,5!]=246, > f[6,6!]=1103, f[7,7!]=5247 > values are generated by procedure > ClearAll[f]; a = {}; Do[k = 0; Do[k = k + f[n] x^n, {n, 0, s}]; > m = Resultant[k, D[k, x], x]; AppendTo[a, Length[m]], {s, 1, 8}]; a > > Who can help in find formula or do above procedure much quickest I will > be greatfull ! Though I am not sure to have fully grasped what you try to achieve, the following approach for computing the coefficients is about 10 times faster that the expression above (and clearer). Clear[f, g] g[0] = f[0]; g[n_Integer?Positive] := g[n] = g[n - 1] + f[n] x^n myFun[n_Integer?Positive] := Length@Resultant[g[n], D[g[n], x], x, Method -> BezoutMatrix] Table[myFun[n], {n, 1, 8}] {1, 2, 5, 16, 59, 246, 1103, 5247} We use a recursive definition with memoization (i.e. the intermediate results are saved, avoiding to be computed again after their first computation) to compute the polynomials. Also, most of the CPU time is spent computing *Resultant*, so we use the method *BezoutMatrix*, method which seems to be the fastest for this problem. For instance, 1103 (n = 7) is computed in 1.1337 second (vs 4.95693 seconds for the Automatic method) 5247 (n = 8) is computed in 15.8515 second (vs 136.098 seconds for the Automatic method) Below, you will find some timings that show where the CPU spend its time among the different part of the expression and also a speed comparison among the different algorithms available to compute *Resultant*. In[6]:= Clear[f, g] g[0] = f[0]; g[n_Integer?Positive] := g[n] = g[n - 1] + f[n] x^n myFun[n_Integer?Positive] := Length@Resultant[g[n], D[g[n], x], x] Table[{g[n] // Timing // First, D[g[n], x] // Timing // First, Resultant[g[n], D[g[n], x], x] // Timing // First, myFun[n] // Timing}, {n, 1, 8}] Out[10]= {{0.000037, 0.000016, 0.000045, {0.00003, 1}}, {0.000021, 0.00001, 0.000199, {0.000169, 2}}, {0.000024, 0.000012, 0.000666, {0.000644, 5}}, {0.000025, 0.000012, 0.003941, {0.003926, 16}}, {0.000033, 0.000016, 0.037161, {0.036293, 59}}, {0.000044, 0.000022, 0.309441, {0.318596, 246}}, {0.000051, 0.000026, 4.89827, {4.95693, 1103}}, {0.000053, 0.000029, 122.954, {136.098, 5247}}} In[11]:= Table[ Timing[Length@ Resultant[g[n], D[g[n], x], x, Method -> #]] & /@ {Automatic, Modular , Subresultants, BezoutMatrix, SylvesterMatrix}, {n, 1, 5}] Out[11]= {{{0.000072, 1}, {0.000029, 1}, {0.000027, 1}, {0.000026, 1}, {0.000026, 1}}, {{0.000186, 2}, {0.005394, 2}, {0.000147, 2}, {0.000523, 2}, {0.00017, 2}}, {{0.000655, 5}, {0.009401, 5}, {0.000249, 5}, {0.001269, 5}, {0.000657, 5}}, {{0.004164, 16}, {0.375798, 16}, {0.000979, 16}, {0.003623, 16}, {0.003861, 16}}, {{0.039217, 59}, {17.702, 59}, {0.020984, 59}, {0.016298, 59}, {0.038365, 59}}} In[12]:= Table[ Timing@Length@ Resultant[g[n], D[g[n], x], x, Method -> BezoutMatrix], {n, 1, 8}] Out[12]= {{0.000087, 1}, {0.000568, 2}, {0.001319, 5}, {0.003843, 16}, {0.016913, 59}, {0.106776, 246}, {1.1337, 1103}, {15.8515, 5247}} Hope this helps, -- === Subject: Re: Factorial equations Hi Artur, here is a somewhat faster method where we use Discriminant with the option Method-> BezoutMatrix: n=7; poly=Plus@@Table[Symbol[c<>ToString[i]] x^i,{i,0,n}]; Length@Discriminant[poly,x,Method-> BezoutMatrix] hope this helps, Daniel > Who know how is possible with use Mathematica solving equations > involving factorials e.g > Solve[n! + n == 726, n] > > My difficult problem to solving is > x=n > y=n! > > find function f(x,y) such > f[1,1!]==1, f[2,2!]==2, f[3,3!]==5, f[4,4!]=59,f[5,5!]=246, > f[6,6!]=1103, f[7,7!]=5247 > values are generated by procedure > ClearAll[f]; a = {}; Do[k = 0; Do[k = k + f[n] x^n, {n, 0, s}]; > m = Resultant[k, D[k, x], x]; AppendTo[a, Length[m]], {s, 1, 8}]; a > > Who can help in find formula or do above procedure much quickest I will > be greatfull ! > Best wishes > ARTUR > > === Subject: Re: Factorial equations > Who know how is possible with use Mathematica solving equations > involving factorials e.g > Solve[n! + n == 726, n] You could use *Reduce* and tell Mathematica that n is a positive integer. For instance, In[1]:= Reduce[n! + n == 726 && n >= 0, n, Integers] Out[1]= n == 6 (* We check this is the correct result, indeed. *) In[2]:= n! + n == 726 /. ToRules@% Out[2]= True HTH, -- === Subject: Re: same color above a treshold > in ArrayPlot or ContourPlot, I need to color the points exceeding a > certain treshold with the same color (say red). > I guess that could be done defining an appropriate ColorFunction... > but I cannot work it out. Here is several possibilities among many others, using replacement rule, ColorFunction, and ColorRules. data = {{1, 0.5, 0, 0.3}, {1, 1, 0.2, 0.3}, {1, 0, 1, 0.7}}; ArrayPlot[data] (* default colors for comparison *) ArrayPlot[data /. _?(# > 0.5 &) -> Orange] ArrayPlot[data, ColorFunction -> (Hue[Clip[#, {0, 0.5}]] &)] ArrayPlot[data, ColorRules -> {_?(# > .5 &) -> Orange, _ -> Green}] ArrayPlot[data, ColorRules -> {_?(# > .5 &) -> Orange}] HTH, -- === Subject: Re: Any body can help me solve the equation with piecewise function > I have a problem to solve, but it seems not easy because of the piecewise function involved. I am wondering how we should deal with piecewise function when solving an equation or doing optimization. > > To give you an simple example, the piecewise function is f(x)= 3x if x<0; f(x)= 0 if x>=0. And I want to solve the equation f(x)+6=0. > > I actually define the piecewise function at first using Which and then try to use NSolve to solve it. However, NSolve doesn't work through. > > Anybody know how should I solve this kind of problem generally in Mathematica? Of course, for this simple example, we can divide it into two cases and then compare the solutions after solving the two cases. Yet my problem is more general and involves more than 3 piecewise functions, thus a lot of possible cases to deal with. So any command or function to deal with this kind of general problem? First, note that there exists several obvious ways to define a piecewise function in Mathematica such as *Piecewise*, *Which*, *Switch*, *If*, etc., and some less obvious ways such as *Boole*, *UnitStep*, *Clip*, *InterpolatingFunction* to name a few. Which one to choose depends on the version of Mathematica you are using, the familiarity you have with them, what you try to achieve, and also evaluation speed. Therefore, it is hard to tell what in general one should use without taking in account the problem to be solved and its context. Second, note that some solvers are designed to deal specifically with piecewise and piecewise-related function (*Reduce*, *Simplify*, *Minimize*, to name a few) whereas some others are not (*Solve* for instance). Third, note that there exists two classes of solvers --- symbolic (Solve, Reduce, DSolve, Minimize. ...) and numeric (NSolve, NSolve, NMinimize, ...) ---, each type using different algorithms and yielding exact or approximate solutions, respectively. Finally, here is an example using the function you gave in your post (the output from Mathematica have been commented out (**)). Clear[f] f[x_] := Piecewise[{{3 x, x < 0}, {0, x >= 0}}] Reduce[f[x] + 6 == 0, x] (* x == -2 *) f[x] + 6 == 0 /. ToRules@% (* True *) Solve[f[x] + 6 == 0, x] (* During evaluation of In[4]:= Solve::eqf: x<0 is not a well-formed equation. >> Solve[6 + [Piecewise] { {3 x, x < 0} } == 0, x] *) Simplify[f[x] + 6 == 0] (* 2 + x == 0 *) Solve[%, x] (* {{x -> -2}} *) Plot[f[x] + 6, {x, -10, 10}] (* ... discarded plot ... *) -- -- === Subject: Re: Any body can help me solve the equation with piecewise function >I have a problem to solve, but it seems not easy because of the >piecewise function involved. I am wondering how we should deal with >piecewise function when solving an equation or doing optimization. >To give you an simple example, the piecewise function is f(x)= 3x if >x<0; f(x)= 0 if x>=0. And I want to solve the equation f(x)+6=0. >I actually define the piecewise function at first using Which and >then try to use NSolve to solve it. However, NSolve doesn't work >through. >Anybody know how should I solve this kind of problem generally in >Mathematica? How about using Reduce? For example, In[1]:= f[x_] = Piecewise[{{3 x, x < 0}, {0, x >= 0}}]; In[2]:= Reduce[f[x] + 6 == 0, x] Out[2]= x == -2 === Subject: How to put text on a curved surface? I would like to put Mathematica on a curved surface, e.g. a torus. Can anyone help here? with friendly greetings, P_ter === Subject: optimization I'm quite new to mathematica, and I am not sure how to optimize following algorithm (see .nb in link below). Simulation generates 2 time series, and takes quite a long time to generate series for w>1000 even if you try to run the code with w0, it takes few minutes) http://staff.utia.cas.cz/barunik/optimization.nb My question is, if it is possible somehow to optimize the algorithm so Jozef === Subject: setting elements of an array based on a condition I have one array, W, which for testing purposes has 25 rows and 50 columns. There are two more things I want to accomplish with this: 1) I want to set all elements of W which are smaller than zero to zero. 2) Then I want to calculate the sum of the elements in each column of W. How can I do this? The code below shows how I get to W. Claus X = RandomReal[{0, 1}, 50]; Y = RandomReal[{0, 1}, 50]; BinWidth = 0.2; Radius = 0.2; xyzVals2 = Table[ {i/(1/BinWidth) + (BinWidth/2) , j/(1/BinWidth) + (BinWidth/2) } , {i, 0, (1/BinWidth) - 1} , {j, 0, (1/BinWidth) - 1}]; RasterPtsVals = Partition[Flatten[xyzVals2], 2] RasterX = RasterPtsVals[[All, 1]] RasterY = RasterPtsVals[[All, 2]] XDiffSq = (RasterX - a /. a -> X)^2; YDiffSq = (RasterY - b /. b -> Y)^2; Dist = Sqrt[(XDiffSq + YDiffSq)]; W = 1 - (Dist/Radius) === Subject: Re: SetOptions[Plot, BaseStyle :> myBaseStyle] does not work myBaseStyle = {FontFamily -> Helvetica}; SetOptions[Plot, BaseStyle -> myBaseStyle]; work as expected. Jens > Why doesn't the following work? myBaseStyle = {FontFamily -> Helvetica}; > SetOptions[Plot, BaseStyle :> myBaseStyle]; > Plot[Sin[x], {x, 0, 10}] It seems that myBaseStyle does not get evaluated before plotting. Is > this a bug? Using Plot[Sin[x], {x, 0, 10}, BaseStyle :> myBaseStyle] > does work. The old TextStyle option used exactly this pattern, and PerformanceGoal= > and DisplayFunction still use it. > === Subject: Re: CurrentValue CurrentValue[nb, SelectionData] where nb is the NotebookObject of the notebook you are interested in. --David http://scientificarts.com/worklife/ CurrentValue[SelectionData] works for selections in the evaluation > notebook: Button[label, > With[{repeated = ToString@CurrentValue@SelectionData}, > NotebookApply[EvaluationNotebook[], > f[ <> repeated <> , <> repeated <> ]]]] How to use CurrentValue for other notebooks than the evaluation > notebook? > CurrentValue[NotebookSelection[nb]] does not work. Hannes Kesler === Subject: Re: Request for Collective Wisdom... Here is my advice. Create a notebook template and use it as a starting point for all notebooks in mathematica. File: BasicNotebook.nb Main Title Introduction This is the introduction text Initialization If[Length[Names[Global`*]] > 0, Remove[Global`*]] Off[General::spell, General::spell1] Off[Solve::ifun] Loading Modules Needs[MyPackage`] Constants myconstantA = 123 123 Functions myfunction[x_] = x^6 + 3*x + 11 11 + 3*x + x^6 Main Body a = 107; b = N[Sqrt[a]] 10.344080432788601 Closing This is the closing remarks for the basic notebook template === Subject: Re: CurrentValue CurrentValue[SelectionData] works for selections in the evaluation > notebook: Button[label, > With[{repeated = ToString@CurrentValue@SelectionData}, > NotebookApply[EvaluationNotebook[], > f[ <> repeated <> , <> repeated <> ]]]] How to use CurrentValue for other notebooks than the evaluation > notebook? > CurrentValue[NotebookSelection[nb]] does not work. Hannes Kesler For a palette, you would do it like this... CreatePalette@ Button[label, With[{repeated = ToString[CurrentValue[InputNotebook[], SelectionData]]}, NotebookApply[InputNotebook[], f[ <> repeated <> , <> repeated <> ]]]] You can't use InputNotebook[] in a regular notebook because the act of clicking on the button will make the notebook containing the button the InputNotebook[]. Palettes don't have this property. But, of course, it would work fine for any explicit NotebookObject[]. John Fultz jfultz@wolfram.com User Interface Group Wolfram Research, Inc. === Subject: Re: Display commands in a package >> You can do the following: >> << BarCharts` >> ?BarCharts`* > V6.02 XP machine. With a fresh kernel this works ok - no error messages. > << BarCharts` But in response to this line > ?BarCharts`* I get: Syntax::sntxf: ? cannot be followed by BarCharts`*. Syntax::tsntxi: BarCharts`* is incomplete; more input is > needed. Syntax::sntxi: Incomplete expression; more input is needed. Do you have any thoughts on why my machine won't respond > Just to clarify: I thought you were asking about listing symbols in a package, and _not_ loading a package. I made a mistake here. Instead of >> << BarCharts`* I meant ? BarCharts`* which lists all symbols in the BarCharts context. >> or >> Information[BarCharts`*] >> instead. > work either. But I stumbled into a line that does work: > > Needs[BarCharts`] > > This is just one of the peculiar things about my > installation; no idea why commands others use don't work > === Subject: Expression manipulation When trying to simplify an expression by hand, one carries out various kinds of steps: 1. Replace a subexpression that occurs repeatedly by a single symbol. 2. Multiply numerator and denominator of some subexpression by the same factor. 3. Cancel particular factors in numerator and denominator of some subexpression. 4. Gather together two subexpressions that were added together, and rewrite with a common denominator. 5. Remove common factors. etc. etc. etc. Using Part, one can of course access any particular subexpression. But this is time-consuming and clumsy. I find that I need trial and error to access the correct subexpression. Once I've accessed it, I often have difficulty in persuading Mathematica to perform the desired operation. And then I have trouble putting the subexpression back into place. It's something like 20 times slower than working with pencil and paper. HOWEVER pencil and paper calculations are more prone to stupid arithmetic errors, particularly if the computation is a long one. I have been unable to find a convenient way of doing this in Mathematica. I use version 5.2, but because of my University's site license, I have access to more recent versions. Would it help to change? Can anyone point me to a tutorial where experts use Mathematica to do a typical pencil and paper computation? don't look at the newsgroup very often. David === Subject: Re: Expression manipulation David, You should be able to do all the manipulations using Mathematica. You should learn how to use rule based programming, commands such as MapAt, Apart, Together, Cancel. HoldForm and of course Simplify. Still, Mathematica is often very theoretically oriented and lacks some of the practical operations often used. The Presentations package, at my web site below, has a 'Manipulations' section that contains some practical additions. Sometimes these are useful in manipulating expressions and sometimes useful to get expressions in particular standard forms for display in reports or to match a textbook expression. If you want to keep a particular subexpression together as a unit you can wrap it in a HoldForm. This prevents routines like Simplify from splitting it up. Presentations has a CreateSubexpression and a ReleaseSubexpressions routines that allow you to wrap a subexpression in a tagged Tooltip. This works just as well as a HoldForm and allows you to see what the subexpressions are. FactorOut can be used to remove a factor from an expression - even if the factor is not initially in the expression. For example, you can pull a factor out of a matrix and wrap the matrix in a HoldForm all in one operation. MultiplyByOne will multiply the numerator and denominator of an expression by the same factor and Simplify, or perform any other specified operations MapLevelParts and MapLevelPatterns will map an operation onto a subset of level parts in an expression. The most common use is to apply some function to a selected subset of terms in a sum. LinearBreakout[f1,f2,...][v1,v2,..][expr] will break out the linear terms of any expressions within expr that have heads matching the patterns fi over variables matching the patterns vj. PushOnto is a much improved version of the Through command that will push a list of arguments onto specific functions. HoldOp[operation][expr] will prevent an explicit operation in expr from being evaluated but will evaluate the arguments of the operation. It is useful when operation has a number of definitions with it, but you want to see what the expression looks like before these definitions are applied. EvaluateAtPattern will evaluate specific patterns in held expressions. Here is an example of using some of these routines to manipulate an expression as you might do it 'by hand': a + b + c % // MapLevelParts[CreateSubexpression, {{1, 3}}] d % // Expand % // FactorOut[sub] % // ReleaseSubexpressions[] a + b + c b + (a + c) where (a+c) has a tag and Tooltip 'held'. b d+d (a + c) where d did not Distribute across the subexpression. (d+(b d)/(a+c)) (a+c) factoring out the subexpression (a+c), even though it is not a true 'factor'. (a+c) (d+(b d)/(a+c)) releasing the subexpression keeps the overall structure. Finally, I might mention the annoying tendency of Mathematica to get more minus signs into standard expressions than you might wish. One way to correct this is just to Map Minus onto two factors in a product. For example: 3 - a (c - b) MapAt[Minus, %, {{2, 1}, {2, 3}}] 3 - a (-b + c) 3 + a (b - c) -- David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ > When trying to simplify an expression by hand, one carries out various > kinds of steps: > 1. Replace a subexpression that occurs repeatedly by a single symbol. > 2. Multiply numerator and denominator of some subexpression by the > same factor. > 3. Cancel particular factors in numerator and denominator of some > subexpression. > 4. Gather together two subexpressions that were added together, and > rewrite with a common denominator. > 5. Remove common factors. etc. etc. etc. Using Part, one can of course access any particular subexpression. But > this is time-consuming and clumsy. I find that I need trial and error > to access the correct subexpression. Once I've accessed it, I often > have difficulty in persuading Mathematica to perform the desired > operation. And then I have trouble putting the subexpression back into > place. It's something like 20 times slower than working with pencil > and paper. HOWEVER pencil and paper calculations are more prone to > stupid arithmetic errors, particularly if the computation is a long > one. I have been unable to find a convenient way of doing this in > Mathematica. I use version 5.2, but because of my University's site > license, I have access to more recent versions. Would it help to > change? Can anyone point me to a tutorial where experts use Mathematica to do > a typical pencil and paper computation? don't look at the newsgroup very often. David > === Subject: Re: Expression manipulation You might find David Park's no-cost Expression Manipulation package useful. It includes a nice tutorial notebook on its use. (If you're running it with Mathematica 6.0, you'll need to let the Version Advisory scan locate two places in the tutorial notebook that need the compatibility updating it suggests.) Another possibility, although not no-cost, is Park's big Presentations bundle. It includes a Manipulations package that includes, I believe, some or all of the functionality of that Expression Manipulation package. Among the dozen or so functions it defines or extends are: CompleteTheSquare FactorOut MultiplyByOne This last directly accomplishes one of the tasks you listed -- multiplying numerator and denominator by the same quantity. For both, see: http://home.comcast.net/~djmpark/Mathematica.html > When trying to simplify an expression by hand, one carries out various > kinds of steps: > 1. Replace a subexpression that occurs repeatedly by a single symbol. > 2. Multiply numerator and denominator of some subexpression by the > same factor. > 3. Cancel particular factors in numerator and denominator of some > subexpression. > 4. Gather together two subexpressions that were added together, and > rewrite with a common denominator. > 5. Remove common factors. > > etc. etc. etc. > > Using Part, one can of course access any particular subexpression. But > this is time-consuming and clumsy. I find that I need trial and error > to access the correct subexpression. Once I've accessed it, I often > have difficulty in persuading Mathematica to perform the desired > operation. And then I have trouble putting the subexpression back into > place. It's something like 20 times slower than working with pencil > and paper. HOWEVER pencil and paper calculations are more prone to > stupid arithmetic errors, particularly if the computation is a long > one. > > I have been unable to find a convenient way of doing this in > Mathematica. I use version 5.2, but because of my University's site > license, I have access to more recent versions. Would it help to > change? > > Can anyone point me to a tutorial where experts use Mathematica to do > a typical pencil and paper computation? > > don't look at the newsgroup very often. > > David > -- 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 fax 413 545-1801 Amherst, MA 01003-9305 === Subject: Re: Expression manipulation Hello David, I believe there is a tutorial approximately titled Simplifying Expressions in the documentation for 5.2. Your items 2-5 can be done automatically by methods described in that tutorial . The expression you get may not be exactly the form you would choose when using pencil and paper. Item 1 requires a longer answer and a bit more finesse. Replacements of subexpressions can be done with Replace and Rules. However, for not-very-long expressions, you can copy paste the entire expression and then select and over-write subexpressions. I don't like this second method so much because it is prone to mistakes---and a bad habit to break---so I recommend looking at the Rule-Replace methods. Craig > When trying to simplify an expression by hand, one carries out various > kinds of steps: > 1. Replace a subexpression that occurs repeatedly by a single symbol. > 2. Multiply numerator and denominator of some subexpression by the > same factor. > 3. Cancel particular factors in numerator and denominator of some > subexpression. > 4. Gather together two subexpressions that were added together, and > rewrite with a common denominator. > 5. Remove common factors. etc. etc. etc. Using Part, one can of course access any particular subexpression. But > this is time-consuming and clumsy. I find that I need trial and error > to access the correct subexpression. Once I've accessed it, I often > have difficulty in persuading Mathematica to perform the desired > operation. And then I have trouble putting the subexpression back into > place. It's something like 20 times slower than working with pencil > and paper. HOWEVER pencil and paper calculations are more prone to > stupid arithmetic errors, particularly if the computation is a long > one. I have been unable to find a convenient way of doing this in > Mathematica. I use version 5.2, but because of my University's site > license, I have access to more recent versions. Would it help to > change? Can anyone point me to a tutorial where experts use Mathematica to do > a typical pencil and paper computation? don't look at the newsgroup very often. David -- W. Craig Carter === Subject: Re: Expression manipulation > When trying to simplify an expression by hand, one carries out various > kinds of steps: > 1. Replace a subexpression that occurs repeatedly by a single symbol. > 2. Multiply numerator and denominator of some subexpression by the > same factor. > 3. Cancel particular factors in numerator and denominator of some > subexpression. > 4. Gather together two subexpressions that were added together, and > rewrite with a common denominator. > 5. Remove common factors. > > etc. etc. etc. > > Using Part, one can of course access any particular subexpression. But > this is time-consuming and clumsy. I find that I need trial and error > to access the correct subexpression. Once I've accessed it, I often > have difficulty in persuading Mathematica to perform the desired > operation. And then I have trouble putting the subexpression back into > place. It's something like 20 times slower than working with pencil > and paper. HOWEVER pencil and paper calculations are more prone to > stupid arithmetic errors, particularly if the computation is a long > one. > > I have been unable to find a convenient way of doing this in > Mathematica. I use version 5.2, but because of my University's site > license, I have access to more recent versions. Would it help to > change? > > Can anyone point me to a tutorial where experts use Mathematica to do > a typical pencil and paper computation? > I prefer pen and paper to Mathematica when manipulating simple expressions. Mathematica is useful when working with large expressions, e.g. high-order polynomials or rational functions, etc. Don't use Part during interactive work. Instead take a look at ReplaceAll, Together, Expand, ExpandAll, Cancel, etc. Or just copy and paste when you need to extract a particular subexpression. http://reference.wolfram.com/mathematica/guide/FormulaManipulation.html > don't look at the newsgroup very often. This just tells us that you don't really care about the reply ... so fewer people will bother to answer ... === Subject: Re: PlotLegend not working properly in my Mathematica 6 I did evaluate Needs[PlotLegends`] first but it still didn't work. My version is 6.0.0. === Subject: Re: issues with unit package I encountered most of the questions discussed here several years ago and implemented an extension to the combined Units, PhysicalConstants and Notation packages called Accelerator`ConstantsUnits`. Among other things, it contains a function ToFundamentalSI which reduces all expressions containing units to a (unique) canonical form in terms of the four fundamental SI units. In the process it replaces things like Sqrt[Meter^2] by Meter but without doing a PowerExpand on the full expression. This has been implemented in the upgrade of the package for Mathematica Version 6. Version 4.0 of the package (for Mathematica V6) is essentially complete and can be obtained from me on request by email. I will release it more generally when I get time. John Jowett > Why won't Mathematica when using the Units package eliminate reciprocal = units? Consider an example from E&M, finding the wavelength correspondin= g to a frequency: > < < In[1]:= > Freq=100*^6 Hertz; > Wavelength=SpeedOfLight/Freq > Out[1]=(149896229*Meter)/(50000000*Hertz*Second) > In[2]:=N[Wavelength] > Out[2]=(0.299792*Meter)/(Hertz*Second) > i.e. Mathematica doesn't know that Meter/(Hertz Second) should reduce to= Meter. Shouldn't this be handled? > Another example; shouldn't Mathematica reduce expressions in consistent = units to a single result? Example: > In[5]:=3 Ohm + 1 Volt/Ampere > Out[5] = 3 Ohm + 1 Volt/Ampere > Why not 4 Ohm, or 4 Volt/Ampere? After all, the documentation entry = for Ohm says it's equivalent to Volt / Ampere, so it's reasonable that Mathe= matica would be aware of that relationship. Doing SI[] or MKS[] on those = expressions doesn't change anything. > Maybe the Units package doesn't extend to manipulating variables with qu= antities that have units. Am I missing something here? I don't think that a completely automatic reduction of units would be > possible. But it would be nice if the Units package provided a function= > to convert units to one or more canonical forms. This will work in many (but not all) cases: toCanonical[expr_] := SI[expr] //. Units`Private`$ToFundamental In[5]:= toCanonical[3 Ohm + 1 Volt/Ampere] > Out[5]= (4 Kilogram Meter^2)/(Ampere^2 Second^3) In[6]:= toCanonical[(0.299792*Meter)/(Hertz*Second)] > Out[6]= 0.299792 Meter It is not always clear what the appropriate unit is in certain > situations. For example what is the appropriate unit for the torque? > Joule is certainly correct dimensionally, but is it reasonable to use it?-= Hide quoted text - - Show quoted text - === Subject: Re: Region for ListPlot3D > Below I give a set of 3D points and attempt to plot them as a surface > using ListPlot3D. I also plot the points directly using Graphics3D. > The data fill a region that is approximately a trapezium except that > one side is concave. ListPlot3D extrapolates the concave side out to > the convex hull of the x -y coordinates thus giving a false impression > of the surface. How can I make the plotting region conform to the data > and exclude the extrapolation? > I just noticed that you have a regular matrix of 3D points. What you really need is not ListPlot3D, but a ListParametricPlot3D, that AFAIK does not exist. So here's a very simple implementation: listParametricPlot3D[points_, opt___?OptionQ] := Module[{xx, yy}, {yy, xx} = Take[Dimensions[points], 2]; Graphics3D[GraphicsComplex[Join @@ points, Polygon[ Join @@ Table[{1 + i + xx j, 2 + i + xx j, 2 + i + xx (j + 1), 1 + i + xx (j + 1)}, {j, 0, yy - 2}, {i, 0, xx - 2}] ]], opt] ] Fancy stuff like VertexNormals or interpolation is not handled. listParametricPlot3D[pp] will create the plot you're looking for. Here's another example: listParametricPlot3D[ Table[{Cos[u] Cos[v], Cos[u] Sin[v], Sin[u]}, {u, -Pi/2, Pi/2, Pi/14}, {v, 0, 2 Pi, 2 Pi/28}], Boxed -> False, SphericalRegion -> True ] > > pp = {{{0, 0, 0}, {5, 0, 0}, > {10, 0, 0}, {14, 0, 0}, > {19, 0, 0}, {24, 0, 0}, > {29, 0, 0}, {33, 0, 0}, > {38, 0, 0}, {43, 0, 0}, > {48, 0, 0}}, > {{0, 53, 3}, {5, 53, 3}, > {10, 53, 3}, {14, 53, > 3}, {19, 53, 3}, > {24, 53, 3}, {29, 53, > 3}, {33, 53, 3}, > {38, 53, 3}, {43, 53, > 3}, {48, 53, 3}}, > {{0, 107, 18}, {5, 107, > 19}, {10, 107, 19}, > {14, 107, 19}, > {19, 107, 19}, > {24, 107, 18}, > {29, 107, 18}, > {33, 107, 18}, > {38, 107, 18}, > {43, 107, 18}, > {48, 107, 18}}, > {{0, 160, 81}, {5, 160, > 81}, {10, 160, 81}, > {15, 160, 80}, > {20, 160, 80}, > {25, 160, 80}, > {30, 160, 80}, > {35, 160, 79}, > {40, 160, 79}, > {45, 160, 79}, > {50, 160, 79}}, > {{0, 213, 142}, > {6, 213, 142}, > {12, 213, 141}, > {18, 213, 141}, > {25, 213, 140}, > {31, 213, 140}, > {37, 213, 140}, > {43, 213, 139}, > {49, 213, 139}, > {56, 213, 138}, > {62, 213, 138}}, > {{0, 267, 93}, {9, 267, > 93}, {18, 267, 93}, > {27, 267, 93}, > {36, 267, 93}, > {45, 267, 93}, > {54, 267, 92}, > {63, 267, 92}, > {72, 267, 91}, > {82, 267, 91}, > {91, 267, 90}}, > {{0, 320, 60}, {13, 320, > 60}, {26, 320, 60}, > {40, 320, 60}, > {53, 320, 59}, > {66, 320, 59}, > {79, 320, 58}, > {92, 320, 58}, > {105, 320, 58}, > {118, 320, 58}, > {132, 320, 57}}, > {{0, 373, 40}, {18, 373, > 40}, {36, 373, 40}, > {54, 373, 40}, > {72, 373, 40}, > {90, 373, 40}, > {108, 373, 40}, > {126, 373, 40}, > {144, 373, 40}, > {162, 373, 40}, > {180, 373, 40}}, > {{0, 427, 29}, {23, 427, > 29}, {47, 427, 29}, > {70, 427, 29}, > {93, 427, 29}, > {116, 427, 29}, > {140, 427, 29}, > {163, 427, 28}, > {186, 427, 28}, > {210, 427, 28}, > {233, 427, 28}}, > {{0, 480, 22}, {29, 480, > 22}, {58, 480, 22}, > {87, 480, 22}, > {116, 480, 22}, > {145, 480, 22}, > {174, 480, 22}, > {203, 480, 22}, > {232, 480, 22}, > {260, 480, 22}, > {289, 480, 22}}, > {{0, 533, 17}, {35, 533, > 17}, {70, 533, 17}, > {104, 533, 17}, > {139, 533, 17}, > {174, 533, 17}, > {209, 533, 17}, > {244, 533, 17}, > {278, 533, 17}, > {313, 533, 17}, > {348, 533, 17}}}; === Subject: Re: Region for ListPlot3D Hello Hugh, I can't see how ListPlot3D isn't doing what you wish--sorry if I am missing something obvious. viz: ppf = Flatten[pp, 1] gc = GraphicsComplex[ppf, Table[Sphere[i, 5], {i, Length[ppf]}]]; g1 = Graphics3D[{Orange, gc}] g2 = ListPlot3D[ppf] Show[g2, g1] g3 = ListPlot3D[Flatten[pp, 1], InterpolationOrder -> 3] Show[g3, g1] WCC > Below I give a set of 3D points and attempt to plot them as a surface > using ListPlot3D. I also plot the points directly using Graphics3D. > The data fill a region that is approximately a trapezium except that > one side is concave. ListPlot3D extrapolates the concave side out to > the convex hull of the x -y coordinates thus giving a false impression > of the surface. How can I make the plotting region conform to the data > and exclude the extrapolation? > pp = {{{0, 0, 0}, {5, 0, 0}, > {10, 0, 0}, {14, 0, 0}, : : > {348, 533, 17}}}; g1 = Graphics3D[{Point[Flatten[pp, 1]]}, > PlotRange -> All] g2 = ListPlot3D[Flatten[pp, 1]] Show[g1, g2] > -- W. Craig Carter === Subject: Re: Region for ListPlot3D > Below I give a set of 3D points and attempt to plot them as a surface > using ListPlot3D. I also plot the points directly using Graphics3D. > The data fill a region that is approximately a trapezium except that > one side is concave. ListPlot3D extrapolates the concave side out to > the convex hull of the x -y coordinates thus giving a false impression > of the surface. How can I make the plotting region conform to the data > and exclude the extrapolation? > > > Hugh Goyder > > > pp = {{{0, 0, 0}, {5, 0, 0}, > {10, 0, 0}, {14, 0, 0}, > {19, 0, 0}, {24, 0, 0}, > {29, 0, 0}, {33, 0, 0}, > {38, 0, 0}, {43, 0, 0}, > {48, 0, 0}}, > {{0, 53, 3}, {5, 53, 3}, > {10, 53, 3}, {14, 53, > 3}, {19, 53, 3}, > {24, 53, 3}, {29, 53, > 3}, {33, 53, 3}, > {38, 53, 3}, {43, 53, > 3}, {48, 53, 3}}, > {{0, 107, 18}, {5, 107, > 19}, {10, 107, 19}, > {14, 107, 19}, > {19, 107, 19}, > {24, 107, 18}, > {29, 107, 18}, > {33, 107, 18}, > {38, 107, 18}, > {43, 107, 18}, > {48, 107, 18}}, > {{0, 160, 81}, {5, 160, > 81}, {10, 160, 81}, > {15, 160, 80}, > {20, 160, 80}, > {25, 160, 80}, > {30, 160, 80}, > {35, 160, 79}, > {40, 160, 79}, > {45, 160, 79}, > {50, 160, 79}}, > {{0, 213, 142}, > {6, 213, 142}, > {12, 213, 141}, > {18, 213, 141}, > {25, 213, 140}, > {31, 213, 140}, > {37, 213, 140}, > {43, 213, 139}, > {49, 213, 139}, > {56, 213, 138}, > {62, 213, 138}}, > {{0, 267, 93}, {9, 267, > 93}, {18, 267, 93}, > {27, 267, 93}, > {36, 267, 93}, > {45, 267, 93}, > {54, 267, 92}, > {63, 267, 92}, > {72, 267, 91}, > {82, 267, 91}, > {91, 267, 90}}, > {{0, 320, 60}, {13, 320, > 60}, {26, 320, 60}, > {40, 320, 60}, > {53, 320, 59}, > {66, 320, 59}, > {79, 320, 58}, > {92, 320, 58}, > {105, 320, 58}, > {118, 320, 58}, > {132, 320, 57}}, > {{0, 373, 40}, {18, 373, > 40}, {36, 373, 40}, > {54, 373, 40}, > {72, 373, 40}, > {90, 373, 40}, > {108, 373, 40}, > {126, 373, 40}, > {144, 373, 40}, > {162, 373, 40}, > {180, 373, 40}}, > {{0, 427, 29}, {23, 427, > 29}, {47, 427, 29}, > {70, 427, 29}, > {93, 427, 29}, > {116, 427, 29}, > {140, 427, 29}, > {163, 427, 28}, > {186, 427, 28}, > {210, 427, 28}, > {233, 427, 28}}, > {{0, 480, 22}, {29, 480, > 22}, {58, 480, 22}, > {87, 480, 22}, > {116, 480, 22}, > {145, 480, 22}, > {174, 480, 22}, > {203, 480, 22}, > {232, 480, 22}, > {260, 480, 22}, > {289, 480, 22}}, > {{0, 533, 17}, {35, 533, > 17}, {70, 533, 17}, > {104, 533, 17}, > {139, 533, 17}, > {174, 533, 17}, > {209, 533, 17}, > {244, 533, 17}, > {278, 533, 17}, > {313, 533, 17}, > {348, 533, 17}}}; > > g1 = Graphics3D[{Point[Flatten[pp, 1]]}, > PlotRange -> All] > > g2 = ListPlot3D[Flatten[pp, 1]] > > Show[g1, g2] This is a pretty nasty way of doing it, but at least it works ... Show[ListPlot3D[#, Mesh -> None] & /@ (Join @@ # & /@ Partition[pp, 2, 1]), PlotRange -> All] === Subject: plot primes only hi everyone! a quick one: how can i tell mathematica to only list the primes from a list of data and omit the others? primeQ only tells me the boolean result thanx markus www.humanchaos.net === Subject: Re: plot primes only Hello Marcus, This may what you are looking for: data = Range[10] primesdata = Select[data, PrimeQ] Or this, data = Table[{i, Log[i]}, {i, 1, 100000}]; primesdata = Select[data, PrimeQ[#[[1]]] &]; ListPlot[primesdata] Craig > hi everyone! a quick one: > how can i tell mathematica to only list the primes from a list of data > and omit the others? > primeQ only tells me the boolean result > thanx > markus www.humanchaos.net -- W. Craig Carter === Subject: Re: plot primes only In[695] = list = Table[i, {i, 1, 100}]; In[690]= Select[list, PrimeQ[# ] &] Out[690]= {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97} Tom Dowling > hi everyone! a quick one: > how can i tell mathematica to only list the primes from a list of data > and omit the others? > primeQ only tells me the boolean result > thanx > markus www.humanchaos.net === Subject: Re: plot primes only > hi everyone! > > a quick one: > how can i tell mathematica to only list the primes from a list of data > and omit the others? > primeQ only tells me the boolean result > > Select[list, PrimeQ] === Subject: Re: plot primes only data = Select[Table[i, {i, 1, 100}], PrimeQ] ?? Jens > hi everyone! > > a quick one: > how can i tell mathematica to only list the primes from a list of data > and omit the others? > primeQ only tells me the boolean result > > > thanx > markus > > www.humanchaos.net > === Subject: export mathematica table to .mat (MATLAB) format.Please help!!! I have created a Table in Mathematica but I have found it very difficult to export it in the ,mat format. The table has the following form: {0.275467} {-0.00287361+0.31966i0.00135455,-0.00174298+0.316246i} and so on..... I then use the follwing command Export[file.mat, Out[6]] but It fails to export the table. I would appreciate anyone's help Alex === Subject: Re: export mathematica table to .mat (MATLAB) format.Please help!!! > > I have created a Table in Mathematica but I have found it very difficult to export it in the ,mat format. The table has the following form: > > {0.275467} > {-0.00287361+0.31966i0.00135455,-0.00174298+0.316246i} > and so on..... > > I then use the follwing command Export[file.mat, Out[6]] but It fails to export the table. > > I would appreciate anyone's help > The imaginary unit is written as I in Mathematica (not i). === Subject: Re: Testing TOC sidebar palette Me too. Same error message. Tom Dowling > Did you forget to make those files public? I'm getting a 404 Not Found > error when I try the URLs. > Hi group, > > Sometimes ago there was question about creating TOC of the notebook. > David Reiss gave a hint of using CellID for these purposes. Based on > this idea I have developed a sidebar TOC palette where I also include > several tasks typical for my work. Could you please inform me if it is > convenient to use it and what kind of extra tasks should be added to > the palette? > > Main properties of palette include: > - Generation of Table of Contents for any currently selected notebook > - Additional selection instrument for extra tasks. Current version > supports locking/unlocking cells to block cells from accidental > editing and deleting > - Tracing graphics coordinates. (It also launches an additional tool > GraphicsCoordinates. Note, the Graphics object must be selected to > activate this button) > - Tracing evaluation time > - Running everyday notebooks in save mode (with cell options > Delatable and Editable set to False) > - Few additional actions: comparing two cells in the notebook, > evaluating the whole section etc. > > The files can be downloaded from: > http://www.spinalgebra.com/sidebar/graphicscoordinates.zip > http://www.spinalgebra.com/sidebar/sidebar.zip > > -- > 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 fax 413 545-1801 > Amherst, MA 01003-9305 === Subject: Re: Testing TOC sidebar palette Did you forget to make those files public? I'm getting a 404 Not Found error when I try the URLs. > Hi group, > > Sometimes ago there was question about creating TOC of the notebook. > David Reiss gave a hint of using CellID for these purposes. Based on > this idea I have developed a sidebar TOC palette where I also include > several tasks typical for my work. Could you please inform me if it is > convenient to use it and what kind of extra tasks should be added to > the palette? > > Main properties of palette include: > - Generation of Table of Contents for any currently selected notebook > - Additional selection instrument for extra tasks. Current version > supports locking/unlocking cells to block cells from accidental > editing and deleting > - Tracing graphics coordinates. (It also launches an additional tool > GraphicsCoordinates. Note, the Graphics object must be selected to > activate this button) > - Tracing evaluation time > - Running everyday notebooks in save mode (with cell options > Delatable and Editable set to False) > - Few additional actions: comparing two cells in the notebook, > evaluating the whole section etc. > > The files can be downloaded from: > http://www.spinalgebra.com/sidebar/graphicscoordinates.zip > http://www.spinalgebra.com/sidebar/sidebar.zip > -- 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 fax 413 545-1801 Amherst, MA 01003-9305 === Subject: Re: Testing TOC sidebar palette Did you forget to make those files public? I'm getting a 404 Not Found error when I try the URLs. > Hi group, > > Sometimes ago there was question about creating TOC of the notebook. > David Reiss gave a hint of using CellID for these purposes. Based on > this idea I have developed a sidebar TOC palette where I also include > several tasks typical for my work. Could you please inform me if it is > convenient to use it and what kind of extra tasks should be added to > the palette? > > Main properties of palette include: > - Generation of Table of Contents for any currently selected notebook > - Additional selection instrument for extra tasks. Current version > supports locking/unlocking cells to block cells from accidental > editing and deleting > - Tracing graphics coordinates. (It also launches an additional tool > GraphicsCoordinates. Note, the Graphics object must be selected to > activate this button) > - Tracing evaluation time > - Running everyday notebooks in save mode (with cell options > Delatable and Editable set to False) > - Few additional actions: comparing two cells in the notebook, > evaluating the whole section etc. > > The files can be downloaded from: > http://www.spinalgebra.com/sidebar/graphicscoordinates.zip > http://www.spinalgebra.com/sidebar/sidebar.zip > -- 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 fax 413 545-1801 Amherst, MA 01003-9305 === Subject: Re: export mathematica table to .mat (MATLAB) format.Please help!!! I am aware of this. I simply changed it to make the text more readable. This is because I copy pasted the values directly from the table in this box. The first few entries is simply an example of the Table as I see it. I have also used the command MatrixForm[%]. Now when I try to export this it fails. HELP PLEASE!!!!!!!! So a different sample of what I see follows: { {{0.272409}}, {{0.132711+ 0.231672 [ImaginaryI], 0.221351, -0.130221 + 0.226132 [ImaginaryI]}} } I then use MatrixForm[%] I then use Export[file.mat, Out[6]] and it fails.WHY??? Alex === Subject: Asking NonlinearRegression I have a problem with nonlinear regression in Mathematica. I want to fit my data (below) to this following equation: y = Exp[(1-Exp[a*(1-Exp[-b*x])])*(Exp[-b*x])/(1-Exp[-b*x])] and I would like to find a and b values and also determined r-squared value. I try to use NonlinearRegression/NonlinearFit code, but its not working, I hope someone could help me DATA: x y 1 0.00 2 0.00 3 0.00 4 0.00 5 0.00 6 0.00 7 0.00 8 0.00 9 0.00 10 0.00 11 0.00 12 0.00 13 0.00 14 0.00 15 0.00 16 0.00 17 0.00 18 0.00 19 0.00 20 0.00 21 0.00 22 0.00 23 0.00 24 0.00 25 0.00 26 0.00 27 0.00 28 0.00 29 0.00 30 0.00 31 0.00 32 0.00 33 0.00 34 0.00 35 0.00 36 0.00 37 0.00 38 0.00 39 0.00 40 0.00 42 0.00 44 0.00 46 0.00 48 0.00 50 0.00 52 0.04 54 0.06 56 0.08 58 0.09 60 0.16 65 0.24 70 0.32 75 0.43 80 0.49 85 0.58 90 0.80 95 0.91 100 1.00 105 1 Rgds, Navri === Subject: Re: plot primes only >a quick one: how can i tell mathematica to only list the primes from >a list of data and omit the others? primeQ only tells me the boolean >result There are a number of ways to do this. For example, In[1]:= Cases[Range@10, _?PrimeQ] Out[1]= {2,3,5,7} or In[2]:= Select[Range@10, PrimeQ] Out[2]= {2,3,5,7} === Subject: RenderBadPicture error while running Mathematica 6 on Linux Hi all, I am getting an error while running Mathematica 6 on my Linux machine. The details of the error is as follows. Please help me out if you know the solution. X Error of failed request: RenderBadPicture (invalid Picture parameter) Major opcode of failed request: 154 (RENDER) Minor opcode of failed request: 7 (RenderFreePicture) Picture id in failed request: 0x2a09632 Serial number of failed request: 382906 Current serial number in output stream: 382909 X Error of failed request: BadMatch (invalid parameter attributes) Major opcode of failed request: 154 (RENDER) Minor opcode of failed request: 4 (RenderCreatePicture) Serial number of failed request: 383763 Current serial number in output stream: 383766 Kishan. === Subject: cell convert to Some of my students have a strange problem, and I cannot find the solution. In the menu Cell, Convert To, they don't have StandardForm and TraditionalForm (ctrl+shift+n and ctrl+shift+t also don't work). Is there a way to install these settings? Florian Jaccard === Subject: Applying the Integration Function to a List Of Regions Assume that I have already determined a list of 4 dimensional regions as follows: regions={{{x,0,a},{cx,0,a+x},{y,0,Sqrt[a^2-cx^2+2 cx a-Sqrt[a^2-cx^2+2 cx x-x^2]},{cy,-Sqrt[a^2-cx^2+2 cx a-Sqrt[a^2-cx^2+2 cx x-x^2],2 a},{cy,-Sqrt[a^2-cx^2+2 cx x-x^2]+y,2 a}},{{x,a,2 a},{cx,-a+x,2 a},{y,0,Sqrt[a^2-cx^2+2 cx a},{y,Sqrt[a^2-cx^2+2 cx x-x^2],2 a-Sqrt[a^2-cx^2+2 cx a},{cy,-Sqrt[a^2-cx^2+2 cx x-x^2]+y,2 a}}}; I want to integrate over each of these regions using an integrand of 1. I want my output to be as follows: {Integrate[1,{x,0,a},{cx,0,a+x},{y,0,Sqrt[a^2-cx^2+2 cx a-Sqrt[a^2-cx^2+2 cx x-x^2]},{cy,-Sqrt[a^2-cx^2+2 cx a-Sqrt[a^2-cx^2+2 cx x-x^2],2 a},{cy,-Sqrt[a^2-cx^2+2 cx x-x^2]+y,2 a}],Integrate[1,{x,a,2 a},{cx,-a+x,2 a},{y,0,Sqrt[a^2-cx^2+2 cx a},{y,Sqrt[a^2-cx^2+2 cx x-x^2],2 a-Sqrt[a^2-cx^2+2 cx How can I do that without having to set up each of the integrals manually? I am looking for some way to do something like: Integrate @@ regions or Integrate @@@ regions But I can't figure out how to incorporate the 1 as the integrand when I try to set this up automatically. There must be a way? John === Subject: Re: Expression manipulation I'm no expert at this, but I've seen other experts within Wolfram using the AlgebraicManipulation palette to do simplifications on pieces of a large expression similar to the ones you describe. Basically, they select a piece by hand, apply the appropriate button from the palette, possibly re-evaluate to combine like terms and/or save the current state of the expression, and iterate again with the palette until they're satisfied. To aid in this, you may find structured selection in the user interface useful. The user interface is aware of the structure of expressions and responds to multi-clicking by selecting successively larger structurally complete elements (important since the buttons in the palette would fail on structurally incomplete elements). For example, double-clicking on an open or close parenthesis will select the entire parenthesized contents. Double-click-drag from there will then allow you to drag-select neighboring terms in their entirety. Triple-click, quadruple-click, quintuple-click, and so on from any given point will select successively larger structural elements. It's difficult to explain in words, but easy to understand once you've observed it in action, so feel free to experiment. The AlgebraicManipulation palette is available in both 5.2 and 6.0. John Fultz jfultz@wolfram.com User Interface Group Wolfram Research, Inc. > When trying to simplify an expression by hand, one carries out various > kinds of steps: > 1. Replace a subexpression that occurs repeatedly by a single symbol. > 2. Multiply numerator and denominator of some subexpression by the > same factor. > 3. Cancel particular factors in numerator and denominator of some > subexpression. > 4. Gather together two subexpressions that were added together, and > rewrite with a common denominator. > 5. Remove common factors. etc. etc. etc. Using Part, one can of course access any particular subexpression. But > this is time-consuming and clumsy. I find that I need trial and error > to access the correct subexpression. Once I've accessed it, I often > have difficulty in persuading Mathematica to perform the desired > operation. And then I have trouble putting the subexpression back into > place. It's something like 20 times slower than working with pencil > and paper. HOWEVER pencil and paper calculations are more prone to > stupid arithmetic errors, particularly if the computation is a long > one. I have been unable to find a convenient way of doing this in > Mathematica. I use version 5.2, but because of my University's site > license, I have access to more recent versions. Would it help to > change? Can anyone point me to a tutorial where experts use Mathematica to do > a typical pencil and paper computation? don't look at the newsgroup very often. David === Subject: Multiple clipboards It can be very useful to save multiple items to a clipboard so that any one of them can be chosen and pasted in later. I am using an Intel Mac with OS 10.5.2. The two utilities I have that ordinarily do this are: iClipboard and CopyPaste. Neither of these works with my Mathematica 6.0.1. I can only paste the most recent item I have copied in Mathematica. Is there a utility or method that would permit multiple clipboard items. Paul === Subject: Re: Eigenvalues Okay, Eigenvectors Fail Okay, a week later, I can answer my own question for the benefit of someone else someday, perhaps. To recap, I had a large (n = 733), square (n x n), real matrix, mSub, and asked why, if I could find eigenvalues in short order, my computer could not find the eigenvectors? Such that, A. Timing@Eigenvalues[mSub] = {2 Second, l}, where l is a list of eigenvalues of length n, but, B. Eigenvectors[mSub] does not complete. Anyway, I still do not completely understand what is happening, but I get the sense that Mathematica was simply not converging to an answer quickly with the default settings for the function Eigenvectors. Reading Trott, Mathematica Guidebook for Numerics, chapter 1.4, and later Mathematica Help, Advanced Documentation - Linear Algebra, I learned of some obscure options for the function Eigenvectors, and set up the following function which runs quickly and provides the kind of answers I need: Eigensystem[mSub, 4, Method->{Arnoldi, Criteria->BothEnds, MaxIterations->10^3, Tolerance->10^-3}] === Subject: Re: HoldForm, TraditionalForm Bug? > Here is a polynomial. Mathematica rearranges the order of the terms. > > x y - x^3 - 1 > -1 - x^3 + x y > > I would like to display the polynomial without rearranging the order. So I > use a HoldForm. Sorry, but given previous posts by both of us, have to say that it seems to me you've just provided a perfect example of why even attempting to devise a software system or syntax in which users are supposed to be able to use the same input both for evaluating (computing, calculating) a mathematical expression, and also for displaying (typesetting) the expression in a desired fashion, is an inherently bad idea. And the first several initial responses to your post have simply reinforced the claim that it's an inherently bad idea. And the particular difficulty that's exemplified by this example is only one of multiple reasons why it's a bad idea. Bottom line, at least IMHO: Attempting to create a software app that is simultaneously a top of the line numerical and symbolic computational app, and also a top of the line typesetting and publication app, is an inherently impossible goal, and attempting it ultimately acts to the detriment of both these functions. === Subject: Labeling points Here's a graphic I created for a discussion on game theory: http://home.comcast.net/~anglewyrm/thread/dps.png I put the text next to the points in as a post-processing step by hand in PhotoShop. Is there a way to get mathematica to display such information? === Subject: Replace non-numeric values in a list I have a list that contains numeric and non-numeric values list = { a, 1, 2, b, 3}; How can I replace non-numeric values with zeros? -- Adel Elsabbagh http://www.svlab-asu.com/aelsabbagh.html === Subject: DSolve question Hi everyone. I'm looking for help using the result of DSolve. In the code below the DSolve statements in In[3] and In[4] find i1[t] and i2[t] respectively in terms of variable t and a constant a1, a2 respectively. Then, numerical values for a1 and a2 will be found by simultaneous equations equating i1[t] and i2[t] in the FindRoot statement in In[7]. However, I haven.89¥út been able to make Mathematica relate the i1[t], i2[t] in FindRoot to the i1[t], i2[t] resulting from DSolve. I.89¥úve tried several ways and finally the way below and always get errors. On the other hand if I COPY and PASTE the DSolve output Out[3], Out[4] following the -> into the lhs of i1[t] = lhs, then the FindRoot gives me the a1, and similar for a2.. If anyone can instruct me on how to get the FindRoot to recognize the i1[t], i2[t] found from DSolve I would appreciate it. I guess in other words, how do I get output of DSolve to be a usable function. In my own reply to this post I will paste the example of the code where COPY/PASTE has been used as described above to give numerical values for a1, a2. In[1]:= Duty = .6; SWfreq = 1*10^6; Vin = 3.2; Vout = 1.8; L = 4.7*10^-7; R = 0.008; In[2]:= Dt1 = Duty (1/SWfreq); Dt2 = (1 - Duty) (1/SWfreq); VL2 = - Vout; VL1 = Vin - Vout; T = 1/SWfreq; In[3]:= it1 = Simplify[DSolve[{L i1'[t] + R i1[t] - VL1 == 0, i1[0] == a1}, i1[t], t]] Out[3]= {{i1[t] -> 175.+ (-175. + 1. a1) E^(-17021.3 t)}} In[4]:= it2 = Simplify[DSolve[{L i2'[t] + R i2[t] - VL2 == 0, i2[0] == a2}, i2[t], t]] Out[4]= {{i2[t] -> -225. + (225.+ 1. a2) E^(-17021.3 t)}} In[5]:= i1[t_] = i1[t] /. it1 Out[5]= {175.+ (-175. + 1. a1) E^(-17021.3 t)} In[6]:= i2[t_] = i2[t] /. it2 Out[6]= {-225. + (225.+ 1. a2) E^(-17021.3 t)} In[7]:= FindRoot[{i1[0] == i2[T], i1[Dt1] == i2[Dt1]}, {a1, 0}, {a2, 0}] During evaluation of In[7]:= Thread::tdlen: Objects of unequal length in {0,{-0.983123}}+{{1.,0}} cannot be combined. >> During evaluation of In[7]:= Thread::tdlen: Objects of unequal length in {{1.,0}}+{0,{-0.983123}} cannot be combined. >> During evaluation of In[7]:= Thread::tdlen: Objects of unequal length in {0,{-0.989839}}+{{0.989839,0}} cannot be combined. >> During evaluation of In[7]:= General::stop: Further output of Thread::tdlen will be suppressed during this calculation. >> During evaluation of In[7]:= FindRoot::njnum: The Jacobian is not a matrix of numbers at {a1,a2} = {0.,0.}. >> Out[7]= {a1 -> 0., a2 -> 0.} === Subject: Re: an easy one? Two comments about the proffered code NestWhileList[#+(2-#^2)/(2#)&,1.,Abs[#^2-2]>10^-6&] for applying Newton's method to approximate Sqrt[2]... (1) For the function f[x_]:=x^2-2, the formula for Newton's method simplifies to the well-known Hero's method, which is what's shown in the examples of the Mathematica 6 tutorial ApplyingFunctionsRepeatedly: NestWhileList[(# + 2/#)/2 &, 1., Abs[#^2 - 2] > 10^-15 &] In general, for Sqrt[c], the function is (# + c/#)/2&, the average of the current approximation and c divided by the current approximation. And that's now intuitively obvious as a good iterative approximation method even if you've never heard about derivatives: if x is an approximation to Sqrt[c], then both the two numbers x and c/x are approximations to Sqrt[c], so average them to get a better approximation. (2) Although it makes essentially no difference here, in general it's a very bad idea when iteratively approximating a root r of f[x]==0 to use as a stopping criteria that f[#] < epsilon. The trouble is that the function f may be rather flat near an actual root r, and so the current approximation x may well satisfy the condition f[x] 10^-15 &, 2] > Hi Francisco, as you do not give an explicite example, I make one up: calculation of Sqrt[2] using Newtons method: xnew= xold+ f[xold]/f'[xold] starting w ith 1.. Where f[x]= x^2-2 and we want an error <10^-6: NestWhileList[#+(2-#^2)/(2#)&,1.,Abs[#^2-2]>10^-6&] hope this helps, Daniel >> I have a code (for clustering) that works well with FixedPointList. > It takes the following form: > FixedPointList[veamos[dataset,#]&, prototipos,10] > > where veamos is a function that acts on the dataset and prototipos, > and prototipos is also a list of lists (for example {{5,5},{10,10}} ) > > But of course using FixedPointList is imperfect. I want to use NestWhileList instead, with a criterion of termination acting on prototipos (i=2Ee., if the absolute value of the substraction of the penultimate prototipos and the last prototipos is less than a certain amount, say 0.01, then stop). > > But I haven=B4t been able. > Can somebody help me? >> Francisco Guti=E9rrez -- 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 fax 413 545-1801 Amherst, MA 01003-9305 === Subject: URL button on Documentation Center pages I just noticed the URL button at the top right corner of Mathematica 6.0.2 Documentation Center pages. Is this new in 6.0.2? I hadn't noticed it before. Also, what is the use of the first entry in the 4-item drop-down menu that results from clicking the URL button? This entry is the same as what appears in the search bar above the actual page. (By contrast, the 2nd entry, Copy url, is a minor time saver: With two clicks, one on URL, the second on that Copy url entry, one has the page's URL on the clipboard. This is definitely faster, at least for me, than moving the mouse into the search bar, selecting the entire entry there, and then using the usual key combination to copy it.) -- 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 fax 413 545-1801 Amherst, MA 01003-9305 === Subject: Plotting a series of piecewise functions I want to plot a series of functions. Namely I want to plot a series of 2-parametric exponential distribution functions. By series I mean the graphs for various xo values on one plot. So, the function looks like this: f[lambda_, xo_, x_]:=lambda*Exp[-lambda*(x-xo)] Now I can plot this (wrongly) with Plot[Evaluate[Table[f[lambda,xo,x],{lambda,0.5,0.5},{x0,4}]],{x,0,10}] The problem is that, really, f should be zero for x1},{0,x<1}}],{x,0,10}] Now, how could I plot a series of plots (for different xo) on one chart similarly to the Piecwise approach (can I do it with Piecewise at all, or do I need an If clause of sorts)? Claus === Subject: how to determine the center or foci of an ellipse from a slope Hi guys, I have a slope field (2d-array), which is defined by ellipses (can be arbitrarily tilted), which all have the same foci and center but different major and minor half axes. In fact, I obtained the tangent at each point by measurements. Does somebody have an idea on how to approach the problem of finding the center or the foci of the ellipses? I think there is no exact solution to the problem? Thomas === Subject: Adding an edge to a directed cyclic graph Sorry to ask a question that probably has an answer in the Combinatorica book; I've just purchased it and waiting for delivery. I am teaching myself discrete math by learning Combinatorica. Is there an obvious way to add an edge to a directed graph and have the edges renumbered associated with the cyclic order? The number of vertices are fixed. This seems like a common thing to do; so before embarking on my own code to do this, I am hoping I am missing an obvious built-in. For example: Needs[Combinatorica`] (*c6 is the cycle in which I'd like to insert and edge*) c6 = Cycle[6, Type -> Directed] ShowGraph[c6, VertexNumber -> True, EdgeLabel -> True, EdgeLabelColor -> Darker[Orange], BaseStyle -> Large] (*here I hope to add a sub-loop to replace the edge going from 4-5*) modc6 = AddEdges[ DeleteEdge[c6, {4, 5}], { {{4, 5}, EdgeColor -> Green}, {{5, 4}, EdgeColor -> Blue}, {{4, 5}, EdgeColor -> Red} } ] (*the edge numbering no longer corresponds to the cycle index--what I need is a ReplaceEdge*) ShowGraph[modc6, VertexNumber -> True, EdgeLabel -> True, EdgeLabelColor -> Darker[Orange], BaseStyle -> Large] (*does anyone know an option to increase the bowing angle of the Graphics for the subloop?*) -- W. Craig Carter === Subject: Help with find root needed In what follows, I'm looking for the largest root of a function, that is also a function of two parameters. The Manipulate command shows me that the root is consistently there (albeit near a singularity which might be what's causing problems). However, FindRoot doesn't find it as the plot shows. I get one error, but my guess is that it's referring to one particular point on the plot. f[z_, h_, [Gamma]_] := Tanh[h*z] + ([Gamma]^2 + 1 - z^2)/([Gamma]^2 - 1 - z^2) * z/[Gamma]; Manipulate[ Plot[f[z, h, [Gamma]], {z, 0, 10}], {h, .1, 10}, {[Gamma], .1, 10}] K[h_, [Gamma]_] := z /. FindRoot[f[z, h, [Gamma]] == 0, {z, 10, 1, 10}]; Plot3D[K[h, [Gamma]], {h, .1, 10}, {[Gamma], .1, 10}] Aaron === Subject: Re: sending programatically output to clipboard > Hi everyone, > > I would like to find a way to programatically send some output to the > clipboard. For the time being I would like to do that with formatted > equations, and I would like to send them as bitmap or metafile (I work > on Windows). So it should be the equivalent of Copy As. I searched on > the forum and I found a few posts on related topics, but I did not > manage to get it working. > Any help is appreciated. > Here's a way to do it: gr = Plot[Sin[x], {x, 0, 10}] nb = CreateDocument[gr, Visible -> False]; SelectionMove[nb, All, Notebook]; FrontEndTokenExecute[nb, CopySpecial, EMF]; NotebookClose[nb]; This is based on a solution posted by John Fultz in March. Unfortunately I cannot find the original message on Google Groups. === Subject: Re: Mathematica 6: No more memory available problem with Try this: d = RandomReal[{0, 1}, {78, 20003}]; ListDensityPlot[d, PerformanceGoal -> Speed] ListPlot3D[d, PerformanceGoal -> Speed] Mathematica deals with large data sets by downsampling, using the MaxPlotPoints option. PerformanceGoal->Speed, will use a very simple plotting code to give a draft representation of the data (no mesh lines, no RegionFunction, etc.). This also works, although it may take a little bit longer, around 20 ListDensityPlot[d, PerformanceGoal -> Speed, MaxPlotPoints -> Infinity] or even: ListPlot3D[d, PerformanceGoal -> Speed, MaxPlotPoints -> Infinity] Mathematica is a very good tool to visualize large data sets. Ulises Cervantes Wolfram Research, Inc. === Subject: Computing n-grams Imagine one has a list such as {a,b,c,d,e,f,g}. I'm trying to find an efficient way in Mathematica to compute the n-grams of the list. That is, for n=2, the n-grams are all the lists of length 2 consisting of consecutive elements, e.g., {a,b},{b,c},{c,d},{d,e},... While for n=3, {a,b,c},{b,c,d},{c,d,e},..., and so on. As I understand it, the built-in Mathematica commands such as Subsets or Permutations compute all possible list of size n, without regard to the order of the list elements. Mark === Subject: Colors chosen for ListPlot, etc., in v. 6 I was curious about the colors used automatically for multiple lists in graphics such as ListPlot. I know that it looks as though the colors are reused after about four datasets, but I wanted to test this, so I cobbled together a quick set of commands. It turns out that the colors are not reused, but it's hard to see on smallish plots: (* Create a plot with many data sets so we may include a lot of colors: *) g = ListPlot[(Range[10]*#1 & ) /@ Range[10, 0.1, -0.1], PlotStyle -> PointSize[0.02]] (* A function to extract the hues returned in a graphics object: *) {-2, -2}] (* colors used in our plot 'g': *) (* it turns out that all of the points have the same saturation and brightness, but many more hues appear than just four: *) hues = cols /. Hue[a__] :> (First@{a}) ListPlot[hues] (* note that in the ListPlot of hues, the first four hues wrap around the range {0, 1} quite nicely, but when you get to the fifth hue, it falls quite close to the first one, etc. *) (* The hues have a constant offset, sequentially added, presumably so that they wrap around the hue space without repeating themselves: *) ListPlot[Differences@hues] (* but I'm not sure where the chosen number comes from -- it looks as though it's chosen to be a maximal irrational, so that the hues don't repeat, and the same number shows up when perusing the scientific literature about Hausdorff dimensions and so on in physical systems. Can anyone shed some light on it? *) C.O. -- Curtis Osterhoudt cfo@remove_this.lanl.and_this.gov PGP Key ID: 0x4DCA2A10 Please avoid sending me Word or PowerPoint attachments See http://www.gnu.org/philosophy/no-word-attachments.html === Subject: Re: Colors chosen for ListPlot, etc., in v. 6 -- followup Turns out that I was mostly right: the difference between the hue values is equal to (GoldenRatio ^3 ) -4 . Cool! Truly a maximally irrational number. C.O. I was curious about the colors used automatically for multiple lists in > graphics such as ListPlot. I know that it looks as though the colors are > reused after about four datasets, but I wanted to test this, so I cobbled > together a quick set of commands. It turns out that the colors are not > reused, but it's hard to see on smallish plots: (* Create a plot with many data sets so we may include a lot of colors: > *) g = ListPlot[(Range[10]*#1 & ) /@ Range[10, 0.1, -0.1], > PlotStyle -> PointSize[0.02]] (* A function to extract the hues returned in a graphics object: *) {-2, -2}] (* colors used in our plot 'g': *) > (* it turns out that all of the points have the same saturation and > brightness, but many more hues appear than just four: *) hues = cols /. Hue[a__] :> (First@{a}) ListPlot[hues] (* note that in the ListPlot of hues, the first four hues wrap around > the range {0, 1} quite nicely, but when you get to the fifth hue, it falls > quite close to the first one, etc. *) (* The hues have a constant offset, sequentially added, presumably so that > they wrap around the hue space without repeating themselves: *) ListPlot[Differences@hues] (* but I'm not sure where the chosen number comes from -- it looks as > though it's chosen to be a maximal irrational, so that the hues don't > repeat, and the same number shows up when perusing the scientific > literature about Hausdorff dimensions and so on in physical systems. Can > anyone shed some light on it? *) C.O. -- Curtis Osterhoudt cfo@remove_this.lanl.and_this.gov PGP Key ID: 0x4DCA2A10 Please avoid sending me Word or PowerPoint attachments See http://www.gnu.org/philosophy/no-word-attachments.html === Subject: Re: Implementing a array assignment for custom data structure > Lists support a convenient syntax for element assignment: > > a[[i]]=v > > Of course this syntax is syntactic sugar for: > > Set[Part[a, i], v] > > > SparseArray's have a different structure than lists but still support the same syntax. > > This leads me to believe that I should be able to implement a custom type (akin to SparseArray) that also allows this syntax (possibly using UpValues) but for the life of me I can't see how to accomplish this. > > Any ideas? One is always reluctant to say that something is impossible because of the possibility of being proven wrong ... but I believe that this cannot be done. Here are a few examples to demonstrate why. I shall use the symbol part instead of Part (because I do not want to assign rules to Part). Let the custom data structure be myList, whose argument is a normal List. SetAttributes[myList, HoldAll] l = {1, 2, 3} x = myList[l] We shall consider the nth element of x to be equivalent to the nth element of l. We want to allow setting e.g. the 2nd element of x to 5 with the following command: part[x, 2] = 5 The implementation that might spring to mind first is myList /: Set[part[myList[a_], n_], val_] := (a[[n]] = val) But this does not work. The reason is that myList is 2 levels deep inside the pattern, so an UpValue cannot be assigned to it. We need to assign the UpValue to part. Unfortunately this is already a problem, because one does not feel safe modifying Part ... The next try could look like this part /: Set[part[myList[a_], n_], val_] := (a[[n]] = val) But this still does not work ... It turns out that the reason is that Set is HoldFirst, so Set[part[x,2], 5] keeps x unevaluated (and it cannot match myList). Here's a fairly complicated version that does work: Extract[ml, 1, Function[{lst}, lst[[n]] = val, {HoldAll}]] (The complicated RHS is for extracting the argument of the myList object without actually evaluating it. It is not really relevant for the example.) So it seems that what you are asking for can only be accomplished by modifying Part or Set. I strongly recommend against attempting anything like this. Also note that sparse arrays are treated specially by Mathematica. They are considered atoms (AtomQ returns True), and many structure manipulation functions beside Part work on them (e.g. Map, etc.) === Subject: Re: Implementing a array assignment for custom data structure SparseArray /: Part[SparseArray[a___], index_Integer] := sparseGetFunction(a, index) However it is not obvious how to get this to work for Set using either Up or Down values. If you try: Set[Part[SparseArray[a___], index_Integer], value_] := sparseSetFunction(a, index,value) It will not work with: myArray = SparseArray[{{1} -> 10, {30} -> 15}] myArray[[2]] = 15 because Set (=) does not evaluate its first argument so Mathematica will not match the pattern and invoke sparseSetFunction. === Subject: Re: sending programatically output to clipboard > Hi everyone, I would like to find a way to programatically send some output to the > clipboard. For the time being I would like to do that with formatted > equations, and I would like to send them as bitmap or metafile (I work > on Windows). So it should be the equivalent of Copy As. I searched on > the forum and I found a few posts on related topics, but I did not > manage to get it working. > Any help is appreciated. Adrian For example, nb = NotebookPut[Notebook[{Cell[1234, Title]}]]; SelectionMove[nb, All, Notebook]; FrontEndExecute[FrontEndToken[nb, CopySpecial, EMF]] Use EMF for metafile (copies both enhanced and windows-style metafiles). = Use MGF for bitmaps. John Fultz jfultz@wolfram.com User Interface Group Wolfram Research, Inc. === Subject: change a system of PDEs to ODEs via traveling wave If I have a system of PDEs in x and t, how can I change to the traveling wave variable xi=x-ct to get a system of ODEs? === Subject: Re: Framed[3, FrameStyle -> None] fails >It seems that the option FrameStyle -> None to Framed does not work. >Framed[3, FrameStyle -> None] >returns a framed 3 with a black border around it in Mathematica >version 6.0 on WinXP. The documentation states that, The option >setting FrameStyle->None draws no explicit frame. When I paste the code above into a notebook and execute it, I > see just the 3 with no frame. This is using Mathematica version > 6.02 running on Mac OX 10.5.2 I guess this problem is particular to my setup. Chris === Subject: Re: fails? Too bad we have no solution. I have cooked up something that's a little ugly, but it works. It's called KeyHandler and I think it recognizes most of the keys on the keyboard. If you want to mix key event handling with other types of event handling you will need to nest the event handlers. KeyHandler[code_, action_] executions code, calling action when a key is pressed, and passing action the string representing the character. e.g. KeyHandler[some string, Print] prints out the keys that are pressed. Chris ClearAll[charRange, actionTable, KeyHandler]; charRange[c1_, c2_] := Table[i, {i, ToCharacterCode[c1] // First, ToCharacterCode[c2] // First}]; actionTable[lst_List, action_] := Function[key, {KeyDown, key} :> action[key]] /@ lst; SetAttributes[KeyHandler, HoldFirst]; KeyHandler[code_, action_] := EventHandler[code, actionTable[ charRange[a, z]~Join~charRange[A, Z]~Join~ charRange[0, 9]~ Join~{~, !, @, #, $, %, ^, &, *, (, ), -, _, =, +, [, ], , |, ;, :, ', , ,, > I found this problem as well when I tried to write an EventHandler for > generating a custom input field. I described the problem you report in a > question filed with Wolfram Technical Support (identification number TS > 13327) on 9 May. I never received a reply beyond the automated > acknowledgement. So, yes, I think there is good reason to believe that > CurrentValue[EventKey] is broken. Jason >> To all, >> I am unable to create an expression that reports what key has been >> pressed. It seems that CurrentValue[EventKey] always returns >> None. >> Here is the code: >> EventHandler[a string, KeyDown :> Print[CurrentValue[EventKey]]] >> I get similar results with: >> EventHandler[Dynamic[key], >> KeyDown :> (key = CurrentValue[EventKey])] >> Chris -- > Dr J. McKenzie Alexander > Department of Philosophy, Logic and Scientific Method > London School of Economics and Political Science > Houghton Street, London WC2A 2AE > Please access the attached hyperlink for an important electronic > communications disclaimer: > http://www.lse.ac.uk/collections/secretariat/legal/disclaimer.htm > === Subject: Re: fails > There is no Frame displayed on my system $Version 6.0 for Mac OS X x86 (64-bit) (March 13, 2008) Bob Hanlon > It seems that the option FrameStyle -> None to Framed does not work. > Framed[3, FrameStyle -> None] > returns a framed 3 with a black border around it in Mathematica > version 6.0 on WinXP. > The documentation states that, The option setting FrameStyle->None > draws no explicit frame. > Chris configuration and version number. Chris === Subject: Re: Problems with ListPlot 2) In addition of 1 point and 1 line (2 other should be clipped as > they lie outside of the range) I see 2 points, where the line crosses > the lower and upper edges of the plot. >> I don't really understand this second question ... > if you set Joined -> True, there are 2 points visible at:{1.5,0.5} and > {2.5,1.5} that should not be there. > Version:6.0 for Microsoft Windows (32-bit) (February 7, 2008) > Daniel Oh, sorry, now I see what the OP meant. The Mesh option influences this, but I couldn't find a workaround ... It would probably be quicker not to use ListPlot at all, and just build up the plot from graphics primitives (i.e. quicker than finding a workaround for this bug) ... It would also make handling plot markers easier ... === Subject: Re: Problems with ListPlot >> 2) In addition of 1 point and 1 line (2 other should be clipped as >> they lie outside of the range) I see 2 points, where the line crosses >> the lower and upper edges of the plot. > > I don't really understand this second question ... > if you set Joined -> True, there are 2 points visible at:{1.5,0.5} and {2.5,1.5} that should not be there. Version:6.0 for Microsoft Windows (32-bit) (February 7, 2008) Daniel -- Daniel Huber Metrohm Ltd. Oberdorfstr. 68 CH-9100 Herisau Tel. +41 71 353 8585, Fax +41 71 353 8907 E-Mail: Internet: === Subject: On which OS is Mathematica best implemented? I have not used Mathematica in a long time, but am about to get back into it. In it's first few versions (the only ones I have used) the Mac version was by far more polished, had more features, and was much stabler than its Windows counterpart (well, for everything I wanted to do, which was a lot). Such was the case for quite a few other programs at the time, including Microsoft's own cash caws, Excel and Word. Well, things changed for the Office suite- The Windows versions of Excel and Word have been ahead of the Mac versions for years (since v.5 of Excel). What about Mathematica? On which OS is it ahead by and large /these/ days? How does its release/update history compare on the two platforms? The computer I will load this onto runs Mac OS 10.5.2, WinXP sp3, and of course Unix. Dave === Subject: Re: Implementing a array assignment for custom data structure >Lists support a convenient syntax for element assignment: >a[[i]]=v >Of course this syntax is syntactic sugar for: >Set[Part[a, i], v] >SparseArray's have a different structure than lists but still >support the same syntax. >This leads me to believe that I should be able to implement a custom >type (akin to SparseArray) that also allows this syntax (possibly >using UpValues) but for the life of me I can't see how to accomplish >this. It would be helpful if you provided a specific example of what you want to accomplish. But having said that, I don't know that the existing syntax won't work for you. Pretty much any thing in Mathematica can be viewed as having parts. For example: In[32]:= f = x + y + z; f[[2]] = 3; f Out[34]= x+z+3 The only real difficulty with more complex expressions is identifying the part level specification needed to change the portion of the expression you want changed. === Subject: Re: Problems with ListPlot >>I noticed the following problems when creating ListPlot in >>Mathematica 6 (see the example): >>ListPlot[{0, 1, 2}, PlotMarkers -> Style[[FilledCircle], >>FontSize -> 12], Joined -> True, GridLines -> Automatic, PlotRange >>-> {{1, 3}, {0.5, 1.5}}, PlotRangeClipping -> False, ImagePadding >>-> 10] >>1) The plot markers have an offset slightly to the left from their >>correct position >Precise positioning is not really achievable when glyphs from a font >are used as plot markers. The problem can be cured by using >graphics objects: >PlotMarkers -> {Graphics[Circle[]], .05} >Or if you need disks as plot markers, then just use a larger point >size. Why not use PlotMarkers -> {Graphics[Disk[]], .05} if you want disks as plot markers instead of circles? >>2) In addition of 1 point and 1 line (2 other should be clipped as >>they lie outside of the range) I see 2 points, where the line >>crosses the lower and upper edges of the plot. >I don't really understand this second question ... I think the original poster was thinking the graphic should be consistent with: ListPlot[{0, 1, 2}, PlotMarkers -> {Graphics[Disk[]], .05}, Joined -> True, GridLines -> Automatic, PlotRange -> {{1, 3}, {0.5, 1.5}}] Notice the top and bottom disks are clipped since the specified value of PlotRange isn't sufficient to fully include the top and bottom disks. I believe the reason this was not seen using the original poster's code was due to the inclusion of the ImagePadding option and using PlotRangeClipping->False which combine so that the top and bottom disks are not clipped. That is compare the graphic using the code above to: ListPlot[{0, 1, 2}, PlotMarkers -> {Graphics[Disk[]], .05}, Joined -> True, GridLines -> Automatic, PlotRange -> {{1, 3}, {0.5, 1.5}}, PlotRangeClipping -> False, ImagePadding -> 10] === Subject: Re: DumpSave of packages > > how to save interrelated packages to mx-files? This question is a > follow-up to my previous one > > DumpSave[package.mx, {package`, otherpackage`}] does not work > always if the packages depend on each other and contain subcontexts. > No problems using only .m files. > > Here is roughly what I tried: > 1. Start the notebook package.nb (working directly with package.m > gives similar results). > 2. Assign Contexts[] to a variable initialContexts > 3. Execute the package itself > 4. Execute Contexts[] again, delete all contexts already in > initialContexts and assign the result to a variable requiredContexts > 5. DumpSave[package.mx, requiredPackages] > > Now, executing Needs[package`] loads the correct context package` > but some functions do not work anyways. > > Below are the details (paste into a notebook). Any ideas are > appreciated. > > Hannes Kessler > > (* not an initialization cell *) > virgin[LetterSpace]contexts = Contexts[]; > > BeginPackage[package`, {...}] > ... > EndPackage[]; > > (* Now the DumpSave, again not an initialization cell *) > nb = EvaluationNotebook[]; > Module[{ > required[Dash]contexts = > DeleteCases[ > Contexts[], _?(MemberQ[virgin[LetterSpace]contexts, #] &)], > nb[Dash]file = Replace[FileName, NotebookInformation[nb]][[2]], > nb[Dash]dir = > ToFileName @ > First @ Replace[FileName, NotebookInformation[nb]], > mx[Dash]file, mx[Dash]dir, save > }, > mx[Dash]file = > StringReplace[nb[Dash]file, > s_ ~~ .nb ~~ EndOfString :> s <> .mx]; > mx[Dash]dir = > ToFileName[{nb[Dash]dir, mx[Dash]file, ToString @ $SystemID}]; > CreateDirectory @ mx[Dash]dir]; > save = Hold[ > DumpSave[ToFileName[{mx[Dash]dir}, mx[Dash]file], > contexts]] /. {contexts -> required[Dash]contexts}; > ReleaseHold @ save] > In the complex collection of packages that you described in your previous message, I guess it is possible that something untoward is happening - possibly as a result of some manipulation of contexts. It may be better to step back a bit and say what exactly you are trying to achieve. .mx files are indeed a very effecient way of loading (typically) large arrays of data. If this is your situation, it may be better to store these individually: DumpSave[mxfile,{list of items to be saved}]; David Bailey http://www.dbaileyconsultancy.co.uk === Subject: Re: DumpSave of packages - now it works ... I had overseen changes made to system variables in one of the packages. After including the System` context to the DumpSave, all package functions are loaded correctly from the .mx file. Hannes Kessler how to save interrelated packages to mx-files? This question is a DumpSave[package.mx, {package`, otherpackage`}] does not work > always if the packages depend on each other and contain subcontexts. > No problems using only .m files. Here is roughly what I tried: > 1. Start the notebook package.nb (working directly with package.m > gives similar results). > 2. Assign Contexts[] to a variable initialContexts > 3. Execute the package itself > 4. Execute Contexts[] again, delete all contexts already in > initialContexts and assign the result to a variable requiredContexts > 5. DumpSave[package.mx, requiredPackages] Now, executing Needs[package`] loads the correct context package` > but some functions do not work anyways. Below are the details (paste into a notebook). Any ideas are > appreciated. Hannes Kessler (* not an initialization cell *) > virgin[LetterSpace]contexts = Contexts[]; BeginPackage[package`, {...}] > ... > EndPackage[]; (* Now the DumpSave, again not an initialization cell *) > nb = EvaluationNotebook[]; > Module[{ > required[Dash]contexts = > DeleteCases[ > Contexts[], _?(MemberQ[virgin[LetterSpace]contexts, #] &)], > nb[Dash]file = Replace[FileName, NotebookInformation[nb]][[2]], > nb[Dash]dir = > ToFileName @ > First @ Replace[FileName, NotebookInformation[nb]], > mx[Dash]file, mx[Dash]dir, save > }, > mx[Dash]file = > StringReplace[nb[Dash]file, > s_ ~~ .nb ~~ EndOfString :> s <> .mx]; > mx[Dash]dir = > ToFileName[{nb[Dash]dir, mx[Dash]file, ToString @ $SystemID}]; > CreateDirectory @ mx[Dash]dir]; > save = Hold[ > DumpSave[ToFileName[{mx[Dash]dir}, mx[Dash]file], > contexts]] /. {contexts -> required[Dash]contexts}; > ReleaseHold @ save] === Subject: Re: Labeling points The visual system notices area, not diameter, so if you want the subjective size of each point to be proportional to the third value in each element of data you should use PointSize[Sqrt[Last[#]]/50] instead of PointSize[Last[#]/50]. (* Custom LabeledListPlot *) > LabeledListPlot[data_] := > Show[Graphics[{PointSize[Last[#]/50], Point[Take[#, 2]], > Text[ToString[Round[100 Last[#]]] <> %, > Take[#, 2], {-1.5, 0}]} & /@ data], > Axes -> True, AxesOrigin -> {0, 0}, AspectRatio -> 1, > AxesLabel -> {Shots, Damage}]; (* Data supplied by other routines *) > data = {{1, 1, 0.5`1.9999999999999998}, > {2, 1, 0.75`2.0000000000000004}, > {2, 2, 0.25`1.9999999999999998}, > {3, 1, 0.875`2.0000000000000013}, > {3, 2, 0.5`1.9999999999999998}, > {3, 3, 0.125`1.9999999999999998}, > {4, 1, 0.9375`2.0000000000000004}, > {4, 2, 0.6875`2.}, > {4, 3, 0.3125`1.9999999999999998}, > {4, 4, 0.0625`1.9999999999999998}, > {5, 1, 0.96875`1.9999999999999991}, > {5, 2, 0.8125`2.000000000000002}, > {5, 3, 0.5`1.9999999999999998}, > {5, 4, 0.1875`2.0000000000000004}, > {5, 5, 0.03125`1.9999999999999998}, > {6, 1, 0.984375`2.0000000000000004}, > {6, 2, 0.890625`2.0000000000000004}, > {6, 3, 0.65625`1.9999999999999998}, > {6, 4, 0.34375`2.}, > {6, 5, 0.109375`2.0000000000000013}, > {6, 6, 0.015625`1.9999999999999998}}; LabeledListPlot[data] === Subject: Re: Wolfram Workbench user experiences I would be very interested in other people's experiences with the > Wolfram Workbench. I must admit that I prefer to use the frontend > as my 'IDE', and the workbench seemed fairly alien when I tried it. David Bailey > http://www.dbaileyconsultancy.co.uk > I'm au fait with IDEs but had difficult using breakpoints in an imported project until I found an option I could uncheck on the initial notebook's properties so that Workbench didn't execute an Automatic load for all source files on startup. All the necessary Get statements were in my project already so the autoload just created shadowed variables and stopped the breakpoints working. The property default seems to be to do the Automatic load. Since I found it and switched it off it works fine. === Subject: Re: Cannot NSolve a system of equations zet = 0.083; phi = 0.75; eta = 1.75; alpha = 0.64; y1 = 0.235457064; y2 = 0.512465374; y3 = 0.781779009; y4 = 1.109572176; y5 = 2.360726377; tau1 = zet y1^phi; tau2 = zet y2^phi; tau3 = zet y3^phi; tau4 = zet y4^phi; tau5 = zet y5^phi; taubar = (tau1 y1 + tau2 y2 + tau3 y3 + tau4 y4 + tau5 y5)/5; a1 = (1 + phi) tau1; a2 = (1 + phi) tau2; a3 = (1 + phi) tau3; a4 = (1 + phi) tau4; a5 = (1 + phi) tau5; eqns1 = {x1 == (roverw (1 - tau1) + ((roverw + (1 - x)) y1 - 1) ((1 - taubar + (1 - abar)/eta) x + (taubar - tau1) roverw - (1 - taubar)))/ (roverw (1 - tau1 + (1 - a1)/eta) - ((1 - taubar + (1 - abar)/eta) x + (taubar - tau1) roverw - (1 - taubar))), x2 == (roverw (1 - tau2) + ((roverw + (1 - x)) y2 - 1) ((1 - taubar + (1 - abar)/eta) x + (taubar - tau2) roverw - (1 - taubar)))/ (roverw (1 - tau2 + (1 - a2)/eta) - ((1 - taubar + (1 - abar)/eta) x + (taubar - tau2) roverw - (1 - taubar))), x3 == (roverw (1 - tau3) + ((roverw + (1 - x)) y3 - 1) ((1 - taubar + (1 - abar)/eta) x + (taubar - tau3) roverw - (1 - taubar)))/ (roverw (1 - tau3 + (1 - a3)/eta) - ((1 - taubar + (1 - abar)/eta) x + (taubar - tau3) roverw - (1 - taubar))), x4 == (roverw (1 - tau4) + ((roverw + (1 - x)) y4 - 1) ((1 - taubar + (1 - abar)/eta) x + (taubar - tau4) roverw - (1 - taubar)))/ (roverw (1 - tau4 + (1 - a4)/eta) - ((1 - taubar + (1 - abar)/eta) x + (taubar - tau4) roverw - (1 - taubar))), x5 == (roverw (1 - tau5) + ((roverw + (1 - x)) y5 - 1) ((1 - taubar + (1 - abar)/eta) x + (taubar - tau5) roverw - (1 - taubar)))/ (roverw (1 - tau5 + (1 - a5)/eta) - ((1 - taubar + (1 - abar)/eta) x + (taubar - tau5) roverw - (1 - taubar))), x == (x1 + x2 + x3 + x4 + x5)/5, abar == (a1 x1 + a2 x2 + a3 x3 + a4 x4 + a5 x5)/(5 x), roverw == (1 - x) (1 - alpha)/alpha}; sol = NSolve[eqns1, {x, x1, x2, x3, x4, x5, abar, roverw}]; Select[sol, And @@ (eqns1 /. #) &] {} Increasing the working precision helps Off[NSolve::precw]; sol2 = NSolve[eqns1, {x, x1, x2, x3, x4, x5, abar, roverw}, WorkingPrecision -> 50]; Select[sol2, And @@ (eqns1 /. #) &] {{x->0.41708623092950157741569019179902289185045201412813,x1->0. 692440249232143611072102477625080745344157628899,x2->0. 604422024572264901699315484017555974822809818657,x3->0. 5127989690938688778766742187652415932939481958373,x4->0. 39437767611147931754234647185921962409136124978897,x5->-0. 11860776436224882111198769327198347830001682254199,abar->0. 08545766887516266300728185720734114355092900559414,roverw->0. 327888995102155362703674267113049623334120742053},{x->1. 0000000000000000000000000000000000000000000000000,x1->1. 000000000000000000000000000000000000000000000000,x2->1. 000000000000000000000000000000000000000000000000,x3->1. 0000000000000000000000000000000000000000000000000,x4->1. 0000000000000000000000000000000000000000000000000,x5->1. 0000000000000000000000000000000000000000000000000,abar->0. 13829898904658144378180892316051003528822699194006,roverw->0}} Bob Hanlon > > I have the following system that I need to solve, but I cannot get a > sensible result. > > Unprotect[In,Out];Clear[In,Out];ClearAll[Global`*]; > zet=0.083; > phi=0.75;eta=1.75;alpha=0.64;y1=0.235457064;y2=0.512465374;y3=0.781779009; > y4=1.109572176; y5=2.360726377;tau1=zet y1^phi;tau2=zet > y2^phi;tau3=zet y3^phi;tau4=zet y4^phi;tau5=zet y5^phi; > taubar=(tau1 y1+tau2 y2+tau3 y3+tau4 y4+tau5 y5)/ > 5;a1=(1+phi)tau1;a2=(1+phi)tau2;a3=(1+phi)tau3;a4=(1+phi)tau4;a5=(1+phi)tau5; > > eqns1={x1==(roverw(1-tau1)+((roverw+(1-x))y1-1)( (1-taubar+(1-abar)/ > eta)x+(taubar-tau1)roverw-(1-taubar)))/(roverw (1-tau1+(1-a1)/eta)- > ( (1-taubar+(1-abar)/eta)x+(taubar-tau1)roverw-(1-taubar))), > x2==(roverw(1-tau2)+((roverw+(1-x))y2-1)( (1-taubar+(1-abar)/eta)x+ > (taubar-tau2)roverw-(1-taubar)))/(roverw (1-tau2+(1-a2)/eta)-( (1- > taubar+(1-abar)/eta)x+(taubar-tau2)roverw-(1-taubar))), > x3==(roverw(1-tau3)+((roverw+(1-x))y3-1)( (1-taubar+(1-abar)/eta)x+ > (taubar-tau3)roverw-(1-taubar)))/(roverw (1-tau3+(1-a3)/eta)-( (1- > taubar+(1-abar)/eta)x+(taubar-tau3)roverw-(1-taubar))), > x4==(roverw(1-tau4)+((roverw+(1-x))y4-1)( (1-taubar+(1-abar)/eta)x+ > (taubar-tau4)roverw-(1-taubar)))/(roverw (1-tau4+(1-a4)/eta)-( (1- > taubar+(1-abar)/eta)x+(taubar-tau4)roverw-(1-taubar))), > x5==(roverw(1-tau5)+((roverw+(1-x))y5-1)( (1-taubar+(1-abar)/eta)x+ > (taubar-tau5)roverw-(1-taubar)))/(roverw (1-tau5+(1-a5)/eta)-( (1- > taubar+(1-abar)/eta)x+(taubar-tau5)roverw-(1-taubar))), > x==(x1+x2+x3+x4+x5)/5, abar == (a1 x1+a2 x2+a3 x3+a4 x4+a5 x5)/ > (5x),roverw==(1-x)(1-alpha)/alpha }; > > sol=NSolve[eqns1,{x, x1,x2,x3,x4,x5,abar, roverw}]; > > eqns1 /. sol > > Out[741]={{False, False, False, False, False, True, True, True}, > {False, False, > False, False, False, True, True, True}, {False, False, False, > False, False, True, False, True}, {False, False, True, False, False, > True, False, True}, {False, False, True, False, False, True, False, > True}, {False, False, True, True, False, True, True, False}} > > > What am I doing wrong? Is it just because the system is too > complicated? > > Any help would be truly appreciated. > Murat > === Subject: strange behaviour of Integration Assuming[0 < a < b,2*Pi*Integrate[y*2*Sqrt[a^2 - (y - b)^2],{y, b - a, b + a}]] gives 2*a^2*b*Pi^2 So does Assuming[0 < b < a,2*Pi*Integrate[y*2*Sqrt[a^2 - (y - b)^2],{y, b - a, b + a}]] And Assuming[a < b < 0, 2*Pi*Integrate[ y*2*Sqrt[a^2 - (y - b)^2], {y, b - a, b + a}]] Gives -2*a^2*b*Pi^2 So why does Assuming[{Element[a, Reals], Element[b, Reals]}, 2*Pi*Integrate[ y*2*Sqrt[a^2 - (y - b)^2], {y, b - a, b + a}]] Give 0 ? Is this a bug ? F.Jaccard === Subject: Re: How to connect one object to the other? > i am using Mathematica 6 on Window XP this code makes disk drag able disk objects, i want to connect them with > arrow, how con i achieve this, any ideas? plotObject[G_] := Locator[{RandomReal[30], RandomReal[30]}, > Graphics[G], ImageSize -> 20] p = { > RGBColor[RandomReal[1], RandomReal[1], RandomReal[1], 0.5], > Disk[{5, 5}, 5] > } Framed@Graphics[ > Table[plotObject[{RGBColor[RandomReal[1], RandomReal[1], > RandomReal[1], 0.5], Disk[{5, 5}, 5]}], {i, 10}], > PlotRange -> 50] > Look up Dynamic in the docs. Here's an example: loc = Graphics[{Red, Disk[]}]; pos = {0, 0} Graphics[{Locator[Dynamic[pos], loc, ImageSize -> Medium], Dynamic@Arrow[{{0, 0}, pos}]}, PlotRange -> 1] === Subject: Re: How to connect one object to the other? smomething like: DynamicModule[{p = {0.5, 0.5}}, Graphics[ {Locator[Dynamic[p]], Arrow[{{0, 0}, Dynamic[p]}]}, PlotRange -> {{-1, 1}, {-1, 1}} ] ] ?? Jens > i am using Mathematica 6 on Window XP > > this code makes disk drag able disk objects, i want to connect them with > arrow, how con i achieve this, any ideas? > > plotObject[G_] := Locator[{RandomReal[30], RandomReal[30]}, > Graphics[G], ImageSize -> 20] > > p = { > RGBColor[RandomReal[1], RandomReal[1], RandomReal[1], 0.5], > Disk[{5, 5}, 5] > } > > Framed@Graphics[ > Table[plotObject[{RGBColor[RandomReal[1], RandomReal[1], > RandomReal[1], 0.5], Disk[{5, 5}, 5]}], {i, 10}], > PlotRange -> 50] > > > > > Gohar Sultan > > === Subject: Re: How to connect one object to the other? Gohar, Below are two solutions with different characteristics:- First, plotObject[G_] := Locator[{RandomReal[30], RandomReal[30]}, Graphics[G], ImageSize -> 20] Framed@Graphics[ Table[{Arrow[{{RandomReal[30], RandomReal[30]}, {RandomReal[30], RandomReal[30]}}], plotObject[{RGBColor[RandomReal[1], RandomReal[1], RandomReal[1], 0.5], Disk[{5, 5}, 5]}]}, {i, 10}], PlotRange -> 50] gives black arrows which can be double clicked to move, resize & redirect each of them but are not Locators. Second, plotObject[G_] := Locator[{RandomReal[30], RandomReal[30]}, Graphics[G], ImageSize -> 40] Framed@Graphics[ Table[{plotObject[{RGBColor[RandomReal[1], RandomReal[1], RandomReal[1], 0.5], Arrowheads[Large], Arrow[{{RandomReal[30], RandomReal[30]}, {RandomReal[30], RandomReal[30]}}]}], plotObject[{RGBColor[RandomReal[1], RandomReal[1], RandomReal[1], 0.9], Disk[{5, 5}, 5]}]}, {i, 10}], PlotRange -> 50] gives random coloured arrows which are locators which can be dragged but which cannot be resized or redirected. HTH, Syd Geraghty B.Sc, M.Sc. sydgeraghty@mac.com My System Mathematica 6.0.2.1 for Mac OS X x86 (64 - bit) (March 13, 2008) MacOS X V 10.5.2 > i am using Mathematica 6 on Window XP this code makes disk drag able disk objects, i want to connect them > with > arrow, how con i achieve this, any ideas? plotObject[G_] := Locator[{RandomReal[30], RandomReal[30]}, > Graphics[G], ImageSize -> 20] p = { > RGBColor[RandomReal[1], RandomReal[1], RandomReal[1], 0.5], > Disk[{5, 5}, 5] > } Framed@Graphics[ > Table[plotObject[{RGBColor[RandomReal[1], RandomReal[1], > RandomReal[1], 0.5], Disk[{5, 5}, 5]}], {i, 10}], > PlotRange -> 50] > Gohar Sultan === Subject: Color space conversion in Mathematica v6.0 I have a several 2D and 3D graphics which I would like to export as EPS and PDF image files. Either prior to Export[]-ing or while Export[]-ing I would like to convert them from color to grayscale. Is there an option to Export[] for doing this or some other function in the Mathematical kernel for doing this? In versions earlier than 6.0 I could specify ColorOutput->GrayLevel, but this is not a valid option in version 6.0. Bob Buchanan === Subject: Re: Cannot NSolve a system of equations Hi Murat, try to check your equations not with Equal, but subtract the left from the right side. E.g. by: eqns1 /. Equal -> Subtract /. sol As you are working with machine numbers, you can not expect an 100% accurate solution. In your case, you will see that the equations are o.k. with an error better than 10^-8. This is not overwhelming, but may be good enough for your purpose. If not, one can consider: Rationalizing, Condition number of equations, Arbitrary precision calculation etc. hope this helps, Daniel > > I have the following system that I need to solve, but I cannot get a > sensible result. > > Unprotect[In,Out];Clear[In,Out];ClearAll[Global`*]; > zet=0.083; > phi=0.75;eta=1.75;alpha=0.64;y1=0.235457064;y2=0.512465374;y3=0.781779009; > y4=1.109572176; y5=2.360726377;tau1=zet y1^phi;tau2=zet > y2^phi;tau3=zet y3^phi;tau4=zet y4^phi;tau5=zet y5^phi; > taubar=(tau1 y1+tau2 y2+tau3 y3+tau4 y4+tau5 y5)/ > 5;a1=(1+phi)tau1;a2=(1+phi)tau2;a3=(1+phi)tau3;a4=(1+phi)tau4;a5=(1+phi)tau5; > > eqns1={x1==(roverw(1-tau1)+((roverw+(1-x))y1-1)( (1-taubar+(1-abar)/ > eta)x+(taubar-tau1)roverw-(1-taubar)))/(roverw (1-tau1+(1-a1)/eta)- > ( (1-taubar+(1-abar)/eta)x+(taubar-tau1)roverw-(1-taubar))), > x2==(roverw(1-tau2)+((roverw+(1-x))y2-1)( (1-taubar+(1-abar)/eta)x+ > (taubar-tau2)roverw-(1-taubar)))/(roverw (1-tau2+(1-a2)/eta)-( (1- > taubar+(1-abar)/eta)x+(taubar-tau2)roverw-(1-taubar))), > x3==(roverw(1-tau3)+((roverw+(1-x))y3-1)( (1-taubar+(1-abar)/eta)x+ > (taubar-tau3)roverw-(1-taubar)))/(roverw (1-tau3+(1-a3)/eta)-( (1- > taubar+(1-abar)/eta)x+(taubar-tau3)roverw-(1-taubar))), > x4==(roverw(1-tau4)+((roverw+(1-x))y4-1)( (1-taubar+(1-abar)/eta)x+ > (taubar-tau4)roverw-(1-taubar)))/(roverw (1-tau4+(1-a4)/eta)-( (1- > taubar+(1-abar)/eta)x+(taubar-tau4)roverw-(1-taubar))), > x5==(roverw(1-tau5)+((roverw+(1-x))y5-1)( (1-taubar+(1-abar)/eta)x+ > (taubar-tau5)roverw-(1-taubar)))/(roverw (1-tau5+(1-a5)/eta)-( (1- > taubar+(1-abar)/eta)x+(taubar-tau5)roverw-(1-taubar))), > x==(x1+x2+x3+x4+x5)/5, abar == (a1 x1+a2 x2+a3 x3+a4 x4+a5 x5)/ > (5x),roverw==(1-x)(1-alpha)/alpha }; > > sol=NSolve[eqns1,{x, x1,x2,x3,x4,x5,abar, roverw}]; > > eqns1 /. sol > > Out[741]={{False, False, False, False, False, True, True, True}, > {False, False, > False, False, False, True, True, True}, {False, False, False, > False, False, True, False, True}, {False, False, True, False, False, > True, False, True}, {False, False, True, False, False, True, False, > True}, {False, False, True, True, False, True, True, False}} > > > What am I doing wrong? Is it just because the system is too > complicated? > > Any help would be truly appreciated. > Murat > -- Daniel Huber Metrohm Ltd. Oberdorfstr. 68 CH-9100 Herisau Tel. +41 71 353 8585, Fax +41 71 353 8907 E-Mail: Internet: === Subject: Re: Cannot NSolve a system of equations I have the following system that I need to solve, but I cannot get a > sensible result. Unprotect[In,Out];Clear[In,Out];ClearAll[Global`*]; > zet=0.083; > phi > = > 0.75;eta=1.75;alpha=0.64;y1=0.235457064;y2=0.512465374;y3=0.781779009; > y4=1.109572176; y5=2.360726377;tau1=zet y1^phi;tau2=zet > y2^phi;tau3=zet y3^phi;tau4=zet y4^phi;tau5=zet y5^phi; > taubar=(tau1 y1+tau2 y2+tau3 y3+tau4 y4+tau5 y5)/ > 5 > ;a1 > = > (1 > +phi)tau1;a2=(1+phi)tau2;a3=(1+phi)tau3;a4=(1+phi)tau4;a5=(1+phi)tau5; eqns1={x1==(roverw(1-tau1)+((roverw+(1-x))y1-1)( (1-taubar+(1-abar)/ > eta)x+(taubar-tau1)roverw-(1-taubar)))/(roverw (1-tau1+(1-a1)/eta)- > ( (1-taubar+(1-abar)/eta)x+(taubar-tau1)roverw-(1-taubar))), > x2==(roverw(1-tau2)+((roverw+(1-x))y2-1)( (1-taubar+(1-abar)/eta)x+ > (taubar-tau2)roverw-(1-taubar)))/(roverw (1-tau2+(1-a2)/eta)-( (1- > taubar+(1-abar)/eta)x+(taubar-tau2)roverw-(1-taubar))), > x3==(roverw(1-tau3)+((roverw+(1-x))y3-1)( (1-taubar+(1-abar)/eta)x+ > (taubar-tau3)roverw-(1-taubar)))/(roverw (1-tau3+(1-a3)/eta)-( (1- > taubar+(1-abar)/eta)x+(taubar-tau3)roverw-(1-taubar))), > x4==(roverw(1-tau4)+((roverw+(1-x))y4-1)( (1-taubar+(1-abar)/eta)x+ > (taubar-tau4)roverw-(1-taubar)))/(roverw (1-tau4+(1-a4)/eta)-( (1- > taubar+(1-abar)/eta)x+(taubar-tau4)roverw-(1-taubar))), > x5==(roverw(1-tau5)+((roverw+(1-x))y5-1)( (1-taubar+(1-abar)/eta)x+ > (taubar-tau5)roverw-(1-taubar)))/(roverw (1-tau5+(1-a5)/eta)-( (1- > taubar+(1-abar)/eta)x+(taubar-tau5)roverw-(1-taubar))), > x==(x1+x2+x3+x4+x5)/5, abar == (a1 x1+a2 x2+a3 x3+a4 x4+a5 x5)/ > (5x),roverw==(1-x)(1-alpha)/alpha }; sol=NSolve[eqns1,{x, x1,x2,x3,x4,x5,abar, roverw}]; eqns1 /. sol Out[741]={{False, False, False, False, False, True, True, True}, > {False, False, > False, False, False, True, True, True}, {False, False, False, > False, False, True, False, True}, {False, False, True, False, False, > True, False, True}, {False, False, True, False, False, True, False, > True}, {False, False, True, True, False, True, True, False}} > What am I doing wrong? Is it just because the system is too > complicated? Any help would be truly appreciated. > Murat > You are doing nothing wrong, just demanding to much. Instead trying to verify the equations just calculate the residues: eqns1 /. Equal -> Subtract /. sol {{-7.815970093361102*^-12, -8.151346264639869*^-11, -7.526068657170981*^-11, -2.701199264265597*^-10, -5.07498043589294*^-10, -9.947598300641403*^-14, 8.881784197001252*^-16, 0.}, {4.4158454670650826*^-11, 1.5007728393356956*^-9, 3.164917217191032*^-10, -1.6515500078639889*^-10, -2.8396840434652404*^-11, -3.3306690738754696*^-16, -1.5265566588595902*^-15, 0.}, {-4.1599612643494766*^-11 + 5.3216098194752703*^-11* I, -9.377387755193922*^-12 - 1.566604623803869*^-10*I, 8.095479842040731*^-11 - 1.2360334977756793*^-10*I, -7.734213269827706*^-11 + 7.310063665499911*^-11*I, 2.5863755581667647*^-11 + 2.5732305175552028*^-11* I, 3.3306690738754696*^-16 - 8.604228440844963*^-16*I, -2.525757381022231*^-15 + 8.770761894538737*^-15*I, 2.7755575615628914*^-17 + 0.*I}, {-4.1599612643494766*^-11 - 5.3216098194752703*^-11* I, -9.377387755193922*^-12 + 1.566604623803869*^-10*I, 8.095479842040731*^-11 + 1.2360334977756793*^-10*I, -7.734213269827706*^-11 - 7.310063665499911*^-11*I, 2.5863755581667647*^-11 - 2.5732305175552028*^-11* I, 3.3306690738754696*^-16 + 8.604228440844963*^-16*I, -2.525757381022231*^-15 - 8.770761894538737*^-15*I, 2.7755575615628914*^-17 + 0.*I}, {1.7763568394002505*^-15, -3.6415315207705135*^-14, 4.052314039881821*^-15, 1.867950238931826*^-14, 1.587618925213974*^-14, -5.551115123125783*^-17, 1.2483070133129104*^-14, 0.}, {1.5765166949677223*^-14, -8.182343691487404*^-14, 1.2656542480726785*^-14, 3.6193270602780103*^-14, 1.7430501486614958*^-14, 0., -3.4139358007223564*^-15, -2.0358714714063808*^-14}} You see that all the residues are small, so the fact that some of them are too large to be regarded by Mathematica as 0 is due to inexact coefficients and round off errors. For example: Chop[%, 10^(-8)] {{0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0}} which means that the residues are all less than 10^-8, which seems pretty good to me. There is nothing more you can do with machine precision coefficients. A system with inexact coefficients does not, of course, have an exact solution in any meaninful sense. One thing you can do is rationalize your system and then compute an approximate solution to some degree of precision. eqns2 = Rationalize[eqns1, 0]; sol2 = NSolve[eqns2, {x, x1, x2, x3, x4, x5, abar, roverw}, WorkingPrecision -> 20]; Now of course: eqns2 /. sol1 {{True, True, True, True, True, True, True, True}, {True, True, True, True, True, True, True, True}, {True, True, True, True, True, True, True, True}, {True, True, True, True, True, True, True, True}, {True, True, True, True, True, True, True, True}, {True, True, True, True, True, True, True, True}} Whehter this should be regarded as a better solution of your original system or not depends on how you obtained your original equations. Andrzej Kozlowski === Subject: Re: Cannot NSolve a system of equations You are using == to test equality of approximate solutions to the equations. You can verify that your solution is correct by slightly modifying how you test the solution. eqns1 /. Equal[u_, v_] -> Plus[u - v] /. sol // Chop The (/. Equal[u_, v_] -> Plus[u - v]) replacement takes the difference between the left and right sides of each of your equations, then the (/. sol) substitutes in your solution (as before), then finally the (// Chop) truncates to zero numbers that are nearly zero. This makes almost all of the differences zero (as required), and there are a few that survive the Chop but which are nevertheless small enough to also be zero. You can use the 2-argument form of Chop to control the range of numbers that is truncated to zero. Stephen Luttrell West Malvern, UK I have the following system that I need to solve, but I cannot get a > sensible result. Unprotect[In,Out];Clear[In,Out];ClearAll[Global`*]; > zet=0.083; > phi=0.75;eta=1.75;alpha=0.64;y1=0.235457064;y2=0.512465374;y3=0.781779009; > y4=1.109572176; y5=2.360726377;tau1=zet y1^phi;tau2=zet > y2^phi;tau3=zet y3^phi;tau4=zet y4^phi;tau5=zet y5^phi; > taubar=(tau1 y1+tau2 y2+tau3 y3+tau4 y4+tau5 y5)/ > 5;a1=(1+phi)tau1;a2=(1+phi)tau2;a3=(1+phi)tau3;a4=(1+phi)tau4;a5=(1+phi)tau5; eqns1={x1==(roverw(1-tau1)+((roverw+(1-x))y1-1)( (1-taubar+(1-abar)/ > eta)x+(taubar-tau1)roverw-(1-taubar)))/(roverw (1-tau1+(1-a1)/eta)- > ( (1-taubar+(1-abar)/eta)x+(taubar-tau1)roverw-(1-taubar))), > x2==(roverw(1-tau2)+((roverw+(1-x))y2-1)( (1-taubar+(1-abar)/eta)x+ > (taubar-tau2)roverw-(1-taubar)))/(roverw (1-tau2+(1-a2)/eta)-( (1- > taubar+(1-abar)/eta)x+(taubar-tau2)roverw-(1-taubar))), > x3==(roverw(1-tau3)+((roverw+(1-x))y3-1)( (1-taubar+(1-abar)/eta)x+ > (taubar-tau3)roverw-(1-taubar)))/(roverw (1-tau3+(1-a3)/eta)-( (1- > taubar+(1-abar)/eta)x+(taubar-tau3)roverw-(1-taubar))), > x4==(roverw(1-tau4)+((roverw+(1-x))y4-1)( (1-taubar+(1-abar)/eta)x+ > (taubar-tau4)roverw-(1-taubar)))/(roverw (1-tau4+(1-a4)/eta)-( (1- > taubar+(1-abar)/eta)x+(taubar-tau4)roverw-(1-taubar))), > x5==(roverw(1-tau5)+((roverw+(1-x))y5-1)( (1-taubar+(1-abar)/eta)x+ > (taubar-tau5)roverw-(1-taubar)))/(roverw (1-tau5+(1-a5)/eta)-( (1- > taubar+(1-abar)/eta)x+(taubar-tau5)roverw-(1-taubar))), > x==(x1+x2+x3+x4+x5)/5, abar == (a1 x1+a2 x2+a3 x3+a4 x4+a5 x5)/ > (5x),roverw==(1-x)(1-alpha)/alpha }; sol=NSolve[eqns1,{x, x1,x2,x3,x4,x5,abar, roverw}]; eqns1 /. sol Out[741]={{False, False, False, False, False, True, True, True}, > {False, False, > False, False, False, True, True, True}, {False, False, False, > False, False, True, False, True}, {False, False, True, False, False, > True, False, True}, {False, False, True, False, False, True, False, > True}, {False, False, True, True, False, True, True, False}} > What am I doing wrong? Is it just because the system is too > complicated? Any help would be truly appreciated. > Murat > === Subject: Re: Cannot NSolve a system of equations > > I have the following system that I need to solve, but I cannot get a > sensible result. > > Unprotect[In,Out];Clear[In,Out];ClearAll[Global`*]; > zet=0.083; > phi=0.75;eta=1.75;alpha=0.64;y1=0.235457064;y2=0.512465374;y3=0.781779009; > y4=1.109572176; y5=2.360726377;tau1=zet y1^phi;tau2=zet > y2^phi;tau3=zet y3^phi;tau4=zet y4^phi;tau5=zet y5^phi; > taubar=(tau1 y1+tau2 y2+tau3 y3+tau4 y4+tau5 y5)/ > 5;a1=(1+phi)tau1;a2=(1+phi)tau2;a3=(1+phi)tau3;a4=(1+phi)tau4;a5=(1+phi)tau5; > > eqns1={x1==(roverw(1-tau1)+((roverw+(1-x))y1-1)( (1-taubar+(1-abar)/ > eta)x+(taubar-tau1)roverw-(1-taubar)))/(roverw (1-tau1+(1-a1)/eta)- > ( (1-taubar+(1-abar)/eta)x+(taubar-tau1)roverw-(1-taubar))), > x2==(roverw(1-tau2)+((roverw+(1-x))y2-1)( (1-taubar+(1-abar)/eta)x+ > (taubar-tau2)roverw-(1-taubar)))/(roverw (1-tau2+(1-a2)/eta)-( (1- > taubar+(1-abar)/eta)x+(taubar-tau2)roverw-(1-taubar))), > x3==(roverw(1-tau3)+((roverw+(1-x))y3-1)( (1-taubar+(1-abar)/eta)x+ > (taubar-tau3)roverw-(1-taubar)))/(roverw (1-tau3+(1-a3)/eta)-( (1- > taubar+(1-abar)/eta)x+(taubar-tau3)roverw-(1-taubar))), > x4==(roverw(1-tau4)+((roverw+(1-x))y4-1)( (1-taubar+(1-abar)/eta)x+ > (taubar-tau4)roverw-(1-taubar)))/(roverw (1-tau4+(1-a4)/eta)-( (1- > taubar+(1-abar)/eta)x+(taubar-tau4)roverw-(1-taubar))), > x5==(roverw(1-tau5)+((roverw+(1-x))y5-1)( (1-taubar+(1-abar)/eta)x+ > (taubar-tau5)roverw-(1-taubar)))/(roverw (1-tau5+(1-a5)/eta)-( (1- > taubar+(1-abar)/eta)x+(taubar-tau5)roverw-(1-taubar))), > x==(x1+x2+x3+x4+x5)/5, abar == (a1 x1+a2 x2+a3 x3+a4 x4+a5 x5)/ > (5x),roverw==(1-x)(1-alpha)/alpha }; > > sol=NSolve[eqns1,{x, x1,x2,x3,x4,x5,abar, roverw}]; > > eqns1 /. sol > > Out[741]={{False, False, False, False, False, True, True, True}, > {False, False, > False, False, False, True, True, True}, {False, False, False, > False, False, True, False, True}, {False, False, True, False, False, > True, False, True}, {False, False, True, False, False, True, False, > True}, {False, False, True, True, False, True, True, False}} > > > What am I doing wrong? Is it just because the system is too > complicated? > > Any help would be truly appreciated. > Murat Quite possibly there are issues involving numeric stability and the presence of denominators. I was able to get a solution set, containg two solutions, by starting with exact input and then numericizing to high precision. zet = 83/1000; phi = 3/4; eta = 7/4; alpha = 16/25; {y1,y2,y3,y4,y5} = Rationalize[ {0.235457064,0.512465374,0.781779009,1.109572176,2.360726377}, 0]; With this I can do: In[34]:= Timing[sol = NSolve[N[eqns,500],vars];] Out[34]= {5., Null} In[36]:= eqns/.sol Out[36]= {{True, True, True, True, True, True, True, True}, {True, True, True, True, True, True, True, True}} Here are the solution values, at machine precision. In[39]:= InputForm[N[sol]] Out[39]//InputForm= {{x -> 0.6251836373550925, x1 -> 0.6454246796060954, x2 -> 0.6474758190687543, x3 -> 0.6445628507802813, x4 -> 0.6355486246954559, x5 -> 0.5529062126248758, abar -> 0.13411739130856176, roverw -> 0.21083420398776043}, {x -> 1., x1 -> 1., x2 -> 1., x3 -> 1., x4 -> 1., x5 -> 1., abar -> 0.13829898904658144, roverw -> 0.}} Daniel Lichtblau Wolfram Research === Subject: Re: Cannot NSolve a system of equations > > I have the following system that I need to solve, but I cannot get a > sensible result. > > Unprotect[In,Out];Clear[In,Out];ClearAll[Global`*]; > zet=0.083; > phi=0.75;eta=1.75;alpha=0.64;y1=0.235457064;y2=0.512465374;y3=0.781779009; > y4=1.109572176; y5=2.360726377;tau1=zet y1^phi;tau2=zet > y2^phi;tau3=zet y3^phi;tau4=zet y4^phi;tau5=zet y5^phi; > taubar=(tau1 y1+tau2 y2+tau3 y3+tau4 y4+tau5 y5)/ > 5;a1=(1+phi)tau1;a2=(1+phi)tau2;a3=(1+phi)tau3;a4=(1+phi)tau4;a5=(1+phi)tau5; > > eqns1={x1==(roverw(1-tau1)+((roverw+(1-x))y1-1)( (1-taubar+(1-abar)/ > eta)x+(taubar-tau1)roverw-(1-taubar)))/(roverw (1-tau1+(1-a1)/eta)- > ( (1-taubar+(1-abar)/eta)x+(taubar-tau1)roverw-(1-taubar))), > x2==(roverw(1-tau2)+((roverw+(1-x))y2-1)( (1-taubar+(1-abar)/eta)x+ > (taubar-tau2)roverw-(1-taubar)))/(roverw (1-tau2+(1-a2)/eta)-( (1- > taubar+(1-abar)/eta)x+(taubar-tau2)roverw-(1-taubar))), > x3==(roverw(1-tau3)+((roverw+(1-x))y3-1)( (1-taubar+(1-abar)/eta)x+ > (taubar-tau3)roverw-(1-taubar)))/(roverw (1-tau3+(1-a3)/eta)-( (1- > taubar+(1-abar)/eta)x+(taubar-tau3)roverw-(1-taubar))), > x4==(roverw(1-tau4)+((roverw+(1-x))y4-1)( (1-taubar+(1-abar)/eta)x+ > (taubar-tau4)roverw-(1-taubar)))/(roverw (1-tau4+(1-a4)/eta)-( (1- > taubar+(1-abar)/eta)x+(taubar-tau4)roverw-(1-taubar))), > x5==(roverw(1-tau5)+((roverw+(1-x))y5-1)( (1-taubar+(1-abar)/eta)x+ > (taubar-tau5)roverw-(1-taubar)))/(roverw (1-tau5+(1-a5)/eta)-( (1- > taubar+(1-abar)/eta)x+(taubar-tau5)roverw-(1-taubar))), > x==(x1+x2+x3+x4+x5)/5, abar == (a1 x1+a2 x2+a3 x3+a4 x4+a5 x5)/ > (5x),roverw==(1-x)(1-alpha)/alpha }; > > sol=NSolve[eqns1,{x, x1,x2,x3,x4,x5,abar, roverw}]; > > eqns1 /. sol > > Out[741]={{False, False, False, False, False, True, True, True}, > {False, False, > False, False, False, True, True, True}, {False, False, False, > False, False, True, False, True}, {False, False, True, False, False, > True, False, True}, {False, False, True, False, False, True, False, > True}, {False, False, True, True, False, True, True, False}} > > > What am I doing wrong? Is it just because the system is too > complicated? The solutions are correct. The 'False' answers are due to numerical errors. Try this to see what I mean: In[51]:= eqns1 /. Equal -> Subtract /. sol Out[51]= {{2.45322*10^-10, 2.81113*10^-9, 2.42972*10^-9, 8.77617*10^-9, 1.59243*10^-8, -6.03961*10^-14, -1.8785*10^-13, 0.}, {-2.41096*10^-11, -8.28258*10^-10, -1.75126*10^-10, 9.1064*10^-11, 1.57208*10^-11, -6.66134*10^-16, -8.74301*10^-16, 0.}, {8.98925*10^-12 - 2.66187*10^-11 I, 2.56666*10^-11 + 6.06653*10^-11 I, -1.45572*10^-11 + 6.01381*10^-11 I, 2.02049*10^-11 - 3.9833*10^-11 I, -1.3828*10^-11 - 6.41887*10^-12 I, 4.44089*10^-16 - 8.88178*10^-16 I, -1.67227*10^-15 - 3.71925*10^-15 I, 0.+ 0. I}, {8.98925*10^-12 + 2.66187*10^-11 I, 2.56666*10^-11 - 6.06653*10^-11 I, -1.45572*10^-11 - 6.01381*10^-11 I, 2.02049*10^-11 + 3.9833*10^-11 I, -1.3828*10^-11 + 6.41887*10^-12 I, 4.44089*10^-16 + 8.88178*10^-16 I, -1.67227*10^-15 + 3.71925*10^-15 I, 0.+ 0. I}, {1.11022*10^-16, 1.38778*10^-14, 9.15934*10^-15, -2.96985*10^-15, -2.52021*10^-14, 5.55112*10^-17, -1.2032*10^-14, 0.}, {-2.15383*10^-14, 5.72875*10^-14, 2.22045*10^-15, -7.54952*10^-15, -3.08642*10^-14, 0., 1.94289*10^-15, 9.36751*10^-15}} === Subject: Re: Redundant manipulate What does that Labeled accomplish that the following does not? Column[{Slider[Dynamic[10/a, (a = 10/#) &], {1, 10}], Slider[Dynamic[a], {1, 10}], Dynamic[a]}, Alignment -> Center] >> I have a manipulate like this: >> Manipulate[ >> Row[{a = , a, b = 2 a = , b = 2 a}] >> , {a, -10, 10, 1}, {b, -20, 20, 1}] >> If I change a, then b changes, but I also want that when I change b, I'm not sure how to do this with Manipulate, but it is achievable with = > Dynamic: Labeled[Column[{Slider[Dynamic[10/a, (a = 10/#) &], {1, 10}], > Slider[Dynamic[a], {1, 10}]}], Dynamic[a]] > -- 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 fax 413 545-1801 Amherst, MA 01003-9305 === Subject: Re: Range of Use of Mathematica > > I think WRI would gain a lot by dedicating one or two sessions at the > conference in the Autumn to discussing these issues. > > David Bailey > http://www.dbaileyconsultancy.co.uk I don't know if WRI has an external advisory board, comprising an adequately diverse and representative group of outside (non-WRI-staff) Mathematica users, but if it doesn't, it should. === Subject: Re: Range of Use of Mathematica well, I disagree, Workbench can only be used together *with* a Notebook. Mathematica always runs in some kind of Notebook interface (if not used in batch mode) and Workbench is just an add-on for *major* devellopment. I can also not see that there are two documentation systems. There is just one in addition to legacy documentation. I believe that for those users, who have intrinsically understood the basic idea of the Mathematica system and its language (and that is a really difficult step), the new hyperlinked documentation is just fine and practical to find the way through the jungle of commands and options, with a printed book this would be just impossible. (Of course, many details in the documentation should be improved and even enlarged.) However, I agree that the possibilities the whole Mathematica system (including Workbench) provides for using it, e.g. for package development, are rather varied, that even seasoned users cannot easily make out best practices, or to say it in terms of AES, see a product strategy. So it is indeed not easy to decide, if to use Workbench for development or the built-in package editor. It may be that Wolfram decided to devlop various lines of interface elements, and see how they work and people like it... and to decide later what to keep and what to discontinue... I personally like to have many options to choose from, but the variety, of course, can be tremendously confusing to casual users. Michael Weyrauch > ........... What is, or what could be, or should be, >> the _strategic vision_ for Mathematica, as a system or as a product line >> or as a useful tool or even as a communications standard? And then, as >> a necessary of this strategic vision, what is really the target market >> or audience for Mathematica? > ......... with user documentation being the most obvious area for >> this kind of criticism. > > I feel I know what AES means. I have been in the software business for > an awfully long time, and one problem that happens over and over again, > is that an OS, computer language, or application starts life as exciting > but limited, evolves through a series of new versions into something > really powerful and versatile, and then decays into something bloated > and un-loved. The best example of this phenomenon would be Microsoft > Windows, but there are many others. > > I would hate to see Mathematica follow this route - though maybe it is > as inevitable as human senescence and death, I don't know! > > One sign of bloat, is that there are now two major interfaces - notebook > and Workbench (not to mention Math.exe) and such a profusion of commands > and options that even those of us that use the product regularly cannot > hope to be familiar with more than a smallish subset. There are also two > help systems! This has, unfortunately, impacted on the quality of > documentation. My advice to a beginner would be to read the V5.0 or even > V4.0 documentation (plus a few tips about the changes in Graphics) to > get some idea of the way the system works. > > I think WRI would gain a lot by dedicating one or two sessions at the > conference in the Autumn to discussing these issues. > > David Bailey > http://www.dbaileyconsultancy.co.uk > > > > === Subject: Re: Range of Use of Mathematica > One sign of bloat, is that there are now two major interfaces - > notebook > and Workbench (not to mention Math.exe) and such a profusion of > commands > and options that even those of us that use the product regularly > cannot > hope to be familiar with more than a smallish subset. There are also > two > help systems! This has, unfortunately, impacted on the quality of > documentation. My advice to a beginner would be to read the V5.0 or > even > V4.0 documentation (plus a few tips about the changes in Graphics) to > get some idea of the way the system works. I think one should not loose sight of in my opinion, a very essential fact, which is that the Mathematica Kernel, has remained largely unchanged, except (of course) for continual enhancement by addition of new functions, which only make it more efficient and powerful (and make programing considerably easier). What this means is, that people who see themselves essentially as Kernel users, are not in any fundamental away affected by any of the changes you are mentioning above. I know, because I consider myself one of them. I have never tried using Workbench (even though I have downloaded it), and I have not even made a serious effort to learn how MakeBoxes etc, works. I still write all research in TeX. I know that it is possible to use FrontEndToken etc, and if I even wanted to do so I know where to find the documentation - but I have never found any incentive to do this. However, I have become interested in the new Dynamic functionality, partly because I think it is a great teaching tool and partly because of the Demonstrations project, but this is really the first new addition to the Front End that has interested me. I am sure that I am not alone. In fact, Wolfram has a different set of people working on the Kernel and on the Front End, and I am sure that there are people in the Kernel group whose knowledge of the workings of the Front End isn't much greater than mine. I mention this because even though I have not, until recently, been very interested in the Front End, I have never been in anyway inconvenience by the developments that have taken place in that area. True, Mathematica has grown larger, but not more than have my hard that seem to worry AES. I am a mathematician and intend to remain one. I use Mathematica in the way that it was originally advertised, as a system for doing mathematics by computer. The most far reaching change in the program that was ever made happened, in fact, in version 2, when the Kernel was separated from the Front End. Sometime little later WRI changed its advertising slogan to something like the world's only fully integrated technical computing system. That, of course, shows clearly the strategic direction that WRI chose and it has consistently followed since. But for me it has always remained a system for doing mathematics by computer. In spite of that, I see no reason to complain, because I have never found the slightest conflict between these two roles of Mathematica. I have never found , for example, that the development of Mathematica's typesetting capabilities has in any way adversely affected any of Mathematica's numerical or algebraic ones, which are the ones that really matter to me. So I really still fail to see what this whole discussion is supposed to be about. I particularly, I can't understand why someone who keeps saying that Mathematica does not need publishing or presentation capabilities etc. and should only be used for computations would at the same time complain about the supposed lack of documentations of functionality which, according to him, should not be there in the first place. Andrzej Kozlowski === Subject: intersecting a hypercube and a hyperplane Hi all, I have a problem you will laugh about (maybe). Here: You have a hypercube and a hyperplane. They intersect. In n-D the intersection region is a (n-1)-D object. I am interested in determining the vertices of the intersection object. Of course, I can check all the edges and determine all intersection vertices, but that takes n 2^(n-1) checks. Do you know of any algorithm to compute that? The hyperplane is Sum(Xi)=C, for some C, where Xi is the i-th coordinate. Idea: For each vertex of the hypercube you add its coordinates, and form a partition into three sets (vertices behind, at, and in-front of the hyperplane). That information would allow you to restrict the search to edges involved in two of those sets. The problem is the preprocessing time (to compute the sum for every vertex) itself is exponential on n. I need something more efficient than exponential, or else, a pointer that indicates that no such algorithm exists. This comes from an optimization problem. The hypercube is the search space and the hyperplane corresponds to a energy conservation constraint. I am using an evolutionary computation technique, and are interested in generating a population of points that lie in the intersection. Any pointers/ideas will be greatly appreciated. Juan Flores Univesity of Michoacan, Mexico