A47 == This has been a frequent question on MathGroup.Basically the purpose of N is to convert an exact number to an approximatenumber. If the approximate number is machine precision, then by default itnow displays with 6 places. You can change that with the Option Inspector.If the approximation is extended precision, then it displays with theindicated precision.The proper command for output formatting of numbers is NumberForm.David Parkdjmp@earthlink.nethttp://home.earthlink.net/~djmp/ andUsing SetPrecision[Sqrt[2.],16] I could make Mathematica4.1 give me 16digits precision.Ideas?Peter W ==== Another in a series of potentially simple questions: What is the difference between using Fit and Interpolation?f[x_]=Fit[data, {1,x},x]-or-f[x_]=Interpolation[data][x]I do know that Fit can take arguments for the independant variablesform like:f[x_]=Fit[data, {1,x},x]f[x_]=Fit[data, {1,x,x^2},x]but that's a bit of guesswork if you have a limited set of points, no?Also, is there a function in Mathematica that allows me to swapDavid SeruyangeStudent ==== I want to make a matrix of derivations, so I will be able to multiplyit by a matrix of functions and get the result matrixsimple example:|d/dx 0 | |xy x| |y 1|| |.| |=| ||d/dy d/dx| |x+y 3| |x+1 0| thank you ==== i have a problem by creating a package. I need routines from anotherpackage, such that i use the followinglines at beginning of the package fileBeginPackage[Seismo`Hazard`PSHA`]Needs[Statistics` ContinuousDistributions`]If i load the package with<< Seismo`Hazard`PSHA`in a notebook everything works, but if i load it a second time (e.g. afterchanging something in the code) and calling one of the modulesthere are error messages produced like the following:Random::randt: Type specificationshould be Real, Integer, or Complex.The same message is produced by loading the package the first time andusingBeginPackage[Seismo`Hazard`PSHA`,{Statistics` ContinuousDistributions`}]Does anybody has a hint what i make wrong??Jan Schmedes ==== I want to make a matrix of derivations, so I will be able to multiplyit by a matrix of functions and get the result matrixsimple example:|d/dx 0 | |xy x| |y 1|| |.| |=| ||d/dy d/dx| |x+y 3| |x+1 0| thank you ==== I don't quite understand what you mean by processing unrelated numbers, but ...first of all , you can just map your test function onto range of integers, e.g.And @@ (PrimePi[2#] - PrimePi[#] çí 1 & /@ Prime/@Range[2,100])TrueOf course if you want to know the actual difference you can use:In[17]:=PrimePi[2#]-PrimePi[#]&/@Prime/@Range[2,100]Out[ 17]={ 1,1,2,3,3,4,4,5,6,7,9,9,9,9,11,13,12,13,14,13,15,15,16,19,20,1 9,19,18,1 8,23, 23,25,25,27,26,28,28,28,28,30,30,32,32,32,32,35,38,38,38,39,39 ,39,41,42, 43,42, 42,42,42,42,44,49,50,49,49,54,54,56,55,55,55,57,58,59,59,60,60 ,60,61,64, 64,66,66,66,67,67,68,68,67,67,70,71,71,73,72,73,77,76,80} and of course lots of different variants of this.Andrzej KozlowskiYokohama, Japanhttp://www.mimuw.edu.pl/~akoz/http:// platon.c.u-tokyo.ac.jp/andrzej/ ==== Bob,(PrimePi[2#]-PrimePi[# ]&) /@ x {1, 1, 1, 2, 3, 5, 9, 15, 28, 49, 90, 163, 302, 456}I get:{2 x, 3 x, 5 x, 7 x, 13 x, 23 x, 43 x, 83 x, 163 x, 317 x, 631 x, 1259 x, 2503 x, 4001 x}Have I mis-applied your code?NestWhile ==== Hmm... Your statement of your problem and the function agree but are not equivalent toPrimePi[2x]-PrimePi[x].Your function is PrimePi[2*list -list] = PrimePi[list] which is not equal to PrimePi[2*list]-PrimePi[list]Clearly, the answer to your question is yes. A more specific answer depends on exactly what you mean by process.If process feed numbers to a function of n arguements m times then a better solution might beMapThread[f, {list1, list2, .... listn}] ==== http://support.wolfram.com/mathematica/interface/ notebooks/setdefaultnotebooksize.html-Dale ==== This is what SeedRandom is for, e.g.SeedRandom[5];Table[Random[Integer,{1,10}],{3}]{2,3,2}Now evaluating again:SeedRandom[5];Table[Random[Integer,{1,10}],{3}]{2,3,2} Andrzej KozlowskiYokohama, Japanhttp://www.mimuw.edu.pl/~akoz/http:// platon.c.u-tokyo.ac.jp/andrzej/ ==== perhaps the function SeedRandom may help you.GreetingsJan Schmedes ==== Donald, SeedRandom[0];n=Random[];{n,n} {0.0318536,0.0318536} SeedRandom[0];n=Random[];{n,n} {0.0318536,0.0318536}--Allan---------------------Allan HayesMathematica Training and ConsultingLeicester UKhay@haystack.demon.co.ukVoice: +44 (0)116 271 4198 ==== Donald,Putmyrandom = Random[]and it will be fixed once and for all. But then why use Random at all? Youprobably want to run different cases, each with a different random number.Then use...With[{myrandom = Random[]},code using myrandom]Then myrandom is fixed once and replaced in all its instances in the code.For example...With[{myrandom = Random[]}, {myrandom, myrandom}]{0.655465, 0.655465}David Parkdjmp@earthlink.nethttp://home.earthlink.net/~djmp/Sender: steve@smc.vnet.net ==== Try using = instead of :=.r = Random[];Then use r throughout the program. Using r := Random[] (or just Random[])instead would cause a fresh random number to be sampled each time r appears.Rob PrattDepartment of Operations ResearchThe University of North Carolina at Chapel Hillhttp://www.unc.edu/~rpratt/ ==== Use SeedRandom to seed the random number generator in a controlled way.--Steve LuttrellWest Malvern, UK ==== Try using = instead of :=.r = Random[];Then use r throughout the program. Using r := Random[] (or just Random[])instead would cause a fresh random number to be sampled each time r appears.Rob PrattDepartment of Operations ResearchThe University of North Carolina at Chapel Hillhttp://www.unc.edu/~rpratt/Rob - This doesn't work for me. If I tryF[n_]=Table[Random[Real,{-1,1}],{n}]I get a different sequence for F[5] each time I use it. Don Darling ==== The code I suggested does work for a single random number.Your command to obtain and remember a random n-vector yields an errormessage. Try the code below. The first call to F[5] assigns a random5-vector to F[5]. Subsequent calls to F[5] just look up the stored value.In[1]:= F[n_] := F[n] = Table[Random[Real, {-1, 1}], {n}]In[2]:= F[5]Out[2]= {0.601045, -0.776375, -0.269912, -0.172019, -0.589347}In[3]:= F[5]Out[3]= {0.601045, -0.776375, -0.269912, -0.172019, -0.589347}Rob PrattDepartment of Operations ResearchThe University of North Carolina at Chapel Hillhttp://www.unc.edu/~rpratt/ ==== Ray: Ted Ersek has written a package, SwitchableRealOnly, that doeswhat you wish. You can read about it athttp://library.wolfram.com/database/MathSource/560/. Best, HarveyHarvey P. DaleUniversity Professor of Philanthropy and the LawDirector, National Center on Philanthropy and the LawNew York University School of LawRoom 206A110 West 3rd StreetNew York, N.Y. 10012-1074-----Original Message-----Sender: steve@smc.vnet.net ==== Ray,Ted Ersek has a package called SwitchableRealOnly that can be downloadedfrom MathSource. A nice package.David Parkdjmp@earthlink.nethttp://home.earthlink.net/~djmp/Sender: steve@smc.vnet.net ==== Ray,Here is a modification of a posting by Bob Hanlon in Sept 2000. RealOnly /: On[RealOnly] := Needs[ Miscellaneous`RealOnly`]; RealOnly /: Off[RealOnly] := (Unprotect[Power, Solve, Roots]; Clear[Power, Solve, Roots]; Protect[Power, Solve, Roots]; Remove[Miscellaneous`RealOnly`Nonreal]; $Post =. )Check (-1.)^(1/3) 0.5 + 0.8660254037844387*I On[RealOnly] (-1.)^(1/3) -1. Off[RealOnly] (-1.)^(1/3) 0.5 + 0.8660254037844387*I--Allan---------------------Allan HayesMathematica Training and ConsultingLeicester UKhay@haystack.demon.co.ukVoice: +44 (0)116 271 4198 ==== My friend Rip Pelletier pointed me to a better method to illustrate theCauchy-Riemann relations for analytic functions. He pointed me to TristanNeedham's book Visual Complex Analysis. In Chapter 5, Section I -Cauchy-Riemann Revealed, the CR conditions are related to the complexmapping.If a small patch of squares are mapped by an analytic function, then they gointo another small patch in which all the squares have been amplified androtated in exactly the same way.Fortunately, we have the ComplexMap package in Mathematica and can easilyillustrate this for your functions. For example, for the Sin function...Needs[Graphics`ComplexMap`]With[ {x = 2, y = 2, del = 0.01, f = Sin}, Show[GraphicsArray[{CartesianMap[ Identity, {x - del, x + del, del/5}, {y - del, y + del, del/5}, CartesianMap[ f, {x - del, x + del, del/5}, {y - del, y + del, del/5},A square patch maps into a rotated square patch. Just change f and/or themapping points for other cases. Use a pure function for z^2.For a case that is not analytic, and so the CR relations do not hold, usef = # + 2Abs[#] &. The squares go to parallelograms.David Parkdjmp@earthlink.nethttp://home.earthlink.net/~djmp/R3=x^3 - 3 x y^2 ; I3= 3 x^2 y - y ^3 ;z3r=Plot3D[R3 , {x,-Pi,Pi},{y,-Pi,Pi} ];z3i=Plot3D[I3 , {x,-Pi,Pi},{y,-Pi,Pi} ];Plot[{x,x (-Sqrt[3]+2) , x (-Sqrt[3]-2) }, {x,-Pi,Pi} ];R2=Cosh[y] Sin[x] ; I2=Sinh[y] Cos[x] ;scr=Plot3D[R2,{x,-Pi/2,Pi/2},{y,-Pi/2,Pi/2}];sci=Plot3D[I2,{ x,-Pi/2,Pi/2},{y,-Pi/2,Pi/2}];Plot[{ArcTanh[Tan[x]]},{x,-Pi/2 ,Pi/2 }];--To contact in private, remove ==== One way that is at least simpler and faster then yours is just to use the NextPrime function in the << NumberTheory`NumberTheoryFunctions`In[1]:=<