Subject: Re: Matrix Dot Product You're in luck! Mathematica will do it. Here are two sample 2 x 2 matrices. matA = Array[a, {2, 2}] {{a[1, 1], a[1, 2]}, {a[2, 1], a[2, 2]}} matB = Array[b, {2, 2}] {{b[1, 1], b[1, 2]}, {b[2, 1], b[2, 2]}} Then matrix multiplication is just performed with the 'dot' product. matA.matB {{a[1, 1] b[1, 1] + a[1, 2] b[2, 1], a[1, 1] b[1, 2] + a[1, 2] b[2, 2]}, {a[2, 1] b[1, 1] + a[2, 2] b[2, 1], a[2, 1] b[1, 2] + a[2, 2] b[2, 2]}} Check out Help/List and Matrices/Matrix Operations for more information and examples. David Park djmp@earthlink.net http://home.earthlink.net/~djmp/ Hi I was wondering if someone could please help me with a command for calculating the dot product of two (NxN) matrices. For example, for two (2x2) matrices, A and B, we define the dot product as: A(1,1)*B(1,1) + A(2,1)*B(2,1) + A(1,2)*B(1,2) + A(2,2)*B(2,2) i.e. we multiply corresponding entries of the matrices and sum these values. It is easy to write this in a loop but for large matrices the calculation is rather slow. Is there a Mathematica function that I can call that will allow me to do this faster? Calum === Subject: Re: next Prime method from sci.math post Roger, The range of your f function includes most integers (10000 of the first 10042, for instance): Clear[f] digits = 10000; f[n_] := Floor[n + Log[n]^2/2] z=f/@Range@digits; Length@z Through[{Min,Max}@z] 10000 {1,10042} ...so OF COURSE the range includes most primes. That is, most primes are f[n] for some n. (Using the word most very loosely.) But here's an f function that doesn't miss any at all!!! Clear[f] digits=10000; f[n_]:=n a=Rest@Union@Table[If[PrimeQ@f@n,f[n],0],{n,1,digits}]; b=Prime@Range@Length@a; Complement[b,a] {} All primes fit that pattern, so I'm thinking of naming it the Treat-Bagula prime finder function. What do you think? Bobby > I read a post several days ago that said you could find a prime between > n and n+Log[n]^2. > ( there also seems to be a NextPrime[] function in Mathematica that I > wasn't aware of) > I tried the average of the two and it works very well > such that there are only a few primes that don't fit that pattern: > (* Primes that aren't at the average of n and n+Log[n]^2 *) > Clear[f] > digits=10000 > f[n_]:=Floor[n+Log[n]^2/2] > a=Delete[Union[Table[If[PrimeQ[f[n]]==True,f[n],0],{n,1,digits}]],1]; > b=Table[Prime[n],{n,1,Dimensions[a][[1]]}]; > Complement[b,a] > {5,37,97,421,673,2659,3407,3847,7703} > Respectfully, Roger L. Bagula > tftn@earthlink.net, 11759Waterhill Road, Lakeside,Ca 92040-2905,tel: 619-5610814 : > alternative email: rlbtftn@netscape.net > URL : http://home.earthlink.net/~tftn -- DrBob@bigfoot.com www.eclecticdreams.net === Subject: next Prime method from sci.math post I read a post several days ago that said you could find a prime between n and n+Log[n]^2. ( there also seems to be a NextPrime[] function in Mathematica that I wasn't aware of) I tried the average of the two and it works very well such that there are only a few primes that don't fit that pattern: (* Primes that aren't at the average of n and n+Log[n]^2 *) Clear[f] digits=10000 f[n_]:=Floor[n+Log[n]^2/2] a=Delete[Union[Table[If[PrimeQ[f[n]]==True,f[n],0],{n,1,digits}]],1]; b=Table[Prime[n],{n,1,Dimensions[a][[1]]}]; Complement[b,a] {5,37,97,421,673,2659,3407,3847,7703} Respectfully, Roger L. Bagula tftn@earthlink.net, 11759Waterhill Road, Lakeside,Ca 92040-2905,tel: 619-5610814 : alternative email: rlbtftn@netscape.net URL : http://home.earthlink.net/~tftn === Subject: Re: TraditionalForm of expressions WITHOUT evaluating. First you may use a text cells so evaluation does not take place. If you need this expression within an input cell, just select the required text with the mouse and then press Ctrl-Shift-T (for traditional). Your second question sound more like system dependent. Are you using Linux, Windows or MacOS? yehuda >Hello. >I would like to ask you how to do the following. >I want to input some expressions (in InputForm or StandardForm) and >display them in TraditionalForm but without evaluating them. >For example, if I do: >2+2 == 4 // TraditionalForm >I obtain True in a nice font ;) but not the 2+2 = 4. >The expression I want to do is more complicated, with integrals, but >basicly it is the same, for example: >Integrate[x,{x,2,3}] //TraditionalForm >Returns 5/2, but I want the Integral symbol with the limits and the >dx. >Also, related to this, anybody knowns how to export a graphic, cell, >or Traditionalform expression to a bitmap with the resulution I want >and smoothed? For example, a 1024x768 graph with the lines smoothed, >or an integral with smoothed font in a resolution to be included in a >image. === Subject: Re: TraditionalForm of expressions WITHOUT evaluating. Try using HoldForm. HoldForm[Integrate[x, {x, 2, 3}]] // TraditionalForm David Park djmp@earthlink.net http://home.earthlink.net/~djmp/ Hello. I would like to ask you how to do the following. I want to input some expressions (in InputForm or StandardForm) and display them in TraditionalForm but without evaluating them. For example, if I do: 2+2 == 4 // TraditionalForm I obtain True in a nice font ;) but not the 2+2 = 4. The expression I want to do is more complicated, with integrals, but basicly it is the same, for example: Integrate[x,{x,2,3}] //TraditionalForm Returns 5/2, but I want the Integral symbol with the limits and the dx. Also, related to this, anybody knowns how to export a graphic, cell, or Traditionalform expression to a bitmap with the resulution I want and smoothed? For example, a 1024x768 graph with the lines smoothed, or an integral with smoothed font in a resolution to be included in a image. === Subject: Re: Accumulating error counts? Try this : test::failure=Failure !; f[]:=If[Random[Integer][Equal]0,0,Message[test::failure]] globalCounter=0; Do[ Check[f[],globalCounter++],{5}]; globalCounter > I'd like to turn off certain error messages like > NIntegrate::ncvb: NIntegrate failed to converge > NIntegrate::slwcon: Numerical integration converging too slowly > using Off[], but accumulate a count of the total number of times the > message occurred in a sequence of calculations. How do I get at that > number? > (Better yet, I'd like to know the number of times it could have > occurred, as well as the number of times it did occur.) === Subject: Accumulating error counts? I'd like to turn off certain error messages like NIntegrate::ncvb: NIntegrate failed to converge NIntegrate::slwcon: Numerical integration converging too slowly using Off[], but accumulate a count of the total number of times the message occurred in a sequence of calculations. How do I get at that number? (Better yet, I'd like to know the number of times it could have occurred, as well as the number of times it did occur.) === Subject: Re: Plot and axes Use the Ticks option Plot[f[x],{x,-4,4},Ticks->{Range[-4,4],Automatic}]. If can change the values of the grid lines in a similar fashion yehuda >I would like to get the marks on my x axis to show as '1, 2, 3, 4', just >like the y axis, but by default they show as '2,4' - is there an easy way >to find this in the help files? >coordaxes = >Plot[0, {x, -4, 4}, PlotRange -> {-4, 4}, Frame -> False, >GridLines -> Automatic, AspectRatio -> .9, ImageSize -> 400]; >I did an >Options[Plot] >but could not figure out how to do it from there. >Steven Shippee >slshippee@comcast.net === Subject: Plot and axes I would like to get the marks on my x axis to show as '1, 2, 3, 4', just like the y axis, but by default they show as '2,4' - is there an easy way to find this in the help files? coordaxes = Plot[0, {x, -4, 4}, PlotRange -> {-4, 4}, Frame -> False, GridLines -> Automatic, AspectRatio -> .9, ImageSize -> 400]; I did an Options[Plot] but could not figure out how to do it from there. Steven Shippee slshippee@comcast.net === Subject: Re: Plot and axes > I would like to get the marks on my x axis to show as '1, 2, 3, 4', just > like the y axis, but by default they show as '2,4' - is there an easy way > to find this in the help files? > coordaxes = > Plot[0, {x, -4, 4}, PlotRange -> {-4, 4}, Frame -> False, > GridLines -> Automatic, AspectRatio -> .9, ImageSize -> 400]; > I did an > Options[Plot] > but could not figure out how to do it from there. > Steven Shippee > slshippee@comcast.net See Mathematica-Book 2.9.5 Labeling Two[CapitalEth]Dimensional Graphics Use the Ticks option: Plot[0, {x, -4, 4}, PlotRange -> {-4, 4}, GridLines -> Automatic, AspectRatio -> .9, ImageSize -> 400, Ticks -> (Range[Floor[#1], Floor[#2]] &)]; -- Peter Pein Berlin === Subject: Re: Plot and axes Explicitly specify the PlotRange in both dimensions Plot[0,{x,-4,4},PlotRange->{{-4,4},{-4,4}}, Frame->False,GridLines->Automatic, AspectRatio->1,ImageSize->400]; or manually specify the Gridlines Plot[0,{x,-4,4},PlotRange->{-4,4}, Frame->False, GridLines->{Range[-4,4],Range[-4,4]}, AspectRatio->1,ImageSize->400]; Bob Hanlon === > Subject: Plot and axes > I would like to get the marks on my x axis to show as '1, 2, 3, 4', just > like the y axis, but by default they show as '2,4' - is there an easy way > to find this in the help files? > coordaxes = > Plot[0, {x, -4, 4}, PlotRange -> {-4, 4}, Frame -> False, > GridLines -> Automatic, AspectRatio -> .9, ImageSize -> 400]; > I did an > Options[Plot] > but could not figure out how to do it from there. > Steven Shippee > slshippee@comcast.net === Subject: Re: Plot and axes Steven, Specify the ticks and grids as follows. Plot[0, {x, -4, 4}, PlotRange -> {-4, 4}, Frame -> False, Ticks -> {Range[-4, 4, 1], Range[-4, 4, 1]}, GridLines -> {Range[-4, 4, 1], Range[-4, 4, 1]}, AspectRatio -> .9, ImageSize -> 400]; There are two small problems with that. Why is the AspectRatio 0.9 instead of Automatic or 1. Wouldn't a square grid be preferable in this case, which I guess is just making a piece of graph paper. A second problem is in using Axes instead of a Frame. The grid lines hide the minus signs on the negative y axis, and also the tick labels are in the middle of the graph paper where they can interfer with a plotted graph. If you page through Science magazine, say, it is nearly impossible to find a graph with axes and tick labels in the middle of the graph. A Frame resolves these problems. Plot[0, {x, -4, 4}, PlotRange -> {{-4, 4}, {-4, 4}}1.05, Frame -> True, Axes -> False, FrameTicks -> {Range[-4, 4, 1], Range[-4, 4, 1], None, None}, GridLines -> {Range[-4, 4, 1], Range[-4, 4, 1]}, AspectRatio -> Automatic, ImageSize -> 400]; Also, if you just want to make graph paper, it can be done without the artifice of plotting a zero function. Here I label only every other tick to make the graph paper less cluttered. Show[Graphics[{}], PlotRange -> {{-4, 4}, {-4, 4}}1.05, Frame -> True, Axes -> False, FrameTicks -> {Range[-4, 4, 2], Range[-4, 4, 2], None, None}, GridLines -> {Range[-4, 4, 1], Range[-4, 4, 1]}, AspectRatio -> Automatic, ImageSize -> 400]; David Park djmp@earthlink.net http://home.earthlink.net/~djmp/ -----Original Message----- === Subject: Plot and axes I would like to get the marks on my x axis to show as '1, 2, 3, 4', just like the y axis, but by default they show as '2,4' - is there an easy way to find this in the help files? coordaxes = Plot[0, {x, -4, 4}, PlotRange -> {-4, 4}, Frame -> False, GridLines -> Automatic, AspectRatio -> .9, ImageSize -> 400]; I did an Options[Plot] but could not figure out how to do it from there. Steven Shippee slshippee@comcast.net === Subject: Re: Plot and axes >I would like to get the marks on my x axis to show as '1, 2, 3, >4', just like the y axis, but by default they show as '2,4' - is >there an easy way to find this in the help files? >coordaxes = Plot[0, {x, -4, 4}, PlotRange -> {-4, 4}, Frame -> >False, GridLines -> Automatic, AspectRatio -> .9, ImageSize -> >400]; Does this do what you are looking for? Plot[0, {x, -4, 4}, PlotRange -> {-4, 4}, Frame -> False, GridLines -> Automatic, AspectRatio -> 0.9, ImageSize -> 400, Ticks -> {Range[-4, 4], Automatic}]; -- To reply via email subtract one hundred and four === Subject: execution problem A mysterious problem happens, has anyone experienced this and what is the solution. I have a notebook with cell expressions, when I hit shift-Enter, it doesn't execute, but if I add a space then shift-enter, then it will execute. What is the problem? === Subject: Re: Poles and Complex Factoring Your solution does not check out (x-2-Sqrt[10])(x-2+Sqrt[10])//ExpandAll -6 - 4*x + x^2 (-b + Sqrt[b^2-4*a*c])/(2a) /. {a->1,b->2,c->10} -1 + 3*I Using Factor as previously posted by several posters: Factor[x^2+2x+10,GaussianIntegers->True] ((1 - 3*I) + x)*((1 + 3*I) + x) Or equating terms: Union[(x-a)(x-b) /. Solve[Thread[CoefficientList[#, x]&/@ (x^2 + 2x + 10 == (x-a)(x-b))], {a,b}]] {((1 - 3*I) + x)*((1 + 3*I) + x)} Bob Hanlon === > Subject: Poles and Complex Factoring >I know how to calculate the residue of a fuction using Mathematica, but how > can I >use Mathematica to calculate the order of a complex pole? >It would also be nice for Mathematica to tell me if a particular singularity > is an >essential singularity, removable singularity or a pole...but this is > not >necessary; just icing on the cake. >Also, is there a way to factor polynomials with imaginary roots? >Something like: > Factor[ x^2 + 2x + 10 ] = (x - 1 + 4.5 I)(x - 1 - 4.5 I) >Peter >-- >Birthdays are good for you: A federal funded project has recently > determined >that people with the most number of birthdays will live the > longest..... >-=><=-+-+-=><=-+-+-=><=-+-+-=><=-+-+-=><=-+-+- =><=-+-+-=><=-+-+-=><=-+-+-=><=- > I BOYCOTT ANY COMPANY THAT USES MASS ADVERTISING ON THE INTERNET > Let x^2 + 2x + 10 = (x-a)(x-b) > Obviously, a and b are the roots of the equation x^2 + 2x + 10 = 0 > ------ (*) > By quadratic forumula, we can find that the roots of (*)=2+sqrt(10) or > 2-sqrt(10) > Therefore, > x^2 + 2x + 10 = {x-[2+sqrt(10)]}{x-[2-sqrt(10)]} > ie. x^2 + 2x + 10 = [x-2-sqrt(10)][x-2+sqrt(10)] > Factorization of other polynomials with imaginary roots can be done in > the same way. === Subject: Re: Plot and axes You can always define how the marks along the axes should appear in your graph. Use Ticks: In[1]:= coordaxes = Plot[0, {x, -4, 4}, PlotRange -> {-4, 4}, Frame -> False, Ticks->{Range[-4,4],Range[-4,4]}, GridLines -> Automatic, AspectRatio -> .9, ImageSize -> 400]; Tomas Garza Mexico City Original Message: ----------------- === Subject: Plot and axes I would like to get the marks on my x axis to show as '1, 2, 3, 4', just like the y axis, but by default they show as '2,4' - is there an easy way to find this in the help files? coordaxes = Plot[0, {x, -4, 4}, PlotRange -> {-4, 4}, Frame -> False, GridLines -> Automatic, AspectRatio -> .9, ImageSize -> 400]; I did an Options[Plot] but could not figure out how to do it from there. Steven Shippee slshippee@comcast.net -------------------------------------------------------------------- mail2web - Check your email from the web at http://mail2web.com/ . === Subject: Clearing local variables and Memory Leaks I had some long computations that used more and more memory. The advice from someone at WRI responding to a similar problem in an old newsgroup post was to clear local variables in Modules before leaving them. I added a Clear statement to each Module, just before my Return, where I clear every local variable except the one I am returning. Sure enough, this solved my problem. My questions: I am still puzzled as to why it would be dangerous for this behavior to be automatic? That is, once Mathematica has calculated what will be returned, what would go wrong if it cleared every local variable just before returning. If it's *not* dangerous, is there some easy way to force it to happen globally? === Subject: Re: Poles and Complex Factoring Another way: In[1]:= SolveAlways[x^2 + 2*x + 10 == (x + c)*(x + d), x] Out[1]= {{c -> 1 - 3*I, d -> 1 + 3*I}, {c -> 1 + 3*I, d -> 1 - 3*I}} In[2]:= Union[(x + c)*(x + d) /. %] Out[2]= {(x + (1 - 3*I))*(x + (1 + 3*I))} Andrzej Kozlowski > Your solution does not check out > (x-2-Sqrt[10])(x-2+Sqrt[10])//ExpandAll > -6 - 4*x + x^2 > (-b + Sqrt[b^2-4*a*c])/(2a) /. {a->1,b->2,c->10} > -1 + 3*I > Using Factor as previously posted by several posters: > Factor[x^2+2x+10,GaussianIntegers->True] > ((1 - 3*I) + x)*((1 + 3*I) + x) > Or equating terms: > Union[(x-a)(x-b) /. Solve[Thread[CoefficientList[#, x]&/@ > (x^2 + 2x + 10 == (x-a)(x-b))], > {a,b}]] > {((1 - 3*I) + x)*((1 + 3*I) + x)} > Bob Hanlon === >> Subject: Poles and Complex Factoring >>> I know how to calculate the residue of a fuction using Mathematica, >>> but > how >> can I >>> use Mathematica to calculate the order of a complex pole? >>> It would also be nice for Mathematica to tell me if a particular >>> singularity >> is an >>> essential singularity, removable singularity or a pole...but this is >> not >>> necessary; just icing on the cake. >>> Also, is there a way to factor polynomials with imaginary roots? >>> Something like: >>> Factor[ x^2 + 2x + 10 ] = (x - 1 + 4.5 I)(x - 1 - 4.5 I) >>> Peter >>> -- >>> Birthdays are good for you: A federal funded project has recently >> determined >>> that people with the most number of birthdays will live the >> longest..... >>> -=><=-+-+-=><=-+-+-=><=-+-+-=><=-+-+-=><=-+-+- > =><=-+-+-=><=-+-+-=><=-+-+-=><=- >>> I BOYCOTT ANY COMPANY THAT USES MASS ADVERTISING ON THE > INTERNET >> Let x^2 + 2x + 10 = (x-a)(x-b) >> Obviously, a and b are the roots of the equation x^2 + 2x + 10 = 0 >> ------ (*) >> By quadratic forumula, we can find that the roots of (*)=2+sqrt(10) or >> 2-sqrt(10) >> Therefore, >> x^2 + 2x + 10 = {x-[2+sqrt(10)]}{x-[2-sqrt(10)]} >> ie. x^2 + 2x + 10 = [x-2-sqrt(10)][x-2+sqrt(10)] >> Factorization of other polynomials with imaginary roots can be done in >> the same way. === Subject: Re: copy and paste Maybe this will help: http://eclecticdreams.net/DrBob/copy_as_inputform.htm Bobby > This is a very simple question, but I'm finding it difficult to find the > answer, can you please help? I want to copy the text output of some > expressions all at once to notepad, but I get all this other stuff I don't > want to get copied along such as invisible characters, and output #x, etc.. > Can anyone tell me how I can just do a text copy and paste please? By the > way I've tried all the copy As options, and paste as options, nothing works. -- DrBob@bigfoot.com www.eclecticdreams.net === Subject: copy and paste This is a very simple question, but I'm finding it difficult to find the answer, can you please help? I want to copy the text output of some expressions all at once to notepad, but I get all this other stuff I don't want to get copied along such as invisible characters, and output #x, etc.. Can anyone tell me how I can just do a text copy and paste please? By the way I've tried all the copy As options, and paste as options, nothing works. === Subject: Re: Re: copy and paste I didn't write the palette -- it was posted by Omega Consulting many months ago. Bobby >> This is a very simple question, but I'm finding it difficult to find the >> answer, can you please help? I want to copy the text output of some >> expressions all at once to notepad, but I get all this other stuff I don't >> want to get copied along such as invisible characters, and output #x, etc.. >> Can anyone tell me how I can just do a text copy and paste please? By the >> way I've tried all the copy As options, and paste as options, nothing works. > If you want to copy as plain text, use either the menu: Edit->Copy As->Plain > Text or download (, install and use) the Copy as InputForm-Palette written by > DrBob at http://www.eclecticdreams.net/ -- DrBob@bigfoot.com www.eclecticdreams.net === Subject: Re: copy and paste > This is a very simple question, but I'm finding it difficult to find the > answer, can you please help? I want to copy the text output of some > expressions all at once to notepad, but I get all this other stuff I don't > want to get copied along such as invisible characters, and output #x, etc.. > Can anyone tell me how I can just do a text copy and paste please? By the > way I've tried all the copy As options, and paste as options, nothing works. If you want to copy as plain text, use either the menu: Edit->Copy As->Plain Text or download (, install and use) the Copy as InputForm-Palette written by DrBob at http://www.eclecticdreams.net/ === Subject: Re: Re: Counting Runs >> I think Abs, Tr, and BitXor are very fast because they are probably >> optimized for integer input and the use of packed arrays. > I don't think an optimization for integers can be effective if > functions take time to CHECK whether the array contains only integers. > Is that precomputed for packed arrays, somehow? > Bobby Yes, that's precisely what packed arrays do. Actually you can check precisely the effect of packed arrays in this case: << Developer` runs[int_, data_] := Module[{modlist}, modlist = Sign[Abs[data - int]]; Tr[BitXor[modlist, RotateRight[modlist]]]/2 + 1 - BitOr[modlist[[1]], modlist[[-1]]]] runs1[int_, data_] := Tr[BitXor[modlist, RotateRight[modlist]]]/2 + 1 - BitOr[modlist[[1]], modlist[[-1]]]] seq = Table[Random[Integer, 10], {10^6}]; Timing[runs[3, seq]] {0.4299999999999997*Second, 83183} Timing[runs1[3, seq]] {0.9299999999999997*Second, 83183} So just over 50% performance increase. Andrzej Kozlowski Chiba, Japan http://www.akikoz.net/~andrzej/ http://www.mimuw.edu.pl/~akoz/ === Subject: Re: Re: Counting Runs Yes, I remember the problem how to count how many 0's are followed by a 1. Allan Hayes and you had some wonderful ideas how to solve that. With respect to your question, it turns out that using 1-Abs[Sign[data-int]] is slightly faster. But when we use Abs[Sign[data-int] and then count how may 1's are followed by a 0 there is a considerable gain. In[1]:= runs[int_,data_]:= Module[{modlist},modlist=Abs@Quotient[#,#+1,1]&@Abs[data-int]; Tr[BitXor[modlist,RotateRight[modlist]]]/2+BitAnd[modlist[[1]],modlist[[-1]] ]] In[2]:= runs1[int_,data_]:=Module[{modlist},modlist=1-Abs[Sign[data-int]]; Tr[BitXor[modlist,RotateRight[modlist]]]/2+BitAnd[modlist[[1]],modlist[[-1]] ]] In[3]:= runs2[int_,data_] := With[{lst=Abs[Sign[data-int]]}, Total[ BitXor[lst ,RotateLeft[lst]]]/2+ If[lst[[1]][Equal]1, 0,If[lst[[-1]][Equal]0, 1,0]] ] In[4]:= data=Table[Random[Integer,20], {2 10^7}]; In[5]:= n=5;{Do[runs[3, data], {n}]// Timing, Do[runs1[3, data], {n}]// Timing, Do[runs2[3, data], {n}]// Timing} Out[5]= {{7.516 Second,Null},{6.328 Second,Null},{4.109 Second,Null}} Fred Simons Eindhoven University of Technology === Subject: Re: Counting Runs > I think Abs, Tr, and BitXor are very fast because they are probably > optimized for integer input and the use of packed arrays. I don't think an optimization for integers can be effective if functions take time to CHECK whether the array contains only integers. Is that precomputed for packed arrays, somehow? Bobby > Hi Bob, > I think Abs, Tr, and BitXor are very fast because they are probably > optimized for integer input and the use of packed arrays. On the other hand, > I doubt that there are any such optimizations for integers or packed arrays > for the functions Part, Split and Sort. > At any rate, Andrzej Kozlowsky has kindly provided an improvement, so that > the following runs function is almost twice as fast as my previous one. > runs[int_,data_]:=Module[{modlist}, > modlist=Sign[Abs[data-int]]; === > runsof>> 1s there are. There the fastest method ended up using Tr and > BitXor.>>>> This suggests that we can count the number of runs of any particularinteger>> in a sequence of integers if we can convert the sequence to 1s for that>> integer and 0s for everything else. Doing this conversion turned out tobe>> troublesome, but I managed to come up with a method that is pretty fast.If>> the sequence is data, then the following expression will have 1s for the>> integer int and 0s for everything else:>>>> Abs@Quotient[#,#+1,1]&@Abs[data-int]>>>> Now that we have an expression of just 1s and 0s, we can count how manyruns>> of 1s there are. The following function counts the number of runs of intin>> the sequence data:>>>> runs[int_,data_]:=Module[{modlist},>> modlist=Abs@Quotient[#,#+1,1]&@Abs[data-int];>>Tr[BitXor[modlist,RotateRight[ modlist]]]/2+BitAnd[modlist[[1]],modlist[[-1]]]]For a sequence of a million integers, the above runs function can findthenumber of runs of a single integer about 7 to 10 or more times faster (onmymachine) than your han! > a data list. The two are somewhatinverselyrelated, of course.>> The f > >>>v={1,1,1,-1,1,1,1,1,1,-1,-1,-1,-1,1}.>>>>>> I'd like to create a functionthat counts the number of runs of 1s>>>>>> and>>>>>> -1s, which in this caseis 3 and 2.>>>>>>>>>>>>Greg>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> -->>>DrBob@bigfoot.com>>>www.eclecticdreams.net>>>>>>>>>> ------------------------------------------------------------------->> J.87nos L.9abb>> Yale University School of Medicine>>Department of Pathology>> Phone: 203-737-5204>> Fax: 203-785-7303>>E-mail: janos.lobb@yale.edu>>>>>>>>>>>> --> DrBob@bigfoot.com>www.eclecticdreams.net>>>>>>>>>>>>>>>>> --> DrBob@bigfoot.com> www.eclecticdreams.net> -- DrBob@bigfoot.com www.eclecticdreams.net === Subject: Re: Counting Runs Hi Bob, I think Abs, Tr, and BitXor are very fast because they are probably optimized for integer input and the use of packed arrays. On the other hand, I doubt that there are any such optimizations for integers or packed arrays for the functions Part, Split and Sort. At any rate, Andrzej Kozlowsky has kindly provided an improvement, so that the following runs function is almost twice as fast as my previous one. runs[int_,data_]:=Module[{modlist}, modlist=Sign[Abs[data-int]]; === Subject: Re: Re: Counting Runs Highlight any built-in (almost) and press the Help key, and you'll easily find out what it is. I have Needs[Statistics`] in my Init.m file, so I never load or think about stat packages. I recommend you do the same. I do the same with graphics by including Needs[Graphics`]. It saves a lot of time. >> Since this the same as one of your other suggestions, how can using this version of Frequencies be faster? I hadn't noticed they were the same; I assumed Frequencies was compiled and optimized. Looking back on the timings again, I notice brt4 and hanlonTreat are within 4% on the largest arrays, with neither of them always winning. They are the two fastest solvers, and the difference seem to be random noise. All that being so, I would use the version with Frequencies. Bobby >> And the new winner -- for both speed and simplicity -- is: >> brt4[v_List] := Frequencies@Split[v][[All, 1]] > Where is the function Frequencies to be found? > If it is the function found in Statistics`DataManipulation` then that is coded > {Length[#],First[#]}&/@Split[Sort[list]] > Since this the same as one of your other suggestions, how can using this version of Frequencies be faster? > -- > To reply via email subtract one hundred and four -- DrBob@bigfoot.com www.eclecticdreams.net === Subject: Re: Counting Runs >And the new winner -- for both speed and simplicity -- is: >brt4[v_List] := Frequencies@Split[v][[All, 1]] Where is the function Frequencies to be found? If it is the function found in Statistics`DataManipulation` then that is coded {Length[#],First[#]}&/@Split[Sort[list]] Since this the same as one of your other suggestions, how can using this version of Frequencies be faster? -- To reply via email subtract one hundred and four === Subject: Re: Re: Counting Runs Actually, this is not a very good test, since unpacking a large array also takes a non-negligible amount of time. The real effect should be somewhat larger. Andrzej >>> I think Abs, Tr, and BitXor are very fast because they are probably >>> optimized for integer input and the use of packed arrays. >> I don't think an optimization for integers can be effective if >> functions take time to CHECK whether the array contains only >> integers. Is that precomputed for packed arrays, somehow? >> Bobby > Yes, that's precisely what packed arrays do. Actually you can check > precisely the effect of packed arrays in this case: > << Developer` > runs[int_, data_] := Module[{modlist}, > modlist = Sign[Abs[data - int]]; > Tr[BitXor[modlist, RotateRight[modlist]]]/2 + 1 - > BitOr[modlist[[1]], modlist[[-1]]]] > runs1[int_, data_] := > Tr[BitXor[modlist, RotateRight[modlist]]]/2 + 1 - > BitOr[modlist[[1]], modlist[[-1]]]] > seq = Table[Random[Integer, 10], {10^6}]; > Timing[runs[3, seq]] > {0.4299999999999997*Second, 83183} > Timing[runs1[3, seq]] > {0.9299999999999997*Second, 83183} > So just over 50% performance increase. > Andrzej Kozlowski > Chiba, Japan > http://www.akikoz.net/~andrzej/ > http://www.mimuw.edu.pl/~akoz/ === Subject: Re: Re: Counting Runs That seems to prove only that there's an optimization for packed arrays -- not for integer input. Am I missing something? Bobby >>> I think Abs, Tr, and BitXor are very fast because they are probably >>> optimized for integer input and the use of packed arrays. >> I don't think an optimization for integers can be effective if >> functions take time to CHECK whether the array contains only integers. >> Is that precomputed for packed arrays, somehow? >> Bobby > Yes, that's precisely what packed arrays do. Actually you can check > precisely the effect of packed arrays in this case: > << Developer` > runs[int_, data_] := Module[{modlist}, > modlist = Sign[Abs[data - int]]; > Tr[BitXor[modlist, RotateRight[modlist]]]/2 + 1 - > BitOr[modlist[[1]], modlist[[-1]]]] > runs1[int_, data_] := > Tr[BitXor[modlist, RotateRight[modlist]]]/2 + 1 - > BitOr[modlist[[1]], modlist[[-1]]]] > seq = Table[Random[Integer, 10], {10^6}]; > Timing[runs[3, seq]] > {0.4299999999999997*Second, 83183} > Timing[runs1[3, seq]] > {0.9299999999999997*Second, 83183} > So just over 50% performance increase. > Andrzej Kozlowski > Chiba, Japan > http://www.akikoz.net/~andrzej/ > http://www.mimuw.edu.pl/~akoz/ -- DrBob@bigfoot.com www.eclecticdreams.net === Subject: NMinimize options I am using the global optimization method DifferentialEvolution and SimulatedAnnealing of NMinimize. Unfortunately, even the Advanced Documentation is rather scarce and does not explain every option you have to adapt those methods to your problem. Is there more information on these options around or more examples? Specifically I would like to learn more about the options PenaltyFuntion, PostProcess and PerturbationScale. Another question is whether I can specify just a subset of SearchPoints by InitalPoints? best, joerg === Subject: Re: 64 bit cpu and Mathematica on windows. http://www.wolfram.com/news/amd64.html. I presume that this is the Linux (64 bit optimized) version . They have checked compatibility with SUSE Linux Enterprise Server 8 which supports 64 bit technology, hopefully this means that its OK on SUSE's desktop version; see http://www.suse.com/us/private/products/suse_linux/prof/64bit.html. So it looks as though a cheap 64 bit Mathematica is possible. Has anybody done it? Ian Quantica P/L >To see any improvement, I think you'll need a 64-bit version of Windows (not yet released) and a 64-bit version of Mathematica (also not released). >Bobby >>http://www.wolfram.com/news/sgiirix.html >>has info on sgi machines >>will Mathematica run faster on a windows machine with 64 bit cpu? >>like.. this one. >>http://www.emachines.com/products/products.html?prod=eMachines_T3256 >>that's only 600 bucks! >>or dooes wri need to release a new version of Mathematica that is optimized >>for 64bit windows cpu? >> === Subject: Re: 64 bit cpu and Mathematica on windows. Just a little further information. First, there has been a good, stable For once, Intel are playing catchup and just starting to produce 64-bit particular, if you run a 64-bit operating system you can run both 32-bit and 64-bit code. 32-bit applications - such as your regular Mathematica for Windows - can then address more or less the whole 4-Gigabyte address space (rather than a typical 1.5G) because the operating system runs in 64-bit mode even when it is servicing 32-bit applications - so it does not use up any of the 4G theoretical limit. The 64 bit Mathematica should be able to address a vast quantity of memory. Of course, to be able to access all this memory it has to be physically present on your machine. their 64-bit design! David Bailey === Subject: Re: 64 bit cpu and Mathematica on windows. To see any improvement, I think you'll need a 64-bit version of Windows (not yet released) and a 64-bit version of Mathematica (also not released). Bobby > http://www.wolfram.com/news/sgiirix.html > has info on sgi machines > will Mathematica run faster on a windows machine with 64 bit cpu? > like.. this one. > http://www.emachines.com/products/products.html?prod=eMachines_T3256 > that's only 600 bucks! > or dooes wri need to release a new version of Mathematica that is optimized > for 64bit windows cpu? -- DrBob@bigfoot.com www.eclecticdreams.net === Subject: 64 bit cpu and Mathematica on windows. http://www.wolfram.com/news/sgiirix.html has info on sgi machines will Mathematica run faster on a windows machine with 64 bit cpu? like.. this one. http://www.emachines.com/products/products.html?prod=eMachines_T3256 that's only 600 bucks! or dooes wri need to release a new version of Mathematica that is optimized for 64bit windows cpu? === Subject: Help in solving PDF equations Could anybody please help me in solving the following PDF equation? (p + r/rou)*(1- (Derivative[1, 0][f][x, t])^2 - k * Derivative[0, 1][f][x, t])/Sqrt[1 + (Derivative[1, 0][f][x, t])^2] ==0 with initial or boundary conditions as f[x, 0] == -1 Derivative[0, 1][f][x, 0] == p/k Derivative[1, 0][f][R0, t] == 0 f[x, t] == If[0<= x <=1, Sqrt[1 - x^2]] where, p, k, R0 and rou are constants. Wei === Subject: Re: Help in solving PDF equations > Could anybody please help me in solving the following PDF equation? > (p + r/rou)*(1- (Derivative[1, 0][f][x, t])^2 - k * Derivative[0, 1][f][x, > t])/Sqrt[1 + (Derivative[1, 0][f][x, t])^2] ==0 Clearly, the left-hand side of this expression vanishes if its numerator does: de = (1- Derivative[1, 0][f][x, t]^2 - k Derivative[0, 1][f][x, t]) == 0 and Mathematica can solve this partial differential equation in closed form: sol = DSolve[de, f, {x, t}] > with initial or boundary conditions as > f[x, 0] == -1 Applying this initial condition f[x, 0] == -1 /. sol one can find the two undetermined coefficients: coefs = SolveAlways[#,x]& /@ % // Union The solution then reads f[x, t] /. sol /. coefs // Flatten // Union {t/k - 1} which is independent of x. Note that the denominator of the original equation reduces to unity as can be seen by evaluating 1 + Derivative[1, 0][f][x, t]^2 /. sol /. coefs > Derivative[0, 1][f][x, 0] == p/k This condition can only be satisfied if p == 1 as can be seen from Derivative[0, 1][f][x, 0] == p/k /. sol /. coefs > Derivative[1, 0][f][R0, t] == 0 This condition is satisfied since f is independent of x, Derivative[1, 0][f][R0, t] == 0 /. sol /. coefs > f[x, t] == If[0<= x <=1, Sqrt[1 - x^2]] This does not make sense to me. The right-hand side does not depend on t. If you mean this to hold for a fixed t then it is incompatible with the general solution determined above. > where, p, k, R0 and rou are constants. The supplied conditions determine p but k, R0, and rou are not determined. Paul -- Paul Abbott Phone: +61 8 6488 2734 School of Physics, M013 Fax: +61 8 6488 1014 The University of Western Australia (CRICOS Provider No 00126G) 35 Stirling Highway Crawley WA 6009 mailto:paul@physics.uwa.edu.au AUSTRALIA http://physics.uwa.edu.au/~paul === Subject: neat sums and pattered randomness In my fractal nonlinear IFS work I have used the rational pair (n/(n+1),1/(n+1)) to produce several new fractals. I know that it behaves very much in IFS like a nonlinear Cantor set. I made up Log[2] like sums alternating the pairs. The result is two irrational numbers that are summed to one. In the iterations based on these sum functions, I get patterned noise, but they still give a sorted slope of one. The result appears to be a paired noise pattern. (* a pair of sums from rational pairs (n/(1+n),1/(n+1))*) (* 1st=0.5224031171170045693773071024046350601893524864083449381053044765826974 39816155245572731717378300356170892928056816556010739766213388511389508371658 7179298436322129249418632659176904330363338074199274*) (* 2nd=0.4775968828829954306226928975953649398106475135916550618946949011157747 74069674040020862904609275584803890199826470133877598754816728085072147509946 7997575850060913783991812218340970953593189635761664*) (*1st+2nd=1*) f[n_]=If[Mod[n,2]==1,1/((n+1)*2^n),n/((n+1)*2^n)] digits=200 a=Table[N[f[n],digits],{n,1,digits}]; b=N[Apply[Plus,a],digits] Clear[f,a,b] f[n_]=If[Mod[n,2]==1,n/((n+1)*2^n),1/((n+1)*2^n)] a=Table[N[f[n],digits],{n,1,digits}]; b=N[Apply[Plus,a],digits] (* iterations based on these that have patterns in them*) x[n_]:=x[n]=Mod[x[n-1]*2+If[Mod[n,2]==1,1/(n+1),n/(n+1)],1] x[0]=0 Clear[a,b] a=Table[N[x[n],digits],{n,0,digits}]; ListPlot[a,PlotJoined->True,PlotRange->All] b=Sort[Table[N[x[n],digits],{n,0,digits}]]; ListPlot[b,PlotJoined->True,PlotRange->All] Fit[digits*b,{1,x},x] Clear[x] x[n_]:=x[n]=Mod[x[n-1]*2+If[Mod[n,2]==1,n/(n+1),1/(n+1)],1] x[0]=0 Clear[a,b] a=Table[N[x[n],digits],{n,0,digits}]; ListPlot[a,PlotJoined->True,PlotRange->All] b=Sort[Table[N[x[n],digits],{n,0,digits}]]; ListPlot[b,PlotJoined->True,PlotRange->All] Fit[digits*b,{1,x},x] Respectfully, Roger L. Bagula tftn@earthlink.net, 11759Waterhill Road, Lakeside,Ca 92040-2905,tel: 619-5610814 : alternative email: rlbtftn@netscape.net URL : http://home.earthlink.net/~tftn === Subject: Re: neat sums and pattered randomness Both pairs based on the projective line and ( Sqrt[n/(1+n)],Sqrt[1/(1+n]) have the property of giving space filling curves, but the sorted iteration arrays are not very good lines in several cases. The Sqrt[] iteration broke my Mod[,1] output (I got numbers in (x,y) greater than one and diverging) It appears the powers (2,1/2) in the sum function although increasing a kind of randomness, do not make good b-normal candidate sums. It isn't clear why the power functions cause this problem or solution. (* Pair Iteration of projective line type *) (* two sets of constants depend on if 1-n^2 or n^2-1 is used*) (* no apparent pattern develops in the iteration: a space filling curve in 2d*) x[n_]:=x[n]=Mod[x[n-1]*2+If[Mod[n,2]==1,2*n/(n^2+1),(1-n^2)/(n^2+1)],1] y[n_]:=y[n]=Mod[y[n-1]*2+If[Mod[n,2]==1,(1-n^2)/(n^2+1),2*n/(n^2+1)],1] x[0]=0;y[0]=0; a0=Table[{x[n],y[n]},{n,0, 200}]; ListPlot[a0,PlotJoined->True, PlotRange->All] (* positive version*) Clear[x,y,a,b,s,g,a0] x[n_]:=x[n]=Mod[x[n-1]*2+If[Mod[n,2]==1,2*n/(n^2+1),(-1+n^2)/(n^2+1)],1] y[n_]:=y[n]=Mod[y[n-1]*2+If[Mod[n,2]==1,(-1+n^2)/(n^2+1),2*n/(n^2+1)],1] x[0]=0;y[0]=0; a0=Table[{x[n],y[n]},{n,0, 200}]; ListPlot[a0,PlotJoined->True, PlotRange->All] Respectfully, Roger L. Bagula tftn@earthlink.net, 11759Waterhill Road, Lakeside,Ca 92040-2905,tel: 619-5610814 : alternative email: rlbtftn@netscape.net URL : http://home.earthlink.net/~tftn === Subject: Re: neat sums and pattered randomness I thought to use a method I just developed for maps on this pair of iterations: (* Pair Iteration gives a Line :y=-x+1*) x[n_]:=x[n]=Mod[x[n-1]*2+If[Mod[n,2]==1,n/(n+1),1/(n+1)],1] y[n_]:=y[n]=Mod[y[n-1]*2+If[Mod[n,2]==1,1/(n+1),n/(n+1)],1] x[0]=0;y[0]=0; a0=Table[{x[n],y[n]},{n,0, 200}]; ListPlot[a0,PlotJoined->True, PlotRange->All] Plot[-x+1,{x,0,1}] >In my fractal nonlinear IFS work I have used the rational pair >(n/(n+1),1/(n+1)) >to produce several new fractals. >I know that it behaves very much in IFS like a nonlinear Cantor set. >I made up Log[2] like sums alternating the pairs. >The result is two irrational numbers that are summed to one. >In the iterations based on these sum functions, >I get patterned noise, but they still give a sorted slope of one. >The result appears to be a paired noise pattern. >(* a pair of sums from rational pairs (n/(1+n),1/(n+1))*) >(* >1st=0.522403117117004569377307102404635060189352486408344938105304476582697 43981615524557273171737830035617089292805681655601073976621338851138950837165 87179298436322129249418632659176904330363338074199274*) >(* >2nd=0.477596882882995430622692897595364939810647513591655061894694901115774 77406967404002086290460927558480389019982647013387759875481672808507214750994 67997575850060913783991812218340970953593189635761664*) >(*1st+2nd=1*) >f[n_]=If[Mod[n,2]==1,1/((n+1)*2^n),n/((n+1)*2^n)] >digits=200 >a=Table[N[f[n],digits],{n,1,digits}]; >b=N[Apply[Plus,a],digits] >Clear[f,a,b] >f[n_]=If[Mod[n,2]==1,n/((n+1)*2^n),1/((n+1)*2^n)] >a=Table[N[f[n],digits],{n,1,digits}]; >b=N[Apply[Plus,a],digits] >(* iterations based on these that have patterns in them*) >x[n_]:=x[n]=Mod[x[n-1]*2+If[Mod[n,2]==1,1/(n+1),n/(n+1)],1] > x[0]=0 >Clear[a,b] >a=Table[N[x[n],digits],{n,0,digits}]; >ListPlot[a,PlotJoined->True,PlotRange->All] >b=Sort[Table[N[x[n],digits],{n,0,digits}]]; >ListPlot[b,PlotJoined->True,PlotRange->All] >Fit[digits*b,{1,x},x] >Clear[x] >x[n_]:=x[n]=Mod[x[n-1]*2+If[Mod[n,2]==1,n/(n+1),1/(n+1)],1] > x[0]=0 >Clear[a,b] >a=Table[N[x[n],digits],{n,0,digits}]; >ListPlot[a,PlotJoined->True,PlotRange->All] >b=Sort[Table[N[x[n],digits],{n,0,digits}]]; >ListPlot[b,PlotJoined->True,PlotRange->All] >Fit[digits*b,{1,x},x] >Respectfully, Roger L. Bagula >tftn@earthlink.net, 11759Waterhill Road, Lakeside,Ca 92040-2905,tel: 619-5610814 : >alternative email: rlbtftn@netscape.net >URL : http://home.earthlink.net/~tftn -- Respectfully, Roger L. Bagula tftn@earthlink.net, 11759Waterhill Road, Lakeside,Ca 92040-2905,tel: 619-5610814 : alternative email: rlbtftn@netscape.net URL : http://home.earthlink.net/~tftn === Subject: Re: Challenge: Fastest method to convert positive integers to 1 in a long list Try this: In[131]:= max = Max[seq]; Timing[Quotient[seq + max - 1, max]; ] Out[132]= {0.0800000000000125*Second, Null} J.87nos > Hi all, > Inspired by the recent thread on counting runs, I have the following > challenge. Come up with a method to convert all the positive integers > in a > long sequence of nonnegative integers to 1, so that the sequence > consists of > only 0s and 1s. Let the sequence be given by > seq = Table[Random[Integer, 10], {10^6}]; > Then, one technique is > newseq = 1+Quotient[#,#+1,1]&@seq; > Can anyone do better? > Carl Woll ---------------------------------------------- Trying to argue with a politician is like lifting up the head of a corpse. (S. Lem: His Master Voice) === Subject: Re: Challenge: Fastest method to convert positive integers to 1 in a long list > Hi all, > Inspired by the recent thread on counting runs, I have the following > challenge. Come up with a method to convert all the positive integers > in a > long sequence of nonnegative integers to 1, so that the sequence > consists of > only 0s and 1s. Let the sequence be given by > seq = Table[Random[Integer, 10], {10^6}]; > Then, one technique is > newseq = 1+Quotient[#,#+1,1]&@seq; > Can anyone do better? > Carl Woll This one seems a tad faster: (newseq = Mod[#+2,#+1]&@seq;) // Timing {0.16 Second, Null} versus your (newseq = 1 + Quotient[#,#+1,1]&@seq;) // Timing {0.23 Second, Null} ----- Selwyn Hollis http://www.appliedsymbols.com (edit reply-to to reply) === Subject: Re: Challenge: Fastest method to convert positive integers to 1 in a long list > Hi all, > Inspired by the recent thread on counting runs, I have the following > challenge. Come up with a method to convert all the positive integers > in a > long sequence of nonnegative integers to 1, so that the sequence > consists of > only 0s and 1s. Let the sequence be given by > seq = Table[Random[Integer, 10], {10^6}]; > Then, one technique is > newseq = 1+Quotient[#,#+1,1]&@seq; > Can anyone do better? > Carl Woll This seems to be very much faster: newseq = Sign[seq]; Andrzej Kozlowski Chiba, Japan http://www.akikoz.net/~andrzej/ http://www.mimuw.edu.pl/~akoz/ === Subject: Challenge: Fastest method to convert positive integers to 1 in a long list Hi all, Inspired by the recent thread on counting runs, I have the following challenge. Come up with a method to convert all the positive integers in a long sequence of nonnegative integers to 1, so that the sequence consists of only 0s and 1s. Let the sequence be given by seq = Table[Random[Integer, 10], {10^6}]; Then, one technique is newseq = 1+Quotient[#,#+1,1]&@seq; Can anyone do better? Carl Woll === Subject: Re: Challenge: Fastest method to convert positive integers to 1 in a long list >Inspired by the recent thread on counting runs, I have the following >challenge. Come up with a method to convert all the positive integers in a >long sequence of nonnegative integers to 1, so that the sequence consists >of only 0s and 1s. Let the sequence be given by >seq = Table[Random[Integer, 10], {10^6}]; >Then, one technique is >newseq = 1+Quotient[#,#+1,1]&@seq; >Can anyone do better? Can't test it right now, but how about newseq = Sign@seq; ? cheers, Peltio === Subject: Re: Challenge: Fastest method to convert positive integers to 1 in a long list > Hi all, > Inspired by the recent thread on counting runs, I have the following > challenge. Come up with a method to convert all the positive integers in a > long sequence of nonnegative integers to 1, so that the sequence consists of > only 0s and 1s. Let the sequence be given by > seq = Table[Random[Integer, 10], {10^6}]; > Then, one technique is > newseq = 1+Quotient[#,#+1,1]&@seq; > Can anyone do better? > Carl Woll Sign[.] is simpler, isn't it? In[1]:= seq = Table[Random[Integer, 10], {10^6}]; In[2]:= t1 = First@Timing[newseq1 = 1 + Quotient[#, # + 1, 1] &@seq;] Out[2]= 0.671 Second In[3]:= t2 = First@Timing[newseq2 = Sign@seq;] Out[3]= 0.12 Second In[4]:= newseq1 == newseq2 t1/t2 Out[4]= True Out[5]= 5.59167 ..it is :-) -- Peter Pein Berlin === Subject: Re: Challenge: Fastest method to convert positive integers to 1 in a long list > Hi all, > Inspired by the recent thread on counting runs, I have the following > challenge. Come up with a method to convert all the positive integers in a > long sequence of nonnegative integers to 1, so that the sequence consists of > only 0s and 1s. Let the sequence be given by > seq = Table[Random[Integer, 10], {10^6}]; > Then, one technique is > newseq = 1+Quotient[#,#+1,1]&@seq; > Can anyone do better? > Carl Woll newseq = Sign[seq] Maxim Rytin m.r@inbox.ru === Subject: Re: Challenge: Fastest method to convert positive integers to 1 in a long list This is the best I could to: seq = Table[Random[Integer, 10], {10^6}]; newseq = 1+Quotient[#,#+1,1]&@seq;//Timing {0.16 Second,Null} newseq2 =(If[#>0,1,0]&)/@seq;//Timing {0.5 Second,Null} Brian > Hi all, > Inspired by the recent thread on counting runs, I have the following > challenge. Come up with a method to convert all the positive integers in a > long sequence of nonnegative integers to 1, so that the sequence consists of > only 0s and 1s. Let the sequence be given by > seq = Table[Random[Integer, 10], {10^6}]; > Then, one technique is > newseq = 1+Quotient[#,#+1,1]&@seq; > Can anyone do better? > Carl Woll === Subject: Re: Challenge: Fastest method to convert positive integers to 1 in a long list Carl K. Woll schrieb im Newsbeitrag > Hi all, > Inspired by the recent thread on counting runs, I have the following > challenge. Come up with a method to convert all the positive integers in a > long sequence of nonnegative integers to 1, so that the sequence consists of > only 0s and 1s. Let the sequence be given by > seq = Table[Random[Integer, 10], {10^6}]; > Then, one technique is > newseq = 1+Quotient[#,#+1,1]&@seq; > Can anyone do better? Sign[seq] Eckhard -- Dr.-Ing. Eckhard Hennig www.kaninkolo.de/ai aidev at kaninkolo dot de === Subject: Help in solving PDF equations Sorry for making mistake in typing in last mail. Here comes the right one: Could anybody please help me in solving the following PDF equation? (p + E * (1 + (Derivative[1, 0][f][x, t])^2)^(1.5)/Derivative[2, 0][f][x, t]) )*(1- (Derivative[1, 0][f][x, t])^2)/Sqrt[1 + (Derivative[1, 0][f][x, t])^2] - k * Derivative[0, 1][f][x, t]==0 with initial or boundary conditions being f[x, 0] == -r Derivative[0, 1][f][x, 0] == p/k Derivative[1, 0][f][R0, t] == 0 f[x, t] == If[0<= x <=r, Sqrt[r^2 - x^2]] where, E, p, k, R0 and r are constants. Wei === Subject: Substitute values in functions!!! Hallo! How can substitute some values(the zeros of BesselJ function) in this Integrals? j0[n_] := x /. FindRoot[BesselJ[0, x] == 0, {x, n 2.5}] !(s_l = Array[j0, 10]) Integrate[BesselJ[0,s0*r/R] BesselJ[0,s2*r/R]BesselJ[0,s3*r/R],{r,0,R}] where s0, s1,s2,the Zero-Poles of BesselJ. === Subject: Re: Substitute values in functions!!! > How can substitute some values(the zeros of BesselJ function) in this > Integrals? > j0[n_] := x /. FindRoot[BesselJ[0, x] == 0, {x, n 2.5}] Change this to j0[n_] := FindRoot[BesselJ[0, x] == 0, {x, n*2.5}] so that the result is a replacement rule instead of a value. > !(s_l = Array[j0, 10]) > Integrate[BesselJ[0,s0*r/R] BesselJ[0,s2*r/R] BesselJ[0,s3*r/R],{r,0,R}] By a change of variables r -> R r, this integral becomes R Integrate[BesselJ[0,s0 r] BesselJ[0,s2 r] BesselJ[0,s3 r],{r,0,1}] > where s0, s1,s2,the Zero-Poles of BesselJ. Substitute the first three zeros into the integrand: Times @@ (BesselJ[0, x r] /. Array[j0, 3]) Compute the integral numerically: R NIntegrate[%, {r, 0, 1}] Paul -- Paul Abbott Phone: +61 8 6488 2734 School of Physics, M013 Fax: +61 8 6488 1014 The University of Western Australia (CRICOS Provider No 00126G) 35 Stirling Highway Crawley WA 6009 mailto:paul@physics.uwa.edu.au AUSTRALIA http://physics.uwa.edu.au/~paul === Subject: Help in solving PDE equations Could anybody please help me in solving the following PDE equation? (p + E * (1 + (Derivative[1, 0][f][x, t])^2)^(1.5)/Derivative[2, 0][f][x, t]) )*(1- (Derivative[1, 0][f][x, t])^2)/Sqrt[1 + (Derivative[1, 0][f][x, t])^2] - k * Derivative[0, 1][f][x, t]==0 with initial or boundary conditions being f[x, 0] == -r Derivative[0, 1][f][x, 0] == p/k Derivative[1, 0][f][R0, t] == 0 f[x, t] == If[0<= x <=r, Sqrt[r^2 - x^2]] where, E, p, k, R0 and r are constants. Wei === Subject: RE: 64 bit cpu and Mathematica on windows. I just bought a premier subscription/upgrade, and asked a sales representative some questions about this, because I'm toying with the idea of get a dual Opteron. I was told that the current release of Mathematica supports 64 bit on Linux, but is a Class B license (which is more expensive). In the next release (5.1, due out any day now), the 64-bit version will be reclassified as Class A. The news release referred to below, which specifically addresses the first technical computing platforms specifically optimized for the optimized Mathematica port outperforms a regular Linux version of and technical calculations.... I don't think the distro matters, except possibly for testing. Is that correct? Since I'm likely to get Fedora Core 3, I'll have to find out if Wolfram has tested it. Mike Melko -----Original Message----- === Subject: 64 bit cpu and Mathematica on windows. http://www.wolfram.com/news/amd64.html. I presume that this is the Linux (64 bit optimized) version . They have checked compatibility with SUSE Linux Enterprise Server 8 which supports 64 bit technology, hopefully this means that its OK on SUSE's desktop version; see http://www.suse.com/us/private/products/suse_linux/prof/64bit.html. So it looks as though a cheap 64 bit Mathematica is possible. Has anybody done it? Ian Quantica P/L >To see any improvement, I think you'll need a 64-bit version of Windows (not yet released) and a 64-bit version of Mathematica (also not released). >Bobby >>http://www.wolfram.com/news/sgiirix.html >>has info on sgi machines >>will Mathematica run faster on a windows machine with 64 bit cpu? >>like.. this one. >>http://www.emachines.com/products/products.html?prod=eMachines_T3256 >>that's only 600 bucks! >>or dooes wri need to release a new version of Mathematica that is optimized >>for 64bit windows cpu? >> === Subject: plot Point with several shapes ? Can Mathematica plot Point with different shapes ? I used colors to plot field (many points) in XY coordinates. I have to convert my pictures to black&white format === Subject: Re: plot Point with several shapes ? whiy not use Text[[FilledTriangleUp},{x,y}] or any other symbol from the Mathematica fonts ?? Jens > Can Mathematica plot Point with different shapes ? > I used colors to plot field (many points) in XY coordinates. > I have to convert my pictures to black&white format === Subject: Re: plot Point with several shapes ? Yes, Look the MultipleListPlot in the add-ons and you will see thing there like: In[7]:= MultipleListPlot[list1, list2, PlotStyle -> {GrayLevel[0], Dashing[{Dot, Dash}]}, SymbolShape -> {PlotSymbol[Triangle], PlotSymbol[Box]}, SymbolStyle -> {GrayLevel[0], GrayLevel[.5]}] J.87nos > Can Mathematica plot Point with different shapes ? > I used colors to plot field (many points) in XY coordinates. > I have to convert my pictures to black&white format ---------------------------------------------- Trying to argue with a politician is like lifting up the head of a corpse. (S. Lem: His Master Voice) === Subject: Re: plot Point with several shapes ? > Can Mathematica plot Point with different shapes ? > I used colors to plot field (many points) in XY coordinates. > I have to convert my pictures to black&white format Hi Olaf, AFAIK there is an option SymbolShape for the Function Graphics`MultipleListPlot` (see documentation). Hope this helps -- Peter Pein 10245 Berlin === Subject: the circle map I've done a lot of searches on chaos and Mathematica and have never seem this. It is sensative chaos , in both the angle based a0 and the initial starting point. The circle was used by Chua as a starting point in his lectures on Chaos. Clear[x,y,a,b,s,g,a0] (* circle map: from Chaos in Digital Filters ,Chua,Lin, IEEE transactions on Circuits and Systems,vol 35 no 6 June 1988*) (* very sensitive to intial conditions*) a0=Cos[Pi/6]/2; x[n_]:=x[n]=Mod[-a0*x[n-1]-y[n-1],1] y[n_]:=y[n]=Mod[x[n-1],1] x[0]=0.7;y[0]=.65; a=Table[{x[n],y[n]},{n,0, 10000}]; ListPlot[a, PlotRange->All] Respectfully, Roger L. Bagula tftn@earthlink.net, 11759Waterhill Road, Lakeside,Ca 92040-2905,tel: 619-5610814 : alternative email: rlbtftn@netscape.net URL : http://home.earthlink.net/~tftn === Subject: Re: Re: the circle map The mapping {x,y} -> {-a x - y, x} (without Mod or FractionalPart) has determinant one and maps an ellipse into itself for any starting point: Clear[p]; a = 0.41209; m = {{-a, -1}, {1, 0}}; p[n_] := p[n] = m.p[n - 1] p[0] = {0.7, .65}; data = Table[p@n, {n, 0, 10000}]; short = Take[data, 10]; ListPlot[data, PlotRange -> All] Show[Graphics@{Text @@@ Transpose@{Range@Length@short, short}}, Axes -> False] The same thing occurs with Fractional Part, but there are false starts (transient behavior) until the series reaches a point whose corresponding ellipse falls entirely within the square -1 All] Show[Graphics@{Text @@@ Transpose@{Range@Length@short, short}}, Axes -> False] Mod[#,1]& clips to a different square, 0 < x < 1, 0 < y < 1, and it adds numerical instability -- hence the fractal nature. 1139 points isn't enough to see any fractal behavior at all, but the next two points leave the original ellipse behind. (They're at edges of the unit square.) Things get crazy after that. Clear[p]; a = 0.41209; m = {{-a, -1}, {1, 0}}; p[n_] := p[n] = Mod[m.p[n - 1], 1] p[0] = {0.7, .65}; data = Table[p@n, {n, 0, 10000}]; limited = Take[data, 1139]; firstFractal = Take[data, 1141]; ListPlot[data, PlotRange -> All] ListPlot[limited, PlotRange -> All] ListPlot[firstFractal, PlotRange -> All] Points outside the initial ellipse are mapped into OTHER ellipses, but they keep escaping to start new ones. When and if numerical instability occurs depends on p[0] as well as a. Changing a to 0.41208 destroys it, at least in the first 175000 entries (I checked). But change p[0] slightly, and it's back: Clear[p]; a = 0.41208; m = {{-a, -1}, {1, 0}}; p[n_] := p[n] = Mod[m.p[n - 1], 1] p[0] = {0.71, .65}; data = Table[p@n, {n, 0, 10000}]; ListPlot[data, PlotRange -> All] Fitting data to an ellipse isn't too hard: Clear[a, b, c, p]; m = {{-0.41209, -1}, {1, 0}}; p[n_] := p[n] = m . p[n - 1] p[0] = {0.7, 0.65}; data = Table[p[n], {n, 0, 1000}]; onePtError[a_, b_, c_][ {x_, y_}] := (a*x^2 + b*x*y + c*y^2 - 1)^2 error[a_, b_, c_] := Total[onePtError[a, b, c] /@ data] NMinimize[error[a, b, c], {a, b, c}] b/a /. Last[%] {3.0907663843655494*^-28, {a -> 0.9090901239676206, b -> 0.3746269491858168, c -> 0.9090901239676206}} 0.41209000000000007 b/a is the upper-left entry of the m matrix (the original a0), and c == a, so we can do it this way: onePtError[a_, b_][{x_, y_}] := (x^2 + b*x*y + y^2 - a)^2 error[a_, b_] := Total[onePtError[a, b] /@ data] NMinimize[error[a, b], {a, b}] {3.8495156975525818*^-28, {a -> 1.1000009499999996, b -> 0.41209}} We can solve for the ellipse's RHS this way, too: x^2 + b*x*y + y^2 == a /. Thread[{x, y} -> p[0]] /. b -> 0.41209 1.10000095 == a When FractionalPart is used to define p[n], NMinimize still works perfectly if transient points at the beginning of the series are omitted from the error definition. Bobby > Roger, > Can you tell me why is it that in the following code of yours: > Clear[x, y, n]; > a0 = 0.41209; > x[n_] := x[n] = Mod[-a0*x[n - 1] - y[n - 1], 1]; > y[n_] := y[n] = Mod[x[n - 1], 1] ; > x[0] = 0.7; > y[0] = .65; > a = Table[{x[n], y[n]}, {n, 0, 10000}]; > ListPlot[a, PlotRange -> All] ; > we get a fractal-like pic, but changing to a0 = 0.41208 we do not? > (And why is that replacing Mod[-,1] by FractionalPart[-] in the above > code will not give the same phenomenon? > Peter >> I've done a lot of searches on chaos >> and Mathematica and have never seem this. >> It is sensative chaos , in both the angle based a0 and the >> initial starting point. >> The circle was used by Chua as a starting point in his lectures on Chaos. >> Clear[x,y,a,b,s,g,a0] >> (* circle map: from Chaos in Digital Filters ,Chua,Lin, >> IEEE transactions on Circuits and Systems,vol 35 no 6 June 1988*) >> (* very sensitive to intial conditions*) >> a0=Cos[Pi/6]/2; >> x[n_]:=x[n]=Mod[-a0*x[n-1]-y[n-1],1] >> y[n_]:=y[n]=Mod[x[n-1],1] >> x[0]=0.7;y[0]=.65; >> a=Table[{x[n],y[n]},{n,0, 10000}]; >> ListPlot[a, PlotRange->All] >> Respectfully, Roger L. Bagula >> tftn@earthlink.net, 11759Waterhill Road, Lakeside,Ca 92040-2905,tel: 619-5610814 : >> alternative email: rlbtftn@netscape.net >> URL : http://home.earthlink.net/~tftn -- DrBob@bigfoot.com www.eclecticdreams.net === Subject: Re: the circle map Roger, Can you tell me why is it that in the following code of yours: Clear[x, y, n]; a0 = 0.41209; x[n_] := x[n] = Mod[-a0*x[n - 1] - y[n - 1], 1]; y[n_] := y[n] = Mod[x[n - 1], 1] ; x[0] = 0.7; y[0] = .65; a = Table[{x[n], y[n]}, {n, 0, 10000}]; ListPlot[a, PlotRange -> All] ; we get a fractal-like pic, but changing to a0 = 0.41208 we do not? (And why is that replacing Mod[-,1] by FractionalPart[-] in the above code will not give the same phenomenon? Peter > I've done a lot of searches on chaos > and Mathematica and have never seem this. > It is sensative chaos , in both the angle based a0 and the > initial starting point. > The circle was used by Chua as a starting point in his lectures on Chaos. > Clear[x,y,a,b,s,g,a0] > (* circle map: from Chaos in Digital Filters ,Chua,Lin, > IEEE transactions on Circuits and Systems,vol 35 no 6 June 1988*) > (* very sensitive to intial conditions*) > a0=Cos[Pi/6]/2; > x[n_]:=x[n]=Mod[-a0*x[n-1]-y[n-1],1] > y[n_]:=y[n]=Mod[x[n-1],1] > x[0]=0.7;y[0]=.65; > a=Table[{x[n],y[n]},{n,0, 10000}]; > ListPlot[a, PlotRange->All] > Respectfully, Roger L. Bagula > tftn@earthlink.net, 11759Waterhill Road, Lakeside,Ca 92040-2905,tel: 619-5610814 : > alternative email: rlbtftn@netscape.net > URL : http://home.earthlink.net/~tftn === Subject: Re: the circle map > Roger, > Can you tell me why is it that in the following code of yours: > Clear[x, y, n]; > a0 = 0.41209; > x[n_] := x[n] = Mod[-a0*x[n - 1] - y[n - 1], 1]; > y[n_] := y[n] = Mod[x[n - 1], 1] ; > x[0] = 0.7; > y[0] = .65; > a = Table[{x[n], y[n]}, {n, 0, 10000}]; > ListPlot[a, PlotRange -> All] ; > we get a fractal-like pic, but changing to a0 = 0.41208 we do not? This behaviour is typical for chaotic systems. See for instance http://mathworld.wolfram.com/LogisticMap.html > (And why is that replacing Mod[-,1] by FractionalPart[-] in the above > code will not give the same phenomenon? (#1[-a0*0.7 - 0.65] & ) /@ { Mod[#1, 1] & , FractionalPart } {0.06153699999999995, -0.938463} > Peter -- Peter Pein 10245 Berlin === Subject: Re: the circle map As I explained map is sensative to both the oringinal a0 ( angle) and the initial conditions. It is easy to get the dengerate circle, and not so easy to get some of the pretty effects This also a problem with the Martin map: I got in real trouble in a Martin map egroup I was in because I was trying to get the simple degenete sets, ha, ha. On the fractional part: I've always got : Mod[x.1]=x-Floor[x] to give the same output. If it doesn't, it may be one more problem with the Mod[x,1] algorithm in Mathematica ( to get Modulo ones where continued use of Sqrt[] are involved , you have to use N[ Mod[x,1], digits_accuracy]. It shouldn't be a problem where a number not a function is used like you have been doing. Mathematica has a bad habit of carrying what errors it does make on and building on them if exact numbers as symbols in a list are used. >Roger, >Can you tell me why is it that in the following code of yours: >Clear[x, y, n]; >a0 = 0.41209; >x[n_] := x[n] = Mod[-a0*x[n - 1] - y[n - 1], 1]; >y[n_] := y[n] = Mod[x[n - 1], 1] ; >x[0] = 0.7; >y[0] = .65; >a = Table[{x[n], y[n]}, {n, 0, 10000}]; >ListPlot[a, PlotRange -> All] ; >we get a fractal-like pic, but changing to a0 = 0.41208 we do not? >(And why is that replacing Mod[-,1] by FractionalPart[-] in the above >code will not give the same phenomenon? >Peter >>I've done a lot of searches on chaos >> and Mathematica and have never seem this. >>It is sensative chaos , in both the angle based a0 and the >>initial starting point. >>The circle was used by Chua as a starting point in his lectures on Chaos. >>Clear[x,y,a,b,s,g,a0] >>(* circle map: from Chaos in Digital Filters ,Chua,Lin, >> IEEE transactions on Circuits and Systems,vol 35 no 6 June 1988*) >> (* very sensitive to intial conditions*) >>a0=Cos[Pi/6]/2; >>x[n_]:=x[n]=Mod[-a0*x[n-1]-y[n-1],1] >>y[n_]:=y[n]=Mod[x[n-1],1] >>x[0]=0.7;y[0]=.65; >>a=Table[{x[n],y[n]},{n,0, 10000}]; >>ListPlot[a, PlotRange->All] >>Respectfully, Roger L. Bagula >>tftn@earthlink.net, 11759Waterhill Road, Lakeside,Ca 92040-2905,tel: 619-5610814 : >>alternative email: rlbtftn@netscape.net >>URL : http://home.earthlink.net/~tftn >> -- Respectfully, Roger L. Bagula tftn@earthlink.net, 11759Waterhill Road, Lakeside,Ca 92040-2905,tel: 619-5610814 : alternative email: rlbtftn@netscape.net URL : http://home.earthlink.net/~tftn === Subject: Re: Numerical Left Eigenvectors I happend to see ur question. I hope u have got the answer already. If not...Please follow the below... 1. Inverse the right matrix(R) in which the columns are right eigen vectors . 2. now this matrix will be the left matrix (L) in which all the rows are it`s left eigen vectors. Arun >When I use the eigenvector function to numerically calculate >eigenvectors, Mathematica seems to assume that I always want right >eigenvectors. Is there some way to numerically calculate left eigenvectors? >Greg Dwyer. >Entomology, UMASS Amherst >dwyer@ent.umass.edu === Subject: 100 digit base ten primes Clear[a,b,m,m0,m1,m3] (* program for finding primes near 100 digits long base 10 using Mersenne seed points*) (* cryptography length primes*) (* the logically most probable way someone taught*) (* traditional number theory might use find 100 digits primes*) (* short of using a sieve to 100 decimal places*) Table[N[Log[2^Prime[n]]/Log[10]],{n,1,68}] $MaxPrecision=Floor[Log[2^Prime[68]]/Log[10]]+1 m=2^Prime[67]-1 m0=Floor[m+Log[m]^2] (m0-m)/2 m1=2^Prime[68]-1 m3=Floor[m1+Log[m1]^2] (m3-m1)/2 a=Delete[Union[Table[If[PrimeQ[n]==True,n,0],{n,m,m0,2}]],1] Dimensions[a][[1]] (* 1/Log[n] probability test*) N[Dimensions[a][[1]]/((m0-m)/2)-1/Log[m0]] b=Delete[Union[Table[If[PrimeQ[n]==True,n,0],{n,m1,m3,2}]],1] Dimensions[b][[1]] N[Dimensions[b][[1]]/((m3-m1)/2)-1/Log[m3]] PrimeQ[m+Floor[Log[m]^2/2]]==True PrimeQ[m1+Floor[Log[m1]^2/2]]==True Respectfully, Roger L. Bagula tftn@earthlink.net, 11759Waterhill Road, Lakeside,Ca 92040-2905,tel: 619-5610814 : alternative email: rlbtftn@netscape.net URL : http://home.earthlink.net/~tftn === Subject: Re: 100 digit base ten primes The code below demonstrates several things: 1) Yes, there's at least one prime between n and n + Log[n]^2. In fact, there are MANY primes in the range when n is large. 2) The average of those limits (rounded to an integer) almost never delivers a prime number. (It didn't in your own examples.) Exactly half the time it's even, for instance. 3) Searching the entire range is silly if you're searching for a prime; why not stop at the first one you find? 4) The upper bound (and the theorem itself) is irrelevant to a practical search for primes. It puts a bound on how far you'll have to search, but knowing that doesn't change the search method in any way. On another note, Dimensions[a][[1]] is usually computed as Length@a, and evaluating PrimeQ[m+Floor[Log[m]^2/2]]==True is the same result as evaluating PrimeQ[m+Floor[Log[m]^2/2]] That's False in both cases from your post. Here's a test for exponents ranging from 1 to 100: f[n_] = n + Floor[Log[n]^2/2]; g[exp_] = 2^Prime[exp] - 1; select[exp_] := If[PrimeQ[f[g[exp]]], f[g[exp]], Sequence @@ {}] select /@ Range[100] Length[%] {3, 8231, 2361183241434822608057, 3064991081731777716716694054300618367237478244367212221} 4 That's four prime numbers in a hundred tries, no better than random, so let's try replacing f with something else: f[n_] = 2*n - 1; select /@ Range[100] Length[%] {5, 13, 61, 4093, 16381, 1048573, 16777213, 14272476927 05959881058285969449495136382746 621, 239452428260295134118491722 99223580994042798784118781} 9 Or better yet: f[n_]=Prime@n; select/@Range@13 Length@% {5,17,127,709,17851,84011,1742527,7754017,148948133,11891268397, 50685770143,3839726846299,67756520645293} 13 Thirteen out of thirteen. The fourteenth candidate is too large for Mathematica's implementation of Prime. Bobby > Clear[a,b,m,m0,m1,m3] > (* program for finding primes near 100 digits long base 10 using Mersenne > seed points*) > (* cryptography length primes*) > (* the logically most probable way someone taught*) > (* traditional number theory might use find 100 digits primes*) > (* short of using a sieve to 100 decimal places*) > Table[N[Log[2^Prime[n]]/Log[10]],{n,1,68}] > $MaxPrecision=Floor[Log[2^Prime[68]]/Log[10]]+1 > m=2^Prime[67]-1 > m0=Floor[m+Log[m]^2] > (m0-m)/2 > m1=2^Prime[68]-1 > m3=Floor[m1+Log[m1]^2] > (m3-m1)/2 > a=Delete[Union[Table[If[PrimeQ[n]==True,n,0],{n,m,m0,2}]],1] > Dimensions[a][[1]] > (* 1/Log[n] probability test*) > N[Dimensions[a][[1]]/((m0-m)/2)-1/Log[m0]] > b=Delete[Union[Table[If[PrimeQ[n]==True,n,0],{n,m1,m3,2}]],1] > Dimensions[b][[1]] > N[Dimensions[b][[1]]/((m3-m1)/2)-1/Log[m3]] > PrimeQ[m+Floor[Log[m]^2/2]]==True > PrimeQ[m1+Floor[Log[m1]^2/2]]==True > Respectfully, Roger L. Bagula > tftn@earthlink.net, 11759Waterhill Road, Lakeside,Ca 92040-2905,tel: 619-5610814 : > alternative email: rlbtftn@netscape.net > URL : http://home.earthlink.net/~tftn === Subject: RE: 64 bit cpu and Mathematica on windows. Another note: The page linked to below, namely http://www.emachines.com/products/products.html?prod=eMachines_T3256 Is for a PC with an Athlon XP processor, which, I'm pretty sure, is Athlon 64. If I'm not mistaken, this is a 32-bit CPU that supports could run 64-bit (and 32-bit) Mathematica on it, but it would be slower I've been shopping around a little , and this this the settup I http://www.micronux.com/catalog/product.php?products_id=168 Properly configured, this would be about $1,500. Mike Melko -----Original Message----- === Subject: 64 bit cpu and Mathematica on windows. http://www.wolfram.com/news/amd64.html. I presume that this is the Linux (64 bit optimized) version . They have checked compatibility with SUSE Linux Enterprise Server 8 which supports 64 bit technology, hopefully this means that its OK on SUSE's desktop version; see http://www.suse.com/us/private/products/suse_linux/prof/64bit.html. So it looks as though a cheap 64 bit Mathematica is possible. Has anybody done it? Ian Quantica P/L >To see any improvement, I think you'll need a 64-bit version of Windows (not yet released) and a 64-bit version of Mathematica (also not released). >Bobby >>http://www.wolfram.com/news/sgiirix.html >>has info on sgi machines >>will Mathematica run faster on a windows machine with 64 bit cpu? >>like.. this one. >>http://www.emachines.com/products/products.html?prod=eMachines_T3256 >>that's only 600 bucks! >>or dooes wri need to release a new version of Mathematica that is optimized >>for 64bit windows cpu? >> === Subject: Newly Released Mathematica 5.1 Delivers Unmatched Performance for Handling Data Newly Released Mathematica 5.1 Delivers Unmatched Performance for Handling Data Mathematica 5.1, the data functions release, is now available from Wolfram Research. Building on Mathematica 5's dramatic speed, scope, and scalability improvements, Version 5.1 adds a host of new capabilities, especially for working with large-scale, diverse types of data. There are more than 50 new functions, toolkits, and performance improvements in Mathematica 5.1. Highlights include: * Industrial-strength string manipulation * Built-in universal database connectivity * Highly optimized binary data I/O * Additional import-export formats, including XLS and AVI * Integrated web services support * 2D and 3D automated network visualization * High-performance array visualization * Numerical linear algebra performance enhancements * Fully integrated piecewise functions * Integration over implicitly defined regions * Event handling in numerical differential equations * New algorithms for symbolic differential equations * Cluster analysis capabilities added * Interactive exploration tool for differential equations * MathematicaMark benchmarking tool * GUIKit interface and application builder--now built in * and many more innovations Complementing these new capabilities are enhancements to Mathematica's unique automatic algorithm selection--the inherent intelligence that automatically applies the best algorithm to each task. Mathematica 5.1 adds more algorithms and better intelligence in a number of key areas, producing accurate results even faster than before. For more information, please visit: http://www.wolfram.com/mathematica === Subject: Re: Re: Newly Released Mathematica 5.1 Delivers Unmatched Performance for Handling Data Don't know about the other problems, but the rotated text on the mac is still not fixed. I believe that in the (yet unannounced) version 6, the Mac front end will finally abandon QuickDraw (which is deprecated) in favor of Quartz. There should be other changes as well to the graphics rendering. george > New features and better algorithms are great, but does anyone know if > they've fixed any bugs in this release? Things like > The rotated text bug on Macs where labels on the y-axis of frames are > garbled. > The instability in large eigenvalue calculations, which sometimes make > it impossible to interrupt the kernel and other times cause the kernel > to unexpectedly quit. > The feature where Mathematica uses a non-standard character > encoding, so that text in graphics is garbled when imported into some > other programs, like Illustrator. > I'm excited about cluster analysis, but I can't bring myself to fork > over any more money to Stephen Wolfram until simple problems which > have existed for years are fixed. > -Tim === Subject: Re: Newly Released Mathematica 5.1 Delivers Unmatched Performance for Handling Data New features and better algorithms are great, but does anyone know if they've fixed any bugs in this release? Things like The rotated text bug on Macs where labels on the y-axis of frames are garbled. The instability in large eigenvalue calculations, which sometimes make it impossible to interrupt the kernel and other times cause the kernel to unexpectedly quit. The feature where Mathematica uses a non-standard character encoding, so that text in graphics is garbled when imported into some other programs, like Illustrator. I'm excited about cluster analysis, but I can't bring myself to fork over any more money to Stephen Wolfram until simple problems which have existed for years are fixed. -Tim === Subject: Re: Newly Released Mathematica 5.1 Delivers Unmatched Performance for Handling Data > Newly Released Mathematica 5.1 Delivers Unmatched Performance > for Handling Data > [...] > For more information, please visit: > http://www.wolfram.com/mathematica In the pdf download Addendum to the Mathematica book, 5th edition: A guide to the new functions and features introduced in Mathematica 5.1, the heading on page iii is Features New in Mathematica Version 5.1, but the entry in the Index, p 67, is 6, new features in, iii. What's going on? === Subject: Lucas Lehmer prime Mersenne test The real problem with this test is that Mersenne number are grossly big, but the Lucas-Lehmer test recurrence is just bigger much too fast. I can't get it above n=8 in real time. The Lucas -Lehmer numbers are always ending in 4 and divisible by 2. Clear[s,a,b] (* Lucas Lehmer prime Mersenne test*) s[n_]:=s[n]=s[n-1]^2-2 s[1]=4 digits=8 a=Table[s[n],{n,1,8}] {4,14,194,37634,1416317954,2005956546822746114, 4023861667741036022825635656102100994, 16191462721115671781777559070120513664958590125499158514329308740975788034} a/2 {2,7,97,18817,708158977,1002978273411373057, 2011930833870518011412817828051050497, 8095731360557835890888779535060256832479295062749579257164654370487894017} (* Lucas -Lehmer test applied to Mersenne numbers*) b=Table[If[Mod[s[Prime[n]-1],2^Prime[n]-1]==0, 2^Prime[n]-1,0],{n,1,digits}] Respectfully, Roger L. Bagula tftn@earthlink.net, 11759Waterhill Road, Lakeside,Ca 92040-2905,tel: 619-5610814 : alternative email: rlbtftn@netscape.net URL : http://home.earthlink.net/~tftn === Subject: Mathematica 2.0 on xp? Sorry for what may be an FAQ, but I own a copy of Mathematica 2.0 which I was hoping to dust off and run some calculations. Trouble is, although it installs on my machine (or seems to), as soon as I try to run the kernel, I get an error message saying that Mathematica can't locate the kernel. I'm guessing that my Mathematica 2.0 just isn't supported any more and this isn't going to work, but thought I'd at least ask. Any thoughts? Andrew === Subject: Re: plot Point with several shapes ? Hi Olaf, > Can Mathematica plot Point with different shapes ? > I used colors to plot field (many points) in XY coordinates. > I have to convert my pictures to black&white format Yes it can. The package you want is Graphics`MultipleListPlot`. Online help gives a number of examples. Dave. === Subject: Re: Recursion Limit & Symbolic Differentiation Since you did not send the function and how you try to differentiate it I'm submitting a basic response Say your function is defined as f[x_,y_,z_]:=Sin[x y z]; Use Dt for total derivative Dt[f[x, y, z]] and get Cos[x y z] (y z Dt[x] + x z Dt[y] + x y Dt[z]) This assumes that x, y and z may be functions of other variables For partial derivatives use D[ ], for example differentiate the given Sin[x y z] according to x D[f[x, y, z], x] and get y z Cos[x y z] I know this is VERY basic but I hope this helps yehuda >I'm new to Mathemtica and I'm trying to differentiate a multi-variable >function >f(x,y,z). When doing so I get a recusion limit 256 reached message. >When examining my equations, I don't see recursion in the expressions. >It should be simple substitution of one expression into the other. >(Its just easier for me to write it that way). >How do I know if this is a valid message, and how do I know if my >expressions will actually be solved / simplified by Mathematica if I >increase the recursion limit? >memory and stops trying to solve the problem. === Subject: Recursion Limit & Symbolic Differentiation I'm new to Mathemtica and I'm trying to differentiate a multi-variable function f(x,y,z). When doing so I get a recusion limit 256 reached message. When examining my equations, I don't see recursion in the expressions. It should be simple substitution of one expression into the other. (Its just easier for me to write it that way). How do I know if this is a valid message, and how do I know if my expressions will actually be solved / simplified by Mathematica if I increase the recursion limit? memory and stops trying to solve the problem. === Subject: Re: Recursion Limit & Symbolic Differentiation > I'm new to Mathemtica and I'm trying to differentiate a multi-variable > function > f(x,y,z). When doing so I get a recusion limit 256 reached message. > When examining my equations, I don't see recursion in the expressions. > It should be simple substitution of one expression into the other. > (Its just easier for me to write it that way). > How do I know if this is a valid message, and how do I know if my > expressions will actually be solved / simplified by Mathematica if I > increase the recursion limit? > memory and stops trying to solve the problem. It would help us to help you, if you sent the definition of the function you're trying to differentiate... -- Peter Pein 10245 Berlin