A27 ==== please nd the documentation how to install the fonts and styleles.It should be in$TopDirectory/SysmteFiles/IncludeFiles/TeX/texmf/doc/ wolframand is called msymdoc.pdfYou have to add the $TopDirectory/SysmteFiles/IncludeFiles/TeX/texmf/to the texmf trees that teTeX search and eventualedit the buggy font name data base.Mail me direct if you have still problems. Jens> I need some help, here. I'm using Mathematica 4.2 on OS X and I'd> like to save a notebook so that I can include it in a LaTeX le.> According to the Wolfram site, Mathematica has a convenient save as> option just for this sort of task. Unfortunately, I can't get it to> work for the life of me. The notebook saves, but it won't compile.> I use TeXShop, a very standard LaTeX environment for OS X that's> built (I believe) on top of teTeX. Per the Ôrequest' of my LaTeX> compiler, I've located copies of notebook2e.sty and wrisym.sty, but> this doesn't help; the fatal error is something like Ô! LaTeX Error:> This NFSS system isn't set up properly.'> Does anybody out there have a slick solution to my problem? It seems> to me that Wolfram should have made this process work out-of-the-box> with standard installations of Mathematica 4.2 and standard> installation of LaTeX utilities. Perhaps I'm missing something.> I hope somebody out there can give me a hand with this. (FWIW, I> have access to latex and Mathematics 4.2 on linux and NT platforms,> too.)> --> Jason Miller, Ph.D.> Division of Mathematics and Computer Science> Truman State University> 100 East Normal St.> Kirksville, MO 63501> http://vh216801.truman.edu> 660.785.7430 ==== =-----Mensagem original-----Enviada em: ter.8da-feira, 10 de dezembro de 2002 06:11Para: mathgroup@smc.vnet.netAssunto: Re: Levembergim sure if you try a search engine like google or yahoo you'll nd it.justtype in the keywords in what your looking for.RAyRAyHmmm... Already tried that, before posting this msg. All I got was a dozenlinks of software that uses this algorithm for something, but no theory atall. Just some books about it.Tks anyway. ==== =http://www.library.cornell.edu/nr/bookcpdf/c15-5. pdfpage 683 Jens-----------------------TKS a lot, Jens!Saved my life! :-)Luiz ==== => Respected Sir/Madam,> I want to super impose(add) two curves of> different ranges-one is -5ms to 15 ms and other one> is 0ms to 20ms of different amplitude.> So kindly suggest me>> --> With best wishes..............>>> SISIR KUMAR NAYAK> ELECTRICAL SCIENCE> U-79,STUDENT HOSTEL> IISC, BANGALORE.> PH:3942624(080)One way:gr1 = Plot[Sin[x], {x, 0, 7}, PlotStyle -> {Hue[0], Thickness[0.01]}];gr2 = Plot[Sin[2*x], {x, 2, 5}, PlotStyle -> {Hue[0.7], Dashing[{0.01, 0.02}]}];Show[gr1, gr2, PlotRange -> All];PlotRange ->All is to protect against Mathematica restricting the display towhat it calculated is interesting - not actually needed here. You could alsoset the plot numerically: here PlotRange-> {{0,7},{-1,1}} would be suitable.We may not want to show the separate curves, only the combination: here arethree ways to do this1)gr1 = Plot[Sin[x], {x, 0, 7}, PlotStyle -> {Hue[0], Thickness[0.01]}, DisplayFunction -> Identity];gr2 = Plot[Sin[2*x], {x, 2, 5}, PlotStyle -> {Hue[0.7], Dashing[{0.01, 0.02}]}, DisplayFunction -> Identity];Show[gr1, gr2, PlotRange -> All, DisplayFunction -> $DisplayFunction];2)Show[Plot[Sin[x], {x, 0, 7}, PlotStyle -> {Hue[0], Thickness[0.01]}, DisplayFunction -> Identity], Plot[Sin[2*x], {x, 2, 5}, PlotStyle -> {Hue[0.7], Dashing[{0.01, 0.02}]}, DisplayFunction -> Identity], DisplayFunction -> $DisplayFunction, PlotRange -> All]3)Show[Block[{$DisplayFunction = Identity}, {Plot[Sin[x], {x, 0, 7}, PlotStyle -> {Hue[0], Thickness[0.01]}], Plot[Sin[2*x], {x, 2, 5}, PlotStyle -> {Hue[0.7], Dashing[{0.01, 0.02}]}]}], PlotRange -> All];--Allan---------------------Allan HayesMathematica Training and ConsultingLeicester UKwww.haystack.demon.co.ukhay@haystack.demon.co.ukVoice: +44 (0)116 271 4198 ==== =[Gianluca - I have reset your question a little - Allan]I am confused by this result: Module[{a},a=x;g[x_]=a] x g[y] x ?g Global`g g[x$_] = xSomehow I would expect the same output as Module[{},a=x;g[x_]=a] x g[y] y ?g Global`g g[x_] = xThe difference is a dollar sign.> +---------------------------------+> | Gianluca Gorni |> | Universita` di Udine |> | Dipartimento di Matematica |> | e Informatica |> | via delle Scienze 208 |> | I-33100 Udine UD |> | Italy |> +---------------------------------+> | Ph.: (39) 0432-558422 |> | http://www.dimi.uniud.it/~gorni |> +---------------------------------+EXPLANATIONFIRST EXAMPLE: Module[{a},a=x;g[x_]=a]In Module1) the occurences of variable a are renamed to a$n (standard evaluation ofModule);2) because the a in g[x_]= a is in the target of the x in x_ , and in thetarget of the a in {a}, the x is changed to x$ (standard scoping renaming toavoid clashes - not specic to Module);giving Module[{a$n},a$n=x;g[x$_]=a$n]The body of Module, a$n=x; g[x$_]=a$n, is now evaluated.The rule for g[x$_] = x is stored.The output from Module is xSECOND EXAMPLE: Module[{},a=x;g[x_]=a];g[y]There is no renamingWhen the body of Module is evaluated the rule for g[x_]=x is stored.We can follow the evaluations with TracePrint.Allan---------------------Allan HayesMathematica Training and ConsultingLeicester UKwww.haystack.demon.co.ukhay@haystack.demon.co.ukVoice: +44 (0)116 271 4198 ==== =For example (if I understand well what you want):In[7]:=p1=Plot[Sin[x/5[Pi]],{x,-5,15},PlotRange->{{-5,20 },{-2,2}}, PlotStyle->RGBColor[1,0,0]];In[9]:=p2=Plot[2Sin[2x/5[Pi]],{x, 0,20},PlotStyle->RGBColor[0,0,1]];In[10]:=Show[p1,p2] Meilleures salutationsFlorian Jaccard-----Message d'origine-----Envoy.8e : mar., 10. d.8ecembre 2002 10:10è : mathgroup@smc.vnet.netObjet : superimpose to curvesRespected Sir/Madam,I want to super impose(add) two curves ofdifferent ranges-one is -5ms to 15 ms and other oneis 0ms to 20ms of different amplitude.So kindly suggest me--With best wishes..............SISIR KUMAR NAYAKELECTRICAL SCIENCEU-79,STUDENT HOSTELIISC, BANGALORE.PH:3942624(080) ==== =your example does work if you put<< Graphics`MultipleListPlot`into a seperate cell of its own and evaluate it rst of all.Matthias Bode.-----Ursprí.b9ngliche Nachricht-----Gesendet: Dienstag, 10. Dezember 2002 10:11An: mathgroup@smc.vnet.netBetreff: MultipleListPlot not workingI can't get this function to do anything. I read it in with Needs[Graphics`MultipleListPlot`];and no error messages appear, and the le IS present inthis directory:C:Program FilesWolfram ResearchMathematica4.1 (2)AddOnsStandardPackagesGraphics'MultipleListPlot.mbut when I do an example right out of Help such as<< Graphics`MultipleListPlot`(list1 = Table[{x, Sin[2 Pi x]}, {x, 0, 1, 0.1}]; list2 = Table[{x, Cos[2 Pi x]}, {x, 0, 1, 0.1}]);MultipleListPlot[list1, list2], nothing appears (no plot shows) except this text!(MultipleListPlot[{{0, 0}, {0.1`, 0.5877852522924731`}, {0.2`, 0.9510565162951535`}, {0.30000000000000004`, 0.9510565162951535`}, {0.4`, 0.5877852522924732`}, {0.5`, 1.2246063538223773`*^-16}, {0.6000000000000001`, (-0.5877852522924734`)}, {0.7000000000000001`,(-0.9510565162951535`)}, {0.8`, (-0.9510565162951536`)}, {0.9`, (-0.5877852522924734`)},{1.`, (-2.4492127076447545`*^-16)}}, {{0, 1}, {0.1`, 0.8090169943749475`},{0.2`, 0.30901699437494745`}, {0.30000000000000004`,(-0.30901699437494756`)}, {0.4`, (-0.8090169943749473`)}, {0.5`, (-1.`)}, {0.6000000000000001`, (-0.8090169943749472`)}, {0.7000000000000001`,(-0.30901699437494756`)}, {0.8`, 0.30901699437494723`}, {0.9`, 0.8090169943749473`}, {1.`, 1.`}}]) ==== =Dear Allan,assuming you have posted this to MathGroup, I reply in public.>-----Original Message----->Sent: Friday, December 06, 2002 9:49 PM>>I give below some further speed-ups.>The improvement, at least on the data I used, is due to using>Split[Sort[_]] right at the start to parcel the data - it probably depends>on there being a lot of repetition of the rst term of the entries in the>data.Yes, the idea is, to exploit all work already done, andComposition[Split,Sort]appears to be a fundamental design pattern for the language!>The code for Matchings7 below is faster than Daniel Lichblau's recently>posted code - though he suggests that this might be speeded up by>substituting numbers for strings and compiling.>>Data>> Random[Integer, {1, 2000}]}, {6000}];> Random[Integer, {1, 2000}]}, {12000}];>>Get the members of s1 with the same rst entry as some member of s2.>>Previous code (preserves order)>> Matched1[s1_,s2_]:=> Cases[ s1,{Alternatives@@Union[s2[[All,1]]],_}]>> Matched1[s1,s2];//Timing>> {3.4 Second,Null}>>New code (does not preserve order) - note the use of >s1[[Ordering[s1[[All, 1]]]]] to save on ordering with respect to the secondentries>> Matched4[s1_,s2_]:=> Cases[Split[s1[[Ordering[s1[[All,1]]]]], #1[[1]] ==== #2[[1]]&],> {{Alternatives@@Union[s2[[All,1]]],_},___}]>> Matched4[s1,s2];//Timing>> {1.6 Second,Null}>This is very pleasing, and a general pattern if I understandUnion[s2[[All,1]]] as the sorted list of keys searched. A slight improvement is still possible though. We suffer from a performancepenalty imposed by the test function for Split. I had already published howto overcome this, here now recalled in a procedure:Attributes[SortSplit1] = {HoldFirst};SortSplit1[s_] := Module[{ord = Ordering[s[[All, 1]]], secs}, secs = FoldList[Plus, 0, Length /@ Split[s[[ord, 1]] ]]; s[[Take[ord, #]]] & /@ Transpose[{Drop[secs + 1, -1], Drop[secs, 1]}]]ssb = SortSplit1[s1]; // Timing{0.271 Second, Null}whereas ssa = Split[s1[[Ordering[s1[[All, 1]]]]], #1[[1]] ==== #2[[1]] &]; // Timing{0.571 Second, Null}In[19]:= ssa == ssbOut[19]= TrueThe Hold-Attribute for SortSplit1 is essential for its performance! If youdon't want to give that, you alternatively may make a local copy of theargument as inSortSplit1x[s1_] := Module[{s = s1}, Module[{ord = Ordering[s[[All, 1]]]}, s[[Take[ord, #]]] & /@ With[{secs = FoldList[Plus, 0, Length /@ Split[s[[ord, 1]] ]]}, Transpose[{Drop[secs + 1, -1], Drop[secs, 1]}]]]]ssx = SortSplit1x[s1]; // Timing{0.301 Second, Null}In[56]:= ssx == ssaOut[56]= TrueI observe this, yet my understanding of Mathematica is not deep enough toexplain it, let alone use this to deduce, so to speek, improved coding. SuchI have to store it in my brain as an ad-hoc rule of surmise. I would be verypleased to have that claried.With this we now may tweak Matched4 a bit further:Attributes[Matched4bis] = {HoldAll};Matched4bis[s1_, s2_] := Cases[SortSplit1[s1], {{Alternatives @@ Union[s2[[All, 1]]], _}, ___}](The need to Hold propagates! Not for SortSplit1x of course)Matched4x[s1_, s2_] := Cases[SortSplit1x[s1], {{Alternatives @@ Union[s2[[All, 1]]], _}, ___}]In[58]:= Matched4[s1, s2]; // TimingOut[58]= {1.061 Second, Null}In[59]:= Matched4bis[s1, s2]; // TimingOut[59]= {0.761 Second, Null}In[60]:= Matched4x[s1, s2]; // TimingOut[60]= {0.781 Second, Null}>>Get the full matchings (this code will work on {s1,s2,....,sn}, as well as>just {s1, s2})>> Matchings7[s_]:=> Module[{st,pt,sp},> st = #[[Ordering[#[[All,1]]]]]&/@s;> sp=Split[#,#1[[1]] ==== #2[[1]]&]&/@st;> pt= (Alternatives@@(Intersection@@ st[[All,All,1]]));> Transpose[Cases[#,{{pt,_},___}]&/@sp]> ];>> (ms7=Matchings7[{s1,s2}]);//Timing>> {3.46 Second,Null}>I didn't manage to introduce SortSplit1 into Matchings7 (the Hold mechanismsseems to break down when Mapping SortSplit1 over the argument), however itworks with SortSplit1x:Matchings7x[s_] := Module[{pt, sp}, sp = SortSplit1x /@ s; pt = (Alternatives @@ (Intersection @@ s[[All, All, 1]])); Transpose[Cases[#, {{pt, _}, ___}] & /@ sp]];In[173]:= ms7x = Matchings7x[{s1, s2}]; // TimingOut[173]= {1.652 Second, Null}In[174]:= ms7 = Matchings7[{s1, s2}]; // TimingOut[174]= {2.364 Second, Null}In[175]:= ms7ax == ms7Out[175]= TrueWell, I just made it (writing calls upon thinking):Attributes[Matchings7a] = {HoldAll};Matchings7a[s_] := Module[{pt, sp}, sp = SortSplit1 /@ Unevaluated[s]; pt = (Alternatives @@ (Intersection @@ s[[All, All, 1]])); Transpose[Cases[#, {{pt, _}, ___}] & /@ sp]];In[227]:= ms7a = Matchings7a[{s1, s2}]; // TimingOut[227]= {1.572 Second, Null}>>Daniel Lichtblau (gives essentially the same information as Matchings7)>> myTest[l1_, l2_] :=> Module[{s1, s2, m = Length[l1], n = Length[l2], j, k, res = {}, ord },> s1 = Sort[l1]; s2 = Sort[l2];> For[j = 1; k = 1, j <= m && k <= n, Null,> ord = Order[s1[[j,1]], s2[[k,1]]];> If[ord == 1, j++; Continue[]];> If[ord == -1, k++; Continue[]];> res = {res, {s1[[j]], s2[[k]]}};> j++; k++;> ];> Partition[Partition[Flatten[res], 2], 2]> ]>> myTest[s1,s2];//Timing>> {7.47 Second,Null}>I do not agree, as to this containing the same information, see:In[239]:= my = myTest[s1, s2]; // TimingOut[239]= {5.578 Second, Null}In[242]:= Length /@ {my, ms7}Out[242]= {5944, 625}In[243]:= Composition[Length, Union, Flatten] /@ {my, ms7}Out[243]= {2592, 2624}In[244]:= Length /@ {my, Flatten[ms7, 1]}Out[244]= {5944, 1250}Or compareIn[248]:= ms7[[1]]Out[248]={{{AAAA, 747}, {AAAA, 1580}, {AAAA, 1929}, {AAAA, 1277}}, {{AAAA, 1241}, {AAAA, 658}, {AAAA, 141}, {AAAA, 1567}, {AAAA, 371}, {AAAA, 861}, {AAAA, 1963}, {AAAA, 1607}, {AAAA, 316}, {AAAA, 1674}, {AAAA, 1501}, {AAAA, 1749}, {AAAA, 1777}, {AAAA, 172}, {AAAA, 568}, {AAAA, 1752}}}In[250]:= Take[my, 10]Out[250]={{{AAAA, 747}, {AAAA, 141}}, {{AAAA, 1277}, {AAAA, 172}}, {{AAAA, 1580}, {AAAA, 316}}, {{AAAA, 1929}, {AAAA, 371}}, {{AAAB, 417}, {AAAB, 18}}, {{AAAB, 1521}, {AAAB, 332}}, {{AAAB, 1526}, {AAAB, 396}}, {{AAAB, 1693}, {AAAB, 525}}, {{AAAB, 1961}, {AAAB, 664}}, {{AAAB, 1976}, {AAAB, 827}}}Quite a lot is missing here! This is caused by the fact that at match, whenOrder[...] == 0, both pointers j, k are incremented, such elements from thelonger sequence at this (matching) key will disappear.I had already communicated a procedural solution, here adapted to your formof output:myMatch4[s1_, s2_] := Module[{ss1 = Sort[s1], ss2 = Sort[s2], keys, rr1, rr2}, keys = Intersection[ss1[[All, 1]], ss2[[All, 1]]]; rr1 = getLabelled[ss1, keys]; rr2 = getLabelled[ss2, keys]; Transpose[{rr1, rr2}]]In[266]:= my4 = myMatch4[s1, s2]; // TimingOut[266]= {5.748 Second, Null}In[267]:= Map[Sort, ms7, {2}] ==== my4Out[267]= TrueOne might obtain Brian's form just by Apply'ing Outer[List,##,1]& at level{1} to get all matching pairs. >>-->Allan>>--------------------->Allan Hayes>Mathematica Training and Consulting>Leicester UK>www.haystack.demon.co.uk>hay@haystack.demon.co.uk>Voice: +44 (0)116 271 4198>Here now a better procedural solution, combining Daniel's ansatz withobservations made so far:myMatch5[s1_, s2_] := Module[{ss1 = SortSplit1[s1], ss2 = SortSplit1[s2], acc}, Module[{u1 = ss1[[All, 1, 1]], u2 = ss2[[All, 1, 1]], j = 1, jx = Length[ss1], k = 1, kx = Length[ss2], res = acc[]}, While[j <= jx && k <= kx, Switch[Order[u1[[j]], u2[[k]]], 1, ++j, -1, ++k, 0, (res = acc[res, {ss1[[j]], ss2[[k]]}]; ++j; ++k)] ]; List @@ Flatten[res, Innity, acc]]]In[277]:= my5 = myMatch5[s1, s2]; // TimingOut[277]= {2.313 Second, Null}In[278]:= my5 ==== ms7Out[278]= TrueEffectively this is a prototype of a Sort-Merge procedure, pairingsubsequences of equal keys. Although Mathematica has a most performant Sortprocedure, there is nothing comparable for the merge step. Having this one(or something similar) in the kernel, certainly would add value to theproduct. SortSplit1 may be considered too.Hartmut ==== =Steven,With a highly oscillatory function like that you need to increase the numberof PlotPoints. Otherwise Mathematica begins to miss some of the features ofthe curve.David Parkdjmp@earthlink.nethttp://home.earthlink.net/~djmp/ STHHatton's Law:There is only One inviolable Law. ==== =Sisir,Make the separate plots and suppress the display. Then combine the two plotswith a Show statement. As a little extra I put color on the two curves. TheBlock statement temporarily sets the system display function to Identity,which suppresses the extra display of the separate curves.Needs[Graphics`Colors`]Block[{$DisplayFunction = Identity}, plot1 = Plot[Sin[x], {x, 0, Pi}, PlotStyle -> Blue]; plot2 = Plot[2Sin[x], {x, Pi/4, 5Pi/4}, PlotStyle -> Red];]Show[{plot1, plot2}];Using the DrawGraphics package from my web site it can be done in a slightlymore natural and direct manner.Needs[DrawGraphics`DrawingMaster`]Draw2D[ {Blue, Draw[Sin[x], {x, 0, Pi}], Red, Draw[2Sin[x], {x, Pi/4, 5Pi/4}]}, Axes -> True];David Parkdjmp@earthlink.nethttp://home.earthlink.net/~djmp/U-79, STUDENT HOSTELIISC, BANGALORE.PH:3942624(080) ==== =Anto,This is the kind of question that is very difcult to answer because yougive very little information. Which procedure? What kind of problem? What doyou mean by the whole procudure? Nor is the subject title of the postingvery helpful for people searching the archives.Many of the high level routines in Mathematica such as Solve, Integrate,etc., are written in C-code and employ advanced algorithms that are probablyvery difcult to follow and not at all educational or enlightening. So, youcan't see and probably don't want to see everything that is going on.However, for purposes of learning methods you don't have to use all ofMathematica's advanced routines. You can program Mathematica to do the stepsand see how some procedure you are trying to learn can be implemented. Forexample, at my web site I have an introductory notebook that shows how tosolve equations without using the Solve routine, but doing it step by step.On the other hand if you have a question about how some advanced routineworks, you will have to take it up with WRI and may not nd them all thatforthcoming.David Parkdjmp@earthlink.nethttp://home.earthlink.net/~djmp/Sender: steve@smc.vnet.netApproved: Steven M. Christensen , Moderator ==== =Steven,observe:In[2]:= Options[Plot, PlotPoints]Out[2]= {PlotPoints -> 25}As you used the default, 25 plot points are not only not enough toreasonably display the rapidly oscillating function, they are also too fewstarting points for the adaptive sampling algorithm. Just increase, e.g.Plot[x Sin[x], {x, -100, 100}, PlotPoints -> 333]is quite pleasing to the eye, even if enlarged. --Hartmut Wolf>-----Original Message----->Sent: Tuesday, December 10, 2002 10:13 AM>To: mathgroup@smc.vnet.net>{-100,100}] and >disvovered that the portion of the plot between,9.5Pi and 11Pi >is displayed >as a line segment joining the points {9.5 , 9.5 Sin[9.5]} and {11 , 11 >Sin[11]}. I've also found that the plot from x=-100 to >x=99.99 is incorrect. >The plot over the range [-100,99] is correct. What is >happening here? Does >this happen on other systems?>-- >STH>Hatton's Law: >There is only One inviolable Law.>> ==== => Can anyone explain the following results?>> In[8]:=> r[t_]:=4-3Sin[t]>> In[9]:=> !(NIntegrate[Sqrt[r[t]^2 + (r')[t]^2], {t, 0, 2 [Pi]}])>> Out[9]=> 28.8142This is correct.> In[10]:=> !(Integrate[Sqrt[r[t]^2 + (r')[t]^2], {t, 0, 2 [Pi]}] // N)>> Out[10]=> -18.9606This is wrong. The exact (incorrect) result of this integration in myversion 4.1 is, after simplication,2*(EllipticE[Pi/4, -48] + EllipticE[(3*Pi)/4, -48] - 25*(EllipticF[Pi/4, -48] + EllipticF[(3*Pi)/4, -48])).The last two terms, involving incomplete elliptic integrals of the rstkind, are spurious. Omitting them, the answer would then be correct.However, there is a simplication which I'm surprised that Mathematicadoesn't know:2*(EllipticE[Pi/4, -48] + EllipticE[(3*Pi)/4, -48]) should simplify toan expression with just a _single complete_ elliptic integral of thesecond kind, namely(#) 4*EllipticE[-48], a much nicer form of the exact (correct) answer.But there's more of interest here!Note that the radicand of the integrand simplies to just 25 - 24*Sin[t].So what do we get if we ask Mathematica toIntegrate[Sqrt[25 - 24*Sin[t]], {t, 0, 2*Pi}]? We nd yet another error!We get2*EllipticE[Pi/4, -48] + 2*EllipticE[(3*Pi)/4, -48] + 4*EllipticF[I*ArcSinh[1/(4*Sqrt[3])], -48]the last term of which is spurious (but, being imaginary, is differentfrom the spurious terms mentioned previously).Next, let's see what we get if we ask for an indenite integral:Integrate[Sqrt[25 - 24*Sin[t]], t] yields -2*EllipticE[(Pi/2 - t)/2, -48].Hooray! If we now use the Fundamental Theorem _ourselves_, wedo get a correct exact answer (nally!), albeit not in the simpliedform of (#). So I must now wonder why Mathematica got a spurious imaginaryterm when it did the corresponding denite integral.Finally, let's see what happens if we rst transform the integralourselves using the standard substitution u = Sin[t]:We get 2*Integrate[Sqrt[(25-24u)/(1-u^2)], {u, -1, 1}].For this, Mathematica then gives(28*I)*(EllipticE[1/49] - EllipticE[ArcSin[7], 1/49] + EllipticF[ArcSin[7], 1/49] - EllipticK[1/49])which, although messy (and looking as though it might be complex,when it is in fact purely real), does happen to be correct! Hoorayagain!In summary, correct exact results can -- at least, sometimes -- beobtained by assisting Mathematica ourselves, although these are notas simple as (#). But we should not have to lead Mathematica by thehand, so to speak. I will be very happy when such matters concerningelliptic integrals are corrected.David Cantrell-- -------------------- http://NewsReader.Com/ --------------------Usenet Newsgroup Service New Rate! $9.95/Month 50GB ==== => disvovered that the portion of the plot between,9.5Pi and 11Pi is displayed> as a line segment joining the points {9.5 , 9.5 Sin[9.5]} and {11 , 11> Sin[11]}. I've also found that the plot from x=-100 to x=99.99 is incorrect.> The plot over the range [-100,99] is correct. What is happening here? Does> this happen on other systems?> -- Although Mathematica attempts to rene the plot recursively as needed toproduce an accurate plot, you can fool the algorithm. One way is to providea function with more oscillations than the initial number of PlotPoints. Onmy system (4.2 on Mac), the default initial number of PlotPoints is 25. Yourfunction oscillates about 32 times over the domain. Increase the number ofPlotPoints to 50. The problem goes away.As you have seen, fewer PlotPoints may work, depending upon the initialdistribution of points. Plot your examples with PlotDivision->1 to see thatsmall adjustments in the domain change the number of oscillations capturedby the initial set of points.Tom Burton ==== => Interesting optimization problem:> Given a list of n-dimensional points, nd a point that minimizes the> average distance to all the given points.>> For example, here are 4 points in 3-space:>> points = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}, {10, 11, 12}};>> Here's the formula for euclidean distance:>> d[p1_, p2_] := Sqrt[Tr[(p1 - p2)^2]]>> Now we want to nd the point where all the partial derivatives are 0:>> eq[i_] := D[Tr[d[Array[z, 3], #] & /@ points], z[i]]>> eqs = (eq[#] == 0 & /@ Range[3])>> Solve[eqs, {z[1], z[2], z[3]}]>> But Mathematica chokes on that...>> Any ideas for a better algorithm to nd the total-distance minimizing> point (this should work for any dimensions; 16 in my case)?>> Daniel>> --> Daniel Reeves -- http://ai.eecs.umich.edu/people/dreeves/>> Humans are genes' way of making more genes. -- Richard Dawkinssearch terms: Euclidean 1-median problem Fermat-Weber problemRob PrattDepartment of Operations Researchhttp://www.unc.edu/~rpratt/ ==== => Given a list of n-dimensional points, nd a point that minimizes the> average distance to all the given points.> ...> Solve[eqs, {z[1], z[2], z[3]}]> But Mathematica chokes on that...>> Any ideas for a better algorithm to nd the total-distance minimizing> point (this should work for any dimensions; 16 in my case)?Well, I happen to know the answer in three dimensions:In[15]:=centroid = Plus@@points/Length[points]Out[15]= 11 13 15{--, --, --} 2 2 2In[16]:=eqs /. Thread[Array[z,3]->centroid]Out[16]={True, True, True}Maybe you can extend this to n dimensions. I cannot do so, at least nottrivially. However, FindRoot worked nicely in the 16-dimensional examples Itried.Tom Burton ==== =Is there a way to construct a graphical map of a Mathematica source le? - D. ==== =just a small question. I export my graph by Export[le.eps, %, EPS]. All works well exept axes labels. In my .ps le there is no ratio sign / or a horizontal line between y and y0 while they are available on a Mathematica graph.Ok, I tried x:x0 and it works, but it looks not so elegant (to my mind, but I keep it as a default now).Is it possible to do something? It's not very crucial but nevertheless...Veniamin ==== =Can Mathematica do the following? (I provided answers that I did by hand).1. Find the GCD of f[x_] := x^5 + 4x^4 + 6x^3 + 6x^2 + 5x +2,g[x_] := x^4 + 3x^2 + 3x +6Answer: gcd (f(x), g(x)) = x^3 + 4x^2 + 5x + 2over the eld Z7? (I think the answer is easy and is yes).2. Write the GCD above as a linear combination of the given polynomials?Answer: 5*(x^5 + 4x^4 + 6x^3 + 6x^2 + 5x +2) + (2x + 1)*(x^4 + 3x^2 + 3x +6)This one I am not sure about (I guess we can do it piece-meal, but is therea slick function to do it?). ==== =regarding the package Statistics'NonlinearFit' is it possible to t anarray of data with a function dened by NIntegrate?Example:f[r_,a_] := NIntegrate[x/(x^2+a^2) Exp[-x^2] BesselJ[0,x r],{x,0,Innity}]BestFitParameters /. NonlinearRegress[data,f[r,a],r,{a},RegressionReport ->BestFitParameters]I mean, I know it's not possible because I tried and it doesn't work, but Iwas wondering if there is some way to do that.Any suggestion is more than welcome.Hyper ==== =Hypermars,Your question has come up before, and I will give you the solution I likethe best.The problem you are having arises because Mathematica doesn't know how todifferentiate your function. So, my solution is to teach Mathematica how todo the derivative. First, we need to change your function denition so thatthe denition is applied only when the arguments to the function arenumbers:f[r_?NumericQ,a_?NumericQ] := NIntegrate[x/(x^2+a^2) Exp[-x^2] BesselJ[0,xr],{x,0,Innity}]Next, the derivative with respect to r isfr[r_?NumericQ,a_?NumericQ]:=NIntegrate[x/(x^2+a^2)Exp[-x^2 ](-x BesselJ[1,xr]),{x,0,Innity}]fa[r_?NumericQ,a_?NumericQ]:= NIntegrate[-2 ax/(x^2+a^2)^2Exp[-x^2]BesselJ[0,x r],{x,0,Innity}]We need to teach Mathematica about these derivatives:Derivative[1,0][f]=fr;Derivative[0,1][f]=fa;Now, we're all set. Let's create some data:data=Table[{i,f[i,1]+Random[]10^-3},{i,0,1,10^-2}];Load the package and run NonlinearFit:<> regarding the package Statistics'NonlinearFit' is it possible to t an> array of data with a function dened by NIntegrate?>> Example:>> f[r_,a_] := NIntegrate[x/(x^2+a^2) Exp[-x^2] BesselJ[0,xr],{x,0,Innity}]>> BestFitParameters /.NonlinearRegress[data,f[r,a],r,{a},RegressionReport ->> BestFitParameters]>> I mean, I know it's not possible because I tried and it doesn't work, butI> was wondering if there is some way to do that.>> Any suggestion is more than welcome.>> Hyper> ==== =>Good day,> I have a question about the utilization of FITS format. I have>Mathematica 4.2 for Students and I'm trying to display and analyze those>images. Since 4.2 is suppose to have added the FITS format to the list of>recognized formats how come I cannot use the standard functions to view and>manipulate them?> I use> image=Import[m22.ts];> Then> Show[image]>It does not display anything!>I bought the add-on Digital Image Processing (1.1) and again I cannot use>any of the functions in that package.>>In a nut shell: I thought that FITS format could be used the same way a JPEG>format or any image (pic) format is used (displayed,manipulated,analyzed).>>Am I doing something wrong or maybe I did not understand something about>this new feature in Mathematica 4.2?>>Robert PigeonWhile many people think of FITS as an image format, it is actually a data format. So the output of Import is data.In[1]:=data=Import[cb.ts];The data is a list of matrices. The length of the data will tell you how many matrices there are:In[2]:=Length[data]Out[2]=1The data in each matrix usually represents an intensity. You can then use a variety of functions to plot one of the matrices. ListDensityPlot is what you see in many FITS viewers.In[3]:=ListDensityPlot[First[data], Mesh->False]-DensityGraphics-In[4]:=ListContourPlot[First[ data]]Out[4]=-ContourGraphics-In[5]:=ListPlot3D[First[data], Mesh->False]Out[5]=-SurfaceGraphics--Dale ==== =Many thanks for all the suggestions from Allan, Harmut, Daniel. In myoriginal post I did not specify why I was interested in the sortingalgorithm. The purpose was to generate what are called DNA dot plotswhich can be used to compare two DNA sequences. For eaxmple, considerthe following sequencesmyDNA1 = TCTGCTTTCTTCCAAATTGATGCTGGATAGAGGTGTTTATTTCTATTCTCATATTCCTAAGT AAAACAGATAACTGCCTCTCAACTATATCAAGTAGACTAAAATATTGTGCGTCCTGAACCTC TAAGTATGCGTCCTGAACCTCTAAGTATCATATTCCTAAGTAAAACAGATAACTGCCTCTCA ACTATATCAAGTAGACTAAAATATTGTCGGGTGCCTGTAGTCCCAGCTACTCGGGAGGCTGA GGCAGGAGAATGGCGTGAACCTGGAAGGCAGAGCTGCAGTGAGCAGAGATCG;myDNA2 = ACAAGAAGGCTGCTGCCACCAGCCTGTGAAGCAAGGTTAAGGTGAGAAGGCTGGAGGTGAGAT TCTGGGCAGGTAGGTACTGGAAGCCGGGGCAAGGTGCAGAAAGGCAGAAAGTGTTTCTGAAA GAGGGATTAGCCCGTTGTCTTACACATATTCCTAAGTAAAACAGATAACTGCCTCTCAACTA TATCAAGTAGACTAAAATATTGTGCGTCCTGAACCTCTAAGTATGCGTCCTGAACCTCTAAG TATCATATTCCTAAGTAAAACAGATAACTGCCTCTCAACTATATCAAGTAGACTAAAATATT GTTAGTCTGACTTTGCACCTGCTCTGTGATTATGACTATCCCACAGTCTCCTA;These sequences were engineered to have several common blocks ofDNA. Using the following program a plot is generated that shows thealignment of the DNA blocks ( I have used one of Allan's algorithms(Matchings7) for searching for common DNA blocksdotPlot1[dna1_, dna2_, BlockSize_, offset_] := Module[{st, pt, sp, s1,s2, s, rr},s1 = MapIndexed[List[#, (First[#2] - 1)offset + 1] &, Map[StringJoin[#] &, Partition[Characters[dna1], BlockSize, offset], 1]];s2 = MapIndexed[List[#, (First[#2] - 1)offset + 1] &, Map[StringJoin[#] &, Partition[Characters[dna2], BlockSize, offset], 1]];s = {s1, s2}; st = #[[Ordering[#[[All, 1]]]]] & /@ s; sp = Split[#, #1[[1]] ==== #2[[1]] &] & /@ st; pt = (Alternatives @@ (Intersection @@ st[[All, All, 1]])); rr = Transpose[Cases[#, {{pt, _}, ___}] & /@ sp]; ListPlot[ Flatten[Apply[Outer[List, ##, 1] &, rr, {1}], 2] /.{{a_String, x1_}, {b_String, y1_}} -> {x1, y1}, AspectRatio -> 1,PlotStyle -> {RGBColor[0, 0, 1]}, Frame -> True, FrameLabel ->{DNA 1, DNA 2}, RotateLabel -> False, Axes -> False]]dotPlot1[myDNA1, myDNA2, 6, 1]One of the reasons Allan's code is so efcient is the use of patternsin Cases and Intersection. The question then arises how would oneproceed if the test is not the equality of blocks, but some othermeasure. For example 2 blocks of 8 nucleotides are equal if at least6 of the eight bases match , e,g,newTest:=Count[Characters[#1]-Characters[#2],0]>6&I have attempted a search using such a test but my code cannnotcompete with Allan's or the various variants that have beensuggested. The bottleneck is in Cases or Intersection.I did nd that if my test used StringMatchQ[block1, block2,SpellingCorrection-> True], I got quite good performance, though thistest is not precise, and I was not able to extend it. Would be nice tobe able to modify the criteria used in SpellingCorrection so that itgives True for user dened criteria.Brian> I give below some further speed-ups.> The improvement, at least on the data I used, is due to using> Split[Sort[_]] right at the start to parcel the data - it probably depends> on there being a lot of repetition of the rst term of the entries in the> data.> The code for Matchings6 below is faster than Daniel Lichblau's recently> posted code - though he suggests that this might be speeded up by> substituting numbers for strings and compiling.> Data> Random[Integer, {1, 2000}]}, {6000}];> Random[Integer, {1, 2000}]}, {12000}];> Get the members of s1 with the same rst entry as some member of s2.> Previous code (preserves order)> Matched1[s1_,s2_]:=> Cases[ s1,{Alternatives@@Union[s2[[All,1]]],_}]> Matched1[s1,s2];//Timing> {3.4 Second,Null}> New code (does not preserve order) - note the use of s1[[Ordering[s1[[All,> 1]]]]] to save on ordering with respect to the second entries> Matched4[s1_,s2_]:=> Cases[Split[s1[[Ordering[s1[[All,1]]]]], #1[[1]] ==== #2[[1]]&],> {{Alternatives@@Union[s2[[All,1]]],_},___}]> Matched4[s1,s2];//Timing> {1.6 Second,Null}> Get the full matchings (this code will work on {s1,s2 ,....,sn}, as well as> just {s1, s2})> Matchings7[s_]:=> Module[{st,pt,sp},> st = #[[Ordering[#[[All,1]]]]]&/@s;> sp=Split[#,#1[[1]] ==== #2[[1]]&]&/@st;> pt= (Alternatives@@(Intersection@@ st[[All,All,1]]));> Transpose[Cases[#,{{pt,_},___}]&/@sp]> ];> (ms7=Matchings7[{s1,s2}]);//Timing> {3.46 Second,Null}> Daniel Lichtblau (gives essentially the same information as Matchings7)> myTest[l1_, l2_] :=> Module[{s1, s2, m = Length[l1], n = Length[l2], j, k, res = {}, ord },> s1 = Sort[l1]; s2 = Sort[l2];> For[j = 1; k = 1, j <= m && k <= n, Null,> ord = Order[s1[[j,1]], s2[[k,1]]];> If[ord == 1, j++; Continue[]];> If[ord == -1, k++; Continue[]];> res = {res, {s1[[j]], s2[[k]]}};> j++; k++;> ];> Partition[Partition[Flatten[res], 2], 2]> ]> myTest[s1,s2];//Timing> {7.47 Second,Null}> --> Allan> ---------------------> Allan Hayes> Mathematica Training and Consulting> Leicester UK> www.haystack.demon.co.uk> hay@haystack.demon.co.uk> Voice: +44 (0)116 271 4198 ==== =One of the things I'm having some trouble with in my math class isdetermining the partial fraction for a simple constant fraction like this:-5Pi----- 12One possibility is:-Pi Pi--- - --- 6 4I'm having difculty intuiting how to do this, and I wind up doing tons oftrial and error, which sometimes takes too long. Besides some advice on theright way to do this, I'd also like to know how to achieve this inMathematica. If it weren't for the Mathematica part, I'd have put this inalt.math.moderated.--Steven Hodgensteven@twitch.net ==== =Math friends,If I program Mathematica to calculate a Cayley Table for A_5, for example,and it displays on the screen in the notebook, I have not been able togure out how to paste the values into Excel without all the extraformatting, such as quote marks. Has someone worked this out?For example, the Cayley Table for A_5 copies as follows into Excel...!(* TagBox[GridBox[{ {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60}, {2, 3, 1, 7, 9, 8, 10, 12, 11, 4, 5, 6,14, 15, 13, 19, 21, 20, 22, 24, 23, 16, 17, 18, 37, 39, 38, 40, 42, 41, 46, 47, 48, 43, 44, 45, 49, 51, 50, 52, 54, 53, 58, 59, 60, 55, 56, 57, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36}, {3, 1, 2, 10, 11, 12, 4, 6, 5, 7, 9, 8,15, 13, 14, 22, 23, 24, 16, 18, 17, 19, 21, 20, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 25, 27, 26, 28, 30, 29, 34, 35, 36, 31, 32, 33, 37, 39, 38, 40, 42, 41, 46, 47, 48, 43, 44, 45}, {4, 6, 5, 1, 3, 2, 11, 10, 12, 8, 7, 9,25, 27, 26, 28, 30, 29, 34, 35, 36, 31, 32, 33, 13, 15, 14, 16, 18, 17, 22, 23, 24, 19, 20, 21, 50, 49, 51, 55, 56, 57, 52, 53, 54, 58, 60, 59, 38, 37, 39, 43, 44, 45, 40, 41, 42, 46, 48, 47}, {5, 4, 6, 8, 7, 9, 1, 2, 3, 11, 12, 10,26, 25, 27, 31, 32, 33, 28, 29, 30, 34, 36, 35, 38, 37, 39, 43, 44, 45, 40, 41, 42, 46, 48, 47, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 50, 51, 49, 55, 57, 56, 58, 60, 59, 52, 53, 54}, and so on... ==== =Here is a little example of how to export in a format that Excel can read:Export[C:table.csv, {{1, 2}, {3, 4}}, CSV]Steve Luttrell> Math friends,>> If I program Mathematica to calculate a Cayley Table for A_5, for example,> and it displays on the screen in the notebook, I have not been able to> gure out how to paste the values into Excel without all the extra> formatting, such as quote marks. Has someone worked this out?>> For example, the Cayley Table for A_5 copies as follows into Excel...>> !(*> TagBox[GridBox[{> {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,> 13,> 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,24,> 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,35,> 36, 37, 38, 39, 40, 41, 42, 43, 44, 45,46,> 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,57,> 58, 59, 60},> {2, 3, 1, 7, 9, 8, 10, 12, 11, 4, 5, 6,> 14,> 15, 13, 19, 21, 20, 22, 24, 23, 16, 17,18,> 37, 39, 38, 40, 42, 41, 46, 47, 48, 43,44,> 45, 49, 51, 50, 52, 54, 53, 58, 59, 60,55,> 56, 57, 25, 26, 27, 28, 29, 30, 31, 32,33,> 34, 35, 36},> {3, 1, 2, 10, 11, 12, 4, 6, 5, 7, 9, 8,> 15,> 13, 14, 22, 23, 24, 16, 18, 17, 19, 21,20,> 49, 50, 51, 52, 53, 54, 55, 56, 57, 58,59,> 60, 25, 27, 26, 28, 30, 29, 34, 35, 36,31,> 32, 33, 37, 39, 38, 40, 42, 41, 46, 47,48,> 43, 44, 45},> {4, 6, 5, 1, 3, 2, 11, 10, 12, 8, 7, 9,> 25,> 27, 26, 28, 30, 29, 34, 35, 36, 31, 32,33,> 13, 15, 14, 16, 18, 17, 22, 23, 24, 19,20,> 21, 50, 49, 51, 55, 56, 57, 52, 53, 54,58,> 60, 59, 38, 37, 39, 43, 44, 45, 40, 41,42,> 46, 48, 47},> {5, 4, 6, 8, 7, 9, 1, 2, 3, 11, 12, 10,> 26,> 25, 27, 31, 32, 33, 28, 29, 30, 34, 36,35,> 38, 37, 39, 43, 44, 45, 40, 41, 42, 46,48,> 47, 13, 14, 15, 16, 17, 18, 19, 20, 21,22,> 23, 24, 50, 51, 49, 55, 57, 56, 58, 60,59,> 52, 53, 54},> and so on...>>>In-reply-To: <200212100910.EAA14854@smc.vnet.net> ==== =SG> I can't get this function to do anything. I read it in withSG> Needs[Graphics`MultipleListPlot`];SG> and no error messages appear, and the le IS present inSG> this directory:SG> C:Program FilesWolfram ResearchMathematica4.1 SG> (2)AddOnsStandardPackagesGraphics'MultipleListPlot.mSG> but when I do an example right out of Help such asSG> << Graphics`MultipleListPlot`SG> (list1 = Table[{x, Sin[2 Pi x]}, {x, 0, 1, 0.1}];SG> list2 = Table[{x, Cos[2 Pi x]}, {x, 0, 1, 0.1}]);SG> MultipleListPlot[list1, list2]SG> , nothing appears (no plot shows) except this textSG> !(MultipleListPlot[{{0, 0}, {0.1`, 0.5877852522924731`}, {0.2`, SG> 0.9510565162951535`}, {0.30000000000000004`, [SKIPPED]I cannot reproduce this behavior in the following versions 4.2 for Microsoft Windows (June 5, 2002) 4.2 for Microsoft Windows (February 28, 2002) 4.1 for Microsoft Windows (November 2, 2000) 4.0 for Microsoft Windows (April 21, 1999) Microsoft Windows 3.0 (April 25, 1997)I can reproduce the behavior you had quoted in such a way.1. Do NOT load MultipleListPlot via Needs[Graphics`MultipleListPlot`];2. Input (list1 = Table[{x, Sin[2 Pi x]}, {x, 0, 1, 0.1}]; list2 = Table[{x, Cos[2 Pi x]}, {x, 0, 1, 0.1}]);3. Input MultipleListPlot[list1, list2]SG> !(MultipleListPlot[{{0, 0}, {0.1`, 0.5877852522924731`}, {0.2`,SG> 0.9510565162951535`}, {0.30000000000000004`, etc !(MultipleListPlot[{{0, 0}, {0.1`, 0.5877852522924731`}, {0.2`, 0.9510565162951535`}, {0.30000000000000004`, 0.9510565162951535`}, {0.4`, 0.5877852522924732`}, {0.5`, 1.2246063538223773`*^-16}, {0.6000000000000001`, (-0.5877852522924734`)}, {0.7000000000000001`, (-0.9510565162951535`)}, {0.8`, (-0.9510565162951536`)}, {0.9`, (-0.5877852522924734`)}, {1.`, (-2.4492127076447545`*^-16)}}, {{0, 1}, {0.1`, 0.8090169943749475`}, {0.2`, 0.30901699437494745`}, {0.30000000000000004`, (-0.30901699437494756` )}, {0.4`, (-0.8090169943749473`)}, {0.5`, (-1.`)}, {0.6000000000000001`, (-0.8090169943749472`)}, {0.7000000000000001`, (-0.30901699437494756`)}, {0.8`, 0.30901699437494723`}, {0.9`, 0.8090169943749473`}, {1.`, 1.`}}])Over years, I gradually came to the nal conclusion that it is best toload the proper package prior to using a function call from it ;-)Best wishes,Vladimir BondarenkoMathematical and Production DirectorSymbolic Testing Group http://www.CAS-testing.org/ GEMM Project (98% ready) Mail : 76 Zalesskaya Str, Simferopol, Crimea, UkraineP.S. A remark for our Moderator only.See at last how good I am ;) ==== =I copied your code as follows:In[1]:=<< Graphics`MultipleListPlot`; In[2]:=(list1 = Table[{x, Sin[2*Pi*x]}, {x, 0, 1, 0.1}]; list2 = Table[{x, Cos[2*Pi*x]}, {x, 0, 1, 0.1}]); In[3]:=MultipleListPlot[list1, list2]; It works as it should. Tomas GarzaMexico City----- Original Message ----- > but when I do an example right out of Help such as> << Graphics`MultipleListPlot`> (list1 = Table[{x, Sin[2 Pi x]}, {x, 0, 1, 0.1}];> list2 = Table[{x, Cos[2 Pi x]}, {x, 0, 1, 0.1}]);> MultipleListPlot[list1, list2]> , nothing appears (no plot shows) except this text> !(MultipleListPlot[{{0, 0}, {0.1`, 0.5877852522924731`}, {0.2`, > 0.9510565162951535`}, {0.30000000000000004`, > 0.9510565162951535`}, {0.4`, 0.5877852522924732`}, {0.5`, > 1.2246063538223773`*^-16}, {0.6000000000000001`, > (-0.5877852522924734`)}, {0.7000000000000001`,> (-0.9510565162951535`)}, > {0.8`, (-0.9510565162951536`)}, {0.9`, (-0.5877852522924734`)},> {1.`, > (-2.4492127076447545`*^-16)}}, {{0, 1}, {0.1`, 0.8090169943749475`},> {0.2`, > 0.30901699437494745`}, {0.30000000000000004`,> (-0.30901699437494756`> )}, {0.4`, (-0.8090169943749473`)}, {0.5`, (-1.`)}, > {0.6000000000000001`, (-0.8090169943749472`)}, {0.7000000000000001`,> (-0.30901699437494756`)}, {0.8`, 0.30901699437494723`}, {0.9`, > 0.8090169943749473`}, {1.`, 1.`}}])> ==== =Borut,Here is a routine that will generate two different random points on a unitsphere.twoPoints := With[ {phi1 = Random[Real, {0, Pi/2}], phi2 = Random[Real, {Pi/2 + 0.01, Pi}], theta1 = Random[Real, {0, 2Pi}], theta2 = Random[Real, {0, 2Pi}]}, {{Cos[theta1]Sin[phi1], Sin[theta1]Sin[phi1], Cos[phi1]}, {Cos[theta2]Sin[phi2], Sin[theta2]Sin[phi2], Cos[phi2]}} ]The following routine generates the parametrization in t for a great circlegoing through the two points and an interator giving the short great circlearc between the two points.greatCircleArc[{pt1_, pt2_}] := Module[{n, e1, e2, t1, t2}, n = pt1[Cross]pt2; {e1, e2} = (NullSpace[{N[n]}]) // Chop; t1 = ArcTan @@ (pt1.# & /@ {e1, e2}); t2 = ArcTan @@ (pt2.# & /@ {e1, e2}); {t1, t2} = Sort[{t1, t2}]; {t1, t2} = Which[ t2 - t1 <= Pi, {t1, t2}, t2 - t1 > Pi, {t2, 2Pi + t1}]; {Cos[t]e1 + Sin[t]e2, {t, t1, t2}}]You can use that to plot the arc in a 3D plot. Since I want to combine anumber of elements in the plot I nd it much easier to use my DrawGraphicspackage from my web site. Here is the code for a plot that draws a wireframe sphere, the two points, the short arc and the complete great circle.Needs[DrawGraphics`DrawingMaster`]pts = twoPoints;plotargs = greatCircleArc[pts];Draw3DItems[ {(* Draw WireFrame sphere *) ColorMix[Cobalt, Gray][0.5], ParametricDraw3D[{Cos[t]Sin[p], Sin[t]Sin[p], Cos[p]}, {p, 0, Pi}, {t, 0, 2Pi}, PlotPoints -> {15, 31}] // UseWireFrame, (* Draw entire great circle *) PermanentGreen, ParametricDraw3D[First[plotargs] // Evaluate, {t, 0, 2Pi}], (* Draw short great circle arc *) AbsoluteThickness[2], EnglishRed, ParametricDraw3D @@ plotargs, (* Plot the two points *) AbsolutePointSize[6], Black, Point /@ pts}, BoxStyle -> LightGray, Background -> Linen, ImageSize -> 450];David Parkdjmp@earthlink.nethttp://home.earthlink.net/~djmp/Borut LevartSlovenia ==== =i am trying to do a poincare map. i generate x[t] and x'[t]. i writez2 = Table[Evaluate[{x[t] , x'[t]} /. %], {t, 0, 10, .005}]ListPlot[z2]and i get a set of values that looks like{{0.517671, 9.75893}}, {{0.562696, 8.33465}}, {{0.601599, 7.26733}}, {{0.635675, 6.38612}},....the problem is when i useListPlot[z2]i get the dreaded is not a list of numbers error. if i remove the extraparenthesis by hand it works, but thats a tedious business several hundredpoints. i am sure this is a simple thing to x. i would appreciate anyhelp.mario ==== =Mario: z2={{{0.517671, 9.75893}}, {{0.562696, 8.33465}}, {{0.601599, 7.26733}}, {{0.635675, 6.38612}}}; Flatten[z2,1]{{0.517671,9.75893},{0.562696,8.33465},{ 0.601599,7.26733},{0.635675,6.38612}}> i am trying to do a poincare map. i generate x[t] and x'[t]. i write>> z2 = Table[Evaluate[{x[t] , x'[t]} /. %], {t, 0, 10, .005}]> ListPlot[z2]>> and i get a set of values that looks like>> {{0.517671, 9.75893}}, {{0.562696, 8.33465}}, {{0.601599,> 7.26733}}, {{0.635675, 6.38612}},....>> the problem is when i use>> ListPlot[z2]>> i get the dreaded is not a list of numbers error. if i remove the extra> parenthesis by hand it works, but thats a tedious business several hundred> points. i am sure this is a simple thing to x. i would appreciate any> help.>> mario> ==== =Use %[[1]] rather than % in your expression.Steve Luttrell> i am trying to do a poincare map. i generate x[t] and x'[t]. i write>> z2 = Table[Evaluate[{x[t] , x'[t]} /. %], {t, 0, 10, .005}]> ListPlot[z2]>> and i get a set of values that looks like>> {{0.517671, 9.75893}}, {{0.562696, 8.33465}}, {{0.601599,> 7.26733}}, {{0.635675, 6.38612}},....>> the problem is when i use>> ListPlot[z2]>> i get the dreaded is not a list of numbers error. if i remove the extra> parenthesis by hand it works, but thats a tedious business several hundred> points. i am sure this is a simple thing to x. i would appreciate any> help.>> mario> ==== =After you generate the list z2, use the following command to plot:ListPlot[Flatten/@z2]Hope this helps.Kezhao> i am trying to do a poincare map. i generate x[t] and x'[t]. i write> z2 = Table[Evaluate[{x[t] , x'[t]} /. %], {t, 0, 10, .005}]> ListPlot[z2]> and i get a set of values that looks like> {{0.517671, 9.75893}}, {{0.562696, 8.33465}}, {{0.601599,> 7.26733}}, {{0.635675, 6.38612}},....> the problem is when i use> ListPlot[z2]> i get the dreaded is not a list of numbers error. if i remove the extra> parenthesis by hand it works, but thats a tedious business several hundred> points. i am sure this is a simple thing to x. i would appreciate any> help.> marioReply-To: kuska@informatik.uni-leipzig.de ==== =ListPlot[z2 /. {{a_?NumericQ,b_?NUmericQ}}:>{a,b}] Jens> i am trying to do a poincare map. i generate x[t] and x'[t]. i write> z2 = Table[Evaluate[{x[t] , x'[t]} /. %], {t, 0, 10, .005}]> ListPlot[z2]> and i get a set of values that looks like> {{0.517671, 9.75893}}, {{0.562696, 8.33465}}, {{0.601599,> 7.26733}}, {{0.635675, 6.38612}},....> the problem is when i use> ListPlot[z2]> i get the dreaded is not a list of numbers error. if i remove the extra> parenthesis by hand it works, but thats a tedious business several hundred> points. i am sure this is a simple thing to x. i would appreciate any> help.> mario ==== = I don't quite get it about precision. If I do$MaxPrecision=$MinPrecision=50, does that mean that all computations following that in the whole notebook will bedone to 50 decimal places? (Assuming that the precisionis not changed explicitly after that.) If that doesn't do it, how can I make that happen?Do I have to put lots of zeroes in every constant I enter?(The exact value of these doesn't matter but once they are entered, the computation itself must be very exact. This computation is to verify an extremely complicated identity.) It's probable that my computations are being limitedby insufcient precision and the easiest thing to do is just upit drastically everywhere in the notebook. ==== = With default settings, apparently Mathematica plotscurves with precision limited by typical printers. I needto export these plots to Corel Draw and view them undervery high magnication. But viewed this way many of theclose-together points in my plots coincide, whereas Iknow they don't in reality. Is there a way to get these plots with muchgreater precision? (The export process using EnhancedMetale otherwise works very well; even the objectgrouping is what I want.) Or is there another way, for example writingan Excel le and plotting there? (I'm an Excel user butno expert and I doubt that it can make high precisionplots.) ==== =I have found the arguments to start with under Unix : lp=MLOpenString(ep, -linkname math -mathlink, &err);problem solved.thanksMatt> I have found the example Ôfactor.c'.> Unfortunatly there are problems with running the program ... something > to do with ÔMLOpenArgv' ... when the program is run it requests :> ÔCreate link:'> thanks> MAtt> I have the following in mathematica :> x[z_]:=1000Log[10]-ProductLog[z]> I would like to be able to execute this from a shell or C code. CForm > just outputs :> CForm[1000Log[10] - ProductLog[z]]> 1000*Log(10) - ProductLog(z)> Is it possible to compile ÔProductLog' to a C library or even an > executable which I can then use in C code ?> thanks> Matt> -- > http://mffm.darktech.org> WSOLA TimeScale Audio Mod : http://mffmtimescale.sourceforge.net/> FFTw C++ : http://mffmfftwrapper.sourceforge.net/> Vector Bass : http://mffmvectorbass.sourceforge.net/> Multimedia Time Code : http://mffmtimecode.sourceforge.net/> -- > http://mffm.darktech.org> WSOLA TimeScale Audio Mod : http://mffmtimescale.sourceforge.net/> FFTw C++ : http://mffmfftwrapper.sourceforge.net/> Vector Bass : http://mffmvectorbass.sourceforge.net/> Multimedia Time Code : http://mffmtimecode.sourceforge.net/-- http://mffm.darktech.orgWSOLA TimeScale Audio Mod : http://mffmtimescale.sourceforge.net/FFTw C++ : http://mffmfftwrapper.sourceforge.net/Vector Bass : http://mffmvectorbass.sourceforge.net/Multimedia Time Code : http://mffmtimecode.sourceforge.net/ ==== =I have found the example Ôfactor.c'.Unfortunatly there are problems with running the program ... something to do with ÔMLOpenArgv' ... when the program is run it requests :'Create link:'thanksMAtt> I have the following in mathematica :> x[z_]:=1000Log[10]-ProductLog[z]> I would like to be able to execute this from a shell or C code. CForm > just outputs :> CForm[1000Log[10] - ProductLog[z]]> 1000*Log(10) - ProductLog(z)> Is it possible to compile ÔProductLog' to a C library or even an > executable which I can then use in C code ?> thanks> Matt> -- > http://mffm.darktech.org> WSOLA TimeScale Audio Mod : http://mffmtimescale.sourceforge.net/> FFTw C++ : http://mffmfftwrapper.sourceforge.net/> Vector Bass : http://mffmvectorbass.sourceforge.net/> Multimedia Time Code : http://mffmtimecode.sourceforge.net/-- http://mffm.darktech.orgWSOLA TimeScale Audio Mod : http://mffmtimescale.sourceforge.net/FFTw C++ : http://mffmfftwrapper.sourceforge.net/Vector Bass : http://mffmvectorbass.sourceforge.net/Multimedia Time Code : http://mffmtimecode.sourceforge.net/ ==== =I have the following in mathematica :x[z_]:=1000Log[10]-ProductLog[z]I would like to be able to execute this from a shell or C code. CForm just outputs :CForm[1000Log[10] - ProductLog[z]]1000*Log(10) - ProductLog(z)Is it possible to compile ÔProductLog' to a C library or even an executable which I can then use in C code ?thanksMatt-- http://mffm.darktech.orgWSOLA TimeScale Audio Mod : http://mffmtimescale.sourceforge.net/FFTw C++ : http://mffmfftwrapper.sourceforge.net/Vector Bass : http://mffmvectorbass.sourceforge.net/Multimedia Time Code : http://mffmtimecode.sourceforge.net/ ==== =Try to use the function: Trace[ ]Trace[expr] generates a list of all expressions used in the evaluation ofexpr. Trace[expr, form] includes only those expressions which match form.Trace[expr, s] includes all evaluations which use transformation rulesassociated with the symbol------------Andy£Âin Chinese called .90.9b.85£.96.82£©bachelor of scienceXi'an Jiaotong UniversityXi'an,ShaanXi,710049P.R.Chinahttp:// wangzhengyao.xiloo.comReply-To: kuska@informatik.uni-leipzig.de ==== =in general no.You can try Trace[] or On[functionName] Jens> Can i make mathematica 4 show me the whole procedure it does before spitting> out the result? ==== =Anto .86Ç.8e.91.93.9e.93[Cent].86.8c.91.81:at4clf$es3$1@s mc.vnet.net...> Can i make mathematica 4 show me the whole procedure it does beforespitting> out the result?Try to use the function: Trace[ ]Trace[expr] generates a list of all expressions used in the evaluation ofexpr. Trace[expr, form] includes only those expressions which match form.Trace[expr, s] includes all evaluations which use transformation rulesassociated with the symbol.------------Andy£Âin Chinese called .90.9b.85£.96.82£©bachelor of scienceXi'an Jiaotong UniversityXi'an,ShaanXi,710049P.R.Chinahttp:// wangzhengyao.xiloo.com ==== =I'm new to Mathematica, and I have a question to which I've found noanswers in the archives. Can you help?The issue is: how do I create a pure recursive function? Normally whencreating a recursive function I use the name of the function to performthe recursive call:fact[n_] := If[n == 1, 1, n fact[n - 1]]However this has the disadvantage that the symbol fact is now global.The logical step to make the name of the function local is somethinglike:Function[factl, factl[5]] @@ {Function[n, If[n == 0, 1, n factl[n -1]]]}or maybe:With[{fact = Function[n, If[n == 0, 1, n fact[n - 1]]]}, fact[5]]However both of these solutions steadfastly return the value 5fact[4]. I assume the problem is that the variables initialised inFunction[] and With[] must be symbols, and cannot be patterns. But arecursion requires a pattern (n_ in the rst, global, solution above).What do I do to get factorial to work _without_ making the symbol factglobal?I'd be grateful for any help.Niall. ==== =Use Block:Block[{fact=If[#>0,# fact[#-1],1]&},fact[5]]returns 5!You can also use Module:Module[{fact},fact[n_]/;n>0 := n fact[n-1];fact[0]=1;fact[5]]also returns 5!Orestis Vantzos> I'm new to Mathematica, and I have a question to which I've found no> answers in the archives. Can you help?> The issue is: how do I create a pure recursive function? Normally when> creating a recursive function I use the name of the function to perform> the recursive call:> fact[n_] :=> If[n == 1, 1, n fact[n - 1]]> However this has the disadvantage that the symbol fact is now global.> The logical step to make the name of the function local is something> like:> Function[factl, factl[5]] @@ {Function[n, If[n == 0, 1, n factl[n -> 1]]]}> or maybe:> With[{fact = Function[n, If[n == 0, 1, n fact[n - 1]]]}, fact[5]]> However both of these solutions steadfastly return the value 5> fact[4]. I assume the problem is that the variables initialised in> Function[] and With[] must be symbols, and cannot be patterns. But a> recursion requires a pattern (n_ in the rst, global, solution above).> What do I do to get factorial to work _without_ making the symbol fact> global?> I'd be grateful for any help.> Niall.Reply-To: kuska@informatik.uni-leipzig.de ==== =If[#1 == 1, 1, #1*#0[# - 1]] & compute the factorial with a pure function. Jens> I'm new to Mathematica, and I have a question to which I've found no> answers in the archives. Can you help?> The issue is: how do I create a pure recursive function? Normally when> creating a recursive function I use the name of the function to perform> the recursive call:> fact[n_] :=> If[n == 1, 1, n fact[n - 1]]> However this has the disadvantage that the symbol fact is now global.> The logical step to make the name of the function local is something> like:> Function[factl, factl[5]] @@ {Function[n, If[n == 0, 1, n factl[n -> 1]]]}> or maybe:> With[{fact = Function[n, If[n == 0, 1, n fact[n - 1]]]}, fact[5]]> However both of these solutions steadfastly return the value 5> fact[4]. I assume the problem is that the variables initialised in> Function[] and With[] must be symbols, and cannot be patterns. But a> recursion requires a pattern (n_ in the rst, global, solution above).> What do I do to get factorial to work _without_ making the symbol fact> global?> I'd be grateful for any help.> Niall. ==== => I am trying to solve 3 equations on 3 variables --- which is solveable.> After that I want to use only the positive solutions of the three> variables for further calculations. I tried to use the Select command in> connection with the Solve command, but I get only an empty list.> [...]Try Cases[sol, {(_ -> _?Positive) ..}]where Ôsol' is the result of Solve.Rainer ==== =Angela,The fact that you have 3 eqns and 3 unknowns does not guarantee youthat the system is solvable. If there are linearly dependent columnsor rows in your matrix, the system is ill-conditioned. So, I suggestyou to start from checking if the matrix is non-singular.Good luck.> I am trying to solve 3 equations on 3 variables --- which is solveable.> After that I want to use only the positive solutions of the three> variables for further calculations. I tried to use the Select command in> connection with the Solve command, but I get only an empty list.> Could you help by recommend commands?> Angela BirkReply-To: kuska@informatik.uni-leipzig.de ==== =a small examplesol = Solve[{0 == x^2 + y, -1 == x + y}, {x, y}];andSelect[sol, (x /. #) > 0 &]will return the solution with positive x. Jens> I am trying to solve 3 equations on 3 variables --- which is solveable.> After that I want to use only the positive solutions of the three> variables for further calculations. I tried to use the Select command in> connection with the Solve command, but I get only an empty list.> Could you help by recommend commands?> Angela Birk> --> Angela Birk> University of Hamburg> HWWA> Economics> 20347 Hamburg, Germany> +49 40 42834 - 478 ==== =of scoping is so poor.My rule-of-thumb for making Module[] was to start off withoutlocal variables, for example:Module[{}, num = x^2; den = 1 + x^2; h[x_] = num/den; h'[1]]so that I can debug easily. When I nally get it to workI add the list of the local variables:Module[{num, x, den, h}, num = x^2; den = 1 + x^2; h[x_] = num/den; h'[1]]But now it is broken!I wish to be enlightened on this issue: How can I safelywrite a function denition inside a Module? Gianluca Gorni> To: gorni@dimi.uniud.it>> I am confused by this result:>>> In: Module[{a}, a = x; g[x_] = a]; g[y]>>> Out: x>>> Somehow I would expect the same output as>>> In: Module[{}, a = x; g[x_] = a]; g[y]>>> Out: y>>> In the rst case ?g gives g[x$_] = x,>> while in the second it gives g[x_] = x.>> The difference is a dollar sign.>>> Can anyone explain why the dollar is inserted in one case>> but not in the other? The x was not a local variable>> in either case.> Since the names of named patterns in rules and denitions> are treated as local variables, the x in the denition of> g[x_] is a local variable in these examples (section 2.6.4> in The Mathematica Book). Module[{a}, a = x; g[x_] = a]> therefore contains nested scoping constructs, so the local> symbol x in g[x_] = a is renamed to prevent a potential> conßict with the variable a from the enclosing Module.> In Module[{}, a = x; g[x_] = a], where there are no conßicting> variables from the nested scoping constructs, the denition of> g is evaluated as if the Module was not present. Since this> denition is an immediate assignment, the right side of the> assignment is not held unevaluated, and will be affected by> denitions (such as the now global denition of a) that are> present when the assignment is evaluated.> If you use a delayed assignment for the denition of g> then both inputs will show the same result:> In[1]:= Module[{a},a=x;g[x_]:=a];g[y]> Out[1]= x> In[2]:= Module[{},a=x;g[x_]:=a];g[y]> Out[2]= x> The only fundamentally troublesome issue here is that immediate> assignments are treated as scoping constructs even though they> do not hold their arguments unevaluated. ==== =Users with HP PA-RISC1.1 processor can use Mathematica 4.2 but without graphics:$ le mathematica/4.2/SystemFiles/Graphics/Binaries/HP-RISC/* makepsres: PA-RISC1.1 shared executablemotifps: PA-RISC2.0 shared executable dynamically linkedpsrender: PA-RISC1.1 shared executablefortunately Could you, please, consider recompiling motifps for HP PA-RISC1.1 processorand puting it on the web?-- Pavel PokornyMath Dept, Prague Institute of Chemical Technologyhttp://staffold.vscht.cz/mat/Pavel.Pokorny ==== => I have the following problem. Given two random points on a sphere, I would> like to connect them with a curve that goes Ôapproximately' on the sufrace> line segments.> Connecting the points with a straigh line is achived by Line[{pt1,pt2}].> I am failing to get good ideas on how to approach the problem, would> appreciate any hint / trick / tip.> Borut Levart> Sloveniasee this example (needs Java):http://wwwvis.informatik.uni-stuttgart.de/~kraus/ LiveGraphics3D/examples/parametrized/greatcircle.htmlMartin-- Martin Kraus, Visualization and Interactive Systems Group (VIS)http://wwwvis.informatik.uni-stuttgart.de/~kraus/--Who does not move, cannot get lost. (Alfred Werner)Reply-To: selwynh@earthlink.net ==== =Borut,If you're willing to use a less primitive approach...First let's assume the radius is 1 and dene p[t_] := (1 - t)*p1 + t*p2and curve[p1_,p2_] := ParametricPlot3D[Evaluate[Flatten[{p[t]/Sqrt[p[t].p[t]], Thickness[0.01]}]], {t, 0, 1}, DisplayFunction->Identity]This generates random points for testing: randompoint := Module[{u=2*Pi*Random[], v=Pi*Random[]}, {Cos[u]Sin[v], Sin[u]Sin[v], Cos[v]}]Now, <>I have the following problem. Given two random points on a sphere, I would>like to connect them with a curve that goes Ôapproximately' on the sufrace>line segments.>>Connecting the points with a straigh line is achived by Line[{pt1,pt2}].>>I am failing to get good ideas on how to approach the problem, would>appreciate any hint / trick / tip.>>Borut Levart>>Slovenia>> > ==== =I like this intuitive solution| Borut,|| If you're willing to use a less primitive approach...|| First let's assume the radius is 1 and dene|| p[t_] := (1 - t)*p1 + t*p2|| and|| curve[p1_,p2_] :=ParametricPlot3D[Evaluate[Flatten[{p[t]/Sqrt[p[t].p[t]],| Thickness[0.01]}]], {t, 0, 1}, DisplayFunction->Identity]|| This generates random points for testing:|| randompoint := Module[{u=2*Pi*Random[], v=Pi*Random[]},| {Cos[u]Sin[v], Sin[u]Sin[v], Cos[v]}]|| Now,|| < I have the following problem. Given two random points on a sphere, I would> like to connect them with a curve that goes Ôapproximately' on the sufrace> line segments.> Connecting the points with a straigh line is achived by Line[{pt1,pt2}].> I am failing to get good ideas on how to approach the problem, would> appreciate any hint / trick / tip.> Borut Levart> Slovenia ==== =Here is the correct code, I hope.First load the Combinatorica package:In[1]:=<< DiscreteMath`Combinatorica`Next dene the group elementsIn[2]:=Z4Z12 = Flatten[Outer[List, Range[0, 3], Range[0, 11]], 1]Out[2]={{0, 0}, {0, 1}, {0, 2}, {0, 3}, {0, 4}, {0, 5}, {0, 6}, {0, 7}, {0, 8}, {0, 9}, {0, 10}, {0, 11}, {1, 0}, {1, 1}, {1, 2}, {1, 3}, {1, 4}, {1, 5}, {1, 6}, {1, 7}, {1, 8}, {1, 9}, {1, 10}, {1, 11}, {2, 0}, {2, 1}, {2, 2}, {2, 3}, {2, 4}, {2, 5}, {2, 6}, {2, 7}, {2, 8}, {2, 9}, {2, 10}, {2, 11}, {3, 0}, {3, 1}, {3, 2}, {3, 3}, {3, 4}, {3, 5}, {3, 6}, {3, 7}, {3, 8}, {3, 9}, {3, 10}, {3, 11}}Next,t he group multiplication:In[3]:=multZ4Z12[{a_, b_}, {c_, d_}] := {Mod[a + c, 4], Mod[b + d, 12]}THe generated subgroup:In[4]:=H = NestWhileList[multZ4Z12[#1, {2, 2}] & , {2, 2}, #1 != {0, 0} & ]Out[4]={{2, 2}, {0, 4}, {2, 6}, {0, 8}, {2, 10}, {0, 0}}The coset representatives:In[5]:=cosetReps = Union[Z4Z12, SameTest -> (MemberQ[H, multZ4Z12[#1, -#2]] & )]Out[5]={{0, 0}, {0, 1}, {0, 2}, {0, 3}, {1, 0}, {1, 1}, {1, 2}, {1, 3}}Now (this is different from the previous version), the multiplication of the coset representatives:In[6]:=multF[{a_, b_}, {c_, d_}] := First[Select[cosetReps, MemberQ[H, multZ4Z12[multZ4Z12[{a, b}, {c, d}], -#1]] & ]]And here is the multiplication table:In[7]:=TableForm[MultiplicationTable[cosetReps, multF]]Out[7]//TableForm=TableForm[{{1, 2, 3, 4, 5, 6, 7, 8}, {2, 3, 4, 1, 6, 7, 8, 5}, {3, 4, 1, 2, 7, 8, 5, 6}, {4, 1, 2, 3, 8, 5, 6, 7}, {5, 6, 7, 8, 3, 4, 1, 2}, {6, 7, 8, 5, 4, 1, 2, 3}, {7, 8, 5, 6, 1, 2, 3, 4}, {8, 5, 6, 7, 2, 3, 4, 1}}]I hope this is now O.K.Andrzej> Andrzej,> I am not sure that I am getting the desired nal multiplication table> output.>> The output I get for the multiplication table:>> MultiplicationTable[cosetReps, multZ4Z12] // TableForm>> has zeros in it. (Perhaps I have not used the right equation to > calculate> the multiplication table.) I am not sure that the code is > understanding that> the result might not be an exact match of the original coset, but > might have> bits and pieces of the original coset.>> For example, manually multiplying (element for element) the coset> represented by (3,0) and (3,2) gives:>> {(2,2), (2,6), (2,10), (2,2), (2,6), (2,10)}, when the actual coset> represented by the identity is:>> {{0, 0}, {2, 2}, {0, 4}, {2, 6}, {0, 8}, {2, 10}}>> I have listed the representative element, such as {0, 0}, rst.>> I greatly appreciate you help with this. The concept of being able to > do> this with Mathematica is very exciting.>> Diana M.>> -----Original Message-----> Sent: Tuesday, December 10, 2002 9:20 PM> To: Diana> Cc: mathgroup@smc.vnet.net; Andrzej Kozlowski> I think the best way is to use cost representatives rather than cosets> to construct your table.>> First dene Z4Z12 in your way:>> In[2]:=> Z4Z12 = Flatten[Outer[List, Range[0, 3], Range[0, 11]], 1]>> Out[2]=> {{0, 0}, {0, 1}, {0, 2}, {0, 3}, {0, 4}, {0, 5}, {0, 6},> {0, 7}, {0, 8}, {0, 9}, {0, 10}, {0, 11}, {1, 0}, {1, 1},> {1, 2}, {1, 3}, {1, 4}, {1, 5}, {1, 6}, {1, 7}, {1, 8},> {1, 9}, {1, 10}, {1, 11}, {2, 0}, {2, 1}, {2, 2}, {2, 3},> {2, 4}, {2, 5}, {2, 6}, {2, 7}, {2, 8}, {2, 9}, {2, 10},> {2, 11}, {3, 0}, {3, 1}, {3, 2}, {3, 3}, {3, 4}, {3, 5},> {3, 6}, {3, 7}, {3, 8}, {3, 9}, {3, 10}, {3, 11}}>> In[3]:=> multZ4Z12[{a_, b_}, {c_, d_}] := {Mod[a + c, 4],> Mod[b + d, 12]}> Next we cpnstruct the subroup generated by {2,2} (your Coset1):>> In[4]:=> H = NestWhileList[multZ4Z12[#1, {2, 2}] & , {2, 2},> #1 != {0, 0} & ]>> Out[4]=> {{2, 2}, {0, 4}, {2, 6}, {0, 8}, {2, 10}, {0, 0}}>> Now we can use Union with a suitable SameTest function to obtian a set> of coste representatives:> In[7]:=> cosetReps = Union[Z4Z12, SameTest ->> (MemberQ[H, multZ4Z12[#1, -#2]] & )]>> Out[7]=> {{0, 0}, {0, 1}, {0, 2}, {0, 3}, {1, 0}, {1, 1}, {1, 2},> {1, 3}}>> We only need to generate a multiplication table for the coset> representatives, so we deea new multiplication:>> In[8]:=> multF[{a_, b_}, {c_, d_}] := Select[cosetReps,> MemberQ[H, multZ4Z12[{a, b}, {c, d}] - #1] & ]>> You cna check that it wrks the right way. Now it is easy to generate> the multiplication table.>> Not e that I have paid no attention to efciency here. This method> works nicely for examples of your size. For much larger ones it would> be necessary to carefully consider the question of efciency and the> code would almost certainly become less compact.>> Andrzej Kozlowski> Yokohama, Japan>>> Math friends,>> I am trying to create a multiplication table for the factor groups,>> (Z_4 (+) Z_12)/<(2,2)>>> I understand how to list the elements of (Z_4 (+) Z_12). This is done>> with:>> Z4Z12 = Flatten[Outer[List, Range[0, 3], Range[0, 11]], 1]>> I would like to be able to gure out how to list the eight factor>> groups>> with a calculation with (2,2). This would be in modulo 4,12 >> arithmetic.>> As a workaround, I dened (Z_4 (+) Z_12)/<(2,2)> as the eight cosets>> dened below:>> multZ4Z12[{a_, b_}, {c_, d_}] := {Mod[a + c, 4], Mod[b + d, 12]}>> Multiplication[Z4Z12, multZ4Z12] // TableForm;>> Coset1 = {Z4Z12[[1]], Z4Z12[[27]], Z4Z12[[5]], Z4Z12[[31]], >> Z4Z12[[9]],>> Z4Z12[[35]]}>> Coset2 = {Z4Z12[[2]], Z4Z12[[28]], Z4Z12[[6]], Z4Z12[[32]],>> Z4Z12[[10]],>> Z4Z12[[36]]}>> Coset3 = {Z4Z12[[3]], Z4Z12[[29]], Z4Z12[[7]], Z4Z12[[33]],>> Z4Z12[[11]],>> Z4Z12[[25]]}>> Coset4 = {Z4Z12[[4]], Z4Z12[[30]], Z4Z12[[8]], Z4Z12[[34]],>> Z4Z12[[12]],>> Z4Z12[[26]]}>> Coset5 = {Z4Z12[[37]], Z4Z12[[15]], Z4Z12[[41]], Z4Z12[[19]],>> Z4Z12[[45]],>> Z4Z12[[23]]}>> Coset6 = {Z4Z12[[38]], Z4Z12[[16]], Z4Z12[[42]], Z4Z12[[20]],>> Z4Z12[[46]],>> Z4Z12[[24]]}>> Coset7 = {Z4Z12[[39]], Z4Z12[[17]], Z4Z12[[43]], Z4Z12[[21]],>> Z4Z12[[47]],>> Z4Z12[[13]]}>> Coset8 = {Z4Z12[[40]], Z4Z12[[18]], Z4Z12[[44]], Z4Z12[[22]],>> Z4Z12[[48]],>> Z4Z12[[14]]}>> I was not able to gure a way to create a multiplication table with>> these>> eight elements, because of the multiple part modulo addition.>> There must be a way to multiply <(2,2)> by different elements of the>> external direct product, and a way to compute the multiplication table>> of>> the factor groups. Can someone help?>> Diana>> ==== ==================================================>> God made the integers, all else is the work of man.>> L. Kronecker, Jahresber. DMV 2, S. 19.>>>Andrzej KozlowskiYokohama, Japanhttp://www.mimuw.edu.pl/~akoz/http:// platon.c.u-tokyo.ac.jp/andrzej/ ==== =Andrzej,One further question:I was able to replicate all of your work, thanks. I see how to get H,H = NestWhileList[multZ4Z12[#1, {2, 2}] &, {2, 2}, #1 != {0, 0} &]I also sort of understand the coset representative calculation,cosetReps = Union[Z4Z12, SameTest -> (MemberQ[H, multZ4Z12[#1, -#2]] &)]I have tried to derive the different coset groups by altering the expressionfor H above, for example,H01 = NestWhileList[multZ4Z12[#2, {2, 2}] &, {0, 1}, #2 != {0, 1} &]to get the coset group with representative {0, 1}, but no matter how Ichange the variables in the expression, I get H back.> Here is the correct code, I hope.>> First load the Combinatorica package:>> In[1]:=> << DiscreteMath`Combinatorica`>> Next dene the group elements>> In[2]:=> Z4Z12 = Flatten[Outer[List, Range[0, 3], Range[0, 11]], 1]>> Out[2]=> {{0, 0}, {0, 1}, {0, 2}, {0, 3}, {0, 4}, {0, 5}, {0, 6}, {0, 7}, {0,> 8}, {0, 9},> {0, 10}, {0, 11}, {1, 0}, {1, 1}, {1, 2}, {1, 3}, {1, 4}, {1, 5}, {1,> 6},> {1, 7}, {1, 8}, {1, 9}, {1, 10}, {1, 11}, {2, 0}, {2, 1}, {2, 2}, {2,> 3},> {2, 4}, {2, 5}, {2, 6}, {2, 7}, {2, 8}, {2, 9}, {2, 10}, {2, 11}, {3,> 0},> {3, 1}, {3, 2}, {3, 3}, {3, 4}, {3, 5}, {3, 6}, {3, 7}, {3, 8}, {3,> 9},> {3, 10}, {3, 11}}>> Next,t he group multiplication:>> In[3]:=> multZ4Z12[{a_, b_}, {c_, d_}] := {Mod[a + c, 4], Mod[b + d, 12]}>> THe generated subgroup:>> In[4]:=> H = NestWhileList[multZ4Z12[#1, {2, 2}] & , {2, 2}, #1 != {0, 0} & ]>> Out[4]=> {{2, 2}, {0, 4}, {2, 6}, {0, 8}, {2, 10}, {0, 0}}>> The coset representatives:>> In[5]:=> cosetReps = Union[Z4Z12, SameTest -> (MemberQ[H, multZ4Z12[#1, -#2]] &> )]>> Out[5]=> {{0, 0}, {0, 1}, {0, 2}, {0, 3}, {1, 0}, {1, 1}, {1, 2}, {1, 3}}>> Now (this is different from the previous version), the multiplication> of the coset representatives:>> In[6]:=> multF[{a_, b_}, {c_, d_}] := First[Select[cosetReps,> MemberQ[H, multZ4Z12[multZ4Z12[{a, b}, {c, d}], -#1]] & ]]>> And here is the multiplication table:>> In[7]:=> TableForm[MultiplicationTable[cosetReps, multF]]>> Out[7]//TableForm=> TableForm[{{1, 2, 3, 4, 5, 6, 7, 8}, {2, 3, 4, 1, 6, 7, 8, 5},> {3, 4, 1, 2, 7, 8, 5, 6}, {4, 1, 2, 3, 8, 5, 6, 7}, {5, 6, 7, 8, 3,> 4, 1, 2},> {6, 7, 8, 5, 4, 1, 2, 3}, {7, 8, 5, 6, 1, 2, 3, 4}, {8, 5, 6, 7, 2,> 3, 4, 1}}]>> I hope this is now O.K.> Andrzej>> ==== =As I understand it, I can write a Complex java class with a public constructormethod of the form: public Complex(double Re, double Im)and mehtods re() and im() of the form: public double re(); public double im();If I place this class le in a directory on the JavaClassPath and execute SetComplexPath[Complex], I should then be able to pass complex numbers from Mathematica to any java method accepting objects of type Complex. Has anyone had any luck with this? I haven't been able to get it to work inMac OS 9 or Mac OS X.Mark McClureDept. of MathematicsUniversity of North Carolina at Ashevillehttp://www.unca.edu/~mcmcclur/ ==== =Okay, nally I get it. I apologize for thinking you're all nitwits. :^) So the question is whether 1^Innity (and related forms)could/should be assigned some value in a non-limit sense. Thinking back on a previous life (FORTRAN) I see that there may be systems in which it would make sense to have 1^Innity = 1 while 1.^Innity = Indeterminant. But in a system that contains rationals as well as integers, it seems to me that having 1^Innity = 1 is just as wrong as 1.^Innity = 1. (The wrongness of 1.^Innity = 1, by the way, must be understood in terms of limits, not machine arithmetic, since 1. is a machine number.)As usual, Mathematica does the right thing, defering to generality andconsistency with traditional mathematics.---Selwyn Hollis> [Message also posted to: comp.soft-sys.math.mathematica]>>It is astonishing that debates like this keep coming up. To anyone who>>disagrees with the notion that 1^Innity is indeterminate, I suggest>>that you write something called a new kind of calculus. But you might>>want to learn the old kind rst.> I taught calculus for many years. Unless I've misunderstood Ted, his> question has nothing to do with calculus. (If I have misunderstood you,> Ted, please let me know!)> What you're thinking about, Selwyn, cannot be debated -- at least not> by reasonable people:> Certain _limit_ forms, such as 1^oo and 0^0, are indeterminate.> > Just as for the arithmetic expression 0^0, whether the arithmetic> expression 1^Innity should be dened as 1, or be undened, is still> open to debate by reasonable people.> Note: Of course, dening the arithmetic expressions 0^0 and 1^Innity> to be 1 would in no way alter the fact that f(x,y) = x^y has essential> singularities at (0,0) and (1,Innity), and so would in no way alter> the fact that the limit forms 0^0 and 1^Innity are indeterminate.> David Cantrell> ==== => It is astonishing that debates like this keep coming up. To anyone who> disagrees with the notion that 1^Innity is indeterminate, I suggest> that you write something called a new kind of calculus. But you might> want to learn the old kind rst.I taught calculus for many years. Unless I've misunderstood Ted, hisquestion has nothing to do with calculus. (If I have misunderstood you,Ted, please let me know!)What you're thinking about, Selwyn, cannot be debated -- at least notby reasonable people:Certain _limit_ forms, such as 1^oo and 0^0, are indeterminate.That is simply a fact. It cannot be altered (unless we were to changethe power function x^y substantially, which surely we don't want to do).But, when we say that a certain limit form is indeterminate, it isimportant to know not only what that _does_ mean, but also what it does_not_ mean! Let's take the limit form 0^0 as an example. Saying that itis indeterminate means that, as x and y approach 0, x^y may approachany of many different possible values (or the limit may not exist).[The word indeterminate is appropriate in that, merely knowing thatboth base and power approach 0, we do not have enough informationto be able to determine the limit, if it exists.] This indeterminacy isdue to the fact that f(x,y) = x^y has an essential singularity at (0,0).But saying that the limit form 0^0 is indeterminate does _not_ mean thatthe simple arithmetic expression 0^0 need be undened. In the arithmeticexpression 0^0, both base and power _are_ 0, they are constant. No limitsare involved. Whether the arithmetic expression 0^0 should be dened as1, as many prominent mathematicians (including Euler, Knuth, Graham, andKahan) have suggested, or should be undened, is apparently still open todebate by reasonable people.Now the OP had asked about 1^Innity. If he was asking about the limitform 1^Innity, then, just as for 0^0, there can be no reasonabledebate. That limit form is indeterminate, period. But, since he mentionedno limits, I had naturally assumed that he had in mind the simplearithmetic expression 1^Innity, in which the base does not merelyapproach 1, but rather _is_ 1, and the power does not merely approachInnity, by rather _is_ Innity. Both base and power are constants.(In case you're balking at the notion of the power being the constantInnity: Of course, there is no such constant in the real numbersystem. But such a constant does exist in an extension of the reals.)Just as for the arithmetic expression 0^0, whether the arithmeticexpression 1^Innity should be dened as 1, or be undened, is stillopen to debate by reasonable people.Note: Of course, dening the arithmetic expressions 0^0 and 1^Innityto be 1 would in no way alter the fact that f(x,y) = x^y has essentialsingularities at (0,0) and (1,Innity), and so would in no way alterthe fact that the limit forms 0^0 and 1^Innity are indeterminate.David Cantrell-- -------------------- http://NewsReader.Com/ --------------------Usenet Newsgroup Service New Rate! $9.95/Month 50GB ==== =I observed the same thing, except I was computing closures on a largenumber of graphs, again using combinatorica. I examined thecombinatorica code and couldn't nd any place where it was holding onto references internally, but none the less I xed it by modifyingtheir algorithms for my purposes. What I did, in particular, wasinstead of maintaining the several representations of the graph thatcombinatorica passes around, I just used adjacency list.I never did prove what's going on, but my guess is that there is someresults caching in Mathematica (that is suggested by the graph ofMemoryInUse[] as I did repeated closures: it had a distinct sawtoothsuperimposed on it). Perhaps Mathematica doesn't clear the cache aggressivelyenough, maybe having a long chain of references causes it to loose trackof the actual size of something, or it doesn't examine the whole chaineach time is does a cache sweep, or ...> Dearest group> Has anyone noticed this before? I would like to use KSubsets and> RandomKSubsets a few million times in a proggy, but after executing it a few> thousand times Mathematica crashes, running out of memory. Watching my Taskman (Win> 2K, Mathematica 4.1) we see a constant increase in memory used, until its all soaked> up. I have this problem with both the Combinatorica.m that shipped with> Mathematica, and the new one that has been written, which I believe is now the one> in Mathematica 4.2. I am not really sure what it means to Ôleak memory', but this> seems to t the bill.> Here is a crashing-demo. Executing memorySwallower[3,100], for example,> repeatedly just soaks up more and more memory. Pourquoi? I believe the> same thing happens if I use KSubsets also.> In[1]:=> MemoryInUse[]> Get[DiscreteMath`Combinatorica`]> MemoryInUse[]> Out[1]=> 1398624> Out[3]=> 1956536> memorySwallower[S_,n_]:=> Module[{data,subsamples},Print[ToString[MemoryInUse[]]];> Table[data=Table[{i,j},{i,1000},{j,1+m}];> subsamples=Table[RandomKSubset[data,S],{100}],{m,n}];> Print[ToString[MemoryInUse[]]]]> memorySwallower[3,100]> 15497936> 29833672> B> _____________________________> Bernard Gress> Department of Economics> University of California, Riverside> 1150 University Ave.> Riverside, CA 92521-0247> BGRESSatMAILdotUCRdotEDU> http://www.economics.ucr.edu/people/candidates.html ==== =and have found another entirely separate curious behaviorwhich I do not understand.First, if we ask Mathematica (version 4.1) toIntegrate[Sin[x+d]/(x+d), {x, -Innity, 0}]we get, incorrectly, -Pi/2 + SineIntegral[d].A correct result would have been +Pi/2 + SineIntegral[d].The incorrect behavior above presumably explains, in somesense, what I had noted in my previous post:Integrate[Sin[x+d]/(x+d), {x, -Innity, Innity}] incorrectly yields 0.Second, it seems that Mathematica does get correctanswers for such integrals if d is given as a specic value.But sometimes the answer is quite needlessly complicated.For example, Integrate[Sin[x+Pi]/(x+Pi), {x, -Innity, 0}]yields the messy result(Pi*(-2 + Sqrt[2]*BesselJ[1/2, Pi])*Log[2])/2 - (Pi*(-2 + Sqrt[2]*BesselJ[1/2, Pi])*Log[4])/4 + (I/2)*(I*Pi + 2*Pi^2 - (2*I)*Pi*Log[Pi]) - ((-2 + Sqrt[2]*BesselJ[1/2, Pi])*(EulerGamma*Pi^(3/2) - I*Pi^(5/2) - Pi^(3/2)*Log[Pi]))/(2*Sqrt[Pi]) + (Pi^(3/2)*(-(((-2 + Sqrt[2]*BesselJ[1/2, Pi])*Log[2])/ Sqrt[Pi]) - (EulerGamma*Pi - 2*SinIntegral[Pi] + SinIntegral[2*Pi])/Pi^(3/2) - (-4*Sqrt[Pi] + 2*EulerGamma*Sqrt[Pi] + 2*Sqrt[Pi]*Log[4] - Sqrt[2*Pi]* Derivative[1, 0][BesselJ][1/2, Pi])/(2*Pi)))/2But Pi/2 + SineIntegral[Pi] is a much simpler correct answer!BTW, asking for a numerical approximation of the messyanswer above, we get correctly 3.42273 + 1.77635*10^-15*I .(Of course, the precise answer is purely real. The very smallimaginary component in the approximation is an understandableartifact.)Now here's the new behavior I can't understand:Suppose that we ask Mathematica to Simplify the messyresult above, hoping that it will be smart enough to give ussomething like Pi/2 + SineIntegral[Pi] . Instead, we getIndeterminatepreceded by the comment!(Power::indet ((:)( )) Indeterminate expression !(0``68.9889^0) encountered.)Now it's bad enough that Mathematica thinks the result isIndeterminate, but what I really can't grasp is how ßoating-pointvalues could possibly be involved in this matter: The messyexpression to be simplied was _precise_! Floating-point valuesshould have nothing to do with its simplication.Curiously, David Cantrell-- -------------------- http://NewsReader.Com/ --------------------Usenet Newsgroup Service New Rate! $9.95/Month 50GB ==== =Have no idea why it is doing this but interesting to note that if you replace d by a specic value you always seem to get Pi rather than 0 as an answer. Also, you might want to look at the integals from 0 to Innity and -Innity to 0 (the latter is especially messy for a specic value of d). Maybe a clue there.> Using version 4.1,> Integral[Sin[x+d]/(x+d),{x,-Innity,Innity}] yields 0 .> This is, of course, incorrect. (Does version 4.2 make this error also?)> Mathematica does Integral[Sin[x]/x,{x,-Innity,Innity}] correctly> however, yielding Pi, which should also be the answer for the original> integral (regardless of the value of d).> Does anyone have an idea why Mathematica gets the original integral wrong?> David Cantrell> ==== =>Allan>> I type primitives in the Master Index and get section 2.9.1, which does> not> have a list of all the primitives. Yes, of course I found it sooner or> later.> But that's not a good index.> All I can say is that, when someone asks me about Mathematica, I'll say it> is> hard to use for many reasons, and one of them is the poor documentation.> Dave GolberI agree that the documentation is extensive, but at the same timeit's inadequate. For example try to nd out how to delimit a function(subroutine) denition without using Module[{x}, . Or try to nd howto put several statements together in one branch of an If statement. Ortry to nd a clear and complete explanation of exactly how to increasethe precision of all computations in a notebook. The rst two I guessedat and have answers for. The last one I still don't know. I may beunusual in that I work alone, have no one to ask questions of verbally,and will not pay over $1000 for a 2-day course. ==== => So today I'm doing some graphics. Oh: there are _options_ and _directives_.> So I try to nd out what are all the graphics primatives?> When you look in the index of the 1500 page book, or type Graphics Primatives> in the on-line Help, you don't nd it. You have to look under Graphics or> Graphics3D. In the book, it's in the appendix.> And the entry in the appendix is not quite complete:> It says Graphics[primatives, options] represents a two-dimensional graphical> image.> It should say returns a graphis object The reason is that the appendix is> the place for the complete and formal description of the functions and all> their arguments and returns. No longer the place for chatty-teachy.> (represents is chatty-teachy)> To understand the system, I need to be able to trace the sequence> Line[...] is a graphics _primative_> Graphics[ ... graphics primatives ....] is a graphics _object_> Show [... graphics object...] puts a picture on the screen.> I don't know if this sounds dumb on my part, but I do know that I have just> wasted a bunch of time on this, and that having to go back and forth just to> nd out the type of the return of a function (to use old fashioned> nomenclature) .... which people knew thirty years ago was part of documenting a> system .... seems pretty dumb on the part of Mathematica.> Dave GolberGRAY: Here again I agree. All the different kinds of graphic-relatedentities are quite confusing. The only way I cope is to copy a workinggraphic sequence and change it bit by bit until it does what I want. Thisusually works but is very slow. I have wasted hours on this. I expectbetter from documentation of an expensive professional product. Another thing that bothers me is that the error messages tell menowhere near enough to help nd the error easily. And so far as I knowmost of these messages are not documented anywhere. There are about 12entries under error in the book but there should be a place where youcan just look up anything that appears in the microscopic blue print. ==== =---Snip-------> Another thing that bothers me is that the error messages tell me> nowhere near enough to help nd the error easily. And so far as I know> most of these messages are not documented anywhere. There are about 12> entries under error in the book but there should be a place where you> can just look up anything that appears in the microscopic blue print.>Steve,You will nd descriptions and examples of warning messages at menu>Help>Help Browser>Other Information>Warning Messages.To nd out about the warning message that is generated below Plot[a,{a,b,c}] Plot::plln: Limiting value b in {a,b,c} is not a machine-size realnumber. Plot[a,{a,b,c}]do the following- select plln (not Plot::plln)- menu>Help > Find Selected Function... >..- click button Other Information- click on Go To button (or on function::plln at bottom right) ==== =I'm trying to do a 2 dimensional convolution of the Airy disk with theimage of an extended source in an optical system, using the DigitalImage Processing package. Does anyone have an example routine for doingthis?lanny.sterritt@lmco.com ==== => I'm trying to do a 2 dimensional convolution of the Airy disk with the> image of an extended source in an optical system, using the Digital> Image Processing package. Does anyone have an example routine for doing> this?>> lanny.sterritt@lmco.com>here is a suggestion. Assuming img is the image and ker is the Airy diskshaped kernel calculate:result = DiscreteConvolve[img, ker, Centered->True];Display result using:ListDensityPlot[ result, Mesh->False] ;I understand that the Airy disk is dened BesselJ[1,x]^2/x^2, so a 2D diskin rectangular coordinates can be obtained as follows (you may need tochange the limits and step size in Table to t your needs):ker = N[Table[If[x^2 + y^2 == 0, 1/2, BesselJ[1, Sqrt[x^2 + y^2]]^2/(x^2 +y^2)], {x, -6, 6}, {y, -6, 6}]];Hope this helps, Mariusz ==== ============================Mariusz JankowskiUniversity of Southern Mainemjkcc@usm.maine.edu207-780-5580Reply-To: tharter@attglobal.net ==== = How can I get Mathematica 4.2 to do simple multipliction thruPlusMinus operators?For example, suppose I have a 3-dimensional vector with componenttolerances specied: In[4]:= va = {{4.10 ± 0.057}, {-3.16 ± 0.796}, {5.09 ± .250}} Out[4]:={{4.1[PlusMinus]0.057},{-3.16[PlusMinus]0.796},{5.09[ PlusMinus]0.25}} In[5]:= FullForm[va] Out[5]://FullForm=List[List[PlusMinus[4.1`,0.057`]],List[ PlusMinus[-3.16`,0.796`]],List[PlusMinus[5.09`,0.25`]]] In[6]:= 5.2*va Out[6]:= {{5.2 (4.1[PlusMinus]0.057)},{5.2(-3.16[PlusMinus]0.796)},{5.2 (5.09 [PlusMinus]0.25)}}However, what I want is (for the rst component of the vector, va) is 5.2*4.1 ± (5.2*0.057)or, equivalently 21.32 ± 0.2964Is there a standard package to do this? I wasn't able to nd anythingof help inSection 1.10 or 3.10 of the Wolfram Reference. How does one assignmeaning to thePlusMinus operator to do simple arithmetic calculations as shown above?Many thanks to all who may respond!....Terry H ==== =Terry, Use a Repalcement rule:va /. PlusMinus[x_, y_] -> PlusMinus[a x, a y]{{4.1 a ± 0.057 a}, {-3.16 a ± 0.796 a}, {5.09 a ± 0.25 a}}Brian> How can I get Mathematica 4.2 to do simple multipliction thru> PlusMinus operators?> For example, suppose I have a 3-dimensional vector with component> tolerances specied:> In[4]:= va = {{4.10 ± 0.057}, {-3.16 ± 0.796}, {5.09 ± .250}}> Out[4]:=> {{4.1[PlusMinus]0.057},{-3.16[PlusMinus]0.796},{5.09[ PlusMinus]0.25}}> In[5]:= FullForm[va]> Out[5]://FullForm=> List[List[PlusMinus[4.1`,0.057`]],List[PlusMinus[-3.16`,0.796 `]],> List[PlusMinus[5.09`,0.25`]]]> In[6]:= 5.2*va> Out[6]:= {{5.2 (4.1[PlusMinus]0.057)},{5.2> (-3.16[PlusMinus]0.796)},{5.2 (5.09> [PlusMinus]0.25)}}> However, what I want is (for the rst component of the vector, va) is> 5.2*4.1 ± (5.2*0.057)> or, equivalently> 21.32 ± 0.2964> Is there a standard package to do this? I wasn't able to nd anything> of help in> Section 1.10 or 3.10 of the Wolfram Reference. How does one assign> meaning to the> PlusMinus operator to do simple arithmetic calculations as shown above?> Many thanks to all who may respond!> ....Terry HReply-To: kuska@informatik.uni-leipzig.de ==== =a) there is no standard package b)PlusMinus /: a_*PlusMinus[v_, d_] := PlusMinus[a*v, a*d]BTW PlusMinus[] is for typesetting not for calculations,you have to do your error propagation by your self Jens> How can I get Mathematica 4.2 to do simple multipliction thru> PlusMinus operators?> For example, suppose I have a 3-dimensional vector with component> tolerances specied:> In[4]:= va = {{4.10 ± 0.057}, {-3.16 ± 0.796}, {5.09 ± .250}}> Out[4]:=> {{4.1[PlusMinus]0.057},{-3.16[PlusMinus]0.796},{5.09[ PlusMinus]0.25}}> In[5]:= FullForm[va]> Out[5]://FullForm=> List[List[PlusMinus[4.1`,0.057`]],List[PlusMinus[-3.16`,0.796 `]],> List[PlusMinus[5.09`,0.25`]]]> In[6]:= 5.2*va> Out[6]:= {{5.2 (4.1[PlusMinus]0.057)},{5.2> (-3.16[PlusMinus]0.796)},{5.2 (5.09> [PlusMinus]0.25)}}> However, what I want is (for the rst component of the vector, va) is> 5.2*4.1 ± (5.2*0.057)> or, equivalently> 21.32 ± 0.2964> Is there a standard package to do this? I wasn't able to nd anything> of help in> Section 1.10 or 3.10 of the Wolfram Reference. How does one assign> meaning to the> PlusMinus operator to do simple arithmetic calculations as shown above?> Many thanks to all who may respond!> ....Terry H ==== => disvovered that the portion of the plot between,9.5Pi and 11Pi is displayed > as a line segment joining the points {9.5 , 9.5 Sin[9.5]} and {11 , 11 > Sin[11]}. I've also found that the plot from x=-100 to x=99.99 is incorrect. > The plot over the range [-100,99] is correct. What is happening here? Does > this happen on other systems?I tried this in 4.0 and saw the same thing. If you add the directivePlotPoints->100, it xes it. ==== =greetings:what is happening here is Mathematica is showing something about the adaptiveplottingalgorithm. by altering the value of PlotPoints, one can modify the pointselection.try some examples with different values of PlotPoints. you/ll besurprised.try PlotPoints->n for n=26? n=12 (!) n=2 (!). what/s going on?now, get your hands on the points that are being selected by using:pts = Plot[x Sin[x], {-100,100}][[1,1,1,1]]the x,y coordinates are:xpts = Transpose[pts][[1]]ypts = Transpose[pts][[2]]now plot these with ListPlot.you/ll see that the xpts are not uniformly spaced as you might expect.this Ôfeature' in the plotting algorithm has been there since the daysof Mathematica on NeXt (that/s when i rst saw this)is it a bug? is it an artifact of the adaptive algorithm and thusinherent?m. r.> disvovered that the portion of the plot between,9.5Pi and 11Pi is displayed> as a line segment joining the points {9.5 , 9.5 Sin[9.5]} and {11 , 11> Sin[11]}. I've also found that the plot from x=-100 to x=99.99 is incorrect.> The plot over the range [-100,99] is correct. What is happening here? Does> this happen on other systems?> I tried this in 4.0 and saw the same thing. If you add the directive> PlotPoints->100, it xes it. ==== =A similar problem occurs with Mathematica 4.2 for Windows, but the rangeover which it occurs is somewhere in the range x=30 to x=40 (I haven'tchecked precisely). You can x the problem by using a larger number ofPlotPoints, which ensures that the oscillating function you want to plotdoesn't fool the plotting algorithm. In this case the following works:Plot[x Sin[x], {x, -100, 100}, PlotPoints -> 100];Steve Luttrelland> disvovered that the portion of the plot between,9.5Pi and 11Pi isdisplayed> as a line segment joining the points {9.5 , 9.5 Sin[9.5]} and {11 , 11> Sin[11]}. I've also found that the plot from x=-100 to x=99.99 isincorrect.> The plot over the range [-100,99] is correct. What is happening here?Does> this happen on other systems?> --> STH> Hatton's Law:> There is only One inviolable Law.>>Reply-To: kuska@informatik.uni-leipzig.de ==== =set the PlotPoints option to a value that resolve the oscillationsand Plot[x Sin[x], {x, -100, 100}, PlotPoints -> 66]will work ne. Jens> disvovered that the portion of the plot between,9.5Pi and 11Pi is displayed> as a line segment joining the points {9.5 , 9.5 Sin[9.5]} and {11 , 11> Sin[11]}. I've also found that the plot from x=-100 to x=99.99 is incorrect.> The plot over the range [-100,99] is correct. What is happening here? Does> this happen on other systems?> --> STH> Hatton's Law:> There is only One inviolable Law. ==== =A correspondent has sent me the following problem.I want to calculate the intersection of an ellipse ((x-c)^2/b^2 + (y-d)^2/a^2 ==1) with centre at the point (c,d) and a circle (x^2 + y^2 == 1) with centre at(0,0). What are the formal point solutions?.ellipse = (x - c)^2/b^2 + (y - d)^2/a^2 == 1;circ = x^2 + y^2 == 1;sol = Solve[{ellipse, circ}, {x, y}];The output comes out immediately as a rather long expression. However, when trying to obtain numerical values for given values of a, b, c, and d, I get complex numbers, and even in the case where their imaginary part is close to 0, the real part doesn't correspond at all to the solution (as seen in an implicit plot of the two gures). I'm at a loss!What's going on?Tomas GarzaMexico City ==== =Gentlemen;We are a research group on mineral processing ofINGEOMINAS; which is a geological institute here inColombia and are interested in knowing if could usethis software to solve kinetics expression like thefollowing:t= C1g(X)+C2p(X)Where g(x) = 1- ( 1-X)^1/3 and p(X) = 1- 3(1-X)^2/3 +2(1-X); t=time(min); X = extent of reaction % ;According with bibliography ,through the method ofNedler and Mead (Flexible Polyhedron search method)C1and C2 can be obtained from minimization of thefunction.We would greateful if you could give us an orientationto solve our experimental problem. I would ask you anspecial collaboration to develop one example with thecorrect syntax using the experimental results sent inthe attachment le. [contact the author to obtaincollaboration and orientation.Carlos EspitiaGeorecursos AreaINGEOMINAS Diagonal 53 # 34 .9a 53Bogota .9a Colombia ==== =Carlos , Have you tried to use NonlinearFit? Here is a simple example: << Statistics`NonlinearFit`g[x_]:= 1- ( 1-x)^1/3p[x_]:= 1- 3(1-x)^2/3 +2(1-x)Generate some data with C1=2, C2=3data = Table[{x, 2 g[x] + 3p[x]}, {x, 0, 1, .1}];NonlinearFit[data, c1 g[x] + c2 p[x], {x}, {c1, c2}]3.*(1 + 2*(1 - x) - (1 - x)^2) + 2.*(1 + (-1 + x)/3)Brian> Gentlemen;> We are a research group on mineral processing of> INGEOMINAS; which is a geological institute here in> Colombia and are interested in knowing if could use> this software to solve kinetics expression like the> following:> t= C1g(X)+C2p(X)> Where > g(x) = 1- ( 1-X)^1/3 and p(X) = 1- 3(1-X)^2/3 +2(> 1-X); t=time(min); X = extent of reaction % ;> According with bibliography ,through the method of> Nedler and Mead (Flexible Polyhedron search method)C1> and C2 can be obtained from minimization of the> function.> We would greateful if you could give us an orientation> to solve our experimental problem. I would ask you an> special collaboration to develop one example with the> correct syntax using the experimental results sent in> the attachment le. [contact the author to obtain> collaboration and orientation.> Carlos Espitia> Georecursos Area> INGEOMINAS Diagonal 53 # 34 .9a 53> Bogota .9a Colombia ==== =If you study the following sequence youÇll understand how to obtain what youwant:In[1]:=sol = Solve[{3*x + y + z == -1, 2*x + y + z == -3, x - y + z == -3}, {x, y, z}]Out[1]={{x -> 2, y -> -1, z -> -6}}In[2]:=pos = Cases[sol[[1]], w_ /; w[[2]] > 0]Out[2]={x -> 2}In[3]:=pos[[1,2]]Out[3]=2Bear in mind that the solution to a set of simultaneous equations comes outas a sequence of rules. Then Cases will help you get the rule or rules wherethe second part is positive.Tomas GarzaMexico City----- Original Message ----->> Angela Birk>> --> Angela Birk> University of Hamburg> HWWA> Economics> 20347 Hamburg, Germany> +49 40 42834 - 478>> ==== =I believe the reason may be that it expects the result to be interpreted asa repeating result. The root Pi, is simply the root 0, which it does nd,in the next period of the function. So, if you view it like this:roots = 0 + k*Pi (k=+-1, +-2, +-3,...)in this case where k = 1, you get your root.I'm not 100% certain, but this may be what it assumes.--Steven> Regard this function:>> f[x_] := Sin[x]^3 * Cos[x]>> And then try this:>> Solve[f'[x] == 0, x]>> and you'll get a list of all roots but one. I wonder why.>> By regarding f'[x] one can directly see that x = pi is a root,>> yet, Mathematica fails to see it...> V.8anligen> Konrad> ------------------->>> ==== =f'[x] is a periodic function, hence it has an innity of roots.Mathematica tries to sample at least one period of this function; inthis case it returns roots contained in the (-Pi,Pi) interval.Since the period of the function is Pi, it can be deduced that x->0also corresponds to x->Pi (actually x->k*Pi, with k in the Integers).Since Solve produces a relevant message, I think its overall behaviouris consistent in this case.Orestis Vantzos> Regard this function:> f[x_] := Sin[x]^3 * Cos[x]> And then try this:> Solve[f'[x] == 0, x]> and you'll get a list of all roots but one. I wonder why.> By regarding f'[x] one can directly see that x = pi is a root,> yet, Mathematica fails to see it...> V.8anligen> Konrad> ------------------- ==== => Regard this function:>> f[x_] := Sin[x]^3 * Cos[x]>> And then try this:>> Solve[f'[x] == 0, x]>> and you'll get a list of all roots but one.No, you don't. There are innitely many roots, of which Mathematica givesyou only three: -Pi/2, 0, and Pi/2.> I wonder why.Didn't you notice Mathematica's comment that, since inverse functions werebeing used, some solutions might not be found? That's the explanation.> By regarding f'[x] one can directly see that x = pi is a root,>> yet, Mathematica fails to see it...More basically, just try Solve[Sin[x] == 0, x]. The only solution you'llget is 0, the _principal_ value of the inverse sine of 0.David-- -------------------- http://NewsReader.Com/ --------------------Usenet Newsgroup Service New Rate! $9.95/Month 50GB ==== => No, you don't. There are innitely many roots, of which Mathematica gives> you only three: -Pi/2, 0, and Pi/2.Actually, you get ve different roots, not three. Nevertheless - pointtaken.I ment of course that i'd like Mathematica to give me ALL the roots on form:angle + (period * n). I'll try to be more exact the next time.> Didn't you notice Mathematica's comment that, since inverse functions were> being used, some solutions might not be found? That's the explanation.Yes, i did. I wonder why it's the ONLY method used by Mathematica. It feelspretty bad to know that the program misses some simple roots. I don'twonderwhat kind of algorithm gave that, rather why do they use only thatalgorithm.I appologize if my question caused any trouble by it's fuzziness.--V.8anligenKonrad------------------- ==== =Strange, indeed...I tried the RootSearch package from Ted Ersek... It works ne on yourexample !In[11]:=RootSearch[f'[x]==0,{x,3,3.2}]{{x -> 3.141592653589793}}Florian Jaccard-----Message d'origine-----Envoy.8e : mar., 10. d.8ecembre 2002 10:17è : mathgroup@smc.vnet.netObjet : Why can't Mathematica nd this root?Regard this function:f[x_] := Sin[x]^3 * Cos[x]And then try this:Solve[f'[x] == 0, x]and you'll get a list of all roots but one. I wonder why.By regarding f'[x] one can directly see that x = pi is a root,yet, Mathematica fails to see it...V.8anligenKonrad------------------- ==== =I'm new to Mathematica, and I have a question to which I've found noanswers in the archives. Can you help?The issue is: how do I create a pure recursive function? Normally whencreating a recursive function I use the name of the function to performthe recursive call:fact[n_] := If[n == 0, 1, n fact[n - 1]]However this has the disadvantage that the symbol fact is now global.The logical step to avoid this seems to be to make the name of thefunction local as in something like the following:Function[fact, fact[5]] @@ {Function[n, If[n==0, 1, n fact[n-1]]]}or maybe:With[{fact = Function[n, If[n == 0, 1, n fact[n - 1]]]}, fact[5]]However both of these solutions steadfastly return the value 5fact[4]. I assume the problem is that the variables initialised inFunction[] and With[] must be symbols, and cannot be patterns. But arecursion requires a pattern (n_ in the rst, global, solution above).What do I do to get factorial to work _without_ making the symbol factglobal?I'd be grateful for any help.Niall. ==== =Youneed touse the package Algebra`ExtendedPolynomialGCD. However, because of a bug inthis package you need to use a x. Recently I provided such a x in response to another posting on the same topic. Daniel Lichblau sent me another own, that ought to be better, but I tried it on your example and got errors. So I am sending my own again.In[1]:=<< Algebra`PolynomialExtendedGCD`(Loaded the package)In[2]:=MyPolynomialExtendedGCD[a_, b_, p_] := With[{gcd = PolynomialGCD[a, b, Modulus -> p]}, {gcd, 1}*PolynomialMod[(PolynomialExtendedGCD[##1, Modulus -> p] & ) @@ Cancel[{a, b}/gcd, Modulus -> p], p]](my bug x)In[3]:=f[x_] := x^5 + 4*x^4 + 6*x^3 + 6*x^2 + 5*x + 2In[4]:=g[x_] := x^4 + 3*x^2 + 3*x + 6(your polys)In[5]:=MyPolynomialExtendedGCD[f[x], g[x], 7]Out[5]={2 + 5*x + 4*x^2 + x^3, {5, 1 + 2*x}}(the answer, same as yours).Andrzej KozlowskiYokohama, Japanhttp://www.mimuw.edu.pl/~akoz/http:// platon.c.u-tokyo.ac.jp/andrzej/>> Can Mathematica do the following? (I provided answers that I did by > hand).>> 1. Find the GCD of>> f[x_] := x^5 + 4x^4 + 6x^3 + 6x^2 + 5x +2,> g[x_] := x^4 + 3x^2 + 3x +6>> Answer: gcd (f(x), g(x)) = x^3 + 4x^2 + 5x + 2>> over the eld Z7? (I think the answer is easy and is yes).>> 2. Write the GCD above as a linear combination of the given > polynomials?>> Answer: 5*(x^5 + 4x^4 + 6x^3 + 6x^2 + 5x +2) + (2x + 1)*(x^4 + 3x^2 + > 3x +6)>> This one I am not sure about (I guess we can do it piece-meal, but is > there> a slick function to do it?).>>> ==== =Well, you can use:Function[If[#1 == 0, 1, #1 #0[#1 - 1]]]for example:In[36]:=Function[If[#1==0,1,#1 #0[#1-1]]][3]Out[36]=6#0 is a rarely used parameter which refers to the pure function itself and thus makes it possible to create pure recursive functions. I may be wrong but it seems to me that this feature is unique to Mathematica.Andrzej KozlowskiYokohama, Japanhttp://www.mimuw.edu.pl/~akoz/http:// platon.c.u-tokyo.ac.jp/andrzej/>> I'm new to Mathematica, and I have a question to which I've found no> answers in the archives. Can you help?>> The issue is: how do I create a pure recursive function? Normally when> creating a recursive function I use the name of the function to perform> the recursive call:>> fact[n_] :=> If[n == 1, 1, n fact[n - 1]]>> However this has the disadvantage that the symbol fact is now global.> The logical step to make the name of the function local is something> like:>> Function[factl, factl[5]] @@ {Function[n, If[n == 0, 1, n factl[n -> 1]]]}>> or maybe:>> With[{fact = Function[n, If[n == 0, 1, n fact[n - 1]]]}, fact[5]]>> However both of these solutions steadfastly return the value 5> fact[4]. I assume the problem is that the variables initialised in> Function[] and With[] must be symbols, and cannot be patterns. But a> recursion requires a pattern (n_ in the rst, global, solution above).> What do I do to get factorial to work _without_ making the symbol > fact> global?>> I'd be grateful for any help.>> Niall.> ==== =Andrzej,This is great! I can't wait to play with this tonight.my Abstract Algebra notes for this semester. Myteacher is going to get a kick out of seeing how thisone is done.Diana Mecum> Math friends,>> I am trying to create a multiplication table for the factor groups,>> (Z_4 (+) Z_12)/<(2,2)> I understand how to list the elements of (Z_4 (+) Z_12). This is donewith:>> Z4Z12 = Flatten[Outer[List, Range[0, 3], Range[0, 11]], 1]>> I would like to be able to gure out how to list the eight factor groups> with a calculation with (2,2). This would be in modulo 4,12 arithmetic.>> As a workaround, I dened (Z_4 (+) Z_12)/<(2,2)> as the eight cosets> dened below:>> multZ4Z12[{a_, b_}, {c_, d_}] := {Mod[a + c, 4], Mod[b + d, 12]}>> Multiplication[Z4Z12, multZ4Z12] // TableForm;>> Coset1 = {Z4Z12[[1]], Z4Z12[[27]], Z4Z12[[5]], Z4Z12[[31]], Z4Z12[[9]],> Z4Z12[[35]]}>> Coset2 = {Z4Z12[[2]], Z4Z12[[28]], Z4Z12[[6]], Z4Z12[[32]], Z4Z12[[10]],> Z4Z12[[36]]}>> Coset3 = {Z4Z12[[3]], Z4Z12[[29]], Z4Z12[[7]], Z4Z12[[33]], Z4Z12[[11]],> Z4Z12[[25]]}>> Coset4 = {Z4Z12[[4]], Z4Z12[[30]], Z4Z12[[8]], Z4Z12[[34]], Z4Z12[[12]],> Z4Z12[[26]]}>> Coset5 = {Z4Z12[[37]], Z4Z12[[15]], Z4Z12[[41]], Z4Z12[[19]], Z4Z12[[45]],> Z4Z12[[23]]}>> Coset6 = {Z4Z12[[38]], Z4Z12[[16]], Z4Z12[[42]], Z4Z12[[20]], Z4Z12[[46]],> Z4Z12[[24]]}>> Coset7 = {Z4Z12[[39]], Z4Z12[[17]], Z4Z12[[43]], Z4Z12[[21]], Z4Z12[[47]],> Z4Z12[[13]]}>> Coset8 = {Z4Z12[[40]], Z4Z12[[18]], Z4Z12[[44]], Z4Z12[[22]], Z4Z12[[48]],> Z4Z12[[14]]}>> I was not able to gure a way to create a multiplication table with these> eight elements, because of the multiple part modulo addition.>> There must be a way to multiply <(2,2)> by different elements of the> external direct product, and a way to compute the multiplication table of> the factor groups. Can someone help?> Diana>> ==== ==================================================> God made the integers, all else is the work of man.> L. Kronecker, Jahresber. DMV 2, S. 19.> ==== =Andrzej,I used the wrong equation for multiplication.MultiplicationTable[cosetReps, multF] // TableFormalso gives a table entirely of zeros.Diana> Math friends,>> I am trying to create a multiplication table for the factor groups,>> (Z_4 (+) Z_12)/<(2,2)> I understand how to list the elements of (Z_4 (+) Z_12). This is donewith:>> Z4Z12 = Flatten[Outer[List, Range[0, 3], Range[0, 11]], 1]>> I would like to be able to gure out how to list the eight factor groups> with a calculation with (2,2). This would be in modulo 4,12 arithmetic.>> As a workaround, I dened (Z_4 (+) Z_12)/<(2,2)> as the eight cosets> dened below:>> multZ4Z12[{a_, b_}, {c_, d_}] := {Mod[a + c, 4], Mod[b + d, 12]}>> Multiplication[Z4Z12, multZ4Z12] // TableForm;>> Coset1 = {Z4Z12[[1]], Z4Z12[[27]], Z4Z12[[5]], Z4Z12[[31]], Z4Z12[[9]],> Z4Z12[[35]]}>> Coset2 = {Z4Z12[[2]], Z4Z12[[28]], Z4Z12[[6]], Z4Z12[[32]], Z4Z12[[10]],> Z4Z12[[36]]}>> Coset3 = {Z4Z12[[3]], Z4Z12[[29]], Z4Z12[[7]], Z4Z12[[33]], Z4Z12[[11]],> Z4Z12[[25]]}>> Coset4 = {Z4Z12[[4]], Z4Z12[[30]], Z4Z12[[8]], Z4Z12[[34]], Z4Z12[[12]],> Z4Z12[[26]]}>> Coset5 = {Z4Z12[[37]], Z4Z12[[15]], Z4Z12[[41]], Z4Z12[[19]], Z4Z12[[45]],> Z4Z12[[23]]}>> Coset6 = {Z4Z12[[38]], Z4Z12[[16]], Z4Z12[[42]], Z4Z12[[20]], Z4Z12[[46]],> Z4Z12[[24]]}>> Coset7 = {Z4Z12[[39]], Z4Z12[[17]], Z4Z12[[43]], Z4Z12[[21]], Z4Z12[[47]],> Z4Z12[[13]]}>> Coset8 = {Z4Z12[[40]], Z4Z12[[18]], Z4Z12[[44]], Z4Z12[[22]], Z4Z12[[48]],> Z4Z12[[14]]}>> I was not able to gure a way to create a multiplication table with these> eight elements, because of the multiple part modulo addition.>> There must be a way to multiply <(2,2)> by different elements of the> external direct product, and a way to compute the multiplication table of> the factor groups. Can someone help?> Diana>> ==== ==================================================> God made the integers, all else is the work of man.> L. Kronecker, Jahresber. DMV 2, S. 19.> ==== =Andrzej,I am not sure that I am getting the desired nal multiplication tableoutput.The output I get for the multiplication table:MultiplicationTable[cosetReps, multZ4Z12] // TableFormhas zeros in it. (Perhaps I have not used the right equation to calculatethe multiplication table.) I am not sure that the code is understanding thatthe result might not be an exact match of the original coset, but might havebits and pieces of the original coset.For example, manually multiplying (element for element) the cosetrepresented by (3,0) and (3,2) gives:{(2,2), (2,6), (2,10), (2,2), (2,6), (2,10)}, when the actual cosetrepresented by the identity is:{{0, 0}, {2, 2}, {0, 4}, {2, 6}, {0, 8}, {2, 10}}I have listed the representative element, such as {0, 0}, rst.I greatly appreciate you help with this. The concept of being able to dothis with Mathematica is very exciting.Diana M. ==== =I think the best way is to use cost representatives rather than cosets to construct your table.First dene Z4Z12 in your way:In[2]:=Z4Z12 = Flatten[Outer[List, Range[0, 3], Range[0, 11]], 1]Out[2]={{0, 0}, {0, 1}, {0, 2}, {0, 3}, {0, 4}, {0, 5}, {0, 6}, {0, 7}, {0, 8}, {0, 9}, {0, 10}, {0, 11}, {1, 0}, {1, 1}, {1, 2}, {1, 3}, {1, 4}, {1, 5}, {1, 6}, {1, 7}, {1, 8}, {1, 9}, {1, 10}, {1, 11}, {2, 0}, {2, 1}, {2, 2}, {2, 3}, {2, 4}, {2, 5}, {2, 6}, {2, 7}, {2, 8}, {2, 9}, {2, 10}, {2, 11}, {3, 0}, {3, 1}, {3, 2}, {3, 3}, {3, 4}, {3, 5}, {3, 6}, {3, 7}, {3, 8}, {3, 9}, {3, 10}, {3, 11}}In[3]:=multZ4Z12[{a_, b_}, {c_, d_}] := {Mod[a + c, 4], Mod[b + d, 12]}Next we cpnstruct the subroup generated by {2,2} (your Coset1):In[4]:=H = NestWhileList[multZ4Z12[#1, {2, 2}] & , {2, 2}, #1 != {0, 0} & ]Out[4]={{2, 2}, {0, 4}, {2, 6}, {0, 8}, {2, 10}, {0, 0}}Now we can use Union with a suitable SameTest function to obtian a set of coste representatives:In[7]:=cosetReps = Union[Z4Z12, SameTest -> (MemberQ[H, multZ4Z12[#1, -#2]] & )]Out[7]={{0, 0}, {0, 1}, {0, 2}, {0, 3}, {1, 0}, {1, 1}, {1, 2}, {1, 3}}We only need to generate a multiplication table for the coset representatives, so we deea new multiplication:In[8]:=multF[{a_, b_}, {c_, d_}] := Select[cosetReps, MemberQ[H, multZ4Z12[{a, b}, {c, d}] - #1] & ]You cna check that it wrks the right way. Now it is easy to generate the multiplication table.Not e that I have paid no attention to efciency here. This method works nicely for examples of your size. For much larger ones it would be necessary to carefully consider the question of efciency and the code would almost certainly become less compact.Andrzej KozlowskiYokohama, Japan> Math friends,>> I am trying to create a multiplication table for the factor groups,>> (Z_4 (+) Z_12)/<(2,2)> I understand how to list the elements of (Z_4 (+) Z_12). This is done > with:>> Z4Z12 = Flatten[Outer[List, Range[0, 3], Range[0, 11]], 1]>> I would like to be able to gure out how to list the eight factor > groups> with a calculation with (2,2). This would be in modulo 4,12 arithmetic.>> As a workaround, I dened (Z_4 (+) Z_12)/<(2,2)> as the eight cosets> dened below:>> multZ4Z12[{a_, b_}, {c_, d_}] := {Mod[a + c, 4], Mod[b + d, 12]}>> Multiplication[Z4Z12, multZ4Z12] // TableForm;>> Coset1 = {Z4Z12[[1]], Z4Z12[[27]], Z4Z12[[5]], Z4Z12[[31]], Z4Z12[[9]],> Z4Z12[[35]]}>> Coset2 = {Z4Z12[[2]], Z4Z12[[28]], Z4Z12[[6]], Z4Z12[[32]], > Z4Z12[[10]],> Z4Z12[[36]]}>> Coset3 = {Z4Z12[[3]], Z4Z12[[29]], Z4Z12[[7]], Z4Z12[[33]], > Z4Z12[[11]],> Z4Z12[[25]]}>> Coset4 = {Z4Z12[[4]], Z4Z12[[30]], Z4Z12[[8]], Z4Z12[[34]], > Z4Z12[[12]],> Z4Z12[[26]]}>> Coset5 = {Z4Z12[[37]], Z4Z12[[15]], Z4Z12[[41]], Z4Z12[[19]], > Z4Z12[[45]],> Z4Z12[[23]]}>> Coset6 = {Z4Z12[[38]], Z4Z12[[16]], Z4Z12[[42]], Z4Z12[[20]], > Z4Z12[[46]],> Z4Z12[[24]]}>> Coset7 = {Z4Z12[[39]], Z4Z12[[17]], Z4Z12[[43]], Z4Z12[[21]], > Z4Z12[[47]],> Z4Z12[[13]]}>> Coset8 = {Z4Z12[[40]], Z4Z12[[18]], Z4Z12[[44]], Z4Z12[[22]], > Z4Z12[[48]],> Z4Z12[[14]]}>> I was not able to gure a way to create a multiplication table with > these> eight elements, because of the multiple part modulo addition.>> There must be a way to multiply <(2,2)> by different elements of the> external direct product, and a way to compute the multiplication table > of> the factor groups. Can someone help?> Diana>> ==== ==================================================> God made the integers, all else is the work of man.> L. Kronecker, Jahresber. DMV 2, S. 19.> ==== =In Mathematica when you have a pure function with n-arguments you denote them by #1, #2, etc. But when your function has only one argument you can't use #2. So your denition of H01 below produces an error on my machine.One way to do what you want is simply:cosets = Function[z, (multZ4Z12[z, #1] & ) /@ H] /@ cosetReps{{{2, 2}, {0, 4}, {2, 6}, {0, 8}, {2, 10}, {0, 0}}, {{2, 3}, {0, 5}, {2, 7}, {0, 9}, {2, 11}, {0, 1}}, {{2, 4}, {0, 6}, {2, 8}, {0, 10}, {2, 0}, {0, 2}}, {{2, 5}, {0, 7}, {2, 9}, {0, 11}, {2, 1}, {0, 3}}, {{3, 2}, {1, 4}, {3, 6}, {1, 8}, {3, 10}, {1, 0}}, {{3, 3}, {1, 5}, {3, 7}, {1, 9}, {3, 11}, {1, 1}}, {{3, 4}, {1, 6}, {3, 8}, {1, 10}, {3, 0}, {1, 2}}, {{3, 5}, {1, 7}, {3, 9}, {1, 11}, {3, 1}, {1, 3}}}You can now extract individual cosets with cosets[[i]], for example the group H is:cosets[[1]]{{2, 2}, {0, 4}, {2, 6}, {0, 8}, {2, 10}, {0, 0}}Andrzej KozlowskiYokohama, Japanhttp://www.mimuw.edu.pl/~akoz/http:// platon.c.u-tokyo.ac.jp/andrzej/> Andrzej,>> One further question:>> I was able to replicate all of your work, thanks. I see how to get H,>> H = NestWhileList[multZ4Z12[#1, {2, 2}] &, {2, 2}, #1 != {0, 0} &]>> I also sort of understand the coset representative calculation,>> cosetReps = Union[Z4Z12, SameTest -> (MemberQ[H, multZ4Z12[#1, -#2]] > &)]>> I have tried to derive the different coset groups by altering the > expression> for H above, for example,>> H01 = NestWhileList[multZ4Z12[#2, {2, 2}] &, {0, 1}, #2 != {0, 1} &]>> to get the coset group with representative {0, 1}, but no matter how I > change> the variables in the expression, I get H back.> On Wed, 11 Dec 2002 23:14:08 +0900 Andrzej Kozlowski > > made some silly mistake.>> Here is the correct code, I hope.>> First load the Combinatorica package:>> In[1]:=>> (MemberQ[H, multZ4Z12[#1, -#2]] &>> )]>> Out[5]=>> {{0, 0}, {0, 1}, {0, 2}, {0, 3}, {1, 0}, {1,>> 1}, {1, 2}, {1, 3}}>> Now (this is different from the previous>> version), the multiplication>> of the coset representatives:>> In[6]:=>> multF[{a_, b_}, {c_, d_}] :=>> First[Select[cosetReps,>> MemberQ[H, multZ4Z12[multZ4Z12[{a, b}, {c,>> d}], -#1]] & ]]>> And here is the multiplication table:>> In[7]:=>> TableForm[MultiplicationTable[cosetReps,>> multF]]>> Out[7]//TableForm=>> TableForm[{{1, 2, 3, 4, 5, 6, 7, 8}, {2, 3, 4,>> 1, 6, 7, 8, 5},>> {3, 4, 1, 2, 7, 8, 5, 6}, {4, 1, 2, 3, 8,>> 5, 6, 7}, {5, 6, 7, 8, 3,>> 4, 1, 2},>> {6, 7, 8, 5, 4, 1, 2, 3}, {7, 8, 5, 6, 1,>> 2, 3, 4}, {8, 5, 6, 7, 2,>> 3, 4, 1}}]>> I hope this is now O.K.>> Andrzej>>> ==== ==================================================> God made the integers, all else is the work of man.> L. Kronecker, Jahresber. DMV 2, S. 19.>> ==== =consider the following:In[1]:= test[1, 1] = a; test[1, 3] = b;In[2]:= ?testGlobal`testtest[1, 1] = a test[1, 3] = bIn[3]:= from := 1; to := 3; test[ 1, #1 ] & /@ Range[ from, to ]Out[5]= {a, test[1, 2], b}Of course the test[ 1, 2 ] is not evaluated; it does not exist. If I wantto delete the existing ones I could use:In[9]:= deletableValue := 1; ( HoldForm[ test[ deletableValue, #1 ] =. & ] /@ Range[ from, to ] ) // ReleaseHoldUnset::norep: Assignment on test for test[1, 2] not found.Out[10]= {Null, $Failed, Null}Which makes sense. In[14]:= ?test Global`testNo test in the global context. My question now: is there a mechanisme.g. something like test[ 1, All ] that does only access the existingtest?I am aware of the possibility to use a conditional (If, Case, ..) andDownValues to avoid the error message, but is there a more direct(faster?) way?OliverOliver Ruebenkoenig, ==== => I have the following in mathematica :> x[z_]:=1000Log[10]-ProductLog[z]>> I would like to be able to execute this from a shell or C code. CForm> just outputs :> CForm[1000Log[10] - ProductLog[z]]> 1000*Log(10) - ProductLog(z)>> Is it possible to compile ÔProductLog' to a C library or even an> executable which I can then use in C code ?>>You can use Mathlink to write a C program which calls the Mathematica kernel and returns the result. If you are using UNIX you can then write a script which calls the Mathlink program with the appropriate arguments to start the kernel, I have some example code for this if you want. I'm not sure how this works on Windows or Mac OS 9.Sseziwa ==== =>-----Original Message----->Sent: Thursday, December 12, 2002 7:37 AM>To: mathgroup@smc.vnet.net>>I'm new to Mathematica, and I have a question to which I've found no>answers in the archives. Can you help?>>The issue is: how do I create a pure recursive function? Normally when>creating a recursive function I use the name of the function to perform>the recursive call:>>fact[n_] :=> If[n == 1, 1, n fact[n - 1]]>>However this has the disadvantage that the symbol fact is now global.>The logical step to make the name of the function local is something>like:>>Function[factl, factl[5]] @@ {Function[n, If[n == 0, 1, n factl[n ->1]]]}>>or maybe:>>With[{fact = Function[n, If[n == 0, 1, n fact[n - 1]]]}, fact[5]]>>However both of these solutions steadfastly return the value 5>fact[4]. I assume the problem is that the variables initialised in>Function[] and With[] must be symbols, and cannot be patterns. But a>recursion requires a pattern (n_ in the rst, global, solution above).>What do I do to get factorial to work _without_ making the >symbol fact>global?>>I'd be grateful for any help.>>Niall.>Well, Niall, the logical step, to make a denition local, I think, is this:In[5]:= Module[{fact}, fact = Function[n, If[n == 0, 1, n fact[n - 1]]]; fact[5]]Out[5]= 120In[6]:= ?factGlobal`factThe way to do that with a pure function, however is...In[7]:= If[#1 <= 1, 1, #1*#0[#1 - 1]] &[5]Out[7]= 120...and this certainly is somewhere in the archive, not easy to nd though.If you get the idea to pass around a locally dened name, do e.g.In[8]:= Module[{fact = If[#1 == 0, 1, #1 #2[#1 - 1, #2]] &}, fact[5, fact]]Out[8]= 120But...In[10]:= Module[{fact = Function[n, If[n == 0, 1, n fact[n - 1]]]}, fact[5]]Out[10]= 5 fact[4]...fails because the name fact inserted at the rhs of the denition oßocal fact (which in reality is fact$nnn, nnn being some number) is thename of the global symbol fact, as you may read off the result returned;With a fortiory.It works, however, for Block, due to dynamic (delayed) binding:In[18]:= Block[{fact = Function[n, If[n == 0, 1, n fact[n - 1]]]}, fact[5]]Out[18]= 120Your idea...In[24]:=Function[factl, factl[5]][Function[n, If[n == 0, 1, n factl[n - 1]]]]Out[24]= 5 factl[4]...doesn't work as fact1 in the Function of the argument cannot refer theformal parameter of the function at left (see semantics of lambda calculus);or technically speaking: after the value of fact1 at left (the argument) isinserted (copied) it is forgotten and such the remaining fact1 inside theargument has no value (as seen from the result, or a Trace if you like).--Hartmut Wolf ==== =>> I'm new to Mathematica, and I have a question to which I've found no> answers in the archives. Can you help?>> The issue is: how do I create a pure recursive function? Normally when> creating a recursive function I use the name of the function to perform> the recursive call:>> fact[n_] :=> If[n == 1, 1, n fact[n - 1]]>> However this has the disadvantage that the symbol fact is now global.> The logical step to make the name of the function local is something> like:>> Function[factl, factl[5]] @@ {Function[n, If[n == 0, 1, n factl[n -> 1]]]}>> or maybe:>> With[{fact = Function[n, If[n == 0, 1, n fact[n - 1]]]}, fact[5]]>> However both of these solutions steadfastly return the value 5> fact[4]. I assume the problem is that the variables initialised in> Function[] and With[] must be symbols, and cannot be patterns. But a> recursion requires a pattern (n_ in the rst, global, solution above).> What do I do to get factorial to work _without_ making the symbol > fact> global?>> I'd be grateful for any help.>#0 is the function itself when the & notation is used. Unfortunately it appears you cannot write recursive lambda functions without using & SoIf[# == 1, 1, # #0[# - 1]] &is a recursive factorial function.Sseziwa ==== =Just one more thing. Your original idea works if you use Block instead of With:In[61]:=Block[{fact = Function[n, If[n == 0, 1, n fact[n - 1]]]}, fact[5]]Out[61]=120Andrzej KozlowskiYokohama, Japanhttp://www.mimuw.edu.pl/~akoz/http:// platon.c.u-tokyo.ac.jp/andrzej/> Well, the only thing that comes to my mind is to use replace # by Slot:>> Function[If[Slot[1] == 0, 1, Slot[1] Slot[0][Slot[1] - 1]]]>> Is that any better?> Andrzej>>> Andrzej Kozlowski schrieb:>>> Function[If[#1 == 0, 1, #1 #0[#1 - 1]]]>> soon>> as you answer it, I notice that I asked the wrong question. What I >> still>> would like to know is whether I can specify local names for these>> arguments (using With[] or somesuch), since I'm creating a worksheet >> for>> students, and the # arguments are a little hard to read. Any ideas?>> Best wishes,>> Niall.> Andrzej Kozlowski> Yokohama, Japan> http://www.mimuw.edu.pl/~akoz/> http://platon.c.u-tokyo.ac.jp/andrzej/>> ==== =Gianluca ,First, symbol names declared in a module, like Ôh' below, are silently renamed to avoid conßict with the parent scope. Second, a pattern identier for a function dened in a module is not considered to be the same as a declared symbol of the same name.Very loosely, Mathematica interprets> Module[{num, x, den, h},> num = x^2;> den = 1 + x^2;> h[x_] = num/den;> h'[1]]asModule[{}, num$ = x$^2; den$ = 1 + x$^2; h[x_] = num$/den$; h'[1]]so that the pattern symbol x in the denition of h does not actually occur in the right hand side, since x$ occurs there instead.The solution is not to use so called free variables, but to bind symbols more tightly to there expressions, like in the following exampleModule[{h}, h[x_] = With[{num = x^2, den = 1+x^2}, num/den]; h'[1]]Of course, for this simple example you probably would rather just writeFunction[x, x^2/(1+x^2)]'[1]and avoid the module altogether.Alex>> of scoping is so poor.>> My rule-of-thumb for making Module[] was to start off without> local variables, for example:>> Module[{},> num = x^2;> den = 1 + x^2;> h[x_] = num/den;> h'[1]]>> so that I can debug easily. When I nally get it to work> I add the list of the local variables:>> Module[{num, x, den, h},> num = x^2;> den = 1 + x^2;> h[x_] = num/den;> h'[1]]>> But now it is broken!>> I wish to be enlightened on this issue: How can I safely> write a function denition inside a Module?>> Gianluca Gorni>> To: mathgroup@smc.vnet.net>> To: gorni@dimi.uniud.it>>> I am confused by this result:>> In: Module[{a}, a = x; g[x_] = a]; g[y]>> Out: x>> Somehow I would expect the same output as>> In: Module[{}, a = x; g[x_] = a]; g[y]>> Out: y>> In the rst case ?g gives g[x$_] = x,> while in the second it gives g[x_] = x.> The difference is a dollar sign.>> Can anyone explain why the dollar is inserted in one case> but not in the other? The x was not a local variable> in either case.>> Since the names of named patterns in rules and denitions>> are treated as local variables, the x in the denition of>> g[x_] is a local variable in these examples (section 2.6.4>> in The Mathematica Book). Module[{a}, a = x; g[x_] = a]>> therefore contains nested scoping constructs, so the local>> symbol x in g[x_] = a is renamed to prevent a potential>> conßict with the variable a from the enclosing Module.>> In Module[{}, a = x; g[x_] = a], where there are no conßicting>> variables from the nested scoping constructs, the denition of>> g is evaluated as if the Module was not present. Since this>> denition is an immediate assignment, the right side of the>> assignment is not held unevaluated, and will be affected by>> denitions (such as the now global denition of a) that are>> present when the assignment is evaluated.>> If you use a delayed assignment for the denition of g>> then both inputs will show the same result:>> In[1]:= Module[{a},a=x;g[x_]:=a];g[y]>> Out[1]= x>> In[2]:= Module[{},a=x;g[x_]:=a];g[y]>> Out[2]= x>> The only fundamentally troublesome issue here is that immediate>> assignments are treated as scoping constructs even though they>> do not hold their arguments unevaluated.>> ==== =>-----Original Message----->Sent: Thursday, December 12, 2002 7:38 AM>To: mathgroup@smc.vnet.net> How can I get Mathematica 4.2 to do simple multipliction thru>PlusMinus operators?>For example, suppose I have a 3-dimensional vector with component>tolerances specied:>> In[4]:= va = {{4.10 ± 0.057}, {-3.16 ± 0.796}, {5.09 ± .250}}> Out[4]:=>{{4.1[PlusMinus]0.057},{-3.16[PlusMinus]0.796},{5.09 [PlusMin>us]0.25}}>> In[5]:= FullForm[va]> Out[5]://FullForm=>>List[List[PlusMinus[4.1`,0.057`]],List[ PlusMinus[-3.16`,0.796`]],>>List[PlusMinus[5.09`,0.25`]]]>> In[6]:= 5.2*va> Out[6]:= {{5.2 (4.1[PlusMinus]0.057)},{5.2>(-3.16[PlusMinus]0.796)},{5.2 (5.09> [PlusMinus]0.25)}}>>However, what I want is (for the rst component of the vector, va) is> 5.2*4.1 ± (5.2*0.057)>or, equivalently> 21.32 ± 0.2964>>Is there a standard package to do this? I wasn't able to nd anything>of help in>Section 1.10 or 3.10 of the Wolfram Reference. How does one assign>meaning to the>PlusMinus operator to do simple arithmetic calculations as shown above?>>Many thanks to all who may respond!>....Terry H>Terry,I'd recommend to use interval arithmetic as built in Mathematica: In[1]:= va = {{4.10 ± 0.057}, {-3.16 ± 0.796}, {5.09 ± .250}};In[2]:= 5.2*vaOut[2]= {{5.2 (4.1 ± 0.057)}, {5.2 (-3.16 ± 0.796)}, {5.2 (5.09 ± 0.25)}}Now dene:PlusMinus[a_, b_?Negative] := PlusMinus[a, -b]PlusMinus[a_, b_] := Interval[{a - b, a + b}]Unprotect[Interval]Interval /: MakeBoxes[Interval[{a_, b_}], StandardForm] := With[{c = (a + b)/2, d = Abs[a - b]/2}, MakeBoxes[PlusMinus[c, d]]]Protect[Interval]SuchIn[8]:= vaOut[8]= {{4.1 ± 0.057}, {-3.16 ± 0.796}, {5.09 ± 0.25}}In[9]:= 5.2*vaOut[9]= {{21.32 ± 0.2964}, {-16.432 ± 4.1392}, {26.468 ± 1.3}}In[10]:= -5.2*vaOut[10]= {{-21.32 ± 0.2964}, {16.432 ± 4.1392}, {-26.468 ± 1.3}}In[11]:= (va - 4.1)^2Out[11]= {{0.0016245 ± 0.0016245}, {53.3412 ± 11.5579}, {1.0426 ± 0.495}}In[13]:= Sin[va]Out[13]={{-0.816948 ± 0.0327472}, {0.0128765 ± 0.714442}, {-0.900651 ± 0.0912181}}In[14]:= Exp[va]Out[14]= {{60.4383 ± 3.44126}, {0.0565914 ± 0.0374519}, {167.491 ± 41.0217}}However, Interval in Mathematica has a broader meaning, and you have deneyour output if it contains disconnected pieces!--Hartmut Wolf ==== => ellipse = (x - c)^2/b^2 + (y - d)^2/a^2 == 1;> circ = x^2 + y^2 == 1;> sol = Solve[{ellipse, circ}, {x, y}];> The output comes out immediately as a rather long expression...Everything works just ne for me:4.2 for Mac OS X (June 4, 2002)example1={a->1.2,b->1.3,c->.2,d->.3};example2={a->1.2,b- >1.3,c->1.2,d->1.3};sol1=sol/.example1sol2=sol/.example2pts1= {x,y}/.Select[sol1,FreeQ[#,_Complex]&];pts2={x,y}/.Select[ sol2,FreeQ[#,_Complex]&];<= amount, balance -= amount; balance, Print[ Insufcient Funds ] ] ] ] ]In[2]:= withdraw [ 60 ]Out[2]= 40In[2]:= withdraw[ 60 ]Insufcient FundsThe question now is, can I in Mathematica write a function that takes asargument the balance, so that I do not have to use the xed balance =100. Note that in rst example balance is _not_ present in the globalcontext. My idea was the following:secondWithdraw[ initBalance_ ] := Evaluate[ Module[ { balance = initBalance }, Function[ amount, If[ balance >= amount, balance -= amount; balance, Print[ Insufcient Funds ] ] ] ] ]In[7]:= W1:=secondWithdraw[ 100 ]In[8]:= W1[ 60 ] Out[8]= If[initBalance >= 60, balance$2 -= 60; balance$2, > Print[Insufcient Funds]]So this however does not work. I _assume_ that Evaluate hits to early.The evaluation of balance >= amount to initBalance >= amount is tooearly. Is this the problem? How can I circumvent it?I'd be glad for any insights you might have.Oliver Ruebenkoenig, ==== =It seems to me that the answer is simplyBinomial[m-1,k-1]Carl WollPhysics DeptU of Washington>> I was wondering if there was a simple expression (as a function of m andk )> to compute> the total number of solutions to the integer programming problem:>> n_1 + n_2 + n_3 + ... + n_k = m>> where m > k, each ni >= 1.>> Basically, I am trying to gure out the number of ways of partitioning> a set with m unique elements into k non-empty disjoint subsets.>> For example, if k = 2, then the number of solutions to>> n_1 + n_2 = m is (m-1) = M_2(m) (say)>> if k = 3, then the number of solutions to>> n_1 + n_2 + n_3 = m is M_3(m) = sum_{i=1}^{m-2} (m-i-1) => sum_{i=1}^{m-2} M_2(m-i)>> I can think of a recursive solutions wherein>> M_2(m) = (m-1) and> M_k(m) = sum_{i=1}^{m-k+1} M_(k-1)(m-i), k > 2>> Kumar>>> ==== =I don't think there is a simple expression in a conventional sense, but you can give a simple formula in terms of a generating power series:f[k_, m_] := SeriesCoefcient[Series[1/(1 - x)^k, {x, 0, m - k}], m - k]Andrzej KozlowskiYokohama, Japanhttp://www.mimuw.edu.pl/~akoz/http:// platon.c.u-tokyo.ac.jp/andrzej/>> I was wondering if there was a simple expression (as a function of m > and k )> to compute> the total number of solutions to the integer programming problem:>> n_1 + n_2 + n_3 + ... + n_k = m>> wh